Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway into dev
正在显示
7 个修改的文件
包含
76 行增加
和
6 行删除
@@ -10,7 +10,7 @@ type SwitchOrgCommand struct { | @@ -10,7 +10,7 @@ type SwitchOrgCommand struct { | ||
10 | //操作人 | 10 | //操作人 |
11 | Operator domain.Operator `json:"-"` | 11 | Operator domain.Operator `json:"-"` |
12 | // 组织ID | 12 | // 组织ID |
13 | - OrgId int64 `json:"orgId"` | 13 | + OrgId int64 `json:"orgId,string"` |
14 | } | 14 | } |
15 | 15 | ||
16 | func (switchOrgCommand *SwitchOrgCommand) Valid(validation *validation.Validation) { | 16 | func (switchOrgCommand *SwitchOrgCommand) Valid(validation *validation.Validation) { |
@@ -168,6 +168,7 @@ loopUser1: | @@ -168,6 +168,7 @@ loopUser1: | ||
168 | if vv.OrgID == int(currentAccess.OrganizationId) { | 168 | if vv.OrgID == int(currentAccess.OrganizationId) { |
169 | currentOrgIsOK = true | 169 | currentOrgIsOK = true |
170 | currentAccess.UserId = int64(v.UserId) | 170 | currentAccess.UserId = int64(v.UserId) |
171 | + currentAccess.UserBaseId = int64(v.UserBaseId) | ||
171 | break loopUser1 | 172 | break loopUser1 |
172 | } | 173 | } |
173 | } | 174 | } |
@@ -181,6 +182,7 @@ loopUser1: | @@ -181,6 +182,7 @@ loopUser1: | ||
181 | currentAccess.CompanyId = int64(v.Company.CompanyId) | 182 | currentAccess.CompanyId = int64(v.Company.CompanyId) |
182 | for _, vv := range v.UserOrg { | 183 | for _, vv := range v.UserOrg { |
183 | currentAccess.UserId = int64(v.UserId) | 184 | currentAccess.UserId = int64(v.UserId) |
185 | + currentAccess.UserBaseId = int64(v.UserBaseId) | ||
184 | currentAccess.OrganizationId = int64(vv.OrgID) | 186 | currentAccess.OrganizationId = int64(vv.OrgID) |
185 | currentOrgIsOK = true | 187 | currentOrgIsOK = true |
186 | break loopUser2 | 188 | break loopUser2 |
@@ -189,11 +191,12 @@ loopUser1: | @@ -189,11 +191,12 @@ loopUser1: | ||
189 | } | 191 | } |
190 | 192 | ||
191 | loginToken := domain.LoginToken{ | 193 | loginToken := domain.LoginToken{ |
192 | - UserId: currentAccess.UserId, | ||
193 | - Account: currentAccess.Account, | ||
194 | - CompanyId: currentAccess.CompanyId, | ||
195 | - OrgId: currentAccess.OrganizationId, | ||
196 | - Platform: currentAccess.Platform, | 194 | + UserId: currentAccess.UserId, |
195 | + Account: currentAccess.Account, | ||
196 | + UserBaseId: currentAccess.UserBaseId, | ||
197 | + CompanyId: currentAccess.CompanyId, | ||
198 | + OrgId: currentAccess.OrganizationId, | ||
199 | + Platform: currentAccess.Platform, | ||
197 | } | 200 | } |
198 | 201 | ||
199 | accessTokenStr, err := loginToken.GenerateAccessToken() | 202 | accessTokenStr, err := loginToken.GenerateAccessToken() |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | + | ||
9 | + "github.com/beego/beego/v2/core/validation" | ||
10 | +) | ||
11 | + | ||
12 | +type DestroyAccountCommand struct { | ||
13 | + //操作人 | ||
14 | + Operator domain.Operator `json:"-"` | ||
15 | +} | ||
16 | + | ||
17 | +func (cmd *DestroyAccountCommand) Valid(validation *validation.Validation) { | ||
18 | + | ||
19 | +} | ||
20 | + | ||
21 | +func (cmd *DestroyAccountCommand) ValidateCommand() error { | ||
22 | + valid := validation.Validation{} | ||
23 | + b, err := valid.Valid(cmd) | ||
24 | + if err != nil { | ||
25 | + return err | ||
26 | + } | ||
27 | + if !b { | ||
28 | + elem := reflect.TypeOf(cmd).Elem() | ||
29 | + for _, validErr := range valid.Errors { | ||
30 | + field, isExist := elem.FieldByName(validErr.Field) | ||
31 | + if isExist { | ||
32 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
33 | + } else { | ||
34 | + return fmt.Errorf(validErr.Message) | ||
35 | + } | ||
36 | + } | ||
37 | + } | ||
38 | + return nil | ||
39 | +} |
@@ -123,3 +123,15 @@ func (srv UserService) UpdateUserBaseInfo(updateUserInfoCommand *command.UpdateU | @@ -123,3 +123,15 @@ func (srv UserService) UpdateUserBaseInfo(updateUserInfoCommand *command.UpdateU | ||
123 | "userName": userName, | 123 | "userName": userName, |
124 | }, nil | 124 | }, nil |
125 | } | 125 | } |
126 | + | ||
127 | +// CompanySignUp 企业注册 | ||
128 | +func (srv UserService) DestroyAccount(destroyAccountCommand *command.DestroyAccountCommand) (interface{}, error) { | ||
129 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{}) | ||
130 | + result, err := creationUserGateway.AuthDestroyAccount(allied_creation_user.ReqAuthDestroyAccount{ | ||
131 | + UserId: destroyAccountCommand.Operator.UserId, | ||
132 | + }) | ||
133 | + if err != nil { | ||
134 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
135 | + } | ||
136 | + return result, err | ||
137 | +} |
@@ -42,6 +42,8 @@ type ( | @@ -42,6 +42,8 @@ type ( | ||
42 | //注销账号 (添加用户时重新激活) | 42 | //注销账号 (添加用户时重新激活) |
43 | type ( | 43 | type ( |
44 | ReqAuthDestroyAccount struct { | 44 | ReqAuthDestroyAccount struct { |
45 | + // 用户Id 用户唯一标识 | ||
46 | + UserId int64 `cname:"用户Id 用户唯一标识" json:"userId" valid:"Required"` | ||
45 | } | 47 | } |
46 | 48 | ||
47 | DataAuthDestroyAccount struct { | 49 | DataAuthDestroyAccount struct { |
@@ -71,3 +71,16 @@ func (controller *UserController) UpdateUserInfo() { | @@ -71,3 +71,16 @@ func (controller *UserController) UpdateUserInfo() { | ||
71 | data, err := authService.UpdateUserBaseInfo(cmd) | 71 | data, err := authService.UpdateUserBaseInfo(cmd) |
72 | controller.Response(data, err) | 72 | controller.Response(data, err) |
73 | } | 73 | } |
74 | + | ||
75 | +func (controller *UserController) DestroyAccount() { | ||
76 | + authService := service.UserService{} | ||
77 | + cmd := &command.DestroyAccountCommand{} | ||
78 | + err := controller.Unmarshal(cmd) | ||
79 | + if err != nil { | ||
80 | + controller.Response(nil, err) | ||
81 | + return | ||
82 | + } | ||
83 | + cmd.Operator = controller.GetOperator() | ||
84 | + data, err := authService.DestroyAccount(cmd) | ||
85 | + controller.Response(data, err) | ||
86 | +} |
@@ -12,4 +12,5 @@ func init() { | @@ -12,4 +12,5 @@ func init() { | ||
12 | web.Router("/v1/app/users/change-password", &mobile_client.UserController{}, "Post:ChangePassword") | 12 | web.Router("/v1/app/users/change-password", &mobile_client.UserController{}, "Post:ChangePassword") |
13 | web.Router("/v1/app/users/change-phone", &mobile_client.UserController{}, "Post:ChangePhone") | 13 | web.Router("/v1/app/users/change-phone", &mobile_client.UserController{}, "Post:ChangePhone") |
14 | web.Router("/v1/app/users/personal", &mobile_client.UserController{}, "Post:UpdateUserInfo") | 14 | web.Router("/v1/app/users/personal", &mobile_client.UserController{}, "Post:UpdateUserInfo") |
15 | + web.Router("/v1/app/users/destroy-account", &mobile_client.UserController{}, "Post:DestroyAccount") | ||
15 | } | 16 | } |
-
请 注册 或 登录 后发表评论