正在显示
6 个修改的文件
包含
85 行增加
和
47 行删除
@@ -80,7 +80,7 @@ func (rs *RoleService) Update(in *command.UpdateRoleCommand) (interface{}, error | @@ -80,7 +80,7 @@ func (rs *RoleService) Update(in *command.UpdateRoleCommand) (interface{}, error | ||
80 | } | 80 | } |
81 | 81 | ||
82 | role.Name = in.Name | 82 | role.Name = in.Name |
83 | - role.Name = in.Description | 83 | + role.Description = in.Description |
84 | 84 | ||
85 | role, err = roleRepository.Insert(role) | 85 | role, err = roleRepository.Insert(role) |
86 | if err != nil { | 86 | if err != nil { |
@@ -171,6 +171,5 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | @@ -171,6 +171,5 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | ||
171 | roleUser.Users = tempList | 171 | roleUser.Users = tempList |
172 | adapterList = append(adapterList, roleUser) | 172 | adapterList = append(adapterList, roleUser) |
173 | } | 173 | } |
174 | - | ||
175 | - return map[string]interface{}{"list": adapterList}, nil | 174 | + return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil |
176 | } | 175 | } |
@@ -2,6 +2,7 @@ package service | @@ -2,6 +2,7 @@ package service | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/linmadan/egglib-go/core/application" | 4 | "github.com/linmadan/egglib-go/core/application" |
5 | + "github.com/linmadan/egglib-go/utils/tool_funs" | ||
5 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/command" | 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/command" |
7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
@@ -88,47 +89,25 @@ func (rs *RoleUserService) Remove(in *command.UserRoleDeleteCommand) (interface{ | @@ -88,47 +89,25 @@ func (rs *RoleUserService) Remove(in *command.UserRoleDeleteCommand) (interface{ | ||
88 | return rus, nil | 89 | return rus, nil |
89 | } | 90 | } |
90 | 91 | ||
91 | -//func (rs *RoleUserService) ListForUser(in *command.UserRoleQueryCommand) (interface{}, error) { | ||
92 | -// transactionContext, err := factory.StartTransaction() | ||
93 | -// if err != nil { | ||
94 | -// return nil, err | ||
95 | -// } | ||
96 | -// defer func() { | ||
97 | -// transactionContext.RollbackTransaction() | ||
98 | -// }() | ||
99 | -// roleRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
100 | -// userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
101 | -// | ||
102 | -// in.PageNumber = 1 | ||
103 | -// in.PageSize = 9999999 | ||
104 | -// | ||
105 | -// conditionMap := tool_funs.SimpleStructToMap(in) | ||
106 | -// _, roles, err := roleRepository.Find(conditionMap) | ||
107 | -// if err != nil { | ||
108 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
109 | -// } | ||
110 | -// if len(roles) == 0 { | ||
111 | -// return nil, application.ThrowError(application.BUSINESS_ERROR, "未找到角色数据") | ||
112 | -// } | ||
113 | -// | ||
114 | -// ids := make([]int64, 0) | ||
115 | -// for i := range roles { | ||
116 | -// ids = append(ids, roles[i].Id) | ||
117 | -// } | ||
118 | -// | ||
119 | -// _, users, err := userRepository.Find(conditionMap) | ||
120 | -// if err != nil { | ||
121 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
122 | -// } | ||
123 | -// | ||
124 | -// //for i := range users { | ||
125 | -// // users[i].RoleUserIds | ||
126 | -// //} | ||
127 | -// | ||
128 | -// //if err := transactionContext.CommitTransaction(); err != nil { | ||
129 | -// // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
130 | -// //} | ||
131 | -// //groupAdapter := &adapter.RoleUserAdapter{} | ||
132 | -// //newList := groupAdapter.TransformTree(groups) | ||
133 | -// return map[string]interface{}{"list": users}, nil | ||
134 | -//} | 92 | +func (rs *RoleUserService) ListRole(in *command.UserRoleQueryCommand) (interface{}, error) { |
93 | + transactionContext, err := factory.StartTransaction() | ||
94 | + if err != nil { | ||
95 | + return nil, err | ||
96 | + } | ||
97 | + defer func() { | ||
98 | + transactionContext.RollbackTransaction() | ||
99 | + }() | ||
100 | + ruRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
101 | + | ||
102 | + in.PageNumber = 1 | ||
103 | + in.PageSize = 9999999 | ||
104 | + | ||
105 | + tempList, err := ruRepository.FindAllContainUser(1, 10, in.CompanyId, in.RoleId) | ||
106 | + if err != nil { | ||
107 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
108 | + } | ||
109 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
110 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
111 | + } | ||
112 | + return tool_funs.SimpleWrapGridMap(int64(len(tempList)), tempList), nil | ||
113 | +} |
@@ -44,3 +44,14 @@ func (controller *RoleController) RemoveRole() { | @@ -44,3 +44,14 @@ func (controller *RoleController) RemoveRole() { | ||
44 | controller.Response(ruService.Remove(in)) | 44 | controller.Response(ruService.Remove(in)) |
45 | } | 45 | } |
46 | } | 46 | } |
47 | + | ||
48 | +func (controller *RoleController) ListForUserRole() { | ||
49 | + ruService := service.NewRoleService() | ||
50 | + in := &command.QueryRoleUserCommand{} | ||
51 | + if err := controller.Unmarshal(in); err != nil { | ||
52 | + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
53 | + } else { | ||
54 | + in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
55 | + controller.Response(ruService.ListForUser(in)) | ||
56 | + } | ||
57 | +} |
@@ -33,3 +33,14 @@ func (controller *RoleUserController) RemoveRoleUser() { | @@ -33,3 +33,14 @@ func (controller *RoleUserController) RemoveRoleUser() { | ||
33 | controller.Response(ruService.Remove(in)) | 33 | controller.Response(ruService.Remove(in)) |
34 | } | 34 | } |
35 | } | 35 | } |
36 | + | ||
37 | +func (controller *RoleUserController) ListRoleUser() { | ||
38 | + ruService := service.NewRoleUserService() | ||
39 | + in := &command.UserRoleQueryCommand{} | ||
40 | + if err := controller.Unmarshal(in); err != nil { | ||
41 | + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
42 | + } else { | ||
43 | + in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
44 | + controller.Response(ruService.ListRole(in)) | ||
45 | + } | ||
46 | +} |
pkg/port/beego/routers/role_router.go
0 → 100644
1 | +package routers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/beego/beego/v2/server/web" | ||
5 | + "github.com/linmadan/egglib-go/web/beego/filters" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | ||
8 | +) | ||
9 | + | ||
10 | +func init() { | ||
11 | + ns := web.NewNamespace("/v1/role", | ||
12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckToken()), | ||
13 | + //web.NSRouter("/", &controllers.RoleController{}, "Post:CreateRole"), | ||
14 | + //web.NSRouter("/", &controllers.RoleController{}, "Put:UpdateRole"), | ||
15 | + //web.NSRouter("/", &controllers.RoleController{}, "Delete:RemoveRole"), | ||
16 | + //web.NSRouter("/:Id", &controllers.RoleController{}, "Get:GetRole"), | ||
17 | + web.NSRouter("/all", &controllers.RoleController{}, "Post:ListForUserRole"), | ||
18 | + ) | ||
19 | + web.AddNamespace(ns) | ||
20 | +} |
pkg/port/beego/routers/role_user_router.go
0 → 100644
1 | +package routers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/beego/beego/v2/server/web" | ||
5 | + "github.com/linmadan/egglib-go/web/beego/filters" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | ||
8 | +) | ||
9 | + | ||
10 | +func init() { | ||
11 | + ns := web.NewNamespace("/v1/role-user", | ||
12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckToken()), | ||
13 | + web.NSRouter("/", &controllers.RoleUserController{}, "Post:CreateRole"), | ||
14 | + web.NSRouter("/", &controllers.RoleUserController{}, "Delete:RemoveRole"), | ||
15 | + web.NSRouter("/all", &controllers.RoleUserController{}, "Post:ListRoleUser"), | ||
16 | + ) | ||
17 | + web.AddNamespace(ns) | ||
18 | +} |
-
请 注册 或 登录 后发表评论