Files
Yi.Admin/Yi.Furion.Net6/Yi.Framework.Module/WebFirstManager/Impl/WebFirstService.cs

85 lines
2.6 KiB
C#
Raw Normal View History

2023-06-10 13:53:00 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2023-09-24 00:42:09 +08:00
using Furion.DatabaseAccessor;
2023-09-19 23:48:37 +08:00
using Furion.DependencyInjection;
using Furion.DynamicApiController;
2023-06-10 13:53:00 +08:00
using Mapster;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
2023-09-19 23:48:37 +08:00
using Microsoft.AspNetCore.Mvc;
2023-06-10 13:53:00 +08:00
using Yi.Framework.Infrastructure.Ddd.Repositories;
using Yi.Framework.Infrastructure.Ddd.Services;
2023-09-21 19:55:55 +08:00
using Yi.Framework.Module.WebFirstManager.Domain;
2023-09-19 23:48:37 +08:00
using Yi.Framework.Module.WebFirstManager.Dtos.WebFirst;
2023-06-10 13:53:00 +08:00
using Yi.Framework.Module.WebFirstManager.Entities;
namespace Yi.Framework.Module.WebFirstManager.Impl
{
2023-09-19 23:48:37 +08:00
[ApiDescriptionSettings("WebFirstManager")]
2023-09-21 00:04:55 +08:00
public class WebFirstService : ApplicationService, IWebFirstService, IDynamicApiController, ITransient
2023-06-10 13:53:00 +08:00
{
2023-09-24 00:42:09 +08:00
private IRepository<TableAggregateRoot> _tableRepository;
private CodeFileManager _codeFileManager;
private WebTemplateManager _webTemplateManager;
public WebFirstService(IRepository<TableAggregateRoot> tableRepository, CodeFileManager codeFileManager, WebTemplateManager webTemplateManager)
2023-09-21 00:04:55 +08:00
{
2023-09-21 19:55:55 +08:00
_tableRepository = tableRepository;
2023-09-24 00:42:09 +08:00
_codeFileManager = codeFileManager;
_webTemplateManager= webTemplateManager;
2023-09-21 00:04:55 +08:00
}
2023-06-10 13:53:00 +08:00
/// <summary>
2023-09-22 10:25:05 +08:00
/// Web To Code
2023-06-10 13:53:00 +08:00
/// </summary>
/// <returns></returns>
2023-09-22 10:25:05 +08:00
public async Task PostWebBuildCodeAsync()
2023-06-10 13:53:00 +08:00
{
2023-09-21 19:55:55 +08:00
//获取全部表
var tables = await _tableRepository.GetListAsync();
foreach (var table in tables)
{
2023-09-24 00:42:09 +08:00
await _codeFileManager.BuildWebToCodeAsync(table);
2023-09-21 19:55:55 +08:00
}
2023-06-10 13:53:00 +08:00
}
2023-09-21 19:55:55 +08:00
/// <summary>
2023-09-22 10:25:05 +08:00
/// Web To Db
2023-09-21 19:55:55 +08:00
/// </summary>
/// <returns></returns>
2023-09-22 10:25:05 +08:00
public async Task PostWebBuildDbAsync()
{
}
/// <summary>
/// Code To Web
/// </summary>
/// <returns></returns>
2023-09-24 00:42:09 +08:00
[UnitOfWork]
2023-09-22 10:25:05 +08:00
public async Task PostCodeBuildWebAsync()
{
2023-09-24 00:42:09 +08:00
var tableAggregateRoots =await _webTemplateManager.BuildCodeToWebAsync();
//覆盖数据库,将聚合根保存到数据库
_tableRepository._Db.DbMaintenance.TruncateTable<TableAggregateRoot>();
_tableRepository._Db.DbMaintenance.TruncateTable<FieldEntity>();
//导航插入即可
await _tableRepository._Db.InsertNav(tableAggregateRoots).Include(x => x.Fields).ExecuteCommandAsync();
2023-09-22 10:25:05 +08:00
}
/// <summary>
/// Code To Db
/// </summary>
/// <returns></returns>
public async Task PostCodeBuildDbAsync()
2023-09-21 00:04:55 +08:00
{
2023-09-21 19:55:55 +08:00
}
2023-06-10 13:53:00 +08:00
}
}