add
add related supplier function
| | |
| | | SupplierApi |
| | | ContractApi |
| | | ProductApi |
| | | MemberApi |
| | | } |
| New file |
| | |
| | | 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 用id查询Member |
| | | // @Tags Member |
| | | // @Summary 用id查询Member |
| | | // @Security ApiKeyAuth |
| | | // @accept application/json |
| | | // @Produce application/json |
| | | // @Param data query test.Member true "用id查询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) |
| | | } |
| | | } |
| | |
| | | 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) |
| | | |
| | | } |
| | |
| | | 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 |
| | |
| | | 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服务地址 |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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": "用id查询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": [ |
| | |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "responsiblePersonId", |
| | | "type": "string", |
| | | "name": "responsiblePersonName", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "responsiblePersonId", |
| | | "type": "string", |
| | | "name": "responsiblePersonName", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | "description": "环境值", |
| | | "type": "string" |
| | | }, |
| | | "grpc-admin-url": { |
| | | "description": "grpc服务地址", |
| | | "type": "string" |
| | | }, |
| | | "grpc-url": { |
| | | "description": "grpc服务地址", |
| | | "type": "string" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "test.Member": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | | }, |
| | | "nickname": { |
| | | "type": "string" |
| | | }, |
| | | "userName": { |
| | | "type": "string" |
| | | }, |
| | | "uuid": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "test.Product": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "phone": { |
| | | "type": "string" |
| | | }, |
| | | "responsiblePersonId": { |
| | | "type": "integer" |
| | | "responsiblePersonName": { |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "type": "integer" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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": "用id查询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": [ |
| | |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "responsiblePersonId", |
| | | "type": "string", |
| | | "name": "responsiblePersonName", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "name": "responsiblePersonId", |
| | | "type": "string", |
| | | "name": "responsiblePersonName", |
| | | "in": "query" |
| | | }, |
| | | { |
| | |
| | | "description": "环境值", |
| | | "type": "string" |
| | | }, |
| | | "grpc-admin-url": { |
| | | "description": "grpc服务地址", |
| | | "type": "string" |
| | | }, |
| | | "grpc-url": { |
| | | "description": "grpc服务地址", |
| | | "type": "string" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "test.Member": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | | }, |
| | | "nickname": { |
| | | "type": "string" |
| | | }, |
| | | "userName": { |
| | | "type": "string" |
| | | }, |
| | | "uuid": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "test.Product": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "phone": { |
| | | "type": "string" |
| | | }, |
| | | "responsiblePersonId": { |
| | | "type": "integer" |
| | | "responsiblePersonName": { |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "type": "integer" |
| | |
| | | env: |
| | | description: 环境值 |
| | | type: string |
| | | grpc-admin-url: |
| | | description: grpc服务地址 |
| | | type: string |
| | | grpc-url: |
| | | description: grpc服务地址 |
| | | type: string |
| | |
| | | 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: |
| | |
| | | type: string |
| | | phone: |
| | | type: string |
| | | responsiblePersonId: |
| | | type: integer |
| | | responsiblePersonName: |
| | | type: string |
| | | status: |
| | | type: integer |
| | | supplierType: |
| | |
| | | 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: 用id查询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: |
| | |
| | | name: phone |
| | | type: string |
| | | - in: query |
| | | name: responsiblePersonId |
| | | type: integer |
| | | name: responsiblePersonName |
| | | type: string |
| | | - in: query |
| | | name: status |
| | | type: integer |
| | |
| | | name: phone |
| | | type: string |
| | | - in: query |
| | | name: responsiblePersonId |
| | | type: integer |
| | | name: responsiblePersonName |
| | | type: string |
| | | - in: query |
| | | name: startCreatedAt |
| | | type: string |
| | |
| | | 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)) |
| | |
| | | testRouter.InitSupplierRouter(PrivateGroup) |
| | | testRouter.InitContractRouter(PrivateGroup) |
| | | testRouter.InitProductRouter(PrivateGroup) |
| | | testRouter.InitMemberRouter(PrivateGroup) |
| | | } |
| | | |
| | | global.GVA_LOG.Info("router register success") |
| New file |
| | |
| | | // 自动生成模板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" |
| | | } |
| New file |
| | |
| | | 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 |
| | | } |
| | |
| | | // 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:负责人id;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 表名 |
| New file |
| | |
| | | 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; |
| | | |
| | | } |
| New file |
| | |
| | | // 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 |
| | | } |
| New file |
| | |
| | | // 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", |
| | | } |
| | |
| | | SupplierRouter |
| | | ContractRouter |
| | | ProductRouter |
| | | MemberRouter |
| | | } |
| New file |
| | |
| | | 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) // 从grpc获取Member列表 |
| | | } |
| | | } |
| | |
| | | SupplierService |
| | | ContractService |
| | | ProductService |
| | | MemberService |
| | | } |
| New file |
| | |
| | | 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 |
| | | } |