From 1d672586b3c9e23319e328f8328da0a28f9f583f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=87=AA=E5=B8=A6=E5=A4=A7=E4=BD=AC=E6=B0=94=E5=9C=BA?= <188633308@qq.com> Date: Tue, 6 Jul 2021 18:27:07 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E8=8E=B7=E5=8F=96=E6=B5=81=E8=BD=AC?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HouseSafety/HouseLog/Dto/HouseLogInput.cs | 15 ++++++ .../HouseLog/Dto/HouseLogOutput.cs | 19 +++++++ .../HouseSafety/HouseLog/HouseLogService.cs | 51 +++++++++++++++++-- .../HouseSafety/HouseLog/IHouseLogService.cs | 3 ++ 4 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 Api/Ewide.Application/Service/HouseSafety/HouseLog/Dto/HouseLogInput.cs create mode 100644 Api/Ewide.Application/Service/HouseSafety/HouseLog/Dto/HouseLogOutput.cs diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseLog/Dto/HouseLogInput.cs b/Api/Ewide.Application/Service/HouseSafety/HouseLog/Dto/HouseLogInput.cs new file mode 100644 index 0000000..356d221 --- /dev/null +++ b/Api/Ewide.Application/Service/HouseSafety/HouseLog/Dto/HouseLogInput.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Ewide.Application +{ + public class HouseLogInput + { + [Required(ErrorMessage = "Id不能为空")] + public string Id { get; set; } + } +} diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseLog/Dto/HouseLogOutput.cs b/Api/Ewide.Application/Service/HouseSafety/HouseLog/Dto/HouseLogOutput.cs new file mode 100644 index 0000000..f5aab48 --- /dev/null +++ b/Api/Ewide.Application/Service/HouseSafety/HouseLog/Dto/HouseLogOutput.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Ewide.Application +{ + public class HouseLogOutput + { + public string TargetUserNames { get; set; } + public int Type { get; set; } + public int Status { get; set; } + public DateTime CreatedTime { get; set; } + public DateTime? UpdatedTimeg { get; set; } + public string CreatedUserName { get; set; } + public string UpdatedUserName { get; set; } + } +} diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseLog/HouseLogService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseLog/HouseLogService.cs index 278fec9..22dd992 100644 --- a/Api/Ewide.Application/Service/HouseSafety/HouseLog/HouseLogService.cs +++ b/Api/Ewide.Application/Service/HouseSafety/HouseLog/HouseLogService.cs @@ -1,8 +1,10 @@ -using Ewide.Core; +using Dapper; +using Ewide.Core; using Furion.DatabaseAccessor; using Furion.DatabaseAccessor.Extensions; using Furion.DependencyInjection; using Furion.DynamicApiController; +using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; @@ -12,12 +14,16 @@ using System.Threading.Tasks; namespace Ewide.Application.Service { - public class HouseLogService : IHouseLogService, ITransient + [ApiDescriptionSettings(Name = "HouseLog", Order = 180)] + public class HouseLogService : IHouseLogService, IDynamicApiController, ITransient { + private readonly IDapperRepository _dapperRep; + private readonly IRepository _bsHouseLogRep; - public HouseLogService(IRepository bsHouseLogRep) + public HouseLogService(IDapperRepository dapperRep, IRepository bsHouseLogRep) { + _dapperRep = dapperRep; _bsHouseLogRep = bsHouseLogRep; } @@ -105,5 +111,44 @@ namespace Ewide.Application.Service Status = HouseLogStatus.Handled }.InsertAsync(); } + + [HttpGet("/houseLog/list")] + public async Task List([FromQuery] HouseLogInput input) + { + var sql = @"SELECT *, +(SELECT GROUP_CONCAT(`Name`) FROM sys_user + WHERE Id IN ( + SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(_HL.TargetUserIds,',',HT.help_topic_id + 1),',',-1) + FROM bs_house_log _HL + JOIN mysql.help_topic HT ON HT.help_topic_id < (LENGTH(_HL.TargetUserIds) - LENGTH(REPLACE(_HL.TargetUserIds,',','')) + 1) + WHERE _HL.Id = HL.Id + ) +) TargetUserNames +FROM bs_house_log HL +WHERE HouseCodeId = @HouseCodeId +ORDER BY HL.CreatedTime DESC, Type DESC"; + + return await _dapperRep.QueryAsync(sql, new { houseCodeId = input.Id }); + } + + [HttpGet("/houseLog/listByInfoId")] + public async Task ListByInfoId([FromQuery] HouseLogInput input) + { + var info = await Db.GetRepository().DetachedEntities.FirstOrDefaultAsync(p => p.Id.Equals(input.Id)); + return await List(new HouseLogInput + { + Id = info.HouseCodeId + }); + } + + [HttpGet("/houseLog/listByTaskId")] + public async Task ListByTaskId([FromQuery] HouseLogInput input) + { + var task = await Db.GetRepository().DetachedEntities.FirstOrDefaultAsync(p => p.Id.Equals(input.Id)); + return await List(new HouseLogInput + { + Id = task.HouseCodeId + }); + } } } diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseLog/IHouseLogService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseLog/IHouseLogService.cs index b93db7b..f85e66f 100644 --- a/Api/Ewide.Application/Service/HouseSafety/HouseLog/IHouseLogService.cs +++ b/Api/Ewide.Application/Service/HouseSafety/HouseLog/IHouseLogService.cs @@ -17,5 +17,8 @@ namespace Ewide.Application.Service Task AddThenRead(string houseCodeId, List targetUsers, HouseLogType type); Task AddThenDone(string houseCodeId, SysUser targetUser, HouseLogType type); Task AddThenDone(string houseCodeId, List targetUsers, HouseLogType type); + Task List(HouseLogInput input); + Task ListByInfoId(HouseLogInput input); + Task ListByTaskId(HouseLogInput input); } }