|
@@ -21,12 +21,14 @@ type SafeAuditService interface {
|
|
|
AddAuditor(safeId int, bId int, auditId int, times int) error
|
|
|
CloseAudit(id int, opinion string, curUid int, saveId int) error
|
|
|
BackAudit(id int, opinion string, curUid int, saveId int, auditId int, progress string) error
|
|
|
+ PassAudit(id int, uid int, auditId int, opinion string) error
|
|
|
}
|
|
|
|
|
|
type safeAuditService struct {
|
|
|
- validaAdd string
|
|
|
- validaClose string
|
|
|
- validaBack string
|
|
|
+ validAdd string
|
|
|
+ validPass string
|
|
|
+ validClose string
|
|
|
+ validBack string
|
|
|
daoSafeAudit *dao.SafeAuditDao
|
|
|
daoSafe *dao.SafeDao
|
|
|
}
|
|
@@ -34,9 +36,10 @@ type safeAuditService struct {
|
|
|
//创建项目用户service
|
|
|
func NewSafeAuditService() SafeAuditService {
|
|
|
return &safeAuditService{
|
|
|
- validaBack: "/api/safe_audit/back",
|
|
|
- validaAdd: "/api/safe_audit/add",
|
|
|
- validaClose: "/api/safe_audit/close",
|
|
|
+ validBack: "/api/safe_audit/back",
|
|
|
+ validAdd: "/api/safe_audit/add",
|
|
|
+ validClose: "/api/safe_audit/close",
|
|
|
+ validPass: "/api/safe_audit/pass",
|
|
|
daoSafeAudit: dao.NewSafeAuditDao(datasource.InstanceDbMaster()),
|
|
|
daoSafe: dao.NewSafeDao(datasource.InstanceDbMaster()),
|
|
|
}
|
|
@@ -103,6 +106,34 @@ func (s *safeAuditService) BackAudit(id int, opinion string, curUid int, saveId
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
+// 审批通过
|
|
|
+func (s *safeAuditService) PassAudit(id int, uid int, auditId int, opinion string) error {
|
|
|
+ auditor, err := s.daoSafeAudit.FindById(id)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if auditor.AuditId != uid {
|
|
|
+ return errors.New("该用户没有审批权限!")
|
|
|
+ }
|
|
|
+ if auditId != 0 {
|
|
|
+ // 审批人选择了整改人
|
|
|
+ err := s.daoSafeAudit.ChangeStatusById(auditor.Id, "", 1)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ err = s.daoSafeAudit.AddCheckWorker(id, auditId, opinion)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ err := s.daoSafeAudit.ChangeStatusById(auditor.Id, "", 1)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
// 规则校验
|
|
|
func (s *safeAuditService) ValidRule(ctx iris.Context) (viewmodels.SafeAudit, error) {
|
|
|
safeAuditVaild := viewmodels.SafeAudit{}
|
|
@@ -112,15 +143,18 @@ func (s *safeAuditService) ValidRule(ctx iris.Context) (viewmodels.SafeAudit, er
|
|
|
log.Println("safe-ValidRule-ReadJson转换异常, error=", err)
|
|
|
return safeAuditVaild, err
|
|
|
}
|
|
|
- if ctx.Path() == s.validaAdd {
|
|
|
+ if ctx.Path() == s.validAdd {
|
|
|
err = safeAuditVaild.ValidateAddAuditor()
|
|
|
return safeAuditVaild, err
|
|
|
- } else if ctx.Path() == s.validaClose {
|
|
|
+ } else if ctx.Path() == s.validClose {
|
|
|
err = safeAuditVaild.ValidateClose()
|
|
|
return safeAuditVaild, err
|
|
|
- } else if ctx.Path() == s.validaBack {
|
|
|
+ } else if ctx.Path() == s.validBack {
|
|
|
err = safeAuditVaild.ValidateBack()
|
|
|
return safeAuditVaild, err
|
|
|
+ } else if ctx.Path() == s.validPass {
|
|
|
+ err = safeAuditVaild.ValidatePass()
|
|
|
+ return safeAuditVaild, err
|
|
|
}
|
|
|
return safeAuditVaild, err
|
|
|
}
|