This commit is contained in:
david.yan 2025-04-01 17:37:16 +08:00
parent d94b2744c0
commit 23c5220745
35 changed files with 2938 additions and 3585 deletions

12
go.mod
View File

@ -3,6 +3,18 @@ module protoc-gen-slc
go 1.24.0
require (
git.apinb.com/bsm-sdk/core v0.0.29
golang.org/x/mod v0.24.0
google.golang.org/grpc v1.71.0
google.golang.org/protobuf v1.36.6
)
require (
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/oklog/ulid/v2 v2.1.0 // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/text v0.22.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb // indirect
)

41
go.sum
View File

@ -1,8 +1,41 @@
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
git.apinb.com/bsm-sdk/core v0.0.29 h1:7ibdZw5doJ0AP+7+5G8/HjZysD1frEapHxtemJySfGs=
git.apinb.com/bsm-sdk/core v0.0.29/go.mod h1:FY2knuEVN7d7eHhpkyI+Cj/4oJ34gqZ8xzE7hB3JkOE=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU=
github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=
go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ=
go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE=
go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A=
go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU=
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=
go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k=
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb h1:TLPQVbx1GJ8VKZxz52VAxl1EBgKXXbTiU9Fc5fZeLn4=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb/go.mod h1:LuRYeWDFV6WOn90g357N17oMCaxpgCnbi/44qJvDn2I=
google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg=
google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=

93
main.go
View File

