release_cooperation_project.go 1.9 KB
package command

import (
	"fmt"

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

type ReleaseCooperationProjectCommand struct {
	//操作人
	Operator domain.Operator `json:"-"`
	// 共创项目名称
	CooperationProjectName string `json:"cooperationProjectName" valid:"Required"`
	// 共创模式ID
	CooperationModeId int64 `json:"cooperationModeId" valid:"Required"`
	// 手机号码
	Phone string `json:"phone" valid:"Required"`
	// 共创模式状态,1启用,2禁用
	Status int32 `json:"status" valid:"Required"`
	// 用户编号
	UsersCode string `json:"usersCode" valid:"Required"`
	// 用户编号
	UsersId int64 `json:"usersId" valid:"Required"`
	// 用户姓名
	UsersName string `json:"usersName" valid:"Required"`
	// 邮箱
	Email string `json:"email" valid:"Required"`
	// 共创公司
	CooperationCompany string `json:"cooperationCompany" valid:"Required"`
	// 共创公司到期时间
	CooperationDeadline string `json:"cooperationDeadline" valid:"Required"`
	// 共创项目承接对象,1员工,2共创用户,3公开,可以多选
	CooperationProjectUndertakerType []int32 `json:"cooperationProjectUndertakerType" valid:"Required"`
	// 共创项目描述
	CooperationProjectDescription string `json:"cooperationProjectDescription" valid:"Required"`
}

func (releaseCooperationProjectCommand *ReleaseCooperationProjectCommand) Valid(validation *validation.Validation) {
	validation.SetError("CustomValid", "未实现的自定义认证")
}

func (releaseCooperationProjectCommand *ReleaseCooperationProjectCommand) ValidateCommand() error {
	valid := validation.Validation{}
	b, err := valid.Valid(releaseCooperationProjectCommand)
	if err != nil {
		return err
	}
	if !b {
		for _, validErr := range valid.Errors {
			return fmt.Errorf("%s  %s", validErr.Key, validErr.Message)
		}
	}
	return nil
}