|
@@ -682,3 +682,90 @@ func CategoryEditSort(uid, companyId int64, request *protocol.CategoryEditSortRe |
|
@@ -682,3 +682,90 @@ func CategoryEditSort(uid, companyId int64, request *protocol.CategoryEditSortRe |
682
|
rsp = &protocol.CategoryEditSortResponse{}
|
682
|
rsp = &protocol.CategoryEditSortResponse{}
|
683
|
return
|
683
|
return
|
684
|
}
|
684
|
}
|
|
|
685
|
+
|
|
|
686
|
+//验证模板配置
|
|
|
687
|
+func ValidAuditFlowConfig(flowConfig protocol.AuditFlowConfig) (msg *protocol.ResponseMessage) {
|
|
|
688
|
+ var (
|
|
|
689
|
+ count int
|
|
|
690
|
+ specailUser map[int]int
|
|
|
691
|
+ )
|
|
|
692
|
+ msg = protocol.NewMessage("0")
|
|
|
693
|
+ for i := range flowConfig.ProcessConfig {
|
|
|
694
|
+ config := flowConfig.ProcessConfig[i]
|
|
|
695
|
+ if !(config.ApproveType == models.AuditByDepartmentor || config.ApproveType == models.AuditByUser || config.ApproveType == models.AuditByRole) {
|
|
|
696
|
+ msg = protocol.BadRequestParam("10171")
|
|
|
697
|
+ return
|
|
|
698
|
+ }
|
|
|
699
|
+ if !(config.AcitonType == models.ActionTypeOr || config.AcitonType == models.ActionTypeAnd) {
|
|
|
700
|
+ msg = protocol.BadRequestParam("10172")
|
|
|
701
|
+ return
|
|
|
702
|
+ }
|
|
|
703
|
+ if config.ApproveType == models.AuditByUser {
|
|
|
704
|
+ if len(config.ToUser) == 0 {
|
|
|
705
|
+ msg = protocol.BadRequestParam("10170")
|
|
|
706
|
+ return
|
|
|
707
|
+ }
|
|
|
708
|
+ if len(config.ToUser) > 10 {
|
|
|
709
|
+ msg = protocol.BadRequestParam("10174")
|
|
|
710
|
+ return
|
|
|
711
|
+ }
|
|
|
712
|
+ }
|
|
|
713
|
+ if config.ApproveType == models.AuditByRole {
|
|
|
714
|
+ if len(config.ToRole) == 0 {
|
|
|
715
|
+ msg = protocol.BadRequestParam("10173")
|
|
|
716
|
+ return
|
|
|
717
|
+ }
|
|
|
718
|
+ if len(config.ToRole) > 1 {
|
|
|
719
|
+ msg = protocol.BadRequestParam("10175")
|
|
|
720
|
+ return
|
|
|
721
|
+ }
|
|
|
722
|
+ }
|
|
|
723
|
+ if config.ProcessType == models.FlowTypeNormal {
|
|
|
724
|
+ count++
|
|
|
725
|
+ if count > 1 {
|
|
|
726
|
+ msg = protocol.BadRequestParam("10176")
|
|
|
727
|
+ return
|
|
|
728
|
+ }
|
|
|
729
|
+ }
|
|
|
730
|
+ if config.ProcessType == models.FlowTypeSpecail {
|
|
|
731
|
+ if len(config.FromSpecialUser) == 0 { //特殊人为空
|
|
|
732
|
+ msg = protocol.BadRequestParam("10281")
|
|
|
733
|
+ return
|
|
|
734
|
+ }
|
|
|
735
|
+ msg = ValidProcessConfig(&config)
|
|
|
736
|
+ if msg.Errno != 0 {
|
|
|
737
|
+ return
|
|
|
738
|
+ }
|
|
|
739
|
+ for i := range config.ToUser {
|
|
|
740
|
+ u := config.ToUser[i]
|
|
|
741
|
+ if _, ok := specailUser[u.Id]; ok {
|
|
|
742
|
+ msg = protocol.BadRequestParam("10283")
|
|
|
743
|
+ return
|
|
|
744
|
+ }
|
|
|
745
|
+ }
|
|
|
746
|
+ }
|
|
|
747
|
+ }
|
|
|
748
|
+ return
|
|
|
749
|
+}
|
|
|
750
|
+
|
|
|
751
|
+//检验审核配置
|
|
|
752
|
+func ValidProcessConfig(config *protocol.ProcessConfig) (msg *protocol.ResponseMessage) {
|
|
|
753
|
+ msg = &protocol.ResponseMessage{}
|
|
|
754
|
+ switch config.ApproveType {
|
|
|
755
|
+ case models.AuditByDepartmentor:
|
|
|
756
|
+ break
|
|
|
757
|
+ case models.AuditByUser:
|
|
|
758
|
+ if len(config.ToUser) == 0 {
|
|
|
759
|
+ msg = protocol.BadRequestParam("10281")
|
|
|
760
|
+ return
|
|
|
761
|
+ }
|
|
|
762
|
+ break
|
|
|
763
|
+ case models.AuditByRole:
|
|
|
764
|
+ if len(config.ToRole) == 0 {
|
|
|
765
|
+ msg = protocol.BadRequestParam("10282")
|
|
|
766
|
+ return
|
|
|
767
|
+ }
|
|
|
768
|
+ break
|
|
|
769
|
+ }
|
|
|
770
|
+ return
|
|
|
771
|
+} |