New file |
| | |
| | | // Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 |
| | | // |
| | | // 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 |
| | | // |
| | | // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! |
| | | |
| | | using Admin.NET.Core.Service; |
| | | using Microsoft.AspNetCore.Http; |
| | | |
| | | using Furion.DatabaseAccessor; |
| | | using Furion.FriendlyException; |
| | | using Mapster; |
| | | using SqlSugar; |
| | | using System.ComponentModel; |
| | | using System.ComponentModel.DataAnnotations; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Admin.NET.Core; |
| | | using Admin.NET.Application; |
| | | using Furion.DynamicApiController; |
| | | using FZCZTB.NET.MD; |
| | | using Furion.DependencyInjection; |
| | | namespace FZCZTB.TSCL.Application; |
| | | |
| | | /// <summary> |
| | | /// 行政处罚服务 🧩 |
| | | /// </summary> |
| | | [ApiDescriptionSettings(ApplicationConst.GroupName, Order = 100)] |
| | | public class ADPenaltyService : IDynamicApiController, ITransient |
| | | { |
| | | private readonly SqlSugarRepository<ADPenalty> _aDPenaltyRep; |
| | | |
| | | public ADPenaltyService(SqlSugarRepository<ADPenalty> aDPenaltyRep) |
| | | { |
| | | _aDPenaltyRep = aDPenaltyRep; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 分页查询行政处罚 🔖 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [DisplayName("分页查询行政处罚")] |
| | | [ApiDescriptionSettings(Name = "Page"), HttpPost] |
| | | public async Task<SqlSugarPagedList<ADPenaltyOutput>> Page(PageADPenaltyInput input) |
| | | { |
| | | input.Keyword = input.Keyword?.Trim(); |
| | | var query = _aDPenaltyRep.AsQueryable() |
| | | .WhereIF(!string.IsNullOrWhiteSpace(input.Keyword), u => u.Parties.Contains(input.Keyword) || u.CaseReason.Contains(input.Keyword) || u.DisposalDecision.Contains(input.Keyword) || u.SupervisionDepartment.Contains(input.Keyword)) |
| | | .WhereIF(!string.IsNullOrWhiteSpace(input.Parties), u => u.Parties.Contains(input.Parties.Trim())) |
| | | .WhereIF(!string.IsNullOrWhiteSpace(input.CaseReason), u => u.CaseReason.Contains(input.CaseReason.Trim())) |
| | | .WhereIF(!string.IsNullOrWhiteSpace(input.DisposalDecision), u => u.DisposalDecision.Contains(input.DisposalDecision.Trim())) |
| | | .WhereIF(!string.IsNullOrWhiteSpace(input.SupervisionDepartment), u => u.SupervisionDepartment.Contains(input.SupervisionDepartment.Trim())) |
| | | .WhereIF(input.DecisionDateRange?.Length == 2, u => u.DecisionDate >= input.DecisionDateRange[0] && u.DecisionDate <= input.DecisionDateRange[1]) |
| | | .Select<ADPenaltyOutput>(); |
| | | return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取行政处罚详情 ℹ️ |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [DisplayName("获取行政处罚详情")] |
| | | [ApiDescriptionSettings(Name = "Detail"), HttpGet] |
| | | public async Task<ADPenalty> Detail([FromQuery] QueryByIdADPenaltyInput input) |
| | | { |
| | | return await _aDPenaltyRep.GetFirstAsync(u => u.Id == input.Id); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 增加行政处罚 ➕ |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [DisplayName("增加行政处罚")] |
| | | [ApiDescriptionSettings(Name = "Add"), HttpPost] |
| | | public async Task<bool> Add(AddADPenaltyInput input) |
| | | { |
| | | var entity = input.Adapt<ADPenalty>(); |
| | | entity.Id = Guid.NewGuid(); |
| | | return await _aDPenaltyRep.InsertAsync(entity) ; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新行政处罚 ✏️ |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [DisplayName("更新行政处罚")] |
| | | [ApiDescriptionSettings(Name = "Update"), HttpPost] |
| | | public async Task Update(UpdateADPenaltyInput input) |
| | | { |
| | | var entity = input.Adapt<ADPenalty>(); |
| | | await _aDPenaltyRep.AsUpdateable(entity) |
| | | |
| | | .ExecuteCommandAsync(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除行政处罚 ❌ |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [DisplayName("删除行政处罚")] |
| | | [ApiDescriptionSettings(Name = "Delete"), HttpPost] |
| | | public async Task Delete(DeleteADPenaltyInput input) |
| | | { |
| | | var entity = await _aDPenaltyRep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D1002); |
| | | await _aDPenaltyRep.DeleteAsync(entity); //假删除 |
| | | //await _aDPenaltyRep.DeleteAsync(entity); //真删除 |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 批量删除行政处罚 ❌ |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [DisplayName("批量删除行政处罚")] |
| | | [ApiDescriptionSettings(Name = "BatchDelete"), HttpPost] |
| | | public async Task<bool> BatchDelete([Required(ErrorMessage = "主键列表不能为空")]List<DeleteADPenaltyInput> input) |
| | | { |
| | | var exp = Expressionable.Create<ADPenalty>(); |
| | | foreach (var row in input) exp = exp.Or(it => it.Id == row.Id); |
| | | var list = await _aDPenaltyRep.AsQueryable().Where(exp.ToExpression()).ToListAsync(); |
| | | |
| | | return await _aDPenaltyRep.DeleteAsync(list); //假删除 |
| | | //return await _aDPenaltyRep.DeleteAsync(list); //真删除 |
| | | } |
| | | } |