...
|
...
|
@@ -77,6 +77,57 @@ func (dao *CooperationContractDao) CheckContractNumberAvailable(queryOptions map |
|
|
return !ok, err
|
|
|
}
|
|
|
|
|
|
// SearchCooperationContractByUndertaker 查询共创合约并根据承接人返回
|
|
|
func (dao *CooperationContractDao) SearchCooperationContractByUndertaker(queryOptions map[string]interface{}) (int, []*models.CooperationContractByUndertaker, error) {
|
|
|
tx := dao.transactionContext.PgTx
|
|
|
var cooperationContractByUndertakerModels []*models.CooperationContractByUndertaker
|
|
|
var cooperationUndertakerModels []*models.CooperationContractUndertaker
|
|
|
query := tx.Model(&cooperationUndertakerModels)
|
|
|
query.ColumnExpr("cooperation_contract_undertaker.cooperation_contract_undertaker_id")
|
|
|
query.ColumnExpr("cooperation_contract_undertaker.user_info->>'userCode' AS undertaker_code")
|
|
|
query.ColumnExpr("cooperation_contract_undertaker.user_info->>'userName' AS undertaker_name")
|
|
|
query.ColumnExpr("cooperation_contract_undertaker.user_info->>'userPhone' AS undertaker_phone")
|
|
|
query.ColumnExpr("cooperation_contract_undertaker.contract_attachment")
|
|
|
query.ColumnExpr("A.cooperation_contract_sponsor")
|
|
|
query.ColumnExpr("A.cooperation_contract_number")
|
|
|
query.ColumnExpr("A.cooperation_contract_name")
|
|
|
query.ColumnExpr("A.cooperation_contract_description")
|
|
|
query.ColumnExpr("A.department")
|
|
|
query.ColumnExpr("A.org")
|
|
|
query.ColumnExpr("A.status AS contract_status")
|
|
|
query.ColumnExpr("B.cooperation_mode_name")
|
|
|
if cooperationContractName, ok := queryOptions["cooperationContractName"]; ok && cooperationContractName != "" {
|
|
|
query = query.Where("A.cooperation_contract_name ilike ?", fmt.Sprintf("%%%s%%", cooperationContractName))
|
|
|
}
|
|
|
if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" {
|
|
|
query = query.Where(`A.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName))
|
|
|
}
|
|
|
query.Join("JOIN cooperation_contracts AS A ON A.cooperation_contract_number = cooperation_contract_undertaker.cooperation_contract_number")
|
|
|
query.Join("JOIN cooperation_modes AS B ON B.cooperation_mode_number = A.cooperation_mode_number")
|
|
|
query = query.Order("cooperation_contract_undertaker_id DESC")
|
|
|
if offset, ok := queryOptions["offset"]; ok && offset.(int64) != 0 {
|
|
|
offset := offset.(int64)
|
|
|
if offset > -1 {
|
|
|
query = query.Offset(int(offset))
|
|
|
}
|
|
|
} else {
|
|
|
query = query.Offset(0)
|
|
|
}
|
|
|
if limit, ok := queryOptions["limit"]; ok && limit.(int64) != 0 {
|
|
|
limit := limit.(int64)
|
|
|
if limit > -1 {
|
|
|
query = query.Limit(int(limit))
|
|
|
}
|
|
|
} else {
|
|
|
query = query.Limit(20)
|
|
|
}
|
|
|
if count, err := query.SelectAndCount(&cooperationContractByUndertakerModels); err != nil {
|
|
|
return 0, nil, err
|
|
|
} else {
|
|
|
return count, cooperationContractByUndertakerModels, nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func NewCooperationContractDao(transactionContext *pgTransaction.TransactionContext) (*CooperationContractDao, error) {
|
|
|
if transactionContext == nil {
|
|
|
return nil, fmt.Errorf("transactionContext参数不能为nil")
|
...
|
...
|
|