public static string BuildRepInterface(string name) { var templateBuilder = new StringBuilder(); templateBuilder.AppendLine("using JZFZ.Infrastructure.Data.DapperExtensions;"); templateBuilder.AppendLine("using System.Collections.Generic;"); templateBuilder.AppendLine("using System.Linq;"); templateBuilder.AppendLine("using System.Threading.Tasks;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Config;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Domain.Entity;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Domain.Model;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Inject;"); templateBuilder.AppendLine("namespace $$PROJECTNAME$$.Repository.Interface"); templateBuilder.AppendLine("{"); templateBuilder.AppendLine(" public interface I$$TABLENAME$$Rep: ITransientInject"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// 添加单个对象"); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" Task<$$TABLENAME$$Entity> AddAsync($$TABLENAME$$AddModel model);"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// 修改单个对象"); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" Task<$$TABLENAME$$Entity> ModifyAsync($$TABLENAME$$Model model);"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// 获取单个对象"); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" Task<$$TABLENAME$$Entity> InfoAsync($$TABLENAME$$ConditionModel model);"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// 获取对象列表"); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" Task<List<$$TABLENAME$$Entity>> InfosAsync($$TABLENAME$$ConditionModel model);"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine("}"); return(BusinessBuilderCore.BuildAll(templateBuilder.ToString(), name)); }
public static string BuildServiceInterface(string name) { var templateBuilder = new StringBuilder(); templateBuilder.AppendLine("using JZFZ.Infrastructure.Common.Model.Response;"); templateBuilder.AppendLine("using System.Collections.Generic;"); templateBuilder.AppendLine("using System.Threading.Tasks;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Domain.Entity;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Domain.Model;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Inject;"); templateBuilder.AppendLine(""); templateBuilder.AppendLine("namespace $$PROJECTNAME$$.Business.Interfaces"); templateBuilder.AppendLine("{"); templateBuilder.AppendLine(" public interface I$$TABLENAME$$Service : ITransientInject"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// 添加单个对象"); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" Task<ResultJsonInfo<$$TABLENAME$$ResponseModel>> AddAsync($$TABLENAME$$AddModel model);"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// 修改单个对象"); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" Task<ResultJsonInfo<$$TABLENAME$$ResponseModel>> ModifyAsync($$TABLENAME$$Model model);"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// 获取单个对象"); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" Task<ResultJsonInfo<$$TABLENAME$$ResponseModel>> InfoAsync($$TABLENAME$$ConditionModel model);"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// 获取对象列表"); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" Task<ResultJsonInfo<List<$$TABLENAME$$ResponseModel>>> InfosAsync($$TABLENAME$$ConditionModel model);"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine("}"); return(BusinessBuilderCore.BuildAll(templateBuilder.ToString(), name)); }
public static string BuildRepImplement(string name) { var templateBuilder = new StringBuilder(); templateBuilder.AppendLine("using JZFZ.Infrastructure.Data.DapperExtensions;"); templateBuilder.AppendLine("using System.Collections.Generic;"); templateBuilder.AppendLine("using System.Linq;"); templateBuilder.AppendLine("using System.Threading.Tasks;"); templateBuilder.AppendLine("using AutoMapper;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Config;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Domain.Entity;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Domain.Model;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Inject;"); templateBuilder.AppendLine(""); templateBuilder.AppendLine("namespace $$PROJECTNAME$$.Repository.Interface"); templateBuilder.AppendLine("{"); templateBuilder.AppendLine("public class $$TABLENAME$$Rep : AbstractRepository<$$TABLENAME$$Entity>, I$$TABLENAME$$Rep"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" private readonly IMapper _mapper;"); templateBuilder.AppendLine(" public $$TABLENAME$$Rep(IConnectionConfig connectionConfig, IMapper mapper)"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" SetDbType(DbType.SqlServer);"); templateBuilder.AppendLine(" ConnectionString = connectionConfig.GetJZCADConnection();"); templateBuilder.AppendLine(" SlaveConnectionString = connectionConfig.GetJZCADConnection();"); templateBuilder.AppendLine(" this._mapper = mapper;"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// 添加实体"); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" public async Task<$$TABLENAME$$Entity> AddAsync($$TABLENAME$$AddModel model)"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" var addItem = _mapper.Map<$$TABLENAME$$Entity>(model); "); templateBuilder.AppendLine(" await InsertAsync(addItem);"); templateBuilder.AppendLine(" return addItem;"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// 修改实体"); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" public async Task<$$TABLENAME$$Entity> ModifyAsync($$TABLENAME$$Model model)"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" var dbItem = await GetAsync(model);"); templateBuilder.AppendLine(" await UpdateAsync(dbItem);"); templateBuilder.AppendLine(" return dbItem;"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// 获取单个对象"); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" public async Task<$$TABLENAME$$Entity> InfoAsync($$TABLENAME$$ConditionModel model)"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" var items = await GetListAsync(\"\");"); templateBuilder.AppendLine(" return items.FirstOrDefault();"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// 获取对象列表"); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" public async Task<List<$$TABLENAME$$Entity>> InfosAsync($$TABLENAME$$ConditionModel model)"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" var items = await GetListAsync(\"\");"); templateBuilder.AppendLine(" return items.ToList();"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine(" }"); return(BusinessBuilderCore.BuildAll(templateBuilder.ToString(), name)); }
public static string BuildController(string name) { var templateBuilder = new StringBuilder(); templateBuilder.AppendLine("using System.Collections.Generic;"); templateBuilder.AppendLine("using System.Threading.Tasks;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Business.Interfaces;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Domain.Entity;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Domain.Request;"); templateBuilder.AppendLine("using JZFZ.Infrastructure.Common.Model.Response;"); templateBuilder.AppendLine("using Microsoft.AspNetCore.Mvc;"); templateBuilder.AppendLine("namespace $$PROJECTNAME$$.WebAPI2.Controllers"); templateBuilder.AppendLine("{"); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// "); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" [ApiController]"); templateBuilder.AppendLine(" [Route(\"[controller]\")]"); templateBuilder.AppendLine(" public class $$TABLENAME$$Controller"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" private readonly I$$TABLENAME$$Service _$$PARAMETERNAME$$Service;"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// "); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" public $$TABLENAME$$Controller(I$$TABLENAME$$Service $$PARAMETERNAME$$Service)"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" this._$$PARAMETERNAME$$Service = $$PARAMETERNAME$$Service;"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// "); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" [HttpPost]"); templateBuilder.AppendLine(" [Route(\"Add\")]"); templateBuilder.AppendLine(" public async Task<ResultJsonInfo<$$TABLENAME$$Entity>> AddAsync($$TABLENAME$$AddModel model)"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" return await _$$PARAMETERNAME$$Service.AddAsync(model);"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// "); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" [HttpPost]"); templateBuilder.AppendLine(" [Route(\"Modify\")]"); templateBuilder.AppendLine(" public async Task<ResultJsonInfo<$$TABLENAME$$Entity>> ModifyAsync($$TABLENAME$$Model model)"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" return await _$$PARAMETERNAME$$Service.ModifyAsync(model);"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// "); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" [HttpPost]"); templateBuilder.AppendLine(" [Route(\"Info\")]"); templateBuilder.AppendLine(" public async Task<ResultJsonInfo<$$TABLENAME$$Entity>> InfoAsync($$TABLENAME$$ConditionModel model)"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" return await _$$PARAMETERNAME$$Service.InfoAsync(model);"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// "); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" [HttpPost]"); templateBuilder.AppendLine(" [Route(\"Infos\")]"); templateBuilder.AppendLine(" public async Task<ResultJsonInfo<List<$$TABLENAME$$Entity>>> InfosAsync($$TABLENAME$$ConditionModel model)"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" return await _$$PARAMETERNAME$$Service.InfosAsync(model);"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine("}"); return(BusinessBuilderCore.BuildAll(templateBuilder.ToString(), name)); }
public static void Init(string projectName) { BusinessBuilderCore.SetProjectName(projectName); }
public static string BuildServiceImplement(string name) { var templateBuilder = new StringBuilder(); templateBuilder.AppendLine("using JZFZ.Infrastructure.Common.Model.Response;"); templateBuilder.AppendLine("using System.Collections.Generic;"); templateBuilder.AppendLine("using System.Threading.Tasks;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Business.Interfaces;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Domain.Entity;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Domain.Model;"); templateBuilder.AppendLine("using $$PROJECTNAME$$.Repository.Interface;"); templateBuilder.AppendLine("namespace $$PROJECTNAME$$.Business.Implement"); templateBuilder.AppendLine("{"); templateBuilder.AppendLine(" public class $$TABLENAME$$Service : I$$TABLENAME$$Service"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" private readonly I$$TABLENAME$$Rep _$$PARAMETERNAME$$Rep;"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" public $$TABLENAME$$Service(I$$TABLENAME$$Rep $$PARAMETERNAME$$Rep)"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" _$$PARAMETERNAME$$Rep = $$PARAMETERNAME$$Rep;"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// 添加单个对象"); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" public async Task<ResultJsonInfo<$$TABLENAME$$ResponseModel>> AddAsync($$TABLENAME$$AddModel model)"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" var entityItem = await _$$PARAMETERNAME$$Rep.AddAsync(model);"); templateBuilder.AppendLine(" return ResultJsonInfo<$$TABLENAME$$ResponseModel>.GetSucceedObject(entityItem);"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// 修改单个对象"); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" public async Task<ResultJsonInfo<$$TABLENAME$$ResponseModel>> ModifyAsync($$TABLENAME$$Model model)"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" var entityItem = await _$$PARAMETERNAME$$Rep.ModifyAsync(model);"); templateBuilder.AppendLine(" return ResultJsonInfo<$$TABLENAME$$ResponseModel>.GetSucceedObject(entityItem);"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// 获取单个对象"); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" public async Task<ResultJsonInfo<$$TABLENAME$$ResponseModel>> InfoAsync($$TABLENAME$$ConditionModel model)"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" var entityItem = await _$$PARAMETERNAME$$Rep.InfoAsync(model);"); templateBuilder.AppendLine(" return ResultJsonInfo<$$TABLENAME$$ResponseModel>.GetSucceedObject(entityItem);"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine(""); templateBuilder.AppendLine(""); templateBuilder.AppendLine(" /// <summary>"); templateBuilder.AppendLine(" /// 获取对象列表"); templateBuilder.AppendLine(" /// </summary>"); templateBuilder.AppendLine(" /// <param name=\"model\"></param>"); templateBuilder.AppendLine(" /// <returns></returns>"); templateBuilder.AppendLine(" public async Task<ResultJsonInfo<List<$$TABLENAME$$ResponseModel>>> InfosAsync($$TABLENAME$$ConditionModel model)"); templateBuilder.AppendLine(" {"); templateBuilder.AppendLine(" var entityItem = await _$$PARAMETERNAME$$Rep.InfosAsync(model);"); templateBuilder.AppendLine(" return ResultJsonInfo<List<$$TABLENAME$$ResponseModel>>.GetSucceedObject(entityItem);"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine(" }"); templateBuilder.AppendLine("}"); return(BusinessBuilderCore.BuildAll(templateBuilder.ToString(), name)); }