feat: 对接前端,完成通知公告

This commit is contained in:
陈淳
2024-02-20 15:34:29 +08:00
parent d2ae803ecc
commit f7f8bad301
12 changed files with 235 additions and 66 deletions

View File

@@ -0,0 +1,17 @@
using Yi.Framework.Rbac.Domain.Shared.Enums;
namespace Yi.Framework.Rbac.Application.Contracts.Dtos.Notice
{
/// <summary>
/// Notice输入创建对象
/// </summary>
public class NoticeCreateInput
{
public string Title { get; set; }
public NoticeTypeEnum Type { get; set; }
public string Content { get; set; }
public int OrderNum { get; set; }
public bool State { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using Yi.Framework.Ddd.Application.Contracts;
using Yi.Framework.Rbac.Domain.Shared.Enums;
namespace Yi.Framework.Rbac.Application.Contracts.Dtos.Notice
{
/// <summary>
/// 查询参数
/// </summary>
public class NoticeGetListInput : PagedAllResultRequestDto
{
public string? Title { get; set; }
public NoticeTypeEnum? Type { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
using Volo.Abp.Application.Dtos;
using Yi.Framework.Rbac.Domain.Shared.Enums;
namespace Yi.Framework.Rbac.Application.Contracts.Dtos.Notice
{
public class NoticeGetListOutputDto : EntityDto<Guid>
{
public string Title { get; set; }
public NoticeTypeEnum Type { get; set; }
public string Content { get; set; }
public bool IsDeleted { get; set; }
public DateTime CreationTime { get; set; }
public Guid? CreatorId { get; set; }
public Guid? LastModifierId { get; set; }
public DateTime? LastModificationTime { get; set; }
public int OrderNum { get; set; }
public bool State { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
using Volo.Abp.Application.Dtos;
using Yi.Framework.Rbac.Domain.Shared.Enums;
namespace Yi.Framework.Rbac.Application.Contracts.Dtos.Notice
{
public class NoticeGetOutputDto : EntityDto<Guid>
{
public string Title { get; set; }
public NoticeTypeEnum Type { get; set; }
public string Content { get; set; }
public bool IsDeleted { get; set; }
public DateTime CreationTime { get; set; }
public Guid? CreatorId { get; set; }
public Guid? LastModifierId { get; set; }
public DateTime? LastModificationTime { get; set; }
public int OrderNum { get; set; }
public bool State { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
using Yi.Framework.Rbac.Domain.Shared.Enums;
namespace Yi.Framework.Rbac.Application.Contracts.Dtos.Notice
{
public class NoticeUpdateInput
{
public string? Title { get; set; }
public NoticeTypeEnum? Type { get; set; }
public string? Content { get; set; }
public int? OrderNum { get; set; }
public bool? State { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
using Yi.Framework.Ddd.Application.Contracts;
using Yi.Framework.Rbac.Application.Contracts.Dtos.Notice;
namespace Yi.Framework.Rbac.Application.Contracts.IServices
{
/// <summary>
/// Notice服务抽象
/// </summary>
public interface INoticeService : IYiCrudAppService<NoticeGetOutputDto, NoticeGetListOutputDto, Guid, NoticeGetListInput, NoticeCreateInput, NoticeUpdateInput>
{
}
}

View File

@@ -0,0 +1,39 @@
using SqlSugar;
using Volo.Abp.Application.Dtos;
using Yi.Framework.Ddd.Application;
using Yi.Framework.Rbac.Application.Contracts.Dtos.Notice;
using Yi.Framework.Rbac.Application.Contracts.IServices;
using Yi.Framework.Rbac.Domain.Entities;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Rbac.Application.Services
{
/// <summary>
/// Notice服务实现
/// </summary>
public class NoticeService : YiCrudAppService<NoticeEntity, NoticeGetOutputDto, NoticeGetListOutputDto, Guid, NoticeGetListInput, NoticeCreateInput, NoticeUpdateInput>,
INoticeService
{
private ISqlSugarRepository<NoticeEntity, Guid> _repository;
public NoticeService(ISqlSugarRepository<NoticeEntity, Guid> repository) : base(repository)
{
_repository = repository;
}
/// <summary>
/// 多查
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public override async Task<PagedResultDto<NoticeGetListOutputDto>> GetListAsync(NoticeGetListInput input)
{
RefAsync<int> total = 0;
var entities = await _repository._DbQueryable.WhereIF(input.Type is not null, x => x.Type==input.Type)
.WhereIF(!string.IsNullOrEmpty(input.Title), x => x.Title!.Contains(input.Title!))
.WhereIF(input.StartTime is not null && input.EndTime is not null, x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
return new PagedResultDto<NoticeGetListOutputDto>(total, await MapToGetListOutputDtosAsync(entities));
}
}
}