Compare commits

...

5 Commits

Author SHA1 Message Date
30864dbc40 feat usn 类型改成int64 2026-01-30 14:48:38 +08:00
7eae358996 feat none 2026-01-26 10:25:31 +08:00
ecd8650e0a feat kafka 2026-01-25 16:28:09 +08:00
30ba2e8994 feat 环境 2026-01-24 11:15:41 +08:00
4aa48a822e feat quickly 2026-01-24 11:14:31 +08:00
51 changed files with 6160 additions and 1203 deletions

View File

@@ -8,6 +8,9 @@
{
"name": "Gateway"
},
{
"name": "Qgdzs"
},
{
"name": "Scene"
},
@@ -22,37 +25,10 @@
"application/json"
],
"paths": {
"/user/answer_question": {
"post": {
"summary": "回答题目",
"operationId": "User_AnswerQuestion",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/AnswerQuestionResp"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/AnswerQuestionReq"
}
}
],
"tags": [
"User"
]
}
},
"/user/generate_question": {
"/qgdzs/auth/generate_question": {
"post": {
"summary": "生成题目",
"operationId": "User_GenerateQuestion",
"operationId": "Qgdzs_GenerateQuestion",
"responses": {
"200": {
"description": "A successful response.",
@@ -72,19 +48,19 @@
}
],
"tags": [
"User"
"Qgdzs"
]
}
},
"/user/get_question": {
"/qgdzs/auth/get_record": {
"post": {
"summary": "获取题目",
"operationId": "User_GetQuestion",
"summary": "---------- 答题记录 ----------\n获取答题记录",
"operationId": "Qgdzs_GetRecord",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/GetQuestionResp"
"$ref": "#/definitions/GetRecordResp"
}
}
},
@@ -94,16 +70,232 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/GetQuestionReq"
"$ref": "#/definitions/GetRecordReq"
}
}
],
"tags": [
"User"
"Qgdzs"
]
}
},
"/user/info": {
"/qgdzs/open/category/answer": {
"post": {
"summary": "回答题目",
"operationId": "Qgdzs_CategoryAnswerQuestion",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/CategoryAnswerQuestionResp"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/CategoryAnswerQuestionReq"
}
}
],
"tags": [
"Qgdzs"
]
}
},
"/qgdzs/open/category/get_category": {
"post": {
"summary": "---------- 类目答题 ----------\n获取所有类目",
"operationId": "Qgdzs_GetAllCategory",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/GetAllCategoryResp"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/GetAllCategoryReq"
}
}
],
"tags": [
"Qgdzs"
]
}
},
"/qgdzs/open/category/question": {
"post": {
"summary": "获取题目",
"operationId": "Qgdzs_CategoryGetQuestion",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/CategoryGetQuestionResp"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/CategoryGetQuestionReq"
}
}
],
"tags": [
"Qgdzs"
]
}
},
"/qgdzs/open/get_question_info": {
"post": {
"summary": "获取具体的题目",
"operationId": "Qgdzs_GetQuestionInfo",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/GetQuestionInfoResp"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/GetQuestionInfoReq"
}
}
],
"tags": [
"Qgdzs"
]
}
},
"/qgdzs/open/quickly/answer": {
"post": {
"summary": "回答题目",
"operationId": "Qgdzs_QuicklyAnswerQuestion",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/QuicklyAnswerQuestionResp"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/QuicklyAnswerQuestionReq"
}
}
],
"tags": [
"Qgdzs"
]
}
},
"/qgdzs/open/quickly/question": {
"post": {
"summary": "---------- 快速答题 ----------\n获取题目",
"operationId": "Qgdzs_QuicklyGetQuestion",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/QuicklyGetQuestionResp"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/QuicklyGetQuestionReq"
}
}
],
"tags": [
"Qgdzs"
]
}
},
"/qgdzs/open/random/answer": {
"post": {
"summary": "回答题目",
"operationId": "Qgdzs_RandomAnswerQuestion",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RandomAnswerQuestionResp"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/RandomAnswerQuestionReq"
}
}
],
"tags": [
"Qgdzs"
]
}
},
"/qgdzs/open/random/question": {
"post": {
"summary": "---------- 随机答题 ----------\n获取题目",
"operationId": "Qgdzs_RandomGetQuestion",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RandomGetQuestionResp"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/RandomGetQuestionReq"
}
}
],
"tags": [
"Qgdzs"
]
}
},
"/user/auth/info": {
"post": {
"summary": "获取用户信息",
"operationId": "User_GetUserInfo",
@@ -135,11 +327,16 @@
"ActionResp": {
"type": "object"
},
"AnswerQuestionReq": {
"CategoryAnswerQuestionReq": {
"type": "object",
"properties": {
"usn": {
"type": "string",
"format": "int64"
},
"sn": {
"type": "string",
"format": "int64",
"title": "题目唯一标识"
},
"answer": {
@@ -147,9 +344,9 @@
"title": "答案"
}
},
"title": "---------- AnswerQuestion ----------"
"title": "---------- CategoryAnswerQuestion ----------"
},
"AnswerQuestionResp": {
"CategoryAnswerQuestionResp": {
"type": "object",
"properties": {
"answer": {
@@ -162,15 +359,58 @@
}
}
},
"CategoryGetQuestionReq": {
"type": "object",
"properties": {
"category_sn": {
"type": "string",
"format": "int64",
"title": "类目唯一标识"
}
},
"title": "---------- CategoryGetQuestion ----------"
},
"CategoryGetQuestionResp": {
"type": "object",
"properties": {
"sn": {
"type": "string",
"format": "int64",
"title": "题目唯一标识"
},
"question": {
"type": "string",
"title": "题干"
},
"options": {
"type": "array",
"items": {
"type": "string"
},
"title": "选项"
},
"category": {
"type": "string",
"title": "题目类型"
},
"difficulty": {
"type": "integer",
"format": "int32",
"title": "难度"
}
}
},
"EnterResp": {
"type": "object",
"properties": {
"SceneSID": {
"type": "string",
"format": "int64",
"title": "场景服务ID"
},
"UniqueNo": {
"type": "string",
"format": "int64",
"title": "副本唯一编号"
},
"MessageID": {
@@ -192,10 +432,6 @@
"type": "integer",
"format": "int32",
"title": "生成数量"
},
"category": {
"type": "string",
"title": "题目类型"
}
},
"title": "---------- GenerateQuestion ----------"
@@ -203,17 +439,51 @@
"GenerateQuestionResp": {
"type": "object"
},
"GetQuestionReq": {
"type": "object",
"title": "---------- GetQuestion ----------"
},
"GetQuestionResp": {
"GetAllCategoryItem": {
"type": "object",
"properties": {
"sn": {
"type": "string",
"title": "题目唯一标识"
"format": "int64",
"title": "唯一标识"
},
"category": {
"type": "string",
"title": "类目"
}
}
},
"GetAllCategoryReq": {
"type": "object",
"title": "---------- GetAllCategory ----------"
},
"GetAllCategoryResp": {
"type": "object",
"properties": {
"categories": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/GetAllCategoryItem"
},
"title": "类目"
}
}
},
"GetQuestionInfoReq": {
"type": "object",
"properties": {
"question_sn": {
"type": "string",
"format": "int64",
"title": "题目唯一标识"
}
},
"title": "---------- GetQuestionInfo ----------"
},
"GetQuestionInfoResp": {
"type": "object",
"properties": {
"question": {
"type": "string",
"title": "题干"
@@ -224,6 +494,91 @@
"type": "string"
},
"title": "选项"
},
"category": {
"type": "string",
"title": "类目"
},
"difficulty": {
"type": "integer",
"format": "int32",
"title": "难度"
},
"explanation": {
"type": "string",
"title": "解析"
}
}
},
"GetRecordItem": {
"type": "object",
"properties": {
"question_sn": {
"type": "string",
"format": "int64",
"title": "题目唯一标识"
},
"question": {
"type": "string",
"title": "题干"
},
"difficulty": {
"type": "integer",
"format": "int32",
"title": "难度"
},
"category": {
"type": "string",
"title": "题目类型"
},
"question_answer": {
"type": "string",
"title": "题目答案"
},
"answer": {
"type": "string",
"title": "用户答案"
},
"create_time": {
"type": "string",
"format": "int64",
"title": "创建时间"
}
}
},
"GetRecordReq": {
"type": "object",
"properties": {
"usn": {
"type": "string",
"format": "int64"
},
"page": {
"type": "integer",
"format": "int32"
},
"page_size": {
"type": "integer",
"format": "int32"
}
},
"title": "---------- GetRecord ----------"
},
"GetRecordResp": {
"type": "object",
"properties": {
"count": {
"type": "integer",
"format": "int32",
"title": "总数"
},
"records": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/GetRecordItem"
},
"title": "记录"
}
}
},
@@ -231,7 +586,8 @@
"type": "object",
"properties": {
"usn": {
"type": "string"
"type": "string",
"format": "int64"
}
},
"title": "---------- GetUserInfo ----------"
@@ -240,7 +596,8 @@
"type": "object",
"properties": {
"usn": {
"type": "string"
"type": "string",
"format": "int64"
},
"name": {
"type": "string"
@@ -253,11 +610,12 @@
"LeaveResp": {
"type": "object"
},
"LoginResp": {
"PhoneLoginResp": {
"type": "object",
"properties": {
"usn": {
"type": "string",
"format": "int64",
"title": "用户ID"
},
"name": {
@@ -266,8 +624,154 @@
}
}
},
"QuicklyAnswerQuestionReq": {
"type": "object",
"properties": {
"usn": {
"type": "string",
"format": "int64"
},
"sn": {
"type": "string",
"format": "int64",
"title": "题目唯一标识"
},
"answer": {
"type": "string",
"title": "答案"
}
},
"title": "---------- QuicklyAnswerQuestion ----------"
},
"QuicklyAnswerQuestionResp": {
"type": "object",
"properties": {
"answer": {
"type": "string",
"title": "答案"
},
"explanation": {
"type": "string",
"title": "解析"
}
}
},
"QuicklyGetQuestionReq": {
"type": "object",
"title": "---------- QuicklyGetQuestion ----------"
},
"QuicklyGetQuestionResp": {
"type": "object",
"properties": {
"sn": {
"type": "string",
"format": "int64",
"title": "题目唯一标识"
},
"question": {
"type": "string",
"title": "题干"
},
"options": {
"type": "array",
"items": {
"type": "string"
},
"title": "选项"
},
"category": {
"type": "string",
"title": "题目类型"
},
"difficulty": {
"type": "integer",
"format": "int32",
"title": "难度"
}
}
},
"RandomAnswerQuestionReq": {
"type": "object",
"properties": {
"usn": {
"type": "string",
"format": "int64"
},
"sn": {
"type": "string",
"format": "int64",
"title": "题目唯一标识"
},
"answer": {
"type": "string",
"title": "答案"
}
},
"title": "---------- RandomAnswerQuestion ----------"
},
"RandomAnswerQuestionResp": {
"type": "object",
"properties": {
"answer": {
"type": "string",
"title": "答案"
},
"explanation": {
"type": "string",
"title": "解析"
}
}
},
"RandomGetQuestionReq": {
"type": "object",
"title": "---------- RandomGetQuestion ----------"
},
"RandomGetQuestionResp": {
"type": "object",
"properties": {
"sn": {
"type": "string",
"format": "int64",
"title": "题目唯一标识"
},
"question": {
"type": "string",
"title": "题干"
},
"options": {
"type": "array",
"items": {
"type": "string"
},
"title": "选项"
},
"category": {
"type": "string",
"title": "题目类型"
},
"difficulty": {
"type": "integer",
"format": "int32",
"title": "难度"
}
}
},
"ToClientResp": {
"type": "object"
},
"WxMiniLoginResp": {
"type": "object",
"properties": {
"usn": {
"type": "string",
"format": "int64",
"title": "用户ID"
},
"name": {
"type": "string",
"title": "用户名"
}
}
}
}
}

View File

@@ -26,7 +26,7 @@ type ToClientReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,1,opt,name=USN,proto3" json:"USN,omitempty"`
USN int64 `protobuf:"varint,1,opt,name=USN,proto3" json:"USN,omitempty"`
MessageID int32 `protobuf:"varint,2,opt,name=MessageID,proto3" json:"MessageID,omitempty"`
Payload []byte `protobuf:"bytes,3,opt,name=Payload,proto3" json:"Payload,omitempty"`
}
@@ -63,11 +63,11 @@ func (*ToClientReq) Descriptor() ([]byte, []int) {
return file_service_gateway_proto_rawDescGZIP(), []int{0}
}
func (x *ToClientReq) GetUSN() string {
func (x *ToClientReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
func (x *ToClientReq) GetMessageID() int32 {
@@ -127,7 +127,7 @@ type KickUserReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,1,opt,name=USN,proto3" json:"USN,omitempty"`
USN int64 `protobuf:"varint,1,opt,name=USN,proto3" json:"USN,omitempty"`
}
func (x *KickUserReq) Reset() {
@@ -162,11 +162,11 @@ func (*KickUserReq) Descriptor() ([]byte, []int) {
return file_service_gateway_proto_rawDescGZIP(), []int{2}
}
func (x *KickUserReq) GetUSN() string {
func (x *KickUserReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
type KickUserResp struct {
@@ -214,13 +214,13 @@ var file_service_gateway_proto_rawDesc = []byte{
0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x72, 0x73, 0x5f, 0x63, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x57, 0x0a, 0x0b, 0x54, 0x6f, 0x43, 0x6c,
0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x55, 0x53, 0x4e, 0x12, 0x1c, 0x0a, 0x09, 0x4d, 0x65, 0x73,
0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x55, 0x53, 0x4e, 0x12, 0x1c, 0x0a, 0x09, 0x4d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x4d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f,
0x61, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61,
0x64, 0x22, 0x0e, 0x0a, 0x0c, 0x54, 0x6f, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73,
0x70, 0x22, 0x1f, 0x0a, 0x0b, 0x4b, 0x69, 0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71,
0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x55,
0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x55,
0x53, 0x4e, 0x22, 0x0e, 0x0a, 0x0c, 0x4b, 0x69, 0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65,
0x73, 0x70, 0x32, 0x61, 0x0a, 0x07, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, 0x2b, 0x0a,
0x08, 0x54, 0x6f, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x0c, 0x2e, 0x54, 0x6f, 0x43, 0x6c,

View File

@@ -0,0 +1,721 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: service_qgdzs.proto
/*
Package grpc_pb is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package grpc_pb
import (
"context"
"errors"
"io"
"net/http"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
)
// Suppress "imported and not used" errors
var (
_ codes.Code
_ io.Reader
_ status.Status
_ = errors.New
_ = runtime.String
_ = utilities.NewDoubleArray
_ = metadata.Join
)
func request_Qgdzs_GenerateQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GenerateQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.GenerateQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_GenerateQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GenerateQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.GenerateQuestion(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_RandomGetQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq RandomGetQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.RandomGetQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_RandomGetQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq RandomGetQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.RandomGetQuestion(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_RandomAnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq RandomAnswerQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.RandomAnswerQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_RandomAnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq RandomAnswerQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.RandomAnswerQuestion(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_GetAllCategory_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetAllCategoryReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.GetAllCategory(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_GetAllCategory_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetAllCategoryReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.GetAllCategory(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_CategoryGetQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq CategoryGetQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.CategoryGetQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_CategoryGetQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq CategoryGetQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.CategoryGetQuestion(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_CategoryAnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq CategoryAnswerQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.CategoryAnswerQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_CategoryAnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq CategoryAnswerQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.CategoryAnswerQuestion(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_QuicklyGetQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq QuicklyGetQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.QuicklyGetQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_QuicklyGetQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq QuicklyGetQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.QuicklyGetQuestion(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_QuicklyAnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq QuicklyAnswerQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.QuicklyAnswerQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_QuicklyAnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq QuicklyAnswerQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.QuicklyAnswerQuestion(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_GetRecord_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetRecordReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.GetRecord(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_GetRecord_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetRecordReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.GetRecord(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_GetQuestionInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetQuestionInfoReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.GetQuestionInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_GetQuestionInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetQuestionInfoReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.GetQuestionInfo(ctx, &protoReq)
return msg, metadata, err
}
// RegisterQgdzsHandlerServer registers the http handlers for service Qgdzs to "mux".
// UnaryRPC :call QgdzsServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQgdzsHandlerFromEndpoint instead.
// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
func RegisterQgdzsHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QgdzsServer) error {
mux.Handle(http.MethodPost, pattern_Qgdzs_GenerateQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.Qgdzs/GenerateQuestion", runtime.WithHTTPPathPattern("/qgdzs/auth/generate_question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_GenerateQuestion_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_GenerateQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_RandomGetQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.Qgdzs/RandomGetQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/random/question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_RandomGetQuestion_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_RandomGetQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_RandomAnswerQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.Qgdzs/RandomAnswerQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/random/answer"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_RandomAnswerQuestion_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_RandomAnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetAllCategory_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.Qgdzs/GetAllCategory", runtime.WithHTTPPathPattern("/qgdzs/open/category/get_category"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_GetAllCategory_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_GetAllCategory_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_CategoryGetQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.Qgdzs/CategoryGetQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/category/question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_CategoryGetQuestion_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_CategoryGetQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_CategoryAnswerQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.Qgdzs/CategoryAnswerQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/category/answer"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_CategoryAnswerQuestion_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_CategoryAnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_QuicklyGetQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.Qgdzs/QuicklyGetQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/quickly/question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_QuicklyGetQuestion_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_QuicklyGetQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_QuicklyAnswerQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.Qgdzs/QuicklyAnswerQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/quickly/answer"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_QuicklyAnswerQuestion_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_QuicklyAnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.Qgdzs/GetRecord", runtime.WithHTTPPathPattern("/qgdzs/auth/get_record"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_GetRecord_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_GetRecord_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetQuestionInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.Qgdzs/GetQuestionInfo", runtime.WithHTTPPathPattern("/qgdzs/open/get_question_info"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_GetQuestionInfo_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_GetQuestionInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterQgdzsHandlerFromEndpoint is same as RegisterQgdzsHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterQgdzsHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.NewClient(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterQgdzsHandler(ctx, mux, conn)
}
// RegisterQgdzsHandler registers the http handlers for service Qgdzs to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterQgdzsHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterQgdzsHandlerClient(ctx, mux, NewQgdzsClient(conn))
}
// RegisterQgdzsHandlerClient registers the http handlers for service Qgdzs
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QgdzsClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QgdzsClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "QgdzsClient" to call the correct interceptors. This client ignores the HTTP middlewares.
func RegisterQgdzsHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QgdzsClient) error {
mux.Handle(http.MethodPost, pattern_Qgdzs_GenerateQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.Qgdzs/GenerateQuestion", runtime.WithHTTPPathPattern("/qgdzs/auth/generate_question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_GenerateQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_GenerateQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_RandomGetQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.Qgdzs/RandomGetQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/random/question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_RandomGetQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_RandomGetQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_RandomAnswerQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.Qgdzs/RandomAnswerQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/random/answer"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_RandomAnswerQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_RandomAnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetAllCategory_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.Qgdzs/GetAllCategory", runtime.WithHTTPPathPattern("/qgdzs/open/category/get_category"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_GetAllCategory_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_GetAllCategory_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_CategoryGetQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.Qgdzs/CategoryGetQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/category/question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_CategoryGetQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_CategoryGetQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_CategoryAnswerQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.Qgdzs/CategoryAnswerQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/category/answer"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_CategoryAnswerQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_CategoryAnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_QuicklyGetQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.Qgdzs/QuicklyGetQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/quickly/question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_QuicklyGetQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_QuicklyGetQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_QuicklyAnswerQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.Qgdzs/QuicklyAnswerQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/quickly/answer"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_QuicklyAnswerQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_QuicklyAnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.Qgdzs/GetRecord", runtime.WithHTTPPathPattern("/qgdzs/auth/get_record"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_GetRecord_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_GetRecord_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetQuestionInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.Qgdzs/GetQuestionInfo", runtime.WithHTTPPathPattern("/qgdzs/open/get_question_info"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_GetQuestionInfo_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_GetQuestionInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_Qgdzs_GenerateQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"qgdzs", "auth", "generate_question"}, ""))
pattern_Qgdzs_RandomGetQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "random", "question"}, ""))
pattern_Qgdzs_RandomAnswerQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "random", "answer"}, ""))
pattern_Qgdzs_GetAllCategory_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "category", "get_category"}, ""))
pattern_Qgdzs_CategoryGetQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "category", "question"}, ""))
pattern_Qgdzs_CategoryAnswerQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "category", "answer"}, ""))
pattern_Qgdzs_QuicklyGetQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "quickly", "question"}, ""))
pattern_Qgdzs_QuicklyAnswerQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "quickly", "answer"}, ""))
pattern_Qgdzs_GetRecord_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"qgdzs", "auth", "get_record"}, ""))
pattern_Qgdzs_GetQuestionInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"qgdzs", "open", "get_question_info"}, ""))
)
var (
forward_Qgdzs_GenerateQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_RandomGetQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_RandomAnswerQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetAllCategory_0 = runtime.ForwardResponseMessage
forward_Qgdzs_CategoryGetQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_CategoryAnswerQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_QuicklyGetQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_QuicklyAnswerQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetRecord_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetQuestionInfo_0 = runtime.ForwardResponseMessage
)

View File

@@ -0,0 +1,457 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v4.25.1
// source: service_qgdzs.proto
package grpc_pb
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// QgdzsClient is the client API for Qgdzs service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type QgdzsClient interface {
// 生成题目
GenerateQuestion(ctx context.Context, in *GenerateQuestionReq, opts ...grpc.CallOption) (*GenerateQuestionResp, error)
// ---------- 随机答题 ----------
// 获取题目
RandomGetQuestion(ctx context.Context, in *RandomGetQuestionReq, opts ...grpc.CallOption) (*RandomGetQuestionResp, error)
// 回答题目
RandomAnswerQuestion(ctx context.Context, in *RandomAnswerQuestionReq, opts ...grpc.CallOption) (*RandomAnswerQuestionResp, error)
// ---------- 类目答题 ----------
// 获取所有类目
GetAllCategory(ctx context.Context, in *GetAllCategoryReq, opts ...grpc.CallOption) (*GetAllCategoryResp, error)
// 获取题目
CategoryGetQuestion(ctx context.Context, in *CategoryGetQuestionReq, opts ...grpc.CallOption) (*CategoryGetQuestionResp, error)
// 回答题目
CategoryAnswerQuestion(ctx context.Context, in *CategoryAnswerQuestionReq, opts ...grpc.CallOption) (*CategoryAnswerQuestionResp, error)
// ---------- 快速答题 ----------
// 获取题目
QuicklyGetQuestion(ctx context.Context, in *QuicklyGetQuestionReq, opts ...grpc.CallOption) (*QuicklyGetQuestionResp, error)
// 回答题目
QuicklyAnswerQuestion(ctx context.Context, in *QuicklyAnswerQuestionReq, opts ...grpc.CallOption) (*QuicklyAnswerQuestionResp, error)
// ---------- 答题记录 ----------
// 获取答题记录
GetRecord(ctx context.Context, in *GetRecordReq, opts ...grpc.CallOption) (*GetRecordResp, error)
// 获取具体的题目
GetQuestionInfo(ctx context.Context, in *GetQuestionInfoReq, opts ...grpc.CallOption) (*GetQuestionInfoResp, error)
}
type qgdzsClient struct {
cc grpc.ClientConnInterface
}
func NewQgdzsClient(cc grpc.ClientConnInterface) QgdzsClient {
return &qgdzsClient{cc}
}
func (c *qgdzsClient) GenerateQuestion(ctx context.Context, in *GenerateQuestionReq, opts ...grpc.CallOption) (*GenerateQuestionResp, error) {
out := new(GenerateQuestionResp)
err := c.cc.Invoke(ctx, "/Qgdzs/GenerateQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) RandomGetQuestion(ctx context.Context, in *RandomGetQuestionReq, opts ...grpc.CallOption) (*RandomGetQuestionResp, error) {
out := new(RandomGetQuestionResp)
err := c.cc.Invoke(ctx, "/Qgdzs/RandomGetQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) RandomAnswerQuestion(ctx context.Context, in *RandomAnswerQuestionReq, opts ...grpc.CallOption) (*RandomAnswerQuestionResp, error) {
out := new(RandomAnswerQuestionResp)
err := c.cc.Invoke(ctx, "/Qgdzs/RandomAnswerQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) GetAllCategory(ctx context.Context, in *GetAllCategoryReq, opts ...grpc.CallOption) (*GetAllCategoryResp, error) {
out := new(GetAllCategoryResp)
err := c.cc.Invoke(ctx, "/Qgdzs/GetAllCategory", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) CategoryGetQuestion(ctx context.Context, in *CategoryGetQuestionReq, opts ...grpc.CallOption) (*CategoryGetQuestionResp, error) {
out := new(CategoryGetQuestionResp)
err := c.cc.Invoke(ctx, "/Qgdzs/CategoryGetQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) CategoryAnswerQuestion(ctx context.Context, in *CategoryAnswerQuestionReq, opts ...grpc.CallOption) (*CategoryAnswerQuestionResp, error) {
out := new(CategoryAnswerQuestionResp)
err := c.cc.Invoke(ctx, "/Qgdzs/CategoryAnswerQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) QuicklyGetQuestion(ctx context.Context, in *QuicklyGetQuestionReq, opts ...grpc.CallOption) (*QuicklyGetQuestionResp, error) {
out := new(QuicklyGetQuestionResp)
err := c.cc.Invoke(ctx, "/Qgdzs/QuicklyGetQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) QuicklyAnswerQuestion(ctx context.Context, in *QuicklyAnswerQuestionReq, opts ...grpc.CallOption) (*QuicklyAnswerQuestionResp, error) {
out := new(QuicklyAnswerQuestionResp)
err := c.cc.Invoke(ctx, "/Qgdzs/QuicklyAnswerQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) GetRecord(ctx context.Context, in *GetRecordReq, opts ...grpc.CallOption) (*GetRecordResp, error) {
out := new(GetRecordResp)
err := c.cc.Invoke(ctx, "/Qgdzs/GetRecord", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) GetQuestionInfo(ctx context.Context, in *GetQuestionInfoReq, opts ...grpc.CallOption) (*GetQuestionInfoResp, error) {
out := new(GetQuestionInfoResp)
err := c.cc.Invoke(ctx, "/Qgdzs/GetQuestionInfo", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// QgdzsServer is the server API for Qgdzs service.
// All implementations must embed UnimplementedQgdzsServer
// for forward compatibility
type QgdzsServer interface {
// 生成题目
GenerateQuestion(context.Context, *GenerateQuestionReq) (*GenerateQuestionResp, error)
// ---------- 随机答题 ----------
// 获取题目
RandomGetQuestion(context.Context, *RandomGetQuestionReq) (*RandomGetQuestionResp, error)
// 回答题目
RandomAnswerQuestion(context.Context, *RandomAnswerQuestionReq) (*RandomAnswerQuestionResp, error)
// ---------- 类目答题 ----------
// 获取所有类目
GetAllCategory(context.Context, *GetAllCategoryReq) (*GetAllCategoryResp, error)
// 获取题目
CategoryGetQuestion(context.Context, *CategoryGetQuestionReq) (*CategoryGetQuestionResp, error)
// 回答题目
CategoryAnswerQuestion(context.Context, *CategoryAnswerQuestionReq) (*CategoryAnswerQuestionResp, error)
// ---------- 快速答题 ----------
// 获取题目
QuicklyGetQuestion(context.Context, *QuicklyGetQuestionReq) (*QuicklyGetQuestionResp, error)
// 回答题目
QuicklyAnswerQuestion(context.Context, *QuicklyAnswerQuestionReq) (*QuicklyAnswerQuestionResp, error)
// ---------- 答题记录 ----------
// 获取答题记录
GetRecord(context.Context, *GetRecordReq) (*GetRecordResp, error)
// 获取具体的题目
GetQuestionInfo(context.Context, *GetQuestionInfoReq) (*GetQuestionInfoResp, error)
mustEmbedUnimplementedQgdzsServer()
}
// UnimplementedQgdzsServer must be embedded to have forward compatible implementations.
type UnimplementedQgdzsServer struct {
}
func (UnimplementedQgdzsServer) GenerateQuestion(context.Context, *GenerateQuestionReq) (*GenerateQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GenerateQuestion not implemented")
}
func (UnimplementedQgdzsServer) RandomGetQuestion(context.Context, *RandomGetQuestionReq) (*RandomGetQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method RandomGetQuestion not implemented")
}
func (UnimplementedQgdzsServer) RandomAnswerQuestion(context.Context, *RandomAnswerQuestionReq) (*RandomAnswerQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method RandomAnswerQuestion not implemented")
}
func (UnimplementedQgdzsServer) GetAllCategory(context.Context, *GetAllCategoryReq) (*GetAllCategoryResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetAllCategory not implemented")
}
func (UnimplementedQgdzsServer) CategoryGetQuestion(context.Context, *CategoryGetQuestionReq) (*CategoryGetQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method CategoryGetQuestion not implemented")
}
func (UnimplementedQgdzsServer) CategoryAnswerQuestion(context.Context, *CategoryAnswerQuestionReq) (*CategoryAnswerQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method CategoryAnswerQuestion not implemented")
}
func (UnimplementedQgdzsServer) QuicklyGetQuestion(context.Context, *QuicklyGetQuestionReq) (*QuicklyGetQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method QuicklyGetQuestion not implemented")
}
func (UnimplementedQgdzsServer) QuicklyAnswerQuestion(context.Context, *QuicklyAnswerQuestionReq) (*QuicklyAnswerQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method QuicklyAnswerQuestion not implemented")
}
func (UnimplementedQgdzsServer) GetRecord(context.Context, *GetRecordReq) (*GetRecordResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetRecord not implemented")
}
func (UnimplementedQgdzsServer) GetQuestionInfo(context.Context, *GetQuestionInfoReq) (*GetQuestionInfoResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetQuestionInfo not implemented")
}
func (UnimplementedQgdzsServer) mustEmbedUnimplementedQgdzsServer() {}
// UnsafeQgdzsServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to QgdzsServer will
// result in compilation errors.
type UnsafeQgdzsServer interface {
mustEmbedUnimplementedQgdzsServer()
}
func RegisterQgdzsServer(s grpc.ServiceRegistrar, srv QgdzsServer) {
s.RegisterService(&Qgdzs_ServiceDesc, srv)
}
func _Qgdzs_GenerateQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GenerateQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).GenerateQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/GenerateQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).GenerateQuestion(ctx, req.(*GenerateQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_RandomGetQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RandomGetQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).RandomGetQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/RandomGetQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).RandomGetQuestion(ctx, req.(*RandomGetQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_RandomAnswerQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RandomAnswerQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).RandomAnswerQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/RandomAnswerQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).RandomAnswerQuestion(ctx, req.(*RandomAnswerQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_GetAllCategory_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetAllCategoryReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).GetAllCategory(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/GetAllCategory",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).GetAllCategory(ctx, req.(*GetAllCategoryReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_CategoryGetQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CategoryGetQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).CategoryGetQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/CategoryGetQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).CategoryGetQuestion(ctx, req.(*CategoryGetQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_CategoryAnswerQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CategoryAnswerQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).CategoryAnswerQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/CategoryAnswerQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).CategoryAnswerQuestion(ctx, req.(*CategoryAnswerQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_QuicklyGetQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QuicklyGetQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).QuicklyGetQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/QuicklyGetQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).QuicklyGetQuestion(ctx, req.(*QuicklyGetQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_QuicklyAnswerQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QuicklyAnswerQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).QuicklyAnswerQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/QuicklyAnswerQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).QuicklyAnswerQuestion(ctx, req.(*QuicklyAnswerQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_GetRecord_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetRecordReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).GetRecord(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/GetRecord",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).GetRecord(ctx, req.(*GetRecordReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_GetQuestionInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetQuestionInfoReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).GetQuestionInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/GetQuestionInfo",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).GetQuestionInfo(ctx, req.(*GetQuestionInfoReq))
}
return interceptor(ctx, in, info, handler)
}
// Qgdzs_ServiceDesc is the grpc.ServiceDesc for Qgdzs service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Qgdzs_ServiceDesc = grpc.ServiceDesc{
ServiceName: "Qgdzs",
HandlerType: (*QgdzsServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GenerateQuestion",
Handler: _Qgdzs_GenerateQuestion_Handler,
},
{
MethodName: "RandomGetQuestion",
Handler: _Qgdzs_RandomGetQuestion_Handler,
},
{
MethodName: "RandomAnswerQuestion",
Handler: _Qgdzs_RandomAnswerQuestion_Handler,
},
{
MethodName: "GetAllCategory",
Handler: _Qgdzs_GetAllCategory_Handler,
},
{
MethodName: "CategoryGetQuestion",
Handler: _Qgdzs_CategoryGetQuestion_Handler,
},
{
MethodName: "CategoryAnswerQuestion",
Handler: _Qgdzs_CategoryAnswerQuestion_Handler,
},
{
MethodName: "QuicklyGetQuestion",
Handler: _Qgdzs_QuicklyGetQuestion_Handler,
},
{
MethodName: "QuicklyAnswerQuestion",
Handler: _Qgdzs_QuicklyAnswerQuestion_Handler,
},
{
MethodName: "GetRecord",
Handler: _Qgdzs_GetRecord_Handler,
},
{
MethodName: "GetQuestionInfo",
Handler: _Qgdzs_GetQuestionInfo_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "service_qgdzs.proto",
}

View File

@@ -26,9 +26,9 @@ type EnterReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,1,opt,name=USN,proto3" json:"USN,omitempty"` // 用户ID
GatewaySID string `protobuf:"bytes,2,opt,name=GatewaySID,proto3" json:"GatewaySID,omitempty"` // 网关服务ID
InstanceID int32 `protobuf:"varint,3,opt,name=InstanceID,proto3" json:"InstanceID,omitempty"` // 副本ID
USN int64 `protobuf:"varint,1,opt,name=USN,proto3" json:"USN,omitempty"` // 用户ID
GatewaySID int64 `protobuf:"varint,2,opt,name=GatewaySID,proto3" json:"GatewaySID,omitempty"` // 网关服务ID
InstanceID int32 `protobuf:"varint,3,opt,name=InstanceID,proto3" json:"InstanceID,omitempty"` // 副本ID
}
func (x *EnterReq) Reset() {
@@ -63,18 +63,18 @@ func (*EnterReq) Descriptor() ([]byte, []int) {
return file_service_scene_proto_rawDescGZIP(), []int{0}
}
func (x *EnterReq) GetUSN() string {
func (x *EnterReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
func (x *EnterReq) GetGatewaySID() string {
func (x *EnterReq) GetGatewaySID() int64 {
if x != nil {
return x.GatewaySID
}
return ""
return 0
}
func (x *EnterReq) GetInstanceID() int32 {
@@ -89,8 +89,8 @@ type EnterResp struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
SceneSID string `protobuf:"bytes,1,opt,name=SceneSID,proto3" json:"SceneSID,omitempty"` // 场景服务ID
UniqueNo string `protobuf:"bytes,2,opt,name=UniqueNo,proto3" json:"UniqueNo,omitempty"` // 副本唯一编号
SceneSID int64 `protobuf:"varint,1,opt,name=SceneSID,proto3" json:"SceneSID,omitempty"` // 场景服务ID
UniqueNo int64 `protobuf:"varint,2,opt,name=UniqueNo,proto3" json:"UniqueNo,omitempty"` // 副本唯一编号
MessageID int32 `protobuf:"varint,3,opt,name=MessageID,proto3" json:"MessageID,omitempty"` // 发送给客户端的消息ID
Payload []byte `protobuf:"bytes,4,opt,name=Payload,proto3" json:"Payload,omitempty"` // 消息负载
}
@@ -127,18 +127,18 @@ func (*EnterResp) Descriptor() ([]byte, []int) {
return file_service_scene_proto_rawDescGZIP(), []int{1}
}
func (x *EnterResp) GetSceneSID() string {
func (x *EnterResp) GetSceneSID() int64 {
if x != nil {
return x.SceneSID
}
return ""
return 0
}
func (x *EnterResp) GetUniqueNo() string {
func (x *EnterResp) GetUniqueNo() int64 {
if x != nil {
return x.UniqueNo
}
return ""
return 0
}
func (x *EnterResp) GetMessageID() int32 {
@@ -160,8 +160,8 @@ type LeaveReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,1,opt,name=USN,proto3" json:"USN,omitempty"` // 用户ID
UniqueNo string `protobuf:"bytes,2,opt,name=UniqueNo,proto3" json:"UniqueNo,omitempty"` // 副本唯一编号
USN int64 `protobuf:"varint,1,opt,name=USN,proto3" json:"USN,omitempty"` // 用户ID
UniqueNo int64 `protobuf:"varint,2,opt,name=UniqueNo,proto3" json:"UniqueNo,omitempty"` // 副本唯一编号
}
func (x *LeaveReq) Reset() {
@@ -196,18 +196,18 @@ func (*LeaveReq) Descriptor() ([]byte, []int) {
return file_service_scene_proto_rawDescGZIP(), []int{2}
}
func (x *LeaveReq) GetUSN() string {
func (x *LeaveReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
func (x *LeaveReq) GetUniqueNo() string {
func (x *LeaveReq) GetUniqueNo() int64 {
if x != nil {
return x.UniqueNo
}
return ""
return 0
}
type LeaveResp struct {
@@ -253,12 +253,12 @@ type ActionReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UniqueNo string `protobuf:"bytes,1,opt,name=UniqueNo,proto3" json:"UniqueNo,omitempty"` // 副本唯一编号
USN string `protobuf:"bytes,2,opt,name=USN,proto3" json:"USN,omitempty"` // 用户ID
Action int32 `protobuf:"varint,3,opt,name=Action,proto3" json:"Action,omitempty"` // 指令ID
DirX int32 `protobuf:"zigzag32,4,opt,name=DirX,proto3" json:"DirX,omitempty"` // 移动-X方向×1000 缩放)
DirY int32 `protobuf:"zigzag32,5,opt,name=DirY,proto3" json:"DirY,omitempty"` // 移动-Y方向×1000 缩放)
SkillID int32 `protobuf:"varint,6,opt,name=SkillID,proto3" json:"SkillID,omitempty"` // 攻击-技能ID
UniqueNo int64 `protobuf:"varint,1,opt,name=UniqueNo,proto3" json:"UniqueNo,omitempty"` // 副本唯一编号
USN int64 `protobuf:"varint,2,opt,name=USN,proto3" json:"USN,omitempty"` // 用户ID
Action int32 `protobuf:"varint,3,opt,name=Action,proto3" json:"Action,omitempty"` // 指令ID
DirX int32 `protobuf:"zigzag32,4,opt,name=DirX,proto3" json:"DirX,omitempty"` // 移动-X方向×1000 缩放)
DirY int32 `protobuf:"zigzag32,5,opt,name=DirY,proto3" json:"DirY,omitempty"` // 移动-Y方向×1000 缩放)
SkillID int32 `protobuf:"varint,6,opt,name=SkillID,proto3" json:"SkillID,omitempty"` // 攻击-技能ID
}
func (x *ActionReq) Reset() {
@@ -293,18 +293,18 @@ func (*ActionReq) Descriptor() ([]byte, []int) {
return file_service_scene_proto_rawDescGZIP(), []int{4}
}
func (x *ActionReq) GetUniqueNo() string {
func (x *ActionReq) GetUniqueNo() int64 {
if x != nil {
return x.UniqueNo
}
return ""
return 0
}
func (x *ActionReq) GetUSN() string {
func (x *ActionReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
func (x *ActionReq) GetAction() int32 {
@@ -379,27 +379,27 @@ var file_service_scene_proto_rawDesc = []byte{
0x0a, 0x13, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x73, 0x63, 0x65, 0x6e, 0x65, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x72, 0x73, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5c, 0x0a, 0x08, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x52,
0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
0x03, 0x55, 0x53, 0x4e, 0x12, 0x1e, 0x0a, 0x0a, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53,
0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61,
0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61,
0x79, 0x53, 0x49, 0x44, 0x12, 0x1e, 0x0a, 0x0a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65,
0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e,
0x63, 0x65, 0x49, 0x44, 0x22, 0x7b, 0x0a, 0x09, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73,
0x70, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x63, 0x65, 0x6e, 0x65, 0x53, 0x49, 0x44, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x08, 0x53, 0x63, 0x65, 0x6e, 0x65, 0x53, 0x49, 0x44, 0x12, 0x1a, 0x0a,
0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x4e, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x01, 0x28, 0x03, 0x52, 0x08, 0x53, 0x63, 0x65, 0x6e, 0x65, 0x53, 0x49, 0x44, 0x12, 0x1a, 0x0a,
0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x4e, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x4e, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x4d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x4d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f,
0x61, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61,
0x64, 0x22, 0x38, 0x0a, 0x08, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a,
0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x55, 0x53, 0x4e, 0x12,
0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x55, 0x53, 0x4e, 0x12,
0x1a, 0x0a, 0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x4e, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x4e, 0x6f, 0x22, 0x0b, 0x0a, 0x09, 0x4c,
0x03, 0x52, 0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x4e, 0x6f, 0x22, 0x0b, 0x0a, 0x09, 0x4c,
0x65, 0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x93, 0x01, 0x0a, 0x09, 0x41, 0x63, 0x74,
0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65,
0x4e, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65,
0x4e, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x4e, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65,
0x4e, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
0x03, 0x55, 0x53, 0x4e, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03,
0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04,
0x44, 0x69, 0x72, 0x58, 0x18, 0x04, 0x20, 0x01, 0x28, 0x11, 0x52, 0x04, 0x44, 0x69, 0x72, 0x58,

View File

@@ -22,8 +22,8 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// ---------- Login ----------
type LoginReq struct {
// ---------- PhoneLogin ----------
type PhoneLoginReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
@@ -32,8 +32,8 @@ type LoginReq struct {
Code string `protobuf:"bytes,2,opt,name=Code,json=code,proto3" json:"Code,omitempty"` // 验证码
}
func (x *LoginReq) Reset() {
*x = LoginReq{}
func (x *PhoneLoginReq) Reset() {
*x = PhoneLoginReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -41,13 +41,13 @@ func (x *LoginReq) Reset() {
}
}
func (x *LoginReq) String() string {
func (x *PhoneLoginReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LoginReq) ProtoMessage() {}
func (*PhoneLoginReq) ProtoMessage() {}
func (x *LoginReq) ProtoReflect() protoreflect.Message {
func (x *PhoneLoginReq) ProtoReflect() protoreflect.Message {
mi := &file_service_user_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -59,36 +59,36 @@ func (x *LoginReq) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use LoginReq.ProtoReflect.Descriptor instead.
func (*LoginReq) Descriptor() ([]byte, []int) {
// Deprecated: Use PhoneLoginReq.ProtoReflect.Descriptor instead.
func (*PhoneLoginReq) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{0}
}
func (x *LoginReq) GetPhone() string {
func (x *PhoneLoginReq) GetPhone() string {
if x != nil {
return x.Phone
}
return ""
}
func (x *LoginReq) GetCode() string {
func (x *PhoneLoginReq) GetCode() string {
if x != nil {
return x.Code
}
return ""
}
type LoginResp struct {
type PhoneLoginResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,1,opt,name=USN,json=usn,proto3" json:"USN,omitempty"` // 用户ID
USN int64 `protobuf:"varint,1,opt,name=USN,json=usn,proto3" json:"USN,omitempty"` // 用户ID
Name string `protobuf:"bytes,2,opt,name=Name,json=name,proto3" json:"Name,omitempty"` // 用户名
}
func (x *LoginResp) Reset() {
*x = LoginResp{}
func (x *PhoneLoginResp) Reset() {
*x = PhoneLoginResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -96,13 +96,13 @@ func (x *LoginResp) Reset() {
}
}
func (x *LoginResp) String() string {
func (x *PhoneLoginResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LoginResp) ProtoMessage() {}
func (*PhoneLoginResp) ProtoMessage() {}
func (x *LoginResp) ProtoReflect() protoreflect.Message {
func (x *PhoneLoginResp) ProtoReflect() protoreflect.Message {
mi := &file_service_user_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -114,19 +114,122 @@ func (x *LoginResp) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use LoginResp.ProtoReflect.Descriptor instead.
func (*LoginResp) Descriptor() ([]byte, []int) {
// Deprecated: Use PhoneLoginResp.ProtoReflect.Descriptor instead.
func (*PhoneLoginResp) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{1}
}
func (x *LoginResp) GetUSN() string {
func (x *PhoneLoginResp) GetUSN() int64 {
if x != nil {
return x.USN
}
return 0
}
func (x *PhoneLoginResp) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *LoginResp) GetName() string {
// ---------- WxMiniLogin ----------
type WxMiniLoginReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Code string `protobuf:"bytes,1,opt,name=Code,json=code,proto3" json:"Code,omitempty"` // 微信小程序登录凭证
}
func (x *WxMiniLoginReq) Reset() {
*x = WxMiniLoginReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *WxMiniLoginReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*WxMiniLoginReq) ProtoMessage() {}
func (x *WxMiniLoginReq) ProtoReflect() protoreflect.Message {
mi := &file_service_user_proto_msgTypes[2]
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 WxMiniLoginReq.ProtoReflect.Descriptor instead.
func (*WxMiniLoginReq) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{2}
}
func (x *WxMiniLoginReq) GetCode() string {
if x != nil {
return x.Code
}
return ""
}
type WxMiniLoginResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN int64 `protobuf:"varint,1,opt,name=USN,json=usn,proto3" json:"USN,omitempty"` // 用户ID
Name string `protobuf:"bytes,2,opt,name=Name,json=name,proto3" json:"Name,omitempty"` // 用户名
}
func (x *WxMiniLoginResp) Reset() {
*x = WxMiniLoginResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *WxMiniLoginResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*WxMiniLoginResp) ProtoMessage() {}
func (x *WxMiniLoginResp) ProtoReflect() protoreflect.Message {
mi := &file_service_user_proto_msgTypes[3]
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 WxMiniLoginResp.ProtoReflect.Descriptor instead.
func (*WxMiniLoginResp) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{3}
}
func (x *WxMiniLoginResp) GetUSN() int64 {
if x != nil {
return x.USN
}
return 0
}
func (x *WxMiniLoginResp) GetName() string {
if x != nil {
return x.Name
}
@@ -139,13 +242,13 @@ type GetUserInfoReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,1,opt,name=USN,json=usn,proto3" json:"USN,omitempty"`
USN int64 `protobuf:"varint,1,opt,name=USN,json=usn,proto3" json:"USN,omitempty"`
}
func (x *GetUserInfoReq) Reset() {
*x = GetUserInfoReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[2]
mi := &file_service_user_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -158,7 +261,7 @@ func (x *GetUserInfoReq) String() string {
func (*GetUserInfoReq) ProtoMessage() {}
func (x *GetUserInfoReq) ProtoReflect() protoreflect.Message {
mi := &file_service_user_proto_msgTypes[2]
mi := &file_service_user_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -171,14 +274,14 @@ func (x *GetUserInfoReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetUserInfoReq.ProtoReflect.Descriptor instead.
func (*GetUserInfoReq) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{2}
return file_service_user_proto_rawDescGZIP(), []int{4}
}
func (x *GetUserInfoReq) GetUSN() string {
func (x *GetUserInfoReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
type GetUserInfoResp struct {
@@ -186,14 +289,14 @@ type GetUserInfoResp struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,1,opt,name=USN,json=usn,proto3" json:"USN,omitempty"`
USN int64 `protobuf:"varint,1,opt,name=USN,json=usn,proto3" json:"USN,omitempty"`
Name string `protobuf:"bytes,2,opt,name=Name,json=name,proto3" json:"Name,omitempty"`
}
func (x *GetUserInfoResp) Reset() {
*x = GetUserInfoResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[3]
mi := &file_service_user_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -206,7 +309,7 @@ func (x *GetUserInfoResp) String() string {
func (*GetUserInfoResp) ProtoMessage() {}
func (x *GetUserInfoResp) ProtoReflect() protoreflect.Message {
mi := &file_service_user_proto_msgTypes[3]
mi := &file_service_user_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -219,14 +322,14 @@ func (x *GetUserInfoResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetUserInfoResp.ProtoReflect.Descriptor instead.
func (*GetUserInfoResp) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{3}
return file_service_user_proto_rawDescGZIP(), []int{5}
}
func (x *GetUserInfoResp) GetUSN() string {
func (x *GetUserInfoResp) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
func (x *GetUserInfoResp) GetName() string {
@@ -236,313 +339,6 @@ func (x *GetUserInfoResp) GetName() string {
return ""
}
// ---------- GenerateQuestion ----------
type GenerateQuestionReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Num int32 `protobuf:"varint,1,opt,name=Num,json=num,proto3" json:"Num,omitempty"` // 生成数量
Category string `protobuf:"bytes,2,opt,name=Category,json=category,proto3" json:"Category,omitempty"` // 题目类型
}
func (x *GenerateQuestionReq) Reset() {
*x = GenerateQuestionReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GenerateQuestionReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GenerateQuestionReq) ProtoMessage() {}
func (x *GenerateQuestionReq) ProtoReflect() protoreflect.Message {
mi := &file_service_user_proto_msgTypes[4]
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 GenerateQuestionReq.ProtoReflect.Descriptor instead.
func (*GenerateQuestionReq) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{4}
}
func (x *GenerateQuestionReq) GetNum() int32 {
if x != nil {
return x.Num
}
return 0
}
func (x *GenerateQuestionReq) GetCategory() string {
if x != nil {
return x.Category
}
return ""
}
type GenerateQuestionResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *GenerateQuestionResp) Reset() {
*x = GenerateQuestionResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GenerateQuestionResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GenerateQuestionResp) ProtoMessage() {}
func (x *GenerateQuestionResp) ProtoReflect() protoreflect.Message {
mi := &file_service_user_proto_msgTypes[5]
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 GenerateQuestionResp.ProtoReflect.Descriptor instead.
func (*GenerateQuestionResp) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{5}
}
// ---------- GetQuestion ----------
type GetQuestionReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *GetQuestionReq) Reset() {
*x = GetQuestionReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetQuestionReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetQuestionReq) ProtoMessage() {}
func (x *GetQuestionReq) ProtoReflect() protoreflect.Message {
mi := &file_service_user_proto_msgTypes[6]
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 GetQuestionReq.ProtoReflect.Descriptor instead.
func (*GetQuestionReq) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{6}
}
type GetQuestionResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Sn string `protobuf:"bytes,1,opt,name=Sn,json=sn,proto3" json:"Sn,omitempty"` // 题目唯一标识
Question string `protobuf:"bytes,2,opt,name=Question,json=question,proto3" json:"Question,omitempty"` // 题干
Options []string `protobuf:"bytes,3,rep,name=Options,json=options,proto3" json:"Options,omitempty"` // 选项
}
func (x *GetQuestionResp) Reset() {
*x = GetQuestionResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetQuestionResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetQuestionResp) ProtoMessage() {}
func (x *GetQuestionResp) ProtoReflect() protoreflect.Message {
mi := &file_service_user_proto_msgTypes[7]
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 GetQuestionResp.ProtoReflect.Descriptor instead.
func (*GetQuestionResp) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{7}
}
func (x *GetQuestionResp) GetSn() string {
if x != nil {
return x.Sn
}
return ""
}
func (x *GetQuestionResp) GetQuestion() string {
if x != nil {
return x.Question
}
return ""
}
func (x *GetQuestionResp) GetOptions() []string {
if x != nil {
return x.Options
}
return nil
}
// ---------- AnswerQuestion ----------
type AnswerQuestionReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Sn string `protobuf:"bytes,1,opt,name=Sn,json=sn,proto3" json:"Sn,omitempty"` // 题目唯一标识
Answer string `protobuf:"bytes,2,opt,name=Answer,json=answer,proto3" json:"Answer,omitempty"` // 答案
}
func (x *AnswerQuestionReq) Reset() {
*x = AnswerQuestionReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AnswerQuestionReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AnswerQuestionReq) ProtoMessage() {}
func (x *AnswerQuestionReq) ProtoReflect() protoreflect.Message {
mi := &file_service_user_proto_msgTypes[8]
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 AnswerQuestionReq.ProtoReflect.Descriptor instead.
func (*AnswerQuestionReq) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{8}
}
func (x *AnswerQuestionReq) GetSn() string {
if x != nil {
return x.Sn
}
return ""
}
func (x *AnswerQuestionReq) GetAnswer() string {
if x != nil {
return x.Answer
}
return ""
}
type AnswerQuestionResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Answer string `protobuf:"bytes,1,opt,name=Answer,json=answer,proto3" json:"Answer,omitempty"` // 答案
Explanation string `protobuf:"bytes,2,opt,name=Explanation,json=explanation,proto3" json:"Explanation,omitempty"` // 解析
}
func (x *AnswerQuestionResp) Reset() {
*x = AnswerQuestionResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AnswerQuestionResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AnswerQuestionResp) ProtoMessage() {}
func (x *AnswerQuestionResp) ProtoReflect() protoreflect.Message {
mi := &file_service_user_proto_msgTypes[9]
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 AnswerQuestionResp.ProtoReflect.Descriptor instead.
func (*AnswerQuestionResp) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{9}
}
func (x *AnswerQuestionResp) GetAnswer() string {
if x != nil {
return x.Answer
}
return ""
}
func (x *AnswerQuestionResp) GetExplanation() string {
if x != nil {
return x.Explanation
}
return ""
}
var File_service_user_proto protoreflect.FileDescriptor
var file_service_user_proto_rawDesc = []byte{
@@ -550,69 +346,41 @@ var file_service_user_proto_rawDesc = []byte{
0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x72, 0x73, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70,
0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x22, 0x34, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12,
0x14, 0x0a, 0x05, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x22, 0x31, 0x0a, 0x09, 0x4c, 0x6f, 0x67,
0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x73, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x22, 0x0a, 0x0e,
0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x10,
0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x73, 0x6e,
0x22, 0x37, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52,
0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x03, 0x75, 0x73, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x43, 0x0a, 0x13, 0x47, 0x65, 0x6e,
0x65, 0x72, 0x61, 0x74, 0x65, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71,
0x12, 0x10, 0x0a, 0x03, 0x4e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6e,
0x75, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x22, 0x16,
0x0a, 0x14, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69,
0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x10, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65,
0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x22, 0x57, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x51,
0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x53,
0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x73, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x51,
0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x71,
0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x4f, 0x70, 0x74, 0x69, 0x6f,
0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x73, 0x22, 0x3b, 0x0a, 0x11, 0x41, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x51, 0x75, 0x65, 0x73, 0x74,
0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x53, 0x6e, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x02, 0x73, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6e, 0x73, 0x77, 0x65, 0x72,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x22, 0x4e,
0x0a, 0x12, 0x41, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e,
0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b,
0x45, 0x78, 0x70, 0x6c, 0x61, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x0b, 0x65, 0x78, 0x70, 0x6c, 0x61, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0x84,
0x03, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e,
0x12, 0x09, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x0a, 0x2e, 0x4c, 0x6f,
0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x0b, 0x47, 0x65, 0x74,
0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0f, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73,
0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x47, 0x65, 0x74, 0x55,
0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x22, 0x15, 0x82, 0xd3, 0xe4,
0x93, 0x02, 0x0f, 0x3a, 0x01, 0x2a, 0x22, 0x0a, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x69, 0x6e,
0x66, 0x6f, 0x12, 0x63, 0x0a, 0x10, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x51, 0x75,
0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74,
0x65, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x47,
0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52,
0x65, 0x73, 0x70, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x3a, 0x01, 0x2a, 0x22, 0x17,
0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x71,
0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4f, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x51, 0x75,
0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0f, 0x2e, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65, 0x73,
0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65,
0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x1d, 0x82, 0xd3, 0xe4, 0x93, 0x02,
0x17, 0x3a, 0x01, 0x2a, 0x22, 0x12, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x67, 0x65, 0x74, 0x5f,
0x71, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x5b, 0x0a, 0x0e, 0x41, 0x6e, 0x73, 0x77,
0x65, 0x72, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x2e, 0x41, 0x6e, 0x73,
0x77, 0x65, 0x72, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x13,
0x2e, 0x41, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52,
0x65, 0x73, 0x70, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x3a, 0x01, 0x2a, 0x22, 0x15,
0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x5f, 0x71, 0x75, 0x65,
0x73, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x36, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x2e, 0x68, 0x6c, 0x73,
0x71, 0x2e, 0x61, 0x73, 0x69, 0x61, 0x2f, 0x6d, 0x6d, 0x6f, 0x72, 0x70, 0x67, 0x2f, 0x73, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2f, 0x72, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
0x6f, 0x74, 0x6f, 0x22, 0x39, 0x0a, 0x0d, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x4c, 0x6f, 0x67, 0x69,
0x6e, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f,
0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x22, 0x36,
0x0a, 0x0e, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70,
0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x75,
0x73, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x24, 0x0a, 0x0e, 0x57, 0x78, 0x4d, 0x69, 0x6e, 0x69,
0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x22, 0x37, 0x0a, 0x0f,
0x57, 0x78, 0x4d, 0x69, 0x6e, 0x69, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12,
0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x75, 0x73,
0x6e, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x22, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72,
0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01,
0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x75, 0x73, 0x6e, 0x22, 0x37, 0x0a, 0x0f, 0x47, 0x65, 0x74,
0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03,
0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x75, 0x73, 0x6e, 0x12, 0x12,
0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x32, 0xb9, 0x01, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x2f, 0x0a, 0x0a, 0x50,
0x68, 0x6f, 0x6e, 0x65, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x0e, 0x2e, 0x50, 0x68, 0x6f, 0x6e,
0x65, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x50, 0x68, 0x6f, 0x6e,
0x65, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x32, 0x0a, 0x0b,
0x57, 0x78, 0x4d, 0x69, 0x6e, 0x69, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x0f, 0x2e, 0x57, 0x78,
0x4d, 0x69, 0x6e, 0x69, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x57,
0x78, 0x4d, 0x69, 0x6e, 0x69, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00,
0x12, 0x4c, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12,
0x0f, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71,
0x1a, 0x10, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65,
0x73, 0x70, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x01, 0x2a, 0x22, 0x0f, 0x2f,
0x75, 0x73, 0x65, 0x72, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x42, 0x36,
0x5a, 0x34, 0x67, 0x69, 0x74, 0x2e, 0x68, 0x6c, 0x73, 0x71, 0x2e, 0x61, 0x73, 0x69, 0x61, 0x2f,
0x6d, 0x6d, 0x6f, 0x72, 0x70, 0x67, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2d, 0x63,
0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x73, 0x2f, 0x67,
0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -627,32 +395,24 @@ func file_service_user_proto_rawDescGZIP() []byte {
return file_service_user_proto_rawDescData
}
var file_service_user_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_service_user_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_service_user_proto_goTypes = []interface{}{
(*LoginReq)(nil), // 0: LoginReq
(*LoginResp)(nil), // 1: LoginResp
(*GetUserInfoReq)(nil), // 2: GetUserInfoReq
(*GetUserInfoResp)(nil), // 3: GetUserInfoResp
(*GenerateQuestionReq)(nil), // 4: GenerateQuestionReq
(*GenerateQuestionResp)(nil), // 5: GenerateQuestionResp
(*GetQuestionReq)(nil), // 6: GetQuestionReq
(*GetQuestionResp)(nil), // 7: GetQuestionResp
(*AnswerQuestionReq)(nil), // 8: AnswerQuestionReq
(*AnswerQuestionResp)(nil), // 9: AnswerQuestionResp
(*PhoneLoginReq)(nil), // 0: PhoneLoginReq
(*PhoneLoginResp)(nil), // 1: PhoneLoginResp
(*WxMiniLoginReq)(nil), // 2: WxMiniLoginReq
(*WxMiniLoginResp)(nil), // 3: WxMiniLoginResp
(*GetUserInfoReq)(nil), // 4: GetUserInfoReq
(*GetUserInfoResp)(nil), // 5: GetUserInfoResp
}
var file_service_user_proto_depIdxs = []int32{
0, // 0: User.Login:input_type -> LoginReq
2, // 1: User.GetUserInfo:input_type -> GetUserInfoReq
4, // 2: User.GenerateQuestion:input_type -> GenerateQuestionReq
6, // 3: User.GetQuestion:input_type -> GetQuestionReq
8, // 4: User.AnswerQuestion:input_type -> AnswerQuestionReq
1, // 5: User.Login:output_type -> LoginResp
3, // 6: User.GetUserInfo:output_type -> GetUserInfoResp
5, // 7: User.GenerateQuestion:output_type -> GenerateQuestionResp
7, // 8: User.GetQuestion:output_type -> GetQuestionResp
9, // 9: User.AnswerQuestion:output_type -> AnswerQuestionResp
5, // [5:10] is the sub-list for method output_type
0, // [0:5] is the sub-list for method input_type
0, // 0: User.PhoneLogin:input_type -> PhoneLoginReq
2, // 1: User.WxMiniLogin:input_type -> WxMiniLoginReq
4, // 2: User.GetUserInfo:input_type -> GetUserInfoReq
1, // 3: User.PhoneLogin:output_type -> PhoneLoginResp
3, // 4: User.WxMiniLogin:output_type -> WxMiniLoginResp
5, // 5: User.GetUserInfo:output_type -> GetUserInfoResp
3, // [3:6] is the sub-list for method output_type
0, // [0:3] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
@@ -665,7 +425,7 @@ func file_service_user_proto_init() {
}
if !protoimpl.UnsafeEnabled {
file_service_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LoginReq); i {
switch v := v.(*PhoneLoginReq); i {
case 0:
return &v.state
case 1:
@@ -677,7 +437,7 @@ func file_service_user_proto_init() {
}
}
file_service_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LoginResp); i {
switch v := v.(*PhoneLoginResp); i {
case 0:
return &v.state
case 1:
@@ -689,7 +449,7 @@ func file_service_user_proto_init() {
}
}
file_service_user_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetUserInfoReq); i {
switch v := v.(*WxMiniLoginReq); i {
case 0:
return &v.state
case 1:
@@ -701,7 +461,7 @@ func file_service_user_proto_init() {
}
}
file_service_user_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetUserInfoResp); i {
switch v := v.(*WxMiniLoginResp); i {
case 0:
return &v.state
case 1:
@@ -713,7 +473,7 @@ func file_service_user_proto_init() {
}
}
file_service_user_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GenerateQuestionReq); i {
switch v := v.(*GetUserInfoReq); i {
case 0:
return &v.state
case 1:
@@ -725,55 +485,7 @@ func file_service_user_proto_init() {
}
}
file_service_user_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GenerateQuestionResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_user_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetQuestionReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_user_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetQuestionResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_user_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AnswerQuestionReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_user_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AnswerQuestionResp); i {
switch v := v.(*GetUserInfoResp); i {
case 0:
return &v.state
case 1:
@@ -791,7 +503,7 @@ func file_service_user_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_service_user_proto_rawDesc,
NumEnums: 0,
NumMessages: 10,
NumMessages: 6,
NumExtensions: 0,
NumServices: 1,
},

View File

@@ -59,78 +59,6 @@ func local_request_User_GetUserInfo_0(ctx context.Context, marshaler runtime.Mar
return msg, metadata, err
}
func request_User_GenerateQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client UserClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GenerateQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.GenerateQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_User_GenerateQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server UserServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GenerateQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.GenerateQuestion(ctx, &protoReq)
return msg, metadata, err
}
func request_User_GetQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client UserClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.GetQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_User_GetQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server UserServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.GetQuestion(ctx, &protoReq)
return msg, metadata, err
}
func request_User_AnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client UserClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq AnswerQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.AnswerQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_User_AnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server UserServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq AnswerQuestionReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.AnswerQuestion(ctx, &protoReq)
return msg, metadata, err
}
// RegisterUserHandlerServer registers the http handlers for service User to "mux".
// UnaryRPC :call UserServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
@@ -143,7 +71,7 @@ func RegisterUserHandlerServer(ctx context.Context, mux *runtime.ServeMux, serve
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.User/GetUserInfo", runtime.WithHTTPPathPattern("/user/info"))
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.User/GetUserInfo", runtime.WithHTTPPathPattern("/user/auth/info"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
@@ -157,66 +85,6 @@ func RegisterUserHandlerServer(ctx context.Context, mux *runtime.ServeMux, serve
}
forward_User_GetUserInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_User_GenerateQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.User/GenerateQuestion", runtime.WithHTTPPathPattern("/user/generate_question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_User_GenerateQuestion_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_User_GenerateQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_User_GetQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.User/GetQuestion", runtime.WithHTTPPathPattern("/user/get_question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_User_GetQuestion_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_User_GetQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_User_AnswerQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.User/AnswerQuestion", runtime.WithHTTPPathPattern("/user/answer_question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_User_AnswerQuestion_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_User_AnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
@@ -261,7 +129,7 @@ func RegisterUserHandlerClient(ctx context.Context, mux *runtime.ServeMux, clien
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.User/GetUserInfo", runtime.WithHTTPPathPattern("/user/info"))
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.User/GetUserInfo", runtime.WithHTTPPathPattern("/user/auth/info"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
@@ -274,70 +142,13 @@ func RegisterUserHandlerClient(ctx context.Context, mux *runtime.ServeMux, clien
}
forward_User_GetUserInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_User_GenerateQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.User/GenerateQuestion", runtime.WithHTTPPathPattern("/user/generate_question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_User_GenerateQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_User_GenerateQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_User_GetQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.User/GetQuestion", runtime.WithHTTPPathPattern("/user/get_question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_User_GetQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_User_GetQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_User_AnswerQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.User/AnswerQuestion", runtime.WithHTTPPathPattern("/user/answer_question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_User_AnswerQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_User_AnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_User_GetUserInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"user", "info"}, ""))
pattern_User_GenerateQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"user", "generate_question"}, ""))
pattern_User_GetQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"user", "get_question"}, ""))
pattern_User_AnswerQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"user", "answer_question"}, ""))
pattern_User_GetUserInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"user", "auth", "info"}, ""))
)
var (
forward_User_GetUserInfo_0 = runtime.ForwardResponseMessage
forward_User_GenerateQuestion_0 = runtime.ForwardResponseMessage
forward_User_GetQuestion_0 = runtime.ForwardResponseMessage
forward_User_AnswerQuestion_0 = runtime.ForwardResponseMessage
forward_User_GetUserInfo_0 = runtime.ForwardResponseMessage
)

View File

@@ -22,15 +22,10 @@ const _ = grpc.SupportPackageIsVersion7
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type UserClient interface {
Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*LoginResp, error)
PhoneLogin(ctx context.Context, in *PhoneLoginReq, opts ...grpc.CallOption) (*PhoneLoginResp, error)
WxMiniLogin(ctx context.Context, in *WxMiniLoginReq, opts ...grpc.CallOption) (*WxMiniLoginResp, error)
// 获取用户信息
GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error)
// 生成题目
GenerateQuestion(ctx context.Context, in *GenerateQuestionReq, opts ...grpc.CallOption) (*GenerateQuestionResp, error)
// 获取题目
GetQuestion(ctx context.Context, in *GetQuestionReq, opts ...grpc.CallOption) (*GetQuestionResp, error)
// 回答题目
AnswerQuestion(ctx context.Context, in *AnswerQuestionReq, opts ...grpc.CallOption) (*AnswerQuestionResp, error)
}
type userClient struct {
@@ -41,9 +36,18 @@ func NewUserClient(cc grpc.ClientConnInterface) UserClient {
return &userClient{cc}
}
func (c *userClient) Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*LoginResp, error) {
out := new(LoginResp)
err := c.cc.Invoke(ctx, "/User/Login", in, out, opts...)
func (c *userClient) PhoneLogin(ctx context.Context, in *PhoneLoginReq, opts ...grpc.CallOption) (*PhoneLoginResp, error) {
out := new(PhoneLoginResp)
err := c.cc.Invoke(ctx, "/User/PhoneLogin", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userClient) WxMiniLogin(ctx context.Context, in *WxMiniLoginReq, opts ...grpc.CallOption) (*WxMiniLoginResp, error) {
out := new(WxMiniLoginResp)
err := c.cc.Invoke(ctx, "/User/WxMiniLogin", in, out, opts...)
if err != nil {
return nil, err
}
@@ -59,46 +63,14 @@ func (c *userClient) GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts .
return out, nil
}
func (c *userClient) GenerateQuestion(ctx context.Context, in *GenerateQuestionReq, opts ...grpc.CallOption) (*GenerateQuestionResp, error) {
out := new(GenerateQuestionResp)
err := c.cc.Invoke(ctx, "/User/GenerateQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userClient) GetQuestion(ctx context.Context, in *GetQuestionReq, opts ...grpc.CallOption) (*GetQuestionResp, error) {
out := new(GetQuestionResp)
err := c.cc.Invoke(ctx, "/User/GetQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userClient) AnswerQuestion(ctx context.Context, in *AnswerQuestionReq, opts ...grpc.CallOption) (*AnswerQuestionResp, error) {
out := new(AnswerQuestionResp)
err := c.cc.Invoke(ctx, "/User/AnswerQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// UserServer is the server API for User service.
// All implementations must embed UnimplementedUserServer
// for forward compatibility
type UserServer interface {
Login(context.Context, *LoginReq) (*LoginResp, error)
PhoneLogin(context.Context, *PhoneLoginReq) (*PhoneLoginResp, error)
WxMiniLogin(context.Context, *WxMiniLoginReq) (*WxMiniLoginResp, error)
// 获取用户信息
GetUserInfo(context.Context, *GetUserInfoReq) (*GetUserInfoResp, error)
// 生成题目
GenerateQuestion(context.Context, *GenerateQuestionReq) (*GenerateQuestionResp, error)
// 获取题目
GetQuestion(context.Context, *GetQuestionReq) (*GetQuestionResp, error)
// 回答题目
AnswerQuestion(context.Context, *AnswerQuestionReq) (*AnswerQuestionResp, error)
mustEmbedUnimplementedUserServer()
}
@@ -106,21 +78,15 @@ type UserServer interface {
type UnimplementedUserServer struct {
}
func (UnimplementedUserServer) Login(context.Context, *LoginReq) (*LoginResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method Login not implemented")
func (UnimplementedUserServer) PhoneLogin(context.Context, *PhoneLoginReq) (*PhoneLoginResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method PhoneLogin not implemented")
}
func (UnimplementedUserServer) WxMiniLogin(context.Context, *WxMiniLoginReq) (*WxMiniLoginResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method WxMiniLogin not implemented")
}
func (UnimplementedUserServer) GetUserInfo(context.Context, *GetUserInfoReq) (*GetUserInfoResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUserInfo not implemented")
}
func (UnimplementedUserServer) GenerateQuestion(context.Context, *GenerateQuestionReq) (*GenerateQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GenerateQuestion not implemented")
}
func (UnimplementedUserServer) GetQuestion(context.Context, *GetQuestionReq) (*GetQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetQuestion not implemented")
}
func (UnimplementedUserServer) AnswerQuestion(context.Context, *AnswerQuestionReq) (*AnswerQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method AnswerQuestion not implemented")
}
func (UnimplementedUserServer) mustEmbedUnimplementedUserServer() {}
// UnsafeUserServer may be embedded to opt out of forward compatibility for this service.
@@ -134,20 +100,38 @@ func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer) {
s.RegisterService(&User_ServiceDesc, srv)
}
func _User_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LoginReq)
func _User_PhoneLogin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PhoneLoginReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServer).Login(ctx, in)
return srv.(UserServer).PhoneLogin(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/User/Login",
FullMethod: "/User/PhoneLogin",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServer).Login(ctx, req.(*LoginReq))
return srv.(UserServer).PhoneLogin(ctx, req.(*PhoneLoginReq))
}
return interceptor(ctx, in, info, handler)
}
func _User_WxMiniLogin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(WxMiniLoginReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServer).WxMiniLogin(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/User/WxMiniLogin",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServer).WxMiniLogin(ctx, req.(*WxMiniLoginReq))
}
return interceptor(ctx, in, info, handler)
}
@@ -170,60 +154,6 @@ func _User_GetUserInfo_Handler(srv interface{}, ctx context.Context, dec func(in
return interceptor(ctx, in, info, handler)
}
func _User_GenerateQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GenerateQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServer).GenerateQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/User/GenerateQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServer).GenerateQuestion(ctx, req.(*GenerateQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
func _User_GetQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServer).GetQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/User/GetQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServer).GetQuestion(ctx, req.(*GetQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
func _User_AnswerQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AnswerQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServer).AnswerQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/User/AnswerQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServer).AnswerQuestion(ctx, req.(*AnswerQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
// User_ServiceDesc is the grpc.ServiceDesc for User service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -232,25 +162,17 @@ var User_ServiceDesc = grpc.ServiceDesc{
HandlerType: (*UserServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Login",
Handler: _User_Login_Handler,
MethodName: "PhoneLogin",
Handler: _User_PhoneLogin_Handler,
},
{
MethodName: "WxMiniLogin",
Handler: _User_WxMiniLogin_Handler,
},
{
MethodName: "GetUserInfo",
Handler: _User_GetUserInfo_Handler,
},
{
MethodName: "GenerateQuestion",
Handler: _User_GenerateQuestion_Handler,
},
{
MethodName: "GetQuestion",
Handler: _User_GetQuestion_Handler,
},
{
MethodName: "AnswerQuestion",
Handler: _User_AnswerQuestion_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "service_user.proto",

View File

@@ -10,7 +10,7 @@ service Gateway {
}
message ToClientReq {
string USN = 1;
int64 USN = 1;
int32 MessageID = 2;
bytes Payload = 3;
}
@@ -19,7 +19,7 @@ message ToClientResp {
}
message KickUserReq {
string USN = 1;
int64 USN = 1;
}
message KickUserResp {

View File

@@ -0,0 +1,153 @@
syntax = "proto3";
option go_package = "git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb";
import "rs_common.proto";
import "google/api/annotations.proto";
service Qgdzs {
// 生成题目
rpc GenerateQuestion(GenerateQuestionReq) returns (GenerateQuestionResp) {option (google.api.http) = {post: "/qgdzs/auth/generate_question" body: "*"};}
// ---------- 随机答题 ----------
// 获取题目
rpc RandomGetQuestion(RandomGetQuestionReq) returns (RandomGetQuestionResp) {option (google.api.http) = {post: "/qgdzs/open/random/question" body: "*"};}
// 回答题目
rpc RandomAnswerQuestion(RandomAnswerQuestionReq) returns (RandomAnswerQuestionResp) {option (google.api.http) = {post: "/qgdzs/open/random/answer" body: "*"};}
// ---------- 类目答题 ----------
// 获取所有类目
rpc GetAllCategory(GetAllCategoryReq) returns (GetAllCategoryResp) {option (google.api.http) = {post: "/qgdzs/open/category/get_category" body: "*"};}
// 获取题目
rpc CategoryGetQuestion(CategoryGetQuestionReq) returns (CategoryGetQuestionResp) {option (google.api.http) = {post: "/qgdzs/open/category/question" body: "*"};}
// 回答题目
rpc CategoryAnswerQuestion(CategoryAnswerQuestionReq) returns (CategoryAnswerQuestionResp) {option (google.api.http) = {post: "/qgdzs/open/category/answer" body: "*"};}
// ---------- 快速答题 ----------
// 获取题目
rpc QuicklyGetQuestion(QuicklyGetQuestionReq) returns (QuicklyGetQuestionResp) {option (google.api.http) = {post: "/qgdzs/open/quickly/question" body: "*"};}
// 回答题目
rpc QuicklyAnswerQuestion(QuicklyAnswerQuestionReq) returns (QuicklyAnswerQuestionResp) {option (google.api.http) = {post: "/qgdzs/open/quickly/answer" body: "*"};}
// ---------- 答题记录 ----------
// 获取答题记录
rpc GetRecord(GetRecordReq) returns (GetRecordResp) {option (google.api.http) = {post: "/qgdzs/auth/get_record" body: "*"};}
// 获取具体的题目
rpc GetQuestionInfo(GetQuestionInfoReq) returns (GetQuestionInfoResp) {option (google.api.http) = {post: "/qgdzs/open/get_question_info" body: "*"};}
}
// ---------- GenerateQuestion ----------
message GenerateQuestionReq {
int32 Num = 1 [json_name = "num"]; // 生成数量
}
message GenerateQuestionResp {
}
// ---------- RandomGetQuestion ----------
message RandomGetQuestionReq {
}
message RandomGetQuestionResp {
int64 Sn = 1 [json_name = "sn"]; // 题目唯一标识
string Question = 2 [json_name = "question"]; // 题干
repeated string Options = 3 [json_name = "options"]; // 选项
string Category = 4 [json_name = "category"]; // 题目类型
int32 Difficulty = 5 [json_name = "difficulty"]; // 难度
}
// ---------- RandomAnswerQuestion ----------
message RandomAnswerQuestionReq {
int64 USN = 1 [json_name = "usn"];
int64 Sn = 2 [json_name = "sn"]; // 题目唯一标识
string Answer = 3 [json_name = "answer"]; // 答案
}
message RandomAnswerQuestionResp {
string Answer = 1 [json_name = "answer"]; // 答案
string Explanation = 2 [json_name = "explanation"]; // 解析
}
// ---------- GetAllCategory ----------
message GetAllCategoryReq {
}
message GetAllCategoryResp {
repeated GetAllCategoryItem Categories = 1 [json_name = "categories"]; // 类目
}
message GetAllCategoryItem {
int64 Sn = 1 [json_name = "sn"]; // 唯一标识
string Category = 2 [json_name = "category"]; // 类目
}
// ---------- CategoryGetQuestion ----------
message CategoryGetQuestionReq {
int64 CategorySn = 1 [json_name = "category_sn"]; // 类目唯一标识
}
message CategoryGetQuestionResp {
int64 Sn = 1 [json_name = "sn"]; // 题目唯一标识
string Question = 2 [json_name = "question"]; // 题干
repeated string Options = 3 [json_name = "options"]; // 选项
string Category = 4 [json_name = "category"]; // 题目类型
int32 Difficulty = 5 [json_name = "difficulty"]; // 难度
}
// ---------- CategoryAnswerQuestion ----------
message CategoryAnswerQuestionReq {
int64 USN = 1 [json_name = "usn"];
int64 Sn = 2 [json_name = "sn"]; // 题目唯一标识
string Answer = 3 [json_name = "answer"]; // 答案
}
message CategoryAnswerQuestionResp {
string Answer = 1 [json_name = "answer"]; // 答案
string Explanation = 2 [json_name = "explanation"]; // 解析
}
// ---------- QuicklyGetQuestion ----------
message QuicklyGetQuestionReq {
}
message QuicklyGetQuestionResp {
int64 Sn = 1 [json_name = "sn"]; // 题目唯一标识
string Question = 2 [json_name = "question"]; // 题干
repeated string Options = 3 [json_name = "options"]; // 选项
string Category = 4 [json_name = "category"]; // 题目类型
int32 Difficulty = 5 [json_name = "difficulty"]; // 难度
}
// ---------- QuicklyAnswerQuestion ----------
message QuicklyAnswerQuestionReq {
int64 USN = 1 [json_name = "usn"];
int64 Sn = 2 [json_name = "sn"]; // 题目唯一标识
string Answer = 3 [json_name = "answer"]; // 答案
}
message QuicklyAnswerQuestionResp {
string Answer = 1 [json_name = "answer"]; // 答案
string Explanation = 2 [json_name = "explanation"]; // 解析
}
// ---------- GetRecord ----------
message GetRecordReq {
int64 USN = 1 [json_name = "usn"];
int32 Page = 2 [json_name = "page"];
int32 PageSize = 3 [json_name = "page_size"];
}
message GetRecordResp {
int32 Count = 1 [json_name = "count"]; // 总数
repeated GetRecordItem Records = 2 [json_name = "records"]; // 记录
}
message GetRecordItem {
int64 QuestionSn = 1 [json_name = "question_sn"]; // 题目唯一标识
string Question = 2 [json_name = "question"]; // 题干
int32 Difficulty = 3 [json_name = "difficulty"]; // 难度
string Category = 4 [json_name = "category"]; // 题目类型
string QuestionAnswer = 5 [json_name = "question_answer"]; // 题目答案
string Answer = 6 [json_name = "answer"]; // 用户答案
int64 CreateTime = 7 [json_name = "create_time"]; // 创建时间
}
// ---------- GetQuestionInfo ----------
message GetQuestionInfoReq {
int64 QuestionSn = 1 [json_name = "question_sn"]; // 题目唯一标识
}
message GetQuestionInfoResp {
string Question = 1 [json_name = "question"]; // 题干
repeated string Options = 2 [json_name = "options"]; // 选项
string Category = 3 [json_name = "category"]; // 类目
int32 Difficulty = 4 [json_name = "difficulty"]; // 难度
string Explanation = 5 [json_name = "explanation"]; // 解析
}

View File

@@ -10,29 +10,29 @@ service Scene {
}
message EnterReq {
string USN = 1; // 用户ID
string GatewaySID = 2; // 网关服务ID
int64 USN = 1; // 用户ID
int64 GatewaySID = 2; // 网关服务ID
int32 InstanceID = 3; // 副本ID
}
message EnterResp {
string SceneSID = 1; // 场景服务ID
string UniqueNo = 2; // 副本唯一编号
int64 SceneSID = 1; // 场景服务ID
int64 UniqueNo = 2; // 副本唯一编号
int32 MessageID = 3; // 发送给客户端的消息ID
bytes Payload = 4; // 消息负载
}
message LeaveReq {
string USN = 1; // 用户ID
string UniqueNo = 2; // 副本唯一编号
int64 USN = 1; // 用户ID
int64 UniqueNo = 2; // 副本唯一编号
}
message LeaveResp {
}
message ActionReq {
string UniqueNo = 1; // 副本唯一编号
string USN = 2; // 用户ID
int64 UniqueNo = 1; // 副本唯一编号
int64 USN = 2; // 用户ID
int32 Action = 3; // 指令ID
sint32 DirX = 4; // 移动-X方向×1000 缩放)
sint32 DirY = 5; // 移动-Y方向×1000 缩放)

View File

@@ -5,79 +5,36 @@ import "rs_common.proto";
import "google/api/annotations.proto";
service User {
rpc Login(LoginReq) returns (LoginResp) {}
rpc PhoneLogin(PhoneLoginReq) returns (PhoneLoginResp) {}
rpc WxMiniLogin(WxMiniLoginReq) returns (WxMiniLoginResp) {}
// 获取用户信息
rpc GetUserInfo(GetUserInfoReq) returns (GetUserInfoResp) {
option (google.api.http) = {
post: "/user/info"
body: "*"
};
}
// 生成题目
rpc GenerateQuestion(GenerateQuestionReq) returns (GenerateQuestionResp) {
option (google.api.http) = {
post: "/user/generate_question"
body: "*"
};
}
// 获取题目
rpc GetQuestion(GetQuestionReq) returns (GetQuestionResp) {
option (google.api.http) = {
post: "/user/get_question"
body: "*"
};
}
// 回答题目
rpc AnswerQuestion(AnswerQuestionReq) returns (AnswerQuestionResp) {
option (google.api.http) = {
post: "/user/answer_question"
body: "*"
};
}
rpc GetUserInfo(GetUserInfoReq) returns (GetUserInfoResp) {option (google.api.http) = {post: "/user/auth/info" body: "*"};}
}
// ---------- Login ----------
message LoginReq {
// ---------- PhoneLogin ----------
message PhoneLoginReq {
string Phone = 1 [json_name = "phone"]; // 手机号
string Code = 2 [json_name = "code"]; // 验证码
}
message LoginResp {
string USN = 1 [json_name = "usn"]; // 用户ID
message PhoneLoginResp {
int64 USN = 1 [json_name = "usn"]; // 用户ID
string Name = 2 [json_name = "name"]; // 用户名
}
// ---------- WxMiniLogin ----------
message WxMiniLoginReq {
string Code = 1 [json_name = "code"]; // 微信小程序登录凭证
}
message WxMiniLoginResp {
int64 USN = 1 [json_name = "usn"]; // 用户ID
string Name = 2 [json_name = "name"]; // 用户名
}
// ---------- GetUserInfo ----------
message GetUserInfoReq {
string USN = 1 [json_name = "usn"];
int64 USN = 1 [json_name = "usn"];
}
message GetUserInfoResp {
string USN = 1 [json_name = "usn"];
string Name = 2 [json_name = "name"];
}
// ---------- GenerateQuestion ----------
message GenerateQuestionReq {
int32 Num = 1 [json_name = "num"]; // 生成数量
string Category = 2 [json_name = "category"]; // 题目类型
}
message GenerateQuestionResp {
}
// ---------- GetQuestion ----------
message GetQuestionReq {
}
message GetQuestionResp {
string Sn = 1 [json_name = "sn"]; // 题目唯一标识
string Question = 2 [json_name = "question"]; // 题干
repeated string Options = 3 [json_name = "options"]; // 选项
}
// ---------- AnswerQuestion ----------
message AnswerQuestionReq {
string Sn = 1 [json_name = "sn"]; // 题目唯一标识
string Answer = 2 [json_name = "answer"]; // 答案
}
message AnswerQuestionResp {
string Answer = 1 [json_name = "answer"]; // 答案
string Explanation = 2 [json_name = "explanation"]; // 解析
int64 USN = 1 [json_name = "usn"];
string Name = 2 [json_name = "name"];
}

View File

@@ -28,7 +28,7 @@ public static partial class ActionReflection {
"bhIQCghTZXF1ZW5jZRgBIAEoDRIRCglUaW1lc3RhbXAYAiABKAMSGQoGQWN0",
"aW9uGAMgASgOMgkuQWN0aW9uSUQSDAoERGlyWBgEIAEoERIMCgREaXJZGAUg",
"ASgREg8KB1NraWxsSUQYBiABKAUiMQoMUG9zaXRpb25JbmZvEgsKA1VTThgB",
"IAEoCRIJCgFYGAIgASgREgkKAVkYAyABKBEiKwoMUzJDX1Bvc2l0aW9uEhsK",
"IAEoAxIJCgFYGAIgASgREgkKAVkYAyABKBEiKwoMUzJDX1Bvc2l0aW9uEhsK",
"BEluZm8YASADKAsyDS5Qb3NpdGlvbkluZm8qSwoIQWN0aW9uSUQSFQoRQUNU",
"SU9OX0lEX0lOVkFMSUQQABISCg5BQ1RJT05fSURfTU9WRRABEhQKEEFDVElP",
"Tl9JRF9BVFRBQ0sQAkI0WjJnaXQuaGxzcS5hc2lhL21tb3JwZy9zZXJ2aWNl",
@@ -902,13 +902,13 @@ public sealed partial class PositionInfo : pb::IMessage<PositionInfo>
/// <summary>Field number for the "USN" field.</summary>
public const int USNFieldNumber = 1;
private string uSN_ = "";
private long uSN_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public string USN {
public long USN {
get { return uSN_; }
set {
uSN_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
uSN_ = value;
}
}
@@ -961,7 +961,7 @@ public sealed partial class PositionInfo : pb::IMessage<PositionInfo>
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override int GetHashCode() {
int hash = 1;
if (USN.Length != 0) hash ^= USN.GetHashCode();
if (USN != 0L) hash ^= USN.GetHashCode();
if (X != 0) hash ^= X.GetHashCode();
if (Y != 0) hash ^= Y.GetHashCode();
if (_unknownFields != null) {
@@ -982,9 +982,9 @@ public sealed partial class PositionInfo : pb::IMessage<PositionInfo>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
output.WriteRawMessage(this);
#else
if (USN.Length != 0) {
output.WriteRawTag(10);
output.WriteString(USN);
if (USN != 0L) {
output.WriteRawTag(8);
output.WriteInt64(USN);
}
if (X != 0) {
output.WriteRawTag(16);
@@ -1004,9 +1004,9 @@ public sealed partial class PositionInfo : pb::IMessage<PositionInfo>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
if (USN.Length != 0) {
output.WriteRawTag(10);
output.WriteString(USN);
if (USN != 0L) {
output.WriteRawTag(8);
output.WriteInt64(USN);
}
if (X != 0) {
output.WriteRawTag(16);
@@ -1026,8 +1026,8 @@ public sealed partial class PositionInfo : pb::IMessage<PositionInfo>
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public int CalculateSize() {
int size = 0;
if (USN.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(USN);
if (USN != 0L) {
size += 1 + pb::CodedOutputStream.ComputeInt64Size(USN);
}
if (X != 0) {
size += 1 + pb::CodedOutputStream.ComputeSInt32Size(X);
@@ -1047,7 +1047,7 @@ public sealed partial class PositionInfo : pb::IMessage<PositionInfo>
if (other == null) {
return;
}
if (other.USN.Length != 0) {
if (other.USN != 0L) {
USN = other.USN;
}
if (other.X != 0) {
@@ -1071,8 +1071,8 @@ public sealed partial class PositionInfo : pb::IMessage<PositionInfo>
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
USN = input.ReadString();
case 8: {
USN = input.ReadInt64();
break;
}
case 16: {
@@ -1098,8 +1098,8 @@ public sealed partial class PositionInfo : pb::IMessage<PositionInfo>
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
break;
case 10: {
USN = input.ReadString();
case 8: {
USN = input.ReadInt64();
break;
}
case 16: {

View File

@@ -259,9 +259,9 @@ type PositionInfo struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,1,opt,name=USN,proto3" json:"USN,omitempty"`
X int32 `protobuf:"zigzag32,2,opt,name=X,proto3" json:"X,omitempty"`
Y int32 `protobuf:"zigzag32,3,opt,name=Y,proto3" json:"Y,omitempty"`
USN int64 `protobuf:"varint,1,opt,name=USN,proto3" json:"USN,omitempty"`
X int32 `protobuf:"zigzag32,2,opt,name=X,proto3" json:"X,omitempty"`
Y int32 `protobuf:"zigzag32,3,opt,name=Y,proto3" json:"Y,omitempty"`
}
func (x *PositionInfo) Reset() {
@@ -296,11 +296,11 @@ func (*PositionInfo) Descriptor() ([]byte, []int) {
return file_action_proto_rawDescGZIP(), []int{3}
}
func (x *PositionInfo) GetUSN() string {
func (x *PositionInfo) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
func (x *PositionInfo) GetX() int32 {
@@ -388,7 +388,7 @@ var file_action_proto_rawDesc = []byte{
0x12, 0x18, 0x0a, 0x07, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x49, 0x44, 0x18, 0x06, 0x20, 0x01, 0x28,
0x05, 0x52, 0x07, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x49, 0x44, 0x22, 0x3c, 0x0a, 0x0c, 0x50, 0x6f,
0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x53,
0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x55, 0x53, 0x4e, 0x12, 0x0c, 0x0a, 0x01,
0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x55, 0x53, 0x4e, 0x12, 0x0c, 0x0a, 0x01,
0x58, 0x18, 0x02, 0x20, 0x01, 0x28, 0x11, 0x52, 0x01, 0x58, 0x12, 0x0c, 0x0a, 0x01, 0x59, 0x18,
0x03, 0x20, 0x01, 0x28, 0x11, 0x52, 0x01, 0x59, 0x22, 0x31, 0x0a, 0x0c, 0x53, 0x32, 0x43, 0x5f,
0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x04, 0x49, 0x6e, 0x66, 0x6f,

View File

@@ -28,7 +28,7 @@ message C2S_Action {
// MESSAGE_ID_POSITION
message PositionInfo {
string USN = 1;
int64 USN = 1;
sint32 X = 2;
sint32 Y = 3;
}

View File

@@ -43,6 +43,7 @@ sudo chown -R 1000:1000 jenkins/
sudo chown -R 472:472 grafana/
sudo chown -R 65534:65534 prometheus/
sudo chown -R 1000:1000 gitea/
sudo chown -R 1000:1000 kafka/
nginx auth
nginx验证printf "admin:$(openssl passwd -crypt uF8uY4eM0nS9dA4iZ1bV4hE6)\n" >>./prometheus_passwd
@@ -58,11 +59,55 @@ ssh -L 2379:localhost:2379 root@47.108.184.184 yT1vU8fH5mP0rQ6h
生成ssh
ssh-keygen -t rsa -b 4096 -C "jenkins-to-aliyun" -f ~/.ssh/jenkins -N ""
ssh-copy-id root@47.108.184.184
生成mock代码
mockgen -source ./proto/ss/grpc_pb/service_user_grpc.pb.go -destination ./proto/ss/grpc_pb/mocks/service_user_grpc.pb.go -package mocks
mockgen -source ./proto/rs/grpc_pb/service_user_grpc.pb.go -destination ./proto/rs/grpc_pb/mocks/service_user_grpc.pb.go -package mocks
交叉编译:
sudo docker run --rm --privileged tonistiigi/binfmt --install all
sudo docker buildx create --name multi-arch-builder --use --bootstrap
sudo docker buildx inspect
查看构建器列表:sudo docker buildx ls
让构建器重新扫描QUEM文件sudo docker buildx inspect --bootstrap
客户端VPN设置
iptables -t nat -A POSTROUTING -s 172.18.0.0/24 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 172.18.0.0/24 -o peer1 -j MASQUERADE
iptables -A FORWARD -i eth0 -o peer1 -j ACCEPT
iptables -A FORWARD -i peer1 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
docker exec wireguard-client /bin/bash -c '
echo 1 > /proc/sys/net/ipv4/ip_forward
HOST_IP=$(ip route | awk "/default/ {print \$3}")
iptables -t nat -A PREROUTING -d 192.168.30.2 -j DNAT --to-destination $HOST_IP
iptables -t nat -A POSTROUTING -s $HOST_IP -j SNAT --to-source 192.168.30.2
iptables -P FORWARD ACCEPT
'
PostUp = sysctl -w net.ipv4.ip_forward=1
PostUp = iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostUp = iptables -A FORWARD -i wg0 -o eth0 -j ACCEPT
PostUp = iptables -A FORWARD -i eth0 -o wg0 -j ACCEPT
PostUp = iptables -A INPUT -i wg0 -j ACCEPT
PostDown = iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -o eth0 -j ACCEPT
PostDown = iptables -D FORWARD -i eth0 -o wg0 -j ACCEPT
PostDown = iptables -D INPUT -i wg0 -j ACCEPT
服务端VPN设置
iptables -t nat -A POSTROUTING -s 10.255.12.0/24 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 10.255.12.0/24 -o wg0 -j MASQUERADE
iptables -A FORWARD -i eth0 -o wg0 -j ACCEPT
iptables -A FORWARD -i wg0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
docker exec wireguard-service /bin/bash -c '
echo 1 > /proc/sys/net/ipv4/ip_forward
HOST_IP=$(ip route | awk "/default/ {print \$3}")
iptables -t nat -A PREROUTING -d 192.168.30.1 -j DNAT --to-destination $HOST_IP
iptables -t nat -A POSTROUTING -s $HOST_IP -j SNAT --to-source 192.168.30.1
iptables -P FORWARD ACCEPT
'
sudo ip route add 192.168.30.0/24 via 10.255.12.6

View File

@@ -0,0 +1,11 @@
services:
# yacd.haishan.me
mihomo:
image: metacubex/mihomo:v1.19.19
container_name: mihomo
restart: unless-stopped
ports:
- "7890:7890"
- "9094:9090"
volumes:
- ./clash:/root/.config/mihomo

View File

@@ -0,0 +1,10 @@
services:
dnsmasq:
image: 4km3/dnsmasq:2.90-r3-alpine-3.22.2
container_name: dnsmasq
restart: unless-stopped
ports:
- "53:53/udp"
- "53:53/tcp"
volumes:
- ./dnsmasq/dnsmasq.conf:/etc/dnsmasq.conf

View File

@@ -0,0 +1,9 @@
services:
jaeger:
image: jaegertracing/all-in-one:1.76.0
container_name: jaeger
restart: unless-stopped
ports:
- "16686:16686"
- "4317:4317"
- "5778:5778"

View File

@@ -0,0 +1,34 @@
services:
kafka:
image: confluentinc/cp-kafka:7.7.7
container_name: kafka
restart: unless-stopped
ports:
- '9092:9092'
- '9095:9095'
- '9096:9096'
environment:
CLUSTER_ID: "NB2XQ2LBN5UGK2I="
KAFKA_NODE_ID: 1
KAFKA_PROCESS_ROLES: "controller,broker"
KAFKA_CONTROLLER_QUORUM_VOTERS: "1@kafka:9093"
KAFKA_CONTROLLER_LISTENER_NAMES: "CONTROLLER"
KAFKA_LISTENERS: "PLAINTEXT://:9092,CONTROLLER://:9093,LOCAL://:9095,UI://:9096"
KAFKA_ADVERTISED_LISTENERS: "PLAINTEXT://127.0.0.1:9092,LOCAL://172.18.28.0:9095,UI://192.168.31.10:9096"
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT,LOCAL:PLAINTEXT,UI:PLAINTEXT"
KAFKA_CONTROLLER_LOG_DIRS: "/var/lib/kafka/data/controller-logs"
KAFKA_LOG_DIRS: "/var/lib/kafka/data/logs"
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
volumes:
- './kafka:/var/lib/kafka/data'
kafka-ui:
image: provectuslabs/kafka-ui:v0.7.2
container_name: kafka-ui
restart: unless-stopped
ports:
- '8082:8080'
environment:
DYNAMIC_CONFIG_ENABLED: 'true'

View File

@@ -16,6 +16,7 @@ services:
container_name: node_exporter
command:
- '--path.rootfs=/host'
- '--web.listen-address=:9101'
network_mode: host
pid: host
restart: unless-stopped

View File

@@ -0,0 +1,46 @@
services:
wireguard-service:
image: linuxserver/wireguard:1.0.20250521
container_name: wireguard-service
restart: unless-stopped
cap_add:
- NET_ADMIN
- SYS_MODULE
environment:
PUID: 1000
PGID: 1000
TZ: "Etc/UTC"
SERVERURL: "www.hlsq.asia"
SERVERPORT: "51820"
PEERS: 2
PEERDNS: "auto"
INTERNAL_SUBNET: "192.168.30.0"
ALLOWEDIPS: "0.0.0.0/0"
volumes:
- ./wireguard-service:/config
- /lib/modules:/lib/modules:ro
ports:
- "51820:51820/udp"
sysctls:
- net.ipv4.ip_forward=1
- net.ipv4.conf.all.src_valid_mark=1
wireguard-client:
image: linuxserver/wireguard:1.0.20250521
container_name: wireguard-client
restart: unless-stopped
cap_add:
- NET_ADMIN
- SYS_MODULE
environment:
PUID: 1000
PGID: 1000
TZ: "Etc/UTC"
CLIENT: 1
CONFIG_FILE: "/config/wg_confs/peer1.conf"
volumes:
- ./wireguard-client:/config
- /lib/modules:/lib/modules:ro
sysctls:
- net.ipv4.ip_forward=1
- net.ipv4.conf.all.src_valid_mark=1

View File

@@ -0,0 +1,34 @@
[
{
"targets": [
"192.168.31.10:18504"
],
"labels": {
"job": "server-gateway"
}
},
{
"targets": [
"192.168.31.10:18801"
],
"labels": {
"job": "server-user"
}
},
{
"targets": [
"192.168.31.10:18701"
],
"labels": {
"job": "server-scene"
}
},
{
"targets": [
"192.168.31.10:18601"
],
"labels": {
"job": "server-qgdzs"
}
}
]

12
Publish/tunnel.ps1 Normal file
View File

@@ -0,0 +1,12 @@
Write-Host "tunnel success..."
ssh -N `
-L 3001:localhost:3001 `
-L 4317:localhost:4317 `
-L 6379:localhost:6379 `
-L 2379:localhost:2379 `
-L 3306:localhost:3306 `
-L 9093:localhost:9093 `
-L 9094:localhost:9094 `
-L 9092:localhost:9092 `
-L 8082:localhost:8082 `
root@47.108.184.184

View File

@@ -4,17 +4,17 @@ param(
[string]$dbName
)
& .\gentool.exe `
-dsn "root:gR9pV4tY7zR6qL3e@tcp(47.108.184.184:3306)/${dbName}?charset=utf8mb4&parseTime=True&loc=Local" `
-dsn "root:gR9pV4tY7zR6qL3e@tcp(127.0.0.1:3306)/${dbName}?charset=utf8mb4&parseTime=True&loc=Local" `
-fieldSignable `
-outPath "./${dbName}/query"
Get-ChildItem ./${dbName}/model/*.gen.go | ForEach-Object {
$c = Get-Content $_.FullName -Raw -Encoding UTF8
if ($c -match '\bSn\s+string\b' -and $c -notmatch 'BeforeCreate') {
if ($c -match '\bSn\s+int64\b' -and $c -notmatch 'BeforeCreate') {
$c -match 'type\s+(\w+)\s+struct' | Out-Null
$n = $matches[1]
$c = $c -replace '(?s)(import\s*\([^)]*)', "`$1`t`"git.hlsq.asia/mmorpg/service-common/utils`"`n"
$hook = "`n`n// Auto sn`nfunc (m *$n) BeforeCreate(_ *gorm.DB) error {`n`tif m.Sn == `"`" {`n`t`tm.Sn = utils.SnowflakeInstance().Generate().String()`n`t}`n`treturn nil`n}"
$hook = "`n`n// Auto sn`nfunc (m *$n) BeforeCreate(_ *gorm.DB) error {`n`tif m.Sn == 0 {`n`t`tm.Sn = utils.SnowflakeInstance().Generate().Int64()`n`t}`n`treturn nil`n}"
Set-Content $_.FullName ($c.TrimEnd() + $hook) -Encoding UTF8
}
}

View File

@@ -0,0 +1,37 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
import (
"time"
"git.hlsq.asia/mmorpg/service-common/utils"
"gorm.io/gorm"
)
const TableNameCategory = "categories"
// Category mapped from table <categories>
type Category struct {
ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
Sn int64 `gorm:"column:sn;not null;comment:业务唯一编号" json:"sn"` // 业务唯一编号
Category string `gorm:"column:category;not null;comment:分类" json:"category"` // 分类
CreatedAt time.Time `gorm:"column:created_at;not null" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;not null" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"deleted_at"`
}
// TableName Category's table name
func (*Category) TableName() string {
return TableNameCategory
}
// Auto sn
func (m *Category) BeforeCreate(_ *gorm.DB) error {
if m.Sn == 0 {
m.Sn = utils.SnowflakeInstance().Generate().Int64()
}
return nil
}

View File

@@ -0,0 +1,38 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
import (
"time"
"git.hlsq.asia/mmorpg/service-common/utils"
"gorm.io/gorm"
)
const TableNamePointCard = "point_card"
// PointCard mapped from table <point_card>
type PointCard struct {
ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
Sn int64 `gorm:"column:sn;not null;comment:业务唯一编号" json:"sn"` // 业务唯一编号
UserSn int64 `gorm:"column:user_sn;not null;comment:用户-唯一编号" json:"user_sn"` // 用户-唯一编号
Point int64 `gorm:"column:point;not null;comment:积分" json:"point"` // 积分
CreatedAt time.Time `gorm:"column:created_at;not null" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;not null" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"deleted_at"`
}
// TableName PointCard's table name
func (*PointCard) TableName() string {
return TableNamePointCard
}
// Auto sn
func (m *PointCard) BeforeCreate(_ *gorm.DB) error {
if m.Sn == 0 {
m.Sn = utils.SnowflakeInstance().Generate().Int64()
}
return nil
}

View File

@@ -0,0 +1,46 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
import (
"time"
"git.hlsq.asia/mmorpg/service-common/utils"
"gorm.io/gorm"
)
const TableNamePointRecord = "point_records"
// PointRecord mapped from table <point_records>
type PointRecord struct {
ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
Sn int64 `gorm:"column:sn;not null;comment:业务唯一编号" json:"sn"` // 业务唯一编号
UserSn int64 `gorm:"column:user_sn;not null;comment:用户-唯一编号" json:"user_sn"` // 用户-唯一编号
/*
来源:
0. 未知
1. 随机答题
2. 类目答题
3. 限时答题
*/
Source int32 `gorm:"column:source;not null;comment:来源:\n0. 未知\n1. 随机答题\n2. 类目答题\n3. 限时答题" json:"source"`
Point int64 `gorm:"column:point;not null;comment:积分" json:"point"` // 积分
CreatedAt time.Time `gorm:"column:created_at;not null" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;not null" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"deleted_at"`
}
// TableName PointRecord's table name
func (*PointRecord) TableName() string {
return TableNamePointRecord
}
// Auto sn
func (m *PointRecord) BeforeCreate(_ *gorm.DB) error {
if m.Sn == 0 {
m.Sn = utils.SnowflakeInstance().Generate().Int64()
}
return nil
}

View File

@@ -1,4 +1,4 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
@@ -7,8 +7,8 @@ package model
import (
"time"
"gorm.io/gorm"
"git.hlsq.asia/mmorpg/service-common/utils"
"gorm.io/gorm"
)
const TableNameQuestion = "questions"
@@ -16,13 +16,13 @@ const TableNameQuestion = "questions"
// Question mapped from table <questions>
type Question struct {
ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
Sn string `gorm:"column:sn;not null;comment:业务唯一编号" json:"sn"` // 业务唯一编号
Sn int64 `gorm:"column:sn;not null;comment:业务唯一编号" json:"sn"` // 业务唯一编号
Question string `gorm:"column:question;not null;comment:题干" json:"question"` // 题干
Options string `gorm:"column:options;not null;comment:选项" json:"options"` // 选项
Answer string `gorm:"column:answer;not null;comment:答案" json:"answer"` // 答案
Explanation string `gorm:"column:explanation;not null;comment:解析" json:"explanation"` // 解析
Difficulty int32 `gorm:"column:difficulty;not null;comment:难度分 0 - 100" json:"difficulty"` // 难度分 0 - 100
Category string `gorm:"column:category;not null;comment:分类" json:"category"` // 分类
CategorySn int64 `gorm:"column:category_sn;not null;comment:分类-唯一编号" json:"category_sn"` // 分类-唯一编号
CreatedAt time.Time `gorm:"column:created_at;not null" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;not null" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"deleted_at"`
@@ -35,8 +35,8 @@ func (*Question) TableName() string {
// Auto sn
func (m *Question) BeforeCreate(_ *gorm.DB) error {
if m.Sn == "" {
m.Sn = utils.SnowflakeInstance().Generate().String()
if m.Sn == 0 {
m.Sn = utils.SnowflakeInstance().Generate().Int64()
}
return nil
}

View File

@@ -0,0 +1,40 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
import (
"time"
"git.hlsq.asia/mmorpg/service-common/utils"
"gorm.io/gorm"
)
const TableNameRecord = "records"
// Record mapped from table <records>
type Record struct {
ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
Sn int64 `gorm:"column:sn;not null;comment:业务唯一编号" json:"sn"` // 业务唯一编号
UserSn int64 `gorm:"column:user_sn;not null;comment:用户-唯一编号" json:"user_sn"` // 用户-唯一编号
QuestionSn int64 `gorm:"column:question_sn;not null;comment:题目-唯一编号" json:"question_sn"` // 题目-唯一编号
Answer string `gorm:"column:answer;not null;comment:答案" json:"answer"` // 答案
IsCorrect int32 `gorm:"column:is_correct;not null;comment:是否正确 0 否 1 是" json:"is_correct"` // 是否正确 0 否 1 是
CreatedAt time.Time `gorm:"column:created_at;not null" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;not null" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"deleted_at"`
}
// TableName Record's table name
func (*Record) TableName() string {
return TableNameRecord
}
// Auto sn
func (m *Record) BeforeCreate(_ *gorm.DB) error {
if m.Sn == 0 {
m.Sn = utils.SnowflakeInstance().Generate().Int64()
}
return nil
}

View File

@@ -0,0 +1,347 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"git.hlsq.asia/mmorpg/qgdzs_db/model"
)
func newCategory(db *gorm.DB, opts ...gen.DOOption) category {
_category := category{}
_category.categoryDo.UseDB(db, opts...)
_category.categoryDo.UseModel(&model.Category{})
tableName := _category.categoryDo.TableName()
_category.ALL = field.NewAsterisk(tableName)
_category.ID = field.NewUint64(tableName, "id")
_category.Sn = field.NewInt64(tableName, "sn")
_category.Category = field.NewString(tableName, "category")
_category.CreatedAt = field.NewTime(tableName, "created_at")
_category.UpdatedAt = field.NewTime(tableName, "updated_at")
_category.DeletedAt = field.NewField(tableName, "deleted_at")
_category.fillFieldMap()
return _category
}
type category struct {
categoryDo categoryDo
ALL field.Asterisk
ID field.Uint64
Sn field.Int64 // 业务唯一编号
Category field.String // 分类
CreatedAt field.Time
UpdatedAt field.Time
DeletedAt field.Field
fieldMap map[string]field.Expr
}
func (c category) Table(newTableName string) *category {
c.categoryDo.UseTable(newTableName)
return c.updateTableName(newTableName)
}
func (c category) As(alias string) *category {
c.categoryDo.DO = *(c.categoryDo.As(alias).(*gen.DO))
return c.updateTableName(alias)
}
func (c *category) updateTableName(table string) *category {
c.ALL = field.NewAsterisk(table)
c.ID = field.NewUint64(table, "id")
c.Sn = field.NewInt64(table, "sn")
c.Category = field.NewString(table, "category")
c.CreatedAt = field.NewTime(table, "created_at")
c.UpdatedAt = field.NewTime(table, "updated_at")
c.DeletedAt = field.NewField(table, "deleted_at")
c.fillFieldMap()
return c
}
func (c *category) WithContext(ctx context.Context) *categoryDo { return c.categoryDo.WithContext(ctx) }
func (c category) TableName() string { return c.categoryDo.TableName() }
func (c category) Alias() string { return c.categoryDo.Alias() }
func (c category) Columns(cols ...field.Expr) gen.Columns { return c.categoryDo.Columns(cols...) }
func (c *category) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := c.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (c *category) fillFieldMap() {
c.fieldMap = make(map[string]field.Expr, 6)
c.fieldMap["id"] = c.ID
c.fieldMap["sn"] = c.Sn
c.fieldMap["category"] = c.Category
c.fieldMap["created_at"] = c.CreatedAt
c.fieldMap["updated_at"] = c.UpdatedAt
c.fieldMap["deleted_at"] = c.DeletedAt
}
func (c category) clone(db *gorm.DB) category {
c.categoryDo.ReplaceConnPool(db.Statement.ConnPool)
return c
}
func (c category) replaceDB(db *gorm.DB) category {
c.categoryDo.ReplaceDB(db)
return c
}
type categoryDo struct{ gen.DO }
func (c categoryDo) Debug() *categoryDo {
return c.withDO(c.DO.Debug())
}
func (c categoryDo) WithContext(ctx context.Context) *categoryDo {
return c.withDO(c.DO.WithContext(ctx))
}
func (c categoryDo) ReadDB() *categoryDo {
return c.Clauses(dbresolver.Read)
}
func (c categoryDo) WriteDB() *categoryDo {
return c.Clauses(dbresolver.Write)
}
func (c categoryDo) Session(config *gorm.Session) *categoryDo {
return c.withDO(c.DO.Session(config))
}
func (c categoryDo) Clauses(conds ...clause.Expression) *categoryDo {
return c.withDO(c.DO.Clauses(conds...))
}
func (c categoryDo) Returning(value interface{}, columns ...string) *categoryDo {
return c.withDO(c.DO.Returning(value, columns...))
}
func (c categoryDo) Not(conds ...gen.Condition) *categoryDo {
return c.withDO(c.DO.Not(conds...))
}
func (c categoryDo) Or(conds ...gen.Condition) *categoryDo {
return c.withDO(c.DO.Or(conds...))
}
func (c categoryDo) Select(conds ...field.Expr) *categoryDo {
return c.withDO(c.DO.Select(conds...))
}
func (c categoryDo) Where(conds ...gen.Condition) *categoryDo {
return c.withDO(c.DO.Where(conds...))
}
func (c categoryDo) Order(conds ...field.Expr) *categoryDo {
return c.withDO(c.DO.Order(conds...))
}
func (c categoryDo) Distinct(cols ...field.Expr) *categoryDo {
return c.withDO(c.DO.Distinct(cols...))
}
func (c categoryDo) Omit(cols ...field.Expr) *categoryDo {
return c.withDO(c.DO.Omit(cols...))
}
func (c categoryDo) Join(table schema.Tabler, on ...field.Expr) *categoryDo {
return c.withDO(c.DO.Join(table, on...))
}
func (c categoryDo) LeftJoin(table schema.Tabler, on ...field.Expr) *categoryDo {
return c.withDO(c.DO.LeftJoin(table, on...))
}
func (c categoryDo) RightJoin(table schema.Tabler, on ...field.Expr) *categoryDo {
return c.withDO(c.DO.RightJoin(table, on...))
}
func (c categoryDo) Group(cols ...field.Expr) *categoryDo {
return c.withDO(c.DO.Group(cols...))
}
func (c categoryDo) Having(conds ...gen.Condition) *categoryDo {
return c.withDO(c.DO.Having(conds...))
}
func (c categoryDo) Limit(limit int) *categoryDo {
return c.withDO(c.DO.Limit(limit))
}
func (c categoryDo) Offset(offset int) *categoryDo {
return c.withDO(c.DO.Offset(offset))
}
func (c categoryDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *categoryDo {
return c.withDO(c.DO.Scopes(funcs...))
}
func (c categoryDo) Unscoped() *categoryDo {
return c.withDO(c.DO.Unscoped())
}
func (c categoryDo) Create(values ...*model.Category) error {
if len(values) == 0 {
return nil
}
return c.DO.Create(values)
}
func (c categoryDo) CreateInBatches(values []*model.Category, batchSize int) error {
return c.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (c categoryDo) Save(values ...*model.Category) error {
if len(values) == 0 {
return nil
}
return c.DO.Save(values)
}
func (c categoryDo) First() (*model.Category, error) {
if result, err := c.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.Category), nil
}
}
func (c categoryDo) Take() (*model.Category, error) {
if result, err := c.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.Category), nil
}
}
func (c categoryDo) Last() (*model.Category, error) {
if result, err := c.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.Category), nil
}
}
func (c categoryDo) Find() ([]*model.Category, error) {
result, err := c.DO.Find()
return result.([]*model.Category), err
}
func (c categoryDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Category, err error) {
buf := make([]*model.Category, 0, batchSize)
err = c.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (c categoryDo) FindInBatches(result *[]*model.Category, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return c.DO.FindInBatches(result, batchSize, fc)
}
func (c categoryDo) Attrs(attrs ...field.AssignExpr) *categoryDo {
return c.withDO(c.DO.Attrs(attrs...))
}
func (c categoryDo) Assign(attrs ...field.AssignExpr) *categoryDo {
return c.withDO(c.DO.Assign(attrs...))
}
func (c categoryDo) Joins(fields ...field.RelationField) *categoryDo {
for _, _f := range fields {
c = *c.withDO(c.DO.Joins(_f))
}
return &c
}
func (c categoryDo) Preload(fields ...field.RelationField) *categoryDo {
for _, _f := range fields {
c = *c.withDO(c.DO.Preload(_f))
}
return &c
}
func (c categoryDo) FirstOrInit() (*model.Category, error) {
if result, err := c.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.Category), nil
}
}
func (c categoryDo) FirstOrCreate() (*model.Category, error) {
if result, err := c.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.Category), nil
}
}
func (c categoryDo) FindByPage(offset int, limit int) (result []*model.Category, count int64, err error) {
result, err = c.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = c.Offset(-1).Limit(-1).Count()
return
}
func (c categoryDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = c.Count()
if err != nil {
return
}
err = c.Offset(offset).Limit(limit).Scan(result)
return
}
func (c categoryDo) Scan(result interface{}) (err error) {
return c.DO.Scan(result)
}
func (c categoryDo) Delete(models ...*model.Category) (result gen.ResultInfo, err error) {
return c.DO.Delete(models)
}
func (c *categoryDo) withDO(do gen.Dao) *categoryDo {
c.DO = *do.(*gen.DO)
return c
}

View File

@@ -0,0 +1,117 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"database/sql"
"gorm.io/gorm"
"gorm.io/gen"
"gorm.io/plugin/dbresolver"
)
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
return &Query{
db: db,
Category: newCategory(db, opts...),
PointCard: newPointCard(db, opts...),
PointRecord: newPointRecord(db, opts...),
Question: newQuestion(db, opts...),
Record: newRecord(db, opts...),
}
}
type Query struct {
db *gorm.DB
Category category
PointCard pointCard
PointRecord pointRecord
Question question
Record record
}
func (q *Query) Available() bool { return q.db != nil }
func (q *Query) clone(db *gorm.DB) *Query {
return &Query{
db: db,
Category: q.Category.clone(db),
PointCard: q.PointCard.clone(db),
PointRecord: q.PointRecord.clone(db),
Question: q.Question.clone(db),
Record: q.Record.clone(db),
}
}
func (q *Query) ReadDB() *Query {
return q.ReplaceDB(q.db.Clauses(dbresolver.Read))
}
func (q *Query) WriteDB() *Query {
return q.ReplaceDB(q.db.Clauses(dbresolver.Write))
}
func (q *Query) ReplaceDB(db *gorm.DB) *Query {
return &Query{
db: db,
Category: q.Category.replaceDB(db),
PointCard: q.PointCard.replaceDB(db),
PointRecord: q.PointRecord.replaceDB(db),
Question: q.Question.replaceDB(db),
Record: q.Record.replaceDB(db),
}
}
type queryCtx struct {
Category *categoryDo
PointCard *pointCardDo
PointRecord *pointRecordDo
Question *questionDo
Record *recordDo
}
func (q *Query) WithContext(ctx context.Context) *queryCtx {
return &queryCtx{
Category: q.Category.WithContext(ctx),
PointCard: q.PointCard.WithContext(ctx),
PointRecord: q.PointRecord.WithContext(ctx),
Question: q.Question.WithContext(ctx),
Record: q.Record.WithContext(ctx),
}
}
func (q *Query) Transaction(fc func(tx *Query) error, opts ...*sql.TxOptions) error {
return q.db.Transaction(func(tx *gorm.DB) error { return fc(q.clone(tx)) }, opts...)
}
func (q *Query) Begin(opts ...*sql.TxOptions) *QueryTx {
tx := q.db.Begin(opts...)
return &QueryTx{Query: q.clone(tx), Error: tx.Error}
}
type QueryTx struct {
*Query
Error error
}
func (q *QueryTx) Commit() error {
return q.db.Commit().Error
}
func (q *QueryTx) Rollback() error {
return q.db.Rollback().Error
}
func (q *QueryTx) SavePoint(name string) error {
return q.db.SavePoint(name).Error
}
func (q *QueryTx) RollbackTo(name string) error {
return q.db.RollbackTo(name).Error
}