@ -8,8 +8,10 @@ import (
"os"
"path/filepath"
"protoc-gen-slc/tpl"
"regexp"
"strings"
"git.apinb.com/bsm-sdk/core/utils"
"golang.org/x/mod/modfile"
"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/types/pluginpb"
@ -20,6 +22,19 @@ var ServicesName []string
func main() {
protogen.Options{}.Run(func(gen *protogen.Plugin) error {
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
if !utils.PathExists("./internal") {
os.MkdirAll("./internal", 777)
}
if !utils.PathExists("./internal/server") {
os.MkdirAll("./internal/server", 777)
}
if !utils.PathExists("./internal/logic") {
os.MkdirAll("./internal/logic", 777)
}
for _, f := range gen.Files {
if len(f.Services) == 0 {
continue
@ -29,7 +44,11 @@ func main() {
}
}
generateNewServerFile(ServicesName)
err := generateNewServerFile(ServicesName)
if err != nil {
return err
}
return nil
})
@ -43,15 +62,10 @@ func generateFiles(gen *protogen.Plugin, file *protogen.File) error {
return err
}
// // Generate client file
// if err := generateClientFile(gen, file, service); err != nil {
// return err
// }
// // Generate logic file
// if err := generateLogicFile(gen, file, service); err != nil {
// return err
// }
// Generate logic file
if err := generateLogicFile(gen, file, service); err != nil {
return err
}
}
return nil
@ -66,26 +80,34 @@ func generateNewServerFile(services []string) error {
"pb \"" + moduleName + "/pb\"",
}
code = strings.ReplaceAll(code, "{import}", strings.Join(newImports, "\n"))
// register grpc
var register []string
for _, service := range services {
register = append(register, "pb.Register"+service+"Server(srv, New"+service+"Server())")
register = append(register, "pb.Register"+service+"Server(srv.Grpc, New"+service+"Server())")
}
code = strings.ReplaceAll(code, "{register}", strings.Join(register, "\n"))
// register grpc gw
var gw []string
for _, service := range services {
gw = append(gw, "pb.Register"+service+"HandlerFromEndpoint(srv.Ctx, srv.Mux, addr, opts)")
}
code = strings.ReplaceAll(code, "{gw}", strings.Join(gw, "\n"))
// 格式化代码
formattedCode, err := format.Source([]byte(code))
if err != nil {
return fmt.Errorf("failed to format generated code: %w", err)
}
StringToFile("./server/new.go", string(formattedCode))
StringToFile("./internal/server/new.go", string(formattedCode))
return nil
}
func generateServerFile(gen *protogen.Plugin, file *protogen.File, service *protogen.Service) error {
filename := fmt.Sprintf("./server/%s_server.go", strings.ToLower(service.GoName))
filename := fmt.Sprintf("./internal/server/%s_server.go", strings.ToLower(service.GoName))
moduleName := getModuleName()
//create servers.
@ -130,11 +152,50 @@ func generateClientFile(gen *protogen.Plugin, file *protogen.File, service *prot
}
func generateLogicFile(gen *protogen.Plugin, file *protogen.File, service *protogen.Service) error {
filename := fmt.Sprintf("%s_logic.pb.go", strings.ToLower(service.GoName))
fmt.Println(filename, file.GoImportPath)
logicPath := "./internal/logic/" + strings.ToLower(service.GoName)
if !utils.PathExists(logicPath) {
os.MkdirAll(logicPath, os.ModePerm)
}
moduleName := getModuleName()
for _, method := range service.Methods {
filename := fmt.Sprintf("%s/%s.go", logicPath, toSnakeCase(method.GoName))
if utils.PathExists(filename) {
continue
}
code := tpl.LogicFile
code = strings.ReplaceAll(code, "{methodName}", strings.ToLower(service.GoName))
imports := []string{
"pb \"" + moduleName + "/pb\"",
}
code = strings.ReplaceAll(code, "{import}", strings.Join(imports, "\n"))
commit := strings.TrimSpace(method.Comments.Leading.String())
code = strings.ReplaceAll(code, "{func}", method.GoName)
code = strings.ReplaceAll(code, "{comment}", commit)
code = strings.ReplaceAll(code, "{input}", method.Input.GoIdent.GoName)
code = strings.ReplaceAll(code, "{output}", method.Output.GoIdent.GoName)
// formattedCode, err := format.Source([]byte(code))
// if err != nil {
// return fmt.Errorf("failed to format generated code: %w", err)
// }
// StringToFile(filename, string(formattedCode))
StringToFile(filename, code)
}
return nil
}
func toSnakeCase(str string) string {
// Use a regular expression to find uppercase letters and insert an underscore before them
re := regexp.MustCompile("([a-z0-9])([A-Z])")
snake := re.ReplaceAllString(str, "${1}_${2}")
// Convert the entire string to lowercase
return strings.ToLower(snake)
}
func methodSignature(g *protogen.GeneratedFile, method *protogen.Method) string {
return fmt.Sprintf("%s(ctx context.Context, req pb%s) (*%s, error)",
method.GoName,

287
pb/answer.pb.go Normal file
View File

@ -0,0 +1,287 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.6
// protoc v6.30.1
// source: answer.proto
package survey
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type SubmitAnswerRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
SurveyId string `protobuf:"bytes,1,opt,name=survey_id,json=surveyId,proto3" json:"survey_id,omitempty"`
OwnerId string `protobuf:"bytes,2,opt,name=owner_id,json=ownerId,proto3" json:"owner_id,omitempty"` // 答题者ID
Answer []*AnswerItem `protobuf:"bytes,3,rep,name=answer,proto3" json:"answer,omitempty"` // 答题
IpAddress string `protobuf:"bytes,4,opt,name=ip_address,json=ipAddress,proto3" json:"ip_address,omitempty"`
UserAgent string `protobuf:"bytes,5,opt,name=user_agent,json=userAgent,proto3" json:"user_agent,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *SubmitAnswerRequest) Reset() {
*x = SubmitAnswerRequest{}
mi := &file_answer_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *SubmitAnswerRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SubmitAnswerRequest) ProtoMessage() {}
func (x *SubmitAnswerRequest) ProtoReflect() protoreflect.Message {
mi := &file_answer_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SubmitAnswerRequest.ProtoReflect.Descriptor instead.
func (*SubmitAnswerRequest) Descriptor() ([]byte, []int) {
return file_answer_proto_rawDescGZIP(), []int{0}
}
func (x *SubmitAnswerRequest) GetSurveyId() string {
if x != nil {
return x.SurveyId
}
return ""
}
func (x *SubmitAnswerRequest) GetOwnerId() string {
if x != nil {
return x.OwnerId
}
return ""
}
func (x *SubmitAnswerRequest) GetAnswer() []*AnswerItem {
if x != nil {
return x.Answer
}
return nil
}
func (x *SubmitAnswerRequest) GetIpAddress() string {
if x != nil {
return x.IpAddress
}
return ""
}
func (x *SubmitAnswerRequest) GetUserAgent() string {
if x != nil {
return x.UserAgent
}
return ""
}
type AnswerItem struct {
state protoimpl.MessageState `protogen:"open.v1"`
QuestionId string `protobuf:"bytes,1,opt,name=question_id,json=questionId,proto3" json:"question_id,omitempty"`
Answer []string `protobuf:"bytes,2,rep,name=answer,proto3" json:"answer,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AnswerItem) Reset() {
*x = AnswerItem{}
mi := &file_answer_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AnswerItem) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AnswerItem) ProtoMessage() {}
func (x *AnswerItem) ProtoReflect() protoreflect.Message {
mi := &file_answer_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AnswerItem.ProtoReflect.Descriptor instead.
func (*AnswerItem) Descriptor() ([]byte, []int) {
return file_answer_proto_rawDescGZIP(), []int{1}
}
func (x *AnswerItem) GetQuestionId() string {
if x != nil {
return x.QuestionId
}
return ""
}
func (x *AnswerItem) GetAnswer() []string {
if x != nil {
return x.Answer
}
return nil
}
type ListAnswerReply struct {
state protoimpl.MessageState `protogen:"open.v1"`
Data []*AnswerItem `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
Count int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListAnswerReply) Reset() {
*x = ListAnswerReply{}
mi := &file_answer_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListAnswerReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListAnswerReply) ProtoMessage() {}
func (x *ListAnswerReply) ProtoReflect() protoreflect.Message {
mi := &file_answer_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListAnswerReply.ProtoReflect.Descriptor instead.
func (*ListAnswerReply) Descriptor() ([]byte, []int) {
return file_answer_proto_rawDescGZIP(), []int{2}
}
func (x *ListAnswerReply) GetData() []*AnswerItem {
if x != nil {
return x.Data
}
return nil
}
func (x *ListAnswerReply) GetCount() int64 {
if x != nil {
return x.Count
}
return 0
}
var File_answer_proto protoreflect.FileDescriptor
const file_answer_proto_rawDesc = "" +
"\n" +
"\fanswer.proto\x12\x06survey\x1a\fblocks.proto\"\xb7\x01\n" +
"\x13SubmitAnswerRequest\x12\x1b\n" +
"\tsurvey_id\x18\x01 \x01(\tR\bsurveyId\x12\x19\n" +
"\bowner_id\x18\x02 \x01(\tR\aownerId\x12*\n" +
"\x06answer\x18\x03 \x03(\v2\x12.survey.AnswerItemR\x06answer\x12\x1d\n" +
"\n" +
"ip_address\x18\x04 \x01(\tR\tipAddress\x12\x1d\n" +
"\n" +
"user_agent\x18\x05 \x01(\tR\tuserAgent\"E\n" +
"\n" +
"AnswerItem\x12\x1f\n" +
"\vquestion_id\x18\x01 \x01(\tR\n" +
"questionId\x12\x16\n" +
"\x06answer\x18\x02 \x03(\tR\x06answer\"O\n" +
"\x0fListAnswerReply\x12&\n" +
"\x04data\x18\x01 \x03(\v2\x12.survey.AnswerItemR\x04data\x12\x14\n" +
"\x05count\x18\x02 \x01(\x03R\x05count2\x7f\n" +
"\x06Answer\x12:\n" +
"\x06Submit\x12\x1b.survey.SubmitAnswerRequest\x1a\x13.survey.StatusReply\x129\n" +
"\bBySurvey\x12\x14.survey.IdentRequest\x1a\x17.survey.ListAnswerReplyB\n" +
"Z\b.;surveyb\x06proto3"
var (
file_answer_proto_rawDescOnce sync.Once
file_answer_proto_rawDescData []byte
)
func file_answer_proto_rawDescGZIP() []byte {
file_answer_proto_rawDescOnce.Do(func() {
file_answer_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_answer_proto_rawDesc), len(file_answer_proto_rawDesc)))
})
return file_answer_proto_rawDescData
}
var file_answer_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_answer_proto_goTypes = []any{
(*SubmitAnswerRequest)(nil), // 0: survey.SubmitAnswerRequest
(*AnswerItem)(nil), // 1: survey.AnswerItem
(*ListAnswerReply)(nil), // 2: survey.ListAnswerReply
(*IdentRequest)(nil), // 3: survey.IdentRequest
(*StatusReply)(nil), // 4: survey.StatusReply
}
var file_answer_proto_depIdxs = []int32{
1, // 0: survey.SubmitAnswerRequest.answer:type_name -> survey.AnswerItem
1, // 1: survey.ListAnswerReply.data:type_name -> survey.AnswerItem
0, // 2: survey.Answer.Submit:input_type -> survey.SubmitAnswerRequest
3, // 3: survey.Answer.BySurvey:input_type -> survey.IdentRequest
4, // 4: survey.Answer.Submit:output_type -> survey.StatusReply
2, // 5: survey.Answer.BySurvey:output_type -> survey.ListAnswerReply
4, // [4:6] is the sub-list for method output_type
2, // [2:4] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_answer_proto_init() }
func file_answer_proto_init() {
if File_answer_proto != nil {
return
}
file_blocks_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_answer_proto_rawDesc), len(file_answer_proto_rawDesc)),
NumEnums: 0,
NumMessages: 3,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_answer_proto_goTypes,
DependencyIndexes: file_answer_proto_depIdxs,
MessageInfos: file_answer_proto_msgTypes,
}.Build()
File_answer_proto = out.File
file_answer_proto_goTypes = nil
file_answer_proto_depIdxs = nil
}

163
pb/answer_grpc.pb.go Normal file
View File

@ -0,0 +1,163 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v6.30.1
// source: answer.proto
package survey
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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
Answer_Submit_FullMethodName = "/survey.Answer/Submit"
Answer_BySurvey_FullMethodName = "/survey.Answer/BySurvey"
)
// AnswerClient is the client API for Answer 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 AnswerClient interface {
Submit(ctx context.Context, in *SubmitAnswerRequest, opts ...grpc.CallOption) (*StatusReply, error)
BySurvey(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*ListAnswerReply, error)
}
type answerClient struct {
cc grpc.ClientConnInterface
}
func NewAnswerClient(cc grpc.ClientConnInterface) AnswerClient {
return &answerClient{cc}
}
func (c *answerClient) Submit(ctx context.Context, in *SubmitAnswerRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Answer_Submit_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *answerClient) BySurvey(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*ListAnswerReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListAnswerReply)
err := c.cc.Invoke(ctx, Answer_BySurvey_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// AnswerServer is the server API for Answer service.
// All implementations must embed UnimplementedAnswerServer
// for forward compatibility.
//
// 问卷服务 - 答卷管理
type AnswerServer interface {
Submit(context.Context, *SubmitAnswerRequest) (*StatusReply, error)
BySurvey(context.Context, *IdentRequest) (*ListAnswerReply, error)
mustEmbedUnimplementedAnswerServer()
}
// UnimplementedAnswerServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedAnswerServer struct{}
func (UnimplementedAnswerServer) Submit(context.Context, *SubmitAnswerRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Submit not implemented")
}
func (UnimplementedAnswerServer) BySurvey(context.Context, *IdentRequest) (*ListAnswerReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method BySurvey not implemented")
}
func (UnimplementedAnswerServer) mustEmbedUnimplementedAnswerServer() {}
func (UnimplementedAnswerServer) testEmbeddedByValue() {}
// UnsafeAnswerServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to AnswerServer will
// result in compilation errors.
type UnsafeAnswerServer interface {
mustEmbedUnimplementedAnswerServer()
}
func RegisterAnswerServer(s grpc.ServiceRegistrar, srv AnswerServer) {
// If the following call pancis, it indicates UnimplementedAnswerServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&Answer_ServiceDesc, srv)
}
func _Answer_Submit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SubmitAnswerRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AnswerServer).Submit(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Answer_Submit_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AnswerServer).Submit(ctx, req.(*SubmitAnswerRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Answer_BySurvey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(IdentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AnswerServer).BySurvey(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Answer_BySurvey_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AnswerServer).BySurvey(ctx, req.(*IdentRequest))
}
return interceptor(ctx, in, info, handler)
}
// Answer_ServiceDesc is the grpc.ServiceDesc for Answer service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Answer_ServiceDesc = grpc.ServiceDesc{
ServiceName: "survey.Answer",
HandlerType: (*AnswerServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Submit",
Handler: _Answer_Submit_Handler,
},
{
MethodName: "BySurvey",
Handler: _Answer_BySurvey_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "answer.proto",
}

View File

@ -4,7 +4,7 @@
// protoc v6.30.1
// source: blocks.proto
package content
package survey
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
@ -21,6 +21,101 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// 问题类型
type QuestionType int32
const (
QuestionType_SINGLE_CHOICE QuestionType = 0 // 单选题
QuestionType_MULTIPLE_CHOICE QuestionType = 1 // 多选题
QuestionType_TEXT QuestionType = 2 // 文本题
QuestionType_SCALE QuestionType = 3 // 量表题
QuestionType_RANKING QuestionType = 4 // 排序题
QuestionType_DATE QuestionType = 5 // 日期题
)
// Enum value maps for QuestionType.
var (
QuestionType_name = map[int32]string{
0: "SINGLE_CHOICE",
1: "MULTIPLE_CHOICE",
2: "TEXT",
3: "SCALE",
4: "RANKING",
5: "DATE",
}
QuestionType_value = map[string]int32{
"SINGLE_CHOICE": 0,
"MULTIPLE_CHOICE": 1,
"TEXT": 2,
"SCALE": 3,
"RANKING": 4,
"DATE": 5,
}
)
func (x QuestionType) Enum() *QuestionType {
p := new(QuestionType)
*p = x
return p
}
func (x QuestionType) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (QuestionType) Descriptor() protoreflect.EnumDescriptor {
return file_blocks_proto_enumTypes[0].Descriptor()
}
func (QuestionType) Type() protoreflect.EnumType {
return &file_blocks_proto_enumTypes[0]
}
func (x QuestionType) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use QuestionType.Descriptor instead.
func (QuestionType) EnumDescriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{0}
}
type Empty struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Empty) Reset() {
*x = Empty{}
mi := &file_blocks_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Empty) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Empty) ProtoMessage() {}
func (x *Empty) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Empty.ProtoReflect.Descriptor instead.
func (*Empty) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{0}
}
type FetchRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
PageNo int64 `protobuf:"varint,1,opt,name=page_no,json=pageNo,proto3" json:"page_no,omitempty"` // 页数
@ -32,7 +127,7 @@ type FetchRequest struct {
func (x *FetchRequest) Reset() {
*x = FetchRequest{}
mi := &file_blocks_proto_msgTypes[0]
mi := &file_blocks_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -44,7 +139,7 @@ func (x *FetchRequest) String() string {
func (*FetchRequest) ProtoMessage() {}
func (x *FetchRequest) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[0]
mi := &file_blocks_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -57,7 +152,7 @@ func (x *FetchRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use FetchRequest.ProtoReflect.Descriptor instead.
func (*FetchRequest) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{0}
return file_blocks_proto_rawDescGZIP(), []int{1}
}
func (x *FetchRequest) GetPageNo() int64 {
@ -91,7 +186,7 @@ type IdentRequest struct {
func (x *IdentRequest) Reset() {
*x = IdentRequest{}
mi := &file_blocks_proto_msgTypes[1]
mi := &file_blocks_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -103,7 +198,7 @@ func (x *IdentRequest) String() string {
func (*IdentRequest) ProtoMessage() {}
func (x *IdentRequest) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[1]
mi := &file_blocks_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -116,7 +211,7 @@ func (x *IdentRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use IdentRequest.ProtoReflect.Descriptor instead.
func (*IdentRequest) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{1}
return file_blocks_proto_rawDescGZIP(), []int{2}
}
func (x *IdentRequest) GetId() int64 {
@ -142,7 +237,7 @@ type VersionRequest struct {
func (x *VersionRequest) Reset() {
*x = VersionRequest{}
mi := &file_blocks_proto_msgTypes[2]
mi := &file_blocks_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -154,7 +249,7 @@ func (x *VersionRequest) String() string {
func (*VersionRequest) ProtoMessage() {}
func (x *VersionRequest) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[2]
mi := &file_blocks_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -167,7 +262,7 @@ func (x *VersionRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use VersionRequest.ProtoReflect.Descriptor instead.
func (*VersionRequest) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{2}
return file_blocks_proto_rawDescGZIP(), []int{3}
}
func (x *VersionRequest) GetVersion() int64 {
@ -186,7 +281,7 @@ type SearchRequest struct {
func (x *SearchRequest) Reset() {
*x = SearchRequest{}
mi := &file_blocks_proto_msgTypes[3]
mi := &file_blocks_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -198,7 +293,7 @@ func (x *SearchRequest) String() string {
func (*SearchRequest) ProtoMessage() {}
func (x *SearchRequest) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[3]
mi := &file_blocks_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -211,7 +306,7 @@ func (x *SearchRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use SearchRequest.ProtoReflect.Descriptor instead.
func (*SearchRequest) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{3}
return file_blocks_proto_rawDescGZIP(), []int{4}
}
func (x *SearchRequest) GetKeyword() string {
@ -233,7 +328,7 @@ type StatusReply struct {
func (x *StatusReply) Reset() {
*x = StatusReply{}
mi := &file_blocks_proto_msgTypes[4]
mi := &file_blocks_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -245,7 +340,7 @@ func (x *StatusReply) String() string {
func (*StatusReply) ProtoMessage() {}
func (x *StatusReply) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[4]
mi := &file_blocks_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -258,7 +353,7 @@ func (x *StatusReply) ProtoReflect() protoreflect.Message {
// Deprecated: Use StatusReply.ProtoReflect.Descriptor instead.
func (*StatusReply) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{4}
return file_blocks_proto_rawDescGZIP(), []int{5}
}
func (x *StatusReply) GetStatus() int64 {
@ -289,27 +384,39 @@ func (x *StatusReply) GetTimeseq() int64 {
return 0
}
type Empty struct {
// 问卷基本信息
type SurveyItem struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // 问卷ID
Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` // 问卷标题
Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` // 问卷描述
CreatorId string `protobuf:"bytes,4,opt,name=creator_id,json=creatorId,proto3" json:"creator_id,omitempty"` // 创建者ID
StartTime string `protobuf:"bytes,5,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` // 开始时间
EndTime string `protobuf:"bytes,6,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"` // 结束时间
IsActive bool `protobuf:"varint,7,opt,name=is_active,json=isActive,proto3" json:"is_active,omitempty"` // 是否激活
IsAnonymous bool `protobuf:"varint,8,opt,name=is_anonymous,json=isAnonymous,proto3" json:"is_anonymous,omitempty"` // 是否匿名
Questions []*QuestionItem `protobuf:"bytes,9,rep,name=questions,proto3" json:"questions,omitempty"` // 问题列表
Tags []string `protobuf:"bytes,10,rep,name=tags,proto3" json:"tags,omitempty"` // 标签
StyleConfig string `protobuf:"bytes,11,opt,name=style_config,json=styleConfig,proto3" json:"style_config,omitempty"` // 样式配置(JSON)
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Empty) Reset() {
*x = Empty{}
mi := &file_blocks_proto_msgTypes[5]
func (x *SurveyItem) Reset() {
*x = SurveyItem{}
mi := &file_blocks_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Empty) String() string {
func (x *SurveyItem) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Empty) ProtoMessage() {}
func (*SurveyItem) ProtoMessage() {}
func (x *Empty) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[5]
func (x *SurveyItem) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -320,20 +427,300 @@ func (x *Empty) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use Empty.ProtoReflect.Descriptor instead.
func (*Empty) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{5}
// Deprecated: Use SurveyItem.ProtoReflect.Descriptor instead.
func (*SurveyItem) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{6}
}
func (x *SurveyItem) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *SurveyItem) GetTitle() string {
if x != nil {
return x.Title
}
return ""
}
func (x *SurveyItem) GetDescription() string {
if x != nil {
return x.Description
}
return ""
}
func (x *SurveyItem) GetCreatorId() string {
if x != nil {
return x.CreatorId
}
return ""
}
func (x *SurveyItem) GetStartTime() string {
if x != nil {
return x.StartTime
}
return ""
}
func (x *SurveyItem) GetEndTime() string {
if x != nil {
return x.EndTime
}
return ""
}
func (x *SurveyItem) GetIsActive() bool {
if x != nil {
return x.IsActive
}
return false
}
func (x *SurveyItem) GetIsAnonymous() bool {
if x != nil {
return x.IsAnonymous
}
return false
}
func (x *SurveyItem) GetQuestions() []*QuestionItem {
if x != nil {
return x.Questions
}
return nil
}
func (x *SurveyItem) GetTags() []string {
if x != nil {
return x.Tags
}
return nil
}
func (x *SurveyItem) GetStyleConfig() string {
if x != nil {
return x.StyleConfig
}
return ""
}
// 问题定义
type QuestionItem struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // 问题ID
SurveyId string `protobuf:"bytes,2,opt,name=survey_id,json=surveyId,proto3" json:"survey_id,omitempty"` // 所属问卷ID
Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"` // 问题标题
Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` // 问题描述
Type QuestionType `protobuf:"varint,5,opt,name=type,proto3,enum=survey.QuestionType" json:"type,omitempty"` // 问题类型
IsRequired bool `protobuf:"varint,6,opt,name=is_required,json=isRequired,proto3" json:"is_required,omitempty"` // 是否必答
Options []*Option `protobuf:"bytes,7,rep,name=options,proto3" json:"options,omitempty"` // 选项(适用于选择题)
MinSelections int32 `protobuf:"varint,8,opt,name=min_selections,json=minSelections,proto3" json:"min_selections,omitempty"` // 最少选择数(多选题)
MaxSelections int32 `protobuf:"varint,9,opt,name=max_selections,json=maxSelections,proto3" json:"max_selections,omitempty"` // 最多选择数(多选题)
Order int32 `protobuf:"varint,10,opt,name=order,proto3" json:"order,omitempty"` // 问题顺序
Placeholder string `protobuf:"bytes,11,opt,name=placeholder,proto3" json:"placeholder,omitempty"` // 输入提示(文本题)
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *QuestionItem) Reset() {
*x = QuestionItem{}
mi := &file_blocks_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *QuestionItem) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*QuestionItem) ProtoMessage() {}
func (x *QuestionItem) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use QuestionItem.ProtoReflect.Descriptor instead.
func (*QuestionItem) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{7}
}
func (x *QuestionItem) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *QuestionItem) GetSurveyId() string {
if x != nil {
return x.SurveyId
}
return ""
}
func (x *QuestionItem) GetTitle() string {
if x != nil {
return x.Title
}
return ""
}
func (x *QuestionItem) GetDescription() string {
if x != nil {
return x.Description
}
return ""
}
func (x *QuestionItem) GetType() QuestionType {
if x != nil {
return x.Type
}
return QuestionType_SINGLE_CHOICE
}
func (x *QuestionItem) GetIsRequired() bool {
if x != nil {
return x.IsRequired
}
return false
}
func (x *QuestionItem) GetOptions() []*Option {
if x != nil {
return x.Options
}
return nil
}
func (x *QuestionItem) GetMinSelections() int32 {
if x != nil {
return x.MinSelections
}
return 0
}
func (x *QuestionItem) GetMaxSelections() int32 {
if x != nil {
return x.MaxSelections
}
return 0
}
func (x *QuestionItem) GetOrder() int32 {
if x != nil {
return x.Order
}
return 0
}
func (x *QuestionItem) GetPlaceholder() string {
if x != nil {
return x.Placeholder
}
return ""
}
// 问题选项
type Option struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // 选项ID
Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` // 选项文本
Order int32 `protobuf:"varint,3,opt,name=order,proto3" json:"order,omitempty"` // 选项顺序
ImageUrl string `protobuf:"bytes,4,opt,name=image_url,json=imageUrl,proto3" json:"image_url,omitempty"` // 选项图片
Score int32 `protobuf:"varint,5,opt,name=score,proto3" json:"score,omitempty"` // 选项分数(适用于量表)
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Option) Reset() {
*x = Option{}
mi := &file_blocks_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Option) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Option) ProtoMessage() {}
func (x *Option) ProtoReflect() protoreflect.Message {
mi := &file_blocks_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Option.ProtoReflect.Descriptor instead.
func (*Option) Descriptor() ([]byte, []int) {
return file_blocks_proto_rawDescGZIP(), []int{8}
}
func (x *Option) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Option) GetText() string {
if x != nil {
return x.Text
}
return ""
}
func (x *Option) GetOrder() int32 {
if x != nil {
return x.Order
}
return 0
}
func (x *Option) GetImageUrl() string {
if x != nil {
return x.ImageUrl
}
return ""
}
func (x *Option) GetScore() int32 {
if x != nil {
return x.Score
}
return 0
}
var File_blocks_proto protoreflect.FileDescriptor
const file_blocks_proto_rawDesc = "" +
"\n" +
"\fblocks.proto\x12\acontent\"\xba\x01\n" +
"\fblocks.proto\x12\x06survey\"\a\n" +
"\x05Empty\"\xb9\x01\n" +
"\fFetchRequest\x12\x17\n" +
"\apage_no\x18\x01 \x01(\x03R\x06pageNo\x12\x1b\n" +
"\tpage_size\x18\x02 \x01(\x03R\bpageSize\x129\n" +
"\x06params\x18\x03 \x03(\v2!.content.FetchRequest.ParamsEntryR\x06params\x1a9\n" +
"\tpage_size\x18\x02 \x01(\x03R\bpageSize\x128\n" +
"\x06params\x18\x03 \x03(\v2 .survey.FetchRequest.ParamsEntryR\x06params\x1a9\n" +
"\vParamsEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\":\n" +
@ -348,9 +735,51 @@ const file_blocks_proto_rawDesc = "" +
"\x06status\x18\x01 \x01(\x03R\x06status\x12\x1a\n" +
"\bidentity\x18\x02 \x01(\tR\bidentity\x12\x18\n" +
"\amessage\x18\x03 \x01(\tR\amessage\x12\x18\n" +
"\atimeseq\x18\x04 \x01(\x03R\atimeseq\"\a\n" +
"\x05EmptyB\fZ\n" +
"./;contentb\x06proto3"
"\atimeseq\x18\x04 \x01(\x03R\atimeseq\"\xd8\x02\n" +
"\n" +
"SurveyItem\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x14\n" +
"\x05title\x18\x02 \x01(\tR\x05title\x12 \n" +
"\vdescription\x18\x03 \x01(\tR\vdescription\x12\x1d\n" +
"\n" +
"creator_id\x18\x04 \x01(\tR\tcreatorId\x12\x1d\n" +
"\n" +
"start_time\x18\x05 \x01(\tR\tstartTime\x12\x19\n" +
"\bend_time\x18\x06 \x01(\tR\aendTime\x12\x1b\n" +
"\tis_active\x18\a \x01(\bR\bisActive\x12!\n" +
"\fis_anonymous\x18\b \x01(\bR\visAnonymous\x122\n" +
"\tquestions\x18\t \x03(\v2\x14.survey.QuestionItemR\tquestions\x12\x12\n" +
"\x04tags\x18\n" +
" \x03(\tR\x04tags\x12!\n" +
"\fstyle_config\x18\v \x01(\tR\vstyleConfig\"\xee\x02\n" +
"\fQuestionItem\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x1b\n" +
"\tsurvey_id\x18\x02 \x01(\tR\bsurveyId\x12\x14\n" +
"\x05title\x18\x03 \x01(\tR\x05title\x12 \n" +
"\vdescription\x18\x04 \x01(\tR\vdescription\x12(\n" +
"\x04type\x18\x05 \x01(\x0e2\x14.survey.QuestionTypeR\x04type\x12\x1f\n" +
"\vis_required\x18\x06 \x01(\bR\n" +
"isRequired\x12(\n" +
"\aoptions\x18\a \x03(\v2\x0e.survey.OptionR\aoptions\x12%\n" +
"\x0emin_selections\x18\b \x01(\x05R\rminSelections\x12%\n" +
"\x0emax_selections\x18\t \x01(\x05R\rmaxSelections\x12\x14\n" +
"\x05order\x18\n" +
" \x01(\x05R\x05order\x12 \n" +
"\vplaceholder\x18\v \x01(\tR\vplaceholder\"u\n" +
"\x06Option\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" +
"\x04text\x18\x02 \x01(\tR\x04text\x12\x14\n" +
"\x05order\x18\x03 \x01(\x05R\x05order\x12\x1b\n" +
"\timage_url\x18\x04 \x01(\tR\bimageUrl\x12\x14\n" +
"\x05score\x18\x05 \x01(\x05R\x05score*b\n" +
"\fQuestionType\x12\x11\n" +
"\rSINGLE_CHOICE\x10\x00\x12\x13\n" +
"\x0fMULTIPLE_CHOICE\x10\x01\x12\b\n" +
"\x04TEXT\x10\x02\x12\t\n" +
"\x05SCALE\x10\x03\x12\v\n" +
"\aRANKING\x10\x04\x12\b\n" +
"\x04DATE\x10\x05B\n" +
"Z\b.;surveyb\x06proto3"
var (
file_blocks_proto_rawDescOnce sync.Once
@ -364,23 +793,31 @@ func file_blocks_proto_rawDescGZIP() []byte {
return file_blocks_proto_rawDescData
}
var file_blocks_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_blocks_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_blocks_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_blocks_proto_goTypes = []any{
(*FetchRequest)(nil), // 0: content.FetchRequest
(*IdentRequest)(nil), // 1: content.IdentRequest
(*VersionRequest)(nil), // 2: content.VersionRequest
(*SearchRequest)(nil), // 3: content.SearchRequest
(*StatusReply)(nil), // 4: content.StatusReply
(*Empty)(nil), // 5: content.Empty
nil, // 6: content.FetchRequest.ParamsEntry
(QuestionType)(0), // 0: survey.QuestionType
(*Empty)(nil), // 1: survey.Empty
(*FetchRequest)(nil), // 2: survey.FetchRequest
(*IdentRequest)(nil), // 3: survey.IdentRequest
(*VersionRequest)(nil), // 4: survey.VersionRequest
(*SearchRequest)(nil), // 5: survey.SearchRequest
(*StatusReply)(nil), // 6: survey.StatusReply
(*SurveyItem)(nil), // 7: survey.SurveyItem
(*QuestionItem)(nil), // 8: survey.QuestionItem
(*Option)(nil), // 9: survey.Option
nil, // 10: survey.FetchRequest.ParamsEntry
}
var file_blocks_proto_depIdxs = []int32{
6, // 0: content.FetchRequest.params:type_name -> content.FetchRequest.ParamsEntry
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
10, // 0: survey.FetchRequest.params:type_name -> survey.FetchRequest.ParamsEntry
8, // 1: survey.SurveyItem.questions:type_name -> survey.QuestionItem
0, // 2: survey.QuestionItem.type:type_name -> survey.QuestionType
9, // 3: survey.QuestionItem.options:type_name -> survey.Option
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_blocks_proto_init() }
@ -393,13 +830,14 @@ func file_blocks_proto_init() {
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_blocks_proto_rawDesc), len(file_blocks_proto_rawDesc)),
NumEnums: 0,
NumMessages: 7,
NumEnums: 1,
NumMessages: 10,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_blocks_proto_goTypes,
DependencyIndexes: file_blocks_proto_depIdxs,
EnumInfos: file_blocks_proto_enumTypes,
MessageInfos: file_blocks_proto_msgTypes,
}.Build()
File_blocks_proto = out.File

