作者 唐旭辉

更新

package command
type UpdateBusinessBonusCommand struct {
}
func (cmd UpdateBusinessBonusCommand) ValidateCommand() error {
return nil
}
... ...
... ... @@ -96,15 +96,25 @@ func (repository *BusinessBonusRepository) Find(queryOptions domain.BusinessBonu
businessBonusModels []models.BusinessBonus
)
query := tx.Model(&businessBonusModels)
if queryOptions.Offset > -1 {
query = query.Offset(queryOptions.Offset)
}
if queryOptions.Limit > 0 {
query = query.Limit(queryOptions.Limit)
} else {
query = query.Limit(1000)
}
if cnt, err = query.SelectAndCount(); err != nil {
return 0, businessBonuss, err
}
for i := range businessBonusModels {
if businessBonus, err := repository.transformPgModelToDomainModel(&businessBonusModels[i]); err != nil {
businessBonus, err := repository.transformPgModelToDomainModel(&businessBonusModels[i])
if err != nil {
return 0, businessBonuss, err
} else {
businessBonuss = append(businessBonuss, businessBonus)
}
businessBonuss = append(businessBonuss, businessBonus)
}
return cnt, businessBonuss, nil
}
... ...
... ... @@ -76,6 +76,7 @@ func (reponsitory UsersRepository) Add(u *domain.Users) error {
UpdateAt: u.UpdateAt,
Permission: u.Permission,
AccessPartners: u.AccessPartners,
AdminType: u.AdminType,
}
_, err = tx.Model(m).Insert()
return err
... ... @@ -107,6 +108,7 @@ func (reponsitory UsersRepository) Edit(u *domain.Users) error {
UpdateAt: u.UpdateAt,
Permission: u.Permission,
AccessPartners: u.AccessPartners,
AdminType: u.AdminType,
}
_, err = tx.Model(m).WherePK().Update()
return err
... ...
... ... @@ -121,13 +121,10 @@ func (c *UserController) GetUserData() {
//EditUserPermission 编辑用户的权限数据
func (c *UserController) EditUserPermission() {
type PartnerList struct {
Id int64 `json:"id"`
}
type UserDetailParam struct {
Id int64 `json:"id"`
PermissionType []int64 `json:"permissionType"`
CheckedPartner []PartnerList `json:"checkedPartner"` //合伙人
CheckedPartner []int64 `json:"checkedPartner"` //合伙人
}
var (
param UserDetailParam
... ... @@ -140,17 +137,11 @@ func (c *UserController) EditUserPermission() {
}
companyId := c.GetUserCompany()
newUserService := userService.NewUsersService(nil)
var (
partnerIds = make([]int64, len(param.CheckedPartner))
)
for _, v := range param.CheckedPartner {
partnerIds = append(partnerIds, v.Id)
}
err = newUserService.EditUserPermission(userCommand.EditUserPermissionCommand{
Id: param.Id,
CompanyId: companyId,
PermissionType: param.PermissionType,
CheckedPartner: partnerIds,
CheckedPartner: param.CheckedPartner,
})
if err != nil {
c.ResponseError(err)
... ...