作者 陈志颖

fix:共创申请审核问题修复

... ... @@ -13,20 +13,16 @@ type ApplyForCooperationCommand struct {
CooperationApplicationAttachment []*domain.Attachment `cname:"共创申请描述附件" json:"cooperationApplicationAttachment" valid:"Required"`
// 共创申请描述
CooperationApplicationDescription string `cname:"共创申请描述" json:"cooperationApplicationDescription,omitempty"`
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `cname:"用户ID" json:"userId" valid:"Required"`
// 申请人ID
UserId int64 `cname:"申请人ID" json:"userId" valid:"Required"`
// 用户基本id
UserBaseId int64 `cname:"用户基本数据ID" json:"userBaseId" valid:"Required"`
// 组织机构ID
OrgId int64 `cname:"组织机构ID" json:"orgId" valid:"Required"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"`
// 部门ID,通过REST集成上下文获取
DepartmentId int64 `cname:"部门ID" json:"departmentId" valid:"Required"`
// 共创申请ID
CooperationApplicationId string `cname:"共创申请ID" json:"cooperationApplicationId" valid:"Required"`
// 共创项目编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001
CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber" valid:"Required"`
// 共创项目ID
CooperationProjectId int64 `cname:"共创项目ID" json:"cooperationProjectId" valid:"Required"`
}
func (applyForCooperationCommand *ApplyForCooperationCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -10,7 +10,7 @@ import (
type ApprovalCooperationApplicationCommand struct {
// 共创申请ID
CooperationApplicationId int64 `cname:"共创申请ID" json:"cooperationApplicationId" valid:"Required"`
CooperationApplicationId string `cname:"共创申请ID" json:"cooperationApplicationId" valid:"Required"`
// 共创申请审核描述
CooperationApplicationVerifyDescription string `cname:"共创申请审核描述" json:"cooperationApplicationVerifyDescription,omitempty"`
// 公司ID,通过集成REST上下文获取
... ...
... ... @@ -11,7 +11,7 @@ import (
type UpdateCooperationApplicationCommand struct {
// 共创申请id
CooperationApplicationId string `cname:"共创申请ID" json:"cooperationApplicationId" valid:"Required"`
CooperationApplicationId int64 `cname:"共创申请ID" json:"cooperationApplicationId" valid:"Required"`
// 共创申请人uid
ApplicantUid string `cname:"共创申请人UID" json:"applicantUid" valid:"Required"`
// 共创申请描述
... ...
... ... @@ -33,6 +33,8 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 共创项目仓储初始化
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -41,12 +43,14 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
} else {
cooperationProjectRepository = value
}
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectNumber": applyForCooperationCommand.CooperationProjectNumber})
// 获取共创项目
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": applyForCooperationCommand.CooperationProjectId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationProject == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", applyForCooperationCommand.CooperationProjectNumber))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(applyForCooperationCommand.CooperationProjectId, 10)))
}
// 用户REST服务初始化
... ... @@ -156,12 +160,16 @@ func (cooperationApplicationService *CooperationApplicationService) ApprovalCoop
} else {
cooperationApplicationRepository = value
}
cooperationApplicationId, err := strconv.ParseInt(approvalCooperationApplicationCommand.CooperationApplicationId, 10, 64)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创申请ID类型错误")
}
cooperationApplication, err := cooperationApplicationRepository.FindOne(map[string]interface{}{"cooperationApplicationId": approvalCooperationApplicationCommand.CooperationApplicationId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationApplication == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(approvalCooperationApplicationCommand.CooperationApplicationId, 10)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationApplicationId, 10)))
}
if err := cooperationApplication.Update(tool_funs.SimpleStructToMap(approvalCooperationApplicationCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ...
... ... @@ -19,6 +19,8 @@ func (controller *CooperationApplicationController) ApplyForCooperation() {
applyForCooperationCommand.OrgId = header.OrgId
applyForCooperationCommand.UserId = header.UserId
applyForCooperationCommand.UserBaseId = header.UserBaseId
cooperationProjectId, _ := controller.GetInt64(":cooperationProjectId")
applyForCooperationCommand.CooperationProjectId = cooperationProjectId
data, err := cooperationApplicationService.ApplyForCooperation(applyForCooperationCommand)
controller.Response(data, err)
}
... ... @@ -97,7 +99,7 @@ func (controller *CooperationApplicationController) UpdateCooperationApplication
updateCooperationApplicationCommand.OrgId = header.OrgId
updateCooperationApplicationCommand.UserId = header.UserId
updateCooperationApplicationCommand.UserBaseId = header.UserBaseId
cooperationApplicationId := controller.GetString(":cooperationApplicationId")
cooperationApplicationId, _ := controller.GetInt64(":cooperationApplicationId")
updateCooperationApplicationCommand.CooperationApplicationId = cooperationApplicationId
data, err := cooperationApplicationService.UpdateCooperationApplication(updateCooperationApplicationCommand)
controller.Response(data, err)
... ...
... ... @@ -6,12 +6,12 @@ import (
)
func init() {
web.Router("/cooperation-applications/apply-for-cooperation", &controllers.CooperationApplicationController{}, "Post:ApplyForCooperation") // 申请共创
web.Router("/cooperation-applications/:cooperationProjectId/apply-for-cooperation", &controllers.CooperationApplicationController{}, "Post:ApplyForCooperation") // 申请共创
web.Router("/cooperation-applications/cancel-application", &controllers.CooperationApplicationController{}, "Post:CancelCooperationApplication") // 取消共创申请
web.Router("/cooperation-applications/approval-cooperation-application", &controllers.CooperationApplicationController{}, "Post:ApprovalCooperationApplication") // 同意共创申请
web.Router("/cooperation-applications/batch-approval", &controllers.CooperationContractController{}, "Post:BatchApprovalCooperationApplication") // 批量审核共创申请
web.Router("/cooperation-applications/oneclick-approval", &controllers.CooperationApplicationController{}, "Post:OneClickApprovalCooperationApplication") // 一键审核共创申请
web.Router("/cooperation-applications/", &controllers.CooperationApplicationController{}, "Post:CreateCooperationApplication") // 新增共创申请
web.Router("/cooperation-applications/", &controllers.CooperationApplicationController{}, "Post:CreateCooperationApplication") // 新增共创申请(预留)
web.Router("/cooperation-applications/:cooperationApplicationId", &controllers.CooperationApplicationController{}, "Put:UpdateCooperationApplication") // 编辑共创申请
web.Router("/cooperation-applications/:cooperationApplicationId", &controllers.CooperationApplicationController{}, "Get:GetCooperationApplication") // 获取共创申请详情
web.Router("/cooperation-applications/:cooperationApplicationId", &controllers.CooperationApplicationController{}, "Delete:RemoveCooperationApplication") // 移除共创申请
... ...