...
|
...
|
@@ -505,6 +505,7 @@ func TemplateDelete(uid, companyId int64, request *protocol.TemplateDeleteReques |
|
|
template *models.AuditTemplate
|
|
|
num int
|
|
|
sql1 string = `select count(0) from chance where audit_template_id = ? limit 1`
|
|
|
sql2 string = `select count(0) from achievement where chance_type_id = ? and status in (1,2)`
|
|
|
)
|
|
|
if template, err = models.GetAuditTemplateById(int64(request.TemplateId)); err != nil {
|
|
|
log.Error(err.Error())
|
...
|
...
|
@@ -519,6 +520,11 @@ func TemplateDelete(uid, companyId int64, request *protocol.TemplateDeleteReques |
|
|
err = protocol.NewErrWithMessage("10062")
|
|
|
return
|
|
|
}
|
|
|
//3.判断是否有对应发布的成果
|
|
|
if err = utils.ExecuteQueryOne(&num, sql2, request.TemplateId); err == nil && num > 0 {
|
|
|
err = protocol.NewErrWithMessage("10062")
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//删除数据
|
|
|
if err = models.DeleteAuditTemplate(int64(request.TemplateId)); err != nil {
|
...
|
...
|
@@ -643,6 +649,7 @@ func TemplateDeleteCategory(uid, companyId int64, request *protocol.TemplateDele |
|
|
num int
|
|
|
sql1 string = `select count(0) from audit_template where chance_type_id =? limit 1`
|
|
|
sql2 string = `select count(0) from chance where chance_type_id = ? limit 1`
|
|
|
sql3 string = `select count(0) from achievement where chance_type_id = ? and status in (1,2)`
|
|
|
)
|
|
|
rsp = &protocol.TemplateDeleteCategoryResponse{}
|
|
|
if chanceType, err = models.GetChanceTypeById(request.ChanceTypeId); err != nil {
|
...
|
...
|
@@ -667,6 +674,11 @@ func TemplateDeleteCategory(uid, companyId int64, request *protocol.TemplateDele |
|
|
err = protocol.NewErrWithMessage("10062")
|
|
|
return
|
|
|
}
|
|
|
//3.判断是否有对应发布的成果
|
|
|
if err = utils.ExecuteQueryOne(&num, sql3, request.ChanceTypeId); err == nil && num > 0 {
|
|
|
err = protocol.NewErrWithMessage("10062")
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//删除数据
|
|
|
if err = models.DeleteChanceType(request.ChanceTypeId); err != nil {
|
...
|
...
|
|