|
@@ -12,6 +12,8 @@ using Hotline.Caching.Interfaces;
|
|
|
using Hotline.Settings;
|
|
|
using Hotline.Article;
|
|
|
using Hotline.Snapshot;
|
|
|
+using Hotline.Share.Dtos.Snapshot;
|
|
|
+using Hotline.Share.Tools;
|
|
|
|
|
|
namespace Hotline.Api.Controllers.Snapshot;
|
|
|
|
|
@@ -39,19 +41,18 @@ public class SnapshotBulletinController : BaseController
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpGet("bulletin/query")]
|
|
|
- public async Task<PagedDto<BulletinDto>> QueryBulletinList([FromQuery] QueryBulletinListRequestDto dto)
|
|
|
+ public async Task<PagedDto<SnapshotBulletinItemsOutDto>> QueryBulletinList([FromQuery] SnapshotBulletinItemsInDto dto)
|
|
|
{
|
|
|
- var (total, items) = await _bulletinRepository.Queryable()
|
|
|
+ var query = _bulletinRepository.Queryable()
|
|
|
.Includes(x => x.ExaminMan)
|
|
|
- .WhereIF(!string.IsNullOrEmpty(dto.BulletinTypeId), d => d.SnapshotBulletinTypeId == dto.BulletinTypeId)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.SnapshotBulletinTypeName), d => d.SnapshotBulletinTypeName.Contains(dto.SnapshotBulletinTypeName))
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.Title), d => d.Title.Contains(dto.Title))
|
|
|
- .WhereIF(dto.BulletinTimeStart.HasValue, d => d.BulletinTime >= dto.BulletinTimeStart)
|
|
|
- .WhereIF(dto.BulletinTimeEnd.HasValue, d => d.BulletinTime <= dto.BulletinTimeEnd)
|
|
|
- .WhereIF(dto.BulletinState != null, d => d.BulletinState == dto.BulletinState)
|
|
|
+ .WhereIF(dto.BeginCreationTime.HasValue, d => d.BulletinTime >= dto.BeginCreationTime)
|
|
|
+ .WhereIF(dto.EndCreationTime.HasValue, d => d.BulletinTime <= dto.EndCreationTime)
|
|
|
.OrderByDescending(d => d.CreationTime)
|
|
|
- .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
|
|
|
-
|
|
|
- return new PagedDto<BulletinDto>(total, items.Adapt<IReadOnlyList<BulletinDto>>());
|
|
|
+ .Select<SnapshotBulletinItemsOutDto>();
|
|
|
+ return (await query
|
|
|
+ .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted)).ToPaged();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -178,42 +179,14 @@ public class SnapshotBulletinController : BaseController
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("bulletin/add")]
|
|
|
- public async Task AddBulletin([FromBody] AddBulletinDto dto)
|
|
|
+ public async Task AddBulletin([FromBody] AddSnapshotBulletinInDto dto)
|
|
|
{
|
|
|
var model = dto.Adapt<SnapshotBulletin>();
|
|
|
model.BulletinState = Share.Enums.Article.EBulletinState.Draft;
|
|
|
model.ReadedNum = 0;
|
|
|
- model.IsArrive = false;
|
|
|
await _bulletinRepository.AddAsync(model, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 公告上架或者下架
|
|
|
- /// </summary>
|
|
|
- /// <param name="dto"></param>
|
|
|
- /// <returns></returns>
|
|
|
- [HttpPost("bulletin-arrive")]
|
|
|
- public async Task BulletinArrive([FromBody] BulletinArriveDto dto)
|
|
|
- {
|
|
|
- var bulletin = await _bulletinRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
|
|
|
- if (bulletin == null)
|
|
|
- throw UserFriendlyException.SameMessage("无效数据");
|
|
|
-
|
|
|
- if (bulletin.BulletinState != EBulletinState.ReviewPass)
|
|
|
- throw UserFriendlyException.SameMessage("当前状态不能操作上架或下架");
|
|
|
-
|
|
|
- bulletin.IsArrive = dto.IsArrive;
|
|
|
- if (bulletin.IsArrive == false)
|
|
|
- {
|
|
|
- bulletin.ExaminTime = null;
|
|
|
- bulletin.ExaminManId = null;
|
|
|
- bulletin.ExaminOpinion = null;
|
|
|
- bulletin.CommitTime = null;
|
|
|
- bulletin.BulletinState = EBulletinState.Draft;
|
|
|
- }
|
|
|
- await _bulletinRepository.UpdateAsync(bulletin, HttpContext.RequestAborted);
|
|
|
- }
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 列表页面基础数据
|
|
|
/// </summary>
|
|
@@ -239,6 +212,7 @@ public class SnapshotBulletinController : BaseController
|
|
|
var rsp = new
|
|
|
{
|
|
|
BulletinType = _systemDicDataCacheManager.SnapshotBulletinType,
|
|
|
+ BulletinSource = _systemDicDataCacheManager.SnapshotBulletinSource,
|
|
|
OrgsOptions = await _organizeRepository.GetOrgJson(),
|
|
|
};
|
|
|
return rsp;
|