作者 陈志颖

feat:仓储增加公司、组织查询条件

@@ -234,6 +234,9 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string @@ -234,6 +234,9 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
234 if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { 234 if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
235 query.Where("org->>'orgId' = '?'", orgId) 235 query.Where("org->>'orgId' = '?'", orgId)
236 } 236 }
  237 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  238 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  239 + }
237 offsetLimitFlag := true 240 offsetLimitFlag := true
238 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 241 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
239 offsetLimitFlag = offsetLimit.(bool) 242 offsetLimitFlag = offsetLimit.(bool)
@@ -155,6 +155,15 @@ func (repository *CooperationContractChangeLogRepository) Find(queryOptions map[ @@ -155,6 +155,15 @@ func (repository *CooperationContractChangeLogRepository) Find(queryOptions map[
155 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 155 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
156 offsetLimitFlag = offsetLimit.(bool) 156 offsetLimitFlag = offsetLimit.(bool)
157 } 157 }
  158 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  159 + query.Where("company->>'companyId' = '?'", companyId)
  160 + }
  161 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  162 + query.Where("org->>'orgId' = '?'", orgId)
  163 + }
  164 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  165 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  166 + }
158 if offsetLimitFlag { 167 if offsetLimitFlag {
159 query.SetOffsetAndLimit(20) 168 query.SetOffsetAndLimit(20)
160 } 169 }
@@ -170,6 +170,15 @@ func (repository *CooperationContractRelevantRepository) Find(queryOptions map[s @@ -170,6 +170,15 @@ func (repository *CooperationContractRelevantRepository) Find(queryOptions map[s
170 var cooperationContractRelevantModels []*models.CooperationContractRelevant 170 var cooperationContractRelevantModels []*models.CooperationContractRelevant
171 cooperationContractRelevants := make([]*domain.CooperationContractRelevant, 0) 171 cooperationContractRelevants := make([]*domain.CooperationContractRelevant, 0)
172 query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractRelevantModels), queryOptions) 172 query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractRelevantModels), queryOptions)
  173 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  174 + query.Where("company->>'companyId' = '?'", companyId)
  175 + }
  176 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  177 + query.Where("org->>'orgId' = '?'", orgId)
  178 + }
  179 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  180 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  181 + }
173 offsetLimitFlag := true 182 offsetLimitFlag := true
174 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 183 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
175 offsetLimitFlag = offsetLimit.(bool) 184 offsetLimitFlag = offsetLimit.(bool)
@@ -647,7 +647,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -647,7 +647,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
647 } 647 }
648 // 返回新增的合约 648 // 返回新增的合约
649 cooperationContractSaved, err := repository.FindOne(map[string]interface{}{ 649 cooperationContractSaved, err := repository.FindOne(map[string]interface{}{
650 - "cooperationContractId":cooperationContract.CooperationContractId, 650 + "cooperationContractId": cooperationContract.CooperationContractId,
651 }) 651 })
652 if err != nil { 652 if err != nil {
653 return nil, err 653 return nil, err
@@ -910,6 +910,9 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in @@ -910,6 +910,9 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
910 if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { 910 if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
911 query.Where("org->>'orgId' = '?'", orgId) 911 query.Where("org->>'orgId' = '?'", orgId)
912 } 912 }
  913 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  914 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  915 + }
913 if incentivesType, ok := queryOptions["incentivesType"]; ok && incentivesType.(int32) != 0 { 916 if incentivesType, ok := queryOptions["incentivesType"]; ok && incentivesType.(int32) != 0 {
914 query.Where("incentives_type = ?", incentivesType) 917 query.Where("incentives_type = ?", incentivesType)
915 } 918 }
@@ -181,6 +181,15 @@ func (repository *CooperationContractUndertakerRepository) Find(queryOptions map @@ -181,6 +181,15 @@ 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 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  185 + query.Where("company->>'companyId' = '?'", companyId)
  186 + }
  187 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  188 + query.Where("org->>'orgId' = '?'", orgId)
  189 + }
  190 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  191 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  192 + }
184 offsetLimitFlag := true 193 offsetLimitFlag := true
185 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 194 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
186 offsetLimitFlag = offsetLimit.(bool) 195 offsetLimitFlag = offsetLimit.(bool)
@@ -178,6 +178,15 @@ func (repository *CooperationModeRepository) Find(queryOptions map[string]interf @@ -178,6 +178,15 @@ func (repository *CooperationModeRepository) Find(queryOptions map[string]interf
178 if organizationName, ok := queryOptions["organizationName"]; ok && organizationName != "" { 178 if organizationName, ok := queryOptions["organizationName"]; ok && organizationName != "" {
179 query.Where("org->>'orgName' like ?", fmt.Sprintf("%%%s%%", organizationName)) 179 query.Where("org->>'orgName' like ?", fmt.Sprintf("%%%s%%", organizationName))
180 } 180 }
  181 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  182 + query.Where("company->>'companyId' = '?'", companyId)
  183 + }
  184 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  185 + query.Where("org->>'orgId' = '?'", orgId)
  186 + }
  187 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  188 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  189 + }
181 offsetLimitFlag := true 190 offsetLimitFlag := true
182 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 191 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
183 offsetLimitFlag = offsetLimit.(bool) 192 offsetLimitFlag = offsetLimit.(bool)
@@ -232,6 +232,15 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int @@ -232,6 +232,15 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int
232 var cooperationProjectModels []*models.CooperationProject 232 var cooperationProjectModels []*models.CooperationProject
233 cooperationProjects := make([]*domain.CooperationProject, 0) 233 cooperationProjects := make([]*domain.CooperationProject, 0)
234 query := sqlbuilder.BuildQuery(tx.Model(&cooperationProjectModels), queryOptions) 234 query := sqlbuilder.BuildQuery(tx.Model(&cooperationProjectModels), queryOptions)
  235 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  236 + query.Where("company->>'companyId' = '?'", companyId)
  237 + }
  238 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  239 + query.Where("org->>'orgId' = '?'", orgId)
  240 + }
  241 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  242 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  243 + }
235 if v, ok := queryOptions["status"]; ok && v.(int32) > 0 { 244 if v, ok := queryOptions["status"]; ok && v.(int32) > 0 {
236 query.Where("status =? ", v) 245 query.Where("status =? ", v)
237 } 246 }
@@ -204,6 +204,15 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac @@ -204,6 +204,15 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac
204 if paymentStatus, ok := queryOptions["paymentStatus"]; ok && paymentStatus.(int32) != 0 { 204 if paymentStatus, ok := queryOptions["paymentStatus"]; ok && paymentStatus.(int32) != 0 {
205 query.Where("payment_status = ?", paymentStatus) 205 query.Where("payment_status = ?", paymentStatus)
206 } 206 }
  207 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  208 + query.Where("company->>'companyId' = '?'", companyId)
  209 + }
  210 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  211 + query.Where("org->>'orgId' = '?'", orgId)
  212 + }
  213 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  214 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  215 + }
207 offsetLimitFlag := true 216 offsetLimitFlag := true
208 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 217 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
209 offsetLimitFlag = offsetLimit.(bool) 218 offsetLimitFlag = offsetLimit.(bool)
@@ -286,6 +286,15 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte @@ -286,6 +286,15 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte
286 if dividendsEstimateIds, ok := queryOptions["dividendsEstimateIds"]; ok && len(dividendsEstimateIds.([]int64)) > 0 { 286 if dividendsEstimateIds, ok := queryOptions["dividendsEstimateIds"]; ok && len(dividendsEstimateIds.([]int64)) > 0 {
287 query.Where("dividends_estimate_id IN (?)", pg.In(dividendsEstimateIds)) 287 query.Where("dividends_estimate_id IN (?)", pg.In(dividendsEstimateIds))
288 } 288 }
  289 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  290 + query.Where("company->>'companyId' = '?'", companyId)
  291 + }
  292 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  293 + query.Where("org->>'orgId' = '?'", orgId)
  294 + }
  295 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  296 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  297 + }
289 offsetLimitFlag := true 298 offsetLimitFlag := true
290 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 299 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
291 offsetLimitFlag = offsetLimit.(bool) 300 offsetLimitFlag = offsetLimit.(bool)
@@ -165,6 +165,15 @@ func (repository *DividendsIncentivesRuleRepository) Find(queryOptions map[strin @@ -165,6 +165,15 @@ func (repository *DividendsIncentivesRuleRepository) Find(queryOptions map[strin
165 var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule 165 var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
166 dividendsIncentivesRules := make([]*domain.DividendsIncentivesRule, 0) 166 dividendsIncentivesRules := make([]*domain.DividendsIncentivesRule, 0)
167 query := sqlbuilder.BuildQuery(tx.Model(&dividendsIncentivesRuleModels), queryOptions) 167 query := sqlbuilder.BuildQuery(tx.Model(&dividendsIncentivesRuleModels), queryOptions)
  168 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  169 + query.Where("company->>'companyId' = '?'", companyId)
  170 + }
  171 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  172 + query.Where("org->>'orgId' = '?'", orgId)
  173 + }
  174 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  175 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  176 + }
168 offsetLimitFlag := true 177 offsetLimitFlag := true
169 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 178 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
170 offsetLimitFlag = offsetLimit.(bool) 179 offsetLimitFlag = offsetLimit.(bool)
@@ -330,6 +330,15 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa @@ -330,6 +330,15 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa
330 if dividendsOrderIds, ok := queryOptions["dividendsOrderIds"]; ok && len(dividendsOrderIds.([]int64)) > 0 { 330 if dividendsOrderIds, ok := queryOptions["dividendsOrderIds"]; ok && len(dividendsOrderIds.([]int64)) > 0 {
331 query.Where("dividends_order_id IN (?)", pg.In(dividendsOrderIds.([]int64))) 331 query.Where("dividends_order_id IN (?)", pg.In(dividendsOrderIds.([]int64)))
332 } 332 }
  333 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  334 + query.Where("company->>'companyId' = '?'", companyId)
  335 + }
  336 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  337 + query.Where("org->>'orgId' = '?'", orgId)
  338 + }
  339 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  340 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  341 + }
