作者 陈志颖

feat:完善共创申请查询方法

... ... @@ -424,10 +424,27 @@ func (cooperationApplicationService *CooperationApplicationService) SearchCooper
defer func() {
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationApplicationRepository = value
}
if count, cooperationApplications, err := cooperationApplicationRepository.Find(tool_funs.SimpleStructToMap(searchCooperationApplicationQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"grid": map[string]interface{}{
"total": count,
"list": cooperationApplications,
},
}, nil
}
return nil, nil
}
// UpdateCooperationApplication 更新共创申请服务
... ...
... ... @@ -181,6 +181,21 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
var cooperationApplicationModels []*models.CooperationApplication
cooperationApplications := make([]*domain.CooperationApplication, 0)
query := sqlbuilder.BuildQuery(tx.Model(&cooperationApplicationModels), queryOptions)
if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
query.Where("cooperation_project_number like ?", fmt.Sprintf("%%%s%%", cooperationProjectNumber))
}
//TODO 共创项目名称查询
if cooperationProjectName, ok := queryOptions["cooperationProjectName"]; ok && cooperationProjectName != "" {
query.Join("LEFT JOIN cooperation_projects AS a").
JoinOn("a.cooperation_project_number = cooperation_application.cooperation_project_number").
Where("a.cooperation_project_name like ?", fmt.Sprintf("%%%s%%", cooperationProjectName))
}
if applicantName, ok := queryOptions["applicantName"]; ok && applicantName != "" {
query.Where(`(cooperation_application.cooperation_application_applicant->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", applicantName))
}
if cooperationApplicationStatus, ok := queryOptions["cooperationApplicationStatus"]; ok && cooperationApplicationStatus.(int32) != 0 {
}
query.SetOffsetAndLimit(20)
query.SetOrderDirect("cooperation_application_id", "DESC")
if count, err := query.SelectAndCount(); err != nil {
... ...