作者 tangxvhui

bug 修复

@@ -93,13 +93,13 @@ func (adminUserSrv AdminUserService) SaveAdminUser(saveUserCmd *command.SaveAdmi @@ -93,13 +93,13 @@ func (adminUserSrv AdminUserService) SaveAdminUser(saveUserCmd *command.SaveAdmi
93 if err != nil { 93 if err != nil {
94 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 94 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
95 } 95 }
96 - //.....  
97 for i := range permissions { 96 for i := range permissions {
98 if permissions[i].Code == domain.PERMINSSION_ADMIN_USER { 97 if permissions[i].Code == domain.PERMINSSION_ADMIN_USER {
99 return nil, lib.ThrowError(lib.BUSINESS_ERROR, "操作异常") 98 return nil, lib.ThrowError(lib.BUSINESS_ERROR, "操作异常")
100 } 99 }
101 } 100 }
102 permissionBases := []domain.AdminPermissionBase{} 101 permissionBases := []domain.AdminPermissionBase{}
  102 +
103 for i := range permissions { 103 for i := range permissions {
104 p := domain.AdminPermissionBase{ 104 p := domain.AdminPermissionBase{
105 Id: permissions[i].Id, Code: permissions[i].Code, 105 Id: permissions[i].Id, Code: permissions[i].Code,
@@ -160,7 +160,7 @@ func (adminUserSrv AdminUserService) SaveAdminUser(saveUserCmd *command.SaveAdmi @@ -160,7 +160,7 @@ func (adminUserSrv AdminUserService) SaveAdminUser(saveUserCmd *command.SaveAdmi
160 } 160 }
161 } 161 }
162 162
163 - adminuser, err = adminuserRepository.Save(adminuser) 163 + adminuser, err = adminuserRepository.Save(*adminuser)
164 if err != nil { 164 if err != nil {
165 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 165 return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
166 } 166 }
@@ -34,7 +34,7 @@ type AdminUserFindOneQuery struct { @@ -34,7 +34,7 @@ type AdminUserFindOneQuery struct {
34 } 34 }
35 35
36 type AdminUserRepository interface { 36 type AdminUserRepository interface {
37 - Save(*AdminUser) (*AdminUser, error) 37 + Save(AdminUser) (*AdminUser, error)
38 FindOne(qureyOptions AdminUserFindOneQuery) (*AdminUser, error) 38 FindOne(qureyOptions AdminUserFindOneQuery) (*AdminUser, error)
39 Find(queryOptions AdminUserFindQuery) ([]AdminUser, error) 39 Find(queryOptions AdminUserFindQuery) ([]AdminUser, error)
40 CountAll(queryOption AdminUserFindQuery) (int, error) 40 CountAll(queryOption AdminUserFindQuery) (int, error)
@@ -55,7 +55,7 @@ func (reponsitory AdminUserRepository) FindOne(queryOption domain.AdminUserFindO @@ -55,7 +55,7 @@ func (reponsitory AdminUserRepository) FindOne(queryOption domain.AdminUserFindO
55 return &adminUser, err 55 return &adminUser, err
56 } 56 }
57 57
58 -func (reponsitory AdminUserRepository) updateAdminUser(adminuser *domain.AdminUser) (*domain.AdminUser, error) { 58 +func (reponsitory AdminUserRepository) updateAdminUser(adminuser domain.AdminUser) (*domain.AdminUser, error) {
59 tx := reponsitory.transactionContext.PgTx 59 tx := reponsitory.transactionContext.PgTx
60 adminUserModel := &models.AdminUser{ 60 adminUserModel := &models.AdminUser{
61 Id: adminuser.Id, 61 Id: adminuser.Id,
@@ -72,10 +72,10 @@ func (reponsitory AdminUserRepository) updateAdminUser(adminuser *domain.AdminUs @@ -72,10 +72,10 @@ func (reponsitory AdminUserRepository) updateAdminUser(adminuser *domain.AdminUs
72 if err != nil { 72 if err != nil {
73 return nil, fmt.Errorf("更新用户数据失败:%s", err) 73 return nil, fmt.Errorf("更新用户数据失败:%s", err)
74 } 74 }
75 - return adminuser, nil 75 + return &adminuser, nil
76 } 76 }
77 77
78 -func (reponsitory AdminUserRepository) addAdminUser(adminuser *domain.AdminUser) (*domain.AdminUser, error) { 78 +func (reponsitory AdminUserRepository) addAdminUser(adminuser domain.AdminUser) (*domain.AdminUser, error) {
79 tx := reponsitory.transactionContext.PgTx 79 tx := reponsitory.transactionContext.PgTx
80 adminuserModel := &models.AdminUser{ 80 adminuserModel := &models.AdminUser{
81 Account: adminuser.Account, 81 Account: adminuser.Account,
@@ -93,13 +93,11 @@ func (reponsitory AdminUserRepository) addAdminUser(adminuser *domain.AdminUser) @@ -93,13 +93,11 @@ func (reponsitory AdminUserRepository) addAdminUser(adminuser *domain.AdminUser)
93 return nil, nil 93 return nil, nil
94 } 94 }
95 95
96 -func (reponsitory AdminUserRepository) Save(adminuser *domain.AdminUser) (*domain.AdminUser, error) { 96 +func (reponsitory AdminUserRepository) Save(adminuser domain.AdminUser) (*domain.AdminUser, error) {
97 if adminuser.Id == 0 { 97 if adminuser.Id == 0 {
98 return reponsitory.addAdminUser(adminuser) 98 return reponsitory.addAdminUser(adminuser)
99 - } else {  
100 - return reponsitory.updateAdminUser(adminuser)  
101 } 99 }
102 - return adminuser, nil 100 + return reponsitory.updateAdminUser(adminuser)
103 } 101 }
104 102
105 func (reponsitory AdminUserRepository) Find(queryOption domain.AdminUserFindQuery) ([]domain.AdminUser, error) { 103 func (reponsitory AdminUserRepository) Find(queryOption domain.AdminUserFindQuery) ([]domain.AdminUser, error) {