Merge branch 'master' of http://192.168.1.2:8033/IRaCIS_Core_Api
commit
8683273022
|
@ -11,6 +11,8 @@ using MassTransit;
|
||||||
using MassTransit.NewIdProviders;
|
using MassTransit.NewIdProviders;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
using IRaCIS.Core.Infra.EFCore;
|
||||||
|
using IRaCIS.Core.Application.Helper;
|
||||||
|
|
||||||
namespace IRaCIS.Core.API
|
namespace IRaCIS.Core.API
|
||||||
{
|
{
|
||||||
|
@ -64,9 +66,7 @@ namespace IRaCIS.Core.API
|
||||||
//缓存项目的状态 匿名化数据
|
//缓存项目的状态 匿名化数据
|
||||||
await InitCache(host);
|
await InitCache(host);
|
||||||
|
|
||||||
WatchJsonFile(Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources, StaticData.En_US_Json) );
|
|
||||||
|
|
||||||
WatchJsonFile(Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources, StaticData.Zh_CN_Json));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,54 +104,24 @@ namespace IRaCIS.Core.API
|
||||||
|
|
||||||
private static async Task InitCache(IHost host)
|
private static async Task InitCache(IHost host)
|
||||||
{
|
{
|
||||||
|
var _repository = host.Services.GetService(typeof(IRepository)) as IRepository;
|
||||||
|
|
||||||
|
//初始化 国际化数据,并且监测国际化文件变更
|
||||||
|
await InternationalizationHelper.InitInternationlizationDataAndWatchJsonFileAsync(_repository);
|
||||||
|
|
||||||
var _mediator = host.Services.GetService(typeof(IMediator)) as IMediator;
|
var _mediator = host.Services.GetService(typeof(IMediator)) as IMediator;
|
||||||
|
|
||||||
await _mediator.Send(new AnonymizeCacheRequest());
|
await _mediator.Send(new AnonymizeCacheRequest());
|
||||||
|
|
||||||
await _mediator.Send(new TrialStateCacheRequest());
|
await _mediator.Send(new TrialStateCacheRequest());
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static void LoadJsonFile(string filePath)
|
|
||||||
{
|
|
||||||
|
|
||||||
IConfigurationBuilder builder = new ConfigurationBuilder()
|
|
||||||
.AddJsonFile(filePath);
|
|
||||||
|
|
||||||
IConfigurationRoot enConfiguration = builder.Build();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach (IConfigurationSection section in enConfiguration.GetChildren())
|
|
||||||
{
|
|
||||||
if (filePath.Contains(StaticData.En_US_Json) )
|
|
||||||
{
|
|
||||||
StaticData.En_US_Dic[section.Key] = section.Value;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
StaticData.Zh_CN_Dic[section.Key] = section.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public static void WatchJsonFile(string filePath)
|
|
||||||
{
|
|
||||||
LoadJsonFile(filePath);
|
|
||||||
|
|
||||||
|
|
||||||
FileSystemWatcher watcher = new FileSystemWatcher(Path.GetDirectoryName(filePath), Path.GetFileName(filePath));
|
|
||||||
watcher.Changed += (sender, e) => LoadJsonFile(filePath);
|
|
||||||
watcher.EnableRaisingEvents = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Application.ViewModel;
|
||||||
|
using IRaCIS.Core.Domain.Share;
|
||||||
using IRaCIS.Core.Infrastructure;
|
using IRaCIS.Core.Infrastructure;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -13,32 +16,164 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
{
|
{
|
||||||
public static class InternationalizationHelper
|
public static class InternationalizationHelper
|
||||||
{
|
{
|
||||||
|
public static string JsonFileFolder = Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources);
|
||||||
|
|
||||||
public static async void AddOrUpdateJsonKeyValueAsync(string key, string value)
|
private static void VerifyFolder()
|
||||||
{
|
{
|
||||||
|
if (!Directory.Exists(JsonFileFolder) ||
|
||||||
var jsonFileFolder = Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources);
|
Directory.GetFiles(JsonFileFolder).Any(filePath => Path.GetExtension(filePath).Equals(".json", StringComparison.OrdinalIgnoreCase)))
|
||||||
|
|
||||||
if (!Directory.Exists(jsonFileFolder) ||
|
|
||||||
Directory.GetFiles(jsonFileFolder).Any(filePath => Path.GetExtension(filePath).Equals(".json", StringComparison.OrdinalIgnoreCase)))
|
|
||||||
{
|
{
|
||||||
throw new BusinessValidationFailedException("国际化Json文件目录有误");
|
throw new BusinessValidationFailedException("国际化Json文件目录有误");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
public static async Task BatchAddJsonKeyValueAsync(List<BatchAddInternationalizationDto> batchAddDtos)
|
||||||
foreach (var filePath in Directory.GetFiles(jsonFileFolder).Where(filePath => Path.GetExtension(filePath).Equals(".json", StringComparison.OrdinalIgnoreCase)))
|
{
|
||||||
|
VerifyFolder();
|
||||||
|
|
||||||
|
var usJsonPath = Path.Combine(JsonFileFolder, StaticData.En_US_Json);
|
||||||
|
var cnJsonPath = Path.Combine(JsonFileFolder, StaticData.Zh_CN_Json);
|
||||||
|
|
||||||
|
|
||||||
|
//更新json 文件 同时更新内存缓存的数据
|
||||||
|
foreach (var filePath in new string[] { usJsonPath, cnJsonPath })
|
||||||
{
|
{
|
||||||
var json = await File.ReadAllTextAsync(filePath);
|
var json = await File.ReadAllTextAsync(filePath);
|
||||||
|
|
||||||
JObject jsonObject = JObject.Parse(json, new JsonLoadSettings() { CommentHandling = CommentHandling.Load });
|
JObject jsonObject = JObject.Parse(json, new JsonLoadSettings() { CommentHandling = CommentHandling.Load });
|
||||||
|
|
||||||
// 添加或更新指定的键值对
|
// 添加或更新指定的键值对
|
||||||
|
|
||||||
|
if (filePath.Contains(StaticData.En_US_Json))
|
||||||
|
{
|
||||||
|
foreach (var item in batchAddDtos)
|
||||||
|
{
|
||||||
|
jsonObject[item.Code] = item.Value;
|
||||||
|
|
||||||
|
StaticData.En_US_Dic[item.Code] = item.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var item in batchAddDtos)
|
||||||
|
{
|
||||||
|
jsonObject[item.Code] = item.Value;
|
||||||
|
|
||||||
|
StaticData.Zh_CN_Dic[item.Code] = item.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
await File.WriteAllTextAsync(filePath, jsonObject.ToString());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task AddOrUpdateJsonKeyValueAsync(string key, string value, string valueCN)
|
||||||
|
{
|
||||||
|
|
||||||
|
VerifyFolder();
|
||||||
|
|
||||||
|
var usJsonPath = Path.Combine(JsonFileFolder, StaticData.En_US_Json);
|
||||||
|
var cnJsonPath = Path.Combine(JsonFileFolder, StaticData.Zh_CN_Json);
|
||||||
|
|
||||||
|
|
||||||
|
//更新json 文件 同时更新内存缓存的数据
|
||||||
|
foreach (var filePath in new string[] { usJsonPath, cnJsonPath })
|
||||||
|
{
|
||||||
|
var json = await File.ReadAllTextAsync(filePath);
|
||||||
|
|
||||||
|
JObject jsonObject = JObject.Parse(json, new JsonLoadSettings() { CommentHandling = CommentHandling.Load });
|
||||||
|
|
||||||
|
// 添加或更新指定的键值对
|
||||||
|
|
||||||
|
if (filePath.Contains(StaticData.En_US_Json))
|
||||||
|
{
|
||||||
jsonObject[key] = value;
|
jsonObject[key] = value;
|
||||||
|
|
||||||
|
StaticData.En_US_Dic[key] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jsonObject[key] = valueCN;
|
||||||
|
|
||||||
|
StaticData.Zh_CN_Dic[key] = valueCN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
await File.WriteAllTextAsync(filePath, jsonObject.ToString());
|
await File.WriteAllTextAsync(filePath, jsonObject.ToString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task InitInternationlizationDataAndWatchJsonFileAsync(IRepository _repository)
|
||||||
|
{
|
||||||
|
//查询数据库的数据
|
||||||
|
var toJsonList = await _repository.Where<Internationalization>(t => t.InternationalizationType == 1).Select(t => new
|
||||||
|
{
|
||||||
|
t.Code,
|
||||||
|
t.Value,
|
||||||
|
t.ValueCN
|
||||||
|
}).ToListAsync();
|
||||||
|
|
||||||
|
//组织成json 文件
|
||||||
|
|
||||||
|
var usJsonPath = Path.Combine(JsonFileFolder, StaticData.En_US_Json);
|
||||||
|
var cnJsonPath = Path.Combine(JsonFileFolder, StaticData.Zh_CN_Json);
|
||||||
|
|
||||||
|
|
||||||
|
//本地静态文件国际化需要
|
||||||
|
foreach (var tojsonItem in toJsonList)
|
||||||
|
{
|
||||||
|
StaticData.En_US_Dic[tojsonItem.Code] = tojsonItem.Value;
|
||||||
|
StaticData.Zh_CN_Dic[tojsonItem.Code] = tojsonItem.ValueCN;
|
||||||
|
}
|
||||||
|
|
||||||
|
File.WriteAllText(usJsonPath, JsonConvert.SerializeObject(StaticData.En_US_Dic));
|
||||||
|
File.WriteAllText(cnJsonPath, JsonConvert.SerializeObject(StaticData.Zh_CN_Dic));
|
||||||
|
|
||||||
|
|
||||||
|
//监测Json文件变更 实时刷新数据
|
||||||
|
|
||||||
|
WatchJsonFile(usJsonPath);
|
||||||
|
WatchJsonFile(cnJsonPath);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WatchJsonFile(string filePath)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filePath))
|
||||||
|
{
|
||||||
|
throw new BusinessValidationFailedException("国际化Json文件不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
FileSystemWatcher watcher = new FileSystemWatcher(Path.GetDirectoryName(filePath), Path.GetFileName(filePath));
|
||||||
|
watcher.Changed += (sender, e) => LoadJsonFile(filePath);
|
||||||
|
watcher.EnableRaisingEvents = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void LoadJsonFile(string filePath)
|
||||||
|
{
|
||||||
|
|
||||||
|
IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile(filePath);
|
||||||
|
|
||||||
|
IConfigurationRoot enConfiguration = builder.Build();
|
||||||
|
|
||||||
|
foreach (IConfigurationSection section in enConfiguration.GetChildren())
|
||||||
|
{
|
||||||
|
if (filePath.Contains(StaticData.En_US_Json))
|
||||||
|
{
|
||||||
|
StaticData.En_US_Dic[section.Key] = section.Value;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StaticData.Zh_CN_Dic[section.Key] = section.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10936,6 +10936,13 @@
|
||||||
<param name="addOrEditBasic"></param>
|
<param name="addOrEditBasic"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:IRaCIS.Application.Services.DictionaryService.AddBasicDicAndChild(IRaCIS.Application.Contracts.AddBasicDicAndChild)">
|
||||||
|
<summary>
|
||||||
|
添加字典 的同时 一起添加子项 --New
|
||||||
|
</summary>
|
||||||
|
<param name="addBasicDicAndChild"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:IRaCIS.Application.Services.DictionaryService.GetBasicDicList(IRaCIS.Application.Contracts.BasicDicQuery)">
|
<member name="M:IRaCIS.Application.Services.DictionaryService.GetBasicDicList(IRaCIS.Application.Contracts.BasicDicQuery)">
|
||||||
<summary>
|
<summary>
|
||||||
New 查询条件
|
New 查询条件
|
||||||
|
|
|
@ -165,7 +165,40 @@ namespace IRaCIS.Application.Contracts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class AddBasicDicAndChild
|
||||||
|
{
|
||||||
|
[NotDefault]
|
||||||
|
public Guid ConfigTypeId { get; set; }
|
||||||
|
|
||||||
|
public bool IsEnable { get; set; }
|
||||||
|
|
||||||
|
public string Code { get; set; } = String.Empty;
|
||||||
|
|
||||||
|
public int ShowOrder { get; set; }
|
||||||
|
public string Description { get; set; } = String.Empty;
|
||||||
|
|
||||||
|
public DicDataTypeEnum DataTypeEnum { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public List<AddBasicDicChild> ChildList { get; set; } = new List<AddBasicDicChild>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class AddBasicDicChild
|
||||||
|
{
|
||||||
|
public string Code { get; set; } = String.Empty;
|
||||||
|
public string Value { get; set; } = String.Empty;
|
||||||
|
|
||||||
|
public string ValueCN { get; set; } = String.Empty;
|
||||||
|
|
||||||
|
public string ChildGroup { get; set; } = String.Empty;
|
||||||
|
|
||||||
|
public int ShowOrder { get; set; }
|
||||||
|
|
||||||
|
public string Description { get; set; } = String.Empty;
|
||||||
|
|
||||||
|
public bool IsEnable { get; set; } = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,13 +38,37 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||||
public Guid? Id { get; set; }
|
public Guid? Id { get; set; }
|
||||||
public int State { get; set; }
|
public int State { get; set; }
|
||||||
public string Description { get; set; } = string.Empty;
|
public string Description { get; set; } = string.Empty;
|
||||||
public string Code { get; set; }
|
public string Code { get; set; } = string.Empty;
|
||||||
public string Value { get; set; } = string.Empty;
|
public string Value { get; set; } = string.Empty;
|
||||||
public string ValueCN { get; set; } = string.Empty;
|
public string ValueCN { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int InternationalizationType { get; set; }
|
public int InternationalizationType { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class BatchAddInternationalization
|
||||||
|
{
|
||||||
|
public int InternationalizationType { get; set; }
|
||||||
|
|
||||||
|
public int State { get; set; }
|
||||||
|
|
||||||
|
public List<BatchAddInternationalizationDto> AddList { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class BatchAddInternationalizationDto
|
||||||
|
{
|
||||||
|
public string Description { get; set; } = string.Empty;
|
||||||
|
public string Code { get; set; } = string.Empty;
|
||||||
|
public string Value { get; set; } = string.Empty;
|
||||||
|
public string ValueCN { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class InternationalizationSimpleDto
|
||||||
|
{
|
||||||
|
public string Code { get; set; } = string.Empty;
|
||||||
|
public string Value { get; set; } = string.Empty;
|
||||||
|
public string ValueCN { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,39 @@ namespace IRaCIS.Application.Services
|
||||||
return ResponseOutput.Ok(entity.Id.ToString());
|
return ResponseOutput.Ok(entity.Id.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加字典 的同时 一起添加子项 --New
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="addBasicDicAndChild"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IResponseOutput> AddBasicDicAndChild(AddBasicDicAndChild addBasicDicAndChild)
|
||||||
|
{
|
||||||
|
var verifyExp1 = new EntityVerifyExp<Dictionary>()
|
||||||
|
{
|
||||||
|
VerifyExp = t => t.Code == addBasicDicAndChild.Code && t.ParentId == null,
|
||||||
|
VerifyMsg = $"已有{addBasicDicAndChild.Code}名称的字典",
|
||||||
|
IsVerify = true
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var entity = await _dicRepository.InsertFromDTOAsync(addBasicDicAndChild, false, verifyExp1);
|
||||||
|
|
||||||
|
var childList = _mapper.Map<List<Dictionary>>(addBasicDicAndChild.ChildList);
|
||||||
|
|
||||||
|
foreach (var item in childList)
|
||||||
|
{
|
||||||
|
item.DataTypeEnum = addBasicDicAndChild.DataTypeEnum;
|
||||||
|
item.ParentId = entity.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _dicRepository.AddRangeAsync(childList);
|
||||||
|
|
||||||
|
await _dicRepository.SaveChangesAsync();
|
||||||
|
return ResponseOutput.Ok(entity.Id.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// New 查询条件
|
/// New 查询条件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -8,6 +8,9 @@ using IRaCIS.Core.Domain.Models;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using IRaCIS.Core.Application.Interfaces;
|
using IRaCIS.Core.Application.Interfaces;
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
using IRaCIS.Core.Application.ViewModel;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using IRaCIS.Core.Application.Helper;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service
|
namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -24,27 +27,70 @@ namespace IRaCIS.Core.Application.Service
|
||||||
_internationalizationRepository = internationalizationRepository;
|
_internationalizationRepository = internationalizationRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[AllowAnonymous]
|
||||||
|
|
||||||
|
public async Task<List<InternationalizationSimpleDto>> GetFrontInternationalizationList()
|
||||||
|
{
|
||||||
|
|
||||||
|
var list = await _internationalizationRepository.Where(t => t.InternationalizationType == 0).Select(t => new InternationalizationSimpleDto()
|
||||||
|
{
|
||||||
|
Code = t.Code,
|
||||||
|
Value = t.Value,
|
||||||
|
ValueCN = t.ValueCN
|
||||||
|
}).ToListAsync();
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<PageOutput<InternationalizationView>> GetInternationalizationList(InternationalizationQuery inQuery)
|
public async Task<PageOutput<InternationalizationView>> GetInternationalizationList(InternationalizationQuery inQuery)
|
||||||
{
|
{
|
||||||
|
|
||||||
var internationalizationQueryable =_internationalizationRepository
|
var internationalizationQueryable = _internationalizationRepository
|
||||||
.WhereIf(inQuery.Description!=null,t=>t.Description.Contains(inQuery.Description))
|
.WhereIf(inQuery.Description != null, t => t.Description.Contains(inQuery.Description))
|
||||||
.WhereIf(inQuery.Code != null, t => t.Code.Contains(inQuery.Code))
|
.WhereIf(inQuery.Code != null, t => t.Code.Contains(inQuery.Code))
|
||||||
.WhereIf(inQuery.State != null, t => t.State==inQuery.State)
|
.WhereIf(inQuery.State != null, t => t.State == inQuery.State)
|
||||||
.WhereIf(inQuery.InternationalizationType != null, t => t.InternationalizationType == inQuery.InternationalizationType)
|
.WhereIf(inQuery.InternationalizationType != null, t => t.InternationalizationType == inQuery.InternationalizationType)
|
||||||
|
|
||||||
.WhereIf(inQuery.Value != null, t => t.Value.Contains(inQuery.Value))
|
.WhereIf(inQuery.Value != null, t => t.Value.Contains(inQuery.Value))
|
||||||
.WhereIf(inQuery.ValueCN != null, t => t.ValueCN.Contains(inQuery.ValueCN))
|
.WhereIf(inQuery.ValueCN != null, t => t.ValueCN.Contains(inQuery.ValueCN))
|
||||||
.ProjectTo<InternationalizationView>(_mapper.ConfigurationProvider);
|
.ProjectTo<InternationalizationView>(_mapper.ConfigurationProvider);
|
||||||
|
|
||||||
var pageList = await internationalizationQueryable
|
var pageList = await internationalizationQueryable
|
||||||
.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? "Id" : inQuery.SortField,
|
.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? nameof(InternationalizationView.State) : inQuery.SortField,
|
||||||
inQuery.Asc);
|
inQuery.Asc);
|
||||||
|
|
||||||
return pageList;
|
return pageList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IResponseOutput> BatchAddInternationalization(BatchAddInternationalization batchAdd)
|
||||||
|
{
|
||||||
|
foreach (var item in batchAdd.AddList)
|
||||||
|
{
|
||||||
|
|
||||||
|
var mapItem = _mapper.Map<InternationalizationAddOrEdit>(item);
|
||||||
|
|
||||||
|
mapItem.InternationalizationType = batchAdd.InternationalizationType;
|
||||||
|
mapItem.State = batchAdd.State;
|
||||||
|
|
||||||
|
var verifyExp1 = new EntityVerifyExp<Internationalization>()
|
||||||
|
{
|
||||||
|
VerifyExp = t => t.Code == mapItem.Code && t.InternationalizationType == mapItem.InternationalizationType,
|
||||||
|
|
||||||
|
VerifyMsg = $"该类型已有{item.Code}名称的国际化标识",
|
||||||
|
IsVerify = true
|
||||||
|
};
|
||||||
|
|
||||||
|
var entity = await _internationalizationRepository.InsertOrUpdateAsync(mapItem, false, verifyExp1);
|
||||||
|
}
|
||||||
|
|
||||||
|
await _internationalizationRepository.SaveChangesAsync();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return ResponseOutput.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IResponseOutput> AddOrUpdateInternationalization(InternationalizationAddOrEdit addOrEditInternationalization)
|
public async Task<IResponseOutput> AddOrUpdateInternationalization(InternationalizationAddOrEdit addOrEditInternationalization)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +102,13 @@ namespace IRaCIS.Core.Application.Service
|
||||||
IsVerify = true
|
IsVerify = true
|
||||||
};
|
};
|
||||||
|
|
||||||
var entity = await _internationalizationRepository.InsertOrUpdateAsync(addOrEditInternationalization, true,verifyExp1);
|
var entity = await _internationalizationRepository.InsertOrUpdateAsync(addOrEditInternationalization, true, verifyExp1);
|
||||||
|
|
||||||
|
if (addOrEditInternationalization.InternationalizationType == 1)
|
||||||
|
{
|
||||||
|
await InternationalizationHelper.AddOrUpdateJsonKeyValueAsync(entity.Code, entity.Value, entity.ValueCN);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return ResponseOutput.Ok(entity.Id.ToString());
|
return ResponseOutput.Ok(entity.Id.ToString());
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,10 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
CreateMap<AddOrEditBasicDic, Dictionary>().ReverseMap();
|
CreateMap<AddOrEditBasicDic, Dictionary>().ReverseMap();
|
||||||
|
|
||||||
|
|
||||||
|
CreateMap<AddBasicDicAndChild, Dictionary>().ForMember(o => o.ChildList, t => t.Ignore());
|
||||||
|
CreateMap<AddBasicDicChild, Dictionary>();
|
||||||
|
|
||||||
CreateMap<Dictionary, BasicDicSelectCopy>()
|
CreateMap<Dictionary, BasicDicSelectCopy>()
|
||||||
.ForMember(o => o.ParentChildCodeEnum, t => t.MapFrom(u => u.Parent.ChildCodeEnum))
|
.ForMember(o => o.ParentChildCodeEnum, t => t.MapFrom(u => u.Parent.ChildCodeEnum))
|
||||||
.ForMember(o => o.Value, t => t.MapFrom(u => u.MappedValue))
|
.ForMember(o => o.Value, t => t.MapFrom(u => u.MappedValue))
|
||||||
|
@ -57,6 +61,9 @@ namespace IRaCIS.Core.Application.Service
|
||||||
CreateMap<Internationalization, InternationalizationView>();
|
CreateMap<Internationalization, InternationalizationView>();
|
||||||
CreateMap<Internationalization, InternationalizationAddOrEdit>().ReverseMap();
|
CreateMap<Internationalization, InternationalizationAddOrEdit>().ReverseMap();
|
||||||
|
|
||||||
|
CreateMap<BatchAddInternationalizationDto, InternationalizationAddOrEdit>();
|
||||||
|
|
||||||
|
|
||||||
CreateMap<PublishLog, PublishLogView>();
|
CreateMap<PublishLog, PublishLogView>();
|
||||||
CreateMap<PublishLog, PublishLogAddOrEdit>().ReverseMap();
|
CreateMap<PublishLog, PublishLogAddOrEdit>().ReverseMap();
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace IRaCIS.Application.Services
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
var rows = await MiniExcel.QueryAsync<InternationalizationAddOrEdit>(@"C:\Users\Administrator\Desktop\Export\NetCore.xlsx");
|
var rows = await MiniExcel.QueryAsync<InternationalizationAddOrEdit>(@"C:\Users\Administrator\Desktop\Export\vue.xlsx");
|
||||||
|
|
||||||
foreach (var row in rows)
|
foreach (var row in rows)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue