修复删除字典表数据

This commit is contained in:
2022-04-08 16:06:23 +08:00
parent 6fe823ec7a
commit 2a1f15996d
7 changed files with 50 additions and 13 deletions
@@ -58,12 +58,10 @@ namespace IRaCIS.Application.Contracts
public class BasicDicSelect
{
public Guid Id { get; set; }
public string KeyName { get; set; } = string.Empty;
public string ValueCN { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
public string Code { get; set; } = string.Empty;
public string ChildGroup { get; set; } = string.Empty;
public int ShowOrder { get; set; }
@@ -1,9 +1,7 @@
using IRaCIS.Core.Infrastructure.ExpressionExtend;
using IRaCIS.Application.Interfaces;
using IRaCIS.Application.Interfaces;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Infra.EFCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Panda.DynamicWebApi.Attributes;
namespace IRaCIS.Application.Services
{
@@ -21,7 +19,7 @@ namespace IRaCIS.Application.Services
private readonly IRepository<Trial> _trialRepository;
public DictionaryService(IRepository<Dictionary> sysDicRepository, IRepository<DoctorDictionary> doctorDictionaryRepository, IRepository<TrialDictionary> trialDictionaryRepository,
IRepository<Doctor> doctorRepository, IRepository<Trial> trialRepository)
IRepository<Doctor> doctorRepository, IRepository<Trial> trialRepository)
{
_dicRepository = sysDicRepository;
_doctorDictionaryRepository = doctorDictionaryRepository;
@@ -31,6 +29,7 @@ namespace IRaCIS.Application.Services
}
/// <summary>
/// New 查询条件 IsConfig 代表是字典类型配置项 否就是我们普通的项 和普通项的子项
/// </summary>
@@ -53,7 +52,7 @@ namespace IRaCIS.Application.Services
/// <summary>
/// New
/// 添加和编辑
/// </summary>
/// <param name="addOrEditBasic"></param>
/// <returns></returns>
@@ -68,7 +67,7 @@ namespace IRaCIS.Application.Services
/// <summary>
/// New
/// 获取子项数组
/// </summary>
/// <param name="parentId"></param>
/// <returns></returns>
@@ -80,6 +79,29 @@ namespace IRaCIS.Application.Services
}
/// <summary> 删除字典数据 </summary>
[HttpDelete("{id:guid}")]
public async Task<IResponseOutput> DeleteDictionary(Guid id)
{
if ((await _doctorDictionaryRepository.AnyAsync(t => t.DictionaryId == id)) ||
(await _doctorRepository.AnyAsync(t => t.SpecialityId == id || t.PositionId == id || t.DepartmentId == id || t.RankId == id))
)
{
return ResponseOutput.NotOk("This item is referenced by content of the reviewer's resume.");
}
if (await _trialDictionaryRepository.AnyAsync(t => t.DictionaryId == id) ||
await _trialRepository.AnyAsync(t => t.ReviewModeId == id))
{
return ResponseOutput.NotOk("This item is referenced by content of the trial infomation.");
}
var success = await _dicRepository.DeleteFromQueryAsync(t => t.Id == id);
return ResponseOutput.Result(success);
}
/// <summary>
/// 传递父亲 code 字符串 数组 返回多个下拉框数据
/// </summary>
@@ -103,6 +125,14 @@ namespace IRaCIS.Application.Services
}
[AllowAnonymous]
public async Task<Dictionary<string, List<BasicDicSelect>>> GetBasicDataAllSelect()
{
var searchList = await _dicRepository.Where(t => t.ParentId != null && t.IsEnable).ProjectTo<BasicDicSelect>(_mapper.ConfigurationProvider).ToListAsync();
return searchList.GroupBy(t => t.ParentCode).ToDictionary(g => g.Key, g => g.ToList());
}
}
}