Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway into dev
正在显示
8 个修改的文件
包含
80 行增加
和
5 行删除
@@ -279,7 +279,7 @@ func (svr AuthService) GetUserInfo(userInfoCommand *command.UserInfoCommand) (in | @@ -279,7 +279,7 @@ func (svr AuthService) GetUserInfo(userInfoCommand *command.UserInfoCommand) (in | ||
279 | } | 279 | } |
280 | 280 | ||
281 | //GetUserMenus 获取用户信息-额外的数据 | 281 | //GetUserMenus 获取用户信息-额外的数据 |
282 | -func (svr AuthService) GetUserInfoExtra(userInfoCommand *command.UserInfoCommand) (interface{}, error) { | 282 | +func (svr AuthService) GetFavoriteMenus(userInfoCommand *command.UserInfoCommand) (interface{}, error) { |
283 | creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | 283 | creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( |
284 | userInfoCommand.Operator) | 284 | userInfoCommand.Operator) |
285 | resultUser, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{ | 285 | resultUser, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{ |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type MenuFavoriteCommand struct { | ||
12 | + //操作人 | ||
13 | + Operator domain.Operator `json:"-"` | ||
14 | + // 1:添加菜单 2:移除菜单 3.全量更新 | ||
15 | + Action int `json:"action" valid:"Required"` | ||
16 | + // 对应菜单的code | ||
17 | + FavoriteMenus []string `json:"favoriteMenus,omitempty"` | ||
18 | +} | ||
19 | + | ||
20 | +func (menuFavoriteCommand *MenuFavoriteCommand) Valid(validation *validation.Validation) { | ||
21 | + | ||
22 | +} | ||
23 | + | ||
24 | +func (menuFavoriteCommand *MenuFavoriteCommand) ValidateCommand() error { | ||
25 | + valid := validation.Validation{} | ||
26 | + b, err := valid.Valid(menuFavoriteCommand) | ||
27 | + if err != nil { | ||
28 | + return err | ||
29 | + } | ||
30 | + if !b { | ||
31 | + for _, validErr := range valid.Errors { | ||
32 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
33 | + } | ||
34 | + } | ||
35 | + return nil | ||
36 | +} |
@@ -199,3 +199,22 @@ func (srv UserService) MessagesMarkRead(cmd *command.MessageMarkReadCommand) (in | @@ -199,3 +199,22 @@ func (srv UserService) MessagesMarkRead(cmd *command.MessageMarkReadCommand) (in | ||
199 | //} | 199 | //} |
200 | return struct{}{}, nil | 200 | return struct{}{}, nil |
201 | } | 201 | } |
202 | + | ||
203 | +// 设置收藏菜单 | ||
204 | +func (srv UserService) UpdateMenuFavorite(menuFavoriteCommand *command.MenuFavoriteCommand) (interface{}, error) { | ||
205 | + if err := menuFavoriteCommand.ValidateCommand(); err != nil { | ||
206 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
207 | + } | ||
208 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
209 | + menuFavoriteCommand.Operator, | ||
210 | + ) | ||
211 | + result, err := creationUserGateway.FavoriteMenusUpadate(allied_creation_user.ReqFavoriteMenusUpdate{ | ||
212 | + UserId: menuFavoriteCommand.Operator.UserId, | ||
213 | + FavoriteMenus: menuFavoriteCommand.FavoriteMenus, | ||
214 | + Action: menuFavoriteCommand.Action, | ||
215 | + }) | ||
216 | + if err != nil { | ||
217 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
218 | + } | ||
219 | + return result, nil | ||
220 | +} |
@@ -5,6 +5,8 @@ type ( | @@ -5,6 +5,8 @@ type ( | ||
5 | ReqFavoriteMenusUpdate struct { | 5 | ReqFavoriteMenusUpdate struct { |
6 | UserId int64 `json:"userId"` | 6 | UserId int64 `json:"userId"` |
7 | FavoriteMenus []string `json:"favoriteMenus"` | 7 | FavoriteMenus []string `json:"favoriteMenus"` |
8 | + // 1:添加菜单 2:移除菜单 3.全量更新 | ||
9 | + Action int `json:"action" valid:"Required"` | ||
8 | } | 10 | } |
9 | 11 | ||
10 | DataFavoriteMenusUpdate struct { | 12 | DataFavoriteMenusUpdate struct { |
@@ -85,7 +85,7 @@ func (controller *AuthController) GetUserInfo() { | @@ -85,7 +85,7 @@ func (controller *AuthController) GetUserInfo() { | ||
85 | controller.Response(data, err) | 85 | controller.Response(data, err) |
86 | } | 86 | } |
87 | 87 | ||
88 | -func (controller *AuthController) GetUserInfoExtra() { | 88 | +func (controller *AuthController) GetFavoriteMenus() { |
89 | authService := service.AuthService{} | 89 | authService := service.AuthService{} |
90 | userInfoCommand := &command.UserInfoCommand{} | 90 | userInfoCommand := &command.UserInfoCommand{} |
91 | err := controller.Unmarshal(userInfoCommand) | 91 | err := controller.Unmarshal(userInfoCommand) |
@@ -94,7 +94,7 @@ func (controller *AuthController) GetUserInfoExtra() { | @@ -94,7 +94,7 @@ func (controller *AuthController) GetUserInfoExtra() { | ||
94 | return | 94 | return |
95 | } | 95 | } |
96 | userInfoCommand.Operator = controller.GetOperator() | 96 | userInfoCommand.Operator = controller.GetOperator() |
97 | - data, err := authService.GetUserInfoExtra(userInfoCommand) | 97 | + data, err := authService.GetFavoriteMenus(userInfoCommand) |
98 | controller.Response(data, err) | 98 | controller.Response(data, err) |
99 | } | 99 | } |
100 | 100 |
@@ -124,3 +124,16 @@ func (controller *UserController) MessagesMarkRead() { | @@ -124,3 +124,16 @@ func (controller *UserController) MessagesMarkRead() { | ||
124 | data, err := svr.MessagesMarkRead(cmd) | 124 | data, err := svr.MessagesMarkRead(cmd) |
125 | controller.Response(data, err) | 125 | controller.Response(data, err) |
126 | } | 126 | } |
127 | + | ||
128 | +func (controller *UserController) UpdateMenuFavorite() { | ||
129 | + svr := service.UserService{} | ||
130 | + cmd := &command.MenuFavoriteCommand{} | ||
131 | + err := controller.Unmarshal(cmd) | ||
132 | + if err != nil { | ||
133 | + controller.Response(nil, err) | ||
134 | + return | ||
135 | + } | ||
136 | + cmd.Operator = controller.GetOperator() | ||
137 | + data, err := svr.UpdateMenuFavorite(cmd) | ||
138 | + controller.Response(data, err) | ||
139 | +} |
@@ -25,6 +25,10 @@ func (controller *UsersController) CompanyUserUpdate() { | @@ -25,6 +25,10 @@ func (controller *UsersController) CompanyUserUpdate() { | ||
25 | usersService := service.NewUsersService(nil) | 25 | usersService := service.NewUsersService(nil) |
26 | companyUserUpdateCommand := &command.CompanyUserUpdateCommand{} | 26 | companyUserUpdateCommand := &command.CompanyUserUpdateCommand{} |
27 | controller.Unmarshal(companyUserUpdateCommand) | 27 | controller.Unmarshal(companyUserUpdateCommand) |
28 | + if len(companyUserUpdateCommand.UsersId) == 0 { | ||
29 | + userId := controller.GetString(":userId") | ||
30 | + companyUserUpdateCommand.UsersId = userId | ||
31 | + } | ||
28 | companyUserUpdateCommand.Operator = controller.GetOperator() | 32 | companyUserUpdateCommand.Operator = controller.GetOperator() |
29 | data, err := usersService.CompanyUserUpdate(companyUserUpdateCommand) | 33 | data, err := usersService.CompanyUserUpdate(companyUserUpdateCommand) |
30 | controller.Response(data, err) | 34 | controller.Response(data, err) |
@@ -11,9 +11,10 @@ func init() { | @@ -11,9 +11,10 @@ func init() { | ||
11 | 11 | ||
12 | web.Router("/v1/user/company-orgs", &controllers.AuthController{}, "Post:GetCompanyOrgsByUser") | 12 | web.Router("/v1/user/company-orgs", &controllers.AuthController{}, "Post:GetCompanyOrgsByUser") |
13 | web.Router("/v1/user/user-info", &controllers.AuthController{}, "Post:GetUserInfo") | 13 | web.Router("/v1/user/user-info", &controllers.AuthController{}, "Post:GetUserInfo") |
14 | - web.Router("/v1/user/favorite-menus", &controllers.AuthController{}, "Post:GetUserInfoExtra") | ||
15 | - web.Router("/v1/user/user-menu", &controllers.AuthController{}, "Post:GetUserMenus") | ||
16 | web.Router("/v1/user/user-orgs", &controllers.AuthController{}, "Post:GetUserOrg") | 14 | web.Router("/v1/user/user-orgs", &controllers.AuthController{}, "Post:GetUserOrg") |
15 | + web.Router("/v1/user/user-menu", &controllers.AuthController{}, "Post:GetUserMenus") | ||
16 | + web.Router("/v1/user/favorite-menus", &controllers.AuthController{}, "Get:GetFavoriteMenus") | ||
17 | + web.Router("/v1/user/favorite-menus", &mobile_client.UserController{}, "Post:UpdateMenuFavorite") | ||
17 | 18 | ||
18 | web.Router("/v1/user/change-password", &mobile_client.UserController{}, "Post:ChangePassword") | 19 | web.Router("/v1/user/change-password", &mobile_client.UserController{}, "Post:ChangePassword") |
19 | web.Router("/v1/user/change-phone", &mobile_client.UserController{}, "Post:ChangePhone") | 20 | web.Router("/v1/user/change-phone", &mobile_client.UserController{}, "Post:ChangePhone") |
-
请 注册 或 登录 后发表评论