...
|
...
|
@@ -164,11 +164,14 @@ func (userService *UserService) CreateCooperator(createCooperatorCommand *comman |
|
|
if user, err = createUserService.CreateUser(nil, newUser, createCooperatorCommand.Password); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
userDto := &dto.UserDto{}
|
|
|
if err := userDto.LoadDto(user, nil); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return user, nil
|
|
|
return userDto, nil
|
|
|
}
|
|
|
|
|
|
// 创建
|
...
|
...
|
@@ -211,17 +214,17 @@ func (userService *UserService) CreateUser(createUserCommand *command.CreateUser |
|
|
}
|
|
|
}
|
|
|
newUser := &domain.User{
|
|
|
CompanyId: createUserCommand.CompanyId,
|
|
|
UserType: createUserCommand.UserType,
|
|
|
UserCode: createUserCommand.UserCode,
|
|
|
OrganizationId: createUserCommand.OrganizationId,
|
|
|
DepartmentId: createUserCommand.DepartmentId,
|
|
|
UserOrg: sampleUserOrg,
|
|
|
UserRole: sampleUserRole,
|
|
|
FavoriteMenus: []string{},
|
|
|
CooperationInfo: &domain.CooperationInfo{},
|
|
|
UserInfo: nweUserInfo,
|
|
|
EnableStatus: createUserCommand.EnableStatus,
|
|
|
CompanyId: createUserCommand.CompanyId,
|
|
|
UserType: createUserCommand.UserType,
|
|
|
UserCode: createUserCommand.UserCode,
|
|
|
OrganizationId: createUserCommand.OrganizationId,
|
|
|
DepartmentId: createUserCommand.DepartmentId,
|
|
|
UserOrg: sampleUserOrg,
|
|
|
UserRole: sampleUserRole,
|
|
|
FavoriteMenus: []string{},
|
|
|
//CooperationInfo: &domain.CooperationInfo{},
|
|
|
UserInfo: nweUserInfo,
|
|
|
EnableStatus: createUserCommand.EnableStatus,
|
|
|
Ext: &domain.Ext{
|
|
|
Phone: createUserCommand.Phone,
|
|
|
UserName: createUserCommand.UserName,
|
...
|
...
|
@@ -236,10 +239,14 @@ func (userService *UserService) CreateUser(createUserCommand *command.CreateUser |
|
|
if user, err = createUserService.CreateUser(nil, newUser, createUserCommand.Password); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
userDto := &dto.UserDto{}
|
|
|
if err := userDto.LoadDto(user, nil); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return user, nil
|
|
|
return userDto, nil
|
|
|
}
|
|
|
|
|
|
// 移除我收藏的菜单
|
...
|
...
|
@@ -404,7 +411,7 @@ func (userService *UserService) GetUserAccessMenus(getUserAccessMenusQuery *quer |
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
// TODO:获取用户概要数据
|
|
|
// 获取用户概要数据
|
|
|
func (userService *UserService) GetUserProfile(getUserProfileQuery *query.GetUserProfileQuery) (interface{}, error) {
|
|
|
if err := getUserProfileQuery.ValidateQuery(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
...
|
...
|
@@ -419,10 +426,29 @@ func (userService *UserService) GetUserProfile(getUserProfileQuery *query.GetUse |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
_, user, err := factory.FastPgUser(transactionContext, getUserProfileQuery.UserId)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
_, userBase, err := factory.FastPgUserBase(transactionContext, user.UserBaseId)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
var userProfile = make(map[string]interface{})
|
|
|
userProfile["userId"] = user.UserId
|
|
|
userProfile["userCode"] = user.UserCode
|
|
|
|
|
|
userProfile["userBaseId"] = user.UserBaseId
|
|
|
userProfile["phone"] = userBase.UserInfo.Phone
|
|
|
userProfile["avatar"] = userBase.UserInfo.Avatar
|
|
|
userProfile["email"] = userBase.UserInfo.Email
|
|
|
userProfile["userName"] = userBase.UserInfo.UserName
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return nil, nil
|
|
|
return userProfile, nil
|
|
|
}
|
|
|
|
|
|
// 返回列表
|
...
|
...
|
@@ -557,11 +583,14 @@ func (userService *UserService) UpdateCooperator(updateCooperatorCommand *comman |
|
|
if user, err = updateUserService.UpdateUser(nil, user, userInfo, updateCooperatorCommand.EnableStatus); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
userDto := &dto.UserDto{}
|
|
|
if err := userDto.LoadDto(user, nil); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return struct{}{}, nil
|
|
|
return userDto, nil
|
|
|
}
|
|
|
|
|
|
// 更新我喜欢菜单列表
|
...
|
...
|
@@ -630,11 +659,14 @@ func (userService *UserService) UpdateUser(updateUserCommand *command.UpdateUser |
|
|
if user, err = updateUserService.UpdateUser(nil, user, userInfo, updateUserCommand.EnableStatus); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
userDto := &dto.UserDto{}
|
|
|
if err := userDto.LoadDto(user, nil); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return user, nil
|
|
|
return userDto, nil
|
|
|
}
|
|
|
|
|
|
// 更新用户基础信息数据
|
...
|
...
|
@@ -652,10 +684,27 @@ func (userService *UserService) UpdateUsersBase(updateUsersBaseCommand *command. |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
_, user, err := factory.FastPgUser(transactionContext, updateUsersBaseCommand.UserId)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
userInfo := &domain.UserInfo{
|
|
|
UserName: updateUsersBaseCommand.UserName,
|
|
|
Phone: updateUsersBaseCommand.Phone,
|
|
|
Avatar: updateUsersBaseCommand.Avatar,
|
|
|
Email: updateUsersBaseCommand.Email,
|
|
|
}
|
|
|
updateUserService, _ := factory.CreatePgUpdateUserService(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
if user, err = updateUserService.UpdateUser(nil, user, userInfo, user.EnableStatus); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return nil, nil
|
|
|
return struct{}{}, nil
|
|
|
}
|
|
|
|
|
|
func NewUserService(options map[string]interface{}) *UserService {
|
...
|
...
|
|