作者 陈志颖

feat:仓储查询方法增加查询所有

@@ -36,7 +36,6 @@ type CooperationModeRepository interface { @@ -36,7 +36,6 @@ type CooperationModeRepository interface {
36 BatchRemove(cooperationModes []*CooperationMode) ([]*CooperationMode, error) 36 BatchRemove(cooperationModes []*CooperationMode) ([]*CooperationMode, error)
37 FindOne(queryOptions map[string]interface{}) (*CooperationMode, error) 37 FindOne(queryOptions map[string]interface{}) (*CooperationMode, error)
38 Find(queryOptions map[string]interface{}) (int64, []*CooperationMode, error) 38 Find(queryOptions map[string]interface{}) (int64, []*CooperationMode, error)
39 - FindAll(queryOptions map[string]interface{}) (int64, []*CooperationMode, error)  
40 } 39 }
41 40
42 func (cooperationMode *CooperationMode) Identify() interface{} { 41 func (cooperationMode *CooperationMode) Identify() interface{} {
@@ -159,13 +159,19 @@ func (repository *ContractUndertakerFeedbackRepository) Find(queryOptions map[st @@ -159,13 +159,19 @@ func (repository *ContractUndertakerFeedbackRepository) Find(queryOptions map[st
159 // 搜索内容包括项目合约名称、承接人姓名、承接内容关键字 159 // 搜索内容包括项目合约名称、承接人姓名、承接内容关键字
160 if matchWord, ok := queryOptions["matchWord"]; ok && matchWord != "" { 160 if matchWord, ok := queryOptions["matchWord"]; ok && matchWord != "" {
161 query.WhereGroup(func(q *orm.Query) (*orm.Query, error) { 161 query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
162 - q.WhereOr("cooperation_contract_name like ?",fmt.Sprintf("%%%s%%", matchWord)) 162 + q.WhereOr("cooperation_contract_name like ?", fmt.Sprintf("%%%s%%", matchWord))
163 q.WhereOr("contract_undertaker->>'userName' like ?", fmt.Sprintf("%%%s%%", matchWord)) 163 q.WhereOr("contract_undertaker->>'userName' like ?", fmt.Sprintf("%%%s%%", matchWord))
164 q.WhereOr("feedback_content like ?", fmt.Sprintf("%%%s%%", matchWord)) 164 q.WhereOr("feedback_content like ?", fmt.Sprintf("%%%s%%", matchWord))
165 return q, nil 165 return q, nil
166 }) 166 })
167 } 167 }
168 - query.SetOffsetAndLimit(20) 168 + offsetLimitFlag := true
  169 + if limit, ok := queryOptions["limit"]; ok {
  170 + offsetLimitFlag = limit.(bool)
  171 + }
  172 + if offsetLimitFlag {
  173 + query.SetOffsetAndLimit(20)
  174 + }
169 query.SetOrderDirect("feedback_id", "DESC") 175 query.SetOrderDirect("feedback_id", "DESC")
170 if count, err := query.SelectAndCount(); err != nil { 176 if count, err := query.SelectAndCount(); err != nil {
171 return 0, contractUndertakerFeedbacks, err 177 return 0, contractUndertakerFeedbacks, err
@@ -196,7 +196,13 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string @@ -196,7 +196,13 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
196 if cooperationApplicationStatus, ok := queryOptions["cooperationApplicationStatus"]; ok && cooperationApplicationStatus.(int32) != 0 { 196 if cooperationApplicationStatus, ok := queryOptions["cooperationApplicationStatus"]; ok && cooperationApplicationStatus.(int32) != 0 {
197 197
198 } 198 }
199 - query.SetOffsetAndLimit(20) 199 + offsetLimitFlag := true
  200 + if limit, ok := queryOptions["limit"]; ok {
  201 + offsetLimitFlag = limit.(bool)
  202 + }
  203 + if offsetLimitFlag {
  204 + query.SetOffsetAndLimit(20)
  205 + }
200 query.SetOrderDirect("cooperation_application_id", "DESC") 206 query.SetOrderDirect("cooperation_application_id", "DESC")
201 if count, err := query.SelectAndCount(); err != nil { 207 if count, err := query.SelectAndCount(); err != nil {
202 return 0, cooperationApplications, err 208 return 0, cooperationApplications, err
@@ -141,7 +141,13 @@ func (repository *CooperationContractChangeLogRepository) Find(queryOptions map[ @@ -141,7 +141,13 @@ func (repository *CooperationContractChangeLogRepository) Find(queryOptions map[
141 var cooperationContractChangeLogModels []*models.CooperationContractChangeLog 141 var cooperationContractChangeLogModels []*models.CooperationContractChangeLog
142 cooperationContractChangeLogs := make([]*domain.CooperationContractChangeLog, 0) 142 cooperationContractChangeLogs := make([]*domain.CooperationContractChangeLog, 0)
143 query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractChangeLogModels), queryOptions) 143 query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractChangeLogModels), queryOptions)
144 - query.SetOffsetAndLimit(20) 144 + offsetLimitFlag := true
  145 + if limit, ok := queryOptions["limit"]; ok {
  146 + offsetLimitFlag = limit.(bool)
  147 + }
  148 + if offsetLimitFlag {
  149 + query.SetOffsetAndLimit(20)
  150 + }
145 query.SetOrderDirect("cooperation_contract_change_log_id", "DESC") 151 query.SetOrderDirect("cooperation_contract_change_log_id", "DESC")
146 if count, err := query.SelectAndCount(); err != nil { 152 if count, err := query.SelectAndCount(); err != nil {
147 return 0, cooperationContractChangeLogs, err 153 return 0, cooperationContractChangeLogs, err
@@ -166,7 +166,13 @@ func (repository *CooperationContractRelevantRepository) Find(queryOptions map[s @@ -166,7 +166,13 @@ func (repository *CooperationContractRelevantRepository) Find(queryOptions map[s
166 var cooperationContractRelevantModels []*models.CooperationContractRelevant 166 var cooperationContractRelevantModels []*models.CooperationContractRelevant
167 cooperationContractRelevants := make([]*domain.CooperationContractRelevant, 0) 167 cooperationContractRelevants := make([]*domain.CooperationContractRelevant, 0)
168 query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractRelevantModels), queryOptions) 168 query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractRelevantModels), queryOptions)
169 - query.SetOffsetAndLimit(20) 169 + offsetLimitFlag := true
  170 + if limit, ok := queryOptions["limit"]; ok {
  171 + offsetLimitFlag = limit.(bool)
  172 + }
  173 + if offsetLimitFlag {
  174 + query.SetOffsetAndLimit(20)
  175 + }
170 query.SetOrderDirect("cooperation_contract_relevant_id", "DESC") 176 query.SetOrderDirect("cooperation_contract_relevant_id", "DESC")
171 if count, err := query.SelectAndCount(); err != nil { 177 if count, err := query.SelectAndCount(); err != nil {
172 return 0, cooperationContractRelevants, err 178 return 0, cooperationContractRelevants, err
@@ -594,7 +594,6 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -594,7 +594,6 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
594 func (repository *CooperationContractRepository) UpdateMany(cooperationContracts []*domain.CooperationContract) ([]*domain.CooperationContract, error) { 594 func (repository *CooperationContractRepository) UpdateMany(cooperationContracts []*domain.CooperationContract) ([]*domain.CooperationContract, error) {
595 tx := repository.transactionContext.PgTx 595 tx := repository.transactionContext.PgTx
596 var cooperationContractModels []*models.CooperationContract 596 var cooperationContractModels []*models.CooperationContract
597 - cooperationContractQuery := tx.Model(&cooperationContractModels)  
598 for _, cooperationContract := range cooperationContracts { 597 for _, cooperationContract := range cooperationContracts {
599 cooperationContractModels = append(cooperationContractModels, &models.CooperationContract{ 598 cooperationContractModels = append(cooperationContractModels, &models.CooperationContract{
600 CooperationContractId: cooperationContract.CooperationContractId, 599 CooperationContractId: cooperationContract.CooperationContractId,
@@ -615,7 +614,7 @@ func (repository *CooperationContractRepository) UpdateMany(cooperationContracts @@ -615,7 +614,7 @@ func (repository *CooperationContractRepository) UpdateMany(cooperationContracts
615 UpdatedAt: time.Now(), 614 UpdatedAt: time.Now(),
616 }) 615 })
617 } 616 }
618 - if _, err := tx.Model(&cooperationContractQuery).WherePK().Update(); err != nil { 617 + if _, err := tx.Model(&cooperationContractModels).WherePK().Update(); err != nil {
619 return nil, err 618 return nil, err
620 } 619 }
621 return cooperationContracts, nil 620 return cooperationContracts, nil
@@ -739,7 +738,13 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in @@ -739,7 +738,13 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
739 if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" { 738 if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" {
740 query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName)) 739 query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName))
741 } 740 }
742 - query.SetOffsetAndLimit(20) 741 + offsetLimitFlag := true
  742 + if limit, ok := queryOptions["limit"]; ok {
  743 + offsetLimitFlag = limit.(bool)
  744 + }
  745 + if offsetLimitFlag {
  746 + query.SetOffsetAndLimit(20)
  747 + }
743 query.SetOrderDirect("cooperation_contract_id", "DESC") 748 query.SetOrderDirect("cooperation_contract_id", "DESC")
744 if count, err := query.SelectAndCount(); err != nil { 749 if count, err := query.SelectAndCount(); err != nil {
745 return 0, cooperationContracts, err 750 return 0, cooperationContracts, err
@@ -181,7 +181,13 @@ func (repository *CooperationContractUndertakerRepository) Find(queryOptions map @@ -181,7 +181,13 @@ func (repository *CooperationContractUndertakerRepository) Find(queryOptions map
181 var cooperationContractUndertakerModels []*models.CooperationContractUndertaker 181 var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
182 cooperationContractUndertakers := make([]*domain.CooperationContractUndertaker, 0) 182 cooperationContractUndertakers := make([]*domain.CooperationContractUndertaker, 0)
183 query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractUndertakerModels), queryOptions) 183 query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractUndertakerModels), queryOptions)
184 - query.SetOffsetAndLimit(20) 184 + offsetLimitFlag := true
  185 + if limit, ok := queryOptions["limit"]; ok {
  186 + offsetLimitFlag = limit.(bool)
  187 + }
  188 + if offsetLimitFlag {
  189 + query.SetOffsetAndLimit(20)
  190 + }
185 query.SetOrderDirect("cooperation_contract_undertaker_id", "DESC") 191 query.SetOrderDirect("cooperation_contract_undertaker_id", "DESC")
186 if count, err := query.SelectAndCount(); err != nil { 192 if count, err := query.SelectAndCount(); err != nil {
187 return 0, cooperationContractUndertakers, err 193 return 0, cooperationContractUndertakers, err
@@ -175,32 +175,12 @@ func (repository *CooperationModeRepository) Find(queryOptions map[string]interf @@ -175,32 +175,12 @@ func (repository *CooperationModeRepository) Find(queryOptions map[string]interf
175 if organizationName, ok := queryOptions["organizationName"]; ok && organizationName != "" { 175 if organizationName, ok := queryOptions["organizationName"]; ok && organizationName != "" {
176 query.Where("org->>'orgName' like ?", fmt.Sprintf("%%%s%%", organizationName)) 176 query.Where("org->>'orgName' like ?", fmt.Sprintf("%%%s%%", organizationName))
177 } 177 }
178 - query.SetOffsetAndLimit(20)  
179 - query.SetOrderDirect("cooperation_mode_id", "DESC")  
180 - if count, err := query.SelectAndCount(); err != nil {  
181 - return 0, cooperationModes, err  
182 - } else {  
183 - for _, cooperationModeModel := range cooperationModeModels {  
184 - if cooperationMode, err := transform.TransformToCooperationModeDomainModelFromPgModels(cooperationModeModel); err != nil {  
185 - return 0, cooperationModes, err  
186 - } else {  
187 - cooperationModes = append(cooperationModes, cooperationMode)  
188 - }  
189 - }  
190 - return int64(count), cooperationModes, nil 178 + offsetLimitFlag := true
  179 + if limit, ok := queryOptions["limit"]; ok {
  180 + offsetLimitFlag = limit.(bool)
191 } 181 }
192 -}  
193 -  
194 -func (repository *CooperationModeRepository) FindAll(queryOptions map[string]interface{}) (int64, []*domain.CooperationMode, error) {  
195 - tx := repository.transactionContext.PgTx  
196 - var cooperationModeModels []*models.CooperationMode  
197 - cooperationModes := make([]*domain.CooperationMode, 0)  
198 - query := sqlbuilder.BuildQuery(tx.Model(&cooperationModeModels), queryOptions)  
199 - if cooperationModeName, ok := queryOptions["cooperationModeName"]; ok && cooperationModeName != "" {  
200 - query.Where("cooperation_mode_name like ?", fmt.Sprintf("%%%s%%", cooperationModeName))  
201 - }  
202 - if organizationName, ok := queryOptions["organizationName"]; ok && organizationName != "" {  
203 - query.Where("org->>'orgName' like ?", fmt.Sprintf("%%%s%%", organizationName)) 182 + if offsetLimitFlag {
  183 + query.SetOffsetAndLimit(20)
204 } 184 }
205 query.SetOrderDirect("cooperation_mode_id", "DESC") 185 query.SetOrderDirect("cooperation_mode_id", "DESC")
206 if count, err := query.SelectAndCount(); err != nil { 186 if count, err := query.SelectAndCount(); err != nil {
@@ -202,7 +202,13 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int @@ -202,7 +202,13 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int
202 if v, ok := queryOptions["status"]; ok && v.(int32) > 0 { 202 if v, ok := queryOptions["status"]; ok && v.(int32) > 0 {
203 query.Where("status =? ", v) 203 query.Where("status =? ", v)
204 } 204 }
205 - query.SetOffsetAndLimit(20) 205 + offsetLimitFlag := true
  206 + if limit, ok := queryOptions["limit"]; ok {
  207 + offsetLimitFlag = limit.(bool)
  208 + }
  209 + if offsetLimitFlag {
  210 + query.SetOffsetAndLimit(20)
  211 + }
206 query.SetOrderDirect("cooperation_project_id", "DESC") 212 query.SetOrderDirect("cooperation_project_id", "DESC")
207 if count, err := query.SelectAndCount(); err != nil { 213 if count, err := query.SelectAndCount(); err != nil {
208 return 0, cooperationProjects, err 214 return 0, cooperationProjects, err
@@ -176,7 +176,13 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac @@ -176,7 +176,13 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac
176 var creditAccountModels []*models.CreditAccount 176 var creditAccountModels []*models.CreditAccount
177 creditAccounts := make([]*domain.CreditAccount, 0) 177 creditAccounts := make([]*domain.CreditAccount, 0)
178 query := sqlbuilder.BuildQuery(tx.Model(&creditAccountModels), queryOptions) 178 query := sqlbuilder.BuildQuery(tx.Model(&creditAccountModels), queryOptions)
179 - query.SetOffsetAndLimit(20) 179 + offsetLimitFlag := true
  180 + if limit, ok := queryOptions["limit"]; ok {
  181 + offsetLimitFlag = limit.(bool)
  182 + }
  183 + if offsetLimitFlag {
  184 + query.SetOffsetAndLimit(20)
  185 + }
180 query.SetOrderDirect("credit_account_id", "DESC") 186 query.SetOrderDirect("credit_account_id", "DESC")
181 if count, err := query.SelectAndCount(); err != nil { 187 if count, err := query.SelectAndCount(); err != nil {
182 return 0, creditAccounts, err 188 return 0, creditAccounts, err
@@ -176,7 +176,13 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte @@ -176,7 +176,13 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte
176 var dividendsEstimateModels []*models.DividendsEstimate 176 var dividendsEstimateModels []*models.DividendsEstimate
177 dividendsEstimates := make([]*domain.DividendsEstimate, 0) 177 dividendsEstimates := make([]*domain.DividendsEstimate, 0)
178 query := sqlbuilder.BuildQuery(tx.Model(&dividendsEstimateModels), queryOptions) 178 query := sqlbuilder.BuildQuery(tx.Model(&dividendsEstimateModels), queryOptions)
179 - query.SetOffsetAndLimit(20) 179 + offsetLimitFlag := true
  180 + if limit, ok := queryOptions["limit"]; ok {
  181 + offsetLimitFlag = limit.(bool)
  182 + }
  183 + if offsetLimitFlag {
  184 + query.SetOffsetAndLimit(20)
  185 + }
180 query.SetOrderDirect("dividends_estimate_id", "DESC") 186 query.SetOrderDirect("dividends_estimate_id", "DESC")
181 if count, err := query.SelectAndCount(); err != nil { 187 if count, err := query.SelectAndCount(); err != nil {
182 return 0, dividendsEstimates, err 188 return 0, dividendsEstimates, err
@@ -161,7 +161,13 @@ func (repository *DividendsIncentivesRuleRepository) Find(queryOptions map[strin @@ -161,7 +161,13 @@ func (repository *DividendsIncentivesRuleRepository) Find(queryOptions map[strin
161 var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule 161 var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
162 dividendsIncentivesRules := make([]*domain.DividendsIncentivesRule, 0) 162 dividendsIncentivesRules := make([]*domain.DividendsIncentivesRule, 0)
163 query := sqlbuilder.BuildQuery(tx.Model(&dividendsIncentivesRuleModels), queryOptions) 163 query := sqlbuilder.BuildQuery(tx.Model(&dividendsIncentivesRuleModels), queryOptions)
164 - query.SetOffsetAndLimit(20) 164 + offsetLimitFlag := true
  165 + if limit, ok := queryOptions["limit"]; ok {
  166 + offsetLimitFlag = limit.(bool)
  167 + }
  168 + if offsetLimitFlag {
  169 + query.SetOffsetAndLimit(20)
  170 + }
165 query.SetOrderDirect("dividends_incentives_rule_id", "DESC") 171 query.SetOrderDirect("dividends_incentives_rule_id", "DESC")
166 if count, err := query.SelectAndCount(); err != nil { 172 if count, err := query.SelectAndCount(); err != nil {
167 return 0, dividendsIncentivesRules, err 173 return 0, dividendsIncentivesRules, err
@@ -299,7 +299,13 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa @@ -299,7 +299,13 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa
299 var dividendsOrderModels []*models.DividendsOrder 299 var dividendsOrderModels []*models.DividendsOrder
300 dividendsOrders := make([]*domain.DividendsOrder, 0) 300 dividendsOrders := make([]*domain.DividendsOrder, 0)
301 query := sqlbuilder.BuildQuery(tx.Model(&dividendsOrderModels), queryOptions) 301 query := sqlbuilder.BuildQuery(tx.Model(&dividendsOrderModels), queryOptions)
302 - query.SetOffsetAndLimit(20) 302 + offsetLimitFlag := true
  303 + if limit, ok := queryOptions["limit"]; ok {
  304 + offsetLimitFlag = limit.(bool)
  305 + }
  306 + if offsetLimitFlag {
  307 + query.SetOffsetAndLimit(20)
  308 + }
303 query.SetOrderDirect("dividends_order_id", "DESC") 309 query.SetOrderDirect("dividends_order_id", "DESC")
304 if count, err := query.SelectAndCount(); err != nil { 310 if count, err := query.SelectAndCount(); err != nil {
305 return 0, dividendsOrders, err 311 return 0, dividendsOrders, err
@@ -306,7 +306,13 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string @@ -306,7 +306,13 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string
306 var dividendsReturnedOrderModels []*models.DividendsReturnedOrder 306 var dividendsReturnedOrderModels []*models.DividendsReturnedOrder
307 dividendsReturnedOrders := make([]*domain.DividendsReturnedOrder, 0) 307 dividendsReturnedOrders := make([]*domain.DividendsReturnedOrder, 0)
308 query := sqlbuilder.BuildQuery(tx.Model(&dividendsReturnedOrderModels), queryOptions) 308 query := sqlbuilder.BuildQuery(tx.Model(&dividendsReturnedOrderModels), queryOptions)
309 - query.SetOffsetAndLimit(20) 309 + offsetLimitFlag := true
  310 + if limit, ok := queryOptions["limit"]; ok {
  311 + offsetLimitFlag = limit.(bool)
  312 + }
  313 + if offsetLimitFlag {
  314 + query.SetOffsetAndLimit(20)
  315 + }
310 query.SetOrderDirect("dividends_returned_order_id", "DESC") 316 query.SetOrderDirect("dividends_returned_order_id", "DESC")
311 if count, err := query.SelectAndCount(); err != nil { 317 if count, err := query.SelectAndCount(); err != nil {
312 return 0, dividendsReturnedOrders, err 318 return 0, dividendsReturnedOrders, err
@@ -161,7 +161,13 @@ func (repository *MoneyIncentivesRuleRepository) Find(queryOptions map[string]in @@ -161,7 +161,13 @@ func (repository *MoneyIncentivesRuleRepository) Find(queryOptions map[string]in
161 var moneyIncentivesRuleModels []*models.MoneyIncentivesRule 161 var moneyIncentivesRuleModels []*models.MoneyIncentivesRule
162 moneyIncentivesRules := make([]*domain.MoneyIncentivesRule, 0) 162 moneyIncentivesRules := make([]*domain.MoneyIncentivesRule, 0)
163 query := sqlbuilder.BuildQuery(tx.Model(&moneyIncentivesRuleModels), queryOptions) 163 query := sqlbuilder.BuildQuery(tx.Model(&moneyIncentivesRuleModels), queryOptions)
164 - query.SetOffsetAndLimit(20) 164 + offsetLimitFlag := true
  165 + if limit, ok := queryOptions["limit"]; ok {
  166 + offsetLimitFlag = limit.(bool)
  167 + }
  168 + if offsetLimitFlag {
  169 + query.SetOffsetAndLimit(20)
  170 + }
165 query.SetOrderDirect("money_incentives_rule_id", "DESC") 171 query.SetOrderDirect("money_incentives_rule_id", "DESC")
166 if count, err := query.SelectAndCount(); err != nil { 172 if count, err := query.SelectAndCount(); err != nil {
167 return 0, moneyIncentivesRules, err 173 return 0, moneyIncentivesRules, err
@@ -156,7 +156,13 @@ func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{}) @@ -156,7 +156,13 @@ func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{})
156 var orderGoodModels []*models.OrderGood 156 var orderGoodModels []*models.OrderGood
157 orderGoods := make([]*domain.OrderGood, 0) 157 orderGoods := make([]*domain.OrderGood, 0)
158 query := sqlbuilder.BuildQuery(tx.Model(&orderGoodModels), queryOptions) 158 query := sqlbuilder.BuildQuery(tx.Model(&orderGoodModels), queryOptions)
159 - query.SetOffsetAndLimit(20) 159 + offsetLimitFlag := true
  160 + if limit, ok := queryOptions["limit"]; ok {
  161 + offsetLimitFlag = limit.(bool)
  162 + }
  163 + if offsetLimitFlag {
  164 + query.SetOffsetAndLimit(20)
  165 + }
160 query.SetOrderDirect("order_good_id", "DESC") 166 query.SetOrderDirect("order_good_id", "DESC")
161 if count, err := query.SelectAndCount(); err != nil { 167 if count, err := query.SelectAndCount(); err != nil {
162 return 0, orderGoods, err 168 return 0, orderGoods, err