作者 yangfu

模板删除修改

@@ -505,6 +505,7 @@ func TemplateDelete(uid, companyId int64, request *protocol.TemplateDeleteReques @@ -505,6 +505,7 @@ func TemplateDelete(uid, companyId int64, request *protocol.TemplateDeleteReques
505 template *models.AuditTemplate 505 template *models.AuditTemplate
506 num int 506 num int
507 sql1 string = `select count(0) from chance where audit_template_id = ? limit 1` 507 sql1 string = `select count(0) from chance where audit_template_id = ? limit 1`
  508 + sql2 string = `select count(0) from achievement where chance_type_id = ? and status in (1,2)`
508 ) 509 )
509 if template, err = models.GetAuditTemplateById(int64(request.TemplateId)); err != nil { 510 if template, err = models.GetAuditTemplateById(int64(request.TemplateId)); err != nil {
510 log.Error(err.Error()) 511 log.Error(err.Error())
@@ -519,6 +520,11 @@ func TemplateDelete(uid, companyId int64, request *protocol.TemplateDeleteReques @@ -519,6 +520,11 @@ func TemplateDelete(uid, companyId int64, request *protocol.TemplateDeleteReques
519 err = protocol.NewErrWithMessage("10062") 520 err = protocol.NewErrWithMessage("10062")
520 return 521 return
521 } 522 }
  523 + //3.判断是否有对应发布的成果
  524 + if err = utils.ExecuteQueryOne(&num, sql2, request.TemplateId); err == nil && num > 0 {
  525 + err = protocol.NewErrWithMessage("10062")
  526 + return
  527 + }
522 528
523 //删除数据 529 //删除数据
524 if err = models.DeleteAuditTemplate(int64(request.TemplateId)); err != nil { 530 if err = models.DeleteAuditTemplate(int64(request.TemplateId)); err != nil {
@@ -643,6 +649,7 @@ func TemplateDeleteCategory(uid, companyId int64, request *protocol.TemplateDele @@ -643,6 +649,7 @@ func TemplateDeleteCategory(uid, companyId int64, request *protocol.TemplateDele
643 num int 649 num int
644 sql1 string = `select count(0) from audit_template where chance_type_id =? limit 1` 650 sql1 string = `select count(0) from audit_template where chance_type_id =? limit 1`
645 sql2 string = `select count(0) from chance where chance_type_id = ? limit 1` 651 sql2 string = `select count(0) from chance where chance_type_id = ? limit 1`
  652 + sql3 string = `select count(0) from achievement where chance_type_id = ? and status in (1,2)`
646 ) 653 )
647 rsp = &protocol.TemplateDeleteCategoryResponse{} 654 rsp = &protocol.TemplateDeleteCategoryResponse{}
648 if chanceType, err = models.GetChanceTypeById(request.ChanceTypeId); err != nil { 655 if chanceType, err = models.GetChanceTypeById(request.ChanceTypeId); err != nil {
@@ -667,6 +674,11 @@ func TemplateDeleteCategory(uid, companyId int64, request *protocol.TemplateDele @@ -667,6 +674,11 @@ func TemplateDeleteCategory(uid, companyId int64, request *protocol.TemplateDele
667 err = protocol.NewErrWithMessage("10062") 674 err = protocol.NewErrWithMessage("10062")
668 return 675 return
669 } 676 }
  677 + //3.判断是否有对应发布的成果
  678 + if err = utils.ExecuteQueryOne(&num, sql3, request.ChanceTypeId); err == nil && num > 0 {
  679 + err = protocol.NewErrWithMessage("10062")
  680 + return
  681 + }
670 682
671 //删除数据 683 //删除数据
672 if err = models.DeleteChanceType(request.ChanceTypeId); err != nil { 684 if err = models.DeleteChanceType(request.ChanceTypeId); err != nil {