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.
59 lines
1.7 KiB
Plaintext
59 lines
1.7 KiB
Plaintext
using System;
|
|
$if(isGeneratorValidateClass)
|
|
using FluentValidation;
|
|
$end
|
|
using System.ComponentModel;
|
|
using NCA_MES_Models.CommonUtils.DB.DBAttribute;
|
|
//using NAC_MES_InterfaceLib.CommUtil.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>
|
|
[Description("${filedInfo["comment"]}")]
|
|
$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
|
|
|
|
$if(isGeneratorDynamicTableName)
|
|
static ${table_name}(){
|
|
${table_name}.DynamicTableName += () =>
|
|
{
|
|
return $"${dataBaseName}.{_tableName}";
|
|
};
|
|
}
|
|
$end
|
|
}
|
|
$if(isGeneratorValidateClass)
|
|
/// <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
|
|
}
|
|
}
|
|
$end
|
|
} |