作者 tangxuhui
... ... @@ -10,7 +10,7 @@ type SwitchOrgCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 组织ID
OrgId int64 `json:"orgId"`
OrgId int64 `json:"orgId,string"`
}
func (switchOrgCommand *SwitchOrgCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -168,6 +168,7 @@ loopUser1:
if vv.OrgID == int(currentAccess.OrganizationId) {
currentOrgIsOK = true
currentAccess.UserId = int64(v.UserId)
currentAccess.UserBaseId = int64(v.UserBaseId)
break loopUser1
}
}
... ... @@ -181,6 +182,7 @@ loopUser1:
currentAccess.CompanyId = int64(v.Company.CompanyId)
for _, vv := range v.UserOrg {
currentAccess.UserId = int64(v.UserId)
currentAccess.UserBaseId = int64(v.UserBaseId)
currentAccess.OrganizationId = int64(vv.OrgID)
currentOrgIsOK = true
break loopUser2
... ... @@ -191,6 +193,7 @@ loopUser1:
loginToken := domain.LoginToken{
UserId: currentAccess.UserId,
Account: currentAccess.Account,
UserBaseId: currentAccess.UserBaseId,
CompanyId: currentAccess.CompanyId,
OrgId: currentAccess.OrganizationId,
Platform: currentAccess.Platform,
... ...
package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type DestroyAccountCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (cmd *DestroyAccountCommand) Valid(validation *validation.Validation) {
}
func (cmd *DestroyAccountCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(cmd).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
... ... @@ -123,3 +123,15 @@ func (srv UserService) UpdateUserBaseInfo(updateUserInfoCommand *command.UpdateU
"userName": userName,
}, nil
}
// CompanySignUp 企业注册
func (srv UserService) DestroyAccount(destroyAccountCommand *command.DestroyAccountCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
result, err := creationUserGateway.AuthDestroyAccount(allied_creation_user.ReqAuthDestroyAccount{
UserId: destroyAccountCommand.Operator.UserId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return result, err
}
... ...
... ... @@ -42,6 +42,8 @@ type (
//注销账号 (添加用户时重新激活)
type (
ReqAuthDestroyAccount struct {
// 用户Id 用户唯一标识
UserId int64 `cname:"用户Id 用户唯一标识" json:"userId" valid:"Required"`
}
DataAuthDestroyAccount struct {
... ...
... ... @@ -71,3 +71,16 @@ func (controller *UserController) UpdateUserInfo() {
data, err := authService.UpdateUserBaseInfo(cmd)
controller.Response(data, err)
}
func (controller *UserController) DestroyAccount() {
authService := service.UserService{}
cmd := &command.DestroyAccountCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := authService.DestroyAccount(cmd)
controller.Response(data, err)
}
... ...
... ... @@ -12,4 +12,5 @@ func init() {
web.Router("/v1/app/users/change-password", &mobile_client.UserController{}, "Post:ChangePassword")
web.Router("/v1/app/users/change-phone", &mobile_client.UserController{}, "Post:ChangePhone")
web.Router("/v1/app/users/personal", &mobile_client.UserController{}, "Post:UpdateUserInfo")
web.Router("/v1/app/users/destroy-account", &mobile_client.UserController{}, "Post:DestroyAccount")
}
... ...