...
|
...
|
@@ -205,6 +205,11 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop |
|
|
if cooperationApplication, err := cooperationApplicationRepository.Save(newCooperationApplication); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
// 更新共创项目申请人计数
|
|
|
cooperationProject.ApplicantCount = cooperationProject.ApplicantCount + 1
|
|
|
if _, err := cooperationProjectRepository.Save(cooperationProject); 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())
|
|
|
}
|
...
|
...
|
@@ -799,8 +804,19 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper |
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
//TODO 校验用户菜单模块权限
|
|
|
|
|
|
// 共创项目仓储初始化
|
|
|
var cooperationProjectRepository domain.CooperationProjectRepository
|
|
|
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
cooperationProjectRepository = value
|
|
|
}
|
|
|
|
|
|
// 共创申请仓储初始化
|
|
|
var cooperationApplicationRepository domain.CooperationApplicationRepository
|
|
|
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
|
...
|
...
|
@@ -826,13 +842,26 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper |
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
if cooperationApplication, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil {
|
|
|
if cooperationApplicationSaved, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
// 获取共创项目
|
|
|
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": cooperationApplicationSaved.CooperationProject.CooperationProjectId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创项目不存在")
|
|
|
}
|
|
|
if cooperationProject == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创项目%s不存在", strconv.FormatInt(cooperationApplicationSaved.CooperationProject.CooperationProjectId, 10)))
|
|
|
}
|
|
|
// 更新共创项目申请统计
|
|
|
cooperationProject.ApplicantCount = cooperationProject.ApplicantCount - 1
|
|
|
if _, err := cooperationProjectRepository.Save(cooperationProject); 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())
|
|
|
}
|
|
|
return cooperationApplication, nil
|
|
|
return cooperationApplicationSaved, nil
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|