Input.cs.vm 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. // Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
  2. //
  3. // 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
  4. //
  5. // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
  6. using Admin.NET.Core;
  7. using System.ComponentModel.DataAnnotations;
  8. namespace @(Model.NameSpace);
  9. /// <summary>
  10. /// @(Model.BusName)基础输入参数
  11. /// </summary>
  12. public class @(Model.ClassName)BaseInput
  13. {
  14. @foreach (var column in Model.PrimaryKeyFieldList.Concat(Model.AddUpdateFieldList)){
  15. @:/// <summary>
  16. @:/// @column.ColumnComment
  17. @:/// </summary>
  18. if (column.EffectType is "EnumSelector" or "DictSelector") {
  19. @:[Dict(@(column.EffectType == "EnumSelector" ? $"nameof({column.DictTypeCode})" : $"\"{column.DictTypeCode}\""), AllowNullValue=true)]
  20. }
  21. if (column.WhetherRequired == "Y") {
  22. @:[Required(ErrorMessage = "@(column.ColumnComment)不能为空")]
  23. }
  24. @:public virtual @Model.GetNullableNetType(column.NetType) @column.PropertyName { get; set; }
  25. @:
  26. }
  27. }
  28. /// <summary>
  29. /// @(Model.BusName)分页查询输入参数
  30. /// </summary>
  31. public class Page@(Model.ClassName)Input : BasePageInput
  32. {
  33. @foreach (var column in Model.TableField.Where(u => u.WhetherQuery == "Y")){
  34. if(column.NetType?.TrimEnd('?') == "DateTime" && column.QueryType == "~"){
  35. @:/// <summary>
  36. @:/// @(column.ColumnComment)范围
  37. @:/// </summary>
  38. @: public DateTime?[] @(column.PropertyName)Range { get; set; }
  39. } else {
  40. @:/// <summary>
  41. @:/// @column.ColumnComment
  42. @:/// </summary>
  43. if (column.EffectType is "EnumSelector" or "DictSelector") {
  44. @:[Dict(@(column.EffectType == "EnumSelector" ? $"nameof({column.DictTypeCode})" : $"\"{column.DictTypeCode}\""), AllowNullValue=true)]
  45. }
  46. @:public @Model.GetNullableNetType(column.NetType) @column.PropertyName { get; set; }
  47. }
  48. @:
  49. }
  50. @if (Model.ImportFieldList.Count > 0){
  51. var primaryKey = Model.PrimaryKeyFieldList.First();
  52. @:/// <summary>
  53. @:/// 选中主键列表
  54. @:/// </summary>
  55. @: public List<@(primaryKey.NetType)> SelectKeyList { get; set; }
  56. }
  57. }
  58. /// <summary>
  59. /// @(Model.BusName)增加输入参数
  60. /// </summary>
  61. public class Add@(Model.ClassName)Input
  62. {
  63. @foreach (var column in Model.AddUpdateFieldList){
  64. @:/// <summary>
  65. @:/// @column.ColumnComment
  66. @:/// </summary>
  67. if (column.EffectType is "EnumSelector" or "DictSelector") {
  68. @:[Dict(@(column.EffectType == "EnumSelector" ? $"nameof({column.DictTypeCode})" : $"\"{column.DictTypeCode}\""), AllowNullValue=true)]
  69. }
  70. if (column.WhetherRequired == "Y") {
  71. @:[Required(ErrorMessage = "@(column.ColumnComment)不能为空")]
  72. }
  73. if (column.NetType.TrimEnd('?').EndsWith("string") && column.ColumnLength > 0){
  74. @:[MaxLength(@column.ColumnLength, ErrorMessage = "@(column.ColumnComment)字符长度不能超过@(column.ColumnLength)")]
  75. }
  76. @:public @Model.GetNullableNetType(column.NetType) @column.PropertyName { get; set; }
  77. @:
  78. }
  79. }
  80. /// <summary>
  81. /// @(Model.BusName)删除输入参数
  82. /// </summary>
  83. public class Delete@(Model.ClassName)Input
  84. {
  85. @foreach (var column in Model.PrimaryKeyFieldList) {
  86. @:/// <summary>
  87. @:/// @column.ColumnComment
  88. @:/// </summary>
  89. @:[Required(ErrorMessage = "@(column.ColumnComment)不能为空")]
  90. @:public @Model.GetNullableNetType(column.NetType) @column.PropertyName { get; set; }
  91. @:
  92. }
  93. }
  94. /// <summary>
  95. /// @(Model.BusName)更新输入参数
  96. /// </summary>
  97. public class Update@(Model.ClassName)Input
  98. {
  99. @foreach (var column in Model.PrimaryKeyFieldList.Concat(Model.AddUpdateFieldList)){
  100. @:/// <summary>
  101. @:/// @column.ColumnComment
  102. @:/// </summary>
  103. if (column.EffectType is "EnumSelector" or "DictSelector") {
  104. @:[Dict(@(column.EffectType == "EnumSelector" ? $"nameof({column.DictTypeCode})" : $"\"{column.DictTypeCode}\""), AllowNullValue=true)]
  105. }
  106. if (column.WhetherRequired == "Y" || column.ColumnKey == "True") {
  107. @:[Required(ErrorMessage = "@(column.ColumnComment)不能为空")]
  108. }
  109. if (column.NetType.TrimEnd('?').EndsWith("string") && column.ColumnLength > 0){
  110. @:[MaxLength(@column.ColumnLength, ErrorMessage = "@(column.ColumnComment)字符长度不能超过@(column.ColumnLength)")]
  111. }
  112. @:public @Model.GetNullableNetType(column.NetType) @column.PropertyName { get; set; }
  113. @:
  114. }
  115. }
  116. /// <summary>
  117. /// @(Model.BusName)主键查询输入参数
  118. /// </summary>
  119. public class QueryById@(Model.ClassName)Input : Delete@(Model.ClassName)Input
  120. {
  121. }
  122. @if (Model.DropdownFieldList.Count > 0) {
  123. @:/// <summary>
  124. @:/// 下拉数据输入参数
  125. @:/// </summary>
  126. @:public class DropdownData@(Model.ClassName)Input
  127. @:{
  128. @:/// <summary>
  129. @:/// 是否用于分页查询
  130. @:/// </summary>
  131. @:public bool FromPage { get; set; }
  132. @:}
  133. @:
  134. }
  135. @if (Model.HasSetStatus) {
  136. @:/// <summary>
  137. @:/// 设置状态输入参数
  138. @:/// </summary>
  139. @:public class Set@(Model.ClassName)StatusInput : BaseStatusInput
  140. @:{
  141. @foreach (var column in Model.PrimaryKeyFieldList.Where(u => u.PropertyName != "Id")) {
  142. @:/// <summary>
  143. @:/// @column.ColumnComment
  144. @:/// </summary>
  145. @:[Required(ErrorMessage = "@(column.ColumnComment)不能为空")]
  146. @:public @Model.GetNullableNetType(column.NetType) @column.PropertyName { get; set; }
  147. @:
  148. }
  149. @:}
  150. @:
  151. }
  152. @if (Model.ImportFieldList.Count > 0){
  153. @:/// <summary>
  154. @:/// @(Model.BusName)数据导入实体
  155. @:/// </summary>
  156. @:[ExcelImporter(SheetIndex = 1, IsOnlyErrorRows = true)]
  157. @:public class Import@(Model.ClassName)Input : BaseImportInput
  158. @:{
  159. foreach (var column in Model.ImportFieldList){
  160. var headerName = (column.WhetherRequired == "Y" ? "*" : "") + column.ColumnComment;
  161. if(column.EffectType == "ForeignKey" || column.EffectType == "ApiTreeSelector" || column.EffectType == "DictSelector") {
  162. @:/// <summary>
  163. @:/// @column.ColumnComment 关联值
  164. @:/// </summary>
  165. @:[ImporterHeader(IsIgnore = true)]
  166. @:[ExporterHeader(IsIgnore = true)]
  167. @:public @Model.GetNullableNetType(column.NetType) @column.PropertyName { get; set; }
  168. @:
  169. @:/// <summary>
  170. @:/// @column.ColumnComment 文本
  171. @:/// </summary>
  172. @:[ImporterHeader(Name = "@(headerName)")]
  173. @:[ExporterHeader("@(headerName)", Format = "@", Width = 25, IsBold = true)]
  174. @:public string @column.ExtendedPropertyName { get; set; }
  175. } else {
  176. @:/// <summary>
  177. @:/// @column.ColumnComment
  178. @:/// </summary>
  179. @:[ImporterHeader(Name = "@(headerName)")]
  180. @:[ExporterHeader("@(headerName)", Format = "@", Width = 25, IsBold = true)]
  181. @:public @Model.GetNullableNetType(column.NetType) @column.PropertyName { get; set; }
  182. }
  183. @:
  184. }
  185. @:}
  186. }