...
|
...
|
@@ -276,40 +276,44 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string |
|
|
if count > 0 {
|
|
|
for _, cooperationApplicationModel := range cooperationApplicationModels {
|
|
|
// 获取共创项目
|
|
|
cooperationProjectModel := new(models.CooperationProject)
|
|
|
cooperationProjectQuery := tx.Model(cooperationProjectModel)
|
|
|
cooperationProjectQuery.AllWithDeleted()
|
|
|
if err := cooperationProjectQuery.
|
|
|
var cooperationProjectModels []*models.CooperationProject
|
|
|
cooperationProjectQuery := tx.Model(&cooperationProjectModels)
|
|
|
if countProject, err := cooperationProjectQuery.
|
|
|
Where("company->>'companyId' = '?'", cooperationApplicationModel.Company.CompanyId).
|
|
|
Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId).
|
|
|
Where("cooperation_project_number = ?", cooperationApplicationModel.CooperationProjectNumber).
|
|
|
First(); err != nil {
|
|
|
Limit(1).
|
|
|
SelectAndCount(); err != nil {
|
|
|
log.Logger.Error("申请关联的共创项目不存在", map[string]interface{}{
|
|
|
"cooperationApplicationModel": cooperationApplicationModel,
|
|
|
})
|
|
|
return 0, nil, fmt.Errorf("申请关联的共创项目不存在")
|
|
|
}
|
|
|
} else {
|
|
|
if countProject > 0 {
|
|
|
// 获取共创模式
|
|
|
cooperationModeModel := new(models.CooperationMode)
|
|
|
cooperationModeQuery := tx.Model(cooperationModeModel)
|
|
|
cooperationModeQuery.AllWithDeleted()
|
|
|
if err := cooperationModeQuery.
|
|
|
var cooperationModeModels []*models.CooperationMode
|
|
|
cooperationModeQuery := tx.Model(&cooperationModeModels)
|
|
|
if countMode, err := cooperationModeQuery.
|
|
|
Where("company->>'companyId' = '?'", cooperationApplicationModel.Company.CompanyId).
|
|
|
Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId).
|
|
|
Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).
|
|
|
First(); err != nil {
|
|
|
Where("cooperation_mode_number = ?", cooperationProjectModels[0].CooperationModeNumber).
|
|
|
Limit(1).
|
|
|
SelectAndCount(); err != nil {
|
|
|
log.Logger.Error("申请关联的共创模式不存在", map[string]interface{}{
|
|
|
"cooperationApplicationModel": cooperationApplicationModel,
|
|
|
})
|
|
|
return 0, nil, fmt.Errorf("申请关联的共创模式不存在")
|
|
|
}
|
|
|
if cooperationApplication, err := transform.TransformToCooperationApplicationDomainModelFromPgModels(cooperationApplicationModel, cooperationProjectModel, cooperationModeModel); err != nil {
|
|
|
} else {
|
|
|
if countMode > 0 {
|
|
|
if cooperationApplication, err := transform.TransformToCooperationApplicationDomainModelFromPgModels(cooperationApplicationModel, cooperationProjectModels[0], cooperationModeModels[0]); err != nil {
|
|
|
return 0, cooperationApplications, err
|
|
|
} else {
|
|
|
cooperationApplications = append(cooperationApplications, cooperationApplication)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return int64(count), cooperationApplications, nil
|
|
|
}
|
|
|
}
|
...
|
...
|
|