...
|
...
|
@@ -4,6 +4,7 @@ import ( |
|
|
"fmt"
|
|
|
"github.com/go-pg/pg/v10"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
|
|
|
"time"
|
|
|
|
|
|
"github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
|
...
|
...
|
@@ -189,7 +190,7 @@ func (repository *CooperationApplicationRepository) FindOne(queryOptions map[str |
|
|
query.SetWhereByQueryOption("cooperation_application.cooperation_application_id = ?", "cooperationApplicationId")
|
|
|
if err := query.First(); err != nil {
|
|
|
if err.Error() == "pg: no rows in result set" {
|
|
|
return nil, fmt.Errorf("没有此资源")
|
|
|
return nil, fmt.Errorf("共创申请不存在")
|
|
|
} else {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
@@ -200,14 +201,26 @@ func (repository *CooperationApplicationRepository) FindOne(queryOptions map[str |
|
|
// 获取共创项目
|
|
|
cooperationProjectModel := new(models.CooperationProject)
|
|
|
cooperationProjectQuery := tx.Model(cooperationProjectModel)
|
|
|
if err := cooperationProjectQuery.Where("cooperation_project_number = ?", cooperationApplicationModel.CooperationProjectNumber).First(); err != nil {
|
|
|
return nil, err
|
|
|
if err := cooperationProjectQuery.
|
|
|
Where("company->>'companyId' = '?'", cooperationApplicationModel.Company.CompanyId).
|
|
|
Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId).
|
|
|
Where("cooperation_project_number = ?", cooperationApplicationModel.CooperationProjectNumber).First(); err != nil {
|
|
|
log.Logger.Error("申请关联的共创项目不存在", map[string]interface{}{
|
|
|
"cooperationApplicationModel": cooperationApplicationModel,
|
|
|
})
|
|
|
return nil, fmt.Errorf("申请关联的共创项目不存在")
|
|
|
}
|
|
|
// 获取共创模式
|
|
|
cooperationModeModel := new(models.CooperationMode)
|
|
|
cooperationModeQuery := tx.Model(cooperationModeModel)
|
|
|
if err := cooperationModeQuery.Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).First(); err != nil {
|
|
|
return nil, err
|
|
|
if err := cooperationModeQuery.
|
|
|
Where("company->>'companyId' = '?'", cooperationApplicationModel.Company.CompanyId).
|
|
|
Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId).
|
|
|
Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).First(); err != nil {
|
|
|
log.Logger.Error("申请关联的共创模式不存在", map[string]interface{}{
|
|
|
"cooperationApplicationModel": cooperationApplicationModel,
|
|
|
})
|
|
|
return nil, fmt.Errorf("申请关联的共创模式不存在")
|
|
|
}
|
|
|
return transform.TransformToCooperationApplicationDomainModelFromPgModels(cooperationApplicationModel, cooperationProjectModel, cooperationModeModel)
|
|
|
}
|
...
|
...
|
@@ -270,7 +283,10 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string |
|
|
Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId).
|
|
|
Where("cooperation_project_number = ?", cooperationApplicationModel.CooperationProjectNumber).
|
|
|
First(); err != nil {
|
|
|
return 0, nil, err
|
|
|
log.Logger.Error("申请关联的共创项目不存在", map[string]interface{}{
|
|
|
"cooperationApplicationModel": cooperationApplicationModel,
|
|
|
})
|
|
|
return 0, nil, fmt.Errorf("申请关联的共创项目不存在")
|
|
|
}
|
|
|
// 获取共创模式
|
|
|
cooperationModeModel := new(models.CooperationMode)
|
...
|
...
|
@@ -280,7 +296,10 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string |
|
|
Where("org->>'orgId' = '?'", cooperationApplicationModel.Org.OrgId).
|
|
|
Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).
|
|
|
First(); err != nil {
|
|
|
return 0, nil, err
|
|
|
log.Logger.Error("申请关联的共创模式不存在", map[string]interface{}{
|
|
|
"cooperationApplicationModel": cooperationApplicationModel,
|
|
|
})
|
|
|
return 0, nil, fmt.Errorf("申请关联的共创模式不存在")
|
|
|
}
|
|
|
if cooperationApplication, err := transform.TransformToCooperationApplicationDomainModelFromPgModels(cooperationApplicationModel, cooperationProjectModel, cooperationModeModel); err != nil {
|
|
|
return 0, cooperationApplications, err
|
...
|
...
|
|