View File

@ -1,585 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.6
// protoc v6.30.1
// source: category.proto
package content
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// 无限极分类
type CategoryItem struct {
state protoimpl.MessageState `protogen:"open.v1"`
Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"`
ParentIdentity string `protobuf:"bytes,2,opt,name=parent_identity,json=parentIdentity,proto3" json:"parent_identity,omitempty"` // 为空表示顶级分类
Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`
CoverPath string `protobuf:"bytes,4,opt,name=cover_path,json=coverPath,proto3" json:"cover_path,omitempty"`
Intro string `protobuf:"bytes,5,opt,name=intro,proto3" json:"intro,omitempty"`
CreatedAt string `protobuf:"bytes,6,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
UpdatedAt string `protobuf:"bytes,7,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
Data []*CategoryItem `protobuf:"bytes,8,rep,name=data,proto3" json:"data,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CategoryItem) Reset() {
*x = CategoryItem{}
mi := &file_category_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CategoryItem) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CategoryItem) ProtoMessage() {}
func (x *CategoryItem) ProtoReflect() protoreflect.Message {
mi := &file_category_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CategoryItem.ProtoReflect.Descriptor instead.
func (*CategoryItem) Descriptor() ([]byte, []int) {
return file_category_proto_rawDescGZIP(), []int{0}
}
func (x *CategoryItem) GetIdentity() string {
if x != nil {
return x.Identity
}
return ""
}
func (x *CategoryItem) GetParentIdentity() string {
if x != nil {
return x.ParentIdentity
}
return ""
}
func (x *CategoryItem) GetTitle() string {
if x != nil {
return x.Title
}
return ""
}
func (x *CategoryItem) GetCoverPath() string {
if x != nil {
return x.CoverPath
}
return ""
}
func (x *CategoryItem) GetIntro() string {
if x != nil {
return x.Intro
}
return ""
}
func (x *CategoryItem) GetCreatedAt() string {
if x != nil {
return x.CreatedAt
}
return ""
}
func (x *CategoryItem) GetUpdatedAt() string {
if x != nil {
return x.UpdatedAt
}
return ""
}
func (x *CategoryItem) GetData() []*CategoryItem {
if x != nil {
return x.Data
}
return nil
}
type CategoryListReply struct {
state protoimpl.MessageState `protogen:"open.v1"`
Data []*CategoryItem `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
Count int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CategoryListReply) Reset() {
*x = CategoryListReply{}
mi := &file_category_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CategoryListReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CategoryListReply) ProtoMessage() {}
func (x *CategoryListReply) ProtoReflect() protoreflect.Message {
mi := &file_category_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CategoryListReply.ProtoReflect.Descriptor instead.
func (*CategoryListReply) Descriptor() ([]byte, []int) {
return file_category_proto_rawDescGZIP(), []int{1}
}
func (x *CategoryListReply) GetData() []*CategoryItem {
if x != nil {
return x.Data
}
return nil
}
func (x *CategoryListReply) GetCount() int64 {
if x != nil {
return x.Count
}
return 0
}
type AddCategoryResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` // 新增数据的唯一码
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AddCategoryResponse) Reset() {
*x = AddCategoryResponse{}
mi := &file_category_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AddCategoryResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddCategoryResponse) ProtoMessage() {}
func (x *AddCategoryResponse) ProtoReflect() protoreflect.Message {
mi := &file_category_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AddCategoryResponse.ProtoReflect.Descriptor instead.
func (*AddCategoryResponse) Descriptor() ([]byte, []int) {
return file_category_proto_rawDescGZIP(), []int{2}
}
func (x *AddCategoryResponse) GetIdentity() string {
if x != nil {
return x.Identity
}
return ""
}
type AddCategoryRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` //
ParentIdentity string `protobuf:"bytes,2,opt,name=parent_identity,json=parentIdentity,proto3" json:"parent_identity,omitempty"` // 为空表示顶级分类
Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`
CoverPath string `protobuf:"bytes,4,opt,name=cover_path,json=coverPath,proto3" json:"cover_path,omitempty"`
Intro string `protobuf:"bytes,5,opt,name=intro,proto3" json:"intro,omitempty"`
CreatedAt string `protobuf:"bytes,6,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
UpdatedAt string `protobuf:"bytes,7,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
Data []*CategoryItem `protobuf:"bytes,8,rep,name=data,proto3" json:"data,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AddCategoryRequest) Reset() {
*x = AddCategoryRequest{}
mi := &file_category_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AddCategoryRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddCategoryRequest) ProtoMessage() {}
func (x *AddCategoryRequest) ProtoReflect() protoreflect.Message {
mi := &file_category_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AddCategoryRequest.ProtoReflect.Descriptor instead.
func (*AddCategoryRequest) Descriptor() ([]byte, []int) {
return file_category_proto_rawDescGZIP(), []int{3}
}
func (x *AddCategoryRequest) GetIdentity() string {
if x != nil {
return x.Identity
}
return ""
}
func (x *AddCategoryRequest) GetParentIdentity() string {
if x != nil {
return x.ParentIdentity
}
return ""
}
func (x *AddCategoryRequest) GetTitle() string {
if x != nil {
return x.Title
}
return ""
}
func (x *AddCategoryRequest) GetCoverPath() string {
if x != nil {
return x.CoverPath
}
return ""
}
func (x *AddCategoryRequest) GetIntro() string {
if x != nil {
return x.Intro
}
return ""
}
func (x *AddCategoryRequest) GetCreatedAt() string {
if x != nil {
return x.CreatedAt
}
return ""
}
func (x *AddCategoryRequest) GetUpdatedAt() string {
if x != nil {
return x.UpdatedAt
}
return ""
}
func (x *AddCategoryRequest) GetData() []*CategoryItem {
if x != nil {
return x.Data
}
return nil
}
type ModifyCategoryRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` //
ParentIdentity string `protobuf:"bytes,2,opt,name=parent_identity,json=parentIdentity,proto3" json:"parent_identity,omitempty"` // 为空表示顶级分类
Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`
CoverPath string `protobuf:"bytes,4,opt,name=cover_path,json=coverPath,proto3" json:"cover_path,omitempty"`
Intro string `protobuf:"bytes,5,opt,name=intro,proto3" json:"intro,omitempty"`
CreatedAt string `protobuf:"bytes,6,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
UpdatedAt string `protobuf:"bytes,7,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
Data []*CategoryItem `protobuf:"bytes,8,rep,name=data,proto3" json:"data,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ModifyCategoryRequest) Reset() {
*x = ModifyCategoryRequest{}
mi := &file_category_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ModifyCategoryRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ModifyCategoryRequest) ProtoMessage() {}
func (x *ModifyCategoryRequest) ProtoReflect() protoreflect.Message {
mi := &file_category_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ModifyCategoryRequest.ProtoReflect.Descriptor instead.
func (*ModifyCategoryRequest) Descriptor() ([]byte, []int) {
return file_category_proto_rawDescGZIP(), []int{4}
}
func (x *ModifyCategoryRequest) GetIdentity() string {
if x != nil {
return x.Identity
}
return ""
}
func (x *ModifyCategoryRequest) GetParentIdentity() string {
if x != nil {
return x.ParentIdentity
}
return ""
}
func (x *ModifyCategoryRequest) GetTitle() string {
if x != nil {
return x.Title
}
return ""
}
func (x *ModifyCategoryRequest) GetCoverPath() string {
if x != nil {
return x.CoverPath
}
return ""
}
func (x *ModifyCategoryRequest) GetIntro() string {
if x != nil {
return x.Intro
}
return ""
}
func (x *ModifyCategoryRequest) GetCreatedAt() string {
if x != nil {
return x.CreatedAt
}
return ""
}
func (x *ModifyCategoryRequest) GetUpdatedAt() string {
if x != nil {
return x.UpdatedAt
}
return ""
}
func (x *ModifyCategoryRequest) GetData() []*CategoryItem {
if x != nil {
return x.Data
}
return nil
}
type DeleteCategoryRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` //
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *DeleteCategoryRequest) Reset() {
*x = DeleteCategoryRequest{}
mi := &file_category_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *DeleteCategoryRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteCategoryRequest) ProtoMessage() {}
func (x *DeleteCategoryRequest) ProtoReflect() protoreflect.Message {
mi := &file_category_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DeleteCategoryRequest.ProtoReflect.Descriptor instead.
func (*DeleteCategoryRequest) Descriptor() ([]byte, []int) {
return file_category_proto_rawDescGZIP(), []int{5}
}
func (x *DeleteCategoryRequest) GetIdentity() string {
if x != nil {
return x.Identity
}
return ""
}
var File_category_proto protoreflect.FileDescriptor
const file_category_proto_rawDesc = "" +
"\n" +
"\x0ecategory.proto\x12\acontent\x1a\fblocks.proto\"\x87\x02\n" +
"\fCategoryItem\x12\x1a\n" +
"\bidentity\x18\x01 \x01(\tR\bidentity\x12'\n" +
"\x0fparent_identity\x18\x02 \x01(\tR\x0eparentIdentity\x12\x14\n" +
"\x05title\x18\x03 \x01(\tR\x05title\x12\x1d\n" +
"\n" +
"cover_path\x18\x04 \x01(\tR\tcoverPath\x12\x14\n" +
"\x05intro\x18\x05 \x01(\tR\x05intro\x12\x1d\n" +
"\n" +
"created_at\x18\x06 \x01(\tR\tcreatedAt\x12\x1d\n" +
"\n" +
"updated_at\x18\a \x01(\tR\tupdatedAt\x12)\n" +
"\x04data\x18\b \x03(\v2\x15.content.CategoryItemR\x04data\"T\n" +
"\x11CategoryListReply\x12)\n" +
"\x04data\x18\x01 \x03(\v2\x15.content.CategoryItemR\x04data\x12\x14\n" +
"\x05count\x18\x02 \x01(\x03R\x05count\"1\n" +
"\x13AddCategoryResponse\x12\x1a\n" +
"\bidentity\x18\x01 \x01(\tR\bidentity\"\x8d\x02\n" +
"\x12AddCategoryRequest\x12\x1a\n" +
"\bidentity\x18\x01 \x01(\tR\bidentity\x12'\n" +
"\x0fparent_identity\x18\x02 \x01(\tR\x0eparentIdentity\x12\x14\n" +
"\x05title\x18\x03 \x01(\tR\x05title\x12\x1d\n" +
"\n" +
"cover_path\x18\x04 \x01(\tR\tcoverPath\x12\x14\n" +
"\x05intro\x18\x05 \x01(\tR\x05intro\x12\x1d\n" +
"\n" +
"created_at\x18\x06 \x01(\tR\tcreatedAt\x12\x1d\n" +
"\n" +
"updated_at\x18\a \x01(\tR\tupdatedAt\x12)\n" +
"\x04data\x18\b \x03(\v2\x15.content.CategoryItemR\x04data\"\x90\x02\n" +
"\x15ModifyCategoryRequest\x12\x1a\n" +
"\bidentity\x18\x01 \x01(\tR\bidentity\x12'\n" +
"\x0fparent_identity\x18\x02 \x01(\tR\x0eparentIdentity\x12\x14\n" +
"\x05title\x18\x03 \x01(\tR\x05title\x12\x1d\n" +
"\n" +
"cover_path\x18\x04 \x01(\tR\tcoverPath\x12\x14\n" +
"\x05intro\x18\x05 \x01(\tR\x05intro\x12\x1d\n" +
"\n" +
"created_at\x18\x06 \x01(\tR\tcreatedAt\x12\x1d\n" +
"\n" +
"updated_at\x18\a \x01(\tR\tupdatedAt\x12)\n" +
"\x04data\x18\b \x03(\v2\x15.content.CategoryItemR\x04data\"3\n" +
"\x15DeleteCategoryRequest\x12\x1a\n" +
"\bidentity\x18\x01 \x01(\tR\bidentity2\x9c\x02\n" +
"\bCategory\x12<\n" +
"\fCategoryList\x12\x0e.content.Empty\x1a\x1a.content.CategoryListReply\"\x00\x12J\n" +
"\vAddCategory\x12\x1b.content.AddCategoryRequest\x1a\x1c.content.AddCategoryResponse\"\x00\x12B\n" +
"\x0eModifyCategory\x12\x1e.content.ModifyCategoryRequest\x1a\x0e.content.Empty\"\x00\x12B\n" +
"\x0eDeleteCategory\x12\x1e.content.DeleteCategoryRequest\x1a\x0e.content.Empty\"\x00B\fZ\n" +
"./;contentb\x06proto3"
var (
file_category_proto_rawDescOnce sync.Once
file_category_proto_rawDescData []byte
)
func file_category_proto_rawDescGZIP() []byte {
file_category_proto_rawDescOnce.Do(func() {
file_category_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_category_proto_rawDesc), len(file_category_proto_rawDesc)))
})
return file_category_proto_rawDescData
}
var file_category_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_category_proto_goTypes = []any{
(*CategoryItem)(nil), // 0: content.CategoryItem
(*CategoryListReply)(nil), // 1: content.CategoryListReply
(*AddCategoryResponse)(nil), // 2: content.AddCategoryResponse
(*AddCategoryRequest)(nil), // 3: content.AddCategoryRequest
(*ModifyCategoryRequest)(nil), // 4: content.ModifyCategoryRequest
(*DeleteCategoryRequest)(nil), // 5: content.DeleteCategoryRequest
(*Empty)(nil), // 6: content.Empty
}
var file_category_proto_depIdxs = []int32{
0, // 0: content.CategoryItem.data:type_name -> content.CategoryItem
0, // 1: content.CategoryListReply.data:type_name -> content.CategoryItem
0, // 2: content.AddCategoryRequest.data:type_name -> content.CategoryItem
0, // 3: content.ModifyCategoryRequest.data:type_name -> content.CategoryItem
6, // 4: content.Category.CategoryList:input_type -> content.Empty
3, // 5: content.Category.AddCategory:input_type -> content.AddCategoryRequest
4, // 6: content.Category.ModifyCategory:input_type -> content.ModifyCategoryRequest
5, // 7: content.Category.DeleteCategory:input_type -> content.DeleteCategoryRequest
1, // 8: content.Category.CategoryList:output_type -> content.CategoryListReply
2, // 9: content.Category.AddCategory:output_type -> content.AddCategoryResponse
6, // 10: content.Category.ModifyCategory:output_type -> content.Empty
6, // 11: content.Category.DeleteCategory:output_type -> content.Empty
8, // [8:12] is the sub-list for method output_type
4, // [4:8] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_category_proto_init() }
func file_category_proto_init() {
if File_category_proto != nil {
return
}
file_blocks_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_category_proto_rawDesc), len(file_category_proto_rawDesc)),
NumEnums: 0,
NumMessages: 6,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_category_proto_goTypes,
DependencyIndexes: file_category_proto_depIdxs,
MessageInfos: file_category_proto_msgTypes,
}.Build()
File_category_proto = out.File
file_category_proto_goTypes = nil
file_category_proto_depIdxs = nil
}

View File

@ -1,241 +0,0 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v6.30.1
// source: category.proto
package content
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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
Category_CategoryList_FullMethodName = "/content.Category/CategoryList"
Category_AddCategory_FullMethodName = "/content.Category/AddCategory"
Category_ModifyCategory_FullMethodName = "/content.Category/ModifyCategory"
Category_DeleteCategory_FullMethodName = "/content.Category/DeleteCategory"
)
// CategoryClient is the client API for Category 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 CategoryClient interface {
// 分类列表
CategoryList(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*CategoryListReply, error)
AddCategory(ctx context.Context, in *AddCategoryRequest, opts ...grpc.CallOption) (*AddCategoryResponse, error)
ModifyCategory(ctx context.Context, in *ModifyCategoryRequest, opts ...grpc.CallOption) (*Empty, error)
DeleteCategory(ctx context.Context, in *DeleteCategoryRequest, opts ...grpc.CallOption) (*Empty, error)
}
type categoryClient struct {
cc grpc.ClientConnInterface
}
func NewCategoryClient(cc grpc.ClientConnInterface) CategoryClient {
return &categoryClient{cc}
}
func (c *categoryClient) CategoryList(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*CategoryListReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CategoryListReply)
err := c.cc.Invoke(ctx, Category_CategoryList_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *categoryClient) AddCategory(ctx context.Context, in *AddCategoryRequest, opts ...grpc.CallOption) (*AddCategoryResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(AddCategoryResponse)
err := c.cc.Invoke(ctx, Category_AddCategory_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *categoryClient) ModifyCategory(ctx context.Context, in *ModifyCategoryRequest, opts ...grpc.CallOption) (*Empty, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(Empty)
err := c.cc.Invoke(ctx, Category_ModifyCategory_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *categoryClient) DeleteCategory(ctx context.Context, in *DeleteCategoryRequest, opts ...grpc.CallOption) (*Empty, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(Empty)
err := c.cc.Invoke(ctx, Category_DeleteCategory_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// CategoryServer is the server API for Category service.
// All implementations must embed UnimplementedCategoryServer
// for forward compatibility.
//
// 系统分类
type CategoryServer interface {
// 分类列表
CategoryList(context.Context, *Empty) (*CategoryListReply, error)
AddCategory(context.Context, *AddCategoryRequest) (*AddCategoryResponse, error)
ModifyCategory(context.Context, *ModifyCategoryRequest) (*Empty, error)
DeleteCategory(context.Context, *DeleteCategoryRequest) (*Empty, error)
mustEmbedUnimplementedCategoryServer()
}
// UnimplementedCategoryServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedCategoryServer struct{}
func (UnimplementedCategoryServer) CategoryList(context.Context, *Empty) (*CategoryListReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method CategoryList not implemented")
}
func (UnimplementedCategoryServer) AddCategory(context.Context, *AddCategoryRequest) (*AddCategoryResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddCategory not implemented")
}
func (UnimplementedCategoryServer) ModifyCategory(context.Context, *ModifyCategoryRequest) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method ModifyCategory not implemented")
}
func (UnimplementedCategoryServer) DeleteCategory(context.Context, *DeleteCategoryRequest) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteCategory not implemented")
}
func (UnimplementedCategoryServer) mustEmbedUnimplementedCategoryServer() {}
func (UnimplementedCategoryServer) testEmbeddedByValue() {}
// UnsafeCategoryServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to CategoryServer will
// result in compilation errors.
type UnsafeCategoryServer interface {
mustEmbedUnimplementedCategoryServer()
}
func RegisterCategoryServer(s grpc.ServiceRegistrar, srv CategoryServer) {
// If the following call pancis, it indicates UnimplementedCategoryServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&Category_ServiceDesc, srv)
}
func _Category_CategoryList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CategoryServer).CategoryList(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Category_CategoryList_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CategoryServer).CategoryList(ctx, req.(*Empty))
}
return interceptor(ctx, in, info, handler)
}
func _Category_AddCategory_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AddCategoryRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CategoryServer).AddCategory(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Category_AddCategory_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CategoryServer).AddCategory(ctx, req.(*AddCategoryRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Category_ModifyCategory_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ModifyCategoryRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CategoryServer).ModifyCategory(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Category_ModifyCategory_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CategoryServer).ModifyCategory(ctx, req.(*ModifyCategoryRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Category_DeleteCategory_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteCategoryRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CategoryServer).DeleteCategory(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Category_DeleteCategory_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CategoryServer).DeleteCategory(ctx, req.(*DeleteCategoryRequest))
}
return interceptor(ctx, in, info, handler)
}
// Category_ServiceDesc is the grpc.ServiceDesc for Category service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Category_ServiceDesc = grpc.ServiceDesc{
ServiceName: "content.Category",
HandlerType: (*CategoryServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "CategoryList",
Handler: _Category_CategoryList_Handler,
},
{
MethodName: "AddCategory",
Handler: _Category_AddCategory_Handler,
},
{
MethodName: "ModifyCategory",
Handler: _Category_ModifyCategory_Handler,
},
{
MethodName: "DeleteCategory",
Handler: _Category_DeleteCategory_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "category.proto",
}

File diff suppressed because it is too large Load Diff

View File

@ -1,759 +0,0 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v6.30.1
// source: post.proto
package content
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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
Post_PostList_FullMethodName = "/content.Post/PostList"
Post_GetPost_FullMethodName = "/content.Post/GetPost"
Post_AddPost_FullMethodName = "/content.Post/AddPost"
Post_ModifyPost_FullMethodName = "/content.Post/ModifyPost"
Post_DeletePost_FullMethodName = "/content.Post/DeletePost"
Post_IncrPostLike_FullMethodName = "/content.Post/IncrPostLike"
Post_DescPostLike_FullMethodName = "/content.Post/DescPostLike"
Post_IncrPostUnlike_FullMethodName = "/content.Post/IncrPostUnlike"
Post_DescPostUnlike_FullMethodName = "/content.Post/DescPostUnlike"
Post_CommentList_FullMethodName = "/content.Post/CommentList"
Post_AddComment_FullMethodName = "/content.Post/AddComment"
Post_ModifyComment_FullMethodName = "/content.Post/ModifyComment"
Post_DeleteComment_FullMethodName = "/content.Post/DeleteComment"
Post_IncrCommentLike_FullMethodName = "/content.Post/IncrCommentLike"
Post_DescCommentLike_FullMethodName = "/content.Post/DescCommentLike"
Post_IncrCommentUnlike_FullMethodName = "/content.Post/IncrCommentUnlike"
Post_DescCommentUnlike_FullMethodName = "/content.Post/DescCommentUnlike"
)
// PostClient is the client API for Post 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 PostClient interface {
// 文章列表
PostList(ctx context.Context, in *PostListRequest, opts ...grpc.CallOption) (*PostListReply, error)
// 获取文章详情
GetPost(ctx context.Context, in *GetPostRequest, opts ...grpc.CallOption) (*PostItem, error)
// 发布文章
AddPost(ctx context.Context, in *PostItem, opts ...grpc.CallOption) (*StatusReply, error)
// 修改文章
ModifyPost(ctx context.Context, in *PostItem, opts ...grpc.CallOption) (*StatusReply, error)
// 删除文章
DeletePost(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*StatusReply, error)
// 文章点赞处理
IncrPostLike(ctx context.Context, in *PostOpIdentityRequest, opts ...grpc.CallOption) (*StatusReply, error)
DescPostLike(ctx context.Context, in *PostOpIdentityRequest, opts ...grpc.CallOption) (*StatusReply, error)
// 文章点踩处理
IncrPostUnlike(ctx context.Context, in *PostOpIdentityRequest, opts ...grpc.CallOption) (*StatusReply, error)
DescPostUnlike(ctx context.Context, in *PostOpIdentityRequest, opts ...grpc.CallOption) (*StatusReply, error)
// 评论列表
CommentList(ctx context.Context, in *CommentListRequest, opts ...grpc.CallOption) (*CommentListResponse, error)
// 发布评论
AddComment(ctx context.Context, in *CommentItem, opts ...grpc.CallOption) (*StatusReply, error)
// 修改评论
ModifyComment(ctx context.Context, in *CommentItem, opts ...grpc.CallOption) (*StatusReply, error)
// 删除评论
DeleteComment(ctx context.Context, in *DeleteCommentRequest, opts ...grpc.CallOption) (*StatusReply, error)
// 评论点赞处理
IncrCommentLike(ctx context.Context, in *CommentOpIdentityRequest, opts ...grpc.CallOption) (*StatusReply, error)
DescCommentLike(ctx context.Context, in *CommentOpIdentityRequest, opts ...grpc.CallOption) (*StatusReply, error)
// 评论点踩处理
IncrCommentUnlike(ctx context.Context, in *CommentOpIdentityRequest, opts ...grpc.CallOption) (*StatusReply, error)
DescCommentUnlike(ctx context.Context, in *CommentOpIdentityRequest, opts ...grpc.CallOption) (*StatusReply, error)
}
type postClient struct {
cc grpc.ClientConnInterface
}
func NewPostClient(cc grpc.ClientConnInterface) PostClient {
return &postClient{cc}
}
func (c *postClient) PostList(ctx context.Context, in *PostListRequest, opts ...grpc.CallOption) (*PostListReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(PostListReply)
err := c.cc.Invoke(ctx, Post_PostList_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) GetPost(ctx context.Context, in *GetPostRequest, opts ...grpc.CallOption) (*PostItem, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(PostItem)
err := c.cc.Invoke(ctx, Post_GetPost_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) AddPost(ctx context.Context, in *PostItem, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_AddPost_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) ModifyPost(ctx context.Context, in *PostItem, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_ModifyPost_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) DeletePost(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_DeletePost_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) IncrPostLike(ctx context.Context, in *PostOpIdentityRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_IncrPostLike_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) DescPostLike(ctx context.Context, in *PostOpIdentityRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_DescPostLike_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) IncrPostUnlike(ctx context.Context, in *PostOpIdentityRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_IncrPostUnlike_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) DescPostUnlike(ctx context.Context, in *PostOpIdentityRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_DescPostUnlike_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) CommentList(ctx context.Context, in *CommentListRequest, opts ...grpc.CallOption) (*CommentListResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CommentListResponse)
err := c.cc.Invoke(ctx, Post_CommentList_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) AddComment(ctx context.Context, in *CommentItem, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_AddComment_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) ModifyComment(ctx context.Context, in *CommentItem, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_ModifyComment_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) DeleteComment(ctx context.Context, in *DeleteCommentRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_DeleteComment_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) IncrCommentLike(ctx context.Context, in *CommentOpIdentityRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_IncrCommentLike_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) DescCommentLike(ctx context.Context, in *CommentOpIdentityRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_DescCommentLike_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) IncrCommentUnlike(ctx context.Context, in *CommentOpIdentityRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_IncrCommentUnlike_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *postClient) DescCommentUnlike(ctx context.Context, in *CommentOpIdentityRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Post_DescCommentUnlike_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// PostServer is the server API for Post service.
// All implementations must embed UnimplementedPostServer
// for forward compatibility.
//
// 正文
type PostServer interface {
// 文章列表
PostList(context.Context, *PostListRequest) (*PostListReply, error)
// 获取文章详情
GetPost(context.Context, *GetPostRequest) (*PostItem, error)
// 发布文章
AddPost(context.Context, *PostItem) (*StatusReply, error)
// 修改文章
ModifyPost(context.Context, *PostItem) (*StatusReply, error)
// 删除文章
DeletePost(context.Context, *IdentRequest) (*StatusReply, error)
// 文章点赞处理
IncrPostLike(context.Context, *PostOpIdentityRequest) (*StatusReply, error)
DescPostLike(context.Context, *PostOpIdentityRequest) (*StatusReply, error)
// 文章点踩处理
IncrPostUnlike(context.Context, *PostOpIdentityRequest) (*StatusReply, error)
DescPostUnlike(context.Context, *PostOpIdentityRequest) (*StatusReply, error)
// 评论列表
CommentList(context.Context, *CommentListRequest) (*CommentListResponse, error)
// 发布评论
AddComment(context.Context, *CommentItem) (*StatusReply, error)
// 修改评论
ModifyComment(context.Context, *CommentItem) (*StatusReply, error)
// 删除评论
DeleteComment(context.Context, *DeleteCommentRequest) (*StatusReply, error)
// 评论点赞处理
IncrCommentLike(context.Context, *CommentOpIdentityRequest) (*StatusReply, error)
DescCommentLike(context.Context, *CommentOpIdentityRequest) (*StatusReply, error)
// 评论点踩处理
IncrCommentUnlike(context.Context, *CommentOpIdentityRequest) (*StatusReply, error)
DescCommentUnlike(context.Context, *CommentOpIdentityRequest) (*StatusReply, error)
mustEmbedUnimplementedPostServer()
}
// UnimplementedPostServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedPostServer struct{}
func (UnimplementedPostServer) PostList(context.Context, *PostListRequest) (*PostListReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method PostList not implemented")
}
func (UnimplementedPostServer) GetPost(context.Context, *GetPostRequest) (*PostItem, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetPost not implemented")
}
func (UnimplementedPostServer) AddPost(context.Context, *PostItem) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddPost not implemented")
}
func (UnimplementedPostServer) ModifyPost(context.Context, *PostItem) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method ModifyPost not implemented")
}
func (UnimplementedPostServer) DeletePost(context.Context, *IdentRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeletePost not implemented")
}
func (UnimplementedPostServer) IncrPostLike(context.Context, *PostOpIdentityRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method IncrPostLike not implemented")
}
func (UnimplementedPostServer) DescPostLike(context.Context, *PostOpIdentityRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method DescPostLike not implemented")
}
func (UnimplementedPostServer) IncrPostUnlike(context.Context, *PostOpIdentityRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method IncrPostUnlike not implemented")
}
func (UnimplementedPostServer) DescPostUnlike(context.Context, *PostOpIdentityRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method DescPostUnlike not implemented")
}
func (UnimplementedPostServer) CommentList(context.Context, *CommentListRequest) (*CommentListResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CommentList not implemented")
}
func (UnimplementedPostServer) AddComment(context.Context, *CommentItem) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddComment not implemented")
}
func (UnimplementedPostServer) ModifyComment(context.Context, *CommentItem) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method ModifyComment not implemented")
}
func (UnimplementedPostServer) DeleteComment(context.Context, *DeleteCommentRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteComment not implemented")
}
func (UnimplementedPostServer) IncrCommentLike(context.Context, *CommentOpIdentityRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method IncrCommentLike not implemented")
}
func (UnimplementedPostServer) DescCommentLike(context.Context, *CommentOpIdentityRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method DescCommentLike not implemented")
}
func (UnimplementedPostServer) IncrCommentUnlike(context.Context, *CommentOpIdentityRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method IncrCommentUnlike not implemented")
}
func (UnimplementedPostServer) DescCommentUnlike(context.Context, *CommentOpIdentityRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method DescCommentUnlike not implemented")
}
func (UnimplementedPostServer) mustEmbedUnimplementedPostServer() {}
func (UnimplementedPostServer) testEmbeddedByValue() {}
// UnsafePostServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to PostServer will
// result in compilation errors.
type UnsafePostServer interface {
mustEmbedUnimplementedPostServer()
}
func RegisterPostServer(s grpc.ServiceRegistrar, srv PostServer) {
// If the following call pancis, it indicates UnimplementedPostServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&Post_ServiceDesc, srv)
}
func _Post_PostList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PostListRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).PostList(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_PostList_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).PostList(ctx, req.(*PostListRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Post_GetPost_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetPostRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).GetPost(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_GetPost_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).GetPost(ctx, req.(*GetPostRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Post_AddPost_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PostItem)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).AddPost(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_AddPost_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).AddPost(ctx, req.(*PostItem))
}
return interceptor(ctx, in, info, handler)
}
func _Post_ModifyPost_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PostItem)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).ModifyPost(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_ModifyPost_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).ModifyPost(ctx, req.(*PostItem))
}
return interceptor(ctx, in, info, handler)
}
func _Post_DeletePost_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(IdentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).DeletePost(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_DeletePost_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).DeletePost(ctx, req.(*IdentRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Post_IncrPostLike_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PostOpIdentityRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).IncrPostLike(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_IncrPostLike_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).IncrPostLike(ctx, req.(*PostOpIdentityRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Post_DescPostLike_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PostOpIdentityRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).DescPostLike(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_DescPostLike_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).DescPostLike(ctx, req.(*PostOpIdentityRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Post_IncrPostUnlike_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PostOpIdentityRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).IncrPostUnlike(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_IncrPostUnlike_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).IncrPostUnlike(ctx, req.(*PostOpIdentityRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Post_DescPostUnlike_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PostOpIdentityRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).DescPostUnlike(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_DescPostUnlike_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).DescPostUnlike(ctx, req.(*PostOpIdentityRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Post_CommentList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CommentListRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).CommentList(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_CommentList_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).CommentList(ctx, req.(*CommentListRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Post_AddComment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CommentItem)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).AddComment(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_AddComment_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).AddComment(ctx, req.(*CommentItem))
}
return interceptor(ctx, in, info, handler)
}
func _Post_ModifyComment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CommentItem)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).ModifyComment(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_ModifyComment_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).ModifyComment(ctx, req.(*CommentItem))
}
return interceptor(ctx, in, info, handler)
}
func _Post_DeleteComment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteCommentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).DeleteComment(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_DeleteComment_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).DeleteComment(ctx, req.(*DeleteCommentRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Post_IncrCommentLike_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CommentOpIdentityRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).IncrCommentLike(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_IncrCommentLike_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).IncrCommentLike(ctx, req.(*CommentOpIdentityRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Post_DescCommentLike_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CommentOpIdentityRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).DescCommentLike(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_DescCommentLike_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).DescCommentLike(ctx, req.(*CommentOpIdentityRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Post_IncrCommentUnlike_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CommentOpIdentityRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).IncrCommentUnlike(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_IncrCommentUnlike_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).IncrCommentUnlike(ctx, req.(*CommentOpIdentityRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Post_DescCommentUnlike_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CommentOpIdentityRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PostServer).DescCommentUnlike(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Post_DescCommentUnlike_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PostServer).DescCommentUnlike(ctx, req.(*CommentOpIdentityRequest))
}
return interceptor(ctx, in, info, handler)
}
// Post_ServiceDesc is the grpc.ServiceDesc for Post service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Post_ServiceDesc = grpc.ServiceDesc{
ServiceName: "content.Post",
HandlerType: (*PostServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "PostList",
Handler: _Post_PostList_Handler,
},
{
MethodName: "GetPost",
Handler: _Post_GetPost_Handler,
},
{
MethodName: "AddPost",
Handler: _Post_AddPost_Handler,
},
{
MethodName: "ModifyPost",
Handler: _Post_ModifyPost_Handler,
},
{
MethodName: "DeletePost",
Handler: _Post_DeletePost_Handler,
},
{
MethodName: "IncrPostLike",
Handler: _Post_IncrPostLike_Handler,
},
{
MethodName: "DescPostLike",
Handler: _Post_DescPostLike_Handler,
},
{
MethodName: "IncrPostUnlike",
Handler: _Post_IncrPostUnlike_Handler,
},
{
MethodName: "DescPostUnlike",
Handler: _Post_DescPostUnlike_Handler,
},
{
MethodName: "CommentList",
Handler: _Post_CommentList_Handler,
},
{
MethodName: "AddComment",
Handler: _Post_AddComment_Handler,
},
{
MethodName: "ModifyComment",
Handler: _Post_ModifyComment_Handler,
},
{
MethodName: "DeleteComment",
Handler: _Post_DeleteComment_Handler,
},
{
MethodName: "IncrCommentLike",
Handler: _Post_IncrCommentLike_Handler,
},
{
MethodName: "DescCommentLike",
Handler: _Post_DescCommentLike_Handler,
},
{
MethodName: "IncrCommentUnlike",
Handler: _Post_IncrCommentUnlike_Handler,
},
{
MethodName: "DescCommentUnlike",
Handler: _Post_DescCommentUnlike_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "post.proto",
}

210
pb/question.pb.go Normal file
View File

@ -0,0 +1,210 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.6
// protoc v6.30.1
// source: question.proto
package survey
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type BySurveyRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
SurveyId string `protobuf:"bytes,1,opt,name=survey_id,json=surveyId,proto3" json:"survey_id,omitempty"`
QuestionIds []string `protobuf:"bytes,2,rep,name=question_ids,json=questionIds,proto3" json:"question_ids,omitempty"` // 按顺序排列的问题ID
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *BySurveyRequest) Reset() {
*x = BySurveyRequest{}
mi := &file_question_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *BySurveyRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BySurveyRequest) ProtoMessage() {}
func (x *BySurveyRequest) ProtoReflect() protoreflect.Message {
mi := &file_question_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BySurveyRequest.ProtoReflect.Descriptor instead.
func (*BySurveyRequest) Descriptor() ([]byte, []int) {
return file_question_proto_rawDescGZIP(), []int{0}
}
func (x *BySurveyRequest) GetSurveyId() string {
if x != nil {
return x.SurveyId
}
return ""
}
func (x *BySurveyRequest) GetQuestionIds() []string {
if x != nil {
return x.QuestionIds
}
return nil
}
type ListQuestionReply struct {
state protoimpl.MessageState `protogen:"open.v1"`
Data []*QuestionItem `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
Count int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListQuestionReply) Reset() {
*x = ListQuestionReply{}
mi := &file_question_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListQuestionReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListQuestionReply) ProtoMessage() {}
func (x *ListQuestionReply) ProtoReflect() protoreflect.Message {
mi := &file_question_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListQuestionReply.ProtoReflect.Descriptor instead.
func (*ListQuestionReply) Descriptor() ([]byte, []int) {
return file_question_proto_rawDescGZIP(), []int{1}
}
func (x *ListQuestionReply) GetData() []*QuestionItem {
if x != nil {
return x.Data
}
return nil
}
func (x *ListQuestionReply) GetCount() int64 {
if x != nil {
return x.Count
}
return 0
}
var File_question_proto protoreflect.FileDescriptor
const file_question_proto_rawDesc = "" +
"\n" +
"\x0equestion.proto\x12\x06survey\x1a\fblocks.proto\"Q\n" +
"\x0fBySurveyRequest\x12\x1b\n" +
"\tsurvey_id\x18\x01 \x01(\tR\bsurveyId\x12!\n" +
"\fquestion_ids\x18\x02 \x03(\tR\vquestionIds\"S\n" +
"\x11ListQuestionReply\x12(\n" +
"\x04data\x18\x01 \x03(\v2\x14.survey.QuestionItemR\x04data\x12\x14\n" +
"\x05count\x18\x02 \x01(\x03R\x05count2\xa0\x02\n" +
"\bQuestion\x120\n" +
"\x03Add\x12\x14.survey.QuestionItem\x1a\x13.survey.StatusReply\x123\n" +
"\x06Update\x12\x14.survey.QuestionItem\x1a\x13.survey.StatusReply\x123\n" +
"\x06Delete\x12\x14.survey.IdentRequest\x1a\x13.survey.StatusReply\x128\n" +
"\x05Fetch\x12\x14.survey.FetchRequest\x1a\x19.survey.ListQuestionReply\x12>\n" +
"\bBySurvey\x12\x17.survey.BySurveyRequest\x1a\x19.survey.ListQuestionReplyB\n" +
"Z\b.;surveyb\x06proto3"
var (
file_question_proto_rawDescOnce sync.Once
file_question_proto_rawDescData []byte
)
func file_question_proto_rawDescGZIP() []byte {
file_question_proto_rawDescOnce.Do(func() {
file_question_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_question_proto_rawDesc), len(file_question_proto_rawDesc)))
})
return file_question_proto_rawDescData
}
var file_question_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_question_proto_goTypes = []any{
(*BySurveyRequest)(nil), // 0: survey.BySurveyRequest
(*ListQuestionReply)(nil), // 1: survey.ListQuestionReply
(*QuestionItem)(nil), // 2: survey.QuestionItem
(*IdentRequest)(nil), // 3: survey.IdentRequest
(*FetchRequest)(nil), // 4: survey.FetchRequest
(*StatusReply)(nil), // 5: survey.StatusReply
}
var file_question_proto_depIdxs = []int32{
2, // 0: survey.ListQuestionReply.data:type_name -> survey.QuestionItem
2, // 1: survey.Question.Add:input_type -> survey.QuestionItem
2, // 2: survey.Question.Update:input_type -> survey.QuestionItem
3, // 3: survey.Question.Delete:input_type -> survey.IdentRequest
4, // 4: survey.Question.Fetch:input_type -> survey.FetchRequest
0, // 5: survey.Question.BySurvey:input_type -> survey.BySurveyRequest
5, // 6: survey.Question.Add:output_type -> survey.StatusReply
5, // 7: survey.Question.Update:output_type -> survey.StatusReply
5, // 8: survey.Question.Delete:output_type -> survey.StatusReply
1, // 9: survey.Question.Fetch:output_type -> survey.ListQuestionReply
1, // 10: survey.Question.BySurvey:output_type -> survey.ListQuestionReply
6, // [6:11] is the sub-list for method output_type
1, // [1:6] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_question_proto_init() }
func file_question_proto_init() {
if File_question_proto != nil {
return
}
file_blocks_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_question_proto_rawDesc), len(file_question_proto_rawDesc)),
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_question_proto_goTypes,
DependencyIndexes: file_question_proto_depIdxs,
MessageInfos: file_question_proto_msgTypes,
}.Build()
File_question_proto = out.File
file_question_proto_goTypes = nil
file_question_proto_depIdxs = nil
}

