...
|
...
|
@@ -56,6 +56,11 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs |
|
|
CreateAt: time.Now(),
|
|
|
UpdateAt: time.Now(),
|
|
|
}
|
|
|
if t, e := models.GetAuditTemplateSort(companyId, request.Template.ChanceTypeId); e == nil {
|
|
|
template.SortNum = t.SortNum + 1
|
|
|
} else {
|
|
|
template.SortNum = 1
|
|
|
}
|
|
|
if templateId, err = orm.Insert(template); err != nil {
|
|
|
log.Error(err.Error())
|
|
|
orm.Rollback()
|
...
|
...
|
@@ -515,10 +520,18 @@ func TemplateDelete(uid, companyId int64, request *protocol.TemplateDeleteReques |
|
|
return
|
|
|
}
|
|
|
orm := orm2.NewOrm()
|
|
|
orm.Begin()
|
|
|
if err = utils.ExecuteSQLWithOrmer(orm, models.DeleteAuditFormBy, request.TemplateId, companyId); err != nil {
|
|
|
log.Error(err.Error())
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
if err = utils.ExecuteSQLWithOrmer(orm, models.DeleteAuditFlowConfigSql, request.TemplateId); err != nil {
|
|
|
log.Error(err.Error())
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
orm.Commit()
|
|
|
rsp = &protocol.TemplateDeleteResponse{}
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -605,6 +618,11 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe |
|
|
err = protocol.NewErrWithMessage("10271")
|
|
|
return
|
|
|
}
|
|
|
if c, e := models.GetChanceTypeMaxSort(companyId); e == nil {
|
|
|
chanceType.SortNum = c.SortNum + 1
|
|
|
} else {
|
|
|
chanceType.SortNum = 1
|
|
|
}
|
|
|
if _, err = models.AddChanceType(chanceType); err != nil {
|
|
|
log.Error(err.Error())
|
|
|
}
|
...
|
...
|
@@ -687,7 +705,7 @@ func CategoryEditSort(uid, companyId int64, request *protocol.CategoryEditSortRe |
|
|
func ValidAuditFlowConfig(flowConfig protocol.AuditFlowConfig) (msg *protocol.ResponseMessage) {
|
|
|
var (
|
|
|
count int
|
|
|
specailUser map[int]int
|
|
|
specailUser map[int]int = make(map[int]int)
|
|
|
)
|
|
|
msg = protocol.NewMessage("0")
|
|
|
for i := range flowConfig.ProcessConfig {
|
...
|
...
|
@@ -729,18 +747,16 @@ func ValidAuditFlowConfig(flowConfig protocol.AuditFlowConfig) (msg *protocol.Re |
|
|
}
|
|
|
if config.ProcessType == models.FlowTypeSpecail {
|
|
|
if len(config.FromSpecialUser) == 0 { //特殊人为空
|
|
|
msg = protocol.BadRequestParam("10281")
|
|
|
msg = protocol.BadRequestParam("10286")
|
|
|
return
|
|
|
}
|
|
|
msg = ValidProcessConfig(&config)
|
|
|
if msg.Errno != 0 {
|
|
|
return
|
|
|
}
|
|
|
for i := range config.ToUser {
|
|
|
u := config.ToUser[i]
|
|
|
for i := range config.FromSpecialUser {
|
|
|
u := config.FromSpecialUser[i]
|
|
|
if _, ok := specailUser[u.Id]; ok {
|
|
|
msg = protocol.BadRequestParam("10283")
|
|
|
return
|
|
|
} else {
|
|
|
specailUser[u.Id] = u.Id
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -769,3 +785,47 @@ func ValidProcessConfig(config *protocol.ProcessConfig) (msg *protocol.ResponseM |
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//校验表单
|
|
|
//名称不能超过20字
|
|
|
//表单项最低10个字段
|
|
|
//表单项不能重复
|
|
|
//基础表单项不能为空
|
|
|
func ValidFormList(inputs []*protocol.InputElement) (msg *protocol.ResponseMessage) {
|
|
|
msg = &protocol.ResponseMessage{}
|
|
|
var mapCheckRe map[string]string = make(map[string]string)
|
|
|
var countBasic, countExtral int
|
|
|
var countBasicRequire int
|
|
|
for i := range inputs {
|
|
|
input := inputs[i]
|
|
|
if len([]rune(input.Label)) > 20 {
|
|
|
msg = protocol.BadRequestParam("10273")
|
|
|
return
|
|
|
}
|
|
|
key := fmt.Sprintf("%v-%v", input.SectionType, input.Label)
|
|
|
if _, ok := mapCheckRe[key]; ok {
|
|
|
msg = protocol.BadRequestParam("10284")
|
|
|
return
|
|
|
} else {
|
|
|
mapCheckRe[key] = key
|
|
|
}
|
|
|
if input.SectionType == 1 {
|
|
|
countBasic++
|
|
|
}
|
|
|
if input.SectionType == 2 {
|
|
|
countExtral++
|
|
|
}
|
|
|
if input.SectionType == 1 && input.Required == 1 {
|
|
|
countBasicRequire++
|
|
|
}
|
|
|
}
|
|
|
if countBasic == 0 {
|
|
|
msg = protocol.BadRequestParam("10285")
|
|
|
return
|
|
|
}
|
|
|
if countBasic >= 10 || countExtral >= 10 {
|
|
|
msg = protocol.BadRequestParam("10274")
|
|
|
return
|
|
|
}
|
|
|
return
|
|
|
} |
...
|
...
|
|