using Edu.Model.ViewModel.Log;
using Edu.Repository.Log;
using System;
using System.Collections.Generic;
using System.Text;

namespace Edu.Module.Log
{
    public class UserChangeLogModule
    {
        /// <summary>
        /// 用户信息修改日志仓储层对象
        /// </summary>
        private readonly RB_User_ChangeLogRepository changeLogRepository = new RB_User_ChangeLogRepository();

        /// <summary>
        /// 获取用户信息改变日志列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_User_ChangeLog_ViewModel> GetUserChangeLogListModule(RB_User_ChangeLog_ViewModel query)
        {
            return changeLogRepository.GetUserChangeLogListRepository(query);
        }

        /// <summary>
        /// 新增日志
        /// </summary>
        /// <param name="extModel"></param>
        /// <returns></returns>
        public bool SetUserChangeLogModule(RB_User_ChangeLog_ViewModel extModel)
        {
           return changeLogRepository.Insert(extModel) > 0;
        }

        /// <summary>
        /// 新增日志
        /// </summary>
        /// <param name="CreateBy">创建人</param>
        /// <param name="GroupId">集团编号</param>
        /// <param name="SchoolId">校区编号</param>
        /// <param name="content">日志内容</param>
        /// <returns></returns>
        public bool SetUserChangeLogModule(int CreateBy, int GroupId,int SchoolId,string content)
        {
            RB_User_ChangeLog_ViewModel model = new RB_User_ChangeLog_ViewModel()
            {
                Id = 0,
                CreateBy = CreateBy,
                CreateTime = DateTime.Now,
                Group_Id = GroupId,
                School_Id = SchoolId,
                LogContent = content.TrimStart(',')
            };
            return changeLogRepository.Insert(model) > 0; 
        }
    }
}
