template_update.go 1.1 KB
package command

import (
	"github.com/beego/beego/v2/core/validation"
	"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)

type UpdateTemplateCommand struct {
	Id        int64             `cname:"模板ID" json:"id,string" valid:"Required"`
	CompanyId int64             `cname:"公司ID" json:"companyId"`
	CreatorId int64             `cname:"创建人ID" json:"creatorId"`
	Name      string            `cname:"模板名称" json:"name" valid:"Required"`
	Describe  string            `cname:"模板描述" json:"remark"`
	LinkNodes []domain.LinkNode `cname:"评估流程" json:"linkNodes"`
}

func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) {
	if in.CompanyId == 0 {
		validation.SetError("companyId", "公司ID无效")
		return
	}
	if in.CreatorId == 0 {
		validation.SetError("creatorId", "创建人ID无效")
		return
	}

	if len(in.Name) > 40 {
		validation.SetError("name", "模板名称最大长度40个字符")
		return
	}

	if len(in.LinkNodes) == 0 {
		validation.SetError("linkNodes", "评估模板流程不能为空")
		return
	}

}