generated from VLADIMIR/template
add time
This commit is contained in:
parent
36aaa49273
commit
b17599eb39
@ -147,6 +147,8 @@ message GetGameReq {}
|
||||
|
||||
message GetGameRsp {
|
||||
string state = 1;
|
||||
string startAt = 2;
|
||||
string endAt = 3;
|
||||
}
|
||||
|
||||
message GameStartReq {}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package models
|
||||
|
||||
type Game struct {
|
||||
StartTime int64
|
||||
EndTime int64
|
||||
State string
|
||||
StartTime string
|
||||
EndTime string
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func NewRepository(filepath string) (*Repository, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = db.Exec("CREATE TABLE IF NOT EXISTS games (id INTEGER PRIMARY KEY AUTOINCREMENT, state TEXT, startAt TIMESTAMP, endAt TIMESTAMP);")
|
||||
_, err = db.Exec("CREATE TABLE IF NOT EXISTS games (id INTEGER PRIMARY KEY AUTOINCREMENT, state TEXT, startAt TEXT, endAt TEXT);")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -185,33 +185,49 @@ func (r *Repository) GiveApplications(ctx context.Context, teamId int64, applica
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Repository) GetGame(ctx context.Context) (string, error) {
|
||||
rows, err := r.db.Query("select state from games limit 1")
|
||||
func (r *Repository) GetGame(ctx context.Context) (*models.Game, error) {
|
||||
rows, err := r.db.Query("select state, startAt, endAt from games limit 1")
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
state := ""
|
||||
game := &models.Game{}
|
||||
if rows.Next() {
|
||||
err := rows.Scan(&state)
|
||||
err := rows.Scan(&game.State, &game.StartTime, &game.EndTime)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
return state, nil
|
||||
return game, nil
|
||||
}
|
||||
|
||||
state = "NEW"
|
||||
_, err = r.db.Exec("insert into games (state) values ($1)", state)
|
||||
state := "NEW"
|
||||
_, err = r.db.Exec("insert into games (state, startAt, endAt) values ($1, '', '')", state)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
return state, nil
|
||||
game.State = state
|
||||
return game, nil
|
||||
}
|
||||
|
||||
func (r *Repository) GameUpdateState(ctx context.Context, state string) error {
|
||||
_, err := r.db.Exec("update games set state = $1", state)
|
||||
return err
|
||||
game, err := r.GetGame(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
switch state {
|
||||
case "RUN":
|
||||
if game.StartTime == "" {
|
||||
_, err := r.db.Exec("update games set state = $1, startAt = datetime('now', 'localtime')", state)
|
||||
return err
|
||||
}
|
||||
_, err := r.db.Exec("update games set state = $1", state)
|
||||
return err
|
||||
case "STOP":
|
||||
_, err := r.db.Exec("update games set state = $1, endAt = datetime('now', 'localtime')", state)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Repository) DeleteAllTeams(ctx context.Context) error {
|
||||
|
@ -41,11 +41,15 @@ func (s *Services) GiveApplications(ctx context.Context, req *proto.GiveApplicat
|
||||
}
|
||||
|
||||
func (s *Services) GetGame(ctx context.Context, _ *proto.GetGameReq) (*proto.GetGameRsp, error) {
|
||||
state, err := s.repository.GetGame(ctx)
|
||||
game, err := s.repository.GetGame(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
return &proto.GetGameRsp{State: state}, nil
|
||||
return &proto.GetGameRsp{
|
||||
State: game.State,
|
||||
StartAt: game.StartTime,
|
||||
EndAt: game.EndTime,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Services) GameStart(ctx context.Context, _ *proto.GameStartReq) (*proto.GameStartRsp, error) {
|
||||
|
@ -921,7 +921,9 @@ type GetGameRsp struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
State string `protobuf:"bytes,1,opt,name=state,proto3" json:"state,omitempty"`
|
||||
State string `protobuf:"bytes,1,opt,name=state,proto3" json:"state,omitempty"`
|
||||
StartAt string `protobuf:"bytes,2,opt,name=startAt,proto3" json:"startAt,omitempty"`
|
||||
EndAt string `protobuf:"bytes,3,opt,name=endAt,proto3" json:"endAt,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetGameRsp) Reset() {
|
||||
@ -963,6 +965,20 @@ func (x *GetGameRsp) GetState() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GetGameRsp) GetStartAt() string {
|
||||
if x != nil {
|
||||
return x.StartAt
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GetGameRsp) GetEndAt() string {
|
||||
if x != nil {
|
||||
return x.EndAt
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GameStartReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@ -1288,9 +1304,12 @@ var file_main_proto_rawDesc = []byte{
|
||||
0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x41,
|
||||
0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x61, 0x70, 0x70, 0x6c,
|
||||
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x0c, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x47,
|
||||
0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x22, 0x22, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x47, 0x61, 0x6d,
|
||||
0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x22, 0x52, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x47, 0x61, 0x6d,
|
||||
0x65, 0x52, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0x0e, 0x0a, 0x0c, 0x47, 0x61,
|
||||
0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x74,
|
||||
0x61, 0x72, 0x74, 0x41, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x74, 0x61,
|
||||
0x72, 0x74, 0x41, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6e, 0x64, 0x41, 0x74, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6e, 0x64, 0x41, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x47, 0x61,
|
||||
0x6d, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x22, 0x0e, 0x0a, 0x0c, 0x47, 0x61,
|
||||
0x6d, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x73, 0x70, 0x22, 0x2f, 0x0a, 0x0b, 0x47, 0x61,
|
||||
0x6d, 0x65, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x12, 0x20, 0x0a, 0x0b, 0x74, 0x69, 0x6d,
|
||||
|
@ -383,6 +383,12 @@
|
||||
"properties": {
|
||||
"state": {
|
||||
"type": "string"
|
||||
},
|
||||
"startAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"endAt": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1 +1 @@
|
||||
import{_ as o,c as s,a as t,o as a}from"./index-CdxbIVaR.js";const n={},c={class:"about"};function r(_,e){return a(),s("div",c,e[0]||(e[0]=[t("h1",null,"This is an about page",-1)]))}const l=o(n,[["render",r]]);export{l as default};
|
||||
import{_ as o,c as s,a as t,o as a}from"./index-C49JGeDk.js";const n={},c={class:"about"};function r(_,e){return a(),s("div",c,e[0]||(e[0]=[t("h1",null,"This is an about page",-1)]))}const l=o(n,[["render",r]]);export{l as default};
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
:root{--vt-c-white: #ffffff;--vt-c-white-soft: #f8f8f8;--vt-c-white-mute: #f2f2f2;--vt-c-black: #181818;--vt-c-black-soft: #222222;--vt-c-black-mute: #282828;--vt-c-indigo: #2c3e50;--vt-c-divider-light-1: rgba(60, 60, 60, .29);--vt-c-divider-light-2: rgba(60, 60, 60, .12);--vt-c-divider-dark-1: rgba(84, 84, 84, .65);--vt-c-divider-dark-2: rgba(84, 84, 84, .48);--vt-c-text-light-1: var(--vt-c-indigo);--vt-c-text-light-2: rgba(60, 60, 60, .66);--vt-c-text-dark-1: var(--vt-c-white);--vt-c-text-dark-2: rgba(235, 235, 235, .64);--main-color: rgba(34, 50, 60, 1);--second-color: rgb(136, 105, 31);--main-back-color: rgba(240, 240, 240, 1);--main-back-item-color: rgba(254, 254, 254, 1)}:root{--color-background: var(--vt-c-white);--color-background-soft: var(--vt-c-white-soft);--color-background-mute: var(--vt-c-white-mute);--color-border: var(--vt-c-divider-light-2);--color-border-hover: var(--vt-c-divider-light-1);--color-heading: var(--vt-c-text-light-1);--color-text: var(--vt-c-text-light-1);--section-gap: 160px}*,*:before,*:after{box-sizing:border-box;margin:0;font-weight:400}body{min-height:100dvh;color:var(--color-text);background:var(--main-back-color);transition:color .5s,background-color .5s;line-height:1.6;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:15px;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.header-block{height:50px;background-color:var(--main-color);font-size:large;color:#fff;vertical-align:middle;padding:10px 0 10px 16px;font-weight:700}.input-custom{width:100%;box-sizing:border-box;margin-bottom:15px}.button-custom{margin-left:auto;background-color:var(--main-color);font-weight:600;color:#fff}.button-custom:hover{background-color:var(--second-color)}.input-custom,.button-custom{padding:12px 16px;border:1px solid #ddd;border-radius:15px;font-size:16px}.button-container{display:flex}.center-message{display:flex;justify-content:center;align-items:center;height:calc(100dvh - 100px);text-align:center}header[data-v-e5db0c22]{line-height:1.5;max-height:100vh}.logo[data-v-e5db0c22]{display:block;margin:0 auto 2rem}nav[data-v-e5db0c22]{width:100%;font-size:12px;text-align:center;margin-top:2rem}nav a.router-link-exact-active[data-v-e5db0c22]{color:var(--color-text)}nav a.router-link-exact-active[data-v-e5db0c22]:hover{background-color:transparent}nav a[data-v-e5db0c22]{display:inline-block;padding:0 1rem;border-left:1px solid var(--color-border)}nav a[data-v-e5db0c22]:first-of-type{border:0}@media (min-width: 1024px){header[data-v-e5db0c22]{display:flex;place-items:center;padding-right:calc(var(--section-gap) / 2)}.logo[data-v-e5db0c22]{margin:0 2rem 0 0}header .wrapper[data-v-e5db0c22]{display:flex;place-items:flex-start;flex-wrap:wrap}nav[data-v-e5db0c22]{text-align:left;margin-left:-1rem;font-size:1rem;padding:1rem 0;margin-top:1rem}}body[data-v-8c48c65f]{font-family:Arial,sans-serif;margin:20px}.buttons-block[data-v-8c48c65f]{padding-top:20px}.button-menu[data-v-8c48c65f]{margin:5px}table[data-v-8c48c65f]{width:700px;border-collapse:collapse;margin:30px auto;border:1px solid #444444}th[data-v-8c48c65f],td[data-v-8c48c65f]{padding:12px;text-align:left}th[data-v-8c48c65f]{background-color:var(--main-color);color:#fff;font-weight:700}tr[data-v-8c48c65f]:nth-child(odd){background-color:#efefef}tr[data-v-8c48c65f]:nth-child(2n){background-color:#fff}tr[data-v-8c48c65f]:hover{background-color:#cfcfcf}.time[data-v-8c48c65f]{white-space:nowrap}.team-name[data-v-8c48c65f]{font-weight:600}.link-button[data-v-8c48c65f]{display:inline;border:none;background:none;padding:0;margin:0;font:inherit;cursor:pointer;color:var(--main-color);text-decoration:underline;font-weight:600;-webkit-appearance:none;-moz-appearance:none;appearance:none;line-height:inherit;text-align:left}.link-button[data-v-8c48c65f]:hover{color:var(--second-color);text-decoration:none}.link-button[data-v-8c48c65f]:active{color:#036}.link-button[data-v-8c48c65f]:focus{outline:none;text-decoration:none;box-shadow:0 0 0 2px #0066cc4d}.form-block[data-v-8c48c65f]{width:700px;margin:0 auto}a[data-v-8c48c65f]{color:var(--second-color);text-decoration:none;transition:all .2s ease;cursor:pointer}a[data-v-8c48c65f]:hover{text-decoration:underline;text-decoration-thickness:2px;text-underline-offset:3px}a[data-v-8c48c65f]:focus-visible{outline:2px solid #3182ce;outline-offset:2px;border-radius:2px}a[disabled][data-v-8c48c65f]{color:#a0aec0;pointer-events:none;cursor:not-allowed}.qr[data-v-8c48c65f]{position:absolute;top:80px;right:30px;text-align:center;width:120px}.button-container[data-v-8c48c65f]{margin-bottom:30px}
|
||||
:root{--vt-c-white: #ffffff;--vt-c-white-soft: #f8f8f8;--vt-c-white-mute: #f2f2f2;--vt-c-black: #181818;--vt-c-black-soft: #222222;--vt-c-black-mute: #282828;--vt-c-indigo: #2c3e50;--vt-c-divider-light-1: rgba(60, 60, 60, .29);--vt-c-divider-light-2: rgba(60, 60, 60, .12);--vt-c-divider-dark-1: rgba(84, 84, 84, .65);--vt-c-divider-dark-2: rgba(84, 84, 84, .48);--vt-c-text-light-1: var(--vt-c-indigo);--vt-c-text-light-2: rgba(60, 60, 60, .66);--vt-c-text-dark-1: var(--vt-c-white);--vt-c-text-dark-2: rgba(235, 235, 235, .64);--main-color: rgba(34, 50, 60, 1);--second-color: rgb(136, 105, 31);--main-back-color: rgba(240, 240, 240, 1);--main-back-item-color: rgba(254, 254, 254, 1)}:root{--color-background: var(--vt-c-white);--color-background-soft: var(--vt-c-white-soft);--color-background-mute: var(--vt-c-white-mute);--color-border: var(--vt-c-divider-light-2);--color-border-hover: var(--vt-c-divider-light-1);--color-heading: var(--vt-c-text-light-1);--color-text: var(--vt-c-text-light-1);--section-gap: 160px}*,*:before,*:after{box-sizing:border-box;margin:0;font-weight:400}body{min-height:100dvh;color:var(--color-text);background:var(--main-back-color);transition:color .5s,background-color .5s;line-height:1.6;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:15px;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.header-block{height:50px;background-color:var(--main-color);font-size:large;color:#fff;vertical-align:middle;padding:10px 0 10px 16px;font-weight:700}.input-custom{width:100%;box-sizing:border-box;margin-bottom:15px}.button-custom{margin-left:auto;background-color:var(--main-color);font-weight:600;color:#fff}.button-custom:hover{background-color:var(--second-color)}.input-custom,.button-custom{padding:12px 16px;border:1px solid #ddd;border-radius:15px;font-size:16px}.button-container{display:flex}.center-message{display:flex;justify-content:center;align-items:center;height:calc(100dvh - 100px);text-align:center}header[data-v-e5db0c22]{line-height:1.5;max-height:100vh}.logo[data-v-e5db0c22]{display:block;margin:0 auto 2rem}nav[data-v-e5db0c22]{width:100%;font-size:12px;text-align:center;margin-top:2rem}nav a.router-link-exact-active[data-v-e5db0c22]{color:var(--color-text)}nav a.router-link-exact-active[data-v-e5db0c22]:hover{background-color:transparent}nav a[data-v-e5db0c22]{display:inline-block;padding:0 1rem;border-left:1px solid var(--color-border)}nav a[data-v-e5db0c22]:first-of-type{border:0}@media (min-width: 1024px){header[data-v-e5db0c22]{display:flex;place-items:center;padding-right:calc(var(--section-gap) / 2)}.logo[data-v-e5db0c22]{margin:0 2rem 0 0}header .wrapper[data-v-e5db0c22]{display:flex;place-items:flex-start;flex-wrap:wrap}nav[data-v-e5db0c22]{text-align:left;margin-left:-1rem;font-size:1rem;padding:1rem 0;margin-top:1rem}}body[data-v-4e1da5de]{font-family:Arial,sans-serif;margin:20px}.buttons-block[data-v-4e1da5de]{padding-top:20px}.button-menu[data-v-4e1da5de]{margin:5px}table[data-v-4e1da5de]{width:700px;border-collapse:collapse;margin:30px auto;border:1px solid #444444}th[data-v-4e1da5de],td[data-v-4e1da5de]{padding:12px;text-align:left}th[data-v-4e1da5de]{background-color:var(--main-color);color:#fff;font-weight:700}tr[data-v-4e1da5de]:nth-child(odd){background-color:#efefef}tr[data-v-4e1da5de]:nth-child(2n){background-color:#fff}tr[data-v-4e1da5de]:hover{background-color:#cfcfcf}.time[data-v-4e1da5de]{white-space:nowrap}.team-name[data-v-4e1da5de]{font-weight:600}.link-button[data-v-4e1da5de]{display:inline;border:none;background:none;padding:0;margin:0;font:inherit;cursor:pointer;color:var(--main-color);text-decoration:underline;font-weight:600;-webkit-appearance:none;-moz-appearance:none;appearance:none;line-height:inherit;text-align:left}.link-button[data-v-4e1da5de]:hover{color:var(--second-color);text-decoration:none}.link-button[data-v-4e1da5de]:active{color:#036}.link-button[data-v-4e1da5de]:focus{outline:none;text-decoration:none;box-shadow:0 0 0 2px #0066cc4d}.form-block[data-v-4e1da5de]{width:700px;margin:0 auto}a[data-v-4e1da5de]{color:var(--second-color);text-decoration:none;transition:all .2s ease;cursor:pointer}a[data-v-4e1da5de]:hover{text-decoration:underline;text-decoration-thickness:2px;text-underline-offset:3px}a[data-v-4e1da5de]:focus-visible{outline:2px solid #3182ce;outline-offset:2px;border-radius:2px}a[disabled][data-v-4e1da5de]{color:#a0aec0;pointer-events:none;cursor:not-allowed}.qr[data-v-4e1da5de]{position:absolute;top:80px;right:30px;text-align:center;width:120px}.button-container[data-v-4e1da5de]{margin-bottom:30px}
|
@ -5,8 +5,8 @@
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>ВД Админка</title>
|
||||
<script type="module" crossorigin src="/assets/index-CdxbIVaR.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-C3dpn_mY.css">
|
||||
<script type="module" crossorigin src="/assets/index-C49JGeDk.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-D-LAc9ox.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user