删除、优化之前的表名、表字段名 调用数据库函数代码
continuous-integration/drone/push Build is passing Details

IRC_NewDev
hang 2024-08-30 09:15:26 +08:00
parent 5ccfe70f97
commit 6276e0611a
3 changed files with 1107 additions and 1097 deletions

View File

@ -0,0 +1,30 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IRaCIS.Core.Application.Service.Common
{
/// <summary>
/// 开始时候一些帮助 比如根据配置的字典生成枚举
/// </summary>
/// <param name="_dictionaryRepository"></param>
[ApiExplorerSettings(GroupName = "Common")]
public class DevelopService(IRepository<Dictionary> _dictionaryRepository) : BaseService
{
/// <summary>
/// 根据配置的字典名生成后端枚举
/// </summary>
/// <param name="dicName"></param>
/// <returns></returns>
[HttpPost]
public async Task<IResponseOutput> BackDicGenerateEnum(string dicName)
{
return ResponseOutput.Ok();
}
}
}

View File

@ -71,14 +71,6 @@ namespace IRaCIS.Core.Infra.EFCore
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)
{ {
modelBuilder.Entity<TableList>(builder =>
{
builder.HasBaseType((Type)null);
builder.ToView(null);
builder.HasNoKey();
});
//遍历实体模型手动配置 //遍历实体模型手动配置
var typesToRegister = Assembly.GetExecutingAssembly().GetTypes().Where(q => q.GetInterface(typeof(IEntityTypeConfiguration<>).FullName) != null); var typesToRegister = Assembly.GetExecutingAssembly().GetTypes().Where(q => q.GetInterface(typeof(IEntityTypeConfiguration<>).FullName) != null);
@ -107,16 +99,7 @@ namespace IRaCIS.Core.Infra.EFCore
} }
#region 存储过程或者视图 #region 获取表名 和字段名 优化
public IQueryable<TableList> GetTableList()
{
return Set<TableList>().FromSqlRaw("EXEC dbo.procGetTableList");
}
public IQueryable<TableList> GetTableColumn(string tableName)
{
return Set<TableList>().FromSqlRaw($"EXEC dbo.procGetTableColumn {tableName}");
}
/// <summary> /// <summary>
/// 直接获取代码定义的模型以及表上定义的Description 获取表信息 以及备注 /// 直接获取代码定义的模型以及表上定义的Description 获取表信息 以及备注
@ -167,21 +150,18 @@ namespace IRaCIS.Core.Infra.EFCore
tableColumList.Add(new TableList tableColumList.Add(new TableList
{ {
Name = tableName, Name = columnName,
Remake = columnDescription, Remake = columnDescription,
}); });
} }
return tableColumList.OrderBy(t=>t.Name).ToList();
return tableColumList;
} }
#endregion #endregion
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken()) public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
{ {
// 采用触发器的方式 设置 CreateUserId CreateTime UpdateTime UpdateUserId 稽查实体里面没有这四个字段的值 因为先后顺序的原因 // 采用触发器的方式 设置 CreateUserId CreateTime UpdateTime UpdateUserId 稽查实体里面没有这四个字段的值 因为先后顺序的原因
await AddAudit(); await AddAudit();