正在显示
11 个修改的文件
包含
132 行增加
和
30 行删除
@@ -5,7 +5,16 @@ type RoleItem struct { | @@ -5,7 +5,16 @@ 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"` | 10 | RoleType int `json:"roleType"` |
11 | + Ext Ext `json:"ext"` | ||
12 | +} | ||
13 | + | ||
14 | +type Ext struct { | ||
15 | + DepName string `json:"depName"` | ||
16 | + OrgName string `json:"orgName"` | ||
17 | + ParentDepName string `json:"parentDepName"` | ||
18 | + Phone string `json:"phone"` | ||
19 | + UserName string `json:"userName"` | ||
11 | } | 20 | } |
@@ -2,11 +2,14 @@ package query | @@ -2,11 +2,14 @@ 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 int64 `json:"roleId" valid:"Required"` |
12 | } | 15 | } |
@@ -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"` | ||
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 | } |
@@ -99,6 +112,7 @@ func (rolesService *RolesService) RoleList(roleListQuery *query.RoleListQuery) ( | @@ -99,6 +112,7 @@ func (rolesService *RolesService) RoleList(roleListQuery *query.RoleListQuery) ( | ||
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 |
@@ -113,8 +127,31 @@ func (rolesService *RolesService) RoleMenuBeforeEdit(roleMenuBeforeEditQuery *qu | @@ -113,8 +127,31 @@ func (rolesService *RolesService) RoleMenuBeforeEdit(roleMenuBeforeEditQuery *qu | ||
113 | 127 | ||
114 | // 编辑角色关联用户的前置准备数据 | 128 | // 编辑角色关联用户的前置准备数据 |
115 | func (rolesService *RolesService) RoleUserBeforeEdit(roleUserBeforeEditQuery *query.RoleUserBeforeEditQuery) (interface{}, error) { | 129 | func (rolesService *RolesService) RoleUserBeforeEdit(roleUserBeforeEditQuery *query.RoleUserBeforeEditQuery) (interface{}, error) { |
116 | - //TODO | ||
117 | - return nil, nil | 130 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( |
131 | + roleUserBeforeEditQuery.Operator.CompanyId, | ||
132 | + roleUserBeforeEditQuery.Operator.OrgId, | ||
133 | + roleUserBeforeEditQuery.Operator.UserId) | ||
134 | + //roleId, _ := strconv.Atoi(roleUserBeforeEditQuery.RoleId) | ||
135 | + | ||
136 | + roles, err := creationUserGateway.RoleSearch(allied_creation_user.ReqRoleSearch{ | ||
137 | + OrgId: roleUserBeforeEditQuery.Operator.OrgId, | ||
138 | + Limit: 100, | ||
139 | + RoleType: 1, | ||
140 | + }) | ||
141 | + if err != nil { | ||
142 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
143 | + } | ||
144 | + orgs, err := creationUserGateway.OrgGetSubDepartment(allied_creation_user.ReqOrgGetSubDepartment{ | ||
145 | + OrgId: roleUserBeforeEditQuery.Operator.OrgId, | ||
146 | + }) | ||
147 | + if err != nil { | ||
148 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
149 | + } | ||
150 | + result := map[string]interface{}{ | ||
151 | + "orgs": orgs.Orgs, | ||
152 | + "roles": roles.Roles, | ||
153 | + } | ||
154 | + return result, nil | ||
118 | } | 155 | } |
119 | 156 | ||
120 | // 角色编辑关联菜单权限 | 157 | // 角色编辑关联菜单权限 |
@@ -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") != "" { |
@@ -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 int `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 |
@@ -9,10 +9,14 @@ type ( | @@ -9,10 +9,14 @@ type ( | ||
9 | Offset int `json:"offset"` | 9 | Offset int `json:"offset"` |
10 | // 查询限制 | 10 | // 查询限制 |
11 | Limit int `json:"limit"` | 11 | Limit int `json:"limit"` |
12 | + // 角色类型 1.普通角色 1024:超级管理员 | ||
13 | + RoleType int `cname:"角色类型 1.普通角色 1024:超级管理员" json:"roleType,omitempty"` | ||
12 | //组织名称 | 14 | //组织名称 |
13 | OrgName string `json:"orgName"` | 15 | OrgName string `json:"orgName"` |
14 | //角色码名称 | 16 | //角色码名称 |
15 | RoleName string `json:"roleName"` | 17 | RoleName string `json:"roleName"` |
18 | + // 组织ID | ||
19 | + OrgId int64 `json:"orgId"` | ||
16 | } | 20 | } |
17 | 21 | ||
18 | DataRoleSearch struct { | 22 | DataRoleSearch struct { |
@@ -34,7 +38,7 @@ type ( | @@ -34,7 +38,7 @@ type ( | ||
34 | RoleName string `json:"roleName"` | 38 | RoleName string `json:"roleName"` |
35 | RoleType int `json:"roleType"` | 39 | RoleType int `json:"roleType"` |
36 | UpdatedAt string `json:"updatedAt"` | 40 | UpdatedAt string `json:"updatedAt"` |
37 | - } `json:"role"` | 41 | + } `json:"roles"` |
38 | } | 42 | } |
39 | ) | 43 | ) |
40 | 44 | ||
@@ -45,24 +49,22 @@ type ( | @@ -45,24 +49,22 @@ type ( | ||
45 | } | 49 | } |
46 | 50 | ||
47 | DataRoleGet struct { | 51 | DataRoleGet struct { |
48 | - Role struct { | ||
49 | - AccessMenus []int `json:"accessMenus"` | ||
50 | - CompanyID int `json:"companyId"` | ||
51 | - CreatedAt string `json:"createdAt"` | ||
52 | - Desc int `json:"desc"` | ||
53 | - Ext struct { | ||
54 | - DepName string `json:"depName"` | ||
55 | - OrgName string `json:"orgName"` | ||
56 | - ParentDepName string `json:"parentDepName"` | ||
57 | - Phone string `json:"phone"` | ||
58 | - UserName string `json:"userName"` | ||
59 | - } `json:"ext"` | ||
60 | - OrgID int `json:"orgId"` | ||
61 | - RoleID int `json:"roleId"` | ||
62 | - RoleName string `json:"roleName"` | ||
63 | - RoleType int `json:"roleType"` | ||
64 | - UpdatedAt string `json:"updatedAt"` | ||
65 | - } `json:"role"` | 52 | + AccessMenus []int `json:"accessMenus"` |
53 | + CompanyID int `json:"companyId"` | ||
54 | + CreatedAt string `json:"createdAt"` | ||
55 | + Desc string `json:"desc"` | ||
56 | + Ext struct { | ||
57 | + DepName string `json:"depName"` | ||
58 | + OrgName string `json:"orgName"` | ||
59 | + ParentDepName string `json:"parentDepName"` | ||
60 | + Phone string `json:"phone"` | ||
61 | + UserName string `json:"userName"` | ||
62 | + } `json:"ext"` | ||
63 | + OrgID int `json:"orgId"` | ||
64 | + RoleID int `json:"roleId"` | ||
65 | + RoleName string `json:"roleName"` | ||
66 | + RoleType int `json:"roleType"` | ||
67 | + UpdatedAt string `json:"updatedAt"` | ||
66 | } | 68 | } |
67 | ) | 69 | ) |
68 | 70 | ||
@@ -135,6 +137,16 @@ type ( | @@ -135,6 +137,16 @@ type ( | ||
135 | } | 137 | } |
136 | 138 | ||
137 | DataRoleGetRelatedUser struct { | 139 | DataRoleGetRelatedUser struct { |
140 | + NotInRoleUser []struct { | ||
141 | + DepartmentName string `json:"departmentName"` | ||
142 | + UserID int `json:"userId"` | ||
143 | + UserName string `json:"userName"` | ||
144 | + } `json:"notInRoleUser"` | ||
145 | + RoleUser []struct { | ||
146 | + DepartmentName string `json:"departmentName"` | ||
147 | + UserID int `json:"userId"` | ||
148 | + UserName string `json:"userName"` | ||
149 | + } `json:"roleUser"` | ||
138 | } | 150 | } |
139 | ) | 151 | ) |
140 | 152 | ||
@@ -145,6 +157,22 @@ type ( | @@ -145,6 +157,22 @@ type ( | ||
145 | } | 157 | } |
146 | 158 | ||
147 | DataRoleGetAccessMenus struct { | 159 | DataRoleGetAccessMenus struct { |
160 | + Menus []struct { | ||
161 | + MenuID int `json:"menuId"` | ||
162 | + ParentID int `json:"parentId"` | ||
163 | + MenuName string `json:"menuName"` | ||
164 | + MenuAlias string `json:"menuAlias"` | ||
165 | + Code string `json:"code"` | ||
166 | + AccessCode string `json:"accessCode,omitempty"` | ||
167 | + MenuType string `json:"menuType"` | ||
168 | + Icon string `json:"icon"` | ||
169 | + Sort int `json:"sort"` | ||
170 | + Remark string `json:"remark,omitempty"` | ||
171 | + Category string `json:"category"` | ||
172 | + IsPublish int `json:"isPublish"` | ||
173 | + EnableStatus int `json:"enableStatus"` | ||
174 | + ParentPath string `json:"parentPath,omitempty"` | ||
175 | + } `json:"menus"` | ||
148 | } | 176 | } |
149 | ) | 177 | ) |
150 | 178 |
@@ -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 | } |
@@ -80,6 +80,7 @@ func (controller *RolesController) RoleUserDelete() { | @@ -80,6 +80,7 @@ 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() | ||
83 | data, err := rolesService.RoleUserBeforeEdit(roleUserBeforeEditQuery) | 84 | data, err := rolesService.RoleUserBeforeEdit(roleUserBeforeEditQuery) |
84 | controller.Response(data, err) | 85 | controller.Response(data, err) |
85 | } | 86 | } |
@@ -87,6 +88,7 @@ func (controller *RolesController) RoleUserBeforeEdit() { | @@ -87,6 +88,7 @@ func (controller *RolesController) RoleUserBeforeEdit() { | ||
87 | func (controller *RolesController) RoleMenuBeforeEdit() { | 88 | func (controller *RolesController) RoleMenuBeforeEdit() { |
88 | rolesService := service.NewRolesService(nil) | 89 | rolesService := service.NewRolesService(nil) |
89 | roleMenuBeforeEditQuery := &query.RoleMenuBeforeEditQuery{} | 90 | roleMenuBeforeEditQuery := &query.RoleMenuBeforeEditQuery{} |
91 | + roleMenuBeforeEditQuery.Operator = controller.GetOperator() | ||
90 | data, err := rolesService.RoleMenuBeforeEdit(roleMenuBeforeEditQuery) | 92 | data, err := rolesService.RoleMenuBeforeEdit(roleMenuBeforeEditQuery) |
91 | controller.Response(data, err) | 93 | controller.Response(data, err) |
92 | } | 94 | } |
-
请 注册 或 登录 后发表评论