作者 唐旭辉

更新

  1 +package command
  2 +
  3 +type UpdateBusinessBonusCommand struct {
  4 +}
  5 +
  6 +func (cmd UpdateBusinessBonusCommand) ValidateCommand() error {
  7 + return nil
  8 +}
@@ -96,15 +96,25 @@ func (repository *BusinessBonusRepository) Find(queryOptions domain.BusinessBonu @@ -96,15 +96,25 @@ func (repository *BusinessBonusRepository) Find(queryOptions domain.BusinessBonu
96 businessBonusModels []models.BusinessBonus 96 businessBonusModels []models.BusinessBonus
97 ) 97 )
98 query := tx.Model(&businessBonusModels) 98 query := tx.Model(&businessBonusModels)
  99 + if queryOptions.Offset > -1 {
  100 + query = query.Offset(queryOptions.Offset)
  101 + }
  102 + if queryOptions.Limit > 0 {
  103 + query = query.Limit(queryOptions.Limit)
  104 + } else {
  105 + query = query.Limit(1000)
  106 + }
  107 +
99 if cnt, err = query.SelectAndCount(); err != nil { 108 if cnt, err = query.SelectAndCount(); err != nil {
100 return 0, businessBonuss, err 109 return 0, businessBonuss, err
101 } 110 }
  111 +
102 for i := range businessBonusModels { 112 for i := range businessBonusModels {
103 - if businessBonus, err := repository.transformPgModelToDomainModel(&businessBonusModels[i]); err != nil { 113 + businessBonus, err := repository.transformPgModelToDomainModel(&businessBonusModels[i])
  114 + if err != nil {
104 return 0, businessBonuss, err 115 return 0, businessBonuss, err
105 - } else {  
106 - businessBonuss = append(businessBonuss, businessBonus)  
107 } 116 }
  117 + businessBonuss = append(businessBonuss, businessBonus)
108 } 118 }
109 return cnt, businessBonuss, nil 119 return cnt, businessBonuss, nil
110 } 120 }
@@ -76,6 +76,7 @@ func (reponsitory UsersRepository) Add(u *domain.Users) error { @@ -76,6 +76,7 @@ func (reponsitory UsersRepository) Add(u *domain.Users) error {
76 UpdateAt: u.UpdateAt, 76 UpdateAt: u.UpdateAt,
77 Permission: u.Permission, 77 Permission: u.Permission,
78 AccessPartners: u.AccessPartners, 78 AccessPartners: u.AccessPartners,
  79 + AdminType: u.AdminType,
79 } 80 }
80 _, err = tx.Model(m).Insert() 81 _, err = tx.Model(m).Insert()
81 return err 82 return err
@@ -107,6 +108,7 @@ func (reponsitory UsersRepository) Edit(u *domain.Users) error { @@ -107,6 +108,7 @@ func (reponsitory UsersRepository) Edit(u *domain.Users) error {
107 UpdateAt: u.UpdateAt, 108 UpdateAt: u.UpdateAt,
108 Permission: u.Permission, 109 Permission: u.Permission,
109 AccessPartners: u.AccessPartners, 110 AccessPartners: u.AccessPartners,
  111 + AdminType: u.AdminType,
110 } 112 }
111 _, err = tx.Model(m).WherePK().Update() 113 _, err = tx.Model(m).WherePK().Update()
112 return err 114 return err
@@ -121,13 +121,10 @@ func (c *UserController) GetUserData() { @@ -121,13 +121,10 @@ func (c *UserController) GetUserData() {
121 121
122 //EditUserPermission 编辑用户的权限数据 122 //EditUserPermission 编辑用户的权限数据
123 func (c *UserController) EditUserPermission() { 123 func (c *UserController) EditUserPermission() {
124 - type PartnerList struct {  
125 - Id int64 `json:"id"`  
126 - }  
127 type UserDetailParam struct { 124 type UserDetailParam struct {
128 - Id int64 `json:"id"`  
129 - PermissionType []int64 `json:"permissionType"`  
130 - CheckedPartner []PartnerList `json:"checkedPartner"` //合伙人 125 + Id int64 `json:"id"`
  126 + PermissionType []int64 `json:"permissionType"`
  127 + CheckedPartner []int64 `json:"checkedPartner"` //合伙人
131 } 128 }
132 var ( 129 var (
133 param UserDetailParam 130 param UserDetailParam
@@ -140,17 +137,11 @@ func (c *UserController) EditUserPermission() { @@ -140,17 +137,11 @@ func (c *UserController) EditUserPermission() {
140 } 137 }
141 companyId := c.GetUserCompany() 138 companyId := c.GetUserCompany()
142 newUserService := userService.NewUsersService(nil) 139 newUserService := userService.NewUsersService(nil)
143 - var (  
144 - partnerIds = make([]int64, len(param.CheckedPartner))  
145 - )  
146 - for _, v := range param.CheckedPartner {  
147 - partnerIds = append(partnerIds, v.Id)  
148 - }  
149 err = newUserService.EditUserPermission(userCommand.EditUserPermissionCommand{ 140 err = newUserService.EditUserPermission(userCommand.EditUserPermissionCommand{
150 Id: param.Id, 141 Id: param.Id,
151 CompanyId: companyId, 142 CompanyId: companyId,
152 PermissionType: param.PermissionType, 143 PermissionType: param.PermissionType,
153 - CheckedPartner: partnerIds, 144 + CheckedPartner: param.CheckedPartner,
154 }) 145 })
155 if err != nil { 146 if err != nil {
156 c.ResponseError(err) 147 c.ResponseError(err)