删除、优化之前的表名、表字段名 调用数据库函数代码
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

@ -45,9 +45,9 @@ namespace IRaCIS.Core.Application.Service
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<List<TableList>> GetDatabaseTables()
public List<TableList> GetDatabaseTables()
{
return await _frontAuditConfigRepository._dbContext.GetTableList().ToListAsync();
return _frontAuditConfigRepository._dbContext.GetContextTablesList();
}
/// <summary>
@ -105,9 +105,9 @@ namespace IRaCIS.Core.Application.Service
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<List<TableList>> GetTableColumn(string tableName)
public List<TableList> GetTableColumn(string tableName)
{
return await _frontAuditConfigRepository._dbContext.GetTableColumn(tableName).ToListAsync();
return _frontAuditConfigRepository._dbContext.GetContextTableColumnList(tableName);
}
/// <summary>
@ -684,9 +684,9 @@ namespace IRaCIS.Core.Application.Service
{
// 兼容之前数组的那种方式 实际配置只会配置一条
specialDynamicColumnValueList = tableConfigList.Where(t => t.IsDynamicTranslate && t.IsList == false)
.Select(t => t.ColumnValue ).Distinct().ToList();
.Select(t => t.ColumnValue).Distinct().ToList();
var dicNames= arrays.Where(t=>!string.IsNullOrEmpty( t["DictionaryCode"].ToString()) ).Select(t => t["DictionaryCode"].ToString()).Distinct().ToList();
var dicNames = arrays.Where(t => !string.IsNullOrEmpty(t["DictionaryCode"].ToString())).Select(t => t["DictionaryCode"].ToString()).Distinct().ToList();
dictionaryNameList.AddRange(dicNames);
}
@ -710,7 +710,7 @@ namespace IRaCIS.Core.Application.Service
foreach (var translateInfo in translateInfoList)
{
//Json 解析后 true 变为了True
jsonObject[translateInfo.ColumnValue] = translateDataList[translateInfo.TranslateDictionaryName].Where(t => t.Code.ToLower() == jsonObject[translateInfo.ColumnValue]?.ToString().ToLower()).Select(t => _userInfo.IsEn_Us?t.Value: t.ValueCN).FirstOrDefault();
jsonObject[translateInfo.ColumnValue] = translateDataList[translateInfo.TranslateDictionaryName].Where(t => t.Code.ToLower() == jsonObject[translateInfo.ColumnValue]?.ToString().ToLower()).Select(t => _userInfo.IsEn_Us ? t.Value : t.ValueCN).FirstOrDefault();
}
foreach (var specialDynamicColumnValue in specialDynamicColumnValueList)
@ -863,7 +863,7 @@ namespace IRaCIS.Core.Application.Service
{
var data = value.ToString().Split('|').ToList();
var codeList= await _dictionaryRepository.Where(x => x.Code == item.Code).Join(_dictionaryRepository.Where(x => data.Contains(x.Code)), a => a.Id, b => b.ParentId, (a, b) => new
var codeList = await _dictionaryRepository.Where(x => x.Code == item.Code).Join(_dictionaryRepository.Where(x => data.Contains(x.Code)), a => a.Id, b => b.ParentId, (a, b) => new
{
value = _userInfo.IsEn_Us ? b.Value : b.ValueCN
}).Select(x => x.value).ToListAsync();
@ -1014,7 +1014,7 @@ namespace IRaCIS.Core.Application.Service
var additem = await _frontAuditConfigRepository.FirstOrDefaultAsync(x => x.Id == item.AddItemGuid);
//跟踪的方式查询,直接修改,然后保存数据库
var alllist = _frontAuditConfigRepository.Where(x => item.DataSourceGuids.Contains(x.ParentId),true).ToList().GroupBy(x => new { x.ValueCN }, (key, lst) => new FrontAuditConfig
var alllist = _frontAuditConfigRepository.Where(x => item.DataSourceGuids.Contains(x.ParentId), true).ToList().GroupBy(x => new { x.ValueCN }, (key, lst) => new FrontAuditConfig
{
Sort = lst.Select(x => x.Sort).FirstOrDefault(),
TableConfigJsonStr = lst.Select(x => x.TableConfigJsonStr).FirstOrDefault(),
@ -1100,8 +1100,8 @@ namespace IRaCIS.Core.Application.Service
[HttpGet]
public async Task<List<string>> GetModuleTypeDescriptionList(Guid moduleTypeId)
{
var result =( await _frontAuditConfigRepository.Where(x => x.ModuleTypeId == moduleTypeId && x.ObjectTypeId != null && x.OptTypeId != null && x.Description.Length > 0).Select(x => new { x.Description, x.DescriptionCN, x.Sort }).OrderBy(t => t.Sort).ToListAsync()
).Select(t => _userInfo.IsEn_Us? t.Description:t.DescriptionCN).Distinct().ToList();
var result = (await _frontAuditConfigRepository.Where(x => x.ModuleTypeId == moduleTypeId && x.ObjectTypeId != null && x.OptTypeId != null && x.Description.Length > 0).Select(x => new { x.Description, x.DescriptionCN, x.Sort }).OrderBy(t => t.Sort).ToListAsync()
).Select(t => _userInfo.IsEn_Us ? t.Description : t.DescriptionCN).Distinct().ToList();
return result;
}
@ -1131,7 +1131,7 @@ namespace IRaCIS.Core.Application.Service
CreateTime = data.CreateTime,
CreateUserId = data.CreateUserId,
Description = data.Description,
DescriptionCN=data.DescriptionCN,
DescriptionCN = data.DescriptionCN,
IsConfig = data.IsConfig,
IsEnable = data.IsEnable,
ModuleTypeId = data.ModuleTypeId,

View File

@ -71,14 +71,6 @@ namespace IRaCIS.Core.Infra.EFCore
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);
@ -107,16 +99,7 @@ namespace IRaCIS.Core.Infra.EFCore
}
#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}");
}
#region 获取表名 和字段名 优化
/// <summary>
/// 直接获取代码定义的模型以及表上定义的Description 获取表信息 以及备注
@ -167,21 +150,18 @@ namespace IRaCIS.Core.Infra.EFCore
tableColumList.Add(new TableList
{
Name = tableName,
Name = columnName,
Remake = columnDescription,
});
}
return tableColumList;
return tableColumList.OrderBy(t=>t.Name).ToList();
}
#endregion
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
{
// 采用触发器的方式 设置 CreateUserId CreateTime UpdateTime UpdateUserId 稽查实体里面没有这四个字段的值 因为先后顺序的原因
await AddAudit();