cooperation_user_update.go 1.2 KB
package command

import (
	"fmt"

	"github.com/beego/beego/v2/core/validation"
)

type CooperationUserUpdateCommand struct {
	// 用户编号
	UsersId int64 `json:"usersId" valid:"Required"`
	// 用户编号
	UsersCode string `json:"usersCode" valid:"Required"`
	// 用户姓名
	UsersName string `json:"usersName" valid:"Required"`
	// 共创公司
	CooperationCompany string `json:"cooperationCompany" valid:"Required"`
	// 共创公司到期时间
	CooperationDeadline string `json:"cooperationDeadline" valid:"Required"`
	// 启用状态(启用:1 禁用:2)
	EnableStatus int `json:"enableStatus" valid:"Required"`
	// 邮箱
	Email string `json:"email" valid:"Required"`
}

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

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