修改单位

main
金豪 廖 2024-07-02 00:11:33 +08:00
parent 6c94077b93
commit 6cf4381c53
4 changed files with 48 additions and 6 deletions

View File

@ -143,3 +143,16 @@ public class QueryByIdSysUnitGroupInput : DeleteSysUnitGroupInput
{
}
/// <summary>
/// 单位组检查输入参数
/// </summary>
public class CheckSysUnitGroupInput : SysUnitGroupBaseInput
{
/// <summary>
/// 主键Id
/// </summary>
[Required(ErrorMessage = "主键Id不能为空")]
public long Id { get; set; }
}

View File

@ -11,9 +11,14 @@ namespace Admin.NET.Application;
public class SysUnitGroupService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<SysUnitGroup> _rep;
public SysUnitGroupService(SqlSugarRepository<SysUnitGroup> rep)
private readonly SysUnitService _sysUnitService;
public SysUnitGroupService(SqlSugarRepository<SysUnitGroup> rep,
SysUnitService sysUnitService )
{
_rep = rep;
_sysUnitService = sysUnitService;
}
/// <summary>
@ -101,9 +106,17 @@ public class SysUnitGroupService : IDynamicApiController, ITransient
return await _rep.AsQueryable().Where(a => !a.IsDelete).Select<SysUnitGroupOutput>().ToListAsync();
}
/// <summary>
/// 检查单位是否存在数据
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "CheckUnitList")]
public async Task<bool> CheckUnitList(CheckSysUnitGroupInput input)
{
var sysUnits = await _sysUnitService.ListByGroupId(input.Id);
return sysUnits.Any();
}
}

View File

@ -2,6 +2,7 @@
using Admin.NET.Application.Const;
using Admin.NET.Application.Entity;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
namespace Admin.NET.Application;
/// <summary>
/// 单位服务
@ -171,5 +172,21 @@ public class SysUnitService : IDynamicApiController, ITransient
return result;
}
/// <summary>
/// 校验基本单位是否唯一
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[ApiDescriptionSettings(Name = "checkBaseUnit")]
public async Task<SysUnit> CheckBaseUnit(AddSysUnitInput input)
{
var result = await _rep.AsQueryable()
.Where(a => !a.IsDelete && a.IsBaseUnit==true)
.WhereIF(input.GroupUnitId > 0, u => u.GroupUnitId == input.GroupUnitId)
.FirstAsync();
return result;
}
}

View File

@ -13,7 +13,6 @@
<ItemGroup>
<None Remove="Admin.NET.Core.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AlibabaCloud.SDK.Dysmsapi20170525" Version="2.0.24" />
<PackageReference Include="AngleSharp" Version="1.1.2" />