/*
 * @description:
 * @Author: CP
 * @Date: 2021-06-01 15:13:16
 * @FilePath: \construction_management\web\viewmodels\group.go
 */
package viewmodels

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

// type Permission2 struct {
// 	name map[string]interface{}
// }

type Group struct {
	Id         string   `form:"id" json:"id" `
	Name       string   `form:"name" json:"name" `
	Remark     string   `form:"remark" json:"remark" `
	Permission []string `form:"permission" json:"permission" `

	CreateTime string `form:"createTime" json:"createTime" `
}

func (l Group) ValidateAdd() error {
	return validation.ValidateStruct(&l,
		validation.Field(&l.Name, validation.Required.Error("名称不能为空")),
	)
}

func (l Group) ValidateUpdate() error {
	return validation.ValidateStruct(&l,
		validation.Field(&l.Name, validation.Required.Error("名称不能为空")),
		validation.Field(&l.Id, validation.Required.Error("ID不能为空")),
	)
}

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