update 获取流转日志列表

This commit is contained in:
2021-07-06 18:27:07 +08:00
parent 6a97b9440b
commit 1d672586b3
4 changed files with 85 additions and 3 deletions

View File

@@ -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; }
}
}

View File

@@ -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; }
}
}

View File

@@ -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<BsHouseLog> _bsHouseLogRep;
public HouseLogService(IRepository<BsHouseLog> bsHouseLogRep)
public HouseLogService(IDapperRepository dapperRep, IRepository<BsHouseLog> bsHouseLogRep)
{
_dapperRep = dapperRep;
_bsHouseLogRep = bsHouseLogRep;
}
@@ -105,5 +111,44 @@ namespace Ewide.Application.Service
Status = HouseLogStatus.Handled
}.InsertAsync();
}
[HttpGet("/houseLog/list")]
public async Task<dynamic> 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<HouseLogOutput>(sql, new { houseCodeId = input.Id });
}
[HttpGet("/houseLog/listByInfoId")]
public async Task<dynamic> ListByInfoId([FromQuery] HouseLogInput input)
{
var info = await Db.GetRepository<BsHouseInfo>().DetachedEntities.FirstOrDefaultAsync(p => p.Id.Equals(input.Id));
return await List(new HouseLogInput
{
Id = info.HouseCodeId
});
}
[HttpGet("/houseLog/listByTaskId")]
public async Task<dynamic> ListByTaskId([FromQuery] HouseLogInput input)
{
var task = await Db.GetRepository<BsHouseTask>().DetachedEntities.FirstOrDefaultAsync(p => p.Id.Equals(input.Id));
return await List(new HouseLogInput
{
Id = task.HouseCodeId
});
}
}
}

View File

@@ -17,5 +17,8 @@ namespace Ewide.Application.Service
Task AddThenRead(string houseCodeId, List<SysUser> targetUsers, HouseLogType type);
Task AddThenDone(string houseCodeId, SysUser targetUser, HouseLogType type);
Task AddThenDone(string houseCodeId, List<SysUser> targetUsers, HouseLogType type);
Task<dynamic> List(HouseLogInput input);
Task<dynamic> ListByInfoId(HouseLogInput input);
Task<dynamic> ListByTaskId(HouseLogInput input);
}
}