using Edu.Model.Entity.Log;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
using VT.Repository;

namespace Edu.Module.Log
{
    /// <summary>
    /// 系统日志处理类
    /// </summary>
    public class LogModule
    {
        /// <summary>
        /// 系统消息仓储层对象
        /// </summary>
        private readonly RB_MsgLogRepository msgLogRepository = new RB_MsgLogRepository();

        /// <summary>
        /// 获取消息推送列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_MsgLog> GetMsgLogListModule(RB_MsgLog query)
        {
            return msgLogRepository.GetMsgLogListRepository(query);
        }


        /// <summary>
        /// 更新消息阅读状态
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public virtual bool SetMsgReadModule(List<int> ids)
        {
            bool flag = true;
            Dictionary<string, object> fileds = new Dictionary<string, object>()
            {
                {nameof(RB_MsgLog.IsRead),1 }
            };
            foreach (var item in ids)
            {
                if (item > 0 && flag)
                {
                    flag= msgLogRepository.Update(fileds, new WhereHelper(nameof(RB_MsgLog.Id), item));
                }
            }
            return flag;
        }
    }
}