View File

@@ -0,0 +1,353 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"git.hlsq.asia/mmorpg/qgdzs_db/model"
)
func newPointCard(db *gorm.DB, opts ...gen.DOOption) pointCard {
_pointCard := pointCard{}
_pointCard.pointCardDo.UseDB(db, opts...)
_pointCard.pointCardDo.UseModel(&model.PointCard{})
tableName := _pointCard.pointCardDo.TableName()
_pointCard.ALL = field.NewAsterisk(tableName)
_pointCard.ID = field.NewUint64(tableName, "id")
_pointCard.Sn = field.NewInt64(tableName, "sn")
_pointCard.UserSn = field.NewInt64(tableName, "user_sn")
_pointCard.Point = field.NewInt64(tableName, "point")
_pointCard.CreatedAt = field.NewTime(tableName, "created_at")
_pointCard.UpdatedAt = field.NewTime(tableName, "updated_at")
_pointCard.DeletedAt = field.NewField(tableName, "deleted_at")
_pointCard.fillFieldMap()
return _pointCard
}
type pointCard struct {
pointCardDo pointCardDo
ALL field.Asterisk
ID field.Uint64
Sn field.Int64 // 业务唯一编号
UserSn field.Int64 // 用户-唯一编号
Point field.Int64 // 积分
CreatedAt field.Time
UpdatedAt field.Time
DeletedAt field.Field
fieldMap map[string]field.Expr
}
func (p pointCard) Table(newTableName string) *pointCard {
p.pointCardDo.UseTable(newTableName)
return p.updateTableName(newTableName)
}
func (p pointCard) As(alias string) *pointCard {
p.pointCardDo.DO = *(p.pointCardDo.As(alias).(*gen.DO))
return p.updateTableName(alias)
}
func (p *pointCard) updateTableName(table string) *pointCard {
p.ALL = field.NewAsterisk(table)
p.ID = field.NewUint64(table, "id")
p.Sn = field.NewInt64(table, "sn")
p.UserSn = field.NewInt64(table, "user_sn")
p.Point = field.NewInt64(table, "point")
p.CreatedAt = field.NewTime(table, "created_at")
p.UpdatedAt = field.NewTime(table, "updated_at")
p.DeletedAt = field.NewField(table, "deleted_at")
p.fillFieldMap()
return p
}
func (p *pointCard) WithContext(ctx context.Context) *pointCardDo {
return p.pointCardDo.WithContext(ctx)
}
func (p pointCard) TableName() string { return p.pointCardDo.TableName() }
func (p pointCard) Alias() string { return p.pointCardDo.Alias() }
func (p pointCard) Columns(cols ...field.Expr) gen.Columns { return p.pointCardDo.Columns(cols...) }
func (p *pointCard) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := p.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (p *pointCard) fillFieldMap() {
p.fieldMap = make(map[string]field.Expr, 7)
p.fieldMap["id"] = p.ID
p.fieldMap["sn"] = p.Sn
p.fieldMap["user_sn"] = p.UserSn
p.fieldMap["point"] = p.Point
p.fieldMap["created_at"] = p.CreatedAt
p.fieldMap["updated_at"] = p.UpdatedAt
p.fieldMap["deleted_at"] = p.DeletedAt
}
func (p pointCard) clone(db *gorm.DB) pointCard {
p.pointCardDo.ReplaceConnPool(db.Statement.ConnPool)
return p
}
func (p pointCard) replaceDB(db *gorm.DB) pointCard {
p.pointCardDo.ReplaceDB(db)
return p
}
type pointCardDo struct{ gen.DO }
func (p pointCardDo) Debug() *pointCardDo {
return p.withDO(p.DO.Debug())
}
func (p pointCardDo) WithContext(ctx context.Context) *pointCardDo {
return p.withDO(p.DO.WithContext(ctx))
}
func (p pointCardDo) ReadDB() *pointCardDo {
return p.Clauses(dbresolver.Read)
}
func (p pointCardDo) WriteDB() *pointCardDo {
return p.Clauses(dbresolver.Write)
}
func (p pointCardDo) Session(config *gorm.Session) *pointCardDo {
return p.withDO(p.DO.Session(config))
}
func (p pointCardDo) Clauses(conds ...clause.Expression) *pointCardDo {
return p.withDO(p.DO.Clauses(conds...))
}
func (p pointCardDo) Returning(value interface{}, columns ...string) *pointCardDo {
return p.withDO(p.DO.Returning(value, columns...))
}
func (p pointCardDo) Not(conds ...gen.Condition) *pointCardDo {
return p.withDO(p.DO.Not(conds...))
}
func (p pointCardDo) Or(conds ...gen.Condition) *pointCardDo {
return p.withDO(p.DO.Or(conds...))
}
func (p pointCardDo) Select(conds ...field.Expr) *pointCardDo {
return p.withDO(p.DO.Select(conds...))
}
func (p pointCardDo) Where(conds ...gen.Condition) *pointCardDo {
return p.withDO(p.DO.Where(conds...))
}
func (p pointCardDo) Order(conds ...field.Expr) *pointCardDo {
return p.withDO(p.DO.Order(conds...))
}
func (p pointCardDo) Distinct(cols ...field.Expr) *pointCardDo {
return p.withDO(p.DO.Distinct(cols...))
}
func (p pointCardDo) Omit(cols ...field.Expr) *pointCardDo {
return p.withDO(p.DO.Omit(cols...))
}
func (p pointCardDo) Join(table schema.Tabler, on ...field.Expr) *pointCardDo {
return p.withDO(p.DO.Join(table, on...))
}
func (p pointCardDo) LeftJoin(table schema.Tabler, on ...field.Expr) *pointCardDo {
return p.withDO(p.DO.LeftJoin(table, on...))
}
func (p pointCardDo) RightJoin(table schema.Tabler, on ...field.Expr) *pointCardDo {
return p.withDO(p.DO.RightJoin(table, on...))
}
func (p pointCardDo) Group(cols ...field.Expr) *pointCardDo {
return p.withDO(p.DO.Group(cols...))
}
func (p pointCardDo) Having(conds ...gen.Condition) *pointCardDo {
return p.withDO(p.DO.Having(conds...))
}
func (p pointCardDo) Limit(limit int) *pointCardDo {
return p.withDO(p.DO.Limit(limit))
}
func (p pointCardDo) Offset(offset int) *pointCardDo {
return p.withDO(p.DO.Offset(offset))
}
func (p pointCardDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *pointCardDo {
return p.withDO(p.DO.Scopes(funcs...))
}
func (p pointCardDo) Unscoped() *pointCardDo {
return p.withDO(p.DO.Unscoped())
}
func (p pointCardDo) Create(values ...*model.PointCard) error {
if len(values) == 0 {
return nil
}
return p.DO.Create(values)
}
func (p pointCardDo) CreateInBatches(values []*model.PointCard, batchSize int) error {
return p.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (p pointCardDo) Save(values ...*model.PointCard) error {
if len(values) == 0 {
return nil
}
return p.DO.Save(values)
}
func (p pointCardDo) First() (*model.PointCard, error) {
if result, err := p.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.PointCard), nil
}
}
func (p pointCardDo) Take() (*model.PointCard, error) {
if result, err := p.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.PointCard), nil
}
}
func (p pointCardDo) Last() (*model.PointCard, error) {
if result, err := p.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.PointCard), nil
}
}
func (p pointCardDo) Find() ([]*model.PointCard, error) {
result, err := p.DO.Find()
return result.([]*model.PointCard), err
}
func (p pointCardDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.PointCard, err error) {
buf := make([]*model.PointCard, 0, batchSize)
err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (p pointCardDo) FindInBatches(result *[]*model.PointCard, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return p.DO.FindInBatches(result, batchSize, fc)
}
func (p pointCardDo) Attrs(attrs ...field.AssignExpr) *pointCardDo {
return p.withDO(p.DO.Attrs(attrs...))
}
func (p pointCardDo) Assign(attrs ...field.AssignExpr) *pointCardDo {
return p.withDO(p.DO.Assign(attrs...))
}
func (p pointCardDo) Joins(fields ...field.RelationField) *pointCardDo {
for _, _f := range fields {
p = *p.withDO(p.DO.Joins(_f))
}
return &p
}
func (p pointCardDo) Preload(fields ...field.RelationField) *pointCardDo {
for _, _f := range fields {
p = *p.withDO(p.DO.Preload(_f))
}
return &p
}
func (p pointCardDo) FirstOrInit() (*model.PointCard, error) {
if result, err := p.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.PointCard), nil
}
}
func (p pointCardDo) FirstOrCreate() (*model.PointCard, error) {
if result, err := p.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.PointCard), nil
}
}
func (p pointCardDo) FindByPage(offset int, limit int) (result []*model.PointCard, count int64, err error) {
result, err = p.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = p.Offset(-1).Limit(-1).Count()
return
}
func (p pointCardDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = p.Count()
if err != nil {
return
}
err = p.Offset(offset).Limit(limit).Scan(result)
return
}
func (p pointCardDo) Scan(result interface{}) (err error) {
return p.DO.Scan(result)
}
func (p pointCardDo) Delete(models ...*model.PointCard) (result gen.ResultInfo, err error) {
return p.DO.Delete(models)
}
func (p *pointCardDo) withDO(do gen.Dao) *pointCardDo {
p.DO = *do.(*gen.DO)
return p
}

