add 流转日志
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
using Ewide.Core;
|
||||
using Furion.DatabaseAccessor;
|
||||
using Furion.DatabaseAccessor.Extensions;
|
||||
using Furion.DependencyInjection;
|
||||
using Furion.DynamicApiController;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ewide.Application.Service
|
||||
{
|
||||
public class HouseLogService : IHouseLogService, ITransient
|
||||
{
|
||||
private readonly IRepository<BsHouseLog> _bsHouseLogRep;
|
||||
|
||||
public HouseLogService(IRepository<BsHouseLog> bsHouseLogRep)
|
||||
{
|
||||
_bsHouseLogRep = bsHouseLogRep;
|
||||
}
|
||||
|
||||
[UnitOfWork]
|
||||
public async Task Add(string houseCodeId, SysUser targetUser, HouseLogType type)
|
||||
{
|
||||
await Add(houseCodeId, new List<SysUser> { targetUser }, type);
|
||||
}
|
||||
|
||||
[UnitOfWork]
|
||||
public async Task Add(string houseCodeId, List<SysUser> targetUsers, HouseLogType type)
|
||||
{
|
||||
await new BsHouseLog
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
HouseCodeId = houseCodeId,
|
||||
TargetUserIds = String.Join(",", targetUsers.Select(p => p.Id)),
|
||||
Type = type,
|
||||
Status = HouseLogStatus.Handle
|
||||
}.InsertAsync();
|
||||
}
|
||||
|
||||
[UnitOfWork]
|
||||
public async Task Read(string houseCodeId)
|
||||
{
|
||||
var log = await _bsHouseLogRep
|
||||
.Where(p => p.HouseCodeId.Equals(houseCodeId) && p.Status.Equals(HouseLogStatus.Handle))
|
||||
.OrderByDescending(p => p.CreatedTime)
|
||||
.FirstOrDefaultAsync();
|
||||
if (log != null)
|
||||
{
|
||||
log.Status = HouseLogStatus.Handling;
|
||||
await log.UpdateAsync();
|
||||
}
|
||||
}
|
||||
|
||||
[UnitOfWork]
|
||||
public async Task Done(string houseCodeId)
|
||||
{
|
||||
var log = await _bsHouseLogRep
|
||||
.Where(p => p.HouseCodeId.Equals(houseCodeId) && !p.Status.Equals(HouseLogStatus.Handled))
|
||||
.OrderByDescending(p => p.CreatedTime)
|
||||
.FirstOrDefaultAsync();
|
||||
if (log != null)
|
||||
{
|
||||
log.Status = HouseLogStatus.Handled;
|
||||
await log.UpdateAsync();
|
||||
}
|
||||
}
|
||||
|
||||
[UnitOfWork]
|
||||
public async Task AddThenRead(string houseCodeId, SysUser targetUser, HouseLogType type)
|
||||
{
|
||||
await AddThenRead(houseCodeId, new List<SysUser> { targetUser }, type);
|
||||
}
|
||||
|
||||
[UnitOfWork]
|
||||
public async Task AddThenRead(string houseCodeId, List<SysUser> targetUsers, HouseLogType type)
|
||||
{
|
||||
await new BsHouseLog
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
HouseCodeId = houseCodeId,
|
||||
TargetUserIds = String.Join(",", targetUsers.Select(p => p.Id)),
|
||||
Type = type,
|
||||
Status = HouseLogStatus.Handling
|
||||
}.InsertAsync();
|
||||
}
|
||||
|
||||
[UnitOfWork]
|
||||
public async Task AddThenDone(string houseCodeId, SysUser targetUser, HouseLogType type)
|
||||
{
|
||||
await AddThenDone(houseCodeId, new List<SysUser> { targetUser }, type);
|
||||
}
|
||||
|
||||
[UnitOfWork]
|
||||
public async Task AddThenDone(string houseCodeId, List<SysUser> targetUsers, HouseLogType type)
|
||||
{
|
||||
await new BsHouseLog
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
HouseCodeId = houseCodeId,
|
||||
TargetUserIds = String.Join(",", targetUsers.Select(p => p.Id)),
|
||||
Type = type,
|
||||
Status = HouseLogStatus.Handled
|
||||
}.InsertAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Ewide.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ewide.Application.Service
|
||||
{
|
||||
public interface IHouseLogService
|
||||
{
|
||||
Task Add(string houseCodeId, SysUser targetUser, HouseLogType type);
|
||||
Task Add(string houseCodeId, List<SysUser> targetUsers, HouseLogType type);
|
||||
Task Read(string houseCodeId);
|
||||
Task Done(string houseCodeId);
|
||||
Task AddThenRead(string houseCodeId, SysUser targetUser, HouseLogType type);
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user