...
|
...
|
@@ -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 {
|
...
|
...
|
|