Need the latest source code, or technical questions, Please add QQ group: 538327407, because the source code is constantly improving, it will be synchronized to open source projects later.
brief introduction
ABP framework has been used for nearly two years, and has completed many projects. As CTO and architect, when dealing with small and medium-sized projects, we usually choose ABP (internal large-scale Internet of Things framework adopts its own framework). It feels that this framework is really good. Although many open source communities have written several code generators, but after I use them, I always feel unable to achieve the desired results. I personally prefer one-step, batch generation, so I wrote this code generator based on codesmith, which is stable in the project.
Template introduction
Take a look at the code structure first.
In our project, I plan to use spa, so we usually generate four general directories, which are as follows
The rest of the Chinese and English, as well as permissions, and the relative number of DbContext part is relatively small, unified transformation, generating a single file for copy.
Finally, TemplateBuid is used to automatically generate the batch files above.
Code parsing and usage
Each code generator section needs to configure the corresponding project name, model and so on, and the details need to be understood by oneself.
Conventional simple operation
Generally, we need to use power design and other design tools to design the corresponding tables, annotate the tables, temporarily generate a database, generate code through codesmith, and then generate database tables in the form of code first in the corresponding database of abp.
The following file is TemplateBuid.Cst file, after configuration is completed,
Generate code operation, compile first, then generate.
Detailed code examples
Because of the limited space, I will briefly explain Repository, AppAuthorization Provider, createOrEditModal in view.
1,repository
Routine encapsulation operations, such as add, delete, modify, check, etc., I rewrote the base class method in the project, encapsulated batch operations, but did not combine with code generators. Routine business does not require batch operations.
The default primary key is a bit ID. If there is a requirement in the actual project, the primary key needs to be modified manually for other fields. At present, I encapsulate different code output for ID is int type and GUid type.
1 <%@ CodeTemplate Language="C#" TargetLanguage="C#" ResponseEncoding="UTF-8" Description="Generates a single entity business class." Debug="True" %> 2 <%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="2.data base" Description="Database table that this entity should be based on." %> 3 <%@ Property Name="TablePrefixes" Type="String" Default="" Optional="True" Category="2.data base" Description="The table prefix to be cut from the class name" %> 4 <%@ Property Name="RootNamespace" Type="String" Default="HashBlockChain" Optional="False" Category="1.Namespace" Description="The root name of the system namespace." %> 5 <%@ Property Name="Namespace" Type="String" Default="ZLDB_Domain" Optional="False" Category="1.Namespace" Description="Name of the folder the system currently belongs to (namespace related)." %> 6 <%@ Property Name="FolderNamespace" Type="String" Default="" Optional="true" Category="1.Namespace" Description="System namespace Model Name." %> 7 <%@ Property Name="PrefixLength" Type="Int32" Default="0" Optional="False" Category="2.data base" Description="Data Table Prefix Interception Length." %> 8 <%@ Assembly Name="SchemaExplorer" %> 9 <%@ Assembly Name="CodeSmith.BaseTemplates" %> 10 <%@ Assembly Name="System.Data" %> 11 <%@ Import Namespace="SchemaExplorer" %> 12 <%@ Import Namespace="System.Data" %> 13 <%string tableClass=GetClassName(SourceTable, "", 0); %> 14 <% FolderNamespace=SourceTable.Name.ToString();%> 15 <%string tableName=SourceTable.Name.ToString(); %> 16 <%string paramName=GetParamName(tableName); %> 17 18 using Abp.Application.Services; 19 using Abp.Application.Services.Dto; 20 using Abp.AutoMapper; 21 using Abp.Domain.Repositories; 22 using Abp.Domain.Uow; 23 using AutoMapper; 24 using System; 25 using System.Collections.Generic; 26 using System.Data.Entity; 27 using System.Linq; 28 using System.Linq.Expressions; 29 using System.Text; 30 using System.Threading.Tasks; 31 using System.Linq.Dynamic; 32 using Abp.Linq.Extensions; 33 using <%= RootNamespace %>.<%=Namespace%>.Dtos; 34 using <%= RootNamespace %>.Dto; 35 using <%= RootNamespace %>.Authorization.<%=tableName%>.Exporting; 36 namespace <%= RootNamespace %>.<%=Namespace%> 37 { 38 39 <% foreach (ColumnSchema column in SourceTable.Columns) { %> 40 <% if (column.IsPrimaryKeyMember) { %> 41 42 <%string tempType = GetCSharpVariableType(column); %> 43 44 <% if (tempType=="Guid") { %> 45 /// <summary> 46 /// <%=SourceTable.Description%> Business Implementation Interface 47 /// </summary> 48 public class <%=tableName%>AppService : AbpZeroTemplateAppServiceBase, I<%=tableName%>AppService 49 { 50 private readonly IRepository<<%=tableName%>, Guid> _<%=paramName%>Repository; 51 private readonly I<%=tableName%>ListExcelExporter _i<%=tableName%>ListExcelExporter; 52 53 /// <summary> 54 /// Constructors automatically inject the classes or interfaces we need 55 /// </summary> 56 public <%=tableName%>AppService(IRepository<<%=tableName%>, Guid> <%=paramName%>Repository,I<%=tableName%>ListExcelExporter i<%=tableName%>ListExcelExporter) 57 { 58 _<%=paramName%>Repository = <%=paramName%>Repository; 59 _i<%=tableName%>ListExcelExporter = i<%=tableName%>ListExcelExporter; 60 61 } 62 63 /// <summary> 64 /// Get all the data lists 65 /// </summary> 66 /// <returns>Return data set</returns> 67 public async Task<List<<%=tableName%>Dto>> GetAllList() 68 { 69 //call Task Specific methods of warehousing GetAllWithPeople 70 var resultList = await _<%=paramName%>Repository.GetAllListAsync(); 71 return Mapper.Map<List<<%=tableName%>Dto>>(resultList).ToList(); 72 } 73 74 /// <summary> 75 /// Getting the paging data list and paging specific code needs to be modified appropriately, such as orderby Need to match creation time or other data Id(int) 76 /// </summary> 77 /// <returns>Return data set</returns> 78 public async Task<PagedResultDto<<%=tableName%>Dto>> GetPagedListAsync(PagedAndFilteredInputDto input) 79 { 80 var query = _<%=paramName%>Repository.GetAll(); 81 //TODO:Add filtering conditions based on the incoming parameters 82 83 var resultCount = await query.CountAsync(); 84 var result<%=paramName%> = await query 85 .OrderBy(x=>x.Id) 86 .PageBy(input) 87 .ToListAsync(); 88 89 var resultListDtos = result<%=paramName%>.MapTo<List<<%=tableName%>Dto>>(); 90 91 if (!string.IsNullOrEmpty(input.Sorting)) { 92 resultListDtos = resultListDtos.OrderBy(input.Sorting).ToList(); 93 } 94 95 return new PagedResultDto<<%=tableName%>Dto>( 96 resultCount, 97 resultListDtos 98 ); 99 } 100 101 /// <summary> 102 /// Gets a list of data for a specified condition webapi unavailable 103 /// </summary> 104 /// <returns>Return data set</returns> 105 public async Task<List<<%=tableName%>Dto>> GetListByCodition(Expression<Func<<%=tableName%>, bool>> predicate) 106 { 107 108 var resultList = await _<%=paramName%>Repository.GetAllListAsync(predicate); 109 return Mapper.Map<List<<%=tableName%>Dto>>(resultList).ToList(); 110 } 111 112 113 /// <summary> 114 /// export excel Specific methods 115 /// </summary> 116 /// <returns>excel file</returns> 117 /// public async Task<FileDto> Get<%=tableName%>ToExcel() 118 ///{ 119 /// var resultList = await _<%=paramName%>Repository.GetAllListAsync(); 120 /// var <%=paramName%>Dtos= Mapper.Map<List<<%=tableName%>Dto>>(resultList).ToList(); 121 /// return _i<%=tableName%>ListExcelExporter.ExportToFile(<%=paramName%>Dtos); 122 /// } 123 124 /// <summary> 125 /// According to the designated id Getting data entities 126 /// </summary> 127 /// <param name="input">current id</param> 128 /// <returns></returns> 129 public async Task<<%=tableName%>Dto> Get<%=tableName%>ForEditAsync(NullableIdDto<System.Guid> input) 130 { 131 var output = new <%=tableName%>Dto(); 132 133 <%=tableName%>Dto <%=paramName%>EditDto; 134 135 if (input.Id.HasValue) 136 { 137 var entity = await _<%=paramName%>Repository.GetAsync(input.Id.Value); 138 <%=paramName%>EditDto = entity.MapTo<<%=tableName%>Dto>(); 139 } 140 else 141 { 142 <%=paramName%>EditDto = new <%=tableName%>Dto(); 143 } 144 145 output = <%=paramName%>EditDto; 146 return output; 147 } 148 149 /// <summary> 150 /// according to Id Create or edit operations 151 /// </summary> 152 /// <param name="input">entity</param> 153 /// <returns></returns> 154 public async Task CreateOrUpdate<%=tableName%>Async(<%=tableName%>Dto input) 155 { 156 if (!string.IsNullOrWhiteSpace(input.Id)) 157 { 158 await Update(input); 159 } 160 else 161 { 162 await Create(input); 163 } 164 } 165 166 /// <summary> 167 /// Newly added 168 /// </summary> 169 /// <param name="input">New parameter</param> 170 /// <returns>New entity</returns> 171 public async Task<Guid> Create(<%=tableName%>Dto input) 172 { 173 input.Id = new <%=tableName%>().Id.ToString(); 174 var resultObj = input.MapTo<<%=tableName%>>(); 175 var result = await _<%=paramName%>Repository.InsertAsync(resultObj); 176 177 return result.Id; 178 } 179 180 /// <summary> 181 /// modify 182 /// </summary> 183 /// <param name="input">modify parameters</param> 184 /// <returns>Modify entity</returns> 185 public async Task<<%=tableName%>Dto> Update(<%=tableName%>Dto input) 186 { 187 <%=tableName%> obj = await _<%=paramName%>Repository.GetAsync(new Guid(input.Id)); 188 input.MapTo(obj); 189 var result = await _<%=paramName%>Repository.UpdateAsync(obj); 190 return obj.MapTo<<%=tableName%>Dto>(); 191 } 192 193 /// <summary> 194 /// delete 195 /// </summary> 196 /// <param name="input">delete Dto</param> 197 /// <returns>No return value</returns> 198 public async System.Threading.Tasks.Task Delete(EntityDto<string> input) 199 { 200 await _<%=paramName%>Repository.DeleteAsync(new Guid(input.Id)); 201 } 202 203 /// <summary> 204 /// delete webapi unavailable 205 /// </summary> 206 /// <param name="predicate">Delete condition</param> 207 /// <returns>No return value</returns> 208 public async System.Threading.Tasks.Task DeleteByCondition(Expression<Func<<%=tableName%>, bool>> predicate) 209 { 210 await _<%=paramName%>Repository.DeleteAsync(predicate); 211 212 } 213 } 214 215 216 <% } else {%> 217 /// <summary> 218 /// <%=SourceTable.Description%> Business Implementation Interface 219 /// </summary> 220 public class <%=tableName%>AppService : AbpZeroTemplateAppServiceBase, I<%=tableName%>AppService 221 { 222 private readonly IRepository<<%=tableName%>, <%=tempType%>> _<%=paramName%>Repository; 223 private readonly I<%=tableName%>ListExcelExporter _i<%=tableName%>ListExcelExporter; 224 225 /// <summary> 226 /// Constructors automatically inject the classes or interfaces we need 227 /// </summary> 228 public <%=tableName%>AppService(IRepository<<%=tableName%>, <%=tempType%>> <%=paramName%>Repository,I<%=tableName%>ListExcelExporter i<%=tableName%>ListExcelExporter) 229 { 230 _<%=paramName%>Repository = <%=paramName%>Repository; 231 _i<%=tableName%>ListExcelExporter = i<%=tableName%>ListExcelExporter; 232 233 } 234 235 /// <summary> 236 /// Get all the data lists 237 /// </summary> 238 /// <returns>Return data set</returns> 239 public async Task<List<<%=tableName%>Dto>> GetAllList() 240 { 241 //call Task Specific methods of warehousing GetAllWithPeople 242 var resultList = await _<%=paramName%>Repository.GetAllListAsync(); 243 return Mapper.Map<List<<%=tableName%>Dto>>(resultList).ToList(); 244 } 245 246 /// <summary> 247 /// Getting the paging data list and paging specific code needs to be modified appropriately, such as orderby Need to match creation time or other data Id(int) 248 /// </summary> 249 /// <returns>Return data set</returns> 250 public async Task<PagedResultDto<<%=tableName%>Dto>> GetPagedListAsync(PagedAndFilteredInputDto input) 251 { 252 var query = _<%=paramName%>Repository.GetAll(); 253 //TODO:Add filtering conditions based on the incoming parameters 254 255 var resultCount = await query.CountAsync(); 256 var result<%=paramName%> = await query 257 .OrderBy(x=>x.Id) 258 .PageBy(input) 259 .ToListAsync(); 260 261 var resultListDtos = result<%=paramName%>.MapTo<List<<%=tableName%>Dto>>(); 262 return new PagedResultDto<<%=tableName%>Dto>( 263 resultCount, 264 resultListDtos 265 ); 266 } 267 268 /// <summary> 269 /// Gets a list of data for a specified condition webapi unavailable 270 /// </summary> 271 /// <returns>Return data set</returns> 272 public async Task<List<<%=tableName%>Dto>> GetListByCodition(Expression<Func<<%=tableName%>, bool>> predicate) 273 { 274 275 var resultList = await _<%=paramName%>Repository.GetAllListAsync(predicate); 276 return Mapper.Map<List<<%=tableName%>Dto>>(resultList).ToList(); 277 } 278 279 280 /// <summary> 281 /// export excel Specific methods 282 /// </summary> 283 /// <returns>excel file</returns> 284 /// public async Task<FileDto> Get<%=tableName%>ToExcel() 285 ///{ 286 /// var resultList = await _<%=paramName%>Repository.GetAllListAsync(); 287 /// var <%=paramName%>Dtos= Mapper.Map<List<<%=tableName%>Dto>>(resultList).ToList(); 288 /// return _i<%=tableName%>ListExcelExporter.ExportToFile(<%=paramName%>Dtos); 289 /// } 290 291 /// <summary> 292 /// According to the designated id Getting data entities 293 /// </summary> 294 /// <param name="input">current id</param> 295 /// <returns></returns> 296 public async Task<<%=tableName%>Dto> Get<%=tableName%>ForEditAsync(NullableIdDto<<%=tempType%>> input) 297 { 298 var output = new <%=tableName%>Dto(); 299 300 <%=tableName%>Dto <%=paramName%>EditDto; 301 302 if (Convert.ToInt32(input.Id)>0) 303 { 304 var entity = await _<%=paramName%>Repository.GetAsync(Convert.ToInt32(input.Id)); 305 <%=paramName%>EditDto = entity.MapTo<<%=tableName%>Dto>(); 306 } 307 else 308 { 309 <%=paramName%>EditDto = new <%=tableName%>Dto(); 310 } 311 312 output = <%=paramName%>EditDto; 313 return output; 314 } 315 316 /// <summary> 317 /// according to Id Create or edit operations 318 /// </summary> 319 /// <param name="input">entity</param> 320 /// <returns></returns> 321 public async Task CreateOrUpdate<%=tableName%>Async(<%=tableName%>Dto input) 322 { 323 if (Convert.ToInt32(input.Id)>0) 324 { 325 await Update(input); 326 } 327 else 328 { 329 await Create(input); 330 } 331 } 332 333 /// <summary> 334 /// Newly added 335 /// </summary> 336 /// <param name="input">New parameter</param> 337 /// <returns>New entity</returns> 338 public async Task<<%=tempType%>> Create(<%=tableName%>Dto input) 339 { 340 input.Id = new <%=tableName%>().Id.ToString(); 341 var resultObj = input.MapTo<<%=tableName%>>(); 342 var result = await _<%=paramName%>Repository.InsertAsync(resultObj); 343 344 return result.Id; 345 } 346 347 /// <summary> 348 /// modify 349 /// </summary> 350 /// <param name="input">modify parameters</param> 351 /// <returns>Modify entity</returns> 352 public async Task<<%=tableName%>Dto> Update(<%=tableName%>Dto input) 353 { 354 <%=tableName%> obj = await _<%=paramName%>Repository.GetAsync(Convert.ToInt32(input.Id)); 355 input.MapTo(obj); 356 var result = await _<%=paramName%>Repository.UpdateAsync(obj); 357 return obj.MapTo<<%=tableName%>Dto>(); 358 } 359 360 /// <summary> 361 /// delete 362 /// </summary> 363 /// <param name="input">delete Dto</param> 364 /// <returns>No return value</returns> 365 public async System.Threading.Tasks.Task Delete(EntityDto<string> input) 366 { 367 await _<%=paramName%>Repository.DeleteAsync(Convert.ToInt32(input.Id)); 368 } 369 370 /// <summary> 371 /// delete webapi unavailable 372 /// </summary> 373 /// <param name="predicate">Delete condition</param> 374 /// <returns>No return value</returns> 375 public async System.Threading.Tasks.Task DeleteByCondition(Expression<Func<<%=tableName%>, bool>> predicate) 376 { 377 await _<%=paramName%>Repository.DeleteAsync(predicate); 378 379 } 380 } 381 382 383 <% }%> 384 <% }%> <% }%> 385 386 387 } 388 389 390 391 392 <script runat="template"> 393 <!-- #include file="TemplateUtilities.cs" --> 394 </script>
2. AppAuthorizationProvider.cst is to be used with AppPermissions.cst. In the actual project, I split the original abp code, realized its own integrated version, and minimized the coupling of the original abp code.
Configuration. Authorization. Providers. Add <Customs App Authorization Provider>() in AbpZeroTemplate Application Module; ensure injection
<%-- Name: Author: Description: --%> <%@ Template Language="C#" TargetLanguage="Text" Src="" Inherits=""Debug="False" CompilerVersion="v4.0" %> <%@ Assembly Name="SchemaExplorer" %> <%@ Import Namespace="SchemaExplorer" %> <%@ Property Name="SourceDatabase" DeepLoad="True" Type="SchemaExplorer.DatabaseSchema" %> <%@ Property Name="Tables" Type="TableSchemaCollection" Optional="True" Category="2.data base" Description="Tables to Inclue" %> <%@ Template Language="C#" TargetLanguage="Text" %> <%@ Property Name="SampleStringProperty" Default="SomeValue" Type="System.String" %> <%@ Property Name="SampleBooleanProperty" Default="True" Type="System.Boolean" %> <%@ Property Name="RootNamespace" Type="String" Default="HashBlockChain" Optional="False" Category="1.Namespace" Description="The root name of the system namespace." %> <%@ Property Name="Namespace" Type="String" Default="ZLDB_Domain" Optional="False" Category="1.Namespace" Description="Name of the folder the system currently belongs to (namespace related)." %> My static content here. My dynamic content here: "<%= SampleStringProperty %>" Call a script method: <%= SampleMethod() %> <% if (SampleBooleanProperty) { %> My conditional content here. <% } %> <script runat="template"> // My methods here. public string SampleMethod() { return "Method output."; } </script> using System.Linq; using Abp.Authorization; using Abp.Localization; using <%=RootNamespace%>.Authorization; //-------------------------------------------------------------------------------------------------------------------------------------------------------------- //Introduction: Abp Privilege configuration, after generation AbpZeroTemplateApplicationModule Medium Configuration.Authorization.Providers.Add<CustomsAppAuthorizationProvider>(); Ensure injection // // // // //Author: //-------------------------------------------------------------------------------------------------------------------------------------------------------------- namespace <%= RootNamespace %>.<%=Namespace%>.Authorization { /// <summary> /// The permission configurations are all here. /// Default services for permissions /// See <see cref="CustomsAppPermissions"/> for all permission names. /// </summary> public class CustomsAppAuthorizationProvider : AuthorizationProvider { public override void SetPermissions(IPermissionDefinitionContext context) { //Custom permissions are configured here. var pages = context.GetPermissionOrNull(AppPermissions.Pages) ?? context.CreatePermission(AppPermissions.Pages, L("Pages")); var entityNameModel = pages.Children.FirstOrDefault(p => p.Name == AppPermissions.Pages_Administration) ?? pages.CreateChildPermission(AppPermissions.Pages_Administration, L("Administration")); <% foreach(TableSchema t in Tables){ %> <%string tableName=t.Name.ToString(); %> <%string paramName=GetParamName(tableName); %> //<%=t.Description%> Jurisdiction var <%=paramName%> = entityNameModel.CreateChildPermission(CustomsAppPermissions.<%=t.Name %>, L("<%=t.Name %>")); <%=paramName%>.CreateChildPermission(CustomsAppPermissions.<%=t.Name %>_Create<%=t.Name %>, L("Create<%=t.Name %>")); <%=paramName%>.CreateChildPermission(CustomsAppPermissions.<%=t.Name %>_Edit<%=t.Name %>, L("Edit<%=t.Name %>")); <%=paramName%>.CreateChildPermission(CustomsAppPermissions.<%=t.Name %>_Delete<%=t.Name %>, L("Delete<%=t.Name %>")); <% }%> } private static ILocalizableString L(string name) { return new LocalizableString(name, AbpZeroTemplateConsts.LocalizationSourceName); } } } <script runat="template"> <!-- #include file="TemplateUtilities.cs" --> </script>
3. createOrEditModal.cst in the view folder
This is the view view view based on angular.js, where I encapsulate data validation. If you don't need it, you can adjust it manually, and actively split the template into one column and two columns, you need to change it manually.
<%@ CodeTemplate Language="C#" TargetLanguage="C#" ResponseEncoding="UTF-8" Description="Generates a single entity business class." Debug="True" %> <%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="2.data base" Description="Database table that this entity should be based on." %> <%@ Property Name="TablePrefixes" Type="String" Default="" Optional="True" Category="2.data base" Description="The table prefix to be cut from the class name" %> <%@ Property Name="RootNamespace" Type="String" Default="ManagementSystem" Optional="False" Category="1.Namespace" Description="The root name of the system namespace." %> <%@ Property Name="Title" Type="String" Default="createOrEditModal" Optional="False" Category="1.Namespace" Description="System namespace Model Name." %> <%@ Property Name="PrefixLength" Type="Int32" Default="0" Optional="False" Category="2.data base" Description="Data Table Prefix Interception Length." %> <%@ Assembly Name="SchemaExplorer" %> <%@ Assembly Name="CodeSmith.BaseTemplates" %> <%@ Assembly Name="System.Data" %> <%@ Import Namespace="SchemaExplorer" %> <%@ Import Namespace="System.Data" %> <%string tableClass=GetClassName(SourceTable, "", 0); %> <%string tableName=SourceTable.Name.ToString(); %> <%string paramName=GetParamName(tableName); %> <%string tableDescString=GetTableDescriptionName(SourceTable.Description);%> @using Abp.Web.Mvc.Extensions @using <%=RootNamespace%>.Web.Bundling @using <%=RootNamespace%>.AbpZeroTemplate @{ LocalizationSourceName = AbpZeroTemplateConsts.LocalizationSourceName; } @section Styles { @*@Html.IncludeStyle("~/libs/bootstrap-daterangepicker/daterangepicker.css")*@ } @section Scripts { @*@Html.IncludeScript(ScriptPaths.Angular_DateRangePicker)*@ } <div> @*//mark 1*@ <form name="<%=paramName%>CreateOrEditForm" role="form" novalidate class="form-validation"> <div class="modal-header"> <h4 class="modal-title"> <span ng-if="vm.<%=paramName%>.id">Editing information:{{vm.<%=paramName%>.name}}</span> <span ng-if="!vm.<%=paramName%>.id">New information</span> </h4> </div> <div class="modal-body"> /* Two column template <div class="row"> <div class="col-sm-6"> //Specific code 1 for a single column </div> <div class="col-sm-6"> //Specific code 2 for a single column </div> </div> */ <% foreach (ColumnSchema column in SourceTable.Columns) { %> <% if(column.Size>100) {%> <div class="form-group form-md-line-input form-md-floating-label no-hint"> <textarea auto-focus class="form-control" name="<%=GetParamName(column.Name)%>" style="resize: none;" ng-class="{'edited':vm.<%=paramName%>.<%=GetParamName(column.Name)%>}" ng-model="vm.<%=paramName%>.<%=GetParamName(column.Name)%>" required ng-pattern="{Fill in specific regular expressions}" ng-minlength="10" ng-maxlength="<%=column.Size%>"></textarea> <label><%=column.Description%></label> </div> <div ng-messages="<%=paramName%>CreateOrEditForm.<%=GetParamName(column.Name)%>.$error" ng-show="<%=paramName%>CreateOrEditForm.<%=GetParamName(column.Name)%>.$error"> <ul class="help-block text-danger"> <li ng-show="<%=paramName%>CreateOrEditForm.<%=GetParamName(column.Name)%>.$error.pattern" ng-message="pattern"><%=column.Description%>Incorrect format{Change again on your own}!</li> <li ng-show="<%=paramName%>CreateOrEditForm.<%=GetParamName(column.Name)%>.$error.required" ng-message="required"><%=column.Description%>Can not be empty!</li> <li ng-show="<%=paramName%>CreateOrEditForm.<%=GetParamName(column.Name)%>.$error.minlength" ng-message="minlength"><%=column.Description%>Minimum length is 10!</li> <li ng-show="<%=paramName%>CreateOrEditForm.<%=GetParamName(column.Name)%>.$error.maxlength" ng-message="maxlength"><%=column.Description%>The maximum length is<%=column.Size%>!</li> </ul> </div> <%}else {%> <div class="form-group form-md-line-input form-md-floating-label no-hint"> <input type="text" class="form-control" name="<%=GetParamName(column.Name)%>" ng-class="{'edited':vm.<%=paramName%>.<%=GetParamName(column.Name)%>}" ng-pattern="{Fill in specific regular expressions}" ng-model="vm.<%=paramName%>.<%=GetParamName(column.Name)%>" required ng-minlength="10" ng-maxlength="<%=column.Size%>" /> <label><%=column.Description%></label> </div> <div ng-messages="<%=paramName%>CreateOrEditForm.<%=GetParamName(column.Name)%>.$error" ng-show="<%=paramName%>CreateOrEditForm.<%=GetParamName(column.Name)%>.$error"> <ul class="help-block text-danger"> <li ng-show="<%=paramName%>CreateOrEditForm.<%=GetParamName(column.Name)%>.$error.pattern" ng-message="pattern"><%=column.Description%>Incorrect format{Change again on your own}!</li> <li ng-show="<%=paramName%>CreateOrEditForm.<%=GetParamName(column.Name)%>.$error.required" ng-message="required"><%=column.Description%>Can not be empty!</li> <li ng-show="<%=paramName%>CreateOrEditForm.<%=GetParamName(column.Name)%>.$error.minlength" ng-message="minlength"><%=column.Description%>Minimum length is 10!</li> <li ng-show="<%=paramName%>CreateOrEditForm.<%=GetParamName(column.Name)%>.$error.maxlength" ng-message="maxlength"><%=column.Description%>The maximum length is<%=column.Size%>!</li> </ul> </div> <% }%> <% } %> </div> <div class="modal-footer"> <button ng-disabled="vm.saving" type="button" class="btn btn-default" ng-click="vm.cancel()">@L("Cancel")</button> <button type="submit" button-busy="vm.saving" busy-text="@L("SavingWithThreeDot")" class="btn btn-primary blue" ng-click="vm.save()" ng-disabled="<%=paramName%>CreateOrEditForm.$invalid"><i class="fa fa-save"></i> <span>@L("Save")</span></button> </div> </form> </div> <script runat="template"> <!-- #include file="../TemplateUtilities.cs" --> </script>
Result Partial Display
model entity
using System; using Abp.Authorization.Users; using Abp.Extensions; using Microsoft.AspNet.Identity; using System.ComponentModel.DataAnnotations.Schema; using Abp.Domain.Entities; using System.Threading.Tasks; using System.ComponentModel.DataAnnotations; using System.ComponentModel; using Abp; //---------------------------------------------- //Introduction: HashBlockChain.ZLDB_Domain Entity Database Corresponding Entities // // // //auther: //---------------------------------------------- namespace HashBlockChain.ZLDB_Domain { //Get the primary key Id Naming ///Chain information table [Table("ChainInfo")] public partial class ChainInfo : Entity<int> { #region Declarations /// <summary> /// Chain name /// </summary> [DisplayName("Chain name")] [StringLength(30)] public virtual string ChainName { get; set; } /// <summary> /// chain Id /// </summary> [DisplayName("chain Id")] [StringLength(30)] public virtual string ChainId { get; set; } /// <summary> /// Chain description /// </summary> [DisplayName("Chain description")] [StringLength(200)] public virtual string ChainDescription { get; set; } /// <summary> /// Chain state /// </summary> public virtual int? ChainStatus { get; set; } /// <summary> /// sort /// </summary> public virtual int? Sort { get; set; } /// <summary> /// Visible /// </summary> public virtual bool? IsEnabled { get; set; } /// <summary> /// Founder /// </summary> public virtual int? CreateUserId { get; set; } /// <summary> /// Creation time /// </summary> public virtual DateTime? CreateDateTime { get; set; } /// <summary> /// Last Modifier /// </summary> public virtual int? LastEditUserId { get; set; } /// <summary> /// Last modification time /// </summary> public virtual DateTime? LastEditDateTime { get; set; } /// <summary> /// Node number /// </summary> public virtual int? PeerCount { get; set; } /// <summary> /// Block chain height /// </summary> public virtual long? BlockHeight { get; set; } #endregion } }
Chinese and English display
Code generated by partial privileges