|
@@ -205,6 +205,11 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop |
|
@@ -205,6 +205,11 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop |
205
|
if cooperationApplication, err := cooperationApplicationRepository.Save(newCooperationApplication); err != nil {
|
205
|
if cooperationApplication, err := cooperationApplicationRepository.Save(newCooperationApplication); err != nil {
|
206
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
206
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
207
|
} else {
|
207
|
} else {
|
|
|
208
|
+ // 更新共创项目申请人计数
|
|
|
209
|
+ cooperationProject.ApplicantCount = cooperationProject.ApplicantCount + 1
|
|
|
210
|
+ if _, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
|
|
|
211
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
212
|
+ }
|
208
|
if err := transactionContext.CommitTransaction(); err != nil {
|
213
|
if err := transactionContext.CommitTransaction(); err != nil {
|
209
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
214
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
210
|
}
|
215
|
}
|
|
@@ -799,8 +804,19 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper |
|
@@ -799,8 +804,19 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper |
799
|
defer func() {
|
804
|
defer func() {
|
800
|
_ = transactionContext.RollbackTransaction()
|
805
|
_ = transactionContext.RollbackTransaction()
|
801
|
}()
|
806
|
}()
|
|
|
807
|
+
|
802
|
//TODO 校验用户菜单模块权限
|
808
|
//TODO 校验用户菜单模块权限
|
803
|
|
809
|
|
|
|
810
|
+ // 共创项目仓储初始化
|
|
|
811
|
+ var cooperationProjectRepository domain.CooperationProjectRepository
|
|
|
812
|
+ if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
|
|
|
813
|
+ "transactionContext": transactionContext,
|
|
|
814
|
+ }); err != nil {
|
|
|
815
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
816
|
+ } else {
|
|
|
817
|
+ cooperationProjectRepository = value
|
|
|
818
|
+ }
|
|
|
819
|
+
|
804
|
// 共创申请仓储初始化
|
820
|
// 共创申请仓储初始化
|
805
|
var cooperationApplicationRepository domain.CooperationApplicationRepository
|
821
|
var cooperationApplicationRepository domain.CooperationApplicationRepository
|
806
|
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
|
822
|
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
|
|
@@ -826,13 +842,26 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper |
|
@@ -826,13 +842,26 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper |
826
|
}); err != nil {
|
842
|
}); err != nil {
|
827
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
843
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
828
|
}
|
844
|
}
|
829
|
- if cooperationApplication, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil {
|
845
|
+ if cooperationApplicationSaved, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil {
|
830
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
846
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
831
|
} else {
|
847
|
} else {
|
|
|
848
|
+ // 获取共创项目
|
|
|
849
|
+ cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": cooperationApplicationSaved.CooperationProject.CooperationProjectId})
|
|
|
850
|
+ if err != nil {
|
|
|
851
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创项目不存在")
|
|
|
852
|
+ }
|
|
|
853
|
+ if cooperationProject == nil {
|
|
|
854
|
+ return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创项目%s不存在", strconv.FormatInt(cooperationApplicationSaved.CooperationProject.CooperationProjectId, 10)))
|
|
|
855
|
+ }
|
|
|
856
|
+ // 更新共创项目申请统计
|
|
|
857
|
+ cooperationProject.ApplicantCount = cooperationProject.ApplicantCount - 1
|
|
|
858
|
+ if _, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
|
|
|
859
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
860
|
+ }
|
832
|
if err := transactionContext.CommitTransaction(); err != nil {
|
861
|
if err := transactionContext.CommitTransaction(); err != nil {
|
833
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
862
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
834
|
}
|
863
|
}
|
835
|
- return cooperationApplication, nil
|
864
|
+ return cooperationApplicationSaved, nil
|
836
|
}
|
865
|
}
|
837
|
}
|
866
|
}
|
838
|
|
867
|
|