cooperation_user_add.go 1.2 KB
package command

import (
	"fmt"

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

type CooperationUserAddCommand struct {
	//操作人
	Operator domain.Operator `json:"-"`
	// 用户编号
	UsersCode string `json:"userCode" valid:"Required"`
	// 用户姓名
	UsersName string `json:"userName" valid:"Required"`
	// 共创公司
	CooperationCompany string `json:"cooperationCompany" valid:"Required"`
	// 共创公司到期时间
	CooperationDeadline int64 `json:"cooperationDeadline" valid:"Required"`
	// 启用状态(启用:1 禁用:2)
	EnableStatus int `json:"enableStatus" valid:"Required"`
	// 邮箱
	Email string `json:"email" valid:"Required"`
	//头像
	Avatar string `json:"avatar"`
	Phone  string `json:"phone" valid:"Required"`
}

func (cooperationUserAddCommand *CooperationUserAddCommand) Valid(validation *validation.Validation) {

}

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