/*
 * @description: 管理员 视图
 * @Author: CP
 * @Date: 2020-11-11 11:19:30
 * @FilePath: \construction_management\web\viewmodels\manager.go
 */
package viewmodels

import validation "github.com/go-ozzo/ozzo-validation/v3"

type Manager struct {
	Id        string `form:"id" json:"id" `
	Username  string `form:"username" json:"username" `
	LastLogin string `form:"lastLogin" json:"lastLogin" `
	GroupId   int    `form:"groupId" json:"groupId" `
	RealName  string `form:"realName" json:"realName" `
	Telephone string `form:"telephone" json:"telephone" `
	LoginIp   string `form:"loginIp" json:"loginIp" `
	// Token      string `form:"token" json:"token" `
	CanLogin   int    `form:"canLogin" json:"canLogin" `
	Office     string `form:"office" json:"office" `
	Category   string `form:"category" json:"category" `
	Email      string `form:"email" json:"email" `
	Qq         string `form:"qq" json:"qq" `
	Fixedphone string `form:"fixedphone" json:"fixedphone" `
	Position   string `form:"position" json:"position" `
	Avatar     string `form:"avatar" json:"avatar" `
	CreateTime string `form:"createTime" json:"createTime" `
	// UpdateTime string  `form:"updateTime" json:"updateTime" `

}

// 验证方法
func (l Manager) ValidateGet() error {
	return validation.ValidateStruct(&l,
		validation.Field(&l.Id, validation.Required.Error("ID不能为空")),
	)
}

func (l Manager) ValidateEnable() error {
	return validation.ValidateStruct(&l,
		validation.Field(&l.Id, validation.Required.Error("ID不能为空")),
		validation.Field(&l.CanLogin, validation.In(0, 1).Error("未找到相关请求类型")),
	)
}
