作者 陈志颖

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

... ... @@ -234,6 +234,9 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -155,6 +155,15 @@ func (repository *CooperationContractChangeLogRepository) Find(queryOptions map[
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
if offsetLimitFlag {
query.SetOffsetAndLimit(20)
}
... ...
... ... @@ -170,6 +170,15 @@ func (repository *CooperationContractRelevantRepository) Find(queryOptions map[s
var cooperationContractRelevantModels []*models.CooperationContractRelevant
cooperationContractRelevants := make([]*domain.CooperationContractRelevant, 0)
query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractRelevantModels), queryOptions)
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -647,7 +647,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
}
// 返回新增的合约
cooperationContractSaved, err := repository.FindOne(map[string]interface{}{
"cooperationContractId":cooperationContract.CooperationContractId,
"cooperationContractId": cooperationContract.CooperationContractId,
})
if err != nil {
return nil, err
... ... @@ -910,6 +910,9 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
if incentivesType, ok := queryOptions["incentivesType"]; ok && incentivesType.(int32) != 0 {
query.Where("incentives_type = ?", incentivesType)
}
... ...
... ... @@ -181,6 +181,15 @@ func (repository *CooperationContractUndertakerRepository) Find(queryOptions map
var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
cooperationContractUndertakers := make([]*domain.CooperationContractUndertaker, 0)
query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractUndertakerModels), queryOptions)
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -178,6 +178,15 @@ func (repository *CooperationModeRepository) Find(queryOptions map[string]interf
if organizationName, ok := queryOptions["organizationName"]; ok && organizationName != "" {
query.Where("org->>'orgName' like ?", fmt.Sprintf("%%%s%%", organizationName))
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -232,6 +232,15 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int
var cooperationProjectModels []*models.CooperationProject
cooperationProjects := make([]*domain.CooperationProject, 0)
query := sqlbuilder.BuildQuery(tx.Model(&cooperationProjectModels), queryOptions)
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
if v, ok := queryOptions["status"]; ok && v.(int32) > 0 {
query.Where("status =? ", v)
}
... ...
... ... @@ -204,6 +204,15 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac
if paymentStatus, ok := queryOptions["paymentStatus"]; ok && paymentStatus.(int32) != 0 {
query.Where("payment_status = ?", paymentStatus)
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -286,6 +286,15 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte
if dividendsEstimateIds, ok := queryOptions["dividendsEstimateIds"]; ok && len(dividendsEstimateIds.([]int64)) > 0 {
query.Where("dividends_estimate_id IN (?)", pg.In(dividendsEstimateIds))
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -165,6 +165,15 @@ func (repository *DividendsIncentivesRuleRepository) Find(queryOptions map[strin
var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
dividendsIncentivesRules := make([]*domain.DividendsIncentivesRule, 0)
query := sqlbuilder.BuildQuery(tx.Model(&dividendsIncentivesRuleModels), queryOptions)
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -330,6 +330,15 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa
if dividendsOrderIds, ok := queryOptions["dividendsOrderIds"]; ok && len(dividendsOrderIds.([]int64)) > 0 {
query.Where("dividends_order_id IN (?)", pg.In(dividendsOrderIds.([]int64)))
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -342,6 +342,15 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string
if dividendsReturnedCustomerName, ok := queryOptions["dividendsReturnedCustomerName"]; ok && dividendsReturnedCustomerName != "" {
query.Where("dividends_returned_customer_name like ?", fmt.Sprintf("%%%s%%", dividendsReturnedCustomerName))
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -165,6 +165,15 @@ func (repository *MoneyIncentivesRuleRepository) Find(queryOptions map[string]in
var moneyIncentivesRuleModels []*models.MoneyIncentivesRule
moneyIncentivesRules := make([]*domain.MoneyIncentivesRule, 0)
query := sqlbuilder.BuildQuery(tx.Model(&moneyIncentivesRuleModels), queryOptions)
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...
... ... @@ -178,6 +178,15 @@ func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{})
if orderGoodIds, ok := queryOptions["orderGoodIds"]; ok && len(orderGoodIds.([]int64)) > 0 {
query.Where("order_good_id IN (?)", pg.In(orderGoodIds))
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
query.Where("org->>'orgId' in (?)", pg.In(orgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...