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} { /// /// ${table_comment} /// [TableName("${sql_table_name}")] public class ${table_name} : DBBaseModel<${table_name}> { $foreach(filedInfo in filedInfos) /// /// ${filedInfo["comment"]} /// [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) /// /// 验证类 采用FluentValidation /// 项目地址 https://github.com/FluentValidation/FluentValidation /// 文档地址 https://docs.fluentvalidation.net/en/latest/start.html /// 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 }