Merge branch 'master' of gitlab.fusenpack.com:backend/proto
This commit is contained in:
commit
32e5d9424f
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
15
goutils/proto_build/tpls/main_gen.tpl
Normal file
15
goutils/proto_build/tpls/main_gen.tpl
Normal 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}}
|
||||
}
|
|
@ -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; //模板标签分组信息
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user