From 8c986e1342a2efde9d05dee5df0f9299ba10c139 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期六, 26 八月 2023 17:14:08 +0800
Subject: [PATCH] add
---
proto/user/user.pb.go | 332 ++++++++++
api/v1/test/enter.go | 1
service/test/member.go | 76 ++
router/test/enter.go | 1
model/test/request/member.go | 14
config.yaml | 1
docs/swagger.yaml | 245 +++++++
api/v1/test/product.go | 15
config/system.go | 1
docs/docs.go | 392 +++++++++++
proto/user/user_grpc.pb.go | 101 +++
docs/swagger.json | 392 +++++++++++
service/test/enter.go | 1
proto/user.proto | 30
model/test/member.go | 19
api/v1/test/member.go | 235 +++++++
router/test/member.go | 28
initialize/router.go | 1
model/test/supplier.go | 30
initialize/gorm.go | 8
20 files changed, 1,881 insertions(+), 42 deletions(-)
diff --git a/api/v1/test/enter.go b/api/v1/test/enter.go
index b73c8f6..b0f6dc2 100644
--- a/api/v1/test/enter.go
+++ b/api/v1/test/enter.go
@@ -6,4 +6,5 @@
SupplierApi
ContractApi
ProductApi
+ MemberApi
}
diff --git a/api/v1/test/member.go b/api/v1/test/member.go
new file mode 100644
index 0000000..f0af64d
--- /dev/null
+++ b/api/v1/test/member.go
@@ -0,0 +1,235 @@
+package test
+
+import (
+ "github.com/gin-gonic/gin"
+ "go.uber.org/zap"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/credentials/insecure"
+ "srm/global"
+ "srm/model/common/request"
+ "srm/model/common/response"
+ "srm/model/test"
+ testReq "srm/model/test/request"
+ "srm/proto/user"
+ "srm/service"
+)
+
+type MemberApi struct {
+}
+
+var mService = service.ServiceGroupApp.TestServiceGroup.MemberService
+
+// CreateMember 鍒涘缓Member
+// @Tags Member
+// @Summary 鍒涘缓Member
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body test.Member true "鍒涘缓Member"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}"
+// @Router /m/createMember [post]
+func (mApi *MemberApi) CreateMember(c *gin.Context) {
+ var m test.Member
+ err := c.ShouldBindJSON(&m)
+ if err != nil {
+ response.FailWithMessage(err.Error(), c)
+ return
+ }
+ if err := mService.CreateMember(&m); err != nil {
+ global.GVA_LOG.Error("鍒涘缓澶辫触!", zap.Error(err))
+ response.FailWithMessage("鍒涘缓澶辫触", c)
+ } else {
+ response.OkWithMessage("鍒涘缓鎴愬姛", c)
+ }
+}
+
+// DeleteMember 鍒犻櫎Member
+// @Tags Member
+// @Summary 鍒犻櫎Member
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body test.Member true "鍒犻櫎Member"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"鍒犻櫎鎴愬姛"}"
+// @Router /m/deleteMember [delete]
+func (mApi *MemberApi) DeleteMember(c *gin.Context) {
+ var m test.Member
+ err := c.ShouldBindJSON(&m)
+ if err != nil {
+ response.FailWithMessage(err.Error(), c)
+ return
+ }
+ if err := mService.DeleteMember(m); err != nil {
+ global.GVA_LOG.Error("鍒犻櫎澶辫触!", zap.Error(err))
+ response.FailWithMessage("鍒犻櫎澶辫触", c)
+ } else {
+ response.OkWithMessage("鍒犻櫎鎴愬姛", c)
+ }
+}
+
+// DeleteMemberByIds 鎵归噺鍒犻櫎Member
+// @Tags Member
+// @Summary 鎵归噺鍒犻櫎Member
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body request.IdsReq true "鎵归噺鍒犻櫎Member"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"鎵归噺鍒犻櫎鎴愬姛"}"
+// @Router /m/deleteMemberByIds [delete]
+func (mApi *MemberApi) DeleteMemberByIds(c *gin.Context) {
+ var IDS request.IdsReq
+ err := c.ShouldBindJSON(&IDS)
+ if err != nil {
+ response.FailWithMessage(err.Error(), c)
+ return
+ }
+ if err := mService.DeleteMemberByIds(IDS); err != nil {
+ global.GVA_LOG.Error("鎵归噺鍒犻櫎澶辫触!", zap.Error(err))
+ response.FailWithMessage("鎵归噺鍒犻櫎澶辫触", c)
+ } else {
+ response.OkWithMessage("鎵归噺鍒犻櫎鎴愬姛", c)
+ }
+}
+
+// UpdateMember 鏇存柊Member
+// @Tags Member
+// @Summary 鏇存柊Member
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body test.Member true "鏇存柊Member"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"鏇存柊鎴愬姛"}"
+// @Router /m/updateMember [put]
+func (mApi *MemberApi) UpdateMember(c *gin.Context) {
+ var m test.Member
+ err := c.ShouldBindJSON(&m)
+ if err != nil {
+ response.FailWithMessage(err.Error(), c)
+ return
+ }
+ if err := mService.UpdateMember(m); err != nil {
+ global.GVA_LOG.Error("鏇存柊澶辫触!", zap.Error(err))
+ response.FailWithMessage("鏇存柊澶辫触", c)
+ } else {
+ response.OkWithMessage("鏇存柊鎴愬姛", c)
+ }
+}
+
+// FindMember 鐢╥d鏌ヨMember
+// @Tags Member
+// @Summary 鐢╥d鏌ヨMember
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data query test.Member true "鐢╥d鏌ヨMember"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"鏌ヨ鎴愬姛"}"
+// @Router /m/findMember [get]
+func (mApi *MemberApi) FindMember(c *gin.Context) {
+ var m test.Member
+ err := c.ShouldBindQuery(&m)
+ if err != nil {
+ response.FailWithMessage(err.Error(), c)
+ return
+ }
+ if rem, err := mService.GetMember(m.ID); err != nil {
+ global.GVA_LOG.Error("鏌ヨ澶辫触!", zap.Error(err))
+ response.FailWithMessage("鏌ヨ澶辫触", c)
+ } else {
+ response.OkWithData(gin.H{"rem": rem}, c)
+ }
+}
+
+// GetMemberList 鍒嗛〉鑾峰彇Member鍒楄〃
+// @Tags Member
+// @Summary 鍒嗛〉鑾峰彇Member鍒楄〃
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data query testReq.MemberSearch true "鍒嗛〉鑾峰彇Member鍒楄〃"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}"
+// @Router /m/getMemberList [get]
+func (mApi *MemberApi) GetMemberList(c *gin.Context) {
+ var pageInfo testReq.MemberSearch
+ err := c.ShouldBindQuery(&pageInfo)
+ if err != nil {
+ response.FailWithMessage(err.Error(), c)
+ return
+ }
+ if list, total, err := mService.GetMemberInfoList(pageInfo); err != nil {
+ global.GVA_LOG.Error("鑾峰彇澶辫触!", zap.Error(err))
+ response.FailWithMessage("鑾峰彇澶辫触", c)
+ } else {
+ response.OkWithDetailed(response.PageResult{
+ List: list,
+ Total: total,
+ Page: pageInfo.Page,
+ PageSize: pageInfo.PageSize,
+ }, "鑾峰彇鎴愬姛", c)
+ }
+}
+
+var (
+ userConn *grpc.ClientConn
+)
+
+func InitUserConn() {
+ var err error
+ userConn, err = grpc.Dial(global.GVA_CONFIG.System.GrpcAdminUrl, grpc.WithTransportCredentials(insecure.NewCredentials()))
+ if err != nil {
+ //logx.Errorf("grpc dial user service error: %v", err.Error())
+ return
+ }
+}
+
+func CloseUserConn() {
+ if userConn != nil {
+ userConn.Close()
+ }
+}
+
+// GetMemberListFromGrpc 鍒嗛〉鑾峰彇Member鍒楄〃
+// @Tags Member
+// @Summary 鍒嗛〉鑾峰彇Member鍒楄〃
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data query testReq.MemberSearch true "鍒嗛〉鑾峰彇Member鍒楄〃"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}"
+// @Router /m/getMemberListFromGrpc [get]
+func (mApi *MemberApi) GetMemberListFromGrpc(c *gin.Context) {
+ var pageInfo testReq.MemberSearch
+ err := c.ShouldBindQuery(&pageInfo)
+ if err != nil {
+ response.FailWithMessage(err.Error(), c)
+ return
+ }
+ InitUserConn()
+ defer CloseUserConn()
+
+ cli := user.NewUserServiceClient(userConn)
+ var users []*user.User
+ getMemberListResponse, err := cli.SyncUser(c, &user.UserRequest{Users: users})
+
+ rawMemberList := getMemberListResponse.List
+ memberList := make([]*test.Member, len(rawMemberList))
+
+ for i, member := range rawMemberList {
+ memberList[i] = &test.Member{
+ Uuid: member.Uuid,
+ UserName: member.Username,
+ Nickname: member.Nickname,
+ }
+ }
+
+ if err != nil || len(memberList) == 0 {
+ global.GVA_LOG.Error("鑾峰彇澶辫触!", zap.Error(err))
+ response.FailWithMessage("鑾峰彇澶辫触", c)
+ } else {
+ response.OkWithDetailed(response.PageResult{
+ List: memberList,
+ Total: int64(len(memberList)),
+ Page: pageInfo.Page,
+ PageSize: pageInfo.PageSize,
+ }, "鑾峰彇鎴愬姛", c)
+ }
+}
diff --git a/api/v1/test/product.go b/api/v1/test/product.go
index da50427..46bf465 100644
--- a/api/v1/test/product.go
+++ b/api/v1/test/product.go
@@ -229,14 +229,13 @@
if err != nil || getProductListResponse.Code != 0 {
global.GVA_LOG.Error("鑾峰彇澶辫触!", zap.Error(err))
response.FailWithMessage("鑾峰彇澶辫触", c)
- return
+ } else {
+ response.OkWithDetailed(response.PageResult{
+ List: productList,
+ Total: int64(len(productList)),
+ Page: pageInfo.Page,
+ PageSize: pageInfo.PageSize,
+ }, "鑾峰彇鎴愬姛", c)
}
-
- response.OkWithDetailed(response.PageResult{
- List: productList,
- Total: int64(len(productList)),
- Page: pageInfo.Page,
- PageSize: pageInfo.PageSize,
- }, "鑾峰彇鎴愬姛", c)
}
diff --git a/config.yaml b/config.yaml
index 56e2f29..030fd5f 100644
--- a/config.yaml
+++ b/config.yaml
@@ -183,6 +183,7 @@
use-multipoint: false
use-redis: false
grpc-url: 192.168.20.119:9091
+ grpc-admin-url: 192.168.20.119:50051
tencent-cos:
bucket: xxxxx-10005608
region: ap-shanghai
diff --git a/config/system.go b/config/system.go
index 6f35d0a..0f99af3 100644
--- a/config/system.go
+++ b/config/system.go
@@ -11,4 +11,5 @@
UseMultipoint bool `mapstructure:"use-multipoint" json:"use-multipoint" yaml:"use-multipoint"` // 澶氱偣鐧诲綍鎷︽埅
UseRedis bool `mapstructure:"use-redis" json:"use-redis" yaml:"use-redis"` // 浣跨敤redis
GrpcUrl string `mapstructure:"grpc-url" json:"grpc-url" yaml:"grpc-url"` // grpc鏈嶅姟鍦板潃
+ GrpcAdminUrl string `mapstructure:"grpc-admin-url" json:"grpc-admin-url" yaml:"grpc-admin-url"` // grpc鏈嶅姟鍦板潃
}
diff --git a/docs/docs.go b/docs/docs.go
index 9eb2c74..c33ff8e 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -3140,6 +3140,364 @@
}
}
},
+ "/m/createMember": {
+ "post": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Member"
+ ],
+ "summary": "鍒涘缓Member",
+ "parameters": [
+ {
+ "description": "鍒涘缓Member",
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/test.Member"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "{\"success\":true,\"data\":{},\"msg\":\"鑾峰彇鎴愬姛\"}",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/m/deleteMember": {
+ "delete": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Member"
+ ],
+ "summary": "鍒犻櫎Member",
+ "parameters": [
+ {
+ "description": "鍒犻櫎Member",
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/test.Member"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "{\"success\":true,\"data\":{},\"msg\":\"鍒犻櫎鎴愬姛\"}",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/m/deleteMemberByIds": {
+ "delete": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Member"
+ ],
+ "summary": "鎵归噺鍒犻櫎Member",
+ "parameters": [
+ {
+ "description": "鎵归噺鍒犻櫎Member",
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.IdsReq"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "{\"success\":true,\"data\":{},\"msg\":\"鎵归噺鍒犻櫎鎴愬姛\"}",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/m/findMember": {
+ "get": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Member"
+ ],
+ "summary": "鐢╥d鏌ヨMember",
+ "parameters": [
+ {
+ "type": "integer",
+ "description": "涓婚敭ID",
+ "name": "id",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "nickname",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "userName",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "uuid",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "{\"success\":true,\"data\":{},\"msg\":\"鏌ヨ鎴愬姛\"}",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/m/getMemberList": {
+ "get": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Member"
+ ],
+ "summary": "鍒嗛〉鑾峰彇Member鍒楄〃",
+ "parameters": [
+ {
+ "type": "string",
+ "name": "endCreatedAt",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "涓婚敭ID",
+ "name": "id",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "description": "鍏抽敭瀛�",
+ "name": "keyword",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "nickname",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "椤电爜",
+ "name": "page",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "姣忛〉澶у皬",
+ "name": "pageSize",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "startCreatedAt",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "userName",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "uuid",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "{\"success\":true,\"data\":{},\"msg\":\"鑾峰彇鎴愬姛\"}",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/m/getMemberListFromGrpc": {
+ "get": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Member"
+ ],
+ "summary": "鍒嗛〉鑾峰彇Member鍒楄〃",
+ "parameters": [
+ {
+ "type": "string",
+ "name": "endCreatedAt",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "涓婚敭ID",
+ "name": "id",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "description": "鍏抽敭瀛�",
+ "name": "keyword",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "nickname",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "椤电爜",
+ "name": "page",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "姣忛〉澶у皬",
+ "name": "pageSize",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "startCreatedAt",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "userName",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "uuid",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "{\"success\":true,\"data\":{},\"msg\":\"鑾峰彇鎴愬姛\"}",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/m/updateMember": {
+ "put": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Member"
+ ],
+ "summary": "鏇存柊Member",
+ "parameters": [
+ {
+ "description": "鏇存柊Member",
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/test.Member"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "{\"success\":true,\"data\":{},\"msg\":\"鏇存柊鎴愬姛\"}",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
"/menu/addBaseMenu": {
"post": {
"security": [
@@ -4325,8 +4683,8 @@
"in": "query"
},
{
- "type": "integer",
- "name": "responsiblePersonId",
+ "type": "string",
+ "name": "responsiblePersonName",
"in": "query"
},
{
@@ -4458,8 +4816,8 @@
"in": "query"
},
{
- "type": "integer",
- "name": "responsiblePersonId",
+ "type": "string",
+ "name": "responsiblePersonName",
"in": "query"
},
{
@@ -7221,6 +7579,10 @@
"description": "鐜鍊�",
"type": "string"
},
+ "grpc-admin-url": {
+ "description": "grpc鏈嶅姟鍦板潃",
+ "type": "string"
+ },
"grpc-url": {
"description": "grpc鏈嶅姟鍦板潃",
"type": "string"
@@ -8671,6 +9033,24 @@
}
}
},
+ "test.Member": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "description": "涓婚敭ID",
+ "type": "integer"
+ },
+ "nickname": {
+ "type": "string"
+ },
+ "userName": {
+ "type": "string"
+ },
+ "uuid": {
+ "type": "string"
+ }
+ }
+ },
"test.Product": {
"type": "object",
"properties": {
@@ -8759,8 +9139,8 @@
"phone": {
"type": "string"
},
- "responsiblePersonId": {
- "type": "integer"
+ "responsiblePersonName": {
+ "type": "string"
},
"status": {
"type": "integer"
diff --git a/docs/swagger.json b/docs/swagger.json
index e512ffe..ea17b2e 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -3131,6 +3131,364 @@
}
}
},
+ "/m/createMember": {
+ "post": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Member"
+ ],
+ "summary": "鍒涘缓Member",
+ "parameters": [
+ {
+ "description": "鍒涘缓Member",
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/test.Member"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "{\"success\":true,\"data\":{},\"msg\":\"鑾峰彇鎴愬姛\"}",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/m/deleteMember": {
+ "delete": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Member"
+ ],
+ "summary": "鍒犻櫎Member",
+ "parameters": [
+ {
+ "description": "鍒犻櫎Member",
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/test.Member"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "{\"success\":true,\"data\":{},\"msg\":\"鍒犻櫎鎴愬姛\"}",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/m/deleteMemberByIds": {
+ "delete": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Member"
+ ],
+ "summary": "鎵归噺鍒犻櫎Member",
+ "parameters": [
+ {
+ "description": "鎵归噺鍒犻櫎Member",
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.IdsReq"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "{\"success\":true,\"data\":{},\"msg\":\"鎵归噺鍒犻櫎鎴愬姛\"}",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/m/findMember": {
+ "get": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Member"
+ ],
+ "summary": "鐢╥d鏌ヨMember",
+ "parameters": [
+ {
+ "type": "integer",
+ "description": "涓婚敭ID",
+ "name": "id",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "nickname",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "userName",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "uuid",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "{\"success\":true,\"data\":{},\"msg\":\"鏌ヨ鎴愬姛\"}",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/m/getMemberList": {
+ "get": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Member"
+ ],
+ "summary": "鍒嗛〉鑾峰彇Member鍒楄〃",
+ "parameters": [
+ {
+ "type": "string",
+ "name": "endCreatedAt",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "涓婚敭ID",
+ "name": "id",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "description": "鍏抽敭瀛�",
+ "name": "keyword",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "nickname",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "椤电爜",
+ "name": "page",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "姣忛〉澶у皬",
+ "name": "pageSize",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "startCreatedAt",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "userName",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "uuid",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "{\"success\":true,\"data\":{},\"msg\":\"鑾峰彇鎴愬姛\"}",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/m/getMemberListFromGrpc": {
+ "get": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Member"
+ ],
+ "summary": "鍒嗛〉鑾峰彇Member鍒楄〃",
+ "parameters": [
+ {
+ "type": "string",
+ "name": "endCreatedAt",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "涓婚敭ID",
+ "name": "id",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "description": "鍏抽敭瀛�",
+ "name": "keyword",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "nickname",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "椤电爜",
+ "name": "page",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "姣忛〉澶у皬",
+ "name": "pageSize",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "startCreatedAt",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "userName",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "uuid",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "{\"success\":true,\"data\":{},\"msg\":\"鑾峰彇鎴愬姛\"}",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "/m/updateMember": {
+ "put": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Member"
+ ],
+ "summary": "鏇存柊Member",
+ "parameters": [
+ {
+ "description": "鏇存柊Member",
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/test.Member"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "{\"success\":true,\"data\":{},\"msg\":\"鏇存柊鎴愬姛\"}",
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
"/menu/addBaseMenu": {
"post": {
"security": [
@@ -4316,8 +4674,8 @@
"in": "query"
},
{
- "type": "integer",
- "name": "responsiblePersonId",
+ "type": "string",
+ "name": "responsiblePersonName",
"in": "query"
},
{
@@ -4449,8 +4807,8 @@
"in": "query"
},
{
- "type": "integer",
- "name": "responsiblePersonId",
+ "type": "string",
+ "name": "responsiblePersonName",
"in": "query"
},
{
@@ -7212,6 +7570,10 @@
"description": "鐜鍊�",
"type": "string"
},
+ "grpc-admin-url": {
+ "description": "grpc鏈嶅姟鍦板潃",
+ "type": "string"
+ },
"grpc-url": {
"description": "grpc鏈嶅姟鍦板潃",
"type": "string"
@@ -8662,6 +9024,24 @@
}
}
},
+ "test.Member": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "description": "涓婚敭ID",
+ "type": "integer"
+ },
+ "nickname": {
+ "type": "string"
+ },
+ "userName": {
+ "type": "string"
+ },
+ "uuid": {
+ "type": "string"
+ }
+ }
+ },
"test.Product": {
"type": "object",
"properties": {
@@ -8750,8 +9130,8 @@
"phone": {
"type": "string"
},
- "responsiblePersonId": {
- "type": "integer"
+ "responsiblePersonName": {
+ "type": "string"
},
"status": {
"type": "integer"
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 204a2ff..e6a9835 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -510,6 +510,9 @@
env:
description: 鐜鍊�
type: string
+ grpc-admin-url:
+ description: grpc鏈嶅姟鍦板潃
+ type: string
grpc-url:
description: grpc鏈嶅姟鍦板潃
type: string
@@ -1512,6 +1515,18 @@
name:
type: string
type: object
+ test.Member:
+ properties:
+ id:
+ description: 涓婚敭ID
+ type: integer
+ nickname:
+ type: string
+ userName:
+ type: string
+ uuid:
+ type: string
+ type: object
test.Product:
properties:
deliveryTime:
@@ -1571,8 +1586,8 @@
type: string
phone:
type: string
- responsiblePersonId:
- type: integer
+ responsiblePersonName:
+ type: string
status:
type: integer
supplierType:
@@ -3390,6 +3405,224 @@
summary: jwt鍔犲叆榛戝悕鍗�
tags:
- Jwt
+ /m/createMember:
+ post:
+ consumes:
+ - application/json
+ parameters:
+ - description: 鍒涘缓Member
+ in: body
+ name: data
+ required: true
+ schema:
+ $ref: '#/definitions/test.Member'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: '{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}'
+ schema:
+ type: string
+ security:
+ - ApiKeyAuth: []
+ summary: 鍒涘缓Member
+ tags:
+ - Member
+ /m/deleteMember:
+ delete:
+ consumes:
+ - application/json
+ parameters:
+ - description: 鍒犻櫎Member
+ in: body
+ name: data
+ required: true
+ schema:
+ $ref: '#/definitions/test.Member'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: '{"success":true,"data":{},"msg":"鍒犻櫎鎴愬姛"}'
+ schema:
+ type: string
+ security:
+ - ApiKeyAuth: []
+ summary: 鍒犻櫎Member
+ tags:
+ - Member
+ /m/deleteMemberByIds:
+ delete:
+ consumes:
+ - application/json
+ parameters:
+ - description: 鎵归噺鍒犻櫎Member
+ in: body
+ name: data
+ required: true
+ schema:
+ $ref: '#/definitions/request.IdsReq'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: '{"success":true,"data":{},"msg":"鎵归噺鍒犻櫎鎴愬姛"}'
+ schema:
+ type: string
+ security:
+ - ApiKeyAuth: []
+ summary: 鎵归噺鍒犻櫎Member
+ tags:
+ - Member
+ /m/findMember:
+ get:
+ consumes:
+ - application/json
+ parameters:
+ - description: 涓婚敭ID
+ in: query
+ name: id
+ type: integer
+ - in: query
+ name: nickname
+ type: string
+ - in: query
+ name: userName
+ type: string
+ - in: query
+ name: uuid
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: '{"success":true,"data":{},"msg":"鏌ヨ鎴愬姛"}'
+ schema:
+ type: string
+ security:
+ - ApiKeyAuth: []
+ summary: 鐢╥d鏌ヨMember
+ tags:
+ - Member
+ /m/getMemberList:
+ get:
+ consumes:
+ - application/json
+ parameters:
+ - in: query
+ name: endCreatedAt
+ type: string
+ - description: 涓婚敭ID
+ in: query
+ name: id
+ type: integer
+ - description: 鍏抽敭瀛�
+ in: query
+ name: keyword
+ type: string
+ - in: query
+ name: nickname
+ type: string
+ - description: 椤电爜
+ in: query
+ name: page
+ type: integer
+ - description: 姣忛〉澶у皬
+ in: query
+ name: pageSize
+ type: integer
+ - in: query
+ name: startCreatedAt
+ type: string
+ - in: query
+ name: userName
+ type: string
+ - in: query
+ name: uuid
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: '{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}'
+ schema:
+ type: string
+ security:
+ - ApiKeyAuth: []
+ summary: 鍒嗛〉鑾峰彇Member鍒楄〃
+ tags:
+ - Member
+ /m/getMemberListFromGrpc:
+ get:
+ consumes:
+ - application/json
+ parameters:
+ - in: query
+ name: endCreatedAt
+ type: string
+ - description: 涓婚敭ID
+ in: query
+ name: id
+ type: integer
+ - description: 鍏抽敭瀛�
+ in: query
+ name: keyword
+ type: string
+ - in: query
+ name: nickname
+ type: string
+ - description: 椤电爜
+ in: query
+ name: page
+ type: integer
+ - description: 姣忛〉澶у皬
+ in: query
+ name: pageSize
+ type: integer
+ - in: query
+ name: startCreatedAt
+ type: string
+ - in: query
+ name: userName
+ type: string
+ - in: query
+ name: uuid
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: '{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}'
+ schema:
+ type: string
+ security:
+ - ApiKeyAuth: []
+ summary: 鍒嗛〉鑾峰彇Member鍒楄〃
+ tags:
+ - Member
+ /m/updateMember:
+ put:
+ consumes:
+ - application/json
+ parameters:
+ - description: 鏇存柊Member
+ in: body
+ name: data
+ required: true
+ schema:
+ $ref: '#/definitions/test.Member'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: '{"success":true,"data":{},"msg":"鏇存柊鎴愬姛"}'
+ schema:
+ type: string
+ security:
+ - ApiKeyAuth: []
+ summary: 鏇存柊Member
+ tags:
+ - Member
/menu/addBaseMenu:
post:
consumes:
@@ -4083,8 +4316,8 @@
name: phone
type: string
- in: query
- name: responsiblePersonId
- type: integer
+ name: responsiblePersonName
+ type: string
- in: query
name: status
type: integer
@@ -4164,8 +4397,8 @@
name: phone
type: string
- in: query
- name: responsiblePersonId
- type: integer
+ name: responsiblePersonName
+ type: string
- in: query
name: startCreatedAt
type: string
diff --git a/initialize/gorm.go b/initialize/gorm.go
index 0b0350f..e79f7d4 100644
--- a/initialize/gorm.go
+++ b/initialize/gorm.go
@@ -51,7 +51,13 @@
example.ExaFile{},
example.ExaCustomer{},
example.ExaFileChunk{},
- example.ExaFileUploadAndDownload{}, test.Industry{}, test.SupplierType{}, test.Supplier{}, test.Contract{}, test.Product{},
+ example.ExaFileUploadAndDownload{},
+ test.Industry{},
+ test.SupplierType{},
+ test.Supplier{},
+ test.Contract{},
+ test.Product{},
+ test.Member{},
)
if err != nil {
global.GVA_LOG.Error("register table failed", zap.Error(err))
diff --git a/initialize/router.go b/initialize/router.go
index fda059b..9ca568f 100644
--- a/initialize/router.go
+++ b/initialize/router.go
@@ -78,6 +78,7 @@
testRouter.InitSupplierRouter(PrivateGroup)
testRouter.InitContractRouter(PrivateGroup)
testRouter.InitProductRouter(PrivateGroup)
+ testRouter.InitMemberRouter(PrivateGroup)
}
global.GVA_LOG.Info("router register success")
diff --git a/model/test/member.go b/model/test/member.go
new file mode 100644
index 0000000..4e1e9ca
--- /dev/null
+++ b/model/test/member.go
@@ -0,0 +1,19 @@
+// 鑷姩鐢熸垚妯℃澘Member
+package test
+
+import (
+ "srm/global"
+)
+
+// Member 缁撴瀯浣�
+type Member struct {
+ global.GVA_MODEL
+ Uuid string `json:"uuid" form:"uuid" gorm:"column:uuid;comment:uuid;size:255;"`
+ UserName string `json:"userName" form:"userName" gorm:"column:user_name;comment:鐢ㄦ埛鍚嶇О;size:255;"`
+ Nickname string `json:"nickname" form:"nickname" gorm:"column:nickname;comment:鏄电О;size:255;"`
+}
+
+// TableName Member 琛ㄥ悕
+func (Member) TableName() string {
+ return "member"
+}
diff --git a/model/test/request/member.go b/model/test/request/member.go
new file mode 100644
index 0000000..c4c4aa9
--- /dev/null
+++ b/model/test/request/member.go
@@ -0,0 +1,14 @@
+package request
+
+import (
+ "srm/model/common/request"
+ "srm/model/test"
+ "time"
+)
+
+type MemberSearch struct {
+ test.Member
+ StartCreatedAt *time.Time `json:"startCreatedAt" form:"startCreatedAt"`
+ EndCreatedAt *time.Time `json:"endCreatedAt" form:"endCreatedAt"`
+ request.PageInfo
+}
diff --git a/model/test/supplier.go b/model/test/supplier.go
index 4fef2df..40a56f5 100644
--- a/model/test/supplier.go
+++ b/model/test/supplier.go
@@ -8,21 +8,21 @@
// Supplier 缁撴瀯浣�
type Supplier struct {
global.GVA_MODEL
- Number string `json:"number" form:"number" gorm:"column:number;comment:渚涘簲鍟嗙紪鍙�;size:255;"`
- Name string `json:"name" form:"name" gorm:"column:name;comment:鍚嶇О;size:255;"`
- SupplierType string `json:"supplierType" form:"supplierType" gorm:"column:supplier_type;comment:渚涘簲鍟嗙被鍨�;size:255;"`
- Industry string `json:"industry" form:"industry" gorm:"column:industry;comment:鎵�灞炶涓�;size:255;"`
- Contact string `json:"contact" form:"contact" gorm:"column:contact;comment:鑱旂郴浜�;size:255;"`
- Phone string `json:"phone" form:"phone" gorm:"column:phone;comment:鐢佃瘽;size:255;"`
- ResponsiblePersonId *int `json:"responsiblePersonId" form:"responsiblePersonId" gorm:"column:responsible_person_id;comment:璐熻矗浜篿d;size:11;"`
- Email string `json:"email" form:"email" gorm:"column:email;comment:閭;size:255;"`
- DetailAddress string `json:"detailAddress" form:"detailAddress" gorm:"column:detail_address;comment:璇︾粏鍦板潃;type:text;"`
- Url string `json:"url" form:"url" gorm:"column:url;comment:缃戝潃;size:255;"`
- AccountName string `json:"accountName" form:"accountName" gorm:"column:account_name;comment:鎴峰悕;size:255;"`
- Account string `json:"account" form:"account" gorm:"column:account;comment:璐﹀彿;size:255;"`
- Bank string `json:"bank" form:"bank" gorm:"column:bank;comment:寮�鎴疯;size:255;"`
- FileId *int `json:"fileId" form:"fileId" gorm:"column:file_id;comment:闄勪欢id;size:11;"`
- Status int `json:"status" form:"status" gorm:"column:status;comment:鐘舵��;size:11;"`
+ Number string `json:"number" form:"number" gorm:"column:number;comment:渚涘簲鍟嗙紪鍙�;size:255;"`
+ Name string `json:"name" form:"name" gorm:"column:name;comment:鍚嶇О;size:255;"`
+ SupplierType string `json:"supplierType" form:"supplierType" gorm:"column:supplier_type;comment:渚涘簲鍟嗙被鍨�;size:255;"`
+ Industry string `json:"industry" form:"industry" gorm:"column:industry;comment:鎵�灞炶涓�;size:255;"`
+ Contact string `json:"contact" form:"contact" gorm:"column:contact;comment:鑱旂郴浜�;size:255;"`
+ Phone string `json:"phone" form:"phone" gorm:"column:phone;comment:鐢佃瘽;size:255;"`
+ ResponsiblePersonName string `json:"responsiblePersonName" form:"responsiblePersonName" gorm:"column:responsible_person_name;comment:璐熻矗浜�;size:255;"`
+ Email string `json:"email" form:"email" gorm:"column:email;comment:閭;size:255;"`
+ DetailAddress string `json:"detailAddress" form:"detailAddress" gorm:"column:detail_address;comment:璇︾粏鍦板潃;type:text;"`
+ Url string `json:"url" form:"url" gorm:"column:url;comment:缃戝潃;size:255;"`
+ AccountName string `json:"accountName" form:"accountName" gorm:"column:account_name;comment:鎴峰悕;size:255;"`
+ Account string `json:"account" form:"account" gorm:"column:account;comment:璐﹀彿;size:255;"`
+ Bank string `json:"bank" form:"bank" gorm:"column:bank;comment:寮�鎴疯;size:255;"`
+ FileId *int `json:"fileId" form:"fileId" gorm:"column:file_id;comment:闄勪欢id;size:11;"`
+ Status int `json:"status" form:"status" gorm:"column:status;comment:鐘舵��;size:11;"`
}
// TableName Supplier 琛ㄥ悕
diff --git a/proto/user.proto b/proto/user.proto
new file mode 100644
index 0000000..42d1243
--- /dev/null
+++ b/proto/user.proto
@@ -0,0 +1,30 @@
+syntax = "proto3";
+
+package user;
+
+option go_package = "./user";
+
+service UserService {
+ rpc SyncUser(UserRequest) returns (UserResponse);
+}
+
+message User {
+ string uuid = 1;
+ string username = 2;
+ int32 usertype = 3;
+ string nickname = 4;
+
+ // ... other fields
+}
+
+message UserRequest {
+ repeated User users = 1;
+}
+
+message UserResponse {
+ int32 code = 1;
+ string message = 2;
+ repeated User List = 3;
+ int64 total = 4;
+
+}
diff --git a/proto/user/user.pb.go b/proto/user/user.pb.go
new file mode 100644
index 0000000..91bbfbf
--- /dev/null
+++ b/proto/user/user.pb.go
@@ -0,0 +1,332 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// protoc-gen-go v1.26.0
+// protoc v4.24.0
+// source: user.proto
+
+package user
+
+import (
+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+ reflect "reflect"
+ sync "sync"
+)
+
+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 User struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"`
+ Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
+ Usertype int32 `protobuf:"varint,3,opt,name=usertype,proto3" json:"usertype,omitempty"`
+ Nickname string `protobuf:"bytes,4,opt,name=nickname,proto3" json:"nickname,omitempty"`
+}
+
+func (x *User) Reset() {
+ *x = User{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_user_proto_msgTypes[0]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *User) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*User) ProtoMessage() {}
+
+func (x *User) ProtoReflect() protoreflect.Message {
+ mi := &file_user_proto_msgTypes[0]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use User.ProtoReflect.Descriptor instead.
+func (*User) Descriptor() ([]byte, []int) {
+ return file_user_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *User) GetUuid() string {
+ if x != nil {
+ return x.Uuid
+ }
+ return ""
+}
+
+func (x *User) GetUsername() string {
+ if x != nil {
+ return x.Username
+ }
+ return ""
+}
+
+func (x *User) GetUsertype() int32 {
+ if x != nil {
+ return x.Usertype
+ }
+ return 0
+}
+
+func (x *User) GetNickname() string {
+ if x != nil {
+ return x.Nickname
+ }
+ return ""
+}
+
+type UserRequest struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Users []*User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"`
+}
+
+func (x *UserRequest) Reset() {
+ *x = UserRequest{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_user_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *UserRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*UserRequest) ProtoMessage() {}
+
+func (x *UserRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_user_proto_msgTypes[1]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use UserRequest.ProtoReflect.Descriptor instead.
+func (*UserRequest) Descriptor() ([]byte, []int) {
+ return file_user_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *UserRequest) GetUsers() []*User {
+ if x != nil {
+ return x.Users
+ }
+ return nil
+}
+
+type UserResponse struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
+ Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
+ List []*User `protobuf:"bytes,3,rep,name=List,proto3" json:"List,omitempty"`
+ Total int64 `protobuf:"varint,4,opt,name=total,proto3" json:"total,omitempty"`
+}
+
+func (x *UserResponse) Reset() {
+ *x = UserResponse{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_user_proto_msgTypes[2]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *UserResponse) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*UserResponse) ProtoMessage() {}
+
+func (x *UserResponse) ProtoReflect() protoreflect.Message {
+ mi := &file_user_proto_msgTypes[2]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use UserResponse.ProtoReflect.Descriptor instead.
+func (*UserResponse) Descriptor() ([]byte, []int) {
+ return file_user_proto_rawDescGZIP(), []int{2}
+}
+
+func (x *UserResponse) GetCode() int32 {
+ if x != nil {
+ return x.Code
+ }
+ return 0
+}
+
+func (x *UserResponse) GetMessage() string {
+ if x != nil {
+ return x.Message
+ }
+ return ""
+}
+
+func (x *UserResponse) GetList() []*User {
+ if x != nil {
+ return x.List
+ }
+ return nil
+}
+
+func (x *UserResponse) GetTotal() int64 {
+ if x != nil {
+ return x.Total
+ }
+ return 0
+}
+
+var File_user_proto protoreflect.FileDescriptor
+
+var file_user_proto_rawDesc = []byte{
+ 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x75, 0x73,
+ 0x65, 0x72, 0x22, 0x6e, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75,
+ 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x1a,
+ 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
+ 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73,
+ 0x65, 0x72, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x75, 0x73,
+ 0x65, 0x72, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61,
+ 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61,
+ 0x6d, 0x65, 0x22, 0x2f, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
+ 0x74, 0x12, 0x20, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b,
+ 0x32, 0x0a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73,
+ 0x65, 0x72, 0x73, 0x22, 0x72, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f,
+ 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
+ 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61,
+ 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
+ 0x65, 0x12, 0x1e, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32,
+ 0x0a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x4c, 0x69, 0x73,
+ 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03,
+ 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x32, 0x40, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53,
+ 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x31, 0x0a, 0x08, 0x53, 0x79, 0x6e, 0x63, 0x55, 0x73,
+ 0x65, 0x72, 0x12, 0x11, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65,
+ 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65,
+ 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x75,
+ 0x73, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+ file_user_proto_rawDescOnce sync.Once
+ file_user_proto_rawDescData = file_user_proto_rawDesc
+)
+
+func file_user_proto_rawDescGZIP() []byte {
+ file_user_proto_rawDescOnce.Do(func() {
+ file_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_user_proto_rawDescData)
+ })
+ return file_user_proto_rawDescData
+}
+
+var file_user_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
+var file_user_proto_goTypes = []interface{}{
+ (*User)(nil), // 0: user.User
+ (*UserRequest)(nil), // 1: user.UserRequest
+ (*UserResponse)(nil), // 2: user.UserResponse
+}
+var file_user_proto_depIdxs = []int32{
+ 0, // 0: user.UserRequest.users:type_name -> user.User
+ 0, // 1: user.UserResponse.List:type_name -> user.User
+ 1, // 2: user.UserService.SyncUser:input_type -> user.UserRequest
+ 2, // 3: user.UserService.SyncUser:output_type -> user.UserResponse
+ 3, // [3:4] is the sub-list for method output_type
+ 2, // [2:3] 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_user_proto_init() }
+func file_user_proto_init() {
+ if File_user_proto != nil {
+ return
+ }
+ if !protoimpl.UnsafeEnabled {
+ file_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*User); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*UserRequest); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_user_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*UserResponse); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ }
+ type x struct{}
+ out := protoimpl.TypeBuilder{
+ File: protoimpl.DescBuilder{
+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+ RawDescriptor: file_user_proto_rawDesc,
+ NumEnums: 0,
+ NumMessages: 3,
+ NumExtensions: 0,
+ NumServices: 1,
+ },
+ GoTypes: file_user_proto_goTypes,
+ DependencyIndexes: file_user_proto_depIdxs,
+ MessageInfos: file_user_proto_msgTypes,
+ }.Build()
+ File_user_proto = out.File
+ file_user_proto_rawDesc = nil
+ file_user_proto_goTypes = nil
+ file_user_proto_depIdxs = nil
+}
diff --git a/proto/user/user_grpc.pb.go b/proto/user/user_grpc.pb.go
new file mode 100644
index 0000000..2825eb1
--- /dev/null
+++ b/proto/user/user_grpc.pb.go
@@ -0,0 +1,101 @@
+// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
+
+package user
+
+import (
+ context "context"
+ grpc "google.golang.org/grpc"
+ codes "google.golang.org/grpc/codes"
+ status "google.golang.org/grpc/status"
+)
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+// Requires gRPC-Go v1.32.0 or later.
+const _ = grpc.SupportPackageIsVersion7
+
+// UserServiceClient is the client API for UserService 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 UserServiceClient interface {
+ SyncUser(ctx context.Context, in *UserRequest, opts ...grpc.CallOption) (*UserResponse, error)
+}
+
+type userServiceClient struct {
+ cc grpc.ClientConnInterface
+}
+
+func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient {
+ return &userServiceClient{cc}
+}
+
+func (c *userServiceClient) SyncUser(ctx context.Context, in *UserRequest, opts ...grpc.CallOption) (*UserResponse, error) {
+ out := new(UserResponse)
+ err := c.cc.Invoke(ctx, "/user.UserService/SyncUser", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// UserServiceServer is the server API for UserService service.
+// All implementations must embed UnimplementedUserServiceServer
+// for forward compatibility
+type UserServiceServer interface {
+ SyncUser(context.Context, *UserRequest) (*UserResponse, error)
+ mustEmbedUnimplementedUserServiceServer()
+}
+
+// UnimplementedUserServiceServer must be embedded to have forward compatible implementations.
+type UnimplementedUserServiceServer struct {
+}
+
+func (UnimplementedUserServiceServer) SyncUser(context.Context, *UserRequest) (*UserResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method SyncUser not implemented")
+}
+func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {}
+
+// UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service.
+// Use of this interface is not recommended, as added methods to UserServiceServer will
+// result in compilation errors.
+type UnsafeUserServiceServer interface {
+ mustEmbedUnimplementedUserServiceServer()
+}
+
+func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer) {
+ s.RegisterService(&UserService_ServiceDesc, srv)
+}
+
+func _UserService_SyncUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(UserRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(UserServiceServer).SyncUser(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/user.UserService/SyncUser",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(UserServiceServer).SyncUser(ctx, req.(*UserRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+// UserService_ServiceDesc is the grpc.ServiceDesc for UserService service.
+// It's only intended for direct use with grpc.RegisterService,
+// and not to be introspected or modified (even as a copy)
+var UserService_ServiceDesc = grpc.ServiceDesc{
+ ServiceName: "user.UserService",
+ HandlerType: (*UserServiceServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "SyncUser",
+ Handler: _UserService_SyncUser_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{},
+ Metadata: "user.proto",
+}
diff --git a/router/test/enter.go b/router/test/enter.go
index 9c7187e..7b78a04 100644
--- a/router/test/enter.go
+++ b/router/test/enter.go
@@ -6,4 +6,5 @@
SupplierRouter
ContractRouter
ProductRouter
+ MemberRouter
}
diff --git a/router/test/member.go b/router/test/member.go
new file mode 100644
index 0000000..6f79624
--- /dev/null
+++ b/router/test/member.go
@@ -0,0 +1,28 @@
+package test
+
+import (
+ "github.com/gin-gonic/gin"
+ "srm/api/v1"
+ "srm/middleware"
+)
+
+type MemberRouter struct {
+}
+
+// InitMemberRouter 鍒濆鍖� Member 璺敱淇℃伅
+func (s *MemberRouter) InitMemberRouter(Router *gin.RouterGroup) {
+ mRouter := Router.Group("m").Use(middleware.OperationRecord())
+ mRouterWithoutRecord := Router.Group("m")
+ var mApi = v1.ApiGroupApp.TestApiGroup.MemberApi
+ {
+ mRouter.POST("createMember", mApi.CreateMember) // 鏂板缓Member
+ mRouter.DELETE("deleteMember", mApi.DeleteMember) // 鍒犻櫎Member
+ mRouter.DELETE("deleteMemberByIds", mApi.DeleteMemberByIds) // 鎵归噺鍒犻櫎Member
+ mRouter.PUT("updateMember", mApi.UpdateMember) // 鏇存柊Member
+ }
+ {
+ mRouterWithoutRecord.GET("findMember", mApi.FindMember) // 鏍规嵁ID鑾峰彇Member
+ mRouterWithoutRecord.GET("getMemberList", mApi.GetMemberList) // 鑾峰彇Member鍒楄〃
+ mRouterWithoutRecord.GET("getMemberListFromGrpc", mApi.GetMemberListFromGrpc) // 浠巊rpc鑾峰彇Member鍒楄〃
+ }
+}
diff --git a/service/test/enter.go b/service/test/enter.go
index d035d5b..726b48b 100644
--- a/service/test/enter.go
+++ b/service/test/enter.go
@@ -6,4 +6,5 @@
SupplierService
ContractService
ProductService
+ MemberService
}
diff --git a/service/test/member.go b/service/test/member.go
new file mode 100644
index 0000000..cf712e8
--- /dev/null
+++ b/service/test/member.go
@@ -0,0 +1,76 @@
+package test
+
+import (
+ "srm/global"
+ "srm/model/common/request"
+ "srm/model/test"
+ testReq "srm/model/test/request"
+)
+
+type MemberService struct {
+}
+
+// CreateMember 鍒涘缓Member璁板綍
+// Author [piexlmax](https://github.com/piexlmax)
+func (mService *MemberService) CreateMember(m *test.Member) (err error) {
+ err = global.GVA_DB.Create(m).Error
+ return err
+}
+
+// DeleteMember 鍒犻櫎Member璁板綍
+// Author [piexlmax](https://github.com/piexlmax)
+func (mService *MemberService) DeleteMember(m test.Member) (err error) {
+ err = global.GVA_DB.Delete(&m).Error
+ return err
+}
+
+// DeleteMemberByIds 鎵归噺鍒犻櫎Member璁板綍
+// Author [piexlmax](https://github.com/piexlmax)
+func (mService *MemberService) DeleteMemberByIds(ids request.IdsReq) (err error) {
+ err = global.GVA_DB.Delete(&[]test.Member{}, "id in ?", ids.Ids).Error
+ return err
+}
+
+// UpdateMember 鏇存柊Member璁板綍
+// Author [piexlmax](https://github.com/piexlmax)
+func (mService *MemberService) UpdateMember(m test.Member) (err error) {
+ err = global.GVA_DB.Save(&m).Error
+ return err
+}
+
+// GetMember 鏍规嵁id鑾峰彇Member璁板綍
+// Author [piexlmax](https://github.com/piexlmax)
+func (mService *MemberService) GetMember(id uint) (m test.Member, err error) {
+ err = global.GVA_DB.Where("id = ?", id).First(&m).Error
+ return
+}
+
+// GetMemberInfoList 鍒嗛〉鑾峰彇Member璁板綍
+// Author [piexlmax](https://github.com/piexlmax)
+func (mService *MemberService) GetMemberInfoList(info testReq.MemberSearch) (list []test.Member, total int64, err error) {
+ limit := info.PageSize
+ offset := info.PageSize * (info.Page - 1)
+ // 鍒涘缓db
+ db := global.GVA_DB.Model(&test.Member{})
+ var ms []test.Member
+ // 濡傛灉鏈夋潯浠舵悳绱� 涓嬫柟浼氳嚜鍔ㄥ垱寤烘悳绱㈣鍙�
+ if info.StartCreatedAt != nil && info.EndCreatedAt != nil {
+ db = db.Where("created_at BETWEEN ? AND ?", info.StartCreatedAt, info.EndCreatedAt)
+ }
+ if info.Uuid != "" {
+ db = db.Where("uuid LIKE ?", "%"+info.Uuid+"%")
+ }
+ if info.UserName != "" {
+ db = db.Where("user_name LIKE ?", "%"+info.UserName+"%")
+ }
+ if info.Nickname != "" {
+ db = db.Where("nickname LIKE ?", "%"+info.Nickname+"%")
+ }
+ err = db.Count(&total).Error
+ if err != nil {
+ return
+ }
+
+ err = db.Limit(limit).Offset(offset).Find(&ms).Error
+ return ms, total, err
+}
--
Gitblit v1.8.0