View File

@@ -0,0 +1,364 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"git.hlsq.asia/mmorpg/qgdzs_db/model"
)
func newPointRecord(db *gorm.DB, opts ...gen.DOOption) pointRecord {
_pointRecord := pointRecord{}
_pointRecord.pointRecordDo.UseDB(db, opts...)
_pointRecord.pointRecordDo.UseModel(&model.PointRecord{})
tableName := _pointRecord.pointRecordDo.TableName()
_pointRecord.ALL = field.NewAsterisk(tableName)
_pointRecord.ID = field.NewUint64(tableName, "id")
_pointRecord.Sn = field.NewInt64(tableName, "sn")
_pointRecord.UserSn = field.NewInt64(tableName, "user_sn")
_pointRecord.Source = field.NewInt32(tableName, "source")
_pointRecord.Point = field.NewInt64(tableName, "point")
_pointRecord.CreatedAt = field.NewTime(tableName, "created_at")
_pointRecord.UpdatedAt = field.NewTime(tableName, "updated_at")
_pointRecord.DeletedAt = field.NewField(tableName, "deleted_at")
_pointRecord.fillFieldMap()
return _pointRecord
}
type pointRecord struct {
pointRecordDo pointRecordDo
ALL field.Asterisk
ID field.Uint64
Sn field.Int64 // 业务唯一编号
UserSn field.Int64 // 用户-唯一编号
/*
来源:
0. 未知
1. 随机答题
2. 类目答题
3. 限时答题
*/
Source field.Int32
Point field.Int64 // 积分
CreatedAt field.Time
UpdatedAt field.Time
DeletedAt field.Field
fieldMap map[string]field.Expr
}
func (p pointRecord) Table(newTableName string) *pointRecord {
p.pointRecordDo.UseTable(newTableName)
return p.updateTableName(newTableName)
}
func (p pointRecord) As(alias string) *pointRecord {
p.pointRecordDo.DO = *(p.pointRecordDo.As(alias).(*gen.DO))
return p.updateTableName(alias)
}
func (p *pointRecord) updateTableName(table string) *pointRecord {
p.ALL = field.NewAsterisk(table)
p.ID = field.NewUint64(table, "id")
p.Sn = field.NewInt64(table, "sn")
p.UserSn = field.NewInt64(table, "user_sn")
p.Source = field.NewInt32(table, "source")
p.Point = field.NewInt64(table, "point")
p.CreatedAt = field.NewTime(table, "created_at")
p.UpdatedAt = field.NewTime(table, "updated_at")
p.DeletedAt = field.NewField(table, "deleted_at")
p.fillFieldMap()
return p
}
func (p *pointRecord) WithContext(ctx context.Context) *pointRecordDo {
return p.pointRecordDo.WithContext(ctx)
}
func (p pointRecord) TableName() string { return p.pointRecordDo.TableName() }
func (p pointRecord) Alias() string { return p.pointRecordDo.Alias() }
func (p pointRecord) Columns(cols ...field.Expr) gen.Columns { return p.pointRecordDo.Columns(cols...) }
func (p *pointRecord) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := p.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (p *pointRecord) fillFieldMap() {
p.fieldMap = make(map[string]field.Expr, 8)
p.fieldMap["id"] = p.ID
p.fieldMap["sn"] = p.Sn
p.fieldMap["user_sn"] = p.UserSn
p.fieldMap["source"] = p.Source
p.fieldMap["point"] = p.Point
p.fieldMap["created_at"] = p.CreatedAt
p.fieldMap["updated_at"] = p.UpdatedAt
p.fieldMap["deleted_at"] = p.DeletedAt
}
func (p pointRecord) clone(db *gorm.DB) pointRecord {
p.pointRecordDo.ReplaceConnPool(db.Statement.ConnPool)
return p
}
func (p pointRecord) replaceDB(db *gorm.DB) pointRecord {
p.pointRecordDo.ReplaceDB(db)
return p
}
type pointRecordDo struct{ gen.DO }
func (p pointRecordDo) Debug() *pointRecordDo {
return p.withDO(p.DO.Debug())
}
func (p pointRecordDo) WithContext(ctx context.Context) *pointRecordDo {
return p.withDO(p.DO.WithContext(ctx))
}
func (p pointRecordDo) ReadDB() *pointRecordDo {
return p.Clauses(dbresolver.Read)
}
func (p pointRecordDo) WriteDB() *pointRecordDo {
return p.Clauses(dbresolver.Write)
}
func (p pointRecordDo) Session(config *gorm.Session) *pointRecordDo {
return p.withDO(p.DO.Session(config))
}
func (p pointRecordDo) Clauses(conds ...clause.Expression) *pointRecordDo {
return p.withDO(p.DO.Clauses(conds...))
}
func (p pointRecordDo) Returning(value interface{}, columns ...string) *pointRecordDo {
return p.withDO(p.DO.Returning(value, columns...))
}
func (p pointRecordDo) Not(conds ...gen.Condition) *pointRecordDo {
return p.withDO(p.DO.Not(conds...))
}
func (p pointRecordDo) Or(conds ...gen.Condition) *pointRecordDo {
return p.withDO(p.DO.Or(conds...))
}
func (p pointRecordDo) Select(conds ...field.Expr) *pointRecordDo {
return p.withDO(p.DO.Select(conds...))
}
func (p pointRecordDo) Where(conds ...gen.Condition) *pointRecordDo {
return p.withDO(p.DO.Where(conds...))
}
func (p pointRecordDo) Order(conds ...field.Expr) *pointRecordDo {
return p.withDO(p.DO.Order(conds...))
}
func (p pointRecordDo) Distinct(cols ...field.Expr) *pointRecordDo {
return p.withDO(p.DO.Distinct(cols...))
}
func (p pointRecordDo) Omit(cols ...field.Expr) *pointRecordDo {
return p.withDO(p.DO.Omit(cols...))
}
func (p pointRecordDo) Join(table schema.Tabler, on ...field.Expr) *pointRecordDo {
return p.withDO(p.DO.Join(table, on...))
}
func (p pointRecordDo) LeftJoin(table schema.Tabler, on ...field.Expr) *pointRecordDo {
return p.withDO(p.DO.LeftJoin(table, on...))
}
func (p pointRecordDo) RightJoin(table schema.Tabler, on ...field.Expr) *pointRecordDo {
return p.withDO(p.DO.RightJoin(table, on...))
}
func (p pointRecordDo) Group(cols ...field.Expr) *pointRecordDo {
return p.withDO(p.DO.Group(cols...))
}
func (p pointRecordDo) Having(conds ...gen.Condition) *pointRecordDo {
return p.withDO(p.DO.Having(conds...))
}
func (p pointRecordDo) Limit(limit int) *pointRecordDo {
return p.withDO(p.DO.Limit(limit))
}
func (p pointRecordDo) Offset(offset int) *pointRecordDo {
return p.withDO(p.DO.Offset(offset))
}
func (p pointRecordDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *pointRecordDo {
return p.withDO(p.DO.Scopes(funcs...))
}
func (p pointRecordDo) Unscoped() *pointRecordDo {
return p.withDO(p.DO.Unscoped())
}
func (p pointRecordDo) Create(values ...*model.PointRecord) error {
if len(values) == 0 {
return nil
}
return p.DO.Create(values)
}
func (p pointRecordDo) CreateInBatches(values []*model.PointRecord, batchSize int) error {
return p.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (p pointRecordDo) Save(values ...*model.PointRecord) error {
if len(values) == 0 {
return nil
}
return p.DO.Save(values)
}
func (p pointRecordDo) First() (*model.PointRecord, error) {
if result, err := p.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.PointRecord), nil
}
}
func (p pointRecordDo) Take() (*model.PointRecord, error) {
if result, err := p.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.PointRecord), nil
}
}
func (p pointRecordDo) Last() (*model.PointRecord, error) {
if result, err := p.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.PointRecord), nil
}
}
func (p pointRecordDo) Find() ([]*model.PointRecord, error) {
result, err := p.DO.Find()
return result.([]*model.PointRecord), err
}
func (p pointRecordDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.PointRecord, err error) {
buf := make([]*model.PointRecord, 0, batchSize)
err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (p pointRecordDo) FindInBatches(result *[]*model.PointRecord, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return p.DO.FindInBatches(result, batchSize, fc)
}
func (p pointRecordDo) Attrs(attrs ...field.AssignExpr) *pointRecordDo {
return p.withDO(p.DO.Attrs(attrs...))
}
func (p pointRecordDo) Assign(attrs ...field.AssignExpr) *pointRecordDo {
return p.withDO(p.DO.Assign(attrs...))
}
func (p pointRecordDo) Joins(fields ...field.RelationField) *pointRecordDo {
for _, _f := range fields {
p = *p.withDO(p.DO.Joins(_f))
}
return &p
}
func (p pointRecordDo) Preload(fields ...field.RelationField) *pointRecordDo {
for _, _f := range fields {
p = *p.withDO(p.DO.Preload(_f))
}
return &p
}
func (p pointRecordDo) FirstOrInit() (*model.PointRecord, error) {
if result, err := p.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.PointRecord), nil
}
}
func (p pointRecordDo) FirstOrCreate() (*model.PointRecord, error) {
if result, err := p.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.PointRecord), nil
}
}
func (p pointRecordDo) FindByPage(offset int, limit int) (result []*model.PointRecord, count int64, err error) {
result, err = p.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = p.Offset(-1).Limit(-1).Count()
return
}
func (p pointRecordDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = p.Count()
if err != nil {
return
}
err = p.Offset(offset).Limit(limit).Scan(result)
return
}
func (p pointRecordDo) Scan(result interface{}) (err error) {
return p.DO.Scan(result)
}
func (p pointRecordDo) Delete(models ...*model.PointRecord) (result gen.ResultInfo, err error) {
return p.DO.Delete(models)
}
func (p *pointRecordDo) withDO(do gen.Dao) *pointRecordDo {
p.DO = *do.(*gen.DO)
return p
}

