|
@@ -118,36 +118,53 @@ func (repository *ColumnSettingRepository) FindOne(queryOptions map[string]inter |
|
@@ -118,36 +118,53 @@ func (repository *ColumnSettingRepository) FindOne(queryOptions map[string]inter |
|
118
|
}
|
118
|
}
|
|
119
|
}
|
119
|
}
|
|
120
|
|
120
|
|
|
121
|
-func (repository *ColumnSettingRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ColumnSetting, error) {
|
121
|
+func (repository *ColumnSettingRepository) Find(queryOptions domain.ColumnSettingFindQuery) (int64, []*domain.ColumnSetting, error) {
|
|
122
|
tx := repository.transactionContext.PgTx
|
122
|
tx := repository.transactionContext.PgTx
|
|
123
|
var columnSettingModels []*models.ColumnSetting
|
123
|
var columnSettingModels []*models.ColumnSetting
|
|
124
|
columnSettings := make([]*domain.ColumnSetting, 0)
|
124
|
columnSettings := make([]*domain.ColumnSetting, 0)
|
|
125
|
query := tx.Model(&columnSettingModels)
|
125
|
query := tx.Model(&columnSettingModels)
|
|
126
|
- if ids, ok := queryOptions["ids"]; ok && len(ids.([]int64)) != 0 {
|
|
|
|
127
|
- query = query.Where("column_setting.uid in(?)", ids)
|
126
|
+ if len(queryOptions.Ids) > 0 {
|
|
|
|
127
|
+ query = query.Where("column_setting.uid in(?)", queryOptions.Ids)
|
|
128
|
}
|
128
|
}
|
|
129
|
- if uid, ok := queryOptions["uid"]; ok {
|
|
|
|
130
|
- query = query.Where("column_setting.uid = ?", uid)
|
129
|
+ if queryOptions.Uid > 0 {
|
|
|
|
130
|
+ query = query.Where("column_setting.uid = ?", queryOptions.Uid)
|
|
131
|
}
|
131
|
}
|
|
132
|
- if companyId, ok := queryOptions["companyId"]; ok {
|
|
|
|
133
|
- query = query.Where("column_setting.company_id = ?", companyId)
|
132
|
+ if queryOptions.CompanyId > 0 {
|
|
|
|
133
|
+ query = query.Where("column_setting.company_id = ?", queryOptions.CompanyId)
|
|
134
|
}
|
134
|
}
|
|
135
|
- if offset, ok := queryOptions["offset"]; ok {
|
|
|
|
136
|
- queryOffset := offset.(int)
|
|
|
|
137
|
- if queryOffset > -1 {
|
|
|
|
138
|
- query = query.Offset(queryOffset)
|
|
|
|
139
|
- }
|
|
|
|
140
|
- } else {
|
|
|
|
141
|
- query = query.Offset(0)
|
135
|
+ if queryOptions.Offset > -1 {
|
|
|
|
136
|
+ query = query.Offset(queryOptions.Offset)
|
|
142
|
}
|
137
|
}
|
|
143
|
- if limit, ok := queryOptions["limit"]; ok {
|
|
|
|
144
|
- queryLimit := limit.(int)
|
|
|
|
145
|
- if queryLimit > -1 {
|
|
|
|
146
|
- query = query.Limit(queryLimit)
|
|
|
|
147
|
- }
|
138
|
+ if queryOptions.Limit > 0 {
|
|
|
|
139
|
+ query = query.Limit(queryOptions.Limit)
|
|
148
|
} else {
|
140
|
} else {
|
|
149
|
query = query.Limit(20)
|
141
|
query = query.Limit(20)
|
|
150
|
}
|
142
|
}
|
|
|
|
143
|
+ //if ids, ok := queryOptions["ids"]; ok && len(ids.([]int64)) != 0 {
|
|
|
|
144
|
+ // query = query.Where("column_setting.uid in(?)", ids)
|
|
|
|
145
|
+ //}
|
|
|
|
146
|
+ //if uid, ok := queryOptions["uid"]; ok {
|
|
|
|
147
|
+ // query = query.Where("column_setting.uid = ?", uid)
|
|
|
|
148
|
+ //}
|
|
|
|
149
|
+ //if companyId, ok := queryOptions["companyId"]; ok {
|
|
|
|
150
|
+ // query = query.Where("column_setting.company_id = ?", companyId)
|
|
|
|
151
|
+ //}
|
|
|
|
152
|
+ //if offset, ok := queryOptions["offset"]; ok {
|
|
|
|
153
|
+ // queryOffset := offset.(int)
|
|
|
|
154
|
+ // if queryOffset > -1 {
|
|
|
|
155
|
+ // query = query.Offset(queryOffset)
|
|
|
|
156
|
+ // }
|
|
|
|
157
|
+ //} else {
|
|
|
|
158
|
+ // query = query.Offset(0)
|
|
|
|
159
|
+ //}
|
|
|
|
160
|
+ //if limit, ok := queryOptions["limit"]; ok {
|
|
|
|
161
|
+ // queryLimit := limit.(int)
|
|
|
|
162
|
+ // if queryLimit > -1 {
|
|
|
|
163
|
+ // query = query.Limit(queryLimit)
|
|
|
|
164
|
+ // }
|
|
|
|
165
|
+ //} else {
|
|
|
|
166
|
+ // query = query.Limit(20)
|
|
|
|
167
|
+ //}
|
|
151
|
if count, err := query.Order("id DESC").SelectAndCount(); err != nil {
|
168
|
if count, err := query.Order("id DESC").SelectAndCount(); err != nil {
|
|
152
|
return 0, columnSettings, err
|
169
|
return 0, columnSettings, err
|
|
153
|
} else {
|
170
|
} else {
|