1
|
package command
|
1
|
package command
|
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
|
|
4
|
+ "fmt"
|
4
|
"github.com/beego/beego/v2/core/validation"
|
5
|
"github.com/beego/beego/v2/core/validation"
|
5
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
6
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
6
|
)
|
7
|
)
|
|
@@ -33,6 +34,21 @@ func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) { |
|
@@ -33,6 +34,21 @@ func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) { |
33
|
if len(in.LinkNodes) == 0 {
|
34
|
if len(in.LinkNodes) == 0 {
|
34
|
validation.SetError("linkNodes", "评估模板流程不能为空")
|
35
|
validation.SetError("linkNodes", "评估模板流程不能为空")
|
35
|
return
|
36
|
return
|
|
|
37
|
+ } else {
|
|
|
38
|
+ for i := range in.LinkNodes {
|
|
|
39
|
+ linkNode := in.LinkNodes[i]
|
|
|
40
|
+ // 填写自评反馈,如果有评估内容时,内容权重相加 = 100%
|
|
|
41
|
+ if linkNode.Type == domain.LinkNodeSelfAssessment && len(linkNode.NodeContents) > 0 {
|
|
|
42
|
+ weightTotal := 0.0
|
|
|
43
|
+ for i2 := range linkNode.NodeContents {
|
|
|
44
|
+ weightTotal += linkNode.NodeContents[i2].Weight
|
|
|
45
|
+ }
|
|
|
46
|
+ if weightTotal != 100 {
|
|
|
47
|
+ validation.SetError("linkNodes", fmt.Sprintf("权重错误,当前%s的总权重值为:%f(必须等于100)", linkNode.Name, weightTotal))
|
|
|
48
|
+ return
|
|
|
49
|
+ }
|
|
|
50
|
+ }
|
|
|
51
|
+ }
|
36
|
}
|
52
|
}
|
37
|
|
53
|
|
38
|
} |
54
|
} |