删除、优化之前的表名、表字段名 调用数据库函数代码
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
5ccfe70f97
commit
6276e0611a
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,9 +45,9 @@ namespace IRaCIS.Core.Application.Service
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<List<TableList>> GetDatabaseTables()
|
public List<TableList> GetDatabaseTables()
|
||||||
{
|
{
|
||||||
return await _frontAuditConfigRepository._dbContext.GetTableList().ToListAsync();
|
return _frontAuditConfigRepository._dbContext.GetContextTablesList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -105,9 +105,9 @@ namespace IRaCIS.Core.Application.Service
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[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>
|
/// <summary>
|
||||||
|
@ -684,9 +684,9 @@ namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
// 兼容之前数组的那种方式 实际配置只会配置一条
|
// 兼容之前数组的那种方式 实际配置只会配置一条
|
||||||
specialDynamicColumnValueList = tableConfigList.Where(t => t.IsDynamicTranslate && t.IsList == false)
|
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);
|
dictionaryNameList.AddRange(dicNames);
|
||||||
}
|
}
|
||||||
|
@ -710,7 +710,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
foreach (var translateInfo in translateInfoList)
|
foreach (var translateInfo in translateInfoList)
|
||||||
{
|
{
|
||||||
//Json 解析后 true 变为了True
|
//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)
|
foreach (var specialDynamicColumnValue in specialDynamicColumnValueList)
|
||||||
|
@ -863,7 +863,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
var data = value.ToString().Split('|').ToList();
|
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
|
value = _userInfo.IsEn_Us ? b.Value : b.ValueCN
|
||||||
}).Select(x => x.value).ToListAsync();
|
}).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 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(),
|
Sort = lst.Select(x => x.Sort).FirstOrDefault(),
|
||||||
TableConfigJsonStr = lst.Select(x => x.TableConfigJsonStr).FirstOrDefault(),
|
TableConfigJsonStr = lst.Select(x => x.TableConfigJsonStr).FirstOrDefault(),
|
||||||
|
@ -1100,8 +1100,8 @@ namespace IRaCIS.Core.Application.Service
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<List<string>> GetModuleTypeDescriptionList(Guid moduleTypeId)
|
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()
|
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();
|
).Select(t => _userInfo.IsEn_Us ? t.Description : t.DescriptionCN).Distinct().ToList();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1131,7 +1131,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
CreateTime = data.CreateTime,
|
CreateTime = data.CreateTime,
|
||||||
CreateUserId = data.CreateUserId,
|
CreateUserId = data.CreateUserId,
|
||||||
Description = data.Description,
|
Description = data.Description,
|
||||||
DescriptionCN=data.DescriptionCN,
|
DescriptionCN = data.DescriptionCN,
|
||||||
IsConfig = data.IsConfig,
|
IsConfig = data.IsConfig,
|
||||||
IsEnable = data.IsEnable,
|
IsEnable = data.IsEnable,
|
||||||
ModuleTypeId = data.ModuleTypeId,
|
ModuleTypeId = data.ModuleTypeId,
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue