作者 陈志颖

test:测试删除用户

... ... @@ -142,7 +142,10 @@ func (columnSettingService *ColumnSettingService) ListColumnSetting(listColumnSe
} else {
columnSettingRepository = value
}
if count, columnSettings, err := columnSettingRepository.Find(tool_funs.SimpleStructToMap(listColumnSettingQuery)); err != nil {
if count, columnSettings, err := columnSettingRepository.Find(domain.ColumnSettingFindQuery{
Offset: listColumnSettingQuery.Offset,
Limit: listColumnSettingQuery.Limit,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
... ...
... ... @@ -361,7 +361,10 @@ func (service SyncEmployeeService) deleteEmployeeData(data DeleteUserData) error
} else {
columnSettingRepository = value
}
_, columnSettingsFound, err := columnSettingRepository.Find(map[string]interface{}{"ids": data.Ids, "companyId": data.CompanyId})
_, columnSettingsFound, err := columnSettingRepository.Find(domain.ColumnSettingFindQuery{
Ids: data.Ids,
CompanyId: int(data.CompanyId),
})
if err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -92,11 +92,20 @@ type ColumnSetting struct {
InvalidValue []Column `json:"invalidValue"`
}
type ColumnSettingFindQuery struct {
Ids []int64
Uid int64
CompanyId int
Offset int
Limit int
}
type ColumnSettingRepository interface {
Save(columnSetting *ColumnSetting) (*ColumnSetting, error)
Remove(columnSetting *ColumnSetting, columnSettings []*ColumnSetting) (*ColumnSetting, []*ColumnSetting, error)
FindOne(queryOptions map[string]interface{}) (*ColumnSetting, error)
Find(queryOptions map[string]interface{}) (int64, []*ColumnSetting, error)
//Find(queryOptions map[string]interface{}) (int64, []*ColumnSetting, error)
Find(ColumnSettingFindQuery) (int64, []*ColumnSetting, error)
}
func (columnSetting *ColumnSetting) Identify() interface{} {
... ...
... ... @@ -118,36 +118,53 @@ func (repository *ColumnSettingRepository) FindOne(queryOptions map[string]inter
}
}
func (repository *ColumnSettingRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ColumnSetting, error) {
func (repository *ColumnSettingRepository) Find(queryOptions domain.ColumnSettingFindQuery) (int64, []*domain.ColumnSetting, error) {
tx := repository.transactionContext.PgTx
var columnSettingModels []*models.ColumnSetting
columnSettings := make([]*domain.ColumnSetting, 0)
query := tx.Model(&columnSettingModels)
if ids, ok := queryOptions["ids"]; ok && len(ids.([]int64)) != 0 {
query = query.Where("column_setting.uid in(?)", ids)
if len(queryOptions.Ids) > 0 {
query = query.Where("column_setting.uid in(?)", queryOptions.Ids)
}
if uid, ok := queryOptions["uid"]; ok {
query = query.Where("column_setting.uid = ?", uid)
if queryOptions.Uid > 0 {
query = query.Where("column_setting.uid = ?", queryOptions.Uid)
}
if companyId, ok := queryOptions["companyId"]; ok {
query = query.Where("column_setting.company_id = ?", companyId)
if queryOptions.CompanyId > 0 {
query = query.Where("column_setting.company_id = ?", queryOptions.CompanyId)
}
if offset, ok := queryOptions["offset"]; ok {
queryOffset := offset.(int)
if queryOffset > -1 {
query = query.Offset(queryOffset)
}
} else {
query = query.Offset(0)
if queryOptions.Offset > -1 {
query = query.Offset(queryOptions.Offset)
}
if limit, ok := queryOptions["limit"]; ok {
queryLimit := limit.(int)
if queryLimit > -1 {
query = query.Limit(queryLimit)
}
if queryOptions.Limit > 0 {
query = query.Limit(queryOptions.Limit)
} else {
query = query.Limit(20)
}
//if ids, ok := queryOptions["ids"]; ok && len(ids.([]int64)) != 0 {
// query = query.Where("column_setting.uid in(?)", ids)
//}
//if uid, ok := queryOptions["uid"]; ok {
// query = query.Where("column_setting.uid = ?", uid)
//}
//if companyId, ok := queryOptions["companyId"]; ok {
// query = query.Where("column_setting.company_id = ?", companyId)
//}
//if offset, ok := queryOptions["offset"]; ok {
// queryOffset := offset.(int)
// if queryOffset > -1 {
// query = query.Offset(queryOffset)
// }
//} else {
// query = query.Offset(0)
//}
//if limit, ok := queryOptions["limit"]; ok {
// queryLimit := limit.(int)
// if queryLimit > -1 {
// query = query.Limit(queryLimit)
// }
//} else {
// query = query.Limit(20)
//}
if count, err := query.Order("id DESC").SelectAndCount(); err != nil {
return 0, columnSettings, err
} else {
... ...