/*
 * @description:
 * @Author: CP
 * @Date: 2021-12-25 15:06:19
 * @FilePath: \construction_management\web\viewmodels\jl.go
 */
package viewmodels

import (

	// jwtmiddleware "github.com/iris-contrib/middleware/jwt"

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

type Jl struct {
	Token      string `form:"token" json:"token" `
	Code       string `form:"code" json:"code" `
	Account    string `form:"account" json:"account" `
	NewAccount string `form:"newAccount" json:"newAccount" `
	// 计量-报表使用
	// 存的是表名key
	Key          []string `form:"key" json:"key" `
	BidsectionId []string `form:"bidsectionId" json:"bidsectionId" `
}

// 校验项目接口
func (l Jl) ValidateToken() error {
	return validation.ValidateStruct(&l,
		validation.Field(&l.Token, validation.Required.Error("token不能为空")),
	)
}

// 校验项目接口
func (l Jl) ValidateCodeAToken() error {
	return validation.ValidateStruct(&l,
		validation.Field(&l.Code, validation.Required.Error("项目编号不能为空")),
		validation.Field(&l.Token, validation.Required.Error("token不能为空")),
	)
}

// 校验项目接口
func (l Jl) ValidateCode() error {
	return validation.ValidateStruct(&l,
		validation.Field(&l.Code, validation.Required.Error("项目编号不能为空")),
	)
}

// 验证检验项目
func (l Jl) ValidateParameter() error {
	return validation.ValidateStruct(&l,
		validation.Field(&l.Code, validation.Required.Error("项目编号不能为空")),
	)
}

// 添加项目和账号验证
func (l Jl) ValidateProjectAdd() error {
	return validation.ValidateStruct(&l,
		validation.Field(&l.Code, validation.Required.Error("项目编号不能为空")),
		validation.Field(&l.Account, validation.Required.Error("账号不能为空")),
	)
}

// 添加项目和账号验证
func (l Jl) ValidateAccountUpdate() error {
	return validation.ValidateStruct(&l,
		validation.Field(&l.Code, validation.Required.Error("项目编号不能为空")),
		validation.Field(&l.Account, validation.Required.Error("账号不能为空")),
		validation.Field(&l.NewAccount, validation.Required.Error("修改账号不能为空")),
	)
}
