using Lazy.SlideCaptcha.Core.Resources;
using Microsoft.AspNetCore.Mvc;
using NPOI.SS.Formula.PTG;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using ZhonTai.Admin.Core.Attributes;
using ZhonTai.Admin.Core.Consts;
using ZhonTai.Admin.Core.Dto;
using ZhonTai.Admin.Repositories.Notice;
using ZhonTai.Admin.Services.DiTuiAPI.Dto;
using ZhonTai.DynamicApi;
using ZhonTai.DynamicApi.Attributes;
#region <<版本注释>>
/* ---------------------------
* 版权所有 (c) 2023 Frank 保留所有权利。
* CLR版本:4.0.30319.42000
* 机器名称:FRANK-WIN
* 命名空间:ZhonTai.Admin.Services.DiTuiAPI
* 唯一标识:2de10604-3043-4cef-b46f-96757f867b17
*
* 创建者:Frank
* 电子邮箱: cfrank227@gmail.com
* 创建时间:2023/5/25 9:11:42
--------------------------*/
#endregion <<版本注释>>
namespace ZhonTai.Admin.Services.DiTuiAPI
{
///
/// 通知公告
///
[DynamicApi(Area = AdminConsts.DiTuiName)]
public class NoticeService : BaseService, INoticeService, IDynamicApi
{
private NoticeRepository _noticeRepository;
public NoticeService(NoticeRepository noticeRepository)
{
_noticeRepository = noticeRepository;
}
///
/// 公告列表
///
///
[HttpGet]
[NoOprationLog]
public async Task> IndexAsync(PageInput input)
{
var uId = User?.Id;
var tenantId = User.TenantId;
//List notices = new List();
// 公告
//notices.Add(new Notices("最新","平台悬赏任务、游戏试玩任务上线通知…","11"));
//notices.Add(new Notices("重要", "快手极速版直推版价格政策调整通知", "22"));
//notices.Add(new Notices("最新", "12月平台项目重要通知请注意查看!12月平台项目重要通知请注意查看!", "33"));
var notices = _noticeRepository.Select.DisableGlobalFilter(FilterNames.Tenant)
.Where(a => a.IsAlter == 0)
.OrderByDescending(m => m.Rank)
.Page(input.CurrentPage, input.PageSize)
.ToList(m => new NoticeOutput()
{
Id = m.Id,
Title = m.Title,
Desc = m.Desc,
//Desc = System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.Regex.Replace(m.Content, "<[^>]+>", ""), "&[^;]+;", ""),
//Desc = Regex.Replace(m.Content, "<.*?>", string.Empty),
CreateTime = string.Format("{0:yyyy-MM-dd HH:mm:ss}", m.CreatedTime),
Unread = "1"
});
foreach(var item in notices)
{
}
var data = new PageOutput()
{
List = notices,
Total = notices.Count()
};
return data;
}
///
/// 公告详情
///
///
///
[HttpGet]
[NoOprationLog]
public async Task GetDetailAsync(long id = 0)
{
if(id == 0)
{
throw ResultOutput.Exception("ID不可为空");
}
var noticeDetail = await _noticeRepository.Select.DisableGlobalFilter(FilterNames.Tenant).FirstAsync(a => new NoticeDetailOutput() {
Id = a.Id,
Title = a.Title,
Content = a.Content,
CreateTime = string.Format("{0:yyyy-MM-dd HH:mm:ss}", a.CreatedTime),
});
return noticeDetail;
}
}
}