Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway into dev
正在显示
16 个修改的文件
包含
202 行增加
和
51 行删除
@@ -10,7 +10,7 @@ import ( | @@ -10,7 +10,7 @@ import ( | ||
10 | type RoleRemoveCommand struct { | 10 | type RoleRemoveCommand struct { |
11 | //操作人 | 11 | //操作人 |
12 | Operator domain.Operator `json:"-"` | 12 | Operator domain.Operator `json:"-"` |
13 | - RoleId []string `json:"roleId"` | 13 | + RoleIds []string `json:"roleIds"` |
14 | } | 14 | } |
15 | 15 | ||
16 | func (roleRemoveCommand *RoleRemoveCommand) Valid(validation *validation.Validation) { | 16 | func (roleRemoveCommand *RoleRemoveCommand) Valid(validation *validation.Validation) { |
@@ -5,13 +5,15 @@ type RoleItem struct { | @@ -5,13 +5,15 @@ type RoleItem struct { | ||
5 | RoleId string `json:"roleId"` | 5 | RoleId string `json:"roleId"` |
6 | OrgId string `json:"orgId"` | 6 | OrgId string `json:"orgId"` |
7 | RoleName string `json:"roleName"` | 7 | RoleName string `json:"roleName"` |
8 | - Describe string `json:"describe"` | 8 | + Describe string `json:"desc"` |
9 | OrgName string `json:"orgName"` | 9 | OrgName string `json:"orgName"` |
10 | - RoleType int `json:"roleType"` //角色类型 1.普通角色 1024:超级管理员 | 10 | + Ext Ext `json:"ext"` |
11 | } | 11 | } |
12 | 12 | ||
13 | -type RoleUser struct { | ||
14 | - DepartmentName string `json:"departmentName"` | ||
15 | - UserId string `json:"userId"` | 13 | +type Ext struct { |
14 | + DepName string `json:"depName"` | ||
15 | + OrgName string `json:"orgName"` | ||
16 | + ParentDepName string `json:"parentDepName"` | ||
17 | + Phone string `json:"phone"` | ||
16 | UserName string `json:"userName"` | 18 | UserName string `json:"userName"` |
17 | } | 19 | } |
@@ -2,13 +2,16 @@ package query | @@ -2,13 +2,16 @@ package query | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
5 | 6 | ||
6 | "github.com/beego/beego/v2/core/validation" | 7 | "github.com/beego/beego/v2/core/validation" |
7 | ) | 8 | ) |
8 | 9 | ||
9 | type RoleMenuBeforeEditQuery struct { | 10 | type RoleMenuBeforeEditQuery struct { |
11 | + // 操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
10 | // 角色ID | 13 | // 角色ID |
11 | - RoleId int64 `json:"roleId" valid:"Required"` | 14 | + RoleId string `json:"roleId" valid:"Required"` |
12 | } | 15 | } |
13 | 16 | ||
14 | func (roleMenuBeforeEditQuery *RoleMenuBeforeEditQuery) Valid(validation *validation.Validation) { | 17 | func (roleMenuBeforeEditQuery *RoleMenuBeforeEditQuery) Valid(validation *validation.Validation) { |
@@ -2,15 +2,20 @@ package query | @@ -2,15 +2,20 @@ package query | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
5 | 6 | ||
6 | "github.com/beego/beego/v2/core/validation" | 7 | "github.com/beego/beego/v2/core/validation" |
7 | ) | 8 | ) |
8 | 9 | ||
9 | type RoleUserBeforeEditQuery struct { | 10 | type RoleUserBeforeEditQuery struct { |
11 | + // 操作人 | ||
12 | + Operator domain.Operator `json:"-"` | ||
13 | + // 角色ID | ||
14 | + RoleId string `json:"roleId" valid:"Required"` | ||
10 | } | 15 | } |
11 | 16 | ||
12 | func (roleUserBeforeEditQuery *RoleUserBeforeEditQuery) Valid(validation *validation.Validation) { | 17 | func (roleUserBeforeEditQuery *RoleUserBeforeEditQuery) Valid(validation *validation.Validation) { |
13 | - validation.SetError("CustomValid", "未实现的自定义认证") | 18 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
14 | } | 19 | } |
15 | 20 | ||
16 | func (roleUserBeforeEditQuery *RoleUserBeforeEditQuery) ValidateQuery() error { | 21 | func (roleUserBeforeEditQuery *RoleUserBeforeEditQuery) ValidateQuery() error { |
@@ -66,11 +66,24 @@ func (rolesService *RolesService) RoleGet(roleGetQuery *query.RoleGetQuery) (int | @@ -66,11 +66,24 @@ func (rolesService *RolesService) RoleGet(roleGetQuery *query.RoleGetQuery) (int | ||
66 | RoleId: int64(roleId), | 66 | RoleId: int64(roleId), |
67 | }) | 67 | }) |
68 | if err != nil { | 68 | if err != nil { |
69 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 69 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
70 | + } | ||
71 | + accessMenus, err := creationUserGateway.RoleGetAccessMenus(allied_creation_user.ReqRoleGetAccessMenus{ | ||
72 | + RoleId: int64(roleId), | ||
73 | + }) | ||
74 | + if err != nil { | ||
75 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
76 | + } | ||
77 | + relatedUser, err := creationUserGateway.RoleGetRelatedUser(allied_creation_user.ReqRoleGetRelatedUser{ | ||
78 | + RoleId: int64(roleId), | ||
79 | + }) | ||
80 | + if err != nil { | ||
81 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
70 | } | 82 | } |
71 | - //TODO 补充字段 :权限数据,关联用户数据 | ||
72 | result := map[string]interface{}{ | 83 | result := map[string]interface{}{ |
73 | - "role": roleData.Role, | 84 | + "role": roleData, |
85 | + "menus": accessMenus.Menus, | ||
86 | + "users": relatedUser.RoleUser, | ||
74 | } | 87 | } |
75 | return result, nil | 88 | return result, nil |
76 | } | 89 | } |
@@ -93,12 +106,13 @@ func (rolesService *RolesService) RoleList(roleListQuery *query.RoleListQuery) ( | @@ -93,12 +106,13 @@ func (rolesService *RolesService) RoleList(roleListQuery *query.RoleListQuery) ( | ||
93 | result := []dto.RoleItem{} | 106 | result := []dto.RoleItem{} |
94 | for _, v := range roleList.Roles { | 107 | for _, v := range roleList.Roles { |
95 | result = append(result, dto.RoleItem{ | 108 | result = append(result, dto.RoleItem{ |
96 | - RoleId: strconv.Itoa(v.RoleID), | ||
97 | - OrgId: strconv.Itoa(v.OrgID), | 109 | + RoleId: strconv.Itoa(int(v.RoleID)), |
110 | + OrgId: strconv.Itoa(int(v.OrgID)), | ||
98 | RoleName: v.RoleName, | 111 | RoleName: v.RoleName, |
99 | Describe: v.Desc, | 112 | Describe: v.Desc, |
100 | OrgName: v.Ext.OrgName, | 113 | OrgName: v.Ext.OrgName, |
101 | RoleType: v.RoleType, | 114 | RoleType: v.RoleType, |
115 | + Ext: v.Ext, | ||
102 | }) | 116 | }) |
103 | } | 117 | } |
104 | var cnt int64 = roleList.Count | 118 | var cnt int64 = roleList.Count |
@@ -107,14 +121,62 @@ func (rolesService *RolesService) RoleList(roleListQuery *query.RoleListQuery) ( | @@ -107,14 +121,62 @@ func (rolesService *RolesService) RoleList(roleListQuery *query.RoleListQuery) ( | ||
107 | 121 | ||
108 | // 编辑角色关联权限菜单的前置准备数据 | 122 | // 编辑角色关联权限菜单的前置准备数据 |
109 | func (rolesService *RolesService) RoleMenuBeforeEdit(roleMenuBeforeEditQuery *query.RoleMenuBeforeEditQuery) (interface{}, error) { | 123 | func (rolesService *RolesService) RoleMenuBeforeEdit(roleMenuBeforeEditQuery *query.RoleMenuBeforeEditQuery) (interface{}, error) { |
124 | + //creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
125 | + // roleMenuBeforeEditQuery.Operator.CompanyId, | ||
126 | + // roleMenuBeforeEditQuery.Operator.OrgId, | ||
127 | + // roleMenuBeforeEditQuery.Operator.UserId) | ||
128 | + //roleId, _ := strconv.Atoi(roleMenuBeforeEditQuery.RoleId) | ||
129 | + //roles, err := creationUserGateway.RoleSearch(allied_creation_user.ReqRoleSearch{ | ||
130 | + // OrgId: roleMenuBeforeEditQuery.Operator.OrgId, | ||
131 | + // Limit: 999, | ||
132 | + // RoleType: 1, | ||
133 | + //}) | ||
134 | + //if err != nil { | ||
135 | + // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
136 | + //} | ||
110 | 137 | ||
111 | return nil, nil | 138 | return nil, nil |
112 | } | 139 | } |
113 | 140 | ||
114 | // 编辑角色关联用户的前置准备数据 | 141 | // 编辑角色关联用户的前置准备数据 |
115 | func (rolesService *RolesService) RoleUserBeforeEdit(roleUserBeforeEditQuery *query.RoleUserBeforeEditQuery) (interface{}, error) { | 142 | func (rolesService *RolesService) RoleUserBeforeEdit(roleUserBeforeEditQuery *query.RoleUserBeforeEditQuery) (interface{}, error) { |
116 | - //TODO | ||
117 | - return nil, nil | 143 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( |
144 | + roleUserBeforeEditQuery.Operator.CompanyId, | ||
145 | + roleUserBeforeEditQuery.Operator.OrgId, | ||
146 | + roleUserBeforeEditQuery.Operator.UserId) | ||
147 | + roleId, _ := strconv.Atoi(roleUserBeforeEditQuery.RoleId) | ||
148 | + roles, err := creationUserGateway.RoleSearch(allied_creation_user.ReqRoleSearch{ | ||
149 | + OrgId: roleUserBeforeEditQuery.Operator.OrgId, | ||
150 | + Limit: 999, | ||
151 | + RoleType: 1, | ||
152 | + }) | ||
153 | + if err != nil { | ||
154 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
155 | + } | ||
156 | + orgs, err := creationUserGateway.OrgGetSubDepartment(allied_creation_user.ReqOrgGetSubDepartment{ | ||
157 | + OrgId: roleUserBeforeEditQuery.Operator.OrgId, | ||
158 | + }) | ||
159 | + if err != nil { | ||
160 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
161 | + } | ||
162 | + result := map[string]interface{}{ | ||
163 | + "orgs": orgs.Orgs, | ||
164 | + "roles": roles.Roles, | ||
165 | + } | ||
166 | + // 有传入角色ID才返回关联角色用户数据 | ||
167 | + if roleId > 0 { | ||
168 | + relatedUser, err := creationUserGateway.RoleGetRelatedUser(allied_creation_user.ReqRoleGetRelatedUser{ | ||
169 | + RoleId: int64(roleId), | ||
170 | + }) | ||
171 | + | ||
172 | + if err != nil { | ||
173 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
174 | + } | ||
175 | + result["notInRoleUser"] = relatedUser.NotInRoleUser | ||
176 | + result["roleUser"] = relatedUser.RoleUser | ||
177 | + } | ||
178 | + | ||
179 | + return result, nil | ||
118 | } | 180 | } |
119 | 181 | ||
120 | // 角色编辑关联菜单权限 | 182 | // 角色编辑关联菜单权限 |
@@ -149,14 +211,14 @@ func (rolesService *RolesService) RoleRemove(roleRemoveCommand *command.RoleRemo | @@ -149,14 +211,14 @@ func (rolesService *RolesService) RoleRemove(roleRemoveCommand *command.RoleRemo | ||
149 | roleRemoveCommand.Operator.UserId) | 211 | roleRemoveCommand.Operator.UserId) |
150 | 212 | ||
151 | var roleIds []int64 | 213 | var roleIds []int64 |
152 | - for _, v := range roleRemoveCommand.RoleId { | 214 | + for _, v := range roleRemoveCommand.RoleIds { |
153 | id, err := strconv.Atoi(v) | 215 | id, err := strconv.Atoi(v) |
154 | if err == nil { | 216 | if err == nil { |
155 | roleIds = append(roleIds, int64(id)) | 217 | roleIds = append(roleIds, int64(id)) |
156 | } | 218 | } |
157 | } | 219 | } |
158 | - _, err := creationUserGateway.RoleBatchRemove(allied_creation_user.ReqRoleBatchRemove{ | ||
159 | - RoleIds: roleIds, | 220 | + _, err := creationUserGateway.RoleRemove(allied_creation_user.ReqRoleRemove{ |
221 | + roleIds, | ||
160 | }) | 222 | }) |
161 | if err != nil { | 223 | if err != nil { |
162 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 224 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -183,7 +245,7 @@ func (rolesService *RolesService) RoleUserAdd(roleUserAddCommand *command.RoleUs | @@ -183,7 +245,7 @@ func (rolesService *RolesService) RoleUserAdd(roleUserAddCommand *command.RoleUs | ||
183 | UserIds: userIds, | 245 | UserIds: userIds, |
184 | }) | 246 | }) |
185 | if err != nil { | 247 | if err != nil { |
186 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 248 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
187 | } | 249 | } |
188 | return roleUserAddCommand, err | 250 | return roleUserAddCommand, err |
189 | } | 251 | } |
@@ -207,15 +269,27 @@ func (rolesService *RolesService) RoleUserDelete(roleUserDeleteCommand *command. | @@ -207,15 +269,27 @@ func (rolesService *RolesService) RoleUserDelete(roleUserDeleteCommand *command. | ||
207 | UserIds: userIds, | 269 | UserIds: userIds, |
208 | }) | 270 | }) |
209 | if err != nil { | 271 | if err != nil { |
210 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 272 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
211 | } | 273 | } |
212 | return roleUserDeleteCommand, err | 274 | return roleUserDeleteCommand, err |
213 | } | 275 | } |
214 | 276 | ||
215 | -// 角色下关联用户的数据 | 277 | +// 角色下关联用户的数据 (暂时不需要这个) |
216 | func (rolesService *RolesService) RoleUserInfo(roleUserInfoQuery *query.RoleUserInfoQuery) (interface{}, error) { | 278 | func (rolesService *RolesService) RoleUserInfo(roleUserInfoQuery *query.RoleUserInfoQuery) (interface{}, error) { |
217 | - //TODO | ||
218 | - return nil, nil | 279 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( |
280 | + roleUserInfoQuery.Operator.CompanyId, | ||
281 | + roleUserInfoQuery.Operator.OrgId, | ||
282 | + roleUserInfoQuery.Operator.UserId) | ||
283 | + relatedUser, err := creationUserGateway.RoleGetRelatedUser(allied_creation_user.ReqRoleGetRelatedUser{ | ||
284 | + RoleId: roleUserInfoQuery.RoleId, | ||
285 | + }) | ||
286 | + if err != nil { | ||
287 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
288 | + } | ||
289 | + var result = make(map[string]interface{}) | ||
290 | + result["notInRoleUser"] = relatedUser.NotInRoleUser | ||
291 | + result["roleUser"] = relatedUser.RoleUser | ||
292 | + return result, nil | ||
219 | } | 293 | } |
220 | 294 | ||
221 | func NewRolesService(options map[string]interface{}) *RolesService { | 295 | func NewRolesService(options map[string]interface{}) *RolesService { |
@@ -439,7 +439,7 @@ func (usersService *UsersService) SelectorCompanyRole(selectorQuery *query.Compa | @@ -439,7 +439,7 @@ func (usersService *UsersService) SelectorCompanyRole(selectorQuery *query.Compa | ||
439 | ) | 439 | ) |
440 | for _, v := range result.Roles { | 440 | for _, v := range result.Roles { |
441 | item = dto.UserRole{ | 441 | item = dto.UserRole{ |
442 | - RoleID: strconv.Itoa(v.RoleID), | 442 | + RoleID: strconv.Itoa(int(v.RoleID)), |
443 | RoleName: v.RoleName, | 443 | RoleName: v.RoleName, |
444 | OrgName: v.Ext.OrgName, | 444 | OrgName: v.Ext.OrgName, |
445 | Descript: v.Desc, | 445 | Descript: v.Desc, |
@@ -8,7 +8,7 @@ var LOG_LEVEL = "debug" | @@ -8,7 +8,7 @@ var LOG_LEVEL = "debug" | ||
8 | 8 | ||
9 | var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080" | 9 | var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080" |
10 | 10 | ||
11 | -var ALLIED_CREATION_USER_HOST = "http://localhost:8080" | 11 | +var ALLIED_CREATION_USER_HOST = "http://localhost:8081" |
12 | 12 | ||
13 | func init() { | 13 | func init() { |
14 | if os.Getenv("LOG_LEVEL") != "" { | 14 | if os.Getenv("LOG_LEVEL") != "" { |
@@ -200,8 +200,8 @@ func (gateway HttplibAlliedCreationUser) RoleUpdate(param ReqRoleUpdate) (*DataR | @@ -200,8 +200,8 @@ func (gateway HttplibAlliedCreationUser) RoleUpdate(param ReqRoleUpdate) (*DataR | ||
200 | 200 | ||
201 | // RoleRemove 移除角色 | 201 | // RoleRemove 移除角色 |
202 | func (gateway HttplibAlliedCreationUser) RoleRemove(param ReqRoleRemove) (*DataRoleRemove, error) { | 202 | func (gateway HttplibAlliedCreationUser) RoleRemove(param ReqRoleRemove) (*DataRoleRemove, error) { |
203 | - urlStr := gateway.baseUrL + "/role/" + strconv.FormatInt(param.RoleId, 10) | ||
204 | - method := "delete" | 203 | + urlStr := gateway.baseUrL + "/role/batch-delete" |
204 | + method := "post" | ||
205 | req := gateway.CreateRequest(urlStr, method) | 205 | req := gateway.CreateRequest(urlStr, method) |
206 | log.Logger.Debug("向用户模块请求数据:移除角色。", map[string]interface{}{ | 206 | log.Logger.Debug("向用户模块请求数据:移除角色。", map[string]interface{}{ |
207 | "api": method + ":" + urlStr, | 207 | "api": method + ":" + urlStr, |
@@ -42,6 +42,22 @@ type ( | @@ -42,6 +42,22 @@ type ( | ||
42 | } | 42 | } |
43 | 43 | ||
44 | DataOrgGetSubDepartment struct { | 44 | DataOrgGetSubDepartment struct { |
45 | + Orgs []struct { | ||
46 | + OrgID Int64String `json:"orgId"` | ||
47 | + //CompanyID int `json:"companyId"` | ||
48 | + //CreatedAt time.Time `json:"createdAt"` | ||
49 | + //UpdatedAt time.Time `json:"updatedAt"` | ||
50 | + //DeletedAt time.Time `json:"deletedAt"` | ||
51 | + //OrgCode string `json:"orgCode"` | ||
52 | + OrgName string `json:"orgName"` | ||
53 | + //IsOrg int `json:"isOrg"` | ||
54 | + //OrgStatus int `json:"orgStatus"` | ||
55 | + //ParentID int `json:"parentId"` | ||
56 | + //Ext struct { | ||
57 | + // OrgName string `json:"orgName"` | ||
58 | + // ParentDepName string `json:"parentDepName"` | ||
59 | + //} `json:"ext,omitempty"` | ||
60 | + } `json:"orgs"` | ||
45 | } | 61 | } |
46 | ) | 62 | ) |
47 | 63 |
1 | package allied_creation_user | 1 | package allied_creation_user |
2 | 2 | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "strconv" | ||
6 | +) | ||
7 | + | ||
3 | //################角色模块################## | 8 | //################角色模块################## |
9 | +type Int64String int64 | ||
10 | + | ||
11 | +func (t Int64String) MarshalJSON() ([]byte, error) { | ||
12 | + stamp := fmt.Sprintf(`"%d"`, t) | ||
13 | + return []byte(stamp), nil | ||
14 | +} | ||
15 | +func (t Int64String) UnMarshalJSON(data []byte) error { | ||
16 | + v, err := strconv.ParseInt(string(data), 10, 64) | ||
17 | + t = Int64String(v) | ||
18 | + return err | ||
19 | +} | ||
4 | 20 | ||
5 | //搜索角色列表 | 21 | //搜索角色列表 |
6 | type ( | 22 | type ( |
@@ -9,21 +25,21 @@ type ( | @@ -9,21 +25,21 @@ type ( | ||
9 | Offset int `json:"offset"` | 25 | Offset int `json:"offset"` |
10 | // 查询限制 | 26 | // 查询限制 |
11 | Limit int `json:"limit"` | 27 | Limit int `json:"limit"` |
28 | + // 角色类型 1.普通角色 1024:超级管理员 | ||
29 | + RoleType int `cname:"角色类型 1.普通角色 1024:超级管理员" json:"roleType,omitempty"` | ||
12 | //组织名称 | 30 | //组织名称 |
13 | OrgName string `json:"orgName"` | 31 | OrgName string `json:"orgName"` |
14 | //角色码名称 | 32 | //角色码名称 |
15 | RoleName string `json:"roleName"` | 33 | RoleName string `json:"roleName"` |
16 | - | ||
17 | - InOrgIds []int `json:"inOrgIds"` | ||
18 | - | ||
19 | - OrgId int | 34 | + // 组织ID |
35 | + OrgId int64 `json:"orgId"` | ||
20 | } | 36 | } |
21 | 37 | ||
22 | DataRoleSearch struct { | 38 | DataRoleSearch struct { |
23 | Count int64 | 39 | Count int64 |
24 | Roles []struct { | 40 | Roles []struct { |
25 | AccessMenus []int `json:"accessMenus"` | 41 | AccessMenus []int `json:"accessMenus"` |
26 | - CompanyID int `json:"companyId"` | 42 | + CompanyID Int64String `json:"companyId"` |
27 | CreatedAt string `json:"createdAt"` | 43 | CreatedAt string `json:"createdAt"` |
28 | Desc string `json:"desc"` | 44 | Desc string `json:"desc"` |
29 | Ext struct { | 45 | Ext struct { |
@@ -33,12 +49,12 @@ type ( | @@ -33,12 +49,12 @@ type ( | ||
33 | Phone string `json:"phone"` | 49 | Phone string `json:"phone"` |
34 | UserName string `json:"userName"` | 50 | UserName string `json:"userName"` |
35 | } `json:"ext"` | 51 | } `json:"ext"` |
36 | - OrgID int `json:"orgId"` | ||
37 | - RoleID int `json:"roleId"` | 52 | + OrgID Int64String `json:"orgId"` |
53 | + RoleID Int64String `json:"roleId"` | ||
38 | RoleName string `json:"roleName"` | 54 | RoleName string `json:"roleName"` |
39 | - RoleType int `json:"roleType"` //角色类型 1.普通角色 1024:超级管理员 | 55 | + RoleType int `json:"roleType"` |
40 | UpdatedAt string `json:"updatedAt"` | 56 | UpdatedAt string `json:"updatedAt"` |
41 | - } `json:"role"` | 57 | + } `json:"roles"` |
42 | } | 58 | } |
43 | ) | 59 | ) |
44 | 60 | ||
@@ -49,11 +65,10 @@ type ( | @@ -49,11 +65,10 @@ type ( | ||
49 | } | 65 | } |
50 | 66 | ||
51 | DataRoleGet struct { | 67 | DataRoleGet struct { |
52 | - Role struct { | ||
53 | AccessMenus []int `json:"accessMenus"` | 68 | AccessMenus []int `json:"accessMenus"` |
54 | CompanyID int `json:"companyId"` | 69 | CompanyID int `json:"companyId"` |
55 | CreatedAt string `json:"createdAt"` | 70 | CreatedAt string `json:"createdAt"` |
56 | - Desc int `json:"desc"` | 71 | + Desc string `json:"desc"` |
57 | Ext struct { | 72 | Ext struct { |
58 | DepName string `json:"depName"` | 73 | DepName string `json:"depName"` |
59 | OrgName string `json:"orgName"` | 74 | OrgName string `json:"orgName"` |
@@ -66,7 +81,6 @@ type ( | @@ -66,7 +81,6 @@ type ( | ||
66 | RoleName string `json:"roleName"` | 81 | RoleName string `json:"roleName"` |
67 | RoleType int `json:"roleType"` | 82 | RoleType int `json:"roleType"` |
68 | UpdatedAt string `json:"updatedAt"` | 83 | UpdatedAt string `json:"updatedAt"` |
69 | - } `json:"role"` | ||
70 | } | 84 | } |
71 | ) | 85 | ) |
72 | 86 | ||
@@ -123,7 +137,7 @@ type ( | @@ -123,7 +137,7 @@ type ( | ||
123 | //移除角色 | 137 | //移除角色 |
124 | type ( | 138 | type ( |
125 | ReqRoleRemove struct { | 139 | ReqRoleRemove struct { |
126 | - RoleId int64 `json:"roleId"` | 140 | + RoleIds []int64 `json:"roleIds"` |
127 | } | 141 | } |
128 | 142 | ||
129 | DataRoleRemove struct { | 143 | DataRoleRemove struct { |
@@ -150,14 +164,18 @@ type ( | @@ -150,14 +164,18 @@ type ( | ||
150 | 164 | ||
151 | DataRoleGetRelatedUser struct { | 165 | DataRoleGetRelatedUser struct { |
152 | NotInRoleUser []struct { | 166 | NotInRoleUser []struct { |
167 | + DepartmentId Int64String `json:"departmentId"` | ||
153 | DepartmentName string `json:"departmentName"` | 168 | DepartmentName string `json:"departmentName"` |
154 | - UserID int `json:"userId"` | 169 | + UserID Int64String `json:"userId"` |
155 | UserName string `json:"userName"` | 170 | UserName string `json:"userName"` |
171 | + UserCode string `json:"userCode"` | ||
156 | } `json:"notInRoleUser"` | 172 | } `json:"notInRoleUser"` |
157 | RoleUser []struct { | 173 | RoleUser []struct { |
174 | + DepartmentId Int64String `json:"departmentId"` | ||
158 | DepartmentName string `json:"departmentName"` | 175 | DepartmentName string `json:"departmentName"` |
159 | - UserID int `json:"userId"` | 176 | + UserID Int64String `json:"userId"` |
160 | UserName string `json:"userName"` | 177 | UserName string `json:"userName"` |
178 | + UserCode string `json:"userCode"` | ||
161 | } `json:"roleUser"` | 179 | } `json:"roleUser"` |
162 | } | 180 | } |
163 | ) | 181 | ) |
@@ -169,6 +187,22 @@ type ( | @@ -169,6 +187,22 @@ type ( | ||
169 | } | 187 | } |
170 | 188 | ||
171 | DataRoleGetAccessMenus struct { | 189 | DataRoleGetAccessMenus struct { |
190 | + Menus []struct { | ||
191 | + MenuID int `json:"menuId"` | ||
192 | + ParentID int `json:"parentId"` | ||
193 | + MenuName string `json:"menuName"` | ||
194 | + MenuAlias string `json:"menuAlias"` | ||
195 | + Code string `json:"code"` | ||
196 | + AccessCode string `json:"accessCode,omitempty"` | ||
197 | + MenuType string `json:"menuType"` | ||
198 | + Icon string `json:"icon"` | ||
199 | + Sort int `json:"sort"` | ||
200 | + Remark string `json:"remark,omitempty"` | ||
201 | + Category string `json:"category"` | ||
202 | + IsPublish int `json:"isPublish"` | ||
203 | + EnableStatus int `json:"enableStatus"` | ||
204 | + ParentPath string `json:"parentPath,omitempty"` | ||
205 | + } `json:"menus"` | ||
172 | } | 206 | } |
173 | ) | 207 | ) |
174 | 208 |
@@ -17,7 +17,7 @@ func init() { | @@ -17,7 +17,7 @@ func init() { | ||
17 | web.BConfig.RunMode = "dev" | 17 | web.BConfig.RunMode = "dev" |
18 | web.BConfig.Listen.HTTPPort = 8080 | 18 | web.BConfig.Listen.HTTPPort = 8080 |
19 | web.BConfig.Listen.EnableAdmin = false | 19 | web.BConfig.Listen.EnableAdmin = false |
20 | - web.BConfig.WebConfig.CommentRouterPath = "/pkg/port/beego" | 20 | + web.BConfig.WebConfig.CommentRouterPath = "/pkg/port/beego/routers" |
21 | if os.Getenv("RUN_MODE") != "" { | 21 | if os.Getenv("RUN_MODE") != "" { |
22 | web.BConfig.RunMode = os.Getenv("RUN_MODE") | 22 | web.BConfig.RunMode = os.Getenv("RUN_MODE") |
23 | } | 23 | } |
@@ -27,7 +27,7 @@ func init() { | @@ -27,7 +27,7 @@ func init() { | ||
27 | web.BConfig.Listen.HTTPPort = port | 27 | web.BConfig.Listen.HTTPPort = port |
28 | } | 28 | } |
29 | } | 29 | } |
30 | - web.InsertFilter("/*", web.BeforeExec, filters.AllowCors()) | 30 | + web.InsertFilter("/*", web.BeforeRouter, filters.AllowCors()) |
31 | web.InsertFilter("/*", web.BeforeExec, filters.CreateRequstLogFilter(log.Logger)) | 31 | web.InsertFilter("/*", web.BeforeExec, filters.CreateRequstLogFilter(log.Logger)) |
32 | web.InsertFilter("/*", web.AfterExec, filters.CreateResponseLogFilter(log.Logger), web.WithReturnOnOutput(false)) | 32 | web.InsertFilter("/*", web.AfterExec, filters.CreateResponseLogFilter(log.Logger), web.WithReturnOnOutput(false)) |
33 | } | 33 | } |
@@ -13,7 +13,7 @@ func (controller *baseController) returnPageListData(count int64, data interface | @@ -13,7 +13,7 @@ func (controller *baseController) returnPageListData(count int64, data interface | ||
13 | dataMap := map[string]interface{}{ | 13 | dataMap := map[string]interface{}{ |
14 | "grid": map[string]interface{}{ | 14 | "grid": map[string]interface{}{ |
15 | "total": count, | 15 | "total": count, |
16 | - "pageNumber": pageNumber, | 16 | + //"pageNumber": pageNumber, |
17 | "list": data, | 17 | "list": data, |
18 | }, | 18 | }, |
19 | } | 19 | } |
@@ -38,9 +38,9 @@ func (controller *baseController) GetOrgId() int64 { | @@ -38,9 +38,9 @@ func (controller *baseController) GetOrgId() int64 { | ||
38 | 38 | ||
39 | func (controller *baseController) GetOperator() domain.Operator { | 39 | func (controller *baseController) GetOperator() domain.Operator { |
40 | return domain.Operator{ | 40 | return domain.Operator{ |
41 | - UserId: 1, | ||
42 | - CompanyId: 1, | ||
43 | - OrgId: 1, | 41 | + UserId: 9, |
42 | + CompanyId: 23, | ||
43 | + OrgId: 45, | ||
44 | UserBaseId: 1, | 44 | UserBaseId: 1, |
45 | } | 45 | } |
46 | } | 46 | } |
@@ -80,6 +80,9 @@ func (controller *RolesController) RoleUserDelete() { | @@ -80,6 +80,9 @@ func (controller *RolesController) RoleUserDelete() { | ||
80 | func (controller *RolesController) RoleUserBeforeEdit() { | 80 | func (controller *RolesController) RoleUserBeforeEdit() { |
81 | rolesService := service.NewRolesService(nil) | 81 | rolesService := service.NewRolesService(nil) |
82 | roleUserBeforeEditQuery := &query.RoleUserBeforeEditQuery{} | 82 | roleUserBeforeEditQuery := &query.RoleUserBeforeEditQuery{} |
83 | + roleUserBeforeEditQuery.Operator = controller.GetOperator() | ||
84 | + roleId := controller.GetString("roleId") | ||
85 | + roleUserBeforeEditQuery.RoleId = roleId | ||
83 | data, err := rolesService.RoleUserBeforeEdit(roleUserBeforeEditQuery) | 86 | data, err := rolesService.RoleUserBeforeEdit(roleUserBeforeEditQuery) |
84 | controller.Response(data, err) | 87 | controller.Response(data, err) |
85 | } | 88 | } |
@@ -87,6 +90,8 @@ func (controller *RolesController) RoleUserBeforeEdit() { | @@ -87,6 +90,8 @@ func (controller *RolesController) RoleUserBeforeEdit() { | ||
87 | func (controller *RolesController) RoleMenuBeforeEdit() { | 90 | func (controller *RolesController) RoleMenuBeforeEdit() { |
88 | rolesService := service.NewRolesService(nil) | 91 | rolesService := service.NewRolesService(nil) |
89 | roleMenuBeforeEditQuery := &query.RoleMenuBeforeEditQuery{} | 92 | roleMenuBeforeEditQuery := &query.RoleMenuBeforeEditQuery{} |
93 | + roleMenuBeforeEditQuery.Operator = controller.GetOperator() | ||
94 | + controller.Unmarshal(roleMenuBeforeEditQuery) | ||
90 | data, err := rolesService.RoleMenuBeforeEdit(roleMenuBeforeEditQuery) | 95 | data, err := rolesService.RoleMenuBeforeEdit(roleMenuBeforeEditQuery) |
91 | controller.Response(data, err) | 96 | controller.Response(data, err) |
92 | } | 97 | } |
@@ -101,3 +106,12 @@ func (controller *RolesController) RoleMenuEdit() { | @@ -101,3 +106,12 @@ func (controller *RolesController) RoleMenuEdit() { | ||
101 | data, err := rolesService.RoleMenuEdit(roleMenuEditQuery) | 106 | data, err := rolesService.RoleMenuEdit(roleMenuEditQuery) |
102 | controller.Response(data, err) | 107 | controller.Response(data, err) |
103 | } | 108 | } |
109 | + | ||
110 | +func (controller *RolesController) RoleDelete() { | ||
111 | + rolesService := service.NewRolesService(nil) | ||
112 | + roleRemoveCommand := &command.RoleRemoveCommand{} | ||
113 | + controller.Unmarshal(roleRemoveCommand) | ||
114 | + roleRemoveCommand.Operator = controller.GetOperator() | ||
115 | + data, err := rolesService.RoleRemove(roleRemoveCommand) | ||
116 | + controller.Response(data, err) | ||
117 | +} |
@@ -11,9 +11,10 @@ func init() { | @@ -11,9 +11,10 @@ func init() { | ||
11 | web.Router("/v1/web/roles/search", &web_client.RolesController{}, "Post:RoleList") | 11 | web.Router("/v1/web/roles/search", &web_client.RolesController{}, "Post:RoleList") |
12 | web.Router("/v1/web/roles/:roleId", &web_client.RolesController{}, "Get:RoleGet") | 12 | web.Router("/v1/web/roles/:roleId", &web_client.RolesController{}, "Get:RoleGet") |
13 | web.Router("/v1/web/roles/role-user/:roleId", &web_client.RolesController{}, "Get:RoleUserInfo") | 13 | web.Router("/v1/web/roles/role-user/:roleId", &web_client.RolesController{}, "Get:RoleUserInfo") |
14 | - web.Router("/v1/web/roles/role-user", &web_client.RolesController{}, "Post:RoleUserAdd") | ||
15 | - web.Router("/v1/web/roles/role-user", &web_client.RolesController{}, "Delete:RoleUserDelete") | 14 | + web.Router("/v1/web/roles/role-user/assign", &web_client.RolesController{}, "Post:RoleUserAdd") |
15 | + web.Router("/v1/web/roles/role-user/unassign", &web_client.RolesController{}, "Post:RoleUserDelete") | ||
16 | web.Router("/v1/web/roles/role-user/before-edit", &web_client.RolesController{}, "Get:RoleUserBeforeEdit") | 16 | web.Router("/v1/web/roles/role-user/before-edit", &web_client.RolesController{}, "Get:RoleUserBeforeEdit") |
17 | web.Router("/v1/web/roles/role-menu/before-edit", &web_client.RolesController{}, "Get:RoleMenuBeforeEdit") | 17 | web.Router("/v1/web/roles/role-menu/before-edit", &web_client.RolesController{}, "Get:RoleMenuBeforeEdit") |
18 | web.Router("/v1/web/roles/role-menu/:roleId", &web_client.RolesController{}, "Put:RoleMenuEdit") | 18 | web.Router("/v1/web/roles/role-menu/:roleId", &web_client.RolesController{}, "Put:RoleMenuEdit") |
19 | + web.Router("/v1/web/roles/batch-delete", &web_client.RolesController{}, "Post:RoleDelete") | ||
19 | } | 20 | } |
-
请 注册 或 登录 后发表评论