View File

@@ -16,7 +16,7 @@ import (
"gorm.io/plugin/dbresolver"
"git.hlsq.asia/mmorpg/user_db/model"
"git.hlsq.asia/mmorpg/qgdzs_db/model"
)
func newQuestion(db *gorm.DB, opts ...gen.DOOption) question {
@@ -28,13 +28,13 @@ func newQuestion(db *gorm.DB, opts ...gen.DOOption) question {
tableName := _question.questionDo.TableName()
_question.ALL = field.NewAsterisk(tableName)
_question.ID = field.NewUint64(tableName, "id")
_question.Sn = field.NewString(tableName, "sn")
_question.Sn = field.NewInt64(tableName, "sn")
_question.Question = field.NewString(tableName, "question")
_question.Options = field.NewString(tableName, "options")
_question.Answer = field.NewString(tableName, "answer")
_question.Explanation = field.NewString(tableName, "explanation")
_question.Difficulty = field.NewInt32(tableName, "difficulty")
_question.Category = field.NewString(tableName, "category")
_question.CategorySn = field.NewInt64(tableName, "category_sn")
_question.CreatedAt = field.NewTime(tableName, "created_at")
_question.UpdatedAt = field.NewTime(tableName, "updated_at")
_question.DeletedAt = field.NewField(tableName, "deleted_at")
@@ -49,13 +49,13 @@ type question struct {
ALL field.Asterisk
ID field.Uint64
Sn field.String // 业务唯一编号
Sn field.Int64 // 业务唯一编号
Question field.String // 题干
Options field.String // 选项
Answer field.String // 答案
Explanation field.String // 解析
Difficulty field.Int32 // 难度分 0 - 100
Category field.String // 分类
CategorySn field.Int64 // 分类-唯一编号
CreatedAt field.Time
UpdatedAt field.Time
DeletedAt field.Field
@@ -76,13 +76,13 @@ func (q question) As(alias string) *question {
func (q *question) updateTableName(table string) *question {
q.ALL = field.NewAsterisk(table)
q.ID = field.NewUint64(table, "id")
q.Sn = field.NewString(table, "sn")
q.Sn = field.NewInt64(table, "sn")
q.Question = field.NewString(table, "question")
q.Options = field.NewString(table, "options")
q.Answer = field.NewString(table, "answer")
q.Explanation = field.NewString(table, "explanation")
q.Difficulty = field.NewInt32(table, "difficulty")
q.Category = field.NewString(table, "category")
q.CategorySn = field.NewInt64(table, "category_sn")
q.CreatedAt = field.NewTime(table, "created_at")
q.UpdatedAt = field.NewTime(table, "updated_at")
q.DeletedAt = field.NewField(table, "deleted_at")
@@ -118,7 +118,7 @@ func (q *question) fillFieldMap() {
q.fieldMap["answer"] = q.Answer
q.fieldMap["explanation"] = q.Explanation
q.fieldMap["difficulty"] = q.Difficulty
q.fieldMap["category"] = q.Category
q.fieldMap["category_sn"] = q.CategorySn
q.fieldMap["created_at"] = q.CreatedAt
q.fieldMap["updated_at"] = q.UpdatedAt
q.fieldMap["deleted_at"] = q.DeletedAt

View File

@@ -0,0 +1,359 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"git.hlsq.asia/mmorpg/qgdzs_db/model"
)
func newRecord(db *gorm.DB, opts ...gen.DOOption) record {
_record := record{}
_record.recordDo.UseDB(db, opts...)
_record.recordDo.UseModel(&model.Record{})
tableName := _record.recordDo.TableName()
_record.ALL = field.NewAsterisk(tableName)
_record.ID = field.NewUint64(tableName, "id")
_record.Sn = field.NewInt64(tableName, "sn")
_record.UserSn = field.NewInt64(tableName, "user_sn")
_record.QuestionSn = field.NewInt64(tableName, "question_sn")
_record.Answer = field.NewString(tableName, "answer")
_record.IsCorrect = field.NewInt32(tableName, "is_correct")
_record.CreatedAt = field.NewTime(tableName, "created_at")
_record.UpdatedAt = field.NewTime(tableName, "updated_at")
_record.DeletedAt = field.NewField(tableName, "deleted_at")
_record.fillFieldMap()
return _record
}
type record struct {
recordDo recordDo
ALL field.Asterisk
ID field.Uint64
Sn field.Int64 // 业务唯一编号
UserSn field.Int64 // 用户-唯一编号
QuestionSn field.Int64 // 题目-唯一编号
Answer field.String // 答案
IsCorrect field.Int32 // 是否正确 0 否 1 是
CreatedAt field.Time
UpdatedAt field.Time
DeletedAt field.Field
fieldMap map[string]field.Expr
}
func (r record) Table(newTableName string) *record {
r.recordDo.UseTable(newTableName)
return r.updateTableName(newTableName)
}
func (r record) As(alias string) *record {
r.recordDo.DO = *(r.recordDo.As(alias).(*gen.DO))
return r.updateTableName(alias)
}
func (r *record) updateTableName(table string) *record {
r.ALL = field.NewAsterisk(table)
r.ID = field.NewUint64(table, "id")
r.Sn = field.NewInt64(table, "sn")
r.UserSn = field.NewInt64(table, "user_sn")
r.QuestionSn = field.NewInt64(table, "question_sn")
r.Answer = field.NewString(table, "answer")
r.IsCorrect = field.NewInt32(table, "is_correct")
r.CreatedAt = field.NewTime(table, "created_at")
r.UpdatedAt = field.NewTime(table, "updated_at")
r.DeletedAt = field.NewField(table, "deleted_at")
r.fillFieldMap()
return r
}
func (r *record) WithContext(ctx context.Context) *recordDo { return r.recordDo.WithContext(ctx) }
func (r record) TableName() string { return r.recordDo.TableName() }
func (r record) Alias() string { return r.recordDo.Alias() }
func (r record) Columns(cols ...field.Expr) gen.Columns { return r.recordDo.Columns(cols...) }
func (r *record) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := r.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (r *record) fillFieldMap() {
r.fieldMap = make(map[string]field.Expr, 9)
r.fieldMap["id"] = r.ID
r.fieldMap["sn"] = r.Sn
r.fieldMap["user_sn"] = r.UserSn
r.fieldMap["question_sn"] = r.QuestionSn
r.fieldMap["answer"] = r.Answer
r.fieldMap["is_correct"] = r.IsCorrect
r.fieldMap["created_at"] = r.CreatedAt
r.fieldMap["updated_at"] = r.UpdatedAt
r.fieldMap["deleted_at"] = r.DeletedAt
}
func (r record) clone(db *gorm.DB) record {
r.recordDo.ReplaceConnPool(db.Statement.ConnPool)
return r
}
func (r record) replaceDB(db *gorm.DB) record {
r.recordDo.ReplaceDB(db)
return r
}
type recordDo struct{ gen.DO }
func (r recordDo) Debug() *recordDo {
return r.withDO(r.DO.Debug())
}
func (r recordDo) WithContext(ctx context.Context) *recordDo {
return r.withDO(r.DO.WithContext(ctx))
}
func (r recordDo) ReadDB() *recordDo {
return r.Clauses(dbresolver.Read)
}
func (r recordDo) WriteDB() *recordDo {
return r.Clauses(dbresolver.Write)
}
func (r recordDo) Session(config *gorm.Session) *recordDo {
return r.withDO(r.DO.Session(config))
}
func (r recordDo) Clauses(conds ...clause.Expression) *recordDo {
return r.withDO(r.DO.Clauses(conds...))
}
func (r recordDo) Returning(value interface{}, columns ...string) *recordDo {
return r.withDO(r.DO.Returning(value, columns...))
}
func (r recordDo) Not(conds ...gen.Condition) *recordDo {
return r.withDO(r.DO.Not(conds...))
}
func (r recordDo) Or(conds ...gen.Condition) *recordDo {
return r.withDO(r.DO.Or(conds...))
}
func (r recordDo) Select(conds ...field.Expr) *recordDo {
return r.withDO(r.DO.Select(conds...))
}
func (r recordDo) Where(conds ...gen.Condition) *recordDo {
return r.withDO(r.DO.Where(conds...))
}
func (r recordDo) Order(conds ...field.Expr) *recordDo {
return r.withDO(r.DO.Order(conds...))
}
func (r recordDo) Distinct(cols ...field.Expr) *recordDo {
return r.withDO(r.DO.Distinct(cols...))
}
func (r recordDo) Omit(cols ...field.Expr) *recordDo {
return r.withDO(r.DO.Omit(cols...))
}
func (r recordDo) Join(table schema.Tabler, on ...field.Expr) *recordDo {
return r.withDO(r.DO.Join(table, on...))
}
func (r recordDo) LeftJoin(table schema.Tabler, on ...field.Expr) *recordDo {
return r.withDO(r.DO.LeftJoin(table, on...))
}
func (r recordDo) RightJoin(table schema.Tabler, on ...field.Expr) *recordDo {
return r.withDO(r.DO.RightJoin(table, on...))
}
func (r recordDo) Group(cols ...field.Expr) *recordDo {
return r.withDO(r.DO.Group(cols...))
}
func (r recordDo) Having(conds ...gen.Condition) *recordDo {
return r.withDO(r.DO.Having(conds...))
}
func (r recordDo) Limit(limit int) *recordDo {
return r.withDO(r.DO.Limit(limit))
}
func (r recordDo) Offset(offset int) *recordDo {
return r.withDO(r.DO.Offset(offset))
}
func (r recordDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *recordDo {
return r.withDO(r.DO.Scopes(funcs...))
}
func (r recordDo) Unscoped() *recordDo {
return r.withDO(r.DO.Unscoped())
}
func (r recordDo) Create(values ...*model.Record) error {
if len(values) == 0 {
return nil
}
return r.DO.Create(values)
}
func (r recordDo) CreateInBatches(values []*model.Record, batchSize int) error {
return r.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (r recordDo) Save(values ...*model.Record) error {
if len(values) == 0 {
return nil
}
return r.DO.Save(values)
}
func (r recordDo) First() (*model.Record, error) {
if result, err := r.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.Record), nil
}
}
func (r recordDo) Take() (*model.Record, error) {
if result, err := r.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.Record), nil
}
}
func (r recordDo) Last() (*model.Record, error) {
if result, err := r.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.Record), nil
}
}
func (r recordDo) Find() ([]*model.Record, error) {
result, err := r.DO.Find()
return result.([]*model.Record), err
}
func (r recordDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Record, err error) {
buf := make([]*model.Record, 0, batchSize)
err = r.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (r recordDo) FindInBatches(result *[]*model.Record, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return r.DO.FindInBatches(result, batchSize, fc)
}
func (r recordDo) Attrs(attrs ...field.AssignExpr) *recordDo {
return r.withDO(r.DO.Attrs(attrs...))
}
func (r recordDo) Assign(attrs ...field.AssignExpr) *recordDo {
return r.withDO(r.DO.Assign(attrs...))
}
func (r recordDo) Joins(fields ...field.RelationField) *recordDo {
for _, _f := range fields {
r = *r.withDO(r.DO.Joins(_f))
}
return &r
}
func (r recordDo) Preload(fields ...field.RelationField) *recordDo {
for _, _f := range fields {
r = *r.withDO(r.DO.Preload(_f))
}
return &r
}
func (r recordDo) FirstOrInit() (*model.Record, error) {
if result, err := r.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.Record), nil
}
}
func (r recordDo) FirstOrCreate() (*model.Record, error) {
if result, err := r.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.Record), nil
}
}
func (r recordDo) FindByPage(offset int, limit int) (result []*model.Record, count int64, err error) {
result, err = r.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = r.Offset(-1).Limit(-1).Count()
return
}
func (r recordDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = r.Count()
if err != nil {
return
}
err = r.Offset(offset).Limit(limit).Scan(result)
return
}
func (r recordDo) Scan(result interface{}) (err error) {
return r.DO.Scan(result)
}
func (r recordDo) Delete(models ...*model.Record) (result gen.ResultInfo, err error) {
return r.DO.Delete(models)
}
func (r *recordDo) withDO(do gen.Dao) *recordDo {
r.DO = *do.(*gen.DO)
return r
}

