You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.3 KiB
Plaintext

using System;
using FluentValidation;
using NCA_MES_Models.CommonUtils.DB.DBAttribute;
namespace ${namespace_name}
{
/// <summary>
/// ${table_comment}
/// </summary>
[TableName("${sql_table_name}")]
public class ${table_name} : DBBaseModel<${table_name}>
{
$foreach(filedInfo in filedInfos)
/// <summary>
/// ${filedInfo["comment"]}
/// </summary>
$if(filedInfo["is_primary_key"]=="true")
[TableId]
$end
$if(filedInfo["is_nullable"]=="true")
[NotEmpty]
$end
[TableField("${filedInfo["sql_field_name"]}", "${filedInfo["comment"]}")]
public ${filedInfo["type_name"]} ${filedInfo["field_name"]} { get; set; }
$end
}
/// <summary>
/// 验证类 采用FluentValidation
/// 项目地址 https://github.com/FluentValidation/FluentValidation
/// 文档地址 https://docs.fluentvalidation.net/en/latest/start.html
/// </summary>
public class ${table_name}Validator : AbstractValidator<${table_name}>
{
public ${table_name}Validator()
{
$foreach(filedInfo in filedInfos)
$if(filedInfo["is_nullable"]=="true")
RuleFor(item => item.${filedInfo["field_name"]}).NotNull().WithMessage("${filedInfo["comment"]}不能为空");
$end
$end
}
}
}