作者 陈志颖

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

@@ -424,10 +424,27 @@ func (cooperationApplicationService *CooperationApplicationService) SearchCooper @@ -424,10 +424,27 @@ func (cooperationApplicationService *CooperationApplicationService) SearchCooper
424 defer func() { 424 defer func() {
425 _ = transactionContext.RollbackTransaction() 425 _ = transactionContext.RollbackTransaction()
426 }() 426 }()
427 - if err := transactionContext.CommitTransaction(); err != nil {  
428 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 427 + var cooperationApplicationRepository domain.CooperationApplicationRepository
  428 + if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
  429 + "transactionContext": transactionContext,
  430 + }); err != nil {
  431 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  432 + } else {
  433 + cooperationApplicationRepository = value
  434 + }
  435 + if count, cooperationApplications, err := cooperationApplicationRepository.Find(tool_funs.SimpleStructToMap(searchCooperationApplicationQuery)); err != nil {
  436 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  437 + } else {
  438 + if err := transactionContext.CommitTransaction(); err != nil {
  439 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  440 + }
  441 + return map[string]interface{}{
  442 + "grid": map[string]interface{}{
  443 + "total": count,
  444 + "list": cooperationApplications,
  445 + },
  446 + }, nil
429 } 447 }
430 - return nil, nil  
431 } 448 }
432 449
433 // UpdateCooperationApplication 更新共创申请服务 450 // UpdateCooperationApplication 更新共创申请服务
@@ -181,6 +181,21 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string @@ -181,6 +181,21 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
181 var cooperationApplicationModels []*models.CooperationApplication 181 var cooperationApplicationModels []*models.CooperationApplication
182 cooperationApplications := make([]*domain.CooperationApplication, 0) 182 cooperationApplications := make([]*domain.CooperationApplication, 0)
183 query := sqlbuilder.BuildQuery(tx.Model(&cooperationApplicationModels), queryOptions) 183 query := sqlbuilder.BuildQuery(tx.Model(&cooperationApplicationModels), queryOptions)
  184 + if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
  185 + query.Where("cooperation_project_number like ?", fmt.Sprintf("%%%s%%", cooperationProjectNumber))
  186 + }
  187 + //TODO 共创项目名称查询
  188 + if cooperationProjectName, ok := queryOptions["cooperationProjectName"]; ok && cooperationProjectName != "" {
  189 + query.Join("LEFT JOIN cooperation_projects AS a").
  190 + JoinOn("a.cooperation_project_number = cooperation_application.cooperation_project_number").
  191 + Where("a.cooperation_project_name like ?", fmt.Sprintf("%%%s%%", cooperationProjectName))
  192 + }
  193 + if applicantName, ok := queryOptions["applicantName"]; ok && applicantName != "" {
  194 + query.Where(`(cooperation_application.cooperation_application_applicant->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", applicantName))
  195 + }
  196 + if cooperationApplicationStatus, ok := queryOptions["cooperationApplicationStatus"]; ok && cooperationApplicationStatus.(int32) != 0 {
  197 +
  198 + }
184 query.SetOffsetAndLimit(20) 199 query.SetOffsetAndLimit(20)
185 query.SetOrderDirect("cooperation_application_id", "DESC") 200 query.SetOrderDirect("cooperation_application_id", "DESC")
186 if count, err := query.SelectAndCount(); err != nil { 201 if count, err := query.SelectAndCount(); err != nil {