333 offsetLimitFlag := true 342 offsetLimitFlag := true
334 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 343 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
335 offsetLimitFlag = offsetLimit.(bool) 344 offsetLimitFlag = offsetLimit.(bool)
@@ -342,6 +342,15 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string @@ -342,6 +342,15 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string
342 if dividendsReturnedCustomerName, ok := queryOptions["dividendsReturnedCustomerName"]; ok && dividendsReturnedCustomerName != "" { 342 if dividendsReturnedCustomerName, ok := queryOptions["dividendsReturnedCustomerName"]; ok && dividendsReturnedCustomerName != "" {
343 query.Where("dividends_returned_customer_name like ?", fmt.Sprintf("%%%s%%", dividendsReturnedCustomerName)) 343 query.Where("dividends_returned_customer_name like ?", fmt.Sprintf("%%%s%%", dividendsReturnedCustomerName))
344 } 344 }
  345 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  346 + query.Where("company->>'companyId' = '?'", companyId)
  347 + }
  348 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  349 + query.Where("org->>'orgId' = '?'", orgId)
  350 + }
  351 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  352 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  353 + }
345 offsetLimitFlag := true 354 offsetLimitFlag := true
346 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 355 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
347 offsetLimitFlag = offsetLimit.(bool) 356 offsetLimitFlag = offsetLimit.(bool)
@@ -165,6 +165,15 @@ func (repository *MoneyIncentivesRuleRepository) Find(queryOptions map[string]in @@ -165,6 +165,15 @@ func (repository *MoneyIncentivesRuleRepository) Find(queryOptions map[string]in
165 var moneyIncentivesRuleModels []*models.MoneyIncentivesRule 165 var moneyIncentivesRuleModels []*models.MoneyIncentivesRule
166 moneyIncentivesRules := make([]*domain.MoneyIncentivesRule, 0) 166 moneyIncentivesRules := make([]*domain.MoneyIncentivesRule, 0)
167 query := sqlbuilder.BuildQuery(tx.Model(&moneyIncentivesRuleModels), queryOptions) 167 query := sqlbuilder.BuildQuery(tx.Model(&moneyIncentivesRuleModels), queryOptions)
  168 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  169 + query.Where("company->>'companyId' = '?'", companyId)
  170 + }
  171 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  172 + query.Where("org->>'orgId' = '?'", orgId)
  173 + }
  174 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  175 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  176 + }
168 offsetLimitFlag := true 177 offsetLimitFlag := true
169 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 178 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
170 offsetLimitFlag = offsetLimit.(bool) 179 offsetLimitFlag = offsetLimit.(bool)
@@ -178,6 +178,15 @@ func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{}) @@ -178,6 +178,15 @@ func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{})
178 if orderGoodIds, ok := queryOptions["orderGoodIds"]; ok && len(orderGoodIds.([]int64)) > 0 { 178 if orderGoodIds, ok := queryOptions["orderGoodIds"]; ok && len(orderGoodIds.([]int64)) > 0 {
179 query.Where("order_good_id IN (?)", pg.In(orderGoodIds)) 179 query.Where("order_good_id IN (?)", pg.In(orderGoodIds))
180 } 180 }
  181 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  182 + query.Where("company->>'companyId' = '?'", companyId)
  183 + }
  184 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  185 + query.Where("org->>'orgId' = '?'", orgId)
  186 + }
  187 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  188 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  189 + }
181 offsetLimitFlag := true 190 offsetLimitFlag := true
182 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 191 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
183 offsetLimitFlag = offsetLimit.(bool) 192 offsetLimitFlag = offsetLimit.(bool)