作者 tangxvhui

bug 修复

... ... @@ -93,13 +93,13 @@ func (adminUserSrv AdminUserService) SaveAdminUser(saveUserCmd *command.SaveAdmi
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
//.....
for i := range permissions {
if permissions[i].Code == domain.PERMINSSION_ADMIN_USER {
return nil, lib.ThrowError(lib.BUSINESS_ERROR, "操作异常")
}
}
permissionBases := []domain.AdminPermissionBase{}
for i := range permissions {
p := domain.AdminPermissionBase{
Id: permissions[i].Id, Code: permissions[i].Code,
... ... @@ -160,7 +160,7 @@ func (adminUserSrv AdminUserService) SaveAdminUser(saveUserCmd *command.SaveAdmi
}
}
adminuser, err = adminuserRepository.Save(adminuser)
adminuser, err = adminuserRepository.Save(*adminuser)
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -34,7 +34,7 @@ type AdminUserFindOneQuery struct {
}
type AdminUserRepository interface {
Save(*AdminUser) (*AdminUser, error)
Save(AdminUser) (*AdminUser, error)
FindOne(qureyOptions AdminUserFindOneQuery) (*AdminUser, error)
Find(queryOptions AdminUserFindQuery) ([]AdminUser, error)
CountAll(queryOption AdminUserFindQuery) (int, error)
... ...
... ... @@ -55,7 +55,7 @@ func (reponsitory AdminUserRepository) FindOne(queryOption domain.AdminUserFindO
return &adminUser, err
}
func (reponsitory AdminUserRepository) updateAdminUser(adminuser *domain.AdminUser) (*domain.AdminUser, error) {
func (reponsitory AdminUserRepository) updateAdminUser(adminuser domain.AdminUser) (*domain.AdminUser, error) {
tx := reponsitory.transactionContext.PgTx
adminUserModel := &models.AdminUser{
Id: adminuser.Id,
... ... @@ -72,10 +72,10 @@ func (reponsitory AdminUserRepository) updateAdminUser(adminuser *domain.AdminUs
if err != nil {
return nil, fmt.Errorf("更新用户数据失败:%s", err)
}
return adminuser, nil
return &adminuser, nil
}
func (reponsitory AdminUserRepository) addAdminUser(adminuser *domain.AdminUser) (*domain.AdminUser, error) {
func (reponsitory AdminUserRepository) addAdminUser(adminuser domain.AdminUser) (*domain.AdminUser, error) {
tx := reponsitory.transactionContext.PgTx
adminuserModel := &models.AdminUser{
Account: adminuser.Account,
... ... @@ -93,13 +93,11 @@ func (reponsitory AdminUserRepository) addAdminUser(adminuser *domain.AdminUser)
return nil, nil
}
func (reponsitory AdminUserRepository) Save(adminuser *domain.AdminUser) (*domain.AdminUser, error) {
func (reponsitory AdminUserRepository) Save(adminuser domain.AdminUser) (*domain.AdminUser, error) {
if adminuser.Id == 0 {
return reponsitory.addAdminUser(adminuser)
} else {
return reponsitory.updateAdminUser(adminuser)
}
return adminuser, nil
return reponsitory.updateAdminUser(adminuser)
}
func (reponsitory AdminUserRepository) Find(queryOption domain.AdminUserFindQuery) ([]domain.AdminUser, error) {
... ...