Merge branch 'master' of gitlab.fusenpack.com:backend/proto

This commit is contained in:
menghaiwen@fusen.cn 2023-12-04 18:29:05 +08:00
commit 32e5d9424f
4 changed files with 105 additions and 6 deletions

View File

@ -267,6 +267,12 @@ func ExecCreateAutoLogic(workerSpaceDir string, ServiceName string, genDir, pack
// 处理main.go文件
defer func() {
// name := underscoreToLowerCamelCase(ServiceName)
// name := underscoreToLowerCamelCase(ServiceName)
createFile("server/main_gen.go", func(f io.Writer) error {
return tpl.ExecuteTemplate(f, "main_gen.tpl", mtpl)
})
createFileWithPermNotExists("server/main.go", func(f io.Writer) error {
return tpl.ExecuteTemplate(f, "main.tpl", mtpl)
})
@ -1246,6 +1252,34 @@ func _getTypeString(expr ast.Expr, packageName *string, level int) string {
}
}
func createFile(filename string, do func(f io.Writer) error) error {
// 检测文件是否存在
file, err := os.OpenFile(filename, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
if err != nil {
return err
}
defer file.Close()
var buf = bytes.NewBuffer(nil)
err = do(buf)
if err != nil {
panic(err)
}
data, err := format.Source(buf.Bytes())
if err != nil {
_, err = file.Write(buf.Bytes())
} else {
_, err = file.Write(data)
}
if err != nil {
panic(err)
}
return nil
}
func createFileWithPermNotExists(filename string, do func(f io.Writer) error) error {
// 检测文件是否存在
_, err := os.Stat(filename)

View File

@ -30,9 +30,8 @@ func main() {
log.Fatalf("failed to listen: %v", err)
}
s := grpc.NewServer(sopt) //新建一个grpc服务
{{range .StructServiceNames}}
service.Register{{.StructServiceName}}Server(s, &{{.LogicPackageName}}.{{.StructServiceName}}LogicGrpc{}) // {{.LogicPackageName}} 服务注册
{{- end}}
MainRegisterServer(s) // 注册所有的service
if err := s.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)

View File

@ -0,0 +1,15 @@
package main
import (
"{{.ProjectName}}/gen/go/service"
"{{.ProjectName}}/server/logics/info_logic"
"{{.ProjectName}}/server/logics/product_logic"
"google.golang.org/grpc"
)
func MainRegisterServer(s *grpc.Server) {
{{range .StructServiceNames}}
service.Register{{.StructServiceName}}Server(s, &{{.LogicPackageName}}.{{.StructServiceName}}LogicGrpc{}) // {{.LogicPackageName}} 服务注册
{{- end}}
}

View File

@ -128,7 +128,7 @@ service product {
//
rpc GetProductDetail(GetProductDetailReq) returns (GetProductDetailRsp) {
option (google.api.http) = {
get: "/api/product/detail"
get: "/api/product/get_product_detail"
};
}
}
@ -221,14 +221,65 @@ message ContactUsRequest {
string message = 4; //
}
//
message GetProductDetailReq{
int64 product_id = 1;
string template_tag = 2;
int64 selected_color_index = 3;
string logo = 4;
}
message GetProductDetailRsp{
string msg = 1;
message GetProductDetailRsp {
string logo = 1; //logo
TemplateTagColorInfo template_tag_color_info = 2; //
ProductInfo product_info = 3; //
google.protobuf.Struct base_colors = 4; //
repeated SizeInfo size_list = 5; //
}
message SizeInfo {
int64 id =1; //id
int64 is_default = 2; //
google.protobuf.Struct title = 3; //
string capacity = 4; //
int64 parts_can_deleted = 5; //
int64 is_hot = 6; //
string min_price = 7; //
google.protobuf.Struct template_info = 8; //
ModelInfo model_info = 9; //
repeated FittingInfo fitting_list = 10; //
}
message FittingInfo {
int64 id = 1; //id
int64 is_hot = 2; //
string material_image = 3;//
google.protobuf.Struct design_info = 4; //
string price = 5; //
string name = 6; //
int64 is_default = 7; //
}
message ModelInfo {
int64 id = 1; //id
google.protobuf.Struct design_info = 2; //
LightInfo light_info = 3; //
}
message LightInfo {
int64 id = 1; //id
google.protobuf.Struct light_design_info = 2; //
}
message ProductInfo {
int64 id = 1; //id
string description = 2; //
int64 product_type = 3; //id
string product_type_name = 4;//
string title = 5; //
int64 is_env = 6; //
int64 is_micro = 7; //
int64 is_customization = 8; //
google.protobuf.Struct website_unit = 9; //
}
message TemplateTagColorInfo {
google.protobuf.Struct colors = 1; //logo对应的算法颜色组
int64 selected_color_index = 2; //
google.protobuf.Struct template_tag_groups = 3; //
}