277
pb/question_grpc.pb.go Normal file
View File

@ -0,0 +1,277 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v6.30.1
// source: question.proto
package survey
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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
Question_Add_FullMethodName = "/survey.Question/Add"
Question_Update_FullMethodName = "/survey.Question/Update"
Question_Delete_FullMethodName = "/survey.Question/Delete"
Question_Fetch_FullMethodName = "/survey.Question/Fetch"
Question_BySurvey_FullMethodName = "/survey.Question/BySurvey"
)
// QuestionClient is the client API for Question 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 QuestionClient interface {
Add(ctx context.Context, in *QuestionItem, opts ...grpc.CallOption) (*StatusReply, error)
Update(ctx context.Context, in *QuestionItem, opts ...grpc.CallOption) (*StatusReply, error)
Delete(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*StatusReply, error)
Fetch(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*ListQuestionReply, error)
BySurvey(ctx context.Context, in *BySurveyRequest, opts ...grpc.CallOption) (*ListQuestionReply, error)
}
type questionClient struct {
cc grpc.ClientConnInterface
}
func NewQuestionClient(cc grpc.ClientConnInterface) QuestionClient {
return &questionClient{cc}
}
func (c *questionClient) Add(ctx context.Context, in *QuestionItem, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Question_Add_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *questionClient) Update(ctx context.Context, in *QuestionItem, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Question_Update_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *questionClient) Delete(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Question_Delete_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *questionClient) Fetch(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*ListQuestionReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListQuestionReply)
err := c.cc.Invoke(ctx, Question_Fetch_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *questionClient) BySurvey(ctx context.Context, in *BySurveyRequest, opts ...grpc.CallOption) (*ListQuestionReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListQuestionReply)
err := c.cc.Invoke(ctx, Question_BySurvey_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// QuestionServer is the server API for Question service.
// All implementations must embed UnimplementedQuestionServer
// for forward compatibility.
//
// 问卷服务 - 问题管理
type QuestionServer interface {
Add(context.Context, *QuestionItem) (*StatusReply, error)
Update(context.Context, *QuestionItem) (*StatusReply, error)
Delete(context.Context, *IdentRequest) (*StatusReply, error)
Fetch(context.Context, *FetchRequest) (*ListQuestionReply, error)
BySurvey(context.Context, *BySurveyRequest) (*ListQuestionReply, error)
mustEmbedUnimplementedQuestionServer()
}
// UnimplementedQuestionServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedQuestionServer struct{}
func (UnimplementedQuestionServer) Add(context.Context, *QuestionItem) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Add not implemented")
}
func (UnimplementedQuestionServer) Update(context.Context, *QuestionItem) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Update not implemented")
}
func (UnimplementedQuestionServer) Delete(context.Context, *IdentRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented")
}
func (UnimplementedQuestionServer) Fetch(context.Context, *FetchRequest) (*ListQuestionReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Fetch not implemented")
}
func (UnimplementedQuestionServer) BySurvey(context.Context, *BySurveyRequest) (*ListQuestionReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method BySurvey not implemented")
}
func (UnimplementedQuestionServer) mustEmbedUnimplementedQuestionServer() {}
func (UnimplementedQuestionServer) testEmbeddedByValue() {}
// UnsafeQuestionServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to QuestionServer will
// result in compilation errors.
type UnsafeQuestionServer interface {
mustEmbedUnimplementedQuestionServer()
}
func RegisterQuestionServer(s grpc.ServiceRegistrar, srv QuestionServer) {
// If the following call pancis, it indicates UnimplementedQuestionServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&Question_ServiceDesc, srv)
}
func _Question_Add_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QuestionItem)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QuestionServer).Add(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Question_Add_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QuestionServer).Add(ctx, req.(*QuestionItem))
}
return interceptor(ctx, in, info, handler)
}
func _Question_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QuestionItem)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QuestionServer).Update(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Question_Update_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QuestionServer).Update(ctx, req.(*QuestionItem))
}
return interceptor(ctx, in, info, handler)
}
func _Question_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(IdentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QuestionServer).Delete(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Question_Delete_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QuestionServer).Delete(ctx, req.(*IdentRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Question_Fetch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FetchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QuestionServer).Fetch(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Question_Fetch_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QuestionServer).Fetch(ctx, req.(*FetchRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Question_BySurvey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(BySurveyRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QuestionServer).BySurvey(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Question_BySurvey_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QuestionServer).BySurvey(ctx, req.(*BySurveyRequest))
}
return interceptor(ctx, in, info, handler)
}
// Question_ServiceDesc is the grpc.ServiceDesc for Question service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Question_ServiceDesc = grpc.ServiceDesc{
ServiceName: "survey.Question",
HandlerType: (*QuestionServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Add",
Handler: _Question_Add_Handler,
},
{
MethodName: "Update",
Handler: _Question_Update_Handler,
},
{
MethodName: "Delete",
Handler: _Question_Delete_Handler,
},
{
MethodName: "Fetch",
Handler: _Question_Fetch_Handler,
},
{
MethodName: "BySurvey",
Handler: _Question_BySurvey_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "question.proto",
}

152
pb/report.pb.go Normal file
View File

@ -0,0 +1,152 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.6
// protoc v6.30.1
// source: report.proto
package survey
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type SurveyStats struct {
state protoimpl.MessageState `protogen:"open.v1"`
SurveyId string `protobuf:"bytes,1,opt,name=survey_id,json=surveyId,proto3" json:"survey_id,omitempty"`
ResponseCount int32 `protobuf:"varint,2,opt,name=response_count,json=responseCount,proto3" json:"response_count,omitempty"`
QuestionStats map[string]int64 `protobuf:"bytes,3,rep,name=question_stats,json=questionStats,proto3" json:"question_stats,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` // key为question_id
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *SurveyStats) Reset() {
*x = SurveyStats{}
mi := &file_report_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *SurveyStats) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SurveyStats) ProtoMessage() {}
func (x *SurveyStats) ProtoReflect() protoreflect.Message {
mi := &file_report_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SurveyStats.ProtoReflect.Descriptor instead.
func (*SurveyStats) Descriptor() ([]byte, []int) {
return file_report_proto_rawDescGZIP(), []int{0}
}
func (x *SurveyStats) GetSurveyId() string {
if x != nil {
return x.SurveyId
}
return ""
}
func (x *SurveyStats) GetResponseCount() int32 {
if x != nil {
return x.ResponseCount
}
return 0
}
func (x *SurveyStats) GetQuestionStats() map[string]int64 {
if x != nil {
return x.QuestionStats
}
return nil
}
var File_report_proto protoreflect.FileDescriptor
const file_report_proto_rawDesc = "" +
"\n" +
"\freport.proto\x12\x06survey\x1a\fblocks.proto\"\xe2\x01\n" +
"\vSurveyStats\x12\x1b\n" +
"\tsurvey_id\x18\x01 \x01(\tR\bsurveyId\x12%\n" +
"\x0eresponse_count\x18\x02 \x01(\x05R\rresponseCount\x12M\n" +
"\x0equestion_stats\x18\x03 \x03(\v2&.survey.SurveyStats.QuestionStatsEntryR\rquestionStats\x1a@\n" +
"\x12QuestionStatsEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x02 \x01(\x03R\x05value:\x028\x012E\n" +
"\x06Report\x12;\n" +
"\x0eGetSurveyStats\x12\x14.survey.IdentRequest\x1a\x13.survey.SurveyStatsB\n" +
"Z\b.;surveyb\x06proto3"
var (
file_report_proto_rawDescOnce sync.Once
file_report_proto_rawDescData []byte
)
func file_report_proto_rawDescGZIP() []byte {
file_report_proto_rawDescOnce.Do(func() {
file_report_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_report_proto_rawDesc), len(file_report_proto_rawDesc)))
})
return file_report_proto_rawDescData
}
var file_report_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_report_proto_goTypes = []any{
(*SurveyStats)(nil), // 0: survey.SurveyStats
nil, // 1: survey.SurveyStats.QuestionStatsEntry
(*IdentRequest)(nil), // 2: survey.IdentRequest
}
var file_report_proto_depIdxs = []int32{
1, // 0: survey.SurveyStats.question_stats:type_name -> survey.SurveyStats.QuestionStatsEntry
2, // 1: survey.Report.GetSurveyStats:input_type -> survey.IdentRequest
0, // 2: survey.Report.GetSurveyStats:output_type -> survey.SurveyStats
2, // [2:3] is the sub-list for method output_type
1, // [1:2] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_report_proto_init() }
func file_report_proto_init() {
if File_report_proto != nil {
return
}
file_blocks_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_report_proto_rawDesc), len(file_report_proto_rawDesc)),
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_report_proto_goTypes,
DependencyIndexes: file_report_proto_depIdxs,
MessageInfos: file_report_proto_msgTypes,
}.Build()
File_report_proto = out.File
file_report_proto_goTypes = nil
file_report_proto_depIdxs = nil
}

