123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- 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
- {
- /// <summary>
- /// 通知公告
- /// </summary>
- [DynamicApi(Area = AdminConsts.DiTuiName)]
- public class NoticeService : BaseService, INoticeService, IDynamicApi
- {
- private NoticeRepository _noticeRepository;
- public NoticeService(NoticeRepository noticeRepository)
- {
- _noticeRepository = noticeRepository;
- }
- /// <summary>
- /// 公告列表
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- [NoOprationLog]
- public async Task<PageOutput<NoticeOutput>> IndexAsync(PageInput input)
- {
- var uId = User?.Id;
- var tenantId = User.TenantId;
- //List<Notices> notices = new List<Notices>();
- // 公告
- //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<NoticeOutput>()
- {
- List = notices,
- Total = notices.Count()
- };
- return data;
- }
- /// <summary>
- /// 公告详情
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet]
- [NoOprationLog]
- public async Task<NoticeDetailOutput> 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;
- }
- }
- }
|