...
|
...
|
@@ -5,10 +5,12 @@ import ( |
|
|
"github.com/linmadan/egglib-go/core/application"
|
|
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/command"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/dto"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/query"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
)
|
...
|
...
|
@@ -134,8 +136,31 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro |
|
|
if cooperationMode == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationProjectCommand.CooperationModeNumber))
|
|
|
} else {
|
|
|
// 共创项目DAO初始化
|
|
|
var cooperationProjectDao *dao.CooperationProjectDao
|
|
|
if value, err := factory.CreateCooperationProjectDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
} else {
|
|
|
cooperationProjectDao = value
|
|
|
}
|
|
|
// 生成共创项目编号
|
|
|
projectNumber, err2 := cooperationProjectDao.GenerateProjectNumber()
|
|
|
if err2 != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
// 校验共创项目编号是否唯一
|
|
|
numberAvailable, _ := cooperationProjectDao.CheckProjectNumberAvailable(map[string]interface{}{
|
|
|
"companyId": createCooperationProjectCommand.CompanyId,
|
|
|
"orgId": createCooperationProjectCommand.OrgId,
|
|
|
"cooperationProjectNumber": projectNumber,
|
|
|
})
|
|
|
if !numberAvailable {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "共创项目编码已存在")
|
|
|
}
|
|
|
newCooperationProject := &domain.CooperationProject{
|
|
|
CooperationProjectNumber: createCooperationProjectCommand.CooperationModeNumber,
|
|
|
CooperationProjectNumber: projectNumber,
|
|
|
CooperationProjectName: createCooperationProjectCommand.CooperationProjectName,
|
|
|
CooperationProjectUndertakerTypes: createCooperationProjectCommand.CooperationProjectUndertakerTypes,
|
|
|
CooperationProjectSponsor: sponsor,
|
...
|
...
|
@@ -202,6 +227,27 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec |
|
|
if cooperationProject == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationProjectQuery.CooperationProjectId, 10)))
|
|
|
} else {
|
|
|
// 共创项目DAO初始化
|
|
|
var cooperationProjectDao *dao.CooperationProjectDao
|
|
|
if value, err := factory.CreateCooperationProjectDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
} else {
|
|
|
cooperationProjectDao = value
|
|
|
}
|
|
|
//TODO 获取可删除的承接对象类型
|
|
|
undertakerTypesUncheckedAvailable, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
|
|
|
"cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
|
|
|
"cooperationProjectUndertakerTypes": cooperationProject.CooperationProjectUndertakerTypes,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
cooperationProjectDto := &dto.CooperationProjectsDto{}
|
|
|
if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
|