View File

@@ -1,4 +1,4 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
@@ -7,21 +7,23 @@ package model
import (
"time"
"gorm.io/gorm"
"git.hlsq.asia/mmorpg/service-common/utils"
"gorm.io/gorm"
)
const TableNameUser = "users"
// User mapped from table <users>
type User struct {
ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
Sn string `gorm:"column:sn;not null;comment:业务唯一编号" json:"sn"` // 业务唯一编号
Name string `gorm:"column:name;not null" json:"name"`
Phone string `gorm:"column:phone;not null" json:"phone"`
CreatedAt time.Time `gorm:"column:created_at;not null" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;not null" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"deleted_at"`
ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
Sn int64 `gorm:"column:sn;not null;comment:业务唯一编号" json:"sn"` // 业务唯一编号
Name string `gorm:"column:name;not null" json:"name"`
Phone string `gorm:"column:phone" json:"phone"`
WxUnionID string `gorm:"column:wx_union_id;comment:微信用户唯一标识" json:"wx_union_id"` // 微信用户唯一标识
WxMiniOpenID string `gorm:"column:wx_mini_open_id;comment:微信小程序的openID" json:"wx_mini_open_id"` // 微信小程序的openID
CreatedAt time.Time `gorm:"column:created_at;not null" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;not null" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"deleted_at"`
}
// TableName User's table name
@@ -31,8 +33,8 @@ func (*User) TableName() string {
// Auto sn
func (m *User) BeforeCreate(_ *gorm.DB) error {
if m.Sn == "" {
m.Sn = utils.SnowflakeInstance().Generate().String()
if m.Sn == 0 {
m.Sn = utils.SnowflakeInstance().Generate().Int64()
}
return nil
}

View File

@@ -17,26 +17,23 @@ import (
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
return &Query{
db: db,
Question: newQuestion(db, opts...),
User: newUser(db, opts...),
db: db,
User: newUser(db, opts...),
}
}
type Query struct {
db *gorm.DB
Question question
User user
User user
}
func (q *Query) Available() bool { return q.db != nil }
func (q *Query) clone(db *gorm.DB) *Query {
return &Query{
db: db,
Question: q.Question.clone(db),
User: q.User.clone(db),
db: db,
User: q.User.clone(db),
}
}
@@ -50,21 +47,18 @@ func (q *Query) WriteDB() *Query {
func (q *Query) ReplaceDB(db *gorm.DB) *Query {
return &Query{
db: db,
Question: q.Question.replaceDB(db),
User: q.User.replaceDB(db),
db: db,
User: q.User.replaceDB(db),
}
}
type queryCtx struct {
Question *questionDo
User *userDo
User *userDo
}
func (q *Query) WithContext(ctx context.Context) *queryCtx {
return &queryCtx{
Question: q.Question.WithContext(ctx),
User: q.User.WithContext(ctx),
User: q.User.WithContext(ctx),
}
}

View File

@@ -28,9 +28,11 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) user {
tableName := _user.userDo.TableName()
_user.ALL = field.NewAsterisk(tableName)
_user.ID = field.NewUint64(tableName, "id")
_user.Sn = field.NewString(tableName, "sn")
_user.Sn = field.NewInt64(tableName, "sn")
_user.Name = field.NewString(tableName, "name")
_user.Phone = field.NewString(tableName, "phone")
_user.WxUnionID = field.NewString(tableName, "wx_union_id")
_user.WxMiniOpenID = field.NewString(tableName, "wx_mini_open_id")
_user.CreatedAt = field.NewTime(tableName, "created_at")
_user.UpdatedAt = field.NewTime(tableName, "updated_at")
_user.DeletedAt = field.NewField(tableName, "deleted_at")
@@ -43,14 +45,16 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) user {
type user struct {
userDo userDo
ALL field.Asterisk
ID field.Uint64
Sn field.String // 业务唯一编号
Name field.String
Phone field.String
CreatedAt field.Time
UpdatedAt field.Time
DeletedAt field.Field
ALL field.Asterisk
ID field.Uint64
Sn field.Int64 // 业务唯一编号
Name field.String
Phone field.String
WxUnionID field.String // 微信用户唯一标识
WxMiniOpenID field.String // 微信小程序的openID
CreatedAt field.Time
UpdatedAt field.Time
DeletedAt field.Field
fieldMap map[string]field.Expr
}
@@ -68,9 +72,11 @@ func (u user) As(alias string) *user {
func (u *user) updateTableName(table string) *user {
u.ALL = field.NewAsterisk(table)
u.ID = field.NewUint64(table, "id")
u.Sn = field.NewString(table, "sn")
u.Sn = field.NewInt64(table, "sn")
u.Name = field.NewString(table, "name")
u.Phone = field.NewString(table, "phone")
u.WxUnionID = field.NewString(table, "wx_union_id")
u.WxMiniOpenID = field.NewString(table, "wx_mini_open_id")
u.CreatedAt = field.NewTime(table, "created_at")
u.UpdatedAt = field.NewTime(table, "updated_at")
u.DeletedAt = field.NewField(table, "deleted_at")
@@ -98,11 +104,13 @@ func (u *user) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
}
func (u *user) fillFieldMap() {
u.fieldMap = make(map[string]field.Expr, 7)
u.fieldMap = make(map[string]field.Expr, 9)
u.fieldMap["id"] = u.ID
u.fieldMap["sn"] = u.Sn
u.fieldMap["name"] = u.Name
u.fieldMap["phone"] = u.Phone
u.fieldMap["wx_union_id"] = u.WxUnionID
u.fieldMap["wx_mini_open_id"] = u.WxMiniOpenID
u.fieldMap["created_at"] = u.CreatedAt
u.fieldMap["updated_at"] = u.UpdatedAt
u.fieldMap["deleted_at"] = u.DeletedAt

View File

@@ -1,19 +1,13 @@
# README
## About
## 文档
https://wails.io/zh-Hans/docs/introduction
This is the official Wails Vue-TS template.
## 安装 Wails CLI
go install github.com/wailsapp/wails/v2/cmd/wails@v2.11.0
You can configure the project by editing `wails.json`. More information about the project settings can be found
here: https://wails.io/docs/reference/project-config
## 运行
wails dev
## Live Development
To run in live development mode, run `wails dev` in the project directory. This will run a Vite development
server that will provide very fast hot reload of your frontend changes. If you want to develop in a browser
and have access to your Go methods, there is also a dev server that runs on http://localhost:34115. Connect
to this in your browser, and you can call your Go code from devtools.
## Building
To build a redistributable, production mode package, use `wails build`.
## 打包
wails build

View File

@@ -23,7 +23,7 @@ type Settings struct {
MysqlModelPath string `json:"mysqlModelPath"`
DefaultQueryPackagePath string `json:"defaultQueryPackagePath"`
ModelBasePath string `json:"modelBasePath"`
SwaggerDir string `json:"swaggerDir"`
SwaggerFilePath string `json:"swaggerFilePath"`
Databases []DatabaseConfig `json:"databases"`
Projects []ProjectConfig `json:"projects"`
}

View File

@@ -31,7 +31,7 @@ func (a *App) loadSettings() {
MysqlModelPath: "",
DefaultQueryPackagePath: "",
ModelBasePath: "",
SwaggerDir: "",
SwaggerFilePath: "",
Databases: []DatabaseConfig{},
Projects: []ProjectConfig{},
}
@@ -49,7 +49,7 @@ func (a *App) loadSettings() {
MysqlModelPath: "",
DefaultQueryPackagePath: "",
ModelBasePath: "",
SwaggerDir: "",
SwaggerFilePath: "",
Databases: []DatabaseConfig{},
Projects: []ProjectConfig{},
}
@@ -69,7 +69,7 @@ func (a *App) loadSettings() {
MysqlModelPath: "",
DefaultQueryPackagePath: "",
ModelBasePath: "",
SwaggerDir: "",
SwaggerFilePath: "",
Databases: []DatabaseConfig{},
Projects: []ProjectConfig{},
}

View File

@@ -63,6 +63,24 @@ func (a *App) GetSwaggerFiles(dirPath string) ([]SwaggerFile, error) {
return files, nil
}
func (a *App) GetSwaggerFileInfo(filePath string) (SwaggerFile, error) {
if filePath == "" {
return SwaggerFile{}, fmt.Errorf("file path is empty")
}
info, err := os.Stat(filePath)
if err != nil {
return SwaggerFile{}, fmt.Errorf("failed to get file info: %w", err)
}
return SwaggerFile{
Name: info.Name(),
Path: filePath,
Size: info.Size(),
ModifiedTime: info.ModTime().Format("2006-01-02 15:04:05"),
}, nil
}
func (a *App) ReadSwaggerFile(filePath string) (string, error) {
if filePath == "" {
return "", fmt.Errorf("file path is empty")
@@ -76,9 +94,9 @@ func (a *App) ReadSwaggerFile(filePath string) (string, error) {
return string(content), nil
}
func (a *App) StartSwaggerServer(dirPath string) (string, error) {
if dirPath == "" {
return "", fmt.Errorf("directory path is empty")
func (a *App) StartSwaggerServer(filePath string) (string, error) {
if filePath == "" {
return "", fmt.Errorf("file path is empty")
}
swaggerServerMu.Lock()
@@ -121,11 +139,8 @@ func (a *App) StartSwaggerServer(dirPath string) (string, error) {
<script src="https://unpkg.com/swagger-ui-dist@5.10.5/swagger-ui-bundle.js"></script>
<script>
window.onload = function() {
const urlParams = new URLSearchParams(window.location.search);
const fileParam = urlParams.get('file');
const swaggerUrl = fileParam ? '/swagger.json?file=' + encodeURIComponent(fileParam) : '/swagger.json';
const ui = SwaggerUIBundle({
url: swaggerUrl,
url: '/swagger.json',
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
@@ -148,29 +163,7 @@ func (a *App) StartSwaggerServer(dirPath string) (string, error) {
})
mux.HandleFunc("/swagger.json", func(w http.ResponseWriter, r *http.Request) {
files, err := a.GetSwaggerFiles(dirPath)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if len(files) == 0 {
http.Error(w, "No swagger files found", http.StatusNotFound)
return
}
fileName := r.URL.Query().Get("file")
selectedFile := files[0]
if fileName != "" {
for _, file := range files {
if file.Name == fileName {
selectedFile = file
break
}
}
}
content, err := os.ReadFile(selectedFile.Path)
content, err := os.ReadFile(filePath)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return

View File

@@ -1 +1 @@
27251dcea746309433392e41407ed6c9
12a2c8ac492a939e7178bbd4f4e7ce00

View File

@@ -38,7 +38,6 @@ const features = reactive([
</div>
<div class="features-section">
<h2 class="section-title">功能介绍</h2>
<div class="features-grid">
<el-card v-for="(feature, index) in features" :key="index" class="feature-card">
<div class="feature-icon">{{ feature.icon }}</div>
@@ -82,13 +81,6 @@ const features = reactive([
margin: 40px 0;
}
.section-title {
font-size: 28px;
font-weight: 600;
color: #333;
margin: 0 0 30px 0;
}
.features-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));

View File

@@ -3,17 +3,17 @@ import {onMounted, reactive, ref} from 'vue'
import {ElMessage} from 'element-plus'
import {
GetSettings,
GetSwaggerFiles,
GetSwaggerFileInfo,
GetSwaggerServerURL,
IsSwaggerServerRunning,
ReadSwaggerFile,
SaveSettings,
SelectDirectory,
SelectFile,
StartSwaggerServer,
StopSwaggerServer
} from '../../wailsjs/go/backend/App'
interface SwaggerFile {
interface SwaggerFileInfo {
name: string
path: string
size: number
@@ -25,7 +25,7 @@ interface AppSettings {
language: string
notifications: boolean
autoStart: boolean
swaggerDir: string
swaggerFilePath: string
}
const settings = reactive<AppSettings>({
@@ -33,51 +33,39 @@ const settings = reactive<AppSettings>({
language: 'zh-CN',
notifications: true,
autoStart: false,
swaggerDir: ''
swaggerFilePath: ''
})
const swaggerFiles = ref<SwaggerFile[]>([])
const selectedFile = ref<SwaggerFile | null>(null)
const selectedSwaggerFile = ref<SwaggerFile | null>(null)
const swaggerFileInfo = ref<SwaggerFileInfo | null>(null)
const fileContent = ref('')
const isLoading = ref(false)
const serverURL = ref('')
const isServerRunning = ref(false)
async function selectSwaggerDir() {
async function selectSwaggerFile() {
try {
const path = await SelectDirectory('选择 Swagger 目录', settings.swaggerDir)
const path = await SelectFile('选择 Swagger 文件', settings.swaggerFilePath, '*.json')
if (path) {
settings.swaggerDir = path
await loadSwaggerFiles()
settings.swaggerFilePath = path
const fileInfo = await GetSwaggerFileInfo(path)
if (fileInfo) {
swaggerFileInfo.value = fileInfo
}
await saveSettings()
}
} catch (error) {
console.error('Failed to select directory:', error)
console.error('Failed to select swagger file:', error)
}
}
async function loadSwaggerFiles() {
if (!settings.swaggerDir) {
return
}
isLoading.value = true
try {
const files = await GetSwaggerFiles(settings.swaggerDir)
swaggerFiles.value = files
} catch (error) {
console.error('Failed to load swagger files:', error)
ElMessage.error('加载 Swagger 文件失败')
} finally {
isLoading.value = false
}
return
}
async function saveSettings() {
try {
const currentSettings = await GetSettings() as any
currentSettings.swaggerDir = settings.swaggerDir
currentSettings.swaggerFilePath = settings.swaggerFilePath
await SaveSettings(currentSettings)
ElMessage.success('设置保存成功')
} catch (error) {
@@ -86,8 +74,8 @@ async function saveSettings() {
}
}
async function viewFile(file: SwaggerFile) {
selectedFile.value = file
async function viewFile(file: SwaggerFileInfo) {
swaggerFileInfo.value = file
isLoading.value = true
try {
const content = await ReadSwaggerFile(file.path)
@@ -111,18 +99,15 @@ function formatFileSize(bytes: number): string {
}
async function startSwaggerServer() {
if (!settings.swaggerDir) {
ElMessage.warning('请先配置 Swagger 目录')
if (!settings.swaggerFilePath) {
ElMessage.warning('请先配置 Swagger 文件')
return
}
try {
const url = await StartSwaggerServer(settings.swaggerDir)
const url = await StartSwaggerServer(settings.swaggerFilePath)
serverURL.value = url
isServerRunning.value = true
if (swaggerFiles.value.length > 0) {
selectedSwaggerFile.value = swaggerFiles.value[0]
}
ElMessage.success(`Swagger 服务已启动: ${url}`)
} catch (error) {
console.error('Failed to start swagger server:', error)
@@ -162,9 +147,9 @@ function openSwaggerURL() {
}
function updateServerURL() {
if (serverURL.value && selectedSwaggerFile.value) {
if (serverURL.value && swaggerFileInfo.value) {
const baseUrl = serverURL.value.split('?')[0]
serverURL.value = `${baseUrl}?file=${encodeURIComponent(selectedSwaggerFile.value.name)}`
serverURL.value = `${baseUrl}?file=${encodeURIComponent(swaggerFileInfo.value.name)}`
}
}
@@ -175,9 +160,12 @@ onMounted(async () => {
settings.language = loadedSettings.language
settings.notifications = loadedSettings.notifications
settings.autoStart = loadedSettings.autoStart
settings.swaggerDir = loadedSettings.swaggerDir || ''
if (settings.swaggerDir) {
await loadSwaggerFiles()
settings.swaggerFilePath = loadedSettings.swaggerFilePath || ''
if (settings.swaggerFilePath) {
const fileInfo = await GetSwaggerFileInfo(settings.swaggerFilePath)
if (fileInfo) {
swaggerFileInfo.value = fileInfo
}
}
await checkServerStatus()
} catch (error) {
@@ -195,14 +183,14 @@ onMounted(async () => {
</div>
</template>
<el-form label-width="140px" class="settings-form">
<el-form-item label="Swagger 目录">
<el-form-item label="Swagger 文件">
<el-input
v-model="settings.swaggerDir"
placeholder="请输入或选择 Swagger 文件目录"
v-model="settings.swaggerFilePath"
placeholder="请输入或选择 Swagger 文件"
clearable
>
<template #append>
<el-button @click="selectSwaggerDir">选择文件</el-button>
<el-button @click="selectSwaggerFile">选择文件</el-button>
</template>
</el-input>
</el-form-item>
@@ -222,20 +210,6 @@ onMounted(async () => {
>
停止服务
</el-button>
<el-select
v-if="isServerRunning && swaggerFiles.length > 1"
v-model="selectedSwaggerFile"
placeholder="选择 Swagger 文件"
class="file-select"
@change="updateServerURL"
>
<el-option
v-for="file in swaggerFiles"
:key="file.name"
:label="file.name"
:value="file"
/>
</el-select>
<el-input
v-if="serverURL"
v-model="serverURL"
@@ -251,39 +225,19 @@ onMounted(async () => {
</el-form>
</el-card>
<el-card class="files-card">
<el-card class="content-card" v-if="swaggerFileInfo">
<template #header>
<div class="card-header">
<span>Swagger 文件列表</span>
<el-button type="primary" size="small" @click="loadSwaggerFiles" :loading="isLoading">刷新</el-button>
<span>{{ swaggerFileInfo.name }}</span>
<el-button size="small" @click="swaggerFileInfo = null">关闭</el-button>
</div>
</template>
<el-table :data="swaggerFiles" style="width: 100%" v-loading="isLoading">
<el-table-column prop="name" label="文件名" show-overflow-tooltip/>
<el-table-column prop="size" label="大小" width="120">
<template #default="scope">
{{ formatFileSize(scope.row.size) }}
</template>
</el-table-column>
<el-table-column prop="modifiedTime" label="修改时间" width="180"/>
<el-table-column label="操作" width="150">
<template #default="scope">
<el-button size="small" @click="viewFile(scope.row)">查看</el-button>
</template>
</el-table-column>
</el-table>
<el-empty v-if="swaggerFiles.length === 0 && !isLoading" description="暂无 Swagger 文件"/>
</el-card>
<el-card class="content-card" v-if="selectedFile">
<template #header>
<div class="card-header">
<span>{{ selectedFile.name }}</span>
<el-button size="small" @click="selectedFile = null">关闭</el-button>
<div class="info-content">
<div class="file-info">
<p><strong>文件路径</strong>{{ swaggerFileInfo.path }}</p>
<p><strong>文件大小</strong>{{ formatFileSize(swaggerFileInfo.size) }}</p>
<p><strong>修改时间</strong>{{ swaggerFileInfo.modifiedTime }}</p>
</div>
</template>
<div class="file-content" v-loading="isLoading">
<pre>{{ fileContent }}</pre>
</div>
</el-card>
</div>

View File

@@ -12,6 +12,8 @@ export function ExecuteGenPs1(arg1:string,arg2:string,arg3:string,arg4:string):P
export function GetSettings():Promise<backend.Settings>;
export function GetSwaggerFileInfo(arg1:string):Promise<backend.SwaggerFile>;
export function GetSwaggerFiles(arg1:string):Promise<Array<backend.SwaggerFile>>;
export function GetSwaggerServerURL():Promise<string>;

View File

@@ -22,6 +22,10 @@ export function GetSettings() {
return window['go']['backend']['App']['GetSettings']();
}
export function GetSwaggerFileInfo(arg1) {
return window['go']['backend']['App']['GetSwaggerFileInfo'](arg1);
}
export function GetSwaggerFiles(arg1) {
return window['go']['backend']['App']['GetSwaggerFiles'](arg1);
}

View File

@@ -38,7 +38,7 @@ export namespace backend {
mysqlModelPath: string;
defaultQueryPackagePath: string;
modelBasePath: string;
swaggerDir: string;
swaggerFilePath: string;
databases: DatabaseConfig[];
projects: ProjectConfig[];
@@ -55,7 +55,7 @@ export namespace backend {
this.mysqlModelPath = source["mysqlModelPath"];
this.defaultQueryPackagePath = source["defaultQueryPackagePath"];
this.modelBasePath = source["modelBasePath"];
this.swaggerDir = source["swaggerDir"];
this.swaggerFilePath = source["swaggerFilePath"];
this.databases = this.convertValues(source["databases"], DatabaseConfig);
this.projects = this.convertValues(source["projects"], ProjectConfig);
}

View File

@@ -2,10 +2,11 @@ package main
import (
"embed"
"quickly/backend"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"quickly/backend"
)
//go:embed all:frontend/dist
@@ -15,8 +16,8 @@ func main() {
app := backend.NewApp()
err := wails.Run(&options.App{
Title: "Quickly 金牌助手",
Width: 1024,
Height: 768,
Width: 1280,
Height: 720,
AssetServer: &assetserver.Options{
Assets: assets,
},