src/ZKEACMS.Message/Service/MessageBoxWidgetService.cs

(完整代码) 1KB

/* http://www.zkea.net/ 
 * Copyright (c) ZKEASOFT. All rights reserved. 
 * http://www.zkea.net/licenses */

using Easy;
using Easy.Constant;
using Easy.RepositoryPattern;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using ZKEACMS.Message.Models;
using ZKEACMS.Message.ViewModel;
using ZKEACMS.Widget;

namespace ZKEACMS.Message.Service
{
    public class MessageBoxWidgetService : SimpleWidgetService<MessageBoxWidget>
    {
        private readonly IMessageService _messageService;
        public MessageBoxWidgetService(IWidgetBasePartService widgetBasePartService, IApplicationContext applicationContext, IMessageService messageService, CMSDbContext dbContext)
            : base(widgetBasePartService, applicationContext, dbContext)
        {
            _messageService = messageService;
        }

        public override object Display(WidgetDisplayContext widgetDisplayContext)
        {
            int page = widgetDisplayContext.ActionContext.RouteData.GetPage();
            Pagination pagination = new Pagination()
            {
                PageIndex = page,
                PageSize = 20,
                OrderByDescending = "CreateDate"
            };
            var messages = _messageService.Get(m => m.Status == (int)RecordStatus.Active, pagination);
            return new MessageBoxWidgetViewModel
            {
                Messages = messages,
                Pagination = pagination
            };
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。