/*
 * @description: 版本号
 * @Author: CP
 * @Date: 2021-02-02 11:20:56
 * @FilePath: \construction_management\web\viewmodels\version.go
 */
package viewmodels

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

type Version struct {
	Id         string `form:"id" json:"id" `
	Name       string `form:"name" json:"name" `
	CreateTime string `form:"createTime" json:"createTime" `
	Content    string `form:"content" json:"content" `
	Page       int    `form:"page" json:"page"`
	Size       int    `form:"size" json:"size"`
}

func (l Version) ValidateAdd() error {
	return validation.ValidateStruct(&l,
		validation.Field(&l.Name, validation.Required.Error("版本号不能为空")),
		validation.Field(&l.Content, validation.Required.Error("详情不能为空")),
	)
}

func (l Version) ValidateDel() error {
	return validation.ValidateStruct(&l,
		validation.Field(&l.Id, validation.Required.Error("ID不能为空")),
	)
}

func (l Version) ValidatePage() error {
	return validation.ValidateStruct(&l,
		// 字符的4倍
		validation.Field(&l.Page, validation.Required.Error("当前页不能为空")),
		// validation.Field(&l.Size, validation.Required.Error("每页数量不能为空")),
	)
}
