...
|
...
|
@@ -5,6 +5,7 @@ import ( |
|
|
"github.com/beego/beego/v2/core/validation"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
|
|
|
"math"
|
|
|
)
|
|
|
|
|
|
type UpdateTemplateCommand struct {
|
...
|
...
|
@@ -34,6 +35,7 @@ func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) { |
|
|
for i2 := range linkNode.NodeContents {
|
|
|
weightTotal += linkNode.NodeContents[i2].Weight
|
|
|
}
|
|
|
weightTotal = math.Round(weightTotal*100) / 100
|
|
|
if weightTotal != 100 {
|
|
|
formatWeightTotal := utils.FormatFloatDecimal(weightTotal, 2)
|
|
|
validation.SetError("linkNodes", fmt.Sprintf("总权重值错误,当前%s的总权重值为:%s%%(必须等于100%%)", linkNode.Name, formatWeightTotal))
|
...
|
...
|
|