作者 tangxvhui

更新

... ... @@ -112,7 +112,9 @@ func (adminUserSrv AdminUserService) SaveAdminUser(saveUserCmd *command.SaveAdmi
adminuser.Account = saveUserCmd.Account
adminuser.AdminName = saveUserCmd.Name
adminuser.IsUsable = saveUserCmd.IsUsable
adminuser.Permission = permissionBases
if !adminuser.IsDefault {
adminuser.Permission = permissionBases
}
} else {
accountChance = true
... ...
... ... @@ -14,8 +14,7 @@ type PartnerInfoRepository struct {
func (repository *PartnerInfoRepository) transformPgModelToDomainModel(PartnerInfoModel *models.PartnerInfo) (*domain.PartnerInfo, error) {
m := &domain.PartnerInfo{}
return m, err
return m, nil
}
func NewPartnerInfoRepository(transactionContext *transaction.TransactionContext) (*PartnerInfoRepository, error) {
... ... @@ -50,53 +49,53 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) (*domain.P
return dm, nil
}
func (repository *PartnerInfoRepository) Remove(PartnerInfo *domain.PartnerInfo) (*domain.PartnerInfo, error) {
var (
tx = repository.transactionContext.PgTx
PartnerInfoModel = &models.PartnerInfo{Id: PartnerInfo.Identify().(int64)}
)
if _, err := tx.Model(PartnerInfoModel).Where("id = ?", PartnerInfo.Id).Delete(); err != nil {
return PartnerInfo, err
}
return PartnerInfo, nil
}
// func (repository *PartnerInfoRepository) Remove(PartnerInfo *domain.PartnerInfo) (*domain.PartnerInfo, error) {
// var (
// tx = repository.transactionContext.PgTx
// PartnerInfoModel = &models.PartnerInfo{Id: PartnerInfo.Identify().(int64)}
// )
// if _, err := tx.Model(PartnerInfoModel).Where("id = ?", PartnerInfo.Id).Delete(); err != nil {
// return PartnerInfo, err
// }
// return PartnerInfo, nil
// }
func (repository *PartnerInfoRepository) FindOne(queryOptions map[string]interface{}) (*domain.PartnerInfo, error) {
tx := repository.transactionContext.PgTx
PartnerInfoModel := new(models.PartnerInfo)
query := NewQuery(tx.Model(PartnerInfoModel), queryOptions)
query.SetWhere("partner_info.id = ?", "id")
if err := query.First(); err != nil {
return nil, query.HandleError(err, "没有此合伙人")
}
if PartnerInfoModel.Id == 0 {
return nil, nil
}
return repository.transformPgModelToDomainModel(PartnerInfoModel)
}
// func (repository *PartnerInfoRepository) FindOne(queryOptions map[string]interface{}) (*domain.PartnerInfo, error) {
// tx := repository.transactionContext.PgTx
// PartnerInfoModel := new(models.PartnerInfo)
// query := NewQuery(tx.Model(PartnerInfoModel), queryOptions)
// query.SetWhere("partner_info.id = ?", "id")
// if err := query.First(); err != nil {
// return nil, query.HandleError(err, "没有此合伙人")
// }
// if PartnerInfoModel.Id == 0 {
// return nil, nil
// }
// return repository.transformPgModelToDomainModel(PartnerInfoModel)
// }
func (repository *PartnerInfoRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.PartnerInfo, error) {
tx := repository.transactionContext.PgTx
var PartnerInfoModels []*models.PartnerInfo
PartnerInfos := make([]*domain.PartnerInfo, 0)
query := NewQuery(tx.Model(&PartnerInfoModels), queryOptions)
query.
SetWhere("partner_info.account = ?", "account").
SetWhere(`partner_info.status = ?`, "status").
SetWhere(`partner_info.partner_category = ?`, "partnerCategory").
SetLimit().
SetOrder("partner_info.create_at", "sortByCreateTime").
SetOrder("partner_info.update_at", "sortByUpdateTime")
var err error
if query.AffectRow, err = query.SelectAndCount(); err != nil {
return 0, PartnerInfos, err
}
for _, PartnerInfoModel := range PartnerInfoModels {
if PartnerInfo, err := repository.transformPgModelToDomainModel(PartnerInfoModel); err != nil {
return 0, PartnerInfos, err
} else {
PartnerInfos = append(PartnerInfos, PartnerInfo)
}
}
return int64(query.AffectRow), PartnerInfos, nil
}
// func (repository *PartnerInfoRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.PartnerInfo, error) {
// tx := repository.transactionContext.PgTx
// var PartnerInfoModels []*models.PartnerInfo
// PartnerInfos := make([]*domain.PartnerInfo, 0)
// query := NewQuery(tx.Model(&PartnerInfoModels), queryOptions)
// query.
// SetWhere("partner_info.account = ?", "account").
// SetWhere(`partner_info.status = ?`, "status").
// SetWhere(`partner_info.partner_category = ?`, "partnerCategory").
// SetLimit().
// SetOrder("partner_info.create_at", "sortByCreateTime").
// SetOrder("partner_info.update_at", "sortByUpdateTime")
// var err error
// if query.AffectRow, err = query.SelectAndCount(); err != nil {
// return 0, PartnerInfos, err
// }
// for _, PartnerInfoModel := range PartnerInfoModels {
// if PartnerInfo, err := repository.transformPgModelToDomainModel(PartnerInfoModel); err != nil {
// return 0, PartnerInfos, err
// } else {
// PartnerInfos = append(PartnerInfos, PartnerInfo)
// }
// }
// return int64(query.AffectRow), PartnerInfos, nil
// }
... ...
... ... @@ -197,6 +197,7 @@ func (c *AdminUserController) BeforeEditAdminUser() {
newPermissionSrv := adminPermissionService.NewAdminPermissionService(nil)
allPermission, err := newPermissionSrv.ListAdminPermission(adminPermissionquery.ListAdminPermissionQuery{
ParentId: 0,
NotCode: []string{domain.PERMINSSION_ADMIN_USER},
})
if err != nil {
logs.Error("获取权限数据失败:%s", err)
... ...