From d335d0ac454fc9e49a8aaa54ec548fec1e9c0b5b Mon Sep 17 00:00:00 2001 From: Hamza Ali Date: Thu, 23 Dec 2021 10:09:24 +0700 Subject: [PATCH] feat: complete quest service implementation --- api/quest.go | 80 ++- api/v1/.gunkconfig | 5 +- api/v1/all.pb.go | 426 +++++++------- api/v1/all.pb.gw.go | 34 +- api/v1/gen/json/codequest/all.swagger.json | 38 +- api/v1/gen/ts/codequest/all_pb.d.ts | 528 ------------------ api/v1/quest.gunk | 20 +- cmd/gw/main.go | 10 +- cmd/srv/main.go | 5 +- db/quest.go | 22 +- gen.sh | 4 +- go.mod | 2 +- go.sum | 2 + models/partsdata.xo.go | 12 +- models/questionattempt.xo.go | 26 +- models/xo.xo.yaml | 2 +- question/data.go | 14 +- question/question.go | 4 +- sql/schema.sql | 2 +- .../codequest => web_src/lib/pb}/all.pb.ts | 15 +- .../codequest => web_src/lib/pb}/fetch.pb.ts | 0 21 files changed, 423 insertions(+), 828 deletions(-) delete mode 100644 api/v1/gen/ts/codequest/all_pb.d.ts rename {api/v1/gen/ts-gateway/codequest => web_src/lib/pb}/all.pb.ts (96%) rename {api/v1/gen/ts-gateway/codequest => web_src/lib/pb}/fetch.pb.ts (100%) diff --git a/api/quest.go b/api/quest.go index fa8dfb5..6dfbd67 100644 --- a/api/quest.go +++ b/api/quest.go @@ -5,9 +5,11 @@ import ( "context" "errors" "log" + "time" codequestpb "github.com/hhhapz/codequest/api/v1" "github.com/hhhapz/codequest/models" + "github.com/hhhapz/codequest/question" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" @@ -35,7 +37,7 @@ func (qs *QuestService) Questions(ctx context.Context, req *emptypb.Empty) (*cod for _, q := range questions { res.Questions = append(res.Questions, &codequestpb.Question{ - ID: q.QuestionID, + ID: q.Question.ID, Title: q.Name, Part1: &codequestpb.PartData{ Completed: q.Part1.Completed, @@ -70,7 +72,7 @@ func (qs *QuestService) QuestionByID(ctx context.Context, req *codequestpb.Quest } q := &codequestpb.Question{ - ID: question.QuestionID, + ID: question.Question.ID, Title: question.Name, Text: content.String(), Part1: &codequestpb.PartData{ @@ -87,9 +89,79 @@ func (qs *QuestService) QuestionByID(ctx context.Context, req *codequestpb.Quest } func (qs *QuestService) QuestionInput(ctx context.Context, req *codequestpb.QuestionInputRequest) (*codequestpb.QuestionInput, error) { - panic("not implemented") // TODO: Implement + u := UserCtx(ctx) + + question, err := qs.questStore.Question(ctx, u, req.ID) + if err != nil { + if errors.As(err, &models.UserError{}) { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + log.Printf("could not get question %s: %v", req.ID, err) + return nil, status.Errorf(codes.Internal, "could not get question: internal error") + } + + inp := question.Question.Generate(u) + + return &codequestpb.QuestionInput{ + ID: question.Question.ID, + Input: inp, + }, nil } func (qs *QuestService) Submit(ctx context.Context, req *codequestpb.SubmitRequest) (*codequestpb.SubmitResponse, error) { - panic("not implemented") // TODO: Implement + u := UserCtx(ctx) + + q, err := qs.questStore.Question(ctx, u, req.ID) + if err != nil { + if errors.As(err, &models.UserError{}) { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + return nil, status.Errorf(codes.Internal, "could not get question: internal error") + } + + data := req.Body + + completed, attempts, err := qs.questStore.Submissions(ctx, u, req.ID, question.Part(data.Part)) + if err != nil { + if errors.As(err, &models.UserError{}) { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + log.Printf("could not get submissions: %v", err) + return nil, status.Errorf(codes.Internal, "could not get submissions: internal error") + } + + if completed { + return nil, status.Errorf(codes.AlreadyExists, "question %s (part %d) already completed", req.ID, data.Part) + } + + // TODO: cooldowns + + correct := q.Question.Validate(u, question.Part(data.Part), data.Answer) + + var points int + if correct { + points = 5000 - (attempts * 100) + if points < 2000 { + points = 2000 + } + + } + + qa := &models.QuestionAttempt{ + UserID: u.ID, + QuestionID: q.Question.ID, + QuestionPart: int(data.Part), + Correct: correct, + PointsAwarded: points, + Answer: data.Answer, + Code: data.Code, + SubmittedAt: models.NewTime(time.Now()), + } + qs.questStore.AddSubmission(ctx, qa) + + res := &codequestpb.SubmitResponse{ + Correct: qa.Correct, + Points: int32(qa.PointsAwarded), + } + return res, nil } diff --git a/api/v1/.gunkconfig b/api/v1/.gunkconfig index 468ee29..73127a1 100644 --- a/api/v1/.gunkconfig +++ b/api/v1/.gunkconfig @@ -12,8 +12,5 @@ [generate openapiv2] out=./gen/json/{{ .Package }} -[generate ts] ; typescript - out=./gen/ts/{{ .Package }} - [generate grpc-gateway-ts] ; typescript - out=./gen/ts-gateway/{{ .Package }} + out=../../web_src/lib/pb diff --git a/api/v1/all.pb.go b/api/v1/all.pb.go index 2c1905a..8796b11 100644 --- a/api/v1/all.pb.go +++ b/api/v1/all.pb.go @@ -697,19 +697,18 @@ func (x *QuestionInput) GetInput() string { return "" } -type SubmitRequest struct { +type SubmitRequestData struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ID string `protobuf:"bytes,1,opt,name=ID,json=id,proto3" json:"id,omitempty"` - Answer string `protobuf:"bytes,2,opt,name=Answer,json=content,proto3" json:"content,omitempty"` - Part bool `protobuf:"varint,3,opt,name=Part,json=part,proto3" json:"part,omitempty"` + Answer string `protobuf:"bytes,2,opt,name=Answer,json=answer,proto3" json:"answer,omitempty"` + Part int32 `protobuf:"varint,3,opt,name=Part,json=part,proto3" json:"part,omitempty"` Code string `protobuf:"bytes,4,opt,name=Code,json=code,proto3" json:"code,omitempty"` } -func (x *SubmitRequest) Reset() { - *x = SubmitRequest{} +func (x *SubmitRequestData) Reset() { + *x = SubmitRequestData{} if protoimpl.UnsafeEnabled { mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -717,13 +716,13 @@ func (x *SubmitRequest) Reset() { } } -func (x *SubmitRequest) String() string { +func (x *SubmitRequestData) String() string { return protoimpl.X.MessageStringOf(x) } -func (*SubmitRequest) ProtoMessage() {} +func (*SubmitRequestData) ProtoMessage() {} -func (x *SubmitRequest) ProtoReflect() protoreflect.Message { +func (x *SubmitRequestData) ProtoReflect() protoreflect.Message { mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -735,53 +734,43 @@ func (x *SubmitRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SubmitRequest.ProtoReflect.Descriptor instead. -func (*SubmitRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use SubmitRequestData.ProtoReflect.Descriptor instead. +func (*SubmitRequestData) Descriptor() ([]byte, []int) { return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{12} } -func (x *SubmitRequest) GetID() string { - if x != nil { - return x.ID - } - return "" -} - -func (x *SubmitRequest) GetAnswer() string { +func (x *SubmitRequestData) GetAnswer() string { if x != nil { return x.Answer } return "" } -func (x *SubmitRequest) GetPart() bool { +func (x *SubmitRequestData) GetPart() int32 { if x != nil { return x.Part } - return false + return 0 } -func (x *SubmitRequest) GetCode() string { +func (x *SubmitRequestData) GetCode() string { if x != nil { return x.Code } return "" } -type SubmitResponse struct { +type SubmitRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ID string `protobuf:"bytes,1,opt,name=ID,json=id,proto3" json:"id,omitempty"` - Part int32 `protobuf:"varint,2,opt,name=Part,json=part,proto3" json:"part,omitempty"` - Correct bool `protobuf:"varint,3,opt,name=Correct,json=correct,proto3" json:"correct,omitempty"` - Ranking int32 `protobuf:"varint,4,opt,name=Ranking,json=ranking,proto3" json:"ranking,omitempty"` - Points int32 `protobuf:"varint,5,opt,name=Points,json=points,proto3" json:"points,omitempty"` + ID string `protobuf:"bytes,1,opt,name=ID,json=id,proto3" json:"id,omitempty"` + Body *SubmitRequestData `protobuf:"bytes,2,opt,name=Body,json=body,proto3" json:"body,omitempty"` } -func (x *SubmitResponse) Reset() { - *x = SubmitResponse{} +func (x *SubmitRequest) Reset() { + *x = SubmitRequest{} if protoimpl.UnsafeEnabled { mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -789,13 +778,13 @@ func (x *SubmitResponse) Reset() { } } -func (x *SubmitResponse) String() string { +func (x *SubmitRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*SubmitResponse) ProtoMessage() {} +func (*SubmitRequest) ProtoMessage() {} -func (x *SubmitResponse) ProtoReflect() protoreflect.Message { +func (x *SubmitRequest) ProtoReflect() protoreflect.Message { mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -807,37 +796,71 @@ func (x *SubmitResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SubmitResponse.ProtoReflect.Descriptor instead. -func (*SubmitResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use SubmitRequest.ProtoReflect.Descriptor instead. +func (*SubmitRequest) Descriptor() ([]byte, []int) { return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{13} } -func (x *SubmitResponse) GetID() string { +func (x *SubmitRequest) GetID() string { if x != nil { return x.ID } return "" } -func (x *SubmitResponse) GetPart() int32 { +func (x *SubmitRequest) GetBody() *SubmitRequestData { if x != nil { - return x.Part + return x.Body } - return 0 + return nil } -func (x *SubmitResponse) GetCorrect() bool { - if x != nil { - return x.Correct +type SubmitResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Correct bool `protobuf:"varint,3,opt,name=Correct,json=correct,proto3" json:"correct,omitempty"` + Points int32 `protobuf:"varint,5,opt,name=Points,json=points,proto3" json:"points,omitempty"` +} + +func (x *SubmitResponse) Reset() { + *x = SubmitResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return false } -func (x *SubmitResponse) GetRanking() int32 { +func (x *SubmitResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SubmitResponse) ProtoMessage() {} + +func (x *SubmitResponse) ProtoReflect() protoreflect.Message { + mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SubmitResponse.ProtoReflect.Descriptor instead. +func (*SubmitResponse) Descriptor() ([]byte, []int) { + return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{14} +} + +func (x *SubmitResponse) GetCorrect() bool { if x != nil { - return x.Ranking + return x.Correct } - return 0 + return false } func (x *SubmitResponse) GetPoints() int32 { @@ -860,7 +883,7 @@ type UpdateFields struct { func (x *UpdateFields) Reset() { *x = UpdateFields{} if protoimpl.UnsafeEnabled { - mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[14] + mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -873,7 +896,7 @@ func (x *UpdateFields) String() string { func (*UpdateFields) ProtoMessage() {} func (x *UpdateFields) ProtoReflect() protoreflect.Message { - mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[14] + mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[15] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -886,7 +909,7 @@ func (x *UpdateFields) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateFields.ProtoReflect.Descriptor instead. func (*UpdateFields) Descriptor() ([]byte, []int) { - return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{14} + return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{15} } func (x *UpdateFields) GetName() string { @@ -919,7 +942,7 @@ type UserRequest struct { func (x *UserRequest) Reset() { *x = UserRequest{} if protoimpl.UnsafeEnabled { - mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[15] + mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -932,7 +955,7 @@ func (x *UserRequest) String() string { func (*UserRequest) ProtoMessage() {} func (x *UserRequest) ProtoReflect() protoreflect.Message { - mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[15] + mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[16] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -945,7 +968,7 @@ func (x *UserRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UserRequest.ProtoReflect.Descriptor instead. func (*UserRequest) Descriptor() ([]byte, []int) { - return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{15} + return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{16} } type AllUsersRequest struct { @@ -957,7 +980,7 @@ type AllUsersRequest struct { func (x *AllUsersRequest) Reset() { *x = AllUsersRequest{} if protoimpl.UnsafeEnabled { - mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[16] + mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -970,7 +993,7 @@ func (x *AllUsersRequest) String() string { func (*AllUsersRequest) ProtoMessage() {} func (x *AllUsersRequest) ProtoReflect() protoreflect.Message { - mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[16] + mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[17] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -983,7 +1006,7 @@ func (x *AllUsersRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AllUsersRequest.ProtoReflect.Descriptor instead. func (*AllUsersRequest) Descriptor() ([]byte, []int) { - return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{16} + return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{17} } type UpdateUserRequest struct { @@ -998,7 +1021,7 @@ type UpdateUserRequest struct { func (x *UpdateUserRequest) Reset() { *x = UpdateUserRequest{} if protoimpl.UnsafeEnabled { - mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[17] + mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1011,7 +1034,7 @@ func (x *UpdateUserRequest) String() string { func (*UpdateUserRequest) ProtoMessage() {} func (x *UpdateUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[17] + mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[18] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1024,7 +1047,7 @@ func (x *UpdateUserRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateUserRequest.ProtoReflect.Descriptor instead. func (*UpdateUserRequest) Descriptor() ([]byte, []int) { - return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{17} + return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{18} } func (x *UpdateUserRequest) GetEmail() string { @@ -1052,7 +1075,7 @@ type UserByEmailRequest struct { func (x *UserByEmailRequest) Reset() { *x = UserByEmailRequest{} if protoimpl.UnsafeEnabled { - mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[18] + mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1065,7 +1088,7 @@ func (x *UserByEmailRequest) String() string { func (*UserByEmailRequest) ProtoMessage() {} func (x *UserByEmailRequest) ProtoReflect() protoreflect.Message { - mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[18] + mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[19] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1078,7 +1101,7 @@ func (x *UserByEmailRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UserByEmailRequest.ProtoReflect.Descriptor instead. func (*UserByEmailRequest) Descriptor() ([]byte, []int) { - return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{18} + return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{19} } func (x *UserByEmailRequest) GetEmail() string { @@ -1099,7 +1122,7 @@ type DeleteUserRequest struct { func (x *DeleteUserRequest) Reset() { *x = DeleteUserRequest{} if protoimpl.UnsafeEnabled { - mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[19] + mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1112,7 +1135,7 @@ func (x *DeleteUserRequest) String() string { func (*DeleteUserRequest) ProtoMessage() {} func (x *DeleteUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[19] + mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[20] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1125,7 +1148,7 @@ func (x *DeleteUserRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteUserRequest.ProtoReflect.Descriptor instead. func (*DeleteUserRequest) Descriptor() ([]byte, []int) { - return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{19} + return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{20} } func (x *DeleteUserRequest) GetEmail() string { @@ -1146,7 +1169,7 @@ type AllUsersResponse struct { func (x *AllUsersResponse) Reset() { *x = AllUsersResponse{} if protoimpl.UnsafeEnabled { - mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[20] + mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1159,7 +1182,7 @@ func (x *AllUsersResponse) String() string { func (*AllUsersResponse) ProtoMessage() {} func (x *AllUsersResponse) ProtoReflect() protoreflect.Message { - mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[20] + mi := &file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[21] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1172,7 +1195,7 @@ func (x *AllUsersResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AllUsersResponse.ProtoReflect.Descriptor instead. func (*AllUsersResponse) Descriptor() ([]byte, []int) { - return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{20} + return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP(), []int{21} } func (x *AllUsersResponse) GetUsers() []*User { @@ -1279,26 +1302,26 @@ var file_github_com_hhhapz_codequest_api_v1_all_proto_rawDesc = []byte{ 0x28, 0x00, 0x30, 0x00, 0x50, 0x00, 0x52, 0x02, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x05, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0x08, 0x00, 0x18, 0x00, 0x28, 0x00, 0x30, 0x00, 0x50, 0x00, 0x52, 0x05, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x3a, 0x06, 0x08, 0x00, - 0x10, 0x00, 0x18, 0x00, 0x22, 0x98, 0x01, 0x0a, 0x0d, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x52, + 0x10, 0x00, 0x18, 0x00, 0x22, 0x7f, 0x0a, 0x11, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x44, 0x61, 0x74, 0x61, 0x12, 0x22, 0x0a, 0x06, 0x41, 0x6e, 0x73, + 0x77, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0x08, 0x00, 0x18, 0x00, 0x28, + 0x00, 0x30, 0x00, 0x50, 0x00, 0x52, 0x06, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x12, 0x1e, 0x0a, + 0x04, 0x50, 0x61, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x42, 0x0a, 0x08, 0x00, 0x18, + 0x00, 0x28, 0x00, 0x30, 0x00, 0x50, 0x00, 0x52, 0x04, 0x70, 0x61, 0x72, 0x74, 0x12, 0x1e, 0x0a, + 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0x08, 0x00, 0x18, + 0x00, 0x28, 0x00, 0x30, 0x00, 0x50, 0x00, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x3a, 0x06, 0x08, + 0x00, 0x10, 0x00, 0x18, 0x00, 0x22, 0x7b, 0x0a, 0x0d, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x02, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0x08, 0x00, 0x18, 0x00, 0x28, 0x00, 0x30, 0x00, 0x50, 0x00, 0x52, 0x02, - 0x69, 0x64, 0x12, 0x23, 0x0a, 0x06, 0x41, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x42, 0x0a, 0x08, 0x00, 0x18, 0x00, 0x28, 0x00, 0x30, 0x00, 0x50, 0x00, 0x52, 0x07, - 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1e, 0x0a, 0x04, 0x50, 0x61, 0x72, 0x74, 0x18, + 0x69, 0x64, 0x12, 0x46, 0x0a, 0x04, 0x42, 0x6f, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x26, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x44, 0x61, 0x74, 0x61, 0x42, 0x0a, 0x08, 0x00, 0x18, 0x00, 0x28, 0x00, + 0x30, 0x00, 0x50, 0x00, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x3a, 0x06, 0x08, 0x00, 0x10, 0x00, + 0x18, 0x00, 0x22, 0x62, 0x0a, 0x0e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x07, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x42, 0x0a, 0x08, 0x00, 0x18, 0x00, 0x28, 0x00, 0x30, 0x00, 0x50, - 0x00, 0x52, 0x04, 0x70, 0x61, 0x72, 0x74, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0x08, 0x00, 0x18, 0x00, 0x28, 0x00, 0x30, 0x00, 0x50, - 0x00, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x3a, 0x06, 0x08, 0x00, 0x10, 0x00, 0x18, 0x00, 0x22, - 0xc4, 0x01, 0x0a, 0x0e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x02, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, - 0x08, 0x00, 0x18, 0x00, 0x28, 0x00, 0x30, 0x00, 0x50, 0x00, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1e, - 0x0a, 0x04, 0x50, 0x61, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x42, 0x0a, 0x08, 0x00, - 0x18, 0x00, 0x28, 0x00, 0x30, 0x00, 0x50, 0x00, 0x52, 0x04, 0x70, 0x61, 0x72, 0x74, 0x12, 0x24, - 0x0a, 0x07, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x42, - 0x0a, 0x08, 0x00, 0x18, 0x00, 0x28, 0x00, 0x30, 0x00, 0x50, 0x00, 0x52, 0x07, 0x63, 0x6f, 0x72, - 0x72, 0x65, 0x63, 0x74, 0x12, 0x24, 0x0a, 0x07, 0x52, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x05, 0x42, 0x0a, 0x08, 0x00, 0x18, 0x00, 0x28, 0x00, 0x30, 0x00, 0x50, - 0x00, 0x52, 0x07, 0x72, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x12, 0x22, 0x0a, 0x06, 0x50, 0x6f, + 0x00, 0x52, 0x07, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x12, 0x22, 0x0a, 0x06, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x42, 0x0a, 0x08, 0x00, 0x18, 0x00, 0x28, 0x00, 0x30, 0x00, 0x50, 0x00, 0x52, 0x06, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x3a, 0x06, 0x08, 0x00, 0x10, 0x00, 0x18, 0x00, 0x22, 0x85, 0x01, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, @@ -1357,7 +1380,7 @@ var file_github_com_hhhapz_codequest_api_v1_all_proto_rawDesc = []byte{ 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x1c, 0x88, 0x02, 0x00, 0x90, 0x02, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x2a, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x74, 0x6f, 0x6b, - 0x65, 0x6e, 0x28, 0x00, 0x1a, 0x03, 0x88, 0x02, 0x00, 0x32, 0x84, 0x04, 0x0a, 0x0c, 0x51, 0x75, + 0x65, 0x6e, 0x28, 0x00, 0x1a, 0x03, 0x88, 0x02, 0x00, 0x32, 0x8a, 0x04, 0x0a, 0x0c, 0x51, 0x75, 0x65, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6a, 0x0a, 0x09, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, @@ -1382,66 +1405,67 @@ var file_github_com_hhhapz_codequest_api_v1_all_proto_rawDesc = []byte{ 0x6e, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x22, 0x26, 0x88, 0x02, 0x00, 0x90, 0x02, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x12, 0x18, 0x2f, 0x76, 0x31, 0x2f, 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x7b, 0x49, 0x44, 0x7d, 0x2f, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x28, 0x00, - 0x30, 0x00, 0x12, 0x77, 0x0a, 0x06, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x12, 0x22, 0x2e, 0x68, + 0x30, 0x00, 0x12, 0x7d, 0x0a, 0x06, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x12, 0x22, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x20, 0x88, 0x02, 0x00, 0x90, 0x02, 0x00, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x14, 0x22, 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x2f, 0x7b, 0x49, 0x44, 0x7d, 0x28, 0x00, 0x30, 0x00, 0x1a, 0x03, 0x88, 0x02, 0x00, - 0x32, 0xec, 0x05, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x63, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x20, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, - 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x55, - 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x68, 0x68, 0x68, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x26, 0x88, 0x02, 0x00, 0x90, 0x02, 0x00, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x1a, 0x3a, 0x04, 0x42, 0x6f, 0x64, 0x79, 0x22, 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x7b, 0x49, 0x44, 0x7d, 0x28, 0x00, 0x30, + 0x00, 0x1a, 0x03, 0x88, 0x02, 0x00, 0x32, 0xec, 0x05, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x63, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x20, + 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x19, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x1a, 0x88, 0x02, 0x00, + 0x90, 0x02, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x12, 0x0c, 0x2f, 0x76, 0x31, 0x2f, 0x75, + 0x73, 0x65, 0x72, 0x73, 0x2f, 0x6d, 0x65, 0x28, 0x00, 0x30, 0x00, 0x12, 0x7c, 0x0a, 0x0b, 0x55, + 0x73, 0x65, 0x72, 0x42, 0x79, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x27, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, - 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x1a, 0x88, 0x02, 0x00, 0x90, 0x02, 0x00, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x0e, 0x12, 0x0c, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x6d, - 0x65, 0x28, 0x00, 0x30, 0x00, 0x12, 0x7c, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x45, - 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x27, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, - 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x42, - 0x79, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, - 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x25, 0x88, 0x02, 0x00, 0x90, 0x02, 0x00, - 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x12, 0x17, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x64, 0x6d, 0x69, - 0x6e, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x7d, 0x28, - 0x00, 0x30, 0x00, 0x12, 0x7a, 0x0a, 0x08, 0x41, 0x6c, 0x6c, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, - 0x24, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x6c, 0x6c, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, + 0x2e, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x25, + 0x88, 0x02, 0x00, 0x90, 0x02, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x12, 0x17, 0x2f, 0x76, + 0x31, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x45, + 0x6d, 0x61, 0x69, 0x6c, 0x7d, 0x28, 0x00, 0x30, 0x00, 0x12, 0x7a, 0x0a, 0x08, 0x41, 0x6c, 0x6c, + 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x24, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x6c, 0x6c, 0x55, - 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x88, 0x02, - 0x00, 0x90, 0x02, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x12, 0x0f, 0x2f, 0x76, 0x31, 0x2f, - 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x28, 0x00, 0x30, 0x00, 0x12, - 0x75, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x26, 0x2e, - 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, - 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, - 0x22, 0x20, 0x88, 0x02, 0x00, 0x90, 0x02, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x04, - 0x42, 0x6f, 0x64, 0x79, 0x1a, 0x0c, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, - 0x6d, 0x65, 0x28, 0x00, 0x30, 0x00, 0x12, 0x85, 0x01, 0x0a, 0x0f, 0x41, 0x64, 0x6d, 0x69, 0x6e, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x26, 0x2e, 0x68, 0x68, 0x68, + 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x68, 0x68, + 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x76, + 0x31, 0x2e, 0x41, 0x6c, 0x6c, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x1d, 0x88, 0x02, 0x00, 0x90, 0x02, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, + 0x12, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x75, 0x73, 0x65, 0x72, + 0x73, 0x28, 0x00, 0x30, 0x00, 0x12, 0x75, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, + 0x73, 0x65, 0x72, 0x12, 0x26, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x68, 0x68, + 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x76, + 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x20, 0x88, 0x02, 0x00, 0x90, 0x02, 0x00, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x04, 0x42, 0x6f, 0x64, 0x79, 0x1a, 0x0c, 0x2f, 0x76, 0x31, 0x2f, + 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x6d, 0x65, 0x28, 0x00, 0x30, 0x00, 0x12, 0x85, 0x01, 0x0a, + 0x0f, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, + 0x12, 0x26, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, + 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, + 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x55, + 0x73, 0x65, 0x72, 0x22, 0x2b, 0x88, 0x02, 0x00, 0x90, 0x02, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x1f, 0x3a, 0x04, 0x42, 0x6f, 0x64, 0x79, 0x1a, 0x17, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x64, 0x6d, + 0x69, 0x6e, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x7d, + 0x28, 0x00, 0x30, 0x00, 0x12, 0x7a, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, + 0x65, 0x72, 0x12, 0x26, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, + 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, - 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x2b, 0x88, - 0x02, 0x00, 0x90, 0x02, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1f, 0x3a, 0x04, 0x42, 0x6f, 0x64, - 0x79, 0x1a, 0x17, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x75, 0x73, 0x65, - 0x72, 0x73, 0x2f, 0x7b, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x7d, 0x28, 0x00, 0x30, 0x00, 0x12, 0x7a, - 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x26, 0x2e, 0x68, - 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, - 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2e, 0x63, 0x6f, - 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, - 0x25, 0x88, 0x02, 0x00, 0x90, 0x02, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x2a, 0x17, 0x2f, - 0x76, 0x31, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, - 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x7d, 0x28, 0x00, 0x30, 0x00, 0x1a, 0x03, 0x88, 0x02, 0x00, 0x42, - 0x47, 0x48, 0x01, 0x50, 0x00, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x80, 0x01, 0x00, 0x88, 0x01, 0x00, 0x90, 0x01, 0x00, 0xb8, 0x01, 0x00, 0xd8, - 0x01, 0x00, 0xf8, 0x01, 0x01, 0xd0, 0x02, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x25, 0x88, 0x02, 0x00, 0x90, 0x02, 0x00, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x19, 0x2a, 0x17, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x75, + 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x7d, 0x28, 0x00, 0x30, 0x00, + 0x1a, 0x03, 0x88, 0x02, 0x00, 0x42, 0x47, 0x48, 0x01, 0x50, 0x00, 0x5a, 0x2c, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x68, 0x68, 0x61, 0x70, 0x7a, 0x2f, 0x63, + 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x3b, + 0x63, 0x6f, 0x64, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x80, 0x01, 0x00, 0x88, 0x01, 0x00, 0x90, + 0x01, 0x00, 0xb8, 0x01, 0x00, 0xd8, 0x01, 0x00, 0xf8, 0x01, 0x01, 0xd0, 0x02, 0x00, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1456,7 +1480,7 @@ func file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescGZIP() []byte { return file_github_com_hhhapz_codequest_api_v1_all_proto_rawDescData } -var file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes = make([]protoimpl.MessageInfo, 21) +var file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes = make([]protoimpl.MessageInfo, 22) var file_github_com_hhhapz_codequest_api_v1_all_proto_goTypes = []interface{}{ (*Token)(nil), // 0: hhhapz.codequest.v1.Token (*OAuthCodeRequest)(nil), // 1: hhhapz.codequest.v1.OAuthCodeRequest @@ -1470,58 +1494,60 @@ var file_github_com_hhhapz_codequest_api_v1_all_proto_goTypes = []interface{}{ (*QuestionByIDRequest)(nil), // 9: hhhapz.codequest.v1.QuestionByIDRequest (*QuestionInputRequest)(nil), // 10: hhhapz.codequest.v1.QuestionInputRequest (*QuestionInput)(nil), // 11: hhhapz.codequest.v1.QuestionInput - (*SubmitRequest)(nil), // 12: hhhapz.codequest.v1.SubmitRequest - (*SubmitResponse)(nil), // 13: hhhapz.codequest.v1.SubmitResponse - (*UpdateFields)(nil), // 14: hhhapz.codequest.v1.UpdateFields - (*UserRequest)(nil), // 15: hhhapz.codequest.v1.UserRequest - (*AllUsersRequest)(nil), // 16: hhhapz.codequest.v1.AllUsersRequest - (*UpdateUserRequest)(nil), // 17: hhhapz.codequest.v1.UpdateUserRequest - (*UserByEmailRequest)(nil), // 18: hhhapz.codequest.v1.UserByEmailRequest - (*DeleteUserRequest)(nil), // 19: hhhapz.codequest.v1.DeleteUserRequest - (*AllUsersResponse)(nil), // 20: hhhapz.codequest.v1.AllUsersResponse - (*timestamppb.Timestamp)(nil), // 21: google.protobuf.Timestamp - (*emptypb.Empty)(nil), // 22: google.protobuf.Empty + (*SubmitRequestData)(nil), // 12: hhhapz.codequest.v1.SubmitRequestData + (*SubmitRequest)(nil), // 13: hhhapz.codequest.v1.SubmitRequest + (*SubmitResponse)(nil), // 14: hhhapz.codequest.v1.SubmitResponse + (*UpdateFields)(nil), // 15: hhhapz.codequest.v1.UpdateFields + (*UserRequest)(nil), // 16: hhhapz.codequest.v1.UserRequest + (*AllUsersRequest)(nil), // 17: hhhapz.codequest.v1.AllUsersRequest + (*UpdateUserRequest)(nil), // 18: hhhapz.codequest.v1.UpdateUserRequest + (*UserByEmailRequest)(nil), // 19: hhhapz.codequest.v1.UserByEmailRequest + (*DeleteUserRequest)(nil), // 20: hhhapz.codequest.v1.DeleteUserRequest + (*AllUsersResponse)(nil), // 21: hhhapz.codequest.v1.AllUsersResponse + (*timestamppb.Timestamp)(nil), // 22: google.protobuf.Timestamp + (*emptypb.Empty)(nil), // 23: google.protobuf.Empty } var file_github_com_hhhapz_codequest_api_v1_all_proto_depIdxs = []int32{ - 21, // 0: hhhapz.codequest.v1.Token.Expires:type_name -> google.protobuf.Timestamp + 22, // 0: hhhapz.codequest.v1.Token.Expires:type_name -> google.protobuf.Timestamp 0, // 1: hhhapz.codequest.v1.DeleteTokenRequest.Token:type_name -> hhhapz.codequest.v1.Token - 21, // 2: hhhapz.codequest.v1.User.CreatedAt:type_name -> google.protobuf.Timestamp + 22, // 2: hhhapz.codequest.v1.User.CreatedAt:type_name -> google.protobuf.Timestamp 6, // 3: hhhapz.codequest.v1.Question.Part1:type_name -> hhhapz.codequest.v1.PartData 6, // 4: hhhapz.codequest.v1.Question.Part2:type_name -> hhhapz.codequest.v1.PartData 7, // 5: hhhapz.codequest.v1.QuestionsResponse.Questions:type_name -> hhhapz.codequest.v1.Question - 14, // 6: hhhapz.codequest.v1.UpdateUserRequest.Body:type_name -> hhhapz.codequest.v1.UpdateFields - 5, // 7: hhhapz.codequest.v1.AllUsersResponse.Users:type_name -> hhhapz.codequest.v1.User - 1, // 8: hhhapz.codequest.v1.AuthService.OAuthCode:input_type -> hhhapz.codequest.v1.OAuthCodeRequest - 3, // 9: hhhapz.codequest.v1.AuthService.Token:input_type -> hhhapz.codequest.v1.TokenRequest - 4, // 10: hhhapz.codequest.v1.AuthService.DeleteToken:input_type -> hhhapz.codequest.v1.DeleteTokenRequest - 22, // 11: hhhapz.codequest.v1.QuestService.Questions:input_type -> google.protobuf.Empty - 9, // 12: hhhapz.codequest.v1.QuestService.QuestionByID:input_type -> hhhapz.codequest.v1.QuestionByIDRequest - 10, // 13: hhhapz.codequest.v1.QuestService.QuestionInput:input_type -> hhhapz.codequest.v1.QuestionInputRequest - 12, // 14: hhhapz.codequest.v1.QuestService.Submit:input_type -> hhhapz.codequest.v1.SubmitRequest - 15, // 15: hhhapz.codequest.v1.UserService.User:input_type -> hhhapz.codequest.v1.UserRequest - 18, // 16: hhhapz.codequest.v1.UserService.UserByEmail:input_type -> hhhapz.codequest.v1.UserByEmailRequest - 16, // 17: hhhapz.codequest.v1.UserService.AllUsers:input_type -> hhhapz.codequest.v1.AllUsersRequest - 17, // 18: hhhapz.codequest.v1.UserService.UpdateUser:input_type -> hhhapz.codequest.v1.UpdateUserRequest - 17, // 19: hhhapz.codequest.v1.UserService.AdminUpdateUser:input_type -> hhhapz.codequest.v1.UpdateUserRequest - 19, // 20: hhhapz.codequest.v1.UserService.DeleteUser:input_type -> hhhapz.codequest.v1.DeleteUserRequest - 2, // 21: hhhapz.codequest.v1.AuthService.OAuthCode:output_type -> hhhapz.codequest.v1.OAuthCodeResponse - 0, // 22: hhhapz.codequest.v1.AuthService.Token:output_type -> hhhapz.codequest.v1.Token - 22, // 23: hhhapz.codequest.v1.AuthService.DeleteToken:output_type -> google.protobuf.Empty - 8, // 24: hhhapz.codequest.v1.QuestService.Questions:output_type -> hhhapz.codequest.v1.QuestionsResponse - 7, // 25: hhhapz.codequest.v1.QuestService.QuestionByID:output_type -> hhhapz.codequest.v1.Question - 11, // 26: hhhapz.codequest.v1.QuestService.QuestionInput:output_type -> hhhapz.codequest.v1.QuestionInput - 13, // 27: hhhapz.codequest.v1.QuestService.Submit:output_type -> hhhapz.codequest.v1.SubmitResponse - 5, // 28: hhhapz.codequest.v1.UserService.User:output_type -> hhhapz.codequest.v1.User - 5, // 29: hhhapz.codequest.v1.UserService.UserByEmail:output_type -> hhhapz.codequest.v1.User - 20, // 30: hhhapz.codequest.v1.UserService.AllUsers:output_type -> hhhapz.codequest.v1.AllUsersResponse - 5, // 31: hhhapz.codequest.v1.UserService.UpdateUser:output_type -> hhhapz.codequest.v1.User - 5, // 32: hhhapz.codequest.v1.UserService.AdminUpdateUser:output_type -> hhhapz.codequest.v1.User - 5, // 33: hhhapz.codequest.v1.UserService.DeleteUser:output_type -> hhhapz.codequest.v1.User - 21, // [21:34] is the sub-list for method output_type - 8, // [8:21] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 12, // 6: hhhapz.codequest.v1.SubmitRequest.Body:type_name -> hhhapz.codequest.v1.SubmitRequestData + 15, // 7: hhhapz.codequest.v1.UpdateUserRequest.Body:type_name -> hhhapz.codequest.v1.UpdateFields + 5, // 8: hhhapz.codequest.v1.AllUsersResponse.Users:type_name -> hhhapz.codequest.v1.User + 1, // 9: hhhapz.codequest.v1.AuthService.OAuthCode:input_type -> hhhapz.codequest.v1.OAuthCodeRequest + 3, // 10: hhhapz.codequest.v1.AuthService.Token:input_type -> hhhapz.codequest.v1.TokenRequest + 4, // 11: hhhapz.codequest.v1.AuthService.DeleteToken:input_type -> hhhapz.codequest.v1.DeleteTokenRequest + 23, // 12: hhhapz.codequest.v1.QuestService.Questions:input_type -> google.protobuf.Empty + 9, // 13: hhhapz.codequest.v1.QuestService.QuestionByID:input_type -> hhhapz.codequest.v1.QuestionByIDRequest + 10, // 14: hhhapz.codequest.v1.QuestService.QuestionInput:input_type -> hhhapz.codequest.v1.QuestionInputRequest + 13, // 15: hhhapz.codequest.v1.QuestService.Submit:input_type -> hhhapz.codequest.v1.SubmitRequest + 16, // 16: hhhapz.codequest.v1.UserService.User:input_type -> hhhapz.codequest.v1.UserRequest + 19, // 17: hhhapz.codequest.v1.UserService.UserByEmail:input_type -> hhhapz.codequest.v1.UserByEmailRequest + 17, // 18: hhhapz.codequest.v1.UserService.AllUsers:input_type -> hhhapz.codequest.v1.AllUsersRequest + 18, // 19: hhhapz.codequest.v1.UserService.UpdateUser:input_type -> hhhapz.codequest.v1.UpdateUserRequest + 18, // 20: hhhapz.codequest.v1.UserService.AdminUpdateUser:input_type -> hhhapz.codequest.v1.UpdateUserRequest + 20, // 21: hhhapz.codequest.v1.UserService.DeleteUser:input_type -> hhhapz.codequest.v1.DeleteUserRequest + 2, // 22: hhhapz.codequest.v1.AuthService.OAuthCode:output_type -> hhhapz.codequest.v1.OAuthCodeResponse + 0, // 23: hhhapz.codequest.v1.AuthService.Token:output_type -> hhhapz.codequest.v1.Token + 23, // 24: hhhapz.codequest.v1.AuthService.DeleteToken:output_type -> google.protobuf.Empty + 8, // 25: hhhapz.codequest.v1.QuestService.Questions:output_type -> hhhapz.codequest.v1.QuestionsResponse + 7, // 26: hhhapz.codequest.v1.QuestService.QuestionByID:output_type -> hhhapz.codequest.v1.Question + 11, // 27: hhhapz.codequest.v1.QuestService.QuestionInput:output_type -> hhhapz.codequest.v1.QuestionInput + 14, // 28: hhhapz.codequest.v1.QuestService.Submit:output_type -> hhhapz.codequest.v1.SubmitResponse + 5, // 29: hhhapz.codequest.v1.UserService.User:output_type -> hhhapz.codequest.v1.User + 5, // 30: hhhapz.codequest.v1.UserService.UserByEmail:output_type -> hhhapz.codequest.v1.User + 21, // 31: hhhapz.codequest.v1.UserService.AllUsers:output_type -> hhhapz.codequest.v1.AllUsersResponse + 5, // 32: hhhapz.codequest.v1.UserService.UpdateUser:output_type -> hhhapz.codequest.v1.User + 5, // 33: hhhapz.codequest.v1.UserService.AdminUpdateUser:output_type -> hhhapz.codequest.v1.User + 5, // 34: hhhapz.codequest.v1.UserService.DeleteUser:output_type -> hhhapz.codequest.v1.User + 22, // [22:35] is the sub-list for method output_type + 9, // [9:22] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_github_com_hhhapz_codequest_api_v1_all_proto_init() } @@ -1675,7 +1701,7 @@ func file_github_com_hhhapz_codequest_api_v1_all_proto_init() { } } file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SubmitRequest); i { + switch v := v.(*SubmitRequestData); i { case 0: return &v.state case 1: @@ -1687,7 +1713,7 @@ func file_github_com_hhhapz_codequest_api_v1_all_proto_init() { } } file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SubmitResponse); i { + switch v := v.(*SubmitRequest); i { case 0: return &v.state case 1: @@ -1699,7 +1725,7 @@ func file_github_com_hhhapz_codequest_api_v1_all_proto_init() { } } file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateFields); i { + switch v := v.(*SubmitResponse); i { case 0: return &v.state case 1: @@ -1711,7 +1737,7 @@ func file_github_com_hhhapz_codequest_api_v1_all_proto_init() { } } file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UserRequest); i { + switch v := v.(*UpdateFields); i { case 0: return &v.state case 1: @@ -1723,7 +1749,7 @@ func file_github_com_hhhapz_codequest_api_v1_all_proto_init() { } } file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AllUsersRequest); i { + switch v := v.(*UserRequest); i { case 0: return &v.state case 1: @@ -1735,7 +1761,7 @@ func file_github_com_hhhapz_codequest_api_v1_all_proto_init() { } } file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateUserRequest); i { + switch v := v.(*AllUsersRequest); i { case 0: return &v.state case 1: @@ -1747,7 +1773,7 @@ func file_github_com_hhhapz_codequest_api_v1_all_proto_init() { } } file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UserByEmailRequest); i { + switch v := v.(*UpdateUserRequest); i { case 0: return &v.state case 1: @@ -1759,7 +1785,7 @@ func file_github_com_hhhapz_codequest_api_v1_all_proto_init() { } } file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteUserRequest); i { + switch v := v.(*UserByEmailRequest); i { case 0: return &v.state case 1: @@ -1771,6 +1797,18 @@ func file_github_com_hhhapz_codequest_api_v1_all_proto_init() { } } file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteUserRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_github_com_hhhapz_codequest_api_v1_all_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*AllUsersResponse); i { case 0: return &v.state @@ -1789,7 +1827,7 @@ func file_github_com_hhhapz_codequest_api_v1_all_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_github_com_hhhapz_codequest_api_v1_all_proto_rawDesc, NumEnums: 0, - NumMessages: 21, + NumMessages: 22, NumExtensions: 0, NumServices: 3, }, diff --git a/api/v1/all.pb.gw.go b/api/v1/all.pb.gw.go index 14dbe94..717fc68 100644 --- a/api/v1/all.pb.gw.go +++ b/api/v1/all.pb.gw.go @@ -244,14 +244,18 @@ func local_request_QuestService_QuestionInput_0(ctx context.Context, marshaler r } -var ( - filter_QuestService_Submit_0 = &utilities.DoubleArray{Encoding: map[string]int{"ID": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) - func request_QuestService_Submit_0(ctx context.Context, marshaler runtime.Marshaler, client QuestServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq SubmitRequest var metadata runtime.ServerMetadata + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Body); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + var ( val string ok bool @@ -269,13 +273,6 @@ func request_QuestService_Submit_0(ctx context.Context, marshaler runtime.Marsha return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "ID", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_QuestService_Submit_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.Submit(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -285,6 +282,14 @@ func local_request_QuestService_Submit_0(ctx context.Context, marshaler runtime. var protoReq SubmitRequest var metadata runtime.ServerMetadata + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Body); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + var ( val string ok bool @@ -302,13 +307,6 @@ func local_request_QuestService_Submit_0(ctx context.Context, marshaler runtime. return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "ID", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_QuestService_Submit_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.Submit(ctx, &protoReq) return msg, metadata, err diff --git a/api/v1/gen/json/codequest/all.swagger.json b/api/v1/gen/json/codequest/all.swagger.json index 798e762..759d176 100644 --- a/api/v1/gen/json/codequest/all.swagger.json +++ b/api/v1/gen/json/codequest/all.swagger.json @@ -312,22 +312,12 @@ "type": "string" }, { - "name": "content", - "in": "query", - "required": false, - "type": "string" - }, - { - "name": "part", - "in": "query", - "required": false, - "type": "boolean" - }, - { - "name": "code", - "in": "query", - "required": false, - "type": "string" + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1SubmitRequestData" + } } ], "tags": [ @@ -525,23 +515,27 @@ } } }, - "v1SubmitResponse": { + "v1SubmitRequestData": { "type": "object", "properties": { - "id": { + "answer": { "type": "string" }, "part": { "type": "integer", "format": "int32" }, + "code": { + "type": "string" + } + } + }, + "v1SubmitResponse": { + "type": "object", + "properties": { "correct": { "type": "boolean" }, - "ranking": { - "type": "integer", - "format": "int32" - }, "points": { "type": "integer", "format": "int32" diff --git a/api/v1/gen/ts/codequest/all_pb.d.ts b/api/v1/gen/ts/codequest/all_pb.d.ts deleted file mode 100644 index 2c673a4..0000000 --- a/api/v1/gen/ts/codequest/all_pb.d.ts +++ /dev/null @@ -1,528 +0,0 @@ -// package: hhhapz.codequest.v1 -// file: github.com/hhhapz/codequest/api/v1/all.proto - -import * as jspb from "google-protobuf"; -import * as google_api_annotations_pb from "../../../../../google/api/annotations_pb"; -import * as google_protobuf_empty_pb from "google-protobuf/google/protobuf/empty_pb"; -import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb"; - -export class Token extends jspb.Message { - getToken(): string; - setToken(value: string): void; - - hasExpires(): boolean; - clearExpires(): void; - getExpires(): google_protobuf_timestamp_pb.Timestamp | undefined; - setExpires(value?: google_protobuf_timestamp_pb.Timestamp): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): Token.AsObject; - static toObject(includeInstance: boolean, msg: Token): Token.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: Token, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): Token; - static deserializeBinaryFromReader(message: Token, reader: jspb.BinaryReader): Token; -} - -export namespace Token { - export type AsObject = { - token: string, - expires?: google_protobuf_timestamp_pb.Timestamp.AsObject, - } -} - -export class OAuthCodeRequest extends jspb.Message { - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): OAuthCodeRequest.AsObject; - static toObject(includeInstance: boolean, msg: OAuthCodeRequest): OAuthCodeRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: OAuthCodeRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): OAuthCodeRequest; - static deserializeBinaryFromReader(message: OAuthCodeRequest, reader: jspb.BinaryReader): OAuthCodeRequest; -} - -export namespace OAuthCodeRequest { - export type AsObject = { - } -} - -export class OAuthCodeResponse extends jspb.Message { - getRedirecturi(): string; - setRedirecturi(value: string): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): OAuthCodeResponse.AsObject; - static toObject(includeInstance: boolean, msg: OAuthCodeResponse): OAuthCodeResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: OAuthCodeResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): OAuthCodeResponse; - static deserializeBinaryFromReader(message: OAuthCodeResponse, reader: jspb.BinaryReader): OAuthCodeResponse; -} - -export namespace OAuthCodeResponse { - export type AsObject = { - redirecturi: string, - } -} - -export class TokenRequest extends jspb.Message { - getCode(): string; - setCode(value: string): void; - - getState(): string; - setState(value: string): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): TokenRequest.AsObject; - static toObject(includeInstance: boolean, msg: TokenRequest): TokenRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: TokenRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): TokenRequest; - static deserializeBinaryFromReader(message: TokenRequest, reader: jspb.BinaryReader): TokenRequest; -} - -export namespace TokenRequest { - export type AsObject = { - code: string, - state: string, - } -} - -export class DeleteTokenRequest extends jspb.Message { - getAll(): boolean; - setAll(value: boolean): void; - - hasToken(): boolean; - clearToken(): void; - getToken(): Token | undefined; - setToken(value?: Token): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): DeleteTokenRequest.AsObject; - static toObject(includeInstance: boolean, msg: DeleteTokenRequest): DeleteTokenRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: DeleteTokenRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): DeleteTokenRequest; - static deserializeBinaryFromReader(message: DeleteTokenRequest, reader: jspb.BinaryReader): DeleteTokenRequest; -} - -export namespace DeleteTokenRequest { - export type AsObject = { - all: boolean, - token?: Token.AsObject, - } -} - -export class User extends jspb.Message { - getId(): string; - setId(value: string): void; - - getName(): string; - setName(value: string): void; - - getEmail(): string; - setEmail(value: string): void; - - getPicture(): string; - setPicture(value: string): void; - - getAdmin(): boolean; - setAdmin(value: boolean): void; - - hasCreatedat(): boolean; - clearCreatedat(): void; - getCreatedat(): google_protobuf_timestamp_pb.Timestamp | undefined; - setCreatedat(value?: google_protobuf_timestamp_pb.Timestamp): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): User.AsObject; - static toObject(includeInstance: boolean, msg: User): User.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: User, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): User; - static deserializeBinaryFromReader(message: User, reader: jspb.BinaryReader): User; -} - -export namespace User { - export type AsObject = { - id: string, - name: string, - email: string, - picture: string, - admin: boolean, - createdat?: google_protobuf_timestamp_pb.Timestamp.AsObject, - } -} - -export class PartData extends jspb.Message { - getCompleted(): boolean; - setCompleted(value: boolean): void; - - getPointsworth(): number; - setPointsworth(value: number): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): PartData.AsObject; - static toObject(includeInstance: boolean, msg: PartData): PartData.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: PartData, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): PartData; - static deserializeBinaryFromReader(message: PartData, reader: jspb.BinaryReader): PartData; -} - -export namespace PartData { - export type AsObject = { - completed: boolean, - pointsworth: number, - } -} - -export class Question extends jspb.Message { - getId(): string; - setId(value: string): void; - - getTitle(): string; - setTitle(value: string): void; - - getText(): string; - setText(value: string): void; - - hasPart1(): boolean; - clearPart1(): void; - getPart1(): PartData | undefined; - setPart1(value?: PartData): void; - - hasPart2(): boolean; - clearPart2(): void; - getPart2(): PartData | undefined; - setPart2(value?: PartData): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): Question.AsObject; - static toObject(includeInstance: boolean, msg: Question): Question.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: Question, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): Question; - static deserializeBinaryFromReader(message: Question, reader: jspb.BinaryReader): Question; -} - -export namespace Question { - export type AsObject = { - id: string, - title: string, - text: string, - part1?: PartData.AsObject, - part2?: PartData.AsObject, - } -} - -export class QuestionsResponse extends jspb.Message { - clearQuestionsList(): void; - getQuestionsList(): Array; - setQuestionsList(value: Array): void; - addQuestions(value?: Question, index?: number): Question; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): QuestionsResponse.AsObject; - static toObject(includeInstance: boolean, msg: QuestionsResponse): QuestionsResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: QuestionsResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): QuestionsResponse; - static deserializeBinaryFromReader(message: QuestionsResponse, reader: jspb.BinaryReader): QuestionsResponse; -} - -export namespace QuestionsResponse { - export type AsObject = { - questionsList: Array, - } -} - -export class QuestionByIDRequest extends jspb.Message { - getId(): string; - setId(value: string): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): QuestionByIDRequest.AsObject; - static toObject(includeInstance: boolean, msg: QuestionByIDRequest): QuestionByIDRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: QuestionByIDRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): QuestionByIDRequest; - static deserializeBinaryFromReader(message: QuestionByIDRequest, reader: jspb.BinaryReader): QuestionByIDRequest; -} - -export namespace QuestionByIDRequest { - export type AsObject = { - id: string, - } -} - -export class QuestionInputRequest extends jspb.Message { - getId(): string; - setId(value: string): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): QuestionInputRequest.AsObject; - static toObject(includeInstance: boolean, msg: QuestionInputRequest): QuestionInputRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: QuestionInputRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): QuestionInputRequest; - static deserializeBinaryFromReader(message: QuestionInputRequest, reader: jspb.BinaryReader): QuestionInputRequest; -} - -export namespace QuestionInputRequest { - export type AsObject = { - id: string, - } -} - -export class QuestionInput extends jspb.Message { - getId(): string; - setId(value: string): void; - - getInput(): string; - setInput(value: string): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): QuestionInput.AsObject; - static toObject(includeInstance: boolean, msg: QuestionInput): QuestionInput.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: QuestionInput, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): QuestionInput; - static deserializeBinaryFromReader(message: QuestionInput, reader: jspb.BinaryReader): QuestionInput; -} - -export namespace QuestionInput { - export type AsObject = { - id: string, - input: string, - } -} - -export class SubmitRequest extends jspb.Message { - getId(): string; - setId(value: string): void; - - getAnswer(): string; - setAnswer(value: string): void; - - getPart(): boolean; - setPart(value: boolean): void; - - getCode(): string; - setCode(value: string): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): SubmitRequest.AsObject; - static toObject(includeInstance: boolean, msg: SubmitRequest): SubmitRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: SubmitRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): SubmitRequest; - static deserializeBinaryFromReader(message: SubmitRequest, reader: jspb.BinaryReader): SubmitRequest; -} - -export namespace SubmitRequest { - export type AsObject = { - id: string, - answer: string, - part: boolean, - code: string, - } -} - -export class SubmitResponse extends jspb.Message { - getId(): string; - setId(value: string): void; - - getPart(): number; - setPart(value: number): void; - - getCorrect(): boolean; - setCorrect(value: boolean): void; - - getRanking(): number; - setRanking(value: number): void; - - getPoints(): number; - setPoints(value: number): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): SubmitResponse.AsObject; - static toObject(includeInstance: boolean, msg: SubmitResponse): SubmitResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: SubmitResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): SubmitResponse; - static deserializeBinaryFromReader(message: SubmitResponse, reader: jspb.BinaryReader): SubmitResponse; -} - -export namespace SubmitResponse { - export type AsObject = { - id: string, - part: number, - correct: boolean, - ranking: number, - points: number, - } -} - -export class UpdateFields extends jspb.Message { - getName(): string; - setName(value: string): void; - - getGradelevel(): number; - setGradelevel(value: number): void; - - getAdmin(): boolean; - setAdmin(value: boolean): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): UpdateFields.AsObject; - static toObject(includeInstance: boolean, msg: UpdateFields): UpdateFields.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: UpdateFields, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): UpdateFields; - static deserializeBinaryFromReader(message: UpdateFields, reader: jspb.BinaryReader): UpdateFields; -} - -export namespace UpdateFields { - export type AsObject = { - name: string, - gradelevel: number, - admin: boolean, - } -} - -export class UserRequest extends jspb.Message { - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): UserRequest.AsObject; - static toObject(includeInstance: boolean, msg: UserRequest): UserRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: UserRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): UserRequest; - static deserializeBinaryFromReader(message: UserRequest, reader: jspb.BinaryReader): UserRequest; -} - -export namespace UserRequest { - export type AsObject = { - } -} - -export class AllUsersRequest extends jspb.Message { - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): AllUsersRequest.AsObject; - static toObject(includeInstance: boolean, msg: AllUsersRequest): AllUsersRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: AllUsersRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): AllUsersRequest; - static deserializeBinaryFromReader(message: AllUsersRequest, reader: jspb.BinaryReader): AllUsersRequest; -} - -export namespace AllUsersRequest { - export type AsObject = { - } -} - -export class UpdateUserRequest extends jspb.Message { - getEmail(): string; - setEmail(value: string): void; - - hasBody(): boolean; - clearBody(): void; - getBody(): UpdateFields | undefined; - setBody(value?: UpdateFields): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): UpdateUserRequest.AsObject; - static toObject(includeInstance: boolean, msg: UpdateUserRequest): UpdateUserRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: UpdateUserRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): UpdateUserRequest; - static deserializeBinaryFromReader(message: UpdateUserRequest, reader: jspb.BinaryReader): UpdateUserRequest; -} - -export namespace UpdateUserRequest { - export type AsObject = { - email: string, - body?: UpdateFields.AsObject, - } -} - -export class UserByEmailRequest extends jspb.Message { - getEmail(): string; - setEmail(value: string): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): UserByEmailRequest.AsObject; - static toObject(includeInstance: boolean, msg: UserByEmailRequest): UserByEmailRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: UserByEmailRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): UserByEmailRequest; - static deserializeBinaryFromReader(message: UserByEmailRequest, reader: jspb.BinaryReader): UserByEmailRequest; -} - -export namespace UserByEmailRequest { - export type AsObject = { - email: string, - } -} - -export class DeleteUserRequest extends jspb.Message { - getEmail(): string; - setEmail(value: string): void; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): DeleteUserRequest.AsObject; - static toObject(includeInstance: boolean, msg: DeleteUserRequest): DeleteUserRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: DeleteUserRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): DeleteUserRequest; - static deserializeBinaryFromReader(message: DeleteUserRequest, reader: jspb.BinaryReader): DeleteUserRequest; -} - -export namespace DeleteUserRequest { - export type AsObject = { - email: string, - } -} - -export class AllUsersResponse extends jspb.Message { - clearUsersList(): void; - getUsersList(): Array; - setUsersList(value: Array): void; - addUsers(value?: User, index?: number): User; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): AllUsersResponse.AsObject; - static toObject(includeInstance: boolean, msg: AllUsersResponse): AllUsersResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: AllUsersResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): AllUsersResponse; - static deserializeBinaryFromReader(message: AllUsersResponse, reader: jspb.BinaryReader): AllUsersResponse; -} - -export namespace AllUsersResponse { - export type AsObject = { - usersList: Array, - } -} - diff --git a/api/v1/quest.gunk b/api/v1/quest.gunk index 384223c..3934b6b 100644 --- a/api/v1/quest.gunk +++ b/api/v1/quest.gunk @@ -29,6 +29,7 @@ type QuestService interface { // +gunk http.Match{ // Method: "POST", // Path: "/v1/questions/{ID}", + // Body: "Body", // } Submit(SubmitRequest) SubmitResponse } @@ -63,17 +64,18 @@ type QuestionInput struct { Input string `pb:"2" json:"input"` } -type SubmitRequest struct { - ID string `pb:"1" json:"id"` - Answer string `pb:"2" json:"content"` - Part bool `pb:"3" json:"part"` +type SubmitRequestData struct { + Answer string `pb:"2" json:"answer"` + Part int `pb:"3" json:"part"` Code string `pb:"4" json:"code"` } +type SubmitRequest struct { + ID string `pb:"1" json:"id"` + Body SubmitRequestData `pb:"2" json:"body"` +} + type SubmitResponse struct { - ID string `pb:"1" json:"id"` - Part int `pb:"2" json:"part"` - Correct bool `pb:"3" json:"correct"` - Ranking int `pb:"4" json:"ranking"` - Points int `pb:"5" json:"points"` + Correct bool `pb:"3" json:"correct"` + Points int `pb:"5" json:"points"` } diff --git a/cmd/gw/main.go b/cmd/gw/main.go index 7e3543c..e76e06c 100644 --- a/cmd/gw/main.go +++ b/cmd/gw/main.go @@ -16,6 +16,7 @@ import ( "github.com/kenshaw/redoc" "google.golang.org/grpc" "google.golang.org/grpc/grpclog" + "google.golang.org/protobuf/encoding/protojson" ) func main() { @@ -31,10 +32,17 @@ func main() { // run creates and runs the gateway instance. func run(ctx context.Context, addr, endpoint string) error { // build gateway mux - gw, opts := runtime.NewServeMux(), []grpc.DialOption{grpc.WithInsecure()} + gw, opts := runtime.NewServeMux( + runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{ + MarshalOptions: protojson.MarshalOptions{ + EmitUnpopulated: true, + }, + }), + ), []grpc.DialOption{grpc.WithInsecure()} for _, f := range []func(context.Context, *runtime.ServeMux, string, []grpc.DialOption) error{ codequestpb.RegisterAuthServiceHandlerFromEndpoint, codequestpb.RegisterUserServiceHandlerFromEndpoint, + codequestpb.RegisterQuestServiceHandlerFromEndpoint, } { if err := f(ctx, gw, endpoint, opts); err != nil { return err diff --git a/cmd/srv/main.go b/cmd/srv/main.go index 46c78d8..5744669 100644 --- a/cmd/srv/main.go +++ b/cmd/srv/main.go @@ -24,6 +24,7 @@ func run() error { port := fs.Int("port", 10000, "GRPC Server Port") secretFile := fs.String("secret", "client.secret.json", "Path to google oauth2 secret credentials JSON file.") dbFile := fs.String("db", "db.sqlite", "Path to sqlite3 database file") + debug := fs.Bool("debug", false, "debug sql queries") if err := ff.Parse(fs, os.Args[1:], ff.WithEnvVarPrefix("HK")); err != nil { return err } @@ -36,7 +37,9 @@ func run() error { if err != nil { return fmt.Errorf("could not open db: %v", err) } - models.SetLogger(log.Printf) + if *debug { + models.SetLogger(log.Printf) + } oaStore, err := db.NewOAuthState(*secretFile) if err != nil { diff --git a/db/quest.go b/db/quest.go index a27573c..4cb3f38 100644 --- a/db/quest.go +++ b/db/quest.go @@ -49,11 +49,11 @@ func (db *DB) Questions(ctx context.Context, u *models.User) ([]*question.Data, } data = append(data, &question.Data{ - QuestionID: q.ID, - UserID: u.ID, - Name: q.Name, - Part1: p1, - Part2: p2, + Question: q, + UserID: u.ID, + Name: q.Name, + Part1: p1, + Part2: p2, }) } @@ -90,18 +90,20 @@ func (db *DB) Question(ctx context.Context, u *models.User, id string) (*questio } return &question.Data{ - QuestionID: q.ID, - UserID: u.ID, - Name: q.Name, - Text: q.Text, - Level: q.Level, + Question: q, + UserID: u.ID, + Name: q.Name, + Text: q.Text, + Level: q.Level, Part1: question.PartData{ Completed: partData.P1Awarded.Valid, PointsWorth: int(partData.P1Awarded.Int64), + Solution: partData.P1Answer.String, }, Part2: question.PartData{ Completed: partData.P2Awarded.Valid, PointsWorth: int(partData.P2Awarded.Int64), + Solution: partData.P2Answer.String, }, }, nil } diff --git a/gen.sh b/gen.sh index 71e68f0..6f444de 100755 --- a/gen.sh +++ b/gen.sh @@ -93,7 +93,9 @@ WITH attempts AS ( ) SELECT p1.points_awarded AS p1_awarded, - p2.points_awarded AS p2_awarded + p1.answer AS p1_answer, + p2.points_awarded AS p2_awarded, + p2.answer AS p2_answer FROM users u LEFT JOIN attempts AS p1 diff --git a/go.mod b/go.mod index 67aed05..1210a3f 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/google/uuid v1.1.2 github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 github.com/grpc-ecosystem/grpc-gateway/v2 v2.6.0 - github.com/k0kubun/pp/v3 v3.0.7 + github.com/k0kubun/pp/v3 v3.0.8-0.20211130055516-28dbe910808d github.com/kenshaw/redoc v0.1.3 github.com/mattn/go-sqlite3 v1.14.8 github.com/peterbourgon/ff/v3 v3.1.0 diff --git a/go.sum b/go.sum index 69e7c6a..a0a361d 100644 --- a/go.sum +++ b/go.sum @@ -188,6 +188,8 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= github.com/k0kubun/pp/v3 v3.0.7 h1:Qj4zVxA0ceXq0mfNbHwFPye58UyabBWi3emM2SwBT5Y= github.com/k0kubun/pp/v3 v3.0.7/go.mod h1:2ol0zQBSPTermAo8igHVJ4d5vTiNmBkCrUdu7wZp4aI= +github.com/k0kubun/pp/v3 v3.0.8-0.20211130055516-28dbe910808d h1:pnhp6N9BrdCXRnnUO+HDeqMaajUzytmMd49UydYP/Wg= +github.com/k0kubun/pp/v3 v3.0.8-0.20211130055516-28dbe910808d/go.mod h1:8nuy25R0zFAdhfsMYvI5UWvUqW4MvF8wwSd3LXGQZiY= github.com/kenshaw/diskcache v0.5.0/go.mod h1:niKrpaT3MnShxQ4OojUoT8VNr9e5r+SQf8nrzVWjIrQ= github.com/kenshaw/diskcache v0.5.1 h1:mdgyJGiGOn+1ZW6WOa7u+HwsJoExiRzEBymjjTBbOJc= github.com/kenshaw/diskcache v0.5.1/go.mod h1:2g5XF+9Dgd1iBFi0anYYw3beLaLnTgJSSzsKIuk+Z5E= diff --git a/models/partsdata.xo.go b/models/partsdata.xo.go index a68e915..3c7382c 100644 --- a/models/partsdata.xo.go +++ b/models/partsdata.xo.go @@ -9,8 +9,10 @@ import ( // PartsData represents a row from 'parts_data'. type PartsData struct { - P1Awarded sql.NullInt64 `json:"p1_awarded"` // p1_awarded - P2Awarded sql.NullInt64 `json:"p2_awarded"` // p2_awarded + P1Awarded sql.NullInt64 `json:"p1_awarded"` // p1_awarded + P1Answer sql.NullString `json:"p1_answer"` // p1_answer + P2Awarded sql.NullInt64 `json:"p2_awarded"` // p2_awarded + P2Answer sql.NullString `json:"p2_answer"` // p2_answer } // QuestionPartsData runs a custom query, returning results as PartsData. @@ -24,7 +26,9 @@ func QuestionPartsData(ctx context.Context, db DB, question_id, user_id string) `) ` + `SELECT ` + `p1.points_awarded AS p1_awarded, ` + - `p2.points_awarded AS p2_awarded ` + + `p1.answer AS p1_answer, ` + + `p2.points_awarded AS p2_awarded, ` + + `p2.answer AS p2_answer ` + `FROM users u ` + ` ` + `LEFT JOIN attempts AS p1 ` + @@ -40,7 +44,7 @@ func QuestionPartsData(ctx context.Context, db DB, question_id, user_id string) // run logf(sqlstr, question_id, user_id) var pd PartsData - if err := db.QueryRowContext(ctx, sqlstr, question_id, user_id).Scan(&pd.P1Awarded, &pd.P2Awarded); err != nil { + if err := db.QueryRowContext(ctx, sqlstr, question_id, user_id).Scan(&pd.P1Awarded, &pd.P1Answer, &pd.P2Awarded, &pd.P2Answer); err != nil { return nil, logerror(err) } return &pd, nil diff --git a/models/questionattempt.xo.go b/models/questionattempt.xo.go index a36bec4..038f4f3 100644 --- a/models/questionattempt.xo.go +++ b/models/questionattempt.xo.go @@ -14,7 +14,7 @@ type QuestionAttempt struct { QuestionPart int `json:"question_part"` // question_part Correct bool `json:"correct"` // correct PointsAwarded int `json:"points_awarded"` // points_awarded - Input string `json:"input"` // input + Answer string `json:"answer"` // answer Code string `json:"code"` // code SubmittedAt Time `json:"submitted_at"` // submitted_at // xo fields @@ -42,13 +42,13 @@ func (qa *QuestionAttempt) Insert(ctx context.Context, db DB) error { } // insert (primary key generated and returned by database) const sqlstr = `INSERT INTO question_attempt (` + - `user_id, question_id, question_part, correct, points_awarded, input, code, submitted_at` + + `user_id, question_id, question_part, correct, points_awarded, answer, code, submitted_at` + `) VALUES (` + `$1, $2, $3, $4, $5, $6, $7, $8` + `)` // run - logf(sqlstr, qa.UserID, qa.QuestionID, qa.QuestionPart, qa.Correct, qa.PointsAwarded, qa.Input, qa.Code, qa.SubmittedAt) - res, err := db.ExecContext(ctx, sqlstr, qa.UserID, qa.QuestionID, qa.QuestionPart, qa.Correct, qa.PointsAwarded, qa.Input, qa.Code, qa.SubmittedAt) + logf(sqlstr, qa.UserID, qa.QuestionID, qa.QuestionPart, qa.Correct, qa.PointsAwarded, qa.Answer, qa.Code, qa.SubmittedAt) + res, err := db.ExecContext(ctx, sqlstr, qa.UserID, qa.QuestionID, qa.QuestionPart, qa.Correct, qa.PointsAwarded, qa.Answer, qa.Code, qa.SubmittedAt) if err != nil { return logerror(err) } @@ -73,11 +73,11 @@ func (qa *QuestionAttempt) Update(ctx context.Context, db DB) error { } // update with primary key const sqlstr = `UPDATE question_attempt SET ` + - `user_id = $1, question_id = $2, question_part = $3, correct = $4, points_awarded = $5, input = $6, code = $7, submitted_at = $8 ` + + `user_id = $1, question_id = $2, question_part = $3, correct = $4, points_awarded = $5, answer = $6, code = $7, submitted_at = $8 ` + `WHERE id = $9` // run - logf(sqlstr, qa.UserID, qa.QuestionID, qa.QuestionPart, qa.Correct, qa.PointsAwarded, qa.Input, qa.Code, qa.SubmittedAt, qa.ID) - if _, err := db.ExecContext(ctx, sqlstr, qa.UserID, qa.QuestionID, qa.QuestionPart, qa.Correct, qa.PointsAwarded, qa.Input, qa.Code, qa.SubmittedAt, qa.ID); err != nil { + logf(sqlstr, qa.UserID, qa.QuestionID, qa.QuestionPart, qa.Correct, qa.PointsAwarded, qa.Answer, qa.Code, qa.SubmittedAt, qa.ID) + if _, err := db.ExecContext(ctx, sqlstr, qa.UserID, qa.QuestionID, qa.QuestionPart, qa.Correct, qa.PointsAwarded, qa.Answer, qa.Code, qa.SubmittedAt, qa.ID); err != nil { return logerror(err) } return nil @@ -99,16 +99,16 @@ func (qa *QuestionAttempt) Upsert(ctx context.Context, db DB) error { } // upsert const sqlstr = `INSERT INTO question_attempt (` + - `id, user_id, question_id, question_part, correct, points_awarded, input, code, submitted_at` + + `id, user_id, question_id, question_part, correct, points_awarded, answer, code, submitted_at` + `) VALUES (` + `$1, $2, $3, $4, $5, $6, $7, $8, $9` + `)` + ` ON CONFLICT (id) DO ` + `UPDATE SET ` + - `user_id = EXCLUDED.user_id, question_id = EXCLUDED.question_id, question_part = EXCLUDED.question_part, correct = EXCLUDED.correct, points_awarded = EXCLUDED.points_awarded, input = EXCLUDED.input, code = EXCLUDED.code, submitted_at = EXCLUDED.submitted_at ` + `user_id = EXCLUDED.user_id, question_id = EXCLUDED.question_id, question_part = EXCLUDED.question_part, correct = EXCLUDED.correct, points_awarded = EXCLUDED.points_awarded, answer = EXCLUDED.answer, code = EXCLUDED.code, submitted_at = EXCLUDED.submitted_at ` // run - logf(sqlstr, qa.ID, qa.UserID, qa.QuestionID, qa.QuestionPart, qa.Correct, qa.PointsAwarded, qa.Input, qa.Code, qa.SubmittedAt) - if _, err := db.ExecContext(ctx, sqlstr, qa.ID, qa.UserID, qa.QuestionID, qa.QuestionPart, qa.Correct, qa.PointsAwarded, qa.Input, qa.Code, qa.SubmittedAt); err != nil { + logf(sqlstr, qa.ID, qa.UserID, qa.QuestionID, qa.QuestionPart, qa.Correct, qa.PointsAwarded, qa.Answer, qa.Code, qa.SubmittedAt) + if _, err := db.ExecContext(ctx, sqlstr, qa.ID, qa.UserID, qa.QuestionID, qa.QuestionPart, qa.Correct, qa.PointsAwarded, qa.Answer, qa.Code, qa.SubmittedAt); err != nil { return logerror(err) } // set exists @@ -143,7 +143,7 @@ func (qa *QuestionAttempt) Delete(ctx context.Context, db DB) error { func QuestionAttemptByID(ctx context.Context, db DB, id int) (*QuestionAttempt, error) { // query const sqlstr = `SELECT ` + - `id, user_id, question_id, question_part, correct, points_awarded, input, code, submitted_at ` + + `id, user_id, question_id, question_part, correct, points_awarded, answer, code, submitted_at ` + `FROM question_attempt ` + `WHERE id = $1` // run @@ -151,7 +151,7 @@ func QuestionAttemptByID(ctx context.Context, db DB, id int) (*QuestionAttempt, qa := QuestionAttempt{ _exists: true, } - if err := db.QueryRowContext(ctx, sqlstr, id).Scan(&qa.ID, &qa.UserID, &qa.QuestionID, &qa.QuestionPart, &qa.Correct, &qa.PointsAwarded, &qa.Input, &qa.Code, &qa.SubmittedAt); err != nil { + if err := db.QueryRowContext(ctx, sqlstr, id).Scan(&qa.ID, &qa.UserID, &qa.QuestionID, &qa.QuestionPart, &qa.Correct, &qa.PointsAwarded, &qa.Answer, &qa.Code, &qa.SubmittedAt); err != nil { return nil, logerror(err) } return &qa, nil diff --git a/models/xo.xo.yaml b/models/xo.xo.yaml index a59ed92..ca1becd 100644 --- a/models/xo.xo.yaml +++ b/models/xo.xo.yaml @@ -27,7 +27,7 @@ schemas: - name: points_awarded datatype: type: integer - - name: input + - name: answer datatype: type: text - name: code diff --git a/question/data.go b/question/data.go index e17a010..5e5c688 100644 --- a/question/data.go +++ b/question/data.go @@ -9,11 +9,11 @@ type PartData struct { } type Data struct { - QuestionID string - UserID string - Name string - Text *template.Template - Level Level - Part1 PartData - Part2 PartData + Question *Question + UserID string + Name string + Text *template.Template + Level Level + Part1 PartData + Part2 PartData } diff --git a/question/question.go b/question/question.go index 1f2e0d0..55088ea 100644 --- a/question/question.go +++ b/question/question.go @@ -36,14 +36,14 @@ type Question struct { type Level int const ( - Level1 Level = iota + Level1 Level = iota + 1 Level2 ) type Part int const ( - Part1 Part = iota + Part1 Part = iota + 1 Part2 ) diff --git a/sql/schema.sql b/sql/schema.sql index c9c3094..85b8116 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -34,7 +34,7 @@ CREATE TABLE question_attempt ( question_part INTEGER NOT NULL, correct BOOLEAN NOT NULL, points_awarded INTEGER NOT NULL, - input TEXT NOT NULL, + answer TEXT NOT NULL, code TEXT NOT NULL, submitted_at DATETIME NOT NULL ); diff --git a/api/v1/gen/ts-gateway/codequest/all.pb.ts b/web_src/lib/pb/all.pb.ts similarity index 96% rename from api/v1/gen/ts-gateway/codequest/all.pb.ts rename to web_src/lib/pb/all.pb.ts index 7cefc7b..b7d82ce 100644 --- a/api/v1/gen/ts-gateway/codequest/all.pb.ts +++ b/web_src/lib/pb/all.pb.ts @@ -68,18 +68,19 @@ export type QuestionInput = { input?: string } -export type SubmitRequest = { - id?: string +export type SubmitRequestData = { answer?: string - part?: boolean + part?: number code?: string } -export type SubmitResponse = { +export type SubmitRequest = { id?: string - part?: number + body?: SubmitRequestData +} + +export type SubmitResponse = { correct?: boolean - ranking?: number points?: number } @@ -134,7 +135,7 @@ export class QuestService { return fm.fetchReq(`/v1/questions/${req["id"]}/input?${fm.renderURLSearchParams(req, ["id"])}`, {...initReq, method: "GET"}) } static Submit(req: SubmitRequest, initReq?: fm.InitReq): Promise { - return fm.fetchReq(`/v1/questions/${req["id"]}`, {...initReq, method: "POST"}) + return fm.fetchReq(`/v1/questions/${req["id"]}`, {...initReq, method: "POST", body: JSON.stringify(req["Body"])}) } } export class UserService { diff --git a/api/v1/gen/ts-gateway/codequest/fetch.pb.ts b/web_src/lib/pb/fetch.pb.ts similarity index 100% rename from api/v1/gen/ts-gateway/codequest/fetch.pb.ts rename to web_src/lib/pb/fetch.pb.ts