feat: 完善webfirst模板及表模块

This commit is contained in:
陈淳
2023-09-21 19:55:55 +08:00
parent 18eb3a7fbf
commit 710bb97cd3
13 changed files with 110 additions and 88 deletions

View File

@@ -10,6 +10,7 @@ using Microsoft.AspNetCore.DataProtection.KeyManagement;
using Microsoft.AspNetCore.Mvc;
using Yi.Framework.Infrastructure.Ddd.Repositories;
using Yi.Framework.Infrastructure.Ddd.Services;
using Yi.Framework.Module.WebFirstManager.Domain;
using Yi.Framework.Module.WebFirstManager.Dtos.WebFirst;
using Yi.Framework.Module.WebFirstManager.Entities;
@@ -18,34 +19,52 @@ namespace Yi.Framework.Module.WebFirstManager.Impl
[ApiDescriptionSettings("WebFirstManager")]
public class WebFirstService : ApplicationService, IWebFirstService, IDynamicApiController, ITransient
{
private IRepository<TemplateEntity> _repository;
private IRepository<TemplateVarEntity> _varRepository;
public WebFirstService(IRepository<TemplateEntity> repository, IRepository<TemplateVarEntity> varRepository)
private IRepository<TableEntity> _tableRepository;
private TemplateManager _templateManager;
public WebFirstService(IRepository<TableEntity> tableRepository, TemplateManager templateManager)
{
_repository = repository;
_varRepository = varRepository;
_tableRepository = tableRepository;
_templateManager = templateManager;
}
/// <summary>
/// 一键构建
/// 一键构建生成代码
/// </summary>
/// <returns></returns>
public async Task PostBuildAsync()
public async Task PostBuildCodeAsync()
{
//获取全部模板
var templates = await _repository.GetListAsync();
var varTemps = await _varRepository.GetListAsync();
//获取全部
var tables = await _tableRepository.GetListAsync();
foreach (var table in tables)
{
await BuildSingleTableAsync(table);
}
}
private async Task BuildSingleAsync(TemplateEntity template, List<TemplateVarEntity> templateVars)
/// <summary>
/// 一键构建生成表
/// </summary>
/// <returns></returns>
public async Task PostBuildTableAsync()
{
foreach (var tempVar in templateVars)
template.TemplateStr.Replace(tempVar.Value, "model");
}
/// <summary>
/// 每次去构建一张表的数据
/// </summary>
/// <param name="table"></param>
/// <returns></returns>
private async Task BuildSingleTableAsync(TableEntity table)
{
await _templateManager.HandlerAsync(table);
}
}
}