add
add api model
add menu authority
add user authority
fix
Adding role default routes
Modify how the token is generated
Completion of authority Verification
| | |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/contextx" |
| | | "aps_crm/pkg/ecode" |
| | | "github.com/flipped-aurora/gin-vue-admin/server/global" |
| | | "github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
| | | "github.com/flipped-aurora/gin-vue-admin/server/model/system" |
| | | "github.com/flipped-aurora/gin-vue-admin/server/utils" |
| | | "github.com/gin-gonic/gin" |
| | | "go.uber.org/zap" |
| | | ) |
| | | |
| | | type AuthorityApi struct{} |
| | |
| | | return |
| | | } |
| | | |
| | | errCode = authorityService.CreateAuthority(auth) |
| | | errCode, auth.Id = authorityService.CreateAuthority(auth) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | } |
| | | |
| | | //_ = menuService.AddMenuAuthority(systemReq.DefaultMenu(), authority.AuthorityId) |
| | | //_ = casbinService.UpdateCasbin(authority.AuthorityId, systemReq.DefaultCasbin()) |
| | | casbinInfos := append(request.DefaultCasbin(), params.CasbinInfos...) |
| | | |
| | | //_ = menuService.AddMenuAuthority(systemReq.DefaultMenu(), authority.Id) |
| | | _ = casbinService.UpdateCasbin(auth.Id, casbinInfos) |
| | | |
| | | ctx.Ok() |
| | | } |
| | |
| | | // }, "获取成功", c) |
| | | //} |
| | | |
| | | // SetDataAuthority |
| | | // SetMenuAuthority |
| | | // |
| | | // @Tags Authority |
| | | // @Summary 设置角色资源权限 |
| | | // @Summary 设置角色菜单 |
| | | // @Security ApiKeyAuth |
| | | // @accept application/json |
| | | // @Produce application/json |
| | | // @Param data body request.AddAuthority true "设置角色资源权限" |
| | | // @Router /authority/setDataAuthority [post] |
| | | func (a *AuthorityApi) SetDataAuthority(c *gin.Context) { |
| | | var auth system.SysAuthority |
| | | err := c.ShouldBindJSON(&auth) |
| | | if err != nil { |
| | | response.FailWithMessage(err.Error(), c) |
| | | // @Param data body request.SetAuthorityMenu true "设置角色资源权限" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/authority/setMenuAuthority [post] |
| | | func (a *AuthorityApi) SetMenuAuthority(c *gin.Context) { |
| | | var params request.SetAuthorityMenu |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | err = utils.Verify(auth, utils.AuthorityIdVerify) |
| | | if err != nil { |
| | | response.FailWithMessage(err.Error(), c) |
| | | |
| | | menus, errCode := menuService.GetMenusByIds(params.Menus) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(ecode.MenuListErr) |
| | | return |
| | | } |
| | | err = authorityService.SetDataAuthority(auth) |
| | | |
| | | auth := model.Authority{ |
| | | Id: params.AuthorityId, |
| | | Menus: menus, |
| | | } |
| | | |
| | | err := authorityService.SetMenuAuthority(&auth) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("设置失败!", zap.Error(err)) |
| | | response.FailWithMessage("设置失败"+err.Error(), c) |
| | | ctx.Fail(ecode.SetMenuAuthorityErr) |
| | | return |
| | | } |
| | | response.OkWithMessage("设置成功", c) |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | func checkAuthorityParams(params *request.AddAuthority) (int, model.Authority) { |
| | |
| | | // @Tags Menu |
| | | // @Summary 获取菜单树 |
| | | // @Security ApiKeyAuth |
| | | // @param Authorization header string true "Authorization" |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.MenuTreeResponse} |
| | | // @Router /api/menu/getMenu [get] |
| | |
| | | logx.Infof("TokenNext user:%+v", user) |
| | | j := &utils.JWT{SigningKey: []byte(conf.Conf.JWT.SigningKey)} // 唯一签名 |
| | | claims := j.CreateClaims(request.BaseClaims{ |
| | | UserId: user.ID, |
| | | Username: user.Username, |
| | | ParentId: user.ParentName, |
| | | UserType: user.UserType, |
| | | UserId: user.ID, |
| | | Username: user.Username, |
| | | ParentId: user.ParentName, |
| | | UserType: user.UserType, |
| | | AuthorityId: user.AuthorityId, |
| | | }) |
| | | token, err := j.CreateToken(claims) |
| | | if err != nil { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/authority/setMenuAuthority": { |
| | | "post": { |
| | | "security": [ |
| | | { |
| | | "ApiKeyAuth": [] |
| | | } |
| | | ], |
| | | "consumes": [ |
| | | "application/json" |
| | | ], |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Authority" |
| | | ], |
| | | "summary": "设置角色菜单", |
| | | "parameters": [ |
| | | { |
| | | "description": "设置角色资源权限", |
| | | "name": "data", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.SetAuthorityMenu" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/base/captcha": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | }, |
| | | "/api/menu/getMenu": { |
| | | "get": { |
| | | "security": [ |
| | | { |
| | | "ApiKeyAuth": [] |
| | | } |
| | | ], |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | |
| | | "Menu" |
| | | ], |
| | | "summary": "获取菜单树", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "Authorization", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/authority/setDataAuthority": { |
| | | "post": { |
| | | "security": [ |
| | | { |
| | | "ApiKeyAuth": [] |
| | | } |
| | | ], |
| | | "consumes": [ |
| | | "application/json" |
| | | ], |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Authority" |
| | | ], |
| | | "summary": "设置角色资源权限", |
| | | "parameters": [ |
| | | { |
| | | "description": "设置角色资源权限", |
| | | "name": "data", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddAuthority" |
| | | } |
| | | } |
| | | ], |
| | | "responses": {} |
| | | } |
| | | } |
| | | }, |
| | | "definitions": { |
| | |
| | | "model.FollowRecord": { |
| | | "type": "object", |
| | | "properties": { |
| | | "client": { |
| | | "$ref": "#/definitions/model.Client" |
| | | }, |
| | | "client_id": { |
| | | "type": "integer" |
| | | }, |
| | | "client_status_id": { |
| | | "type": "integer" |
| | | }, |
| | | "contact": { |
| | | "$ref": "#/definitions/model.Contact" |
| | | }, |
| | | "contact_id": { |
| | | "type": "integer" |
| | |
| | | "properties": { |
| | | "authorityName": { |
| | | "type": "string" |
| | | }, |
| | | "casbinInfos": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.CasbinInfo" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.CasbinInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | | "method": { |
| | | "description": "方法", |
| | | "type": "string" |
| | | }, |
| | | "path": { |
| | | "description": "路径", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.ChangePasswordReq": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.SetAuthorityMenu": { |
| | | "type": "object", |
| | | "properties": { |
| | | "authorityId": { |
| | | "type": "integer" |
| | | }, |
| | | "menus": { |
| | | "type": "array", |
| | | "items": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.SetCity": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/authority/setMenuAuthority": { |
| | | "post": { |
| | | "security": [ |
| | | { |
| | | "ApiKeyAuth": [] |
| | | } |
| | | ], |
| | | "consumes": [ |
| | | "application/json" |
| | | ], |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Authority" |
| | | ], |
| | | "summary": "设置角色菜单", |
| | | "parameters": [ |
| | | { |
| | | "description": "设置角色资源权限", |
| | | "name": "data", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.SetAuthorityMenu" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/base/captcha": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | }, |
| | | "/api/menu/getMenu": { |
| | | "get": { |
| | | "security": [ |
| | | { |
| | | "ApiKeyAuth": [] |
| | | } |
| | | ], |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | |
| | | "Menu" |
| | | ], |
| | | "summary": "获取菜单树", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "Authorization", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/authority/setDataAuthority": { |
| | | "post": { |
| | | "security": [ |
| | | { |
| | | "ApiKeyAuth": [] |
| | | } |
| | | ], |
| | | "consumes": [ |
| | | "application/json" |
| | | ], |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Authority" |
| | | ], |
| | | "summary": "设置角色资源权限", |
| | | "parameters": [ |
| | | { |
| | | "description": "设置角色资源权限", |
| | | "name": "data", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddAuthority" |
| | | } |
| | | } |
| | | ], |
| | | "responses": {} |
| | | } |
| | | } |
| | | }, |
| | | "definitions": { |
| | |
| | | "model.FollowRecord": { |
| | | "type": "object", |
| | | "properties": { |
| | | "client": { |
| | | "$ref": "#/definitions/model.Client" |
| | | }, |
| | | "client_id": { |
| | | "type": "integer" |
| | | }, |
| | | "client_status_id": { |
| | | "type": "integer" |
| | | }, |
| | | "contact": { |
| | | "$ref": "#/definitions/model.Contact" |
| | | }, |
| | | "contact_id": { |
| | | "type": "integer" |
| | |
| | | "properties": { |
| | | "authorityName": { |
| | | "type": "string" |
| | | }, |
| | | "casbinInfos": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.CasbinInfo" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.CasbinInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | | "method": { |
| | | "description": "方法", |
| | | "type": "string" |
| | | }, |
| | | "path": { |
| | | "description": "路径", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.ChangePasswordReq": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.SetAuthorityMenu": { |
| | | "type": "object", |
| | | "properties": { |
| | | "authorityId": { |
| | | "type": "integer" |
| | | }, |
| | | "menus": { |
| | | "type": "array", |
| | | "items": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.SetCity": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | type: object |
| | | model.FollowRecord: |
| | | properties: |
| | | client: |
| | | $ref: '#/definitions/model.Client' |
| | | client_id: |
| | | type: integer |
| | | client_status_id: |
| | | type: integer |
| | | contact: |
| | | $ref: '#/definitions/model.Contact' |
| | | contact_id: |
| | | type: integer |
| | | contact_information_id: |
| | |
| | | properties: |
| | | authorityName: |
| | | type: string |
| | | casbinInfos: |
| | | items: |
| | | $ref: '#/definitions/request.CasbinInfo' |
| | | type: array |
| | | type: object |
| | | request.AddCity: |
| | | properties: |
| | |
| | | subOrder: |
| | | $ref: '#/definitions/request.SubOrder' |
| | | type: object |
| | | request.CasbinInfo: |
| | | properties: |
| | | method: |
| | | description: 方法 |
| | | type: string |
| | | path: |
| | | description: 路径 |
| | | type: string |
| | | type: object |
| | | request.ChangePasswordReq: |
| | | properties: |
| | | newPassword: |
| | |
| | | type: string |
| | | status: |
| | | type: integer |
| | | type: object |
| | | request.SetAuthorityMenu: |
| | | properties: |
| | | authorityId: |
| | | type: integer |
| | | menus: |
| | | items: |
| | | type: integer |
| | | type: array |
| | | type: object |
| | | request.SetCity: |
| | | properties: |
| | |
| | | security: |
| | | - ApiKeyAuth: [] |
| | | summary: 创建角色 |
| | | tags: |
| | | - Authority |
| | | /api/authority/setMenuAuthority: |
| | | post: |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 设置角色资源权限 |
| | | in: body |
| | | name: data |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.SetAuthorityMenu' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | security: |
| | | - ApiKeyAuth: [] |
| | | summary: 设置角色菜单 |
| | | tags: |
| | | - Authority |
| | | /api/base/captcha: |
| | |
| | | - MasterOrder |
| | | /api/menu/getMenu: |
| | | get: |
| | | parameters: |
| | | - description: Authorization |
| | | in: header |
| | | name: Authorization |
| | | required: true |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | data: |
| | | $ref: '#/definitions/response.MenuTreeResponse' |
| | | type: object |
| | | security: |
| | | - ApiKeyAuth: [] |
| | | summary: 获取菜单树 |
| | | tags: |
| | | - Menu |
| | |
| | | summary: 设置用户信息 |
| | | tags: |
| | | - User |
| | | /authority/setDataAuthority: |
| | | post: |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 设置角色资源权限 |
| | | in: body |
| | | name: data |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddAuthority' |
| | | produces: |
| | | - application/json |
| | | responses: {} |
| | | security: |
| | | - ApiKeyAuth: [] |
| | | summary: 设置角色资源权限 |
| | | tags: |
| | | - Authority |
| | | swagger: "2.0" |
| | |
| | | require ( |
| | | github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect |
| | | github.com/KyleBanks/depth v1.2.1 // indirect |
| | | github.com/aliyun/aliyun-oss-go-sdk v2.1.6+incompatible // indirect |
| | | github.com/aws/aws-sdk-go v1.42.27 // indirect |
| | | github.com/bytedance/sonic v1.9.1 // indirect |
| | | github.com/cespare/xxhash/v2 v2.2.0 // indirect |
| | | github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect |
| | |
| | | github.com/golang-sql/sqlexp v0.1.0 // indirect |
| | | github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect |
| | | github.com/golang/protobuf v1.5.3 // indirect |
| | | github.com/google/go-querystring v1.0.0 // indirect |
| | | github.com/google/uuid v1.3.0 // indirect |
| | | github.com/gookit/color v1.3.1 // indirect |
| | | github.com/hashicorp/hcl v1.0.0 // indirect |
| | | github.com/huaweicloud/huaweicloud-sdk-go-obs v3.21.8+incompatible // indirect |
| | | github.com/jackc/pgpassfile v1.0.0 // indirect |
| | | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect |
| | | github.com/jackc/pgx/v5 v5.3.1 // indirect |
| | | github.com/jinzhu/inflection v1.0.0 // indirect |
| | | github.com/jinzhu/now v1.1.5 // indirect |
| | | github.com/jmespath/go-jmespath v0.4.0 // indirect |
| | | github.com/jordan-wright/email v0.0.0-20200824153738-3f5bafa1cd84 // indirect |
| | | github.com/josharian/intern v1.0.0 // indirect |
| | | github.com/json-iterator/go v1.1.12 // indirect |
| | | github.com/klauspost/cpuid/v2 v2.2.4 // indirect |
| | |
| | | github.com/mitchellh/mapstructure v1.5.0 // indirect |
| | | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect |
| | | github.com/modern-go/reflect2 v1.0.2 // indirect |
| | | github.com/mozillazg/go-httpheader v0.2.1 // indirect |
| | | github.com/onsi/gomega v1.27.4 // indirect |
| | | github.com/otiai10/copy v1.7.0 // indirect |
| | | github.com/pelletier/go-toml/v2 v2.0.8 // indirect |
| | | github.com/pmezard/go-difflib v1.0.0 // indirect |
| | | github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect |
| | | github.com/qiniu/api.v7/v7 v7.4.1 // indirect |
| | | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect |
| | | github.com/rogpeppe/go-internal v1.10.0 // indirect |
| | | github.com/sashabaranov/go-openai v1.5.7 // indirect |
| | | github.com/shirou/gopsutil/v3 v3.22.5 // indirect |
| | | github.com/spf13/afero v1.9.5 // indirect |
| | | github.com/spf13/cast v1.5.1 // indirect |
| | | github.com/spf13/jwalterweatherman v1.1.0 // indirect |
| | | github.com/spf13/pflag v1.0.5 // indirect |
| | | github.com/subosito/gotenv v1.4.2 // indirect |
| | | github.com/tencentyun/cos-go-sdk-v5 v0.7.19 // indirect |
| | | github.com/tklauser/go-sysconf v0.3.10 // indirect |
| | | github.com/tklauser/numcpus v0.4.0 // indirect |
| | | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect |
| | | github.com/ugorji/go/codec v1.2.11 // indirect |
| | | github.com/unrolled/secure v1.0.7 // indirect |
| | | github.com/yusufpapurcu/wmi v1.2.2 // indirect |
| | | go.etcd.io/etcd/api/v3 v3.5.9 // indirect |
| | | go.uber.org/atomic v1.9.0 // indirect |
| | |
| | | golang.org/x/net v0.10.0 // indirect |
| | | golang.org/x/sys v0.9.0 // indirect |
| | | golang.org/x/text v0.10.0 // indirect |
| | | golang.org/x/time v0.1.0 // indirect |
| | | golang.org/x/tools v0.9.1 // indirect |
| | | google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect |
| | | google.golang.org/grpc v1.55.0 // indirect |
| | |
| | | github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= |
| | | github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= |
| | | github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= |
| | | github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= |
| | | github.com/aliyun/aliyun-oss-go-sdk v2.1.6+incompatible h1:Ft+KeWIJxFP76LqgJbvtOA1qBIoC8vGkTV3QeCOeJC4= |
| | | github.com/aliyun/aliyun-oss-go-sdk v2.1.6+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= |
| | | github.com/aws/aws-sdk-go v1.42.27 h1:kxsBXQg3ee6LLbqjp5/oUeDgG7TENFrWYDmEVnd7spU= |
| | | github.com/aws/aws-sdk-go v1.42.27/go.mod h1:OGr6lGMAKGlG9CVrYnWYDKIyb829c6EVBRjxqjmPepc= |
| | | github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f h1:ZNv7On9kyUzm7fvRZumSyy/IUiSC7AzL0I1jKKtwooA= |
| | | github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= |
| | | github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= |
| | | github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= |
| | |
| | | github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= |
| | | github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= |
| | | github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= |
| | | github.com/codegangsta/negroni v1.0.0 h1:+aYywywx4bnKXWvoWtRfJ91vC59NbEhEY03sZjQhbVY= |
| | | github.com/codegangsta/negroni v1.0.0/go.mod h1:v0y3T5G7Y1UlFfyxFn/QLRU4a2EuNau2iZY63YTKWo0= |
| | | github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= |
| | | github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= |
| | | github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= |
| | |
| | | github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= |
| | | github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= |
| | | github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= |
| | | github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= |
| | | github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= |
| | | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= |
| | | github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= |
| | | github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= |
| | |
| | | github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= |
| | | github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ= |
| | | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= |
| | | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
| | | github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
| | | github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= |
| | | github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
| | | github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= |
| | | github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= |
| | | github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= |
| | | github.com/gookit/color v1.3.1 h1:PPD/C7sf8u2L8XQPdPgsWRoAiLQGZEZOzU3cf5IYYUk= |
| | | github.com/gookit/color v1.3.1/go.mod h1:R3ogXq2B9rTbXoSHJ1HyUVAZ3poOJHpd9nQmyGZsfvQ= |
| | | github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= |
| | | github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= |
| | | github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= |
| | |
| | | github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= |
| | | github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= |
| | | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= |
| | | github.com/huaweicloud/huaweicloud-sdk-go-obs v3.21.8+incompatible h1:3kDd8PIWAdU+qGs/+0QUgsMI2ZSiJPt45Xn0su+x/Q0= |
| | | github.com/huaweicloud/huaweicloud-sdk-go-obs v3.21.8+incompatible/go.mod h1:l7VUhRbTKCzdOacdT4oWCwATKyvZqUOlOqr0Ous3k4s= |
| | | github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= |
| | | github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= |
| | | github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= |
| | |
| | | github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= |
| | | github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= |
| | | github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= |
| | | github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= |
| | | github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= |
| | | github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= |
| | | github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= |
| | | github.com/jordan-wright/email v0.0.0-20200824153738-3f5bafa1cd84 h1:pS0A6cr4aHYZnYwC7Uw+rwgb39+nzkm2QhwZ+S6Gn5I= |
| | | github.com/jordan-wright/email v0.0.0-20200824153738-3f5bafa1cd84/go.mod h1:1c7szIrayyPPB/987hsnvNzLushdWf4o/79s3P08L8A= |
| | | github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= |
| | | github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= |
| | | github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= |
| | |
| | | github.com/mojocn/base64Captcha v1.3.5 h1:Qeilr7Ta6eDtG4S+tQuZ5+hO+QHbiGAJdi4PfoagaA0= |
| | | github.com/mojocn/base64Captcha v1.3.5/go.mod h1:/tTTXn4WTpX9CfrmipqRytCpJ27Uw3G6I7NcP2WwcmY= |
| | | github.com/montanaflynn/stats v0.7.0/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= |
| | | github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSrwhe88TQQ= |
| | | github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60= |
| | | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= |
| | | github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= |
| | | github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= |
| | | github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E= |
| | | github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ= |
| | | github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE= |
| | | github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U= |
| | | github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= |
| | | github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= |
| | | github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= |
| | | github.com/otiai10/mint v1.3.3 h1:7JgpsBaN0uMkyju4tbYHu0mnM55hNKVYLsXmwr15NQI= |
| | | github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= |
| | | github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= |
| | | github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= |
| | | github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= |
| | |
| | | github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= |
| | | github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= |
| | | github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= |
| | | github.com/qiniu/api.v7/v7 v7.4.1 h1:BnNUBimLk6nrA/mIwsww9yJRupmViSsb1ndLMC7a9OY= |
| | | github.com/qiniu/api.v7/v7 v7.4.1/go.mod h1:VE5oC5rkE1xul0u1S2N0b2Uxq9/6hZzhyqjgK25XDcM= |
| | | github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= |
| | | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= |
| | | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= |
| | |
| | | github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= |
| | | github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= |
| | | github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= |
| | | github.com/sashabaranov/go-openai v1.5.7 h1:8DGgRG+P7yWixte5j720y6yiXgY3Hlgcd0gcpHdltfo= |
| | | github.com/sashabaranov/go-openai v1.5.7/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg= |
| | | github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= |
| | | github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= |
| | | github.com/shirou/gopsutil/v3 v3.22.5 h1:atX36I/IXgFiB81687vSiBI5zrMsxcIBkP9cQMJQoJA= |
| | | github.com/shirou/gopsutil/v3 v3.22.5/go.mod h1:so9G9VzeHt/hsd0YwqprnjHnfARAUktauykSbr+y2gA= |
| | |
| | | github.com/swaggo/gin-swagger v1.6.0/go.mod h1:BG00cCEy294xtVpyIAHG6+e2Qzj/xKlRdOqDkvq0uzo= |
| | | github.com/swaggo/swag v1.16.1 h1:fTNRhKstPKxcnoKsytm4sahr8FaYzUcT7i1/3nd/fBg= |
| | | github.com/swaggo/swag v1.16.1/go.mod h1:9/LMvHycG3NFHfR6LwvikHv5iFvmPADQ359cKikGxto= |
| | | github.com/tencentyun/cos-go-sdk-v5 v0.7.19 h1:janAfTO4MglOrUFuKGTQJBuMc66+F7TgtEIt1wPsJ+k= |
| | | github.com/tencentyun/cos-go-sdk-v5 v0.7.19/go.mod h1:wQBO5HdAkLjj2q6XQiIfDSP8DXDNrppDRw2Kp/1BODA= |
| | | github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= |
| | | github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= |
| | | github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o= |
| | |
| | | github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= |
| | | github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= |
| | | github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= |
| | | github.com/unrolled/secure v1.0.7 h1:BcQHp3iKZyZCKj5gRqwQG+5urnGBF00wGgoPPwtheVQ= |
| | | github.com/unrolled/secure v1.0.7/go.mod h1:uGc1OcRF8gCVBA+ANksKmvM85Hka6SZtQIbrKc3sHS4= |
| | | github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= |
| | | github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= |
| | | github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= |
| | |
| | | golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= |
| | | golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= |
| | | golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= |
| | | golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= |
| | | golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= |
| | | golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= |
| | | golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= |
| | |
| | | golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
| | | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
| | | golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
| | | golang.org/x/time v0.1.0 h1:xYY+Bajn2a7VBmTM5GikTmnK8ZuX8YgnQCqZpbBNtmA= |
| | | golang.org/x/time v0.1.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
| | | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
| | | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
| | | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= |
New file |
| | |
| | | package model |
| | | |
| | | type Api struct { |
| | | Id uint `json:"id" gorm:"column:id;autoIncrement;not null;unique;primary_key;comment:角色ID;size:90"` // 角色ID |
| | | Path string `json:"path" gorm:"comment:api路径"` // api路径 |
| | | Description string `json:"description" gorm:"comment:api中文描述"` // api中文描述 |
| | | Method string `json:"method" gorm:"default:POST;comment:方法"` // 方法:创建POST(默认)|查看GET|更新PUT|删除DELETE |
| | | } |
| | | |
| | | func (Api) TableName() string { |
| | | return "apis" |
| | | } |
| | |
| | | |
| | | type ( |
| | | Authority struct { |
| | | AuthorityId uint `json:"authorityId" gorm:"not null;unique;primary_key;comment:角色ID;size:90"` // 角色ID |
| | | AuthorityName string `json:"authorityName" gorm:"comment:角色名"` // 角色名 |
| | | Id uint `json:"id" gorm:"column:id;autoIncrement;not null;unique;primary_key;comment:角色ID;size:90"` // 角色ID |
| | | AuthorityName string `json:"authorityName" gorm:"comment:角色名"` // 角色名 |
| | | Users []User `json:"-" gorm:"many2many:user_authority;"` |
| | | Menus []Menu `json:"menus" gorm:"many2many:authority_menus;"` |
| | | DefaultRouter string `json:"defaultRouter" gorm:"comment:默认菜单;default:dashboard"` // 默认菜单(默认dashboard) |
| | |
| | | ) |
| | | |
| | | func (Authority) TableName() string { |
| | | return "sys_authorities" |
| | | return "authorities" |
| | | } |
| | | |
| | | func NewSysAuthoritySearch() *SysAuthoritySearch { |
| | |
| | | |
| | | func (slf *SysAuthoritySearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&Authority{}) |
| | | if slf.AuthorityId != 0 { |
| | | db = db.Where("authority_id = ?", slf.AuthorityId) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | |
| | | return db |
| | |
| | | } |
| | | |
| | | func (slf *SysAuthoritySearch) SetAuthorityId(id uint) *SysAuthoritySearch { |
| | | slf.AuthorityId = id |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *SysAuthoritySearch) SetMenuAuthority(auth *Authority) error { |
| | | var db = slf.build() |
| | | return db.Model(auth).Association("Menus").Append(auth.Menus) |
| | | } |
| | |
| | | NextFollowTime time.Time `json:"next_follow_time" gorm:"column:next_follow_time;type:datetime;comment:下次跟进时间"` |
| | | Purpose string `json:"purpose" gorm:"column:purpose;type:varchar(255);comment:跟进目的"` |
| | | Content string `json:"content" gorm:"column:content;type:MEDIUMTEXT;comment:跟进内容"` |
| | | Client Client `json:"client" gorm:"foreignKey:ClientId"` |
| | | Contact Contact `json:"contact" gorm:"foreignKey:ContactId"` |
| | | gorm.Model `json:"-"` |
| | | } |
| | | |
| | |
| | | |
| | | func (slf *FollowRecordSearch) Find() ([]*FollowRecord, error) { |
| | | var records = make([]*FollowRecord, 0) |
| | | err := slf.build().Find(&records).Error |
| | | err := slf.build().Preload("Client").Preload("Contact").Find(&records).Error |
| | | return records, err |
| | | } |
| | | |
| | |
| | | ServiceFollowup{}, |
| | | CustomerServiceSheet{}, |
| | | ServiceFeeManage{}, |
| | | Authority{}, |
| | | Api{}, |
| | | ) |
| | | return err |
| | | } |
| | |
| | | return records, nil |
| | | } |
| | | |
| | | func (slf *MenuSearch) FindAll() ([]*Menu, error) { |
| | | func (slf *MenuSearch) FindAll() ([]Menu, error) { |
| | | var ( |
| | | records = make([]*Menu, 0) |
| | | records = make([]Menu, 0) |
| | | db = slf.build() |
| | | ) |
| | | |
| | |
| | | package request |
| | | |
| | | type AddAuthority struct { |
| | | AuthorityName string `json:"authorityName"` |
| | | AuthorityName string `json:"authorityName"` |
| | | CasbinInfos []CasbinInfo `json:"casbinInfos"` |
| | | } |
| | | |
| | | type SetAuthorityMenu struct { |
New file |
| | |
| | | package request |
| | | |
| | | // Casbin info structure |
| | | type CasbinInfo struct { |
| | | Path string `json:"path"` // 路径 |
| | | Method string `json:"method"` // 方法 |
| | | } |
| | | |
| | | // Casbin structure for input parameters |
| | | type CasbinInReceive struct { |
| | | AuthorityId uint `json:"authorityId"` // 权限id |
| | | CasbinInfos []CasbinInfo `json:"casbinInfos"` |
| | | } |
| | | |
| | | func DefaultCasbin() []CasbinInfo { |
| | | return []CasbinInfo{ |
| | | {Path: "/menu/getMenu", Method: "POST"}, |
| | | {Path: "/jwt/jsonInBlacklist", Method: "POST"}, |
| | | {Path: "/base/login", Method: "POST"}, |
| | | {Path: "/user/admin_register", Method: "POST"}, |
| | | {Path: "/user/changePassword", Method: "POST"}, |
| | | {Path: "/user/setUserAuthority", Method: "POST"}, |
| | | {Path: "/user/setUserInfo", Method: "PUT"}, |
| | | {Path: "/user/getUserInfo", Method: "GET"}, |
| | | {Path: "/city/list", Method: "GET"}, |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | MenuTreeResponse struct { |
| | | List []*model.Menu `json:"list"` |
| | | List []model.Menu `json:"list"` |
| | | } |
| | | ) |
| | |
| | | Ip string `json:"ip" gorm:"type:varchar(255);comment:集群Ip"` |
| | | Port string `json:"port" gorm:"type:varchar(255);comment:端口号"` |
| | | Status int `json:"status" gorm:"type:int(11);comment:用户审核状态 0:禁用; 1:正常; 2:审核中"` |
| | | AuthorityId uint `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID |
| | | Authority Authority `json:"authority" gorm:"foreignKey:AuthorityId"` |
| | | } |
| | | |
| | | UserSearch struct { |
| | |
| | | RoleDeleteErr = 3800006 // 删除角色失败 |
| | | RoleDeleteErr1 = 3800007 // 该角色下存在用户,无法删除 |
| | | |
| | | MenuListErr = 3900001 // 获取菜单列表失败 |
| | | MenuListErr = 3900001 // 获取菜单列表失败 |
| | | SetMenuAuthorityErr = 3900002 // 设置菜单权限失败 |
| | | |
| | | ) |
| | |
| | | //authorityRouter.DELETE("delete", authorityApi.Delete) // 删除角色 |
| | | //authorityRouter.PUT("update", authorityApi.Update) // 更新角色 |
| | | //authorityRouter.POST("getAuthorityList", authorityApi.GetAuthorityList) // 获取角色列表 |
| | | authorityRouter.POST("setDataAuthority", authorityApi.SetDataAuthority) // 设置角色资源权限 |
| | | authorityRouter.POST("setMenuAuthority", authorityApi.SetMenuAuthority) // 设置角色资源权限 |
| | | //authorityRouter.POST("getAuthorityId", authorityApi.GetAuthorityId) // 获取指定角色权限 |
| | | } |
| | | } |
| | |
| | | import ( |
| | | "aps_crm/conf" |
| | | _ "aps_crm/docs" |
| | | "aps_crm/middleware" |
| | | "github.com/gin-contrib/cors" |
| | | "github.com/gin-gonic/gin" |
| | | swaggerFiles "github.com/swaggo/files" |
| | |
| | | } |
| | | |
| | | PrivateGroup := Router.Group("api") |
| | | //PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler()) |
| | | PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler()) |
| | | //PrivateGroup.Use(middleware.JWTAuth()) |
| | | //PrivateGroup.Use(middleware.CasbinHandler()) |
| | | { |
| | | routerGroup.InitJwtRouter(PrivateGroup) // jwt相关路由 |
| | | routerGroup.InitUserRouter(PrivateGroup) // 注册用户路由 |
| | |
| | | "aps_crm/pkg/ecode" |
| | | "github.com/flipped-aurora/gin-vue-admin/server/global" |
| | | "github.com/flipped-aurora/gin-vue-admin/server/model/system" |
| | | "gorm.io/gorm" |
| | | "strconv" |
| | | ) |
| | | |
| | |
| | | |
| | | var AuthorityServiceApp = new(AuthorityService) |
| | | |
| | | func (authorityService *AuthorityService) CreateAuthority(auth model.Authority) int { |
| | | _, err := model.NewSysAuthoritySearch().SetAuthorityId(auth.AuthorityId).Find() |
| | | if err != gorm.ErrRecordNotFound { |
| | | return ecode.RoleExist |
| | | } |
| | | |
| | | err = model.NewSysAuthoritySearch().Create(&auth) |
| | | // CreateAuthority create authority and return authority id and error code |
| | | func (authorityService *AuthorityService) CreateAuthority(auth model.Authority) (int, uint) { |
| | | // check if authority name exists |
| | | err := model.NewSysAuthoritySearch().Create(&auth) |
| | | if err != nil { |
| | | return ecode.SubOrderExist |
| | | return ecode.RoleExist, 0 |
| | | } |
| | | |
| | | return ecode.OK |
| | | return ecode.OK, auth.Id |
| | | } |
| | | |
| | | func (authorityService *AuthorityService) UpdateAuthority(auth model.Authority) int { |
| | | _, err := model.NewSysAuthoritySearch().SetAuthorityId(auth.AuthorityId).Find() |
| | | _, err := model.NewSysAuthoritySearch().SetAuthorityId(auth.Id).Find() |
| | | if err != nil { |
| | | return ecode.RoleNotExist |
| | | } |
| | | |
| | | err = model.NewSysAuthoritySearch().SetAuthorityId(auth.AuthorityId).Update(&auth) |
| | | err = model.NewSysAuthoritySearch().SetAuthorityId(auth.Id).Update(&auth) |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (authorityService *AuthorityService) DeleteAuthority(auth *model.Authority) int { |
| | | _, err := model.NewSysAuthoritySearch().SetAuthorityId(auth.AuthorityId).Find() |
| | | _, err := model.NewSysAuthoritySearch().SetAuthorityId(auth.Id).Find() |
| | | if err != nil { |
| | | return ecode.RoleNotExist |
| | | } |
| | |
| | | return ecode.RoleDeleteErr1 |
| | | } |
| | | |
| | | authorityId := strconv.Itoa(int(auth.AuthorityId)) |
| | | authorityId := strconv.Itoa(int(auth.Id)) |
| | | CasbinServiceApp.ClearCasbin(0, authorityId) |
| | | return ecode.OK |
| | | } |
| | |
| | | } |
| | | |
| | | //@author: [piexlmax](https://github.com/piexlmax) |
| | | //@function: SetDataAuthority |
| | | //@function: SetMenuAuthority |
| | | //@description: 设置角色资源权限 |
| | | //@param: auth model.Authority |
| | | //@return: error |
| | |
| | | //@param: auth *model.Authority |
| | | //@return: error |
| | | |
| | | func (authorityService *AuthorityService) SetMenuAuthority(auth *system.SysAuthority) error { |
| | | var s system.SysAuthority |
| | | global.GVA_DB.Preload("SysBaseMenus").First(&s, "authority_id = ?", auth.AuthorityId) |
| | | err := global.GVA_DB.Model(&s).Association("SysBaseMenus").Replace(&auth.SysBaseMenus) |
| | | return err |
| | | func (authorityService *AuthorityService) SetMenuAuthority(auth *model.Authority) error { |
| | | return model.NewSysAuthoritySearch().SetMenuAuthority(auth) |
| | | } |
| | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/mysqlx" |
| | | "errors" |
| | | "github.com/flipped-aurora/gin-vue-admin/server/global" |
| | | "github.com/flipped-aurora/gin-vue-admin/server/model/system/request" |
| | | "strconv" |
| | | "sync" |
| | | |
| | |
| | | |
| | | func (casbinService *CasbinService) Casbin() *casbin.SyncedCachedEnforcer { |
| | | once.Do(func() { |
| | | a, err := gormadapter.NewAdapterByDB(global.GVA_DB) |
| | | a, err := gormadapter.NewAdapterByDB(mysqlx.GetDB()) |
| | | if err != nil { |
| | | zap.L().Error("适配数据库失败请检查casbin表是否为InnoDB引擎!", zap.Error(err)) |
| | | return |
| | |
| | | |
| | | type MenuService struct{} |
| | | |
| | | func (MenuService) GetMenuTree() ([]*model.Menu, int) { |
| | | func (MenuService) GetMenuTree() ([]model.Menu, int) { |
| | | list, err := model.NewMenuSearch(nil).FindAll() |
| | | if err != nil { |
| | | return nil, ecode.MenuListErr |
| | |
| | | |
| | | return list, ecode.OK |
| | | } |
| | | |
| | | // GetMenusByIds get menus by ids |
| | | func (MenuService) GetMenusByIds(ids []uint) ([]model.Menu, int) { |
| | | list, err := model.NewMenuSearch(nil).SetIds(ids).FindAll() |
| | | if err != nil { |
| | | return nil, ecode.MenuListErr |
| | | } |
| | | |
| | | return list, ecode.OK |
| | | } |