...
|
...
|
@@ -28,15 +28,15 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs |
|
|
return
|
|
|
}
|
|
|
if len([]rune(request.Template.Code)) > 6 {
|
|
|
err = protocol.NewErrWithMessage("10065")
|
|
|
err = protocol.NewErrWithMessage("10605")
|
|
|
return
|
|
|
}
|
|
|
if _, err = models.GetAuditTemplateByCode(companyId, request.Template.Code, request.Template.ChanceTypeId); err == nil {
|
|
|
err = protocol.NewErrWithMessage("10064")
|
|
|
err = protocol.NewErrWithMessage("10604")
|
|
|
return
|
|
|
}
|
|
|
if _, err = models.GetAuditTemplateByName(companyId, request.Template.Name, request.Template.ChanceTypeId); err == nil {
|
|
|
err = protocol.NewErrWithMessage("10279")
|
|
|
err = protocol.NewErrWithMessage("10619")
|
|
|
return
|
|
|
}
|
|
|
orm := orm2.NewOrm()
|
...
|
...
|
@@ -390,7 +390,7 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques |
|
|
}
|
|
|
if template.Name != request.Template.Name {
|
|
|
if _, err = models.GetAuditTemplateByName(companyId, request.Template.Name, request.Template.ChanceTypeId); err == nil {
|
|
|
err = protocol.NewErrWithMessage("10279")
|
|
|
err = protocol.NewErrWithMessage("10619")
|
|
|
return
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -604,7 +604,7 @@ func TemplateEditVisible(uid, companyId int64, request *protocol.TemplateEditVis |
|
|
return
|
|
|
}
|
|
|
if template.CompanyId != int(companyId) {
|
|
|
err = protocol.NewErrWithMessage("10027")
|
|
|
err = protocol.NewErrWithMessage("10207")
|
|
|
log.Error("template_id:%v companyId:%v want:%v not equal.", request.Id, companyId, template.CompanyId)
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -646,7 +646,7 @@ func TemplateEditSort(uid, companyId int64, request *protocol.TemplateEditSortRe |
|
|
}
|
|
|
if template.CompanyId != int(companyId) {
|
|
|
log.Debug(fmt.Sprintf("template.companyId input:%v want:%v not equal.", companyId, template.CompanyId))
|
|
|
err = protocol.NewErrWithMessage("10027")
|
|
|
err = protocol.NewErrWithMessage("10207")
|
|
|
return
|
|
|
}
|
|
|
if item.SortNum == template.SortNum {
|
...
|
...
|
@@ -751,17 +751,17 @@ func TemplateDelete(uid, companyId int64, request *protocol.TemplateDeleteReques |
|
|
return
|
|
|
}
|
|
|
if template.CompanyId != int(companyId) {
|
|
|
err = protocol.NewErrWithMessage("10027")
|
|
|
err = protocol.NewErrWithMessage("10207")
|
|
|
return
|
|
|
}
|
|
|
//2.判断是否有对应已经发布的机会
|
|
|
if err = utils.ExecuteQueryOne(&num, sql1, request.TemplateId); err == nil && num > 0 {
|
|
|
err = protocol.NewErrWithMessage("10062")
|
|
|
err = protocol.NewErrWithMessage("10602")
|
|
|
return
|
|
|
}
|
|
|
//3.判断是否有对应发布的成果
|
|
|
if err = utils.ExecuteQueryOne(&num, sql2, request.TemplateId); err == nil && num > 0 {
|
|
|
err = protocol.NewErrWithMessage("10062")
|
|
|
err = protocol.NewErrWithMessage("10602")
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -802,13 +802,13 @@ func TemplateEditEnable(uid, companyId int64, request *protocol.TemplateEditEnab |
|
|
return
|
|
|
}
|
|
|
if template.CompanyId != int(companyId) {
|
|
|
err = protocol.NewErrWithMessage("10027")
|
|
|
err = protocol.NewErrWithMessage("10207")
|
|
|
return
|
|
|
}
|
|
|
//2.判断是否有对应已经发布的机会
|
|
|
if request.Enabled == 0 {
|
|
|
if err = utils.ExecuteQueryOne(&num, sql1, request.TemplateId); err == nil && num > 0 {
|
|
|
err = protocol.NewErrWithMessage("10063")
|
|
|
err = protocol.NewErrWithMessage("10603")
|
|
|
return
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -832,13 +832,13 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe |
|
|
return
|
|
|
}
|
|
|
if chanceType.CompanyId != int(companyId) {
|
|
|
err = protocol.NewErrWithMessage("10027")
|
|
|
err = protocol.NewErrWithMessage("10207")
|
|
|
log.Error("template_id:%v companyId:%v want:%v not equal.", request.Id, companyId, chanceType.CompanyId)
|
|
|
return
|
|
|
}
|
|
|
if chanceType.Name != request.Name {
|
|
|
if _, err = models.GetChanceTypeByName(companyId, request.Name); err == nil {
|
|
|
err = protocol.NewErrWithMessage("10271")
|
|
|
err = protocol.NewErrWithMessage("10611")
|
|
|
return
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -850,7 +850,7 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe |
|
|
return
|
|
|
}
|
|
|
if len([]rune(request.Code)) > 6 {
|
|
|
err = protocol.NewErrWithMessage("10065")
|
|
|
err = protocol.NewErrWithMessage("10605")
|
|
|
return
|
|
|
}
|
|
|
chanceType = &models.ChanceType{
|
...
|
...
|
@@ -862,11 +862,11 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe |
|
|
UpdateAt: time.Now(),
|
|
|
}
|
|
|
if _, err = models.GetChanceTypeByCode(companyId, chanceType.Code); err == nil {
|
|
|
err = protocol.NewErrWithMessage("10064")
|
|
|
err = protocol.NewErrWithMessage("10604")
|
|
|
return
|
|
|
}
|
|
|
if _, err = models.GetChanceTypeByName(companyId, chanceType.Name); err == nil {
|
|
|
err = protocol.NewErrWithMessage("10271")
|
|
|
err = protocol.NewErrWithMessage("10611")
|
|
|
return
|
|
|
}
|
|
|
if c, e := models.GetChanceTypeMaxSort(companyId); e == nil {
|
...
|
...
|
@@ -894,28 +894,28 @@ func TemplateDeleteCategory(uid, companyId int64, request *protocol.TemplateDele |
|
|
if chanceType, err = models.GetChanceTypeById(request.ChanceTypeId); err != nil {
|
|
|
log.Error(err.Error())
|
|
|
if err == orm2.ErrNoRows {
|
|
|
err = protocol.NewErrWithMessage("10067")
|
|
|
err = protocol.NewErrWithMessage("10607")
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
if chanceType.CompanyId != int(companyId) {
|
|
|
err = protocol.NewErrWithMessage("10027")
|
|
|
err = protocol.NewErrWithMessage("10207")
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//1.判断分类下面是否有模板
|
|
|
if err = utils.ExecuteQueryOne(&num, sql1, request.ChanceTypeId); err == nil && num > 0 {
|
|
|
err = protocol.NewErrWithMessage("10061")
|
|
|
err = protocol.NewErrWithMessage("10601")
|
|
|
return
|
|
|
}
|
|
|
//2.判断是否有对应已经发布的机会
|
|
|
if err = utils.ExecuteQueryOne(&num, sql2, request.ChanceTypeId); err == nil && num > 0 {
|
|
|
err = protocol.NewErrWithMessage("10062")
|
|
|
err = protocol.NewErrWithMessage("10602")
|
|
|
return
|
|
|
}
|
|
|
//3.判断是否有对应发布的成果
|
|
|
if err = utils.ExecuteQueryOne(&num, sql3, request.ChanceTypeId); err == nil && num > 0 {
|
|
|
err = protocol.NewErrWithMessage("10062")
|
|
|
err = protocol.NewErrWithMessage("10602")
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -941,7 +941,7 @@ func CategoryEditSort(uid, companyId int64, request *protocol.CategoryEditSortRe |
|
|
}
|
|
|
if template.CompanyId != int(companyId) {
|
|
|
log.Debug(fmt.Sprintf("template.companyId input:%v want:%v not equal.", companyId, template.CompanyId))
|
|
|
err = protocol.NewErrWithMessage("10027")
|
|
|
err = protocol.NewErrWithMessage("10207")
|
|
|
return
|
|
|
}
|
|
|
if item.SortNum == template.SortNum {
|
...
|
...
|
@@ -968,49 +968,49 @@ func ValidAuditFlowConfig(flowConfig protocol.AuditFlowConfig) (msg *protocol.Re |
|
|
for i := range flowConfig.ProcessConfig {
|
|
|
config := flowConfig.ProcessConfig[i]
|
|
|
if !(config.ApproveType == models.AuditByDepartmentor || config.ApproveType == models.AuditByUser || config.ApproveType == models.AuditByRole) {
|
|
|
msg = protocol.BadRequestParam("10171")
|
|
|
msg = protocol.BadRequestParam("10628")
|
|
|
return
|
|
|
}
|
|
|
if !(config.AcitonType == models.ActionTypeOr || config.AcitonType == models.ActionTypeAnd) {
|
|
|
msg = protocol.BadRequestParam("10172")
|
|
|
msg = protocol.BadRequestParam("10629")
|
|
|
return
|
|
|
}
|
|
|
if config.ApproveType == models.AuditByUser {
|
|
|
if len(config.ToUser) == 0 {
|
|
|
msg = protocol.BadRequestParam("10170")
|
|
|
msg = protocol.BadRequestParam("10627")
|
|
|
return
|
|
|
}
|
|
|
if len(config.ToUser) > 10 {
|
|
|
msg = protocol.BadRequestParam("10174")
|
|
|
msg = protocol.BadRequestParam("10631")
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
if config.ApproveType == models.AuditByRole {
|
|
|
if len(config.ToRole) == 0 {
|
|
|
msg = protocol.BadRequestParam("10173")
|
|
|
msg = protocol.BadRequestParam("10630")
|
|
|
return
|
|
|
}
|
|
|
if len(config.ToRole) > 1 {
|
|
|
msg = protocol.BadRequestParam("10175")
|
|
|
msg = protocol.BadRequestParam("10632")
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
if config.ProcessType == models.FlowTypeNormal {
|
|
|
count++
|
|
|
if count > 1 {
|
|
|
msg = protocol.BadRequestParam("10176")
|
|
|
msg = protocol.BadRequestParam("10633")
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
if config.ProcessType == models.FlowTypeSpecail {
|
|
|
if len(config.FromSpecialUser) == 0 { //特殊人为空
|
|
|
msg = protocol.BadRequestParam("10286")
|
|
|
msg = protocol.BadRequestParam("10626")
|
|
|
return
|
|
|
}
|
|
|
for i := range config.FromSpecialUser {
|
|
|
u := config.FromSpecialUser[i]
|
|
|
if _, ok := specailUser[u.Id]; ok {
|
|
|
msg = protocol.BadRequestParam("10283")
|
|
|
msg = protocol.BadRequestParam("10623")
|
|
|
return
|
|
|
} else {
|
|
|
specailUser[u.Id] = u.Id
|
...
|
...
|
@@ -1029,13 +1029,13 @@ func ValidProcessConfig(config *protocol.ProcessConfig) (msg *protocol.ResponseM |
|
|
break
|
|
|
case models.AuditByUser:
|
|
|
if len(config.ToUser) == 0 {
|
|
|
msg = protocol.BadRequestParam("10281")
|
|
|
msg = protocol.BadRequestParam("10621")
|
|
|
return
|
|
|
}
|
|
|
break
|
|
|
case models.AuditByRole:
|
|
|
if len(config.ToRole) == 0 {
|
|
|
msg = protocol.BadRequestParam("10282")
|
|
|
msg = protocol.BadRequestParam("10622")
|
|
|
return
|
|
|
}
|
|
|
break
|
...
|
...
|
@@ -1056,12 +1056,12 @@ func ValidFormList(inputs []*protocol.InputElement) (msg *protocol.ResponseMessa |
|
|
for i := range inputs {
|
|
|
input := inputs[i]
|
|
|
if len([]rune(input.Label)) > 50 {
|
|
|
msg = protocol.BadRequestParam("10273")
|
|
|
msg = protocol.BadRequestParam("10613")
|
|
|
return
|
|
|
}
|
|
|
key := fmt.Sprintf("%v-%v", input.SectionType, input.Label)
|
|
|
if _, ok := mapCheckRe[key]; ok {
|
|
|
msg = protocol.BadRequestParam("10284")
|
|
|
msg = protocol.BadRequestParam("10624")
|
|
|
return
|
|
|
} else {
|
|
|
mapCheckRe[key] = key
|
...
|
...
|
@@ -1077,11 +1077,11 @@ func ValidFormList(inputs []*protocol.InputElement) (msg *protocol.ResponseMessa |
|
|
}
|
|
|
}
|
|
|
if countBasic == 0 {
|
|
|
msg = protocol.BadRequestParam("10285")
|
|
|
msg = protocol.BadRequestParam("10625")
|
|
|
return
|
|
|
}
|
|
|
if countBasic > 10 || countExtral > 10 {
|
|
|
msg = protocol.BadRequestParam("10274")
|
|
|
msg = protocol.BadRequestParam("10614")
|
|
|
return
|
|
|
}
|
|
|
return
|
...
|
...
|
|