审查视图

pkg/application/evaluation_project/command/project_update.go 2.1 KB
郑周 authored
1 2 3 4
package command

import (
	"github.com/beego/beego/v2/core/validation"
郑周 authored
5
	"time"
郑周 authored
6 7 8 9 10 11 12
)

type UpdateProjectCommand struct {
	CompanyId int64    `cname:"公司ID" json:"companyId"`
	CycleId   int64    `cname:"周期ID" json:"cycleId,string" valid:"Required"`
	Id        int64    `cname:"项目ID" json:"id,string" valid:"Required"`
	Name      string   `cname:"项目名称" json:"name" valid:"Required"`
郑周 authored
13
	Describe  string   `cname:"项目描述" json:"describe"`
郑周 authored
14 15
	HrBp      int      `cname:"HR角色权限" json:"hrBp"`
	Pmp       int      `cname:"PM角色权限" json:"pmp"`
郑周 authored
16
	PmpIds    []string `cname:"项目管理员ID"  json:"pmpIds"`
郑周 authored
17 18 19
}

type UpdateProjectTemplateCommand struct {
郑周 authored
20 21 22 23 24 25 26 27 28 29 30 31 32
	CompanyId      int64      `cname:"公司ID" json:"companyId"`
	CycleId        int64      `cname:"周期ID" json:"cycleId,string" valid:"Required"`
	Id             int64      `cname:"项目ID" json:"id,string" valid:"Required"`
	TemplateId     int64      `cname:"模板ID" json:"templateId,string"`
	Recipients     []string   `cname:"被评估人ID"  json:"recipients"`
	TimeStart      *time.Time `cname:"自评起始时间" json:"timeStart" valid:"Required"`
	TimeEnd        *time.Time `cname:"自评截止时间" json:"timeEnd" valid:"Required"`
	KpiCycle       int        `cname:"评估周期" json:"kpiCycle" valid:"Required"`
	KpiResultStart *time.Time `cname:"绩效结果开始查看时间" json:"kpiResultStart"`
	Activate       int        `cname:"启动项目" json:"activate"`
}

type CheckRecipientCommand struct {
郑周 authored
33 34 35 36 37 38 39 40
	CompanyId  int64    `cname:"公司ID" json:"companyId"`
	CycleId    int64    `cname:"周期ID" json:"cycleId,string" valid:"Required"`
	Id         int64    `cname:"项目ID" json:"id,string" valid:"Required"`
	Recipients []string `cname:"被评估人ID"  json:"recipients"`
}

func (in *UpdateProjectCommand) Valid(validation *validation.Validation) {
	if len(in.Name) > 40 {
郑周 authored
41
		validation.SetError("name", "项目名称最大长度40个字符")
郑周 authored
42 43 44 45 46 47
		return
	}
}

func (in *UpdateProjectTemplateCommand) Valid(validation *validation.Validation) {
	if len(in.Recipients) == 0 {
48
		validation.SetError("recipients", "请添加被评估人")
郑周 authored
49 50 51
		return
	}
}