project_create.go
975 字节
package command
import (
"github.com/beego/beego/v2/core/validation"
)
type CreateProjectCommand struct {
CompanyId int64 `cname:"公司ID" json:"companyId"`
CreatorId int64 `cname:"创建人ID" json:"creatorId"`
CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"`
Name string `cname:"项目名称" json:"name" valid:"Required"`
Describe string `cname:"项目描述" json:"describe"`
HrBp int `cname:"HR角色权限" json:"hrBp"`
Pmp int `cname:"PM角色权限" json:"pmp"`
PmpIds []string `cname:"项目管理员ID" json:"pmpIds"`
}
func (in *CreateProjectCommand) 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
}
}