From 2d8739b04f86ab5e73ec7b0d3152e702a90a450b Mon Sep 17 00:00:00 2001 From: 移动系统liao <liaoxujun@qq.com> Date: 星期一, 14 七月 2025 16:34:49 +0800 Subject: [PATCH] 修改用户扩展资料 --- Admin.NET/FZFCGDD.ORDER.Application/Service/Neirongfabu/NeirongfabuService.cs | 302 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 302 insertions(+), 0 deletions(-) diff --git a/Admin.NET/FZFCGDD.ORDER.Application/Service/Neirongfabu/NeirongfabuService.cs b/Admin.NET/FZFCGDD.ORDER.Application/Service/Neirongfabu/NeirongfabuService.cs new file mode 100644 index 0000000..7ac1f0a --- /dev/null +++ b/Admin.NET/FZFCGDD.ORDER.Application/Service/Neirongfabu/NeirongfabuService.cs @@ -0,0 +1,302 @@ +锘�// Admin.NET 椤圭洰鐨勭増鏉冦�佸晢鏍囥�佷笓鍒╁拰鍏朵粬鐩稿叧鏉冨埄鍧囧彈鐩稿簲娉曞緥娉曡鐨勪繚鎶ゃ�備娇鐢ㄦ湰椤圭洰搴旈伒瀹堢浉鍏虫硶寰嬫硶瑙勫拰璁稿彲璇佺殑瑕佹眰銆� +// +// 鏈」鐩富瑕侀伒寰� MIT 璁稿彲璇佸拰 Apache 璁稿彲璇侊紙鐗堟湰 2.0锛夎繘琛屽垎鍙戝拰浣跨敤銆傝鍙瘉浣嶄簬婧愪唬鐮佹爲鏍圭洰褰曚腑鐨� LICENSE-MIT 鍜� LICENSE-APACHE 鏂囦欢銆� +// +// 涓嶅緱鍒╃敤鏈」鐩粠浜嬪嵄瀹冲浗瀹跺畨鍏ㄣ�佹壈涔辩ぞ浼氱З搴忋�佷镜鐘粬浜哄悎娉曟潈鐩婄瓑娉曞緥娉曡绂佹鐨勬椿鍔紒浠讳綍鍩轰簬鏈」鐩簩娆″紑鍙戣�屼骇鐢熺殑涓�鍒囨硶寰嬬籂绾峰拰璐d换锛屾垜浠笉鎵挎媴浠讳綍璐d换锛� + +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.Application; +using Admin.NET.Core; +using FZCZTB.NET.MD; +using Furion.DynamicApiController; +using Furion.DependencyInjection; +using System.Collections.Generic; +using System.Linq; +using NewLife.Xml; +using AngleSharp.Dom; +using DocumentFormat.OpenXml.Office2010.ExcelAc; +using Furion; +using System.Security.Claims; +using Microsoft.AspNetCore.Authorization; +using RazorEngine.Compilation.ImpromptuInterface; +using MimeKit; +using static FZCZTB.TSCL.Application.ChangeTenderOrderOut; +using FZFCGDD.ORDER.Application.Service.Neirongfabu.Dto; +namespace FZCZTB.TSCL.Application; + +/// <summary> +/// 鍐呭鍙戝竷鎺ュ彛 馃З +/// </summary> +[ApiDescriptionSettings(ApplicationConst.GroupNameDD, Order = 100)] +public class NeirongfabuService : IDynamicApiController, ITransient +{ + private readonly SqlSugarRepository<SysDictData> _sysDictDataRep; + private readonly SqlSugarRepository<Neirongfabu> _neirongfabu; + private readonly ISqlSugarClient _sqlSugarClient; + + public NeirongfabuService(SqlSugarRepository<SysDictData> sysDictDataRep + , SqlSugarRepository<Neirongfabu> neirongfabu + , ISqlSugarClient sqlSugarClient) + { + + _sysDictDataRep = sysDictDataRep; + _neirongfabu = neirongfabu; + _sqlSugarClient = sqlSugarClient; + + + } + + + /// <summary> + /// 鑾峰彇鍐呭绫诲瀷闆嗗悎 馃敄 + /// </summary> + /// <returns></returns> + [DisplayName("鑾峰彇鍐呭绫诲瀷闆嗗悎")] + [ApiDescriptionSettings(Name = "GetLeirongneixingList"), HttpGet] + [AllowAnonymous] + public async Task<List<SysDictData>> GetLeirongneixingList() + { + return await GetDataListByCode("Leirongneixing"); + } + + + /// <summary> + /// 鑾峰彇瀛楀吀鍊奸泦鍚� 馃敄 + /// </summary> + /// <param name="typeId"></param> + /// <param name="code"></param> + /// <returns></returns> + [NonAction] + public async Task<List<SysDictData>> GetDataListByCode(string code) + { + if (string.IsNullOrWhiteSpace(code)) + throw Oops.Oh(ErrorCodeEnum.D3011); + + var dictType = await _sysDictDataRep.Change<SysDictType>().AsQueryable() + .Where(u => u.Status == StatusEnum.Enable) + .WhereIF(!string.IsNullOrWhiteSpace(code), u => u.Code == code) + .FirstAsync(); + if (dictType == null) return null; + + + + var dictDataList = await _sysDictDataRep.AsQueryable() + .Where(u => u.DictTypeId == dictType.Id) + .Where(u => u.Status == StatusEnum.Enable) + .OrderBy(u => new { u.OrderNo, u.Value, u.Code }) + .ToListAsync(); + return dictDataList; + } + + + + /// <summary> + /// 鍒嗛〉鏌ヨ鍐呭鍙戝竷 馃敄 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + [DisplayName("鍒嗛〉鏌ヨ鍐呭鍙戝竷")] + [ApiDescriptionSettings(Name = "Page"), HttpPost] + public async Task<SqlSugarPagedList<NeirongfabuOutput>> Page(PageNeirongfabuInput input) + { + long userId = 0; + long.TryParse(App.User?.FindFirst(ClaimConst.UserId)?.Value, out userId); + + var query = _neirongfabu.AsQueryable() + .WhereIF(input.CreateDateRange != null && input.CreateDateRange.Length == 2, u => u.FabuDate >= input.CreateDateRange[0] && u.FabuDate <= input.CreateDateRange[1]) + .WhereIF(input.Leirongneixing.HasValue, u => u.Leirongneixing == input.Leirongneixing) + .WhereIF(!string.IsNullOrWhiteSpace(input.NeirongTittle), u => u.NeirongTittle.Contains(input.NeirongTittle.Trim())) + + + .Select(x => new NeirongfabuOutput + { + Id = x.Id, + Leirongneixing = x.Leirongneixing, + IsFabu = x.IsFabu, + IsShouyexianshi = x.IsShouyexianshi, + NeirongTittle = x.NeirongTittle, + Fengmiantupian = x.Fengmiantupian, + Sort = x.Sort, + FabuDate = x.FabuDate, + NeirongZhaiyao = x.NeirongZhaiyao, + // NeirongMiaoshu = x.NeirongMiaoshu, + CreateTime = x.CreateTime, + UpdateTime = x.UpdateTime, + CreateUserId = x.CreateUserId, + CreateUserName = x.CreateUserName, + UpdateUserId = x.UpdateUserId, + UpdateUserName = x.UpdateUserName, + }); + + var pagedList = await query.OrderBuilder(input, "", "Sort", false).ToPagedListAsync(input.Page, input.PageSize); + + var sysDictDatas = await GetDataListByCode("Leirongneixing"); + + foreach (var neirongfabuOutput in pagedList.Items) + { + var sysDictData = sysDictDatas.Where(x => x.Value == neirongfabuOutput.Leirongneixing.Value.ToString()).FirstOrDefault(); + if (sysDictData != null) + { + neirongfabuOutput.LeirongneixingName = sysDictData.Label; + } + + if(neirongfabuOutput.IsFabu.HasValue && neirongfabuOutput.IsFabu.Value) + { + neirongfabuOutput.IsFabuName = "鏄�"; + } + else + { + neirongfabuOutput.IsFabuName = "鍚�"; + } + + if (neirongfabuOutput.IsShouyexianshi.HasValue && neirongfabuOutput.IsShouyexianshi.Value) + { + neirongfabuOutput.IsShouyexianshiName = "鏄�"; + } + else + { + neirongfabuOutput.IsShouyexianshiName = "鍚�"; + } + } + + return pagedList; + } + + /// <summary> + /// 鑾峰彇鍐呭鍙戝竷璇︽儏 鈩癸笍 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + [DisplayName("鑾峰彇鍐呭鍙戝竷璇︽儏")] + [ApiDescriptionSettings(Name = "Detail"), HttpGet] + public async Task<NeirongfabuOutput> Detail([FromQuery] QueryByIdTenderOrderInput input) + { + var Leirongneixing = await GetDataListByCode("Leirongneixing"); + + var neirongfabuOutput = await _neirongfabu.AsQueryable().Where(x => x.Id == input.Id).Select<NeirongfabuOutput>().FirstAsync(); + if (neirongfabuOutput != null) + { + + if (neirongfabuOutput.Leirongneixing.HasValue) + { + neirongfabuOutput.LeirongneixingName = Leirongneixing.Where(x => x.Value == neirongfabuOutput.Leirongneixing.Value.ToString()).Select(x => x.Label).FirstOrDefault() ?? ""; + } + if (neirongfabuOutput.IsFabu.HasValue && neirongfabuOutput.IsFabu.Value) + { + neirongfabuOutput.IsFabuName = "鏄�"; + } + else + { + neirongfabuOutput.IsFabuName = "鍚�"; + } + + if (neirongfabuOutput.IsShouyexianshi.HasValue && neirongfabuOutput.IsShouyexianshi.Value) + { + neirongfabuOutput.IsShouyexianshiName = "鏄�"; + } + else + { + neirongfabuOutput.IsShouyexianshiName = "鍚�"; + } + } + + + + return neirongfabuOutput; + } + + /// <summary> + /// 鏂板鍐呭鍙戝竷 鉃� + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + [DisplayName("鏂板鍐呭鍙戝竷")] + [ApiDescriptionSettings(Name = "Add"), HttpPost] + public async Task<bool> Add(NeirongfabuInput input) + { + var entity = input.Adapt<Neirongfabu>(); + entity.Id = Guid.NewGuid(); + long userId = 0; + long? usertrueId = null; + if (long.TryParse(App.User?.FindFirst(ClaimConst.UserId)?.Value, out userId)) + { + usertrueId = userId; + } + var RealName = App.User?.FindFirstValue(ClaimConst.RealName); + entity.CreateTime = DateTime.Now; + entity.UpdateTime = DateTime.Now; + entity.CreateUserId = usertrueId; + entity.CreateUserName = RealName; + entity.UpdateUserId = usertrueId; + entity.UpdateUserName = RealName; + + return await _neirongfabu.InsertAsync(entity); + } + + /// <summary> + /// 淇敼鍐呭鍙戝竷 鉁忥笍 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + [DisplayName("淇敼鍐呭鍙戝竷")] + [ApiDescriptionSettings(Name = "Update"), HttpPost] + public async Task Update(NeirongfabuInput input) + { + var entity = input.Adapt<Neirongfabu>(); + long userId = 0; + long? usertrueId = null; + if (long.TryParse(App.User?.FindFirst(ClaimConst.UserId)?.Value, out userId)) + { + usertrueId = userId; + } + var RealName = App.User?.FindFirstValue(ClaimConst.RealName); + entity.UpdateTime = DateTime.Now; + entity.UpdateUserId = usertrueId; + entity.UpdateUserName = RealName; + await _neirongfabu.UpdateAsync(entity); + } + + /// <summary> + /// 鍒犻櫎鍐呭鍙戝竷 鉂� + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + [DisplayName("鍒犻櫎鍐呭鍙戝竷")] + [ApiDescriptionSettings(Name = "Delete"), HttpPost] + public async Task Delete(DeleteTenderOrderInput input) + { + //var entity = await _TenderOrderRep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D1002); + var entity = await _sqlSugarClient.Queryable<Neirongfabu>().Where(x => x.Id == input.Id).FirstAsync() ?? throw Oops.Oh(ErrorCodeEnum.D1002); + //await _TenderOrderRep.FakeDeleteAsync(entity); //鍋囧垹闄� + await _neirongfabu.DeleteAsync(entity); //鐪熷垹闄� + } + + /// <summary> + /// 鎵归噺鍒犻櫎鍐呭鍙戝竷 鉂� + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + [DisplayName("鎵归噺鍒犻櫎鍐呭鍙戝竷")] + [ApiDescriptionSettings(Name = "BatchDelete"), HttpPost] + public async Task<bool> BatchDelete([Required(ErrorMessage = "涓婚敭鍒楄〃涓嶈兘涓虹┖")] List<DeleteTenderOrderInput> input) + { + var exp = Expressionable.Create<Neirongfabu>(); + foreach (var row in input) exp = exp.Or(it => it.Id == row.Id); + var list = await _neirongfabu.AsQueryable().Where(exp.ToExpression()).ToListAsync(); + + // return await _TenderOrderRep.FakeDeleteAsync(list); //鍋囧垹闄� + return await _neirongfabu.DeleteAsync(list); //鐪熷垹闄� + } + + + +} -- Gitblit v1.9.1