作者 陈志颖

fix:修复同一个用户多次申请同一个项目

... ... @@ -113,7 +113,9 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
// 校验:同一个用户,不能多次申请同一个项目
applicationExist, _ := cooperationApplicationDao.CheckApplicationExist(map[string]interface{}{
"visitorUserBaseId": applicant.UserBaseId,
"cooperationApplicationId": cooperationProject.CooperationProjectId,
"companyId": cooperationProject.Company.CompanyId,
"orgId": cooperationProject.Org.OrgId,
"cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
})
if applicationExist {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "抱歉,您已经申请过该项目")
... ... @@ -173,7 +175,7 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
"companyId": applyForCooperationCommand.CompanyId,
"orgId": applyForCooperationCommand.OrgId,
"applicantId": applicant.UserId,
"cooperationApplicationId": cooperationProject.CooperationProjectId,
"cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
})
if applicationExist {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "抱歉,您已经申请过该项目")
... ...
... ... @@ -15,8 +15,8 @@ func (dao *CooperationApplicationDao) CheckApplicationExist(queryOptions map[str
tx := dao.transactionContext.PgTx
var cooperationApplicationModels []*models.CooperationApplication
query := tx.Model(&cooperationApplicationModels)
if cooperationApplicationId, ok := queryOptions["cooperationApplicationId"]; ok && cooperationApplicationId != "" {
query = query.Where("cooperation_application_id = ?", cooperationApplicationId)
if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
query = query.Where("cooperation_project_number = ?", cooperationProjectNumber)
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query = query.Where(`cooperation_application.company @> '{"companyId":"?"}'`, companyId)
... ...
... ... @@ -239,7 +239,7 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
if applicantName, ok := queryOptions["applicantName"]; ok && applicantName != "" {
query.Where(`(cooperation_application.cooperation_application_applicant->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", applicantName))
}
if cooperationApplicationStatus, ok := queryOptions["cooperationApplicationStatus"]; ok && cooperationApplicationStatus.(int32) != 0 {
if cooperationApplicationStatus, ok := queryOptions["cooperationApplicationStatus"]; ok && cooperationApplicationStatus.(int) != 0 {
query.Where("cooperation_application_status = ?", cooperationApplicationStatus)
}
if cooperationApplicationIds, ok := queryOptions["cooperationApplicationIds"]; ok && len(cooperationApplicationIds.([]int64)) > 0 {
... ...