125
pb/report_grpc.pb.go Normal file
View File

@ -0,0 +1,125 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v6.30.1
// source: report.proto
package survey
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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
Report_GetSurveyStats_FullMethodName = "/survey.Report/GetSurveyStats"
)
// ReportClient is the client API for Report 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 ReportClient interface {
GetSurveyStats(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*SurveyStats, error)
}
type reportClient struct {
cc grpc.ClientConnInterface
}
func NewReportClient(cc grpc.ClientConnInterface) ReportClient {
return &reportClient{cc}
}
func (c *reportClient) GetSurveyStats(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*SurveyStats, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(SurveyStats)
err := c.cc.Invoke(ctx, Report_GetSurveyStats_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// ReportServer is the server API for Report service.
// All implementations must embed UnimplementedReportServer
// for forward compatibility.
//
// 问卷服务 - 统计分析
type ReportServer interface {
GetSurveyStats(context.Context, *IdentRequest) (*SurveyStats, error)
mustEmbedUnimplementedReportServer()
}
// UnimplementedReportServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedReportServer struct{}
func (UnimplementedReportServer) GetSurveyStats(context.Context, *IdentRequest) (*SurveyStats, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetSurveyStats not implemented")
}
func (UnimplementedReportServer) mustEmbedUnimplementedReportServer() {}
func (UnimplementedReportServer) testEmbeddedByValue() {}
// UnsafeReportServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to ReportServer will
// result in compilation errors.
type UnsafeReportServer interface {
mustEmbedUnimplementedReportServer()
}
func RegisterReportServer(s grpc.ServiceRegistrar, srv ReportServer) {
// If the following call pancis, it indicates UnimplementedReportServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&Report_ServiceDesc, srv)
}
func _Report_GetSurveyStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(IdentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ReportServer).GetSurveyStats(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Report_GetSurveyStats_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ReportServer).GetSurveyStats(ctx, req.(*IdentRequest))
}
return interceptor(ctx, in, info, handler)
}
// Report_ServiceDesc is the grpc.ServiceDesc for Report service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Report_ServiceDesc = grpc.ServiceDesc{
ServiceName: "survey.Report",
HandlerType: (*ReportServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetSurveyStats",
Handler: _Report_GetSurveyStats_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "report.proto",
}

251
pb/share.pb.go Normal file
View File

@ -0,0 +1,251 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.6
// protoc v6.30.1
// source: share.proto
package survey
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type ListShareReply struct {
state protoimpl.MessageState `protogen:"open.v1"`
Data []*ShareItem `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
Count int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListShareReply) Reset() {
*x = ListShareReply{}
mi := &file_share_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListShareReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListShareReply) ProtoMessage() {}
func (x *ListShareReply) ProtoReflect() protoreflect.Message {
mi := &file_share_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListShareReply.ProtoReflect.Descriptor instead.
func (*ListShareReply) Descriptor() ([]byte, []int) {
return file_share_proto_rawDescGZIP(), []int{0}
}
func (x *ListShareReply) GetData() []*ShareItem {
if x != nil {
return x.Data
}
return nil
}
func (x *ListShareReply) GetCount() int64 {
if x != nil {
return x.Count
}
return 0
}
// 分享链接
type ShareItem struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // 分享ID
SurveyId string `protobuf:"bytes,2,opt,name=survey_id,json=surveyId,proto3" json:"survey_id,omitempty"` // 问卷ID
Url string `protobuf:"bytes,3,opt,name=url,proto3" json:"url,omitempty"` // 分享URL
CreatorId string `protobuf:"bytes,4,opt,name=creator_id,json=creatorId,proto3" json:"creator_id,omitempty"` // 创建者ID
ExpiresAt int64 `protobuf:"varint,6,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"` // 过期时间
MaxResponses int32 `protobuf:"varint,7,opt,name=max_responses,json=maxResponses,proto3" json:"max_responses,omitempty"` // 最大回答数(0表示不限)
IsActive bool `protobuf:"varint,8,opt,name=is_active,json=isActive,proto3" json:"is_active,omitempty"` // 是否激活
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ShareItem) Reset() {
*x = ShareItem{}
mi := &file_share_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ShareItem) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ShareItem) ProtoMessage() {}
func (x *ShareItem) ProtoReflect() protoreflect.Message {
mi := &file_share_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ShareItem.ProtoReflect.Descriptor instead.
func (*ShareItem) Descriptor() ([]byte, []int) {
return file_share_proto_rawDescGZIP(), []int{1}
}
func (x *ShareItem) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *ShareItem) GetSurveyId() string {
if x != nil {
return x.SurveyId
}
return ""
}
func (x *ShareItem) GetUrl() string {
if x != nil {
return x.Url
}
return ""
}
func (x *ShareItem) GetCreatorId() string {
if x != nil {
return x.CreatorId
}
return ""
}
func (x *ShareItem) GetExpiresAt() int64 {
if x != nil {
return x.ExpiresAt
}
return 0
}
func (x *ShareItem) GetMaxResponses() int32 {
if x != nil {
return x.MaxResponses
}
return 0
}
func (x *ShareItem) GetIsActive() bool {
if x != nil {
return x.IsActive
}
return false
}
var File_share_proto protoreflect.FileDescriptor
const file_share_proto_rawDesc = "" +
"\n" +
"\vshare.proto\x12\x06survey\x1a\fblocks.proto\"M\n" +
"\x0eListShareReply\x12%\n" +
"\x04data\x18\x01 \x03(\v2\x11.survey.ShareItemR\x04data\x12\x14\n" +
"\x05count\x18\x02 \x01(\x03R\x05count\"\xca\x01\n" +
"\tShareItem\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x1b\n" +
"\tsurvey_id\x18\x02 \x01(\tR\bsurveyId\x12\x10\n" +
"\x03url\x18\x03 \x01(\tR\x03url\x12\x1d\n" +
"\n" +
"creator_id\x18\x04 \x01(\tR\tcreatorId\x12\x1d\n" +
"\n" +
"expires_at\x18\x06 \x01(\x03R\texpiresAt\x12#\n" +
"\rmax_responses\x18\a \x01(\x05R\fmaxResponses\x12\x1b\n" +
"\tis_active\x18\b \x01(\bR\bisActive2\xaa\x01\n" +
"\x05Share\x123\n" +
"\x06Create\x12\x14.survey.IdentRequest\x1a\x13.survey.StatusReply\x125\n" +
"\x05Fetch\x12\x14.survey.FetchRequest\x1a\x16.survey.ListShareReply\x125\n" +
"\tSetStatus\x12\x13.survey.StatusReply\x1a\x13.survey.StatusReplyB\n" +
"Z\b.;surveyb\x06proto3"
var (
file_share_proto_rawDescOnce sync.Once
file_share_proto_rawDescData []byte
)
func file_share_proto_rawDescGZIP() []byte {
file_share_proto_rawDescOnce.Do(func() {
file_share_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_share_proto_rawDesc), len(file_share_proto_rawDesc)))
})
return file_share_proto_rawDescData
}
var file_share_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_share_proto_goTypes = []any{
(*ListShareReply)(nil), // 0: survey.ListShareReply
(*ShareItem)(nil), // 1: survey.ShareItem
(*IdentRequest)(nil), // 2: survey.IdentRequest
(*FetchRequest)(nil), // 3: survey.FetchRequest
(*StatusReply)(nil), // 4: survey.StatusReply
}
var file_share_proto_depIdxs = []int32{
1, // 0: survey.ListShareReply.data:type_name -> survey.ShareItem
2, // 1: survey.Share.Create:input_type -> survey.IdentRequest
3, // 2: survey.Share.Fetch:input_type -> survey.FetchRequest
4, // 3: survey.Share.SetStatus:input_type -> survey.StatusReply
4, // 4: survey.Share.Create:output_type -> survey.StatusReply
0, // 5: survey.Share.Fetch:output_type -> survey.ListShareReply
4, // 6: survey.Share.SetStatus:output_type -> survey.StatusReply
4, // [4:7] is the sub-list for method output_type
1, // [1:4] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_share_proto_init() }
func file_share_proto_init() {
if File_share_proto != nil {
return
}
file_blocks_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_share_proto_rawDesc), len(file_share_proto_rawDesc)),
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_share_proto_goTypes,
DependencyIndexes: file_share_proto_depIdxs,
MessageInfos: file_share_proto_msgTypes,
}.Build()
File_share_proto = out.File
file_share_proto_goTypes = nil
file_share_proto_depIdxs = nil
}

201
pb/share_grpc.pb.go Normal file
View File

@ -0,0 +1,201 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v6.30.1
// source: share.proto
package survey
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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
Share_Create_FullMethodName = "/survey.Share/Create"
Share_Fetch_FullMethodName = "/survey.Share/Fetch"
Share_SetStatus_FullMethodName = "/survey.Share/SetStatus"
)
// ShareClient is the client API for Share 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 ShareClient interface {
Create(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*StatusReply, error)
Fetch(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*ListShareReply, error)
SetStatus(ctx context.Context, in *StatusReply, opts ...grpc.CallOption) (*StatusReply, error)
}
type shareClient struct {
cc grpc.ClientConnInterface
}
func NewShareClient(cc grpc.ClientConnInterface) ShareClient {
return &shareClient{cc}
}
func (c *shareClient) Create(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Share_Create_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *shareClient) Fetch(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*ListShareReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListShareReply)
err := c.cc.Invoke(ctx, Share_Fetch_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *shareClient) SetStatus(ctx context.Context, in *StatusReply, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Share_SetStatus_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// ShareServer is the server API for Share service.
// All implementations must embed UnimplementedShareServer
// for forward compatibility.
//
// 问卷服务 - 分享管理
type ShareServer interface {
Create(context.Context, *IdentRequest) (*StatusReply, error)
Fetch(context.Context, *FetchRequest) (*ListShareReply, error)
SetStatus(context.Context, *StatusReply) (*StatusReply, error)
mustEmbedUnimplementedShareServer()
}
// UnimplementedShareServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedShareServer struct{}
func (UnimplementedShareServer) Create(context.Context, *IdentRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Create not implemented")
}
func (UnimplementedShareServer) Fetch(context.Context, *FetchRequest) (*ListShareReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Fetch not implemented")
}
func (UnimplementedShareServer) SetStatus(context.Context, *StatusReply) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method SetStatus not implemented")
}
func (UnimplementedShareServer) mustEmbedUnimplementedShareServer() {}
func (UnimplementedShareServer) testEmbeddedByValue() {}
// UnsafeShareServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to ShareServer will
// result in compilation errors.
type UnsafeShareServer interface {
mustEmbedUnimplementedShareServer()
}
func RegisterShareServer(s grpc.ServiceRegistrar, srv ShareServer) {
// If the following call pancis, it indicates UnimplementedShareServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&Share_ServiceDesc, srv)
}
func _Share_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(IdentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ShareServer).Create(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Share_Create_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ShareServer).Create(ctx, req.(*IdentRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Share_Fetch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FetchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ShareServer).Fetch(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Share_Fetch_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ShareServer).Fetch(ctx, req.(*FetchRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Share_SetStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(StatusReply)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ShareServer).SetStatus(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Share_SetStatus_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ShareServer).SetStatus(ctx, req.(*StatusReply))
}
return interceptor(ctx, in, info, handler)
}
// Share_ServiceDesc is the grpc.ServiceDesc for Share service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Share_ServiceDesc = grpc.ServiceDesc{
ServiceName: "survey.Share",
HandlerType: (*ShareServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Create",
Handler: _Share_Create_Handler,
},
{
MethodName: "Fetch",
Handler: _Share_Fetch_Handler,
},
{
MethodName: "SetStatus",
Handler: _Share_SetStatus_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "share.proto",
}

154
pb/survey.pb.go Normal file
View File

@ -0,0 +1,154 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.6
// protoc v6.30.1
// source: survey.proto
package survey
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type ListSurveyReply struct {
state protoimpl.MessageState `protogen:"open.v1"`
Data []*SurveyItem `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
Count int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListSurveyReply) Reset() {
*x = ListSurveyReply{}
mi := &file_survey_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListSurveyReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListSurveyReply) ProtoMessage() {}
func (x *ListSurveyReply) ProtoReflect() protoreflect.Message {
mi := &file_survey_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListSurveyReply.ProtoReflect.Descriptor instead.
func (*ListSurveyReply) Descriptor() ([]byte, []int) {
return file_survey_proto_rawDescGZIP(), []int{0}
}
func (x *ListSurveyReply) GetData() []*SurveyItem {
if x != nil {
return x.Data
}
return nil
}
func (x *ListSurveyReply) GetCount() int64 {
if x != nil {
return x.Count
}
return 0
}
var File_survey_proto protoreflect.FileDescriptor
const file_survey_proto_rawDesc = "" +
"\n" +
"\fsurvey.proto\x12\x06survey\x1a\fblocks.proto\"O\n" +
"\x0fListSurveyReply\x12&\n" +
"\x04data\x18\x01 \x03(\v2\x12.survey.SurveyItemR\x04data\x12\x14\n" +
"\x05count\x18\x02 \x01(\x03R\x05count2\x8c\x02\n" +
"\x06Survey\x121\n" +
"\x06Create\x12\x12.survey.SurveyItem\x1a\x13.survey.StatusReply\x12/\n" +
"\x03Get\x12\x14.survey.IdentRequest\x1a\x12.survey.SurveyItem\x121\n" +
"\x06Update\x12\x12.survey.SurveyItem\x1a\x13.survey.StatusReply\x123\n" +
"\x06Delete\x12\x14.survey.IdentRequest\x1a\x13.survey.StatusReply\x126\n" +
"\x05Fetch\x12\x14.survey.FetchRequest\x1a\x17.survey.ListSurveyReplyB\n" +
"Z\b.;surveyb\x06proto3"
var (
file_survey_proto_rawDescOnce sync.Once
file_survey_proto_rawDescData []byte
)
func file_survey_proto_rawDescGZIP() []byte {
file_survey_proto_rawDescOnce.Do(func() {
file_survey_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_survey_proto_rawDesc), len(file_survey_proto_rawDesc)))
})
return file_survey_proto_rawDescData
}
var file_survey_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_survey_proto_goTypes = []any{
(*ListSurveyReply)(nil), // 0: survey.ListSurveyReply
(*SurveyItem)(nil), // 1: survey.SurveyItem
(*IdentRequest)(nil), // 2: survey.IdentRequest
(*FetchRequest)(nil), // 3: survey.FetchRequest
(*StatusReply)(nil), // 4: survey.StatusReply
}
var file_survey_proto_depIdxs = []int32{
1, // 0: survey.ListSurveyReply.data:type_name -> survey.SurveyItem
1, // 1: survey.Survey.Create:input_type -> survey.SurveyItem
2, // 2: survey.Survey.Get:input_type -> survey.IdentRequest
1, // 3: survey.Survey.Update:input_type -> survey.SurveyItem
2, // 4: survey.Survey.Delete:input_type -> survey.IdentRequest
3, // 5: survey.Survey.Fetch:input_type -> survey.FetchRequest
4, // 6: survey.Survey.Create:output_type -> survey.StatusReply
1, // 7: survey.Survey.Get:output_type -> survey.SurveyItem
4, // 8: survey.Survey.Update:output_type -> survey.StatusReply
4, // 9: survey.Survey.Delete:output_type -> survey.StatusReply
0, // 10: survey.Survey.Fetch:output_type -> survey.ListSurveyReply
6, // [6:11] is the sub-list for method output_type
1, // [1:6] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_survey_proto_init() }
func file_survey_proto_init() {
if File_survey_proto != nil {
return
}
file_blocks_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_survey_proto_rawDesc), len(file_survey_proto_rawDesc)),
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_survey_proto_goTypes,
DependencyIndexes: file_survey_proto_depIdxs,
MessageInfos: file_survey_proto_msgTypes,
}.Build()
File_survey_proto = out.File
file_survey_proto_goTypes = nil
file_survey_proto_depIdxs = nil
}

277
pb/survey_grpc.pb.go Normal file
View File

@ -0,0 +1,277 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v6.30.1
// source: survey.proto
package survey
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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
Survey_Create_FullMethodName = "/survey.Survey/Create"
Survey_Get_FullMethodName = "/survey.Survey/Get"
Survey_Update_FullMethodName = "/survey.Survey/Update"
Survey_Delete_FullMethodName = "/survey.Survey/Delete"
Survey_Fetch_FullMethodName = "/survey.Survey/Fetch"
)
// SurveyClient is the client API for Survey 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 SurveyClient interface {
Create(ctx context.Context, in *SurveyItem, opts ...grpc.CallOption) (*StatusReply, error)
Get(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*SurveyItem, error)
Update(ctx context.Context, in *SurveyItem, opts ...grpc.CallOption) (*StatusReply, error)
Delete(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*StatusReply, error)
Fetch(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*ListSurveyReply, error)
}
type surveyClient struct {
cc grpc.ClientConnInterface
}
func NewSurveyClient(cc grpc.ClientConnInterface) SurveyClient {
return &surveyClient{cc}
}
func (c *surveyClient) Create(ctx context.Context, in *SurveyItem, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Survey_Create_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *surveyClient) Get(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*SurveyItem, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(SurveyItem)
err := c.cc.Invoke(ctx, Survey_Get_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *surveyClient) Update(ctx context.Context, in *SurveyItem, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Survey_Update_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *surveyClient) Delete(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Survey_Delete_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *surveyClient) Fetch(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*ListSurveyReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListSurveyReply)
err := c.cc.Invoke(ctx, Survey_Fetch_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// SurveyServer is the server API for Survey service.
// All implementations must embed UnimplementedSurveyServer
// for forward compatibility.
//
// 问卷服务 - 问卷管理
type SurveyServer interface {
Create(context.Context, *SurveyItem) (*StatusReply, error)
Get(context.Context, *IdentRequest) (*SurveyItem, error)
Update(context.Context, *SurveyItem) (*StatusReply, error)
Delete(context.Context, *IdentRequest) (*StatusReply, error)
Fetch(context.Context, *FetchRequest) (*ListSurveyReply, error)
mustEmbedUnimplementedSurveyServer()
}
// UnimplementedSurveyServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedSurveyServer struct{}
func (UnimplementedSurveyServer) Create(context.Context, *SurveyItem) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Create not implemented")
}
func (UnimplementedSurveyServer) Get(context.Context, *IdentRequest) (*SurveyItem, error) {
return nil, status.Errorf(codes.Unimplemented, "method Get not implemented")
}
func (UnimplementedSurveyServer) Update(context.Context, *SurveyItem) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Update not implemented")
}
func (UnimplementedSurveyServer) Delete(context.Context, *IdentRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented")
}
func (UnimplementedSurveyServer) Fetch(context.Context, *FetchRequest) (*ListSurveyReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Fetch not implemented")
}
func (UnimplementedSurveyServer) mustEmbedUnimplementedSurveyServer() {}
func (UnimplementedSurveyServer) testEmbeddedByValue() {}
// UnsafeSurveyServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to SurveyServer will
// result in compilation errors.
type UnsafeSurveyServer interface {
mustEmbedUnimplementedSurveyServer()
}
func RegisterSurveyServer(s grpc.ServiceRegistrar, srv SurveyServer) {
// If the following call pancis, it indicates UnimplementedSurveyServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&Survey_ServiceDesc, srv)
}
func _Survey_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SurveyItem)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SurveyServer).Create(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Survey_Create_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SurveyServer).Create(ctx, req.(*SurveyItem))
}
return interceptor(ctx, in, info, handler)
}
func _Survey_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(IdentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SurveyServer).Get(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Survey_Get_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SurveyServer).Get(ctx, req.(*IdentRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Survey_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SurveyItem)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SurveyServer).Update(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Survey_Update_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SurveyServer).Update(ctx, req.(*SurveyItem))
}
return interceptor(ctx, in, info, handler)
}
func _Survey_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(IdentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SurveyServer).Delete(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Survey_Delete_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SurveyServer).Delete(ctx, req.(*IdentRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Survey_Fetch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FetchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SurveyServer).Fetch(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Survey_Fetch_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SurveyServer).Fetch(ctx, req.(*FetchRequest))
}
return interceptor(ctx, in, info, handler)
}
// Survey_ServiceDesc is the grpc.ServiceDesc for Survey service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Survey_ServiceDesc = grpc.ServiceDesc{
ServiceName: "survey.Survey",
HandlerType: (*SurveyServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Create",
Handler: _Survey_Create_Handler,
},
{
MethodName: "Get",
Handler: _Survey_Get_Handler,
},
{
MethodName: "Update",
Handler: _Survey_Update_Handler,
},
{
MethodName: "Delete",
Handler: _Survey_Delete_Handler,
},
{
MethodName: "Fetch",
Handler: _Survey_Fetch_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "survey.proto",
}

View File

@ -1,247 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.6
// protoc v6.30.1
// source: tags.proto
package content
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// 无限极标签
type TagsItem struct {
state protoimpl.MessageState `protogen:"open.v1"`
Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"`
ParentIdentity string `protobuf:"bytes,2,opt,name=parent_identity,json=parentIdentity,proto3" json:"parent_identity,omitempty"` // 为空表示顶级主题
Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`
CoverPath string `protobuf:"bytes,4,opt,name=cover_path,json=coverPath,proto3" json:"cover_path,omitempty"`
Intro string `protobuf:"bytes,5,opt,name=intro,proto3" json:"intro,omitempty"`
List []*TagsItem `protobuf:"bytes,9,rep,name=list,proto3" json:"list,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *TagsItem) Reset() {
*x = TagsItem{}
mi := &file_tags_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *TagsItem) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TagsItem) ProtoMessage() {}
func (x *TagsItem) ProtoReflect() protoreflect.Message {
mi := &file_tags_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TagsItem.ProtoReflect.Descriptor instead.
func (*TagsItem) Descriptor() ([]byte, []int) {
return file_tags_proto_rawDescGZIP(), []int{0}
}
func (x *TagsItem) GetIdentity() string {
if x != nil {
return x.Identity
}
return ""
}
func (x *TagsItem) GetParentIdentity() string {
if x != nil {
return x.ParentIdentity
}
return ""
}
func (x *TagsItem) GetTitle() string {
if x != nil {
return x.Title
}
return ""
}
func (x *TagsItem) GetCoverPath() string {
if x != nil {
return x.CoverPath
}
return ""
}
func (x *TagsItem) GetIntro() string {
if x != nil {
return x.Intro
}
return ""
}
func (x *TagsItem) GetList() []*TagsItem {
if x != nil {
return x.List
}
return nil
}
type TagsListReply struct {
state protoimpl.MessageState `protogen:"open.v1"`
List []*TagsItem `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"`
Count int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *TagsListReply) Reset() {
*x = TagsListReply{}
mi := &file_tags_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *TagsListReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TagsListReply) ProtoMessage() {}
func (x *TagsListReply) ProtoReflect() protoreflect.Message {
mi := &file_tags_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TagsListReply.ProtoReflect.Descriptor instead.
func (*TagsListReply) Descriptor() ([]byte, []int) {
return file_tags_proto_rawDescGZIP(), []int{1}
}
func (x *TagsListReply) GetList() []*TagsItem {
if x != nil {
return x.List
}
return nil
}
func (x *TagsListReply) GetCount() int64 {
if x != nil {
return x.Count
}
return 0
}
var File_tags_proto protoreflect.FileDescriptor
const file_tags_proto_rawDesc = "" +
"\n" +
"\n" +
"tags.proto\x12\acontent\x1a\fblocks.proto\"\xc1\x01\n" +
"\bTagsItem\x12\x1a\n" +
"\bidentity\x18\x01 \x01(\tR\bidentity\x12'\n" +
"\x0fparent_identity\x18\x02 \x01(\tR\x0eparentIdentity\x12\x14\n" +
"\x05title\x18\x03 \x01(\tR\x05title\x12\x1d\n" +
"\n" +
"cover_path\x18\x04 \x01(\tR\tcoverPath\x12\x14\n" +
"\x05intro\x18\x05 \x01(\tR\x05intro\x12%\n" +
"\x04list\x18\t \x03(\v2\x11.content.TagsItemR\x04list\"L\n" +
"\rTagsListReply\x12%\n" +
"\x04list\x18\x01 \x03(\v2\x11.content.TagsItemR\x04list\x12\x14\n" +
"\x05count\x18\x02 \x01(\x03R\x05count2\xef\x01\n" +
"\x04Tags\x12;\n" +
"\bTagsList\x12\x15.content.IdentRequest\x1a\x16.content.TagsListReply\"\x00\x124\n" +
"\aAddTags\x12\x11.content.TagsItem\x1a\x14.content.StatusReply\"\x00\x127\n" +
"\n" +
"ModifyTags\x12\x11.content.TagsItem\x1a\x14.content.StatusReply\"\x00\x12;\n" +
"\n" +
"DeleteTags\x12\x15.content.IdentRequest\x1a\x14.content.StatusReply\"\x00B\fZ\n" +
"./;contentb\x06proto3"
var (
file_tags_proto_rawDescOnce sync.Once
file_tags_proto_rawDescData []byte
)
func file_tags_proto_rawDescGZIP() []byte {
file_tags_proto_rawDescOnce.Do(func() {
file_tags_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_tags_proto_rawDesc), len(file_tags_proto_rawDesc)))
})
return file_tags_proto_rawDescData
}
var file_tags_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_tags_proto_goTypes = []any{
(*TagsItem)(nil), // 0: content.TagsItem
(*TagsListReply)(nil), // 1: content.TagsListReply
(*IdentRequest)(nil), // 2: content.IdentRequest
(*StatusReply)(nil), // 3: content.StatusReply
}
var file_tags_proto_depIdxs = []int32{
0, // 0: content.TagsItem.list:type_name -> content.TagsItem
0, // 1: content.TagsListReply.list:type_name -> content.TagsItem
2, // 2: content.Tags.TagsList:input_type -> content.IdentRequest
0, // 3: content.Tags.AddTags:input_type -> content.TagsItem
0, // 4: content.Tags.ModifyTags:input_type -> content.TagsItem
2, // 5: content.Tags.DeleteTags:input_type -> content.IdentRequest
1, // 6: content.Tags.TagsList:output_type -> content.TagsListReply
3, // 7: content.Tags.AddTags:output_type -> content.StatusReply
3, // 8: content.Tags.ModifyTags:output_type -> content.StatusReply
3, // 9: content.Tags.DeleteTags:output_type -> content.StatusReply
6, // [6:10] is the sub-list for method output_type
2, // [2:6] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_tags_proto_init() }
func file_tags_proto_init() {
if File_tags_proto != nil {
return
}
file_blocks_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_tags_proto_rawDesc), len(file_tags_proto_rawDesc)),
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_tags_proto_goTypes,
DependencyIndexes: file_tags_proto_depIdxs,
MessageInfos: file_tags_proto_msgTypes,
}.Build()
File_tags_proto = out.File
file_tags_proto_goTypes = nil
file_tags_proto_depIdxs = nil
}

View File

@ -1,247 +0,0 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v6.30.1
// source: tags.proto
package content
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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
Tags_TagsList_FullMethodName = "/content.Tags/TagsList"
Tags_AddTags_FullMethodName = "/content.Tags/AddTags"
Tags_ModifyTags_FullMethodName = "/content.Tags/ModifyTags"
Tags_DeleteTags_FullMethodName = "/content.Tags/DeleteTags"
)
// TagsClient is the client API for Tags 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 TagsClient interface {
// 标签列表
TagsList(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*TagsListReply, error)
// 创建标签
AddTags(ctx context.Context, in *TagsItem, opts ...grpc.CallOption) (*StatusReply, error)
// 修改标签
ModifyTags(ctx context.Context, in *TagsItem, opts ...grpc.CallOption) (*StatusReply, error)
// 删除标签
DeleteTags(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*StatusReply, error)
}
type tagsClient struct {
cc grpc.ClientConnInterface
}
func NewTagsClient(cc grpc.ClientConnInterface) TagsClient {
return &tagsClient{cc}
}
func (c *tagsClient) TagsList(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*TagsListReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(TagsListReply)
err := c.cc.Invoke(ctx, Tags_TagsList_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *tagsClient) AddTags(ctx context.Context, in *TagsItem, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Tags_AddTags_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *tagsClient) ModifyTags(ctx context.Context, in *TagsItem, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Tags_ModifyTags_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *tagsClient) DeleteTags(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Tags_DeleteTags_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// TagsServer is the server API for Tags service.
// All implementations must embed UnimplementedTagsServer
// for forward compatibility.
//
// 标签
type TagsServer interface {
// 标签列表
TagsList(context.Context, *IdentRequest) (*TagsListReply, error)
// 创建标签
AddTags(context.Context, *TagsItem) (*StatusReply, error)
// 修改标签
ModifyTags(context.Context, *TagsItem) (*StatusReply, error)
// 删除标签
DeleteTags(context.Context, *IdentRequest) (*StatusReply, error)
mustEmbedUnimplementedTagsServer()
}
// UnimplementedTagsServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedTagsServer struct{}
func (UnimplementedTagsServer) TagsList(context.Context, *IdentRequest) (*TagsListReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method TagsList not implemented")
}
func (UnimplementedTagsServer) AddTags(context.Context, *TagsItem) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddTags not implemented")
}
func (UnimplementedTagsServer) ModifyTags(context.Context, *TagsItem) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method ModifyTags not implemented")
}
func (UnimplementedTagsServer) DeleteTags(context.Context, *IdentRequest) (*StatusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteTags not implemented")
}
func (UnimplementedTagsServer) mustEmbedUnimplementedTagsServer() {}
func (UnimplementedTagsServer) testEmbeddedByValue() {}
// UnsafeTagsServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to TagsServer will
// result in compilation errors.
type UnsafeTagsServer interface {
mustEmbedUnimplementedTagsServer()
}
func RegisterTagsServer(s grpc.ServiceRegistrar, srv TagsServer) {
// If the following call pancis, it indicates UnimplementedTagsServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&Tags_ServiceDesc, srv)
}
func _Tags_TagsList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(IdentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TagsServer).TagsList(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Tags_TagsList_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TagsServer).TagsList(ctx, req.(*IdentRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Tags_AddTags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TagsItem)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TagsServer).AddTags(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Tags_AddTags_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TagsServer).AddTags(ctx, req.(*TagsItem))
}
return interceptor(ctx, in, info, handler)
}
func _Tags_ModifyTags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TagsItem)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TagsServer).ModifyTags(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Tags_ModifyTags_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TagsServer).ModifyTags(ctx, req.(*TagsItem))
}
return interceptor(ctx, in, info, handler)
}
func _Tags_DeleteTags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(IdentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TagsServer).DeleteTags(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Tags_DeleteTags_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TagsServer).DeleteTags(ctx, req.(*IdentRequest))
}
return interceptor(ctx, in, info, handler)
}
// Tags_ServiceDesc is the grpc.ServiceDesc for Tags service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Tags_ServiceDesc = grpc.ServiceDesc{
ServiceName: "content.Tags",
HandlerType: (*TagsServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "TagsList",
Handler: _Tags_TagsList_Handler,
},
{
MethodName: "AddTags",
Handler: _Tags_AddTags_Handler,
},
{
MethodName: "ModifyTags",
Handler: _Tags_ModifyTags_Handler,
},
{
MethodName: "DeleteTags",
Handler: _Tags_DeleteTags_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "tags.proto",
}

28
proto/answer.proto Normal file
View File

@ -0,0 +1,28 @@
syntax = "proto3";
package survey;
option go_package = ".;survey";
import "blocks.proto";
// -
service Answer {
rpc Submit (SubmitAnswerRequest) returns (StatusReply);
rpc BySurvey (IdentRequest) returns (ListAnswerReply);
}
message SubmitAnswerRequest {
string survey_id = 1;
string owner_id = 2; // ID
repeated AnswerItem answer = 3; //
string ip_address = 4;
string user_agent = 5;
}
message AnswerItem {
string question_id = 1;
repeated string answer = 2;
}
message ListAnswerReply {
repeated AnswerItem data = 1;
int64 count = 2;
}

View File

@ -1,6 +1,10 @@
syntax = "proto3";
package content;
option go_package = "./;content";
package survey;
option go_package = ".;survey";
message Empty{
}
message FetchRequest {
int64 page_no=1; //
@ -30,5 +34,52 @@ message StatusReply{
int64 timeseq=4; //
}
message Empty{
//
message SurveyItem {
string id = 1; // ID
string title = 2; //
string description = 3; //
string creator_id = 4; // ID
string start_time = 5; //
string end_time = 6; //
bool is_active = 7; //
bool is_anonymous = 8; //
repeated QuestionItem questions = 9; //
repeated string tags = 10; //
string style_config = 11; // (JSON)
}
//
enum QuestionType {
SINGLE_CHOICE = 0; //
MULTIPLE_CHOICE = 1; //
TEXT = 2; //
SCALE = 3; //
RANKING = 4; //
DATE = 5; //
}
//
message QuestionItem {
string id = 1; // ID
string survey_id = 2; // ID
string title = 3; //
string description = 4; //
QuestionType type = 5; //
bool is_required = 6; //
repeated Option options = 7; // ()
int32 min_selections = 8; // ()
int32 max_selections = 9; // ()
int32 order = 10; //
string placeholder = 11; // ()
}
//
message Option {
string id = 1; // ID
string text = 2; //
int32 order = 3; //
string image_url = 4; //
int32 score = 5; // ()
}

View File

@ -1,59 +0,0 @@
syntax = "proto3";
package content;
option go_package = "./;content";
import "blocks.proto";
//
service Category {
//
rpc CategoryList (Empty) returns (CategoryListReply) {};
rpc AddCategory (AddCategoryRequest) returns (AddCategoryResponse) {};
rpc ModifyCategory (ModifyCategoryRequest) returns (Empty) {};
rpc DeleteCategory (DeleteCategoryRequest) returns (Empty) {};
}
//
message CategoryItem{
string identity = 1;
string parent_identity = 2; //
string title = 3;
string cover_path = 4;
string intro=5;
string created_at = 6;
string updated_at = 7;
repeated CategoryItem data = 8;
}
message CategoryListReply {
repeated CategoryItem data = 1;
int64 count = 2;
}
message AddCategoryResponse{
string identity = 1; //
}
message AddCategoryRequest{
string identity = 1; //
string parent_identity = 2; //
string title = 3;
string cover_path = 4;
string intro=5;
string created_at = 6;
string updated_at = 7;
repeated CategoryItem data = 8;
}
message ModifyCategoryRequest{
string identity = 1; //
string parent_identity = 2; //
string title = 3;
string cover_path = 4;
string intro=5;
string created_at = 6;
string updated_at = 7;
repeated CategoryItem data = 8;
}
message DeleteCategoryRequest{
string identity = 1; //
}

View File

@ -1,133 +0,0 @@
syntax = "proto3";
package content;
option go_package = "./;content";
import "blocks.proto";
//
service Post{
//
rpc PostList(PostListRequest) returns (PostListReply) {};
//
rpc GetPost (GetPostRequest) returns (PostItem) {};
//
rpc AddPost(PostItem) returns (StatusReply) {};
//
rpc ModifyPost(PostItem) returns (StatusReply) {};
//
rpc DeletePost(IdentRequest) returns (StatusReply) {};
//
rpc IncrPostLike(PostOpIdentityRequest) returns (StatusReply) {};
rpc DescPostLike(PostOpIdentityRequest) returns (StatusReply) {};
//
rpc IncrPostUnlike(PostOpIdentityRequest) returns (StatusReply) {};
rpc DescPostUnlike(PostOpIdentityRequest) returns (StatusReply) {};
//
rpc CommentList(CommentListRequest) returns (CommentListResponse) {};
//
rpc AddComment(CommentItem) returns (StatusReply) {};
//
rpc ModifyComment(CommentItem) returns (StatusReply) {};
//
rpc DeleteComment(DeleteCommentRequest) returns (StatusReply) {};
//
rpc IncrCommentLike(CommentOpIdentityRequest) returns (StatusReply) {};
rpc DescCommentLike(CommentOpIdentityRequest) returns (StatusReply) {};
//
rpc IncrCommentUnlike(CommentOpIdentityRequest) returns (StatusReply) {};
rpc DescCommentUnlike(CommentOpIdentityRequest) returns (StatusReply) {};
}
message DeleteCommentRequest{
string identity = 1; //
string post_identity = 2; //
}
message PostItem{
string identity = 1; //
int64 passport_id =2; // ID
string passport_identity =3; //
repeated string category_identity_list = 4; //Identity
repeated string tags_identity_list = 5; //
string title = 6;
string cover_path = 7; //
string author = 8;
string content = 9;
string target_url = 10;//
string source_url = 11; //
int64 hits = 12; //
repeated string accessory = 13; //
bool has_accessory = 14;//,
string created_at=15;
string updated_at=16;
string description = 17;//
int64 like_hits = 18; //
int64 unlike_hits = 19; //
int64 comment_hits = 20; //
int32 type = 22;//
string rights=23; //
}
message PostListRequest{
int64 page = 1; // ,
int64 size = 2; // ,10,50
string author_identity = 3; //,
string category_identity = 4; // ,
string keyword = 5;//
int32 type = 6;// ,,0,
}
message PostListReply{
repeated PostItem data = 1;
int64 count = 2;
}
message GetPostRequest {
string identity = 1; //
string author_identity = 2; //
}
message CommentItem {
string identity = 1;
string Post_identity = 2;
string parent_identity = 3;
string content = 4;
string reply_identity = 5;//
string created_at = 6;
string updated_at = 7;
repeated CommentItem list = 8;//
int64 like_hits = 9; //
int64 unlike_hits = 10; //
int64 comment_hits = 11; //
}
message CommentListRequest{
string Post_identity = 1;//
int64 page = 2; // ,
int64 size = 3; // ,10,50
}
message CommentListResponse{
repeated CommentItem list =1;
int64 count = 2;
}
message PostOpIdentityRequest{
string post_identity = 1; //
string op_identity = 2; //
}
message CommentOpIdentityRequest{
string comment_identity = 1; //
string op_identity = 2;//
}

23
proto/question.proto Normal file
View File

@ -0,0 +1,23 @@
syntax = "proto3";
package survey;
option go_package = ".;survey";
import "blocks.proto";
// -
service Question {
rpc Add (QuestionItem) returns (StatusReply);
rpc Update (QuestionItem) returns (StatusReply);
rpc Delete (IdentRequest) returns (StatusReply);
rpc Fetch (FetchRequest) returns (ListQuestionReply);
rpc BySurvey (BySurveyRequest) returns (ListQuestionReply);
}
message BySurveyRequest {
string survey_id = 1;
repeated string question_ids = 2; // ID
}
message ListQuestionReply {
repeated QuestionItem data = 1;
int64 count = 2;
}

15
proto/report.proto Normal file
View File

@ -0,0 +1,15 @@
syntax = "proto3";
package survey;
option go_package = ".;survey";
import "blocks.proto";
// -
service Report {
rpc GetSurveyStats (IdentRequest) returns (SurveyStats);
}
message SurveyStats {
string survey_id = 1;
int32 response_count = 2;
map<string, int64> question_stats = 3; // key为question_id
}

27
proto/share.proto Normal file
View File

@ -0,0 +1,27 @@
syntax = "proto3";
package survey;
option go_package = ".;survey";
import "blocks.proto";
// -
service Share {
rpc Create (IdentRequest) returns (StatusReply);
rpc Fetch (FetchRequest) returns (ListShareReply);
rpc SetStatus (StatusReply) returns (StatusReply);
}
message ListShareReply {
repeated ShareItem data = 1;
int64 count = 2;
}
//
message ShareItem {
string id = 1; // ID
string survey_id = 2; // ID
string url = 3; // URL
string creator_id = 4; // ID
int64 expires_at = 6; //
int32 max_responses = 7; // (0)
bool is_active = 8; //
}

18
proto/survey.proto Normal file
View File

@ -0,0 +1,18 @@
syntax = "proto3";
package survey;
option go_package = ".;survey";
import "blocks.proto";
// -
service Survey {
rpc Create (SurveyItem) returns (StatusReply);
rpc Get (IdentRequest) returns (SurveyItem);
rpc Update (SurveyItem) returns (StatusReply);
rpc Delete (IdentRequest) returns (StatusReply);
rpc Fetch (FetchRequest) returns (ListSurveyReply);
}
message ListSurveyReply {
repeated SurveyItem data = 1;
int64 count = 2;
}

View File

@ -1,34 +0,0 @@
syntax = "proto3";
package content;
option go_package = "./;content";
import "blocks.proto";
//
service Tags {
//
rpc TagsList (IdentRequest) returns (TagsListReply) {};
//
rpc AddTags(TagsItem) returns (StatusReply) {};
//
rpc ModifyTags(TagsItem) returns (StatusReply) {};
//
rpc DeleteTags(IdentRequest) returns (StatusReply) {};
}
//
message TagsItem{
string identity = 1;
string parent_identity = 2; //
string title = 3;
string cover_path = 4;
string intro=5;
repeated TagsItem list = 9;
}
message TagsListReply {
repeated TagsItem list = 1;
int64 count = 2;
}

View File

@ -1,33 +0,0 @@
// Code generated by protoc-gen-slc. DO NOT EDIT.
package server
import (
"context"
"protoc-gen-slc/internal/logic/category"
pb "protoc-gen-slc/pb"
)
type CategoryServer struct {
pb.UnimplementedCategoryServer
}
func NewCategoryServer() *CategoryServer {
return &CategoryServer{}
}
// 分类列表
func (s *CategoryServer) CategoryList(ctx context.Context, in *pb.Empty) (*pb.CategoryListReply, error) {
return category.CategoryList(ctx, in)
}
func (s *CategoryServer) AddCategory(ctx context.Context, in *pb.AddCategoryRequest) (*pb.AddCategoryResponse, error) {
return category.AddCategory(ctx, in)
}
func (s *CategoryServer) ModifyCategory(ctx context.Context, in *pb.ModifyCategoryRequest) (*pb.Empty, error) {
return category.ModifyCategory(ctx, in)
}
func (s *CategoryServer) DeleteCategory(ctx context.Context, in *pb.DeleteCategoryRequest) (*pb.Empty, error) {
return category.DeleteCategory(ctx, in)
}

View File

@ -1,21 +0,0 @@
// Code generated by protoc-gen-slc. DO NOT EDIT.
package server
import (
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
pb "protoc-gen-slc/pb"
)
func New() *grpc.Server {
srv := grpc.NewServer()
// register service to grpc.Server
pb.RegisterCategoryServer(srv, NewCategoryServer())
pb.RegisterPostServer(srv, NewPostServer())
pb.RegisterTagsServer(srv, NewTagsServer())
reflection.Register(srv)
return srv
}

View File

@ -1,97 +0,0 @@
// Code generated by protoc-gen-slc. DO NOT EDIT.
package server
import (
"context"
"protoc-gen-slc/internal/logic/post"
pb "protoc-gen-slc/pb"
)
type PostServer struct {
pb.UnimplementedPostServer
}
func NewPostServer() *PostServer {
return &PostServer{}
}
// 文章列表
func (s *PostServer) PostList(ctx context.Context, in *pb.PostListRequest) (*pb.PostListReply, error) {
return post.PostList(ctx, in)
}
// 获取文章详情
func (s *PostServer) GetPost(ctx context.Context, in *pb.GetPostRequest) (*pb.PostItem, error) {
return post.GetPost(ctx, in)
}
// 发布文章
func (s *PostServer) AddPost(ctx context.Context, in *pb.PostItem) (*pb.StatusReply, error) {
return post.AddPost(ctx, in)
}
// 修改文章
func (s *PostServer) ModifyPost(ctx context.Context, in *pb.PostItem) (*pb.StatusReply, error) {
return post.ModifyPost(ctx, in)
}
// 删除文章
func (s *PostServer) DeletePost(ctx context.Context, in *pb.IdentRequest) (*pb.StatusReply, error) {
return post.DeletePost(ctx, in)
}
// 文章点赞处理
func (s *PostServer) IncrPostLike(ctx context.Context, in *pb.PostOpIdentityRequest) (*pb.StatusReply, error) {
return post.IncrPostLike(ctx, in)
}
func (s *PostServer) DescPostLike(ctx context.Context, in *pb.PostOpIdentityRequest) (*pb.StatusReply, error) {
return post.DescPostLike(ctx, in)
}
// 文章点踩处理
func (s *PostServer) IncrPostUnlike(ctx context.Context, in *pb.PostOpIdentityRequest) (*pb.StatusReply, error) {
return post.IncrPostUnlike(ctx, in)
}
func (s *PostServer) DescPostUnlike(ctx context.Context, in *pb.PostOpIdentityRequest) (*pb.StatusReply, error) {
return post.DescPostUnlike(ctx, in)
}
// 评论列表
func (s *PostServer) CommentList(ctx context.Context, in *pb.CommentListRequest) (*pb.CommentListResponse, error) {
return post.CommentList(ctx, in)
}
// 发布评论
func (s *PostServer) AddComment(ctx context.Context, in *pb.CommentItem) (*pb.StatusReply, error) {
return post.AddComment(ctx, in)
}
// 修改评论
func (s *PostServer) ModifyComment(ctx context.Context, in *pb.CommentItem) (*pb.StatusReply, error) {
return post.ModifyComment(ctx, in)
}
// 删除评论
func (s *PostServer) DeleteComment(ctx context.Context, in *pb.DeleteCommentRequest) (*pb.StatusReply, error) {
return post.DeleteComment(ctx, in)
}
// 评论点赞处理
func (s *PostServer) IncrCommentLike(ctx context.Context, in *pb.CommentOpIdentityRequest) (*pb.StatusReply, error) {
return post.IncrCommentLike(ctx, in)
}
func (s *PostServer) DescCommentLike(ctx context.Context, in *pb.CommentOpIdentityRequest) (*pb.StatusReply, error) {
return post.DescCommentLike(ctx, in)
}
// 评论点踩处理
func (s *PostServer) IncrCommentUnlike(ctx context.Context, in *pb.CommentOpIdentityRequest) (*pb.StatusReply, error) {
return post.IncrCommentUnlike(ctx, in)
}
func (s *PostServer) DescCommentUnlike(ctx context.Context, in *pb.CommentOpIdentityRequest) (*pb.StatusReply, error) {
return post.DescCommentUnlike(ctx, in)
}

View File

@ -1,36 +0,0 @@
// Code generated by protoc-gen-slc. DO NOT EDIT.
package server
import (
"context"
"protoc-gen-slc/internal/logic/tags"
pb "protoc-gen-slc/pb"
)
type TagsServer struct {
pb.UnimplementedTagsServer
}
func NewTagsServer() *TagsServer {
return &TagsServer{}
}
// 标签列表
func (s *TagsServer) TagsList(ctx context.Context, in *pb.IdentRequest) (*pb.TagsListReply, error) {
return tags.TagsList(ctx, in)
}
// 创建标签
func (s *TagsServer) AddTags(ctx context.Context, in *pb.TagsItem) (*pb.StatusReply, error) {
return tags.AddTags(ctx, in)
}
// 修改标签
func (s *TagsServer) ModifyTags(ctx context.Context, in *pb.TagsItem) (*pb.StatusReply, error) {
return tags.ModifyTags(ctx, in)
}
// 删除标签
func (s *TagsServer) DeleteTags(ctx context.Context, in *pb.IdentRequest) (*pb.StatusReply, error) {
return tags.DeleteTags(ctx, in)
}

23
tpl/logic.go Normal file
View File

@ -0,0 +1,23 @@
package tpl
var LogicFile = `package {methodName}
import (
"context"
{import}
"git.apinb.com/bsm-sdk/core/service"
)
{comment}
func {func}(ctx context.Context, in *pb.{input}) (reply *pb.{output},err error) {
// parse authorization meta.
_, err = service.ParseMetaCtx(ctx, nil)
if err != nil {
return nil, err
}
// TODO: add your logic code & delete this line.
return
}
`

View File

@ -5,22 +5,59 @@ var NewFile = `
package server
import (
"context"
"net/http"
"os"
"strings"
{import}
"git.apinb.com/bsm-sdk/core/vars"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
gwRuntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
)
func New() *grpc.Server {
srv := grpc.NewServer()
type Server struct {
Grpc *grpc.Server
Ctx context.Context
Mux *gwRuntime.ServeMux
}
func New(addr string) *Server {
srv := &Server{Ctx: context.Background(), Grpc: grpc.NewServer(), Mux: gwRuntime.NewServeMux()}
// register service to grpc.Server
{register}
reflection.Register(srv)
reflection.Register(srv.Grpc)
// 将服务注册到Gateway
opts := []grpc.DialOption{grpc.WithInsecure()}
{gw}
// Register services swagger
srv.RegisterSwagger()
return srv
}
// RegisterSwagger 注册swagger
func (s *Server) RegisterSwagger() {
srvKey := strings.ToLower(vars.ServiceKey)
s.Mux.HandlePath("GET", "/"+srvKey+".swagger.json", func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) {
w.Header().Set("Content-Type", "application/json")
bytes, err := os.ReadFile("./swagger/" + srvKey + ".swagger.json")
if err != nil {
w.WriteHeader(http.StatusNotFound)
w.Write([]byte(err.Error()))
return
}
w.Write(bytes)
return
})
}
`
var Server = `