/*
 * @description: 合同回款-视图
 * @Author: CP
 * @Date: 2020-11-27 14:51:44
 * @FilePath: \construction_management\web\viewmodels\contracts_return.go
 */
package viewmodels

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

type ContractsReturn struct {
	Id           string `form:"id" json:"id" `
	ContractsId  string `form:"contractsId" json:"contractsId" `
	ProjectId    string `form:"projectId" json:"projectId" `
	BidsectionId string `form:"bidsectionId" json:"bidsectionId" `
	// TreeId       string `form:"treeId" json:"treeId" `
	Time       string `form:"time" json:"time" `
	Price      string `form:"price" json:"price" `
	Way        string `form:"way" json:"way" `
	CreateUser string `form:"createUser" json:"createUser" `
	AccountId  string `form:"accountId" json:"accountId" `
	Remarks    string `form:"remarks" json:"remarks" `
	CreateTime string `form:"createTime" json:"createTime" `
	FileCounts int64  `from:"fileCounts" json:"fileCounts"`

	Page int `form:"page" json:"page" `
}

// 验证方法
func (l ContractsReturn) Validate() error {
	return validation.ValidateStruct(&l,
		validation.Field(&l.ContractsId, validation.Required.Error("合同ID不能为空")),
		validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
		validation.Field(&l.Page, validation.Required.Error("页数不能为空")),
	)
}

// 验证方法
func (l ContractsReturn) ValidateAdd() error {
	return validation.ValidateStruct(&l,
		validation.Field(&l.ContractsId, validation.Required.Error("合同ID不能为空")),
		validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
		validation.Field(&l.Time, validation.Required.Error("回款时间不能为空")),
		validation.Field(&l.Price, validation.Required.Error("金额不能为空")),
		validation.Field(&l.Way, validation.Required.Error("合同类型不能为空"), validation.In("支票", "现金", "网上转账", "电汇", "邮政汇款", "支付宝", "微信支付", "其他").Error("未找到相关回款类型")),
	)
}

func (l ContractsReturn) ValidateDel() error {
	return validation.ValidateStruct(&l,
		validation.Field(&l.Id, validation.Required.Error("回款ID不能为空")),
		validation.Field(&l.ContractsId, validation.Required.Error("合同ID不能为空")),
		validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
	)
}
