update 新增机构类型

This commit is contained in:
2021-05-21 16:10:08 +08:00
parent e4696f678e
commit c8530039eb
7 changed files with 83 additions and 29 deletions

View File

@@ -99,7 +99,7 @@ namespace Ewide.Core.Service
{
var isExist = await _sysDictTypeRep.AnyAsync(u => u.Name == input.Name, false);
if (isExist) throw Oops.Oh(ErrorCode.D3001);
var dictTypeEntity = _sysDictTypeRep.Where(s => s.Pid == input.Pid).FirstOrDefault();
var dictTypeEntity = _sysDictTypeRep.Where(s => s.Id == input.Pid).FirstOrDefault();
if (dictTypeEntity != null && dictTypeEntity.Code != null) throw new Exception("此类型下不能添加子类型");
var dictType = input.Adapt<SysDictType>();
dictType.Pids = await CreateNewPids(input.Pid);
@@ -132,14 +132,14 @@ namespace Ewide.Core.Service
[HttpPost("/sysDictType/edit"),]
public async Task UpdateDictType(UpdateDictTypeInput input)
{
var isExist = await _sysDictTypeRep.AnyAsync(u => u.Id == input.Id, false);
if (!isExist) throw Oops.Oh(ErrorCode.D3000);
if (input.Id == input.Pid) throw Oops.Oh(ErrorCode.D4006);
var result = _sysDictTypeRep.Where(u => u.Id == input.Id).Select(s => new { s.Name, s.Id, s.Code }).ToList().First();
if (result == null) throw Oops.Oh(ErrorCode.D3000);
if (result.Name == input.Name) throw Oops.Oh(ErrorCode.D3001);
// 如果是编辑父id不能为自己的子节点
//var childIdList = await _sysDictTypeRep.DetachedEntities.Where(u => u.Pids.Contains(input.Id.ToString()))
// .Select(u => u.Id).ToListAsync();
//if (childIdList.Contains(input.Pid)) throw Oops.Oh(ErrorCode.D4006);
// 排除自己并且判断与其他是否相同
isExist = await _sysDictTypeRep.AnyAsync(u => (u.Name == input.Name || u.Code == input.Code) && u.Id != input.Id, false);
if (isExist) throw Oops.Oh(ErrorCode.D3001);
var dictType = input.Adapt<SysDictType>();
dictType.Pids = await CreateNewPids(input.Pid);

View File

@@ -27,6 +27,11 @@ namespace Ewide.Core.Service
/// </summary>
public virtual string Code { get; set; }
/// <summary>
/// 机构类型
/// </summary>
public virtual int Type { get; set; }
/// <summary>
/// 电话
/// </summary>