diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..7b71657
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/proto.iml b/.idea/proto.iml
new file mode 100644
index 0000000..5e764c4
--- /dev/null
+++ b/.idea/proto.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..e03dad9
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 0e2dca3..95ffd3c 100644
--- a/README.md
+++ b/README.md
@@ -3,11 +3,24 @@
#### 介绍
公共协议, 每个服务需要git submodule 拉 xxx/proto 目录下. 然后使用序列.
+```
+安装protoc protoc-25.0-linux-x86_64.zip
+```
+
```bash
-git submodule add https://gitee.com/fusenpack/proto
+# 去掉SUMDB的验证
+go env -w GOSUMDB="off"
+
+git submodule add git@gitlab.fusenpack.com:backend/proto.git
```
然后执行
```bash
+go install \
+github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
+github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
+google.golang.org/protobuf/cmd/protoc-gen-go \
+google.golang.org/grpc/cmd/protoc-gen-go-grpc
+
go run proto/goutils/proto_build/main.go
或者
在proto/goutils/proto_build/main_test.go执行测试 TestMain
@@ -15,6 +28,8 @@ go run proto/goutils/proto_build/main.go
./update_fspkg_master.sh # 执行更新最新的包
```
+
+
#### 软件架构
软件架构说明
diff --git a/goutils/proto_build/main.go b/goutils/proto_build/main.go
index e0364bc..d29109b 100644
--- a/goutils/proto_build/main.go
+++ b/goutils/proto_build/main.go
@@ -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)
})
@@ -1265,6 +1271,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)
diff --git a/goutils/proto_build/tpls/main.tpl b/goutils/proto_build/tpls/main.tpl
index 4d41cf4..e97338e 100644
--- a/goutils/proto_build/tpls/main.tpl
+++ b/goutils/proto_build/tpls/main.tpl
@@ -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)
diff --git a/goutils/proto_build/tpls/main_gen.tpl b/goutils/proto_build/tpls/main_gen.tpl
new file mode 100644
index 0000000..02f5bf4
--- /dev/null
+++ b/goutils/proto_build/tpls/main_gen.tpl
@@ -0,0 +1,16 @@
+package main
+
+import (
+ "{{.ProjectName}}/gen/go/service"
+ {{range .StructServiceNames}}
+ "{{$.ProjectName}}/server/logics/{{.LogicPackageName}}"
+ {{- end}}
+
+ "google.golang.org/grpc"
+)
+
+func MainRegisterServer(s *grpc.Server) {
+ {{range .StructServiceNames}}
+ service.Register{{.StructServiceName}}Server(s, &{{.LogicPackageName}}.{{.StructServiceName}}LogicGrpc{}) // {{.LogicPackageName}} 服务注册
+ {{- end}}
+}
diff --git a/service/fsservice.proto b/service/fsservice.proto
index 13e0442..e305606 100644
--- a/service/fsservice.proto
+++ b/service/fsservice.proto
@@ -1,8 +1,8 @@
syntax = "proto3"; //版本声明,使用v3版本
package fsservice;
-option go_package = "gitlab.fusenpack.com/backend/service;service";
-
+option go_package = "gitee.com/fusenpack/fusen-service;service";
+
// 导入google/api/annotations.proto 注释依赖
import "google/api/annotations.proto";
import "service/basic.proto";
@@ -11,7 +11,7 @@ import "google/protobuf/any.proto";
//定义服务
-service info {
+service info {
// 用户信息
rpc UserInfo(UserInfoRequest) returns (basic.Response) {
option (google.api.http) = {
@@ -124,6 +124,21 @@ service info {
}
+//定义产品服务
+service product {
+ // 产品详情
+ rpc GetProductDetail(GetProductDetailReq) returns (basic.Response) {
+ option (google.api.http) = {
+ get: "/api/product/get_product_detail"
+ };
+ }
+ //获取产品列表
+ rpc GetProductList(GetProductListReq) returns (basic.Response) {
+ option (google.api.http) = {
+ get: "/api/product/tag_product_list"
+ };
+ }
+}
message UserInfoRequest {
repeated string module = 1; // 模块
@@ -134,7 +149,7 @@ message QueryProfileRequest {
}
message QueryProfileResponse {
- google.protobuf.Struct data = 1;
+ google.protobuf.Struct data = 1;
}
message DefaultProfileRequest {
@@ -213,4 +228,17 @@ message ContactUsRequest {
string message = 4; // 消息内容
}
-
+//获取产品详情
+message GetProductDetailReq{
+ int64 product_id = 1;
+ string template_tag = 2;
+ int64 selected_color_index = 3;
+ string logo = 4;
+}
+//获取产品列表
+message GetProductListReq{
+ int64 basic_tag_id = 1; //传入则以该分类为最高层分类查询
+ int64 merchant_type = 2; //商户类型
+ string template_tag = 3; //模板标签
+ bool with_product = 4; //是否携带分类下的产品
+}
\ No newline at end of file
diff --git a/service/resource.proto b/service/resource.proto
new file mode 100644
index 0000000..e65d416
--- /dev/null
+++ b/service/resource.proto
@@ -0,0 +1,59 @@
+syntax = "proto3"; //版本声明,使用v3版本
+
+package resource;
+option go_package = "gitlab.fusenpack.com/backend/resource;service";
+
+// 导入google/api/annotations.proto 注释依赖
+import "google/api/annotations.proto";
+import "service/basic.proto";
+import "google/protobuf/struct.proto";
+import "google/protobuf/any.proto";
+
+//定义服务
+service resource {
+
+ // 获取资源详情
+ rpc GetResourceInfo(GetResourceInfoReq) returns (basic.Response) {
+ option (google.api.http) = {
+ get: "/api/resource/info"
+ };
+ }
+
+ // 获取资源列表
+ rpc GetResourceList(GetResourceListReq) returns (basic.Response) {
+ option (google.api.http) = {
+ get: "/api/resource/list"
+ };
+ }
+}
+/* 获取资源列表 */
+message GetResourceListReq{
+ optional string resource_id = 1;
+ optional int64 guest_id =2;
+ optional int64 user_id =3;
+ optional string resource_type = 4;
+ optional string resource_url = 5;
+ optional string version = 6;
+ optional int64 api_type = 7;
+ optional string bucket_name = 8;
+ optional string source = 9;
+
+ optional int64 current_page =101;
+ optional int64 per_page =102;
+ optional string order_by = 103;
+}
+/* 获取资源列表 */
+
+/* 获取资源详情 */
+message GetResourceInfoReq{
+ optional string resource_id = 1;
+ optional int64 guest_id =2;
+ optional int64 user_id =3;
+ optional string resource_type = 4;
+ optional string resource_url = 5;
+ optional string version = 6;
+ optional int64 api_type = 7;
+ optional string bucket_name = 8;
+ optional string source = 9;
+}
+/* 获取资源详情 */
\ No newline at end of file