using Edu.Model.ViewModel.Web;
using Edu.Repository.Web;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;

namespace Edu.Module.Web
{
    /// <summary>
    /// 招聘管理处理类
    /// </summary>
    public class WebRecruitmentModule
    {
        /// <summary>
        /// 招聘类型仓储层对象
        /// </summary>
        private readonly RB_Web_RecruitmentTypeRepository web_RecruitmentTypeRepository = new RB_Web_RecruitmentTypeRepository();

        /// <summary>
        /// 招聘管理仓储层对象
        /// </summary>
        private readonly RB_Web_RecruitmentRepository web_RecruitmentRepository = new RB_Web_RecruitmentRepository();

        /// <summary>
        /// 招聘岗位申请仓储层对象
        /// </summary>
        private readonly RB_Web_JobApplyRepository web_JobApplyRepository = new RB_Web_JobApplyRepository();

        #region 招聘类型管理

        /// <summary>
        /// 获取招聘类型分页列表
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="rowsCount"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Web_RecruitmentType_ViewModel> GetWebRecruitmentTypePageModule(int pageIndex, int pageSize, out long rowsCount, RB_Web_RecruitmentType_ViewModel query)
        {
            return web_RecruitmentTypeRepository.GetWebRecruitmentTypePageRepository(pageIndex, pageSize, out rowsCount, query);
        }

        /// <summary>
        /// 获取招聘类型列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Web_RecruitmentType_ViewModel> GetWebRecruitmentTypeListModule(RB_Web_RecruitmentType_ViewModel query)
        {
            return web_RecruitmentTypeRepository.GetWebRecruitmentTypeListRepository(query);
        }

        /// <summary>
        /// 新增修改招聘类型
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool SetWebRecruitmentTypeModule(RB_Web_RecruitmentType_ViewModel model)
        {
            bool flag;
            if (model.Id > 0)
            {
                Dictionary<string, object> fileds = new Dictionary<string, object>()
                {
                    {nameof(RB_Web_RecruitmentType_ViewModel.TypeName),model.TypeName },
                    {nameof(RB_Web_RecruitmentType_ViewModel.ImgCover),model.ImgCover },
                    {nameof(RB_Web_RecruitmentType_ViewModel.CheckImg),model.CheckImg },
                };
                flag = web_RecruitmentTypeRepository.Update(fileds, new WhereHelper(nameof(RB_Web_RecruitmentType_ViewModel.Id), model.Id));
            }
            else
            {
                var newId = web_RecruitmentTypeRepository.Insert(model);
                model.Id = newId;
                flag = newId > 0;
            }
            return flag;
        }

        /// <summary>
        /// 根据编号获取招聘类型详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public RB_Web_RecruitmentType_ViewModel GetWebRecruitmentTypeModule(object Id)
        {
            return web_RecruitmentTypeRepository.GetEntity<RB_Web_RecruitmentType_ViewModel>(Id);
        }

        /// <summary>
        /// 修改招聘类型状态
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="Status">0-正常,1-删除</param>
        /// <returns></returns>
        public bool RemoveWebRecruitmentTypeStatusModule(int Id, int Status)
        {
            Dictionary<string, object> fileds = new Dictionary<string, object>()
            {
                {nameof(RB_Web_RecruitmentType_ViewModel.Status),Status },
            };
            var flag = web_RecruitmentTypeRepository.Update(fileds, new WhereHelper(nameof(RB_Web_RecruitmentType_ViewModel.Id), Id));
            return flag;
        }

        #endregion

        #region 招聘信息管理

        /// <summary>
        /// 获取招聘信息分页列表
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="rowsCount"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Web_Recruitment_ViewModel> GetWebRecruitmentPageModule(int pageIndex, int pageSize, out long rowsCount, RB_Web_Recruitment_ViewModel query)
        {
            return web_RecruitmentRepository.GetWebRecruitmentPageRepository(pageIndex, pageSize, out rowsCount, query);
        }

        /// <summary>
        /// 新增修改招聘信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool SetWebRecruitmentModule(RB_Web_Recruitment_ViewModel model)
        {
            bool flag;
            if (model.Id > 0)
            {
                Dictionary<string, object> fileds = new Dictionary<string, object>()
                {
                    {nameof(RB_Web_Recruitment_ViewModel.TypeId),model.TypeId },
                    {nameof(RB_Web_Recruitment_ViewModel.PositionName),model.PositionName },
                    {nameof(RB_Web_Recruitment_ViewModel.SalaryType),model.SalaryType },
                    {nameof(RB_Web_Recruitment_ViewModel.SalaryStart),model.SalaryStart },
                    {nameof(RB_Web_Recruitment_ViewModel.SalaryEnd),model.SalaryEnd },
                    {nameof(RB_Web_Recruitment_ViewModel.SalaryNum),model.SalaryNum },
                    {nameof(RB_Web_Recruitment_ViewModel.Experience),model.Experience },
                    {nameof(RB_Web_Recruitment_ViewModel.Education),model.Education },
                    {nameof(RB_Web_Recruitment_ViewModel.WorkPlace),model.WorkPlace },
                    {nameof(RB_Web_Recruitment_ViewModel.PublishTime),model.PublishTime },
                    {nameof(RB_Web_Recruitment_ViewModel.PositionDesc),model.PositionDesc },
                };
                flag = web_RecruitmentRepository.Update(fileds, new WhereHelper(nameof(RB_Web_Recruitment_ViewModel.Id), model.Id));
            }
            else
            {
                var newId = web_RecruitmentRepository.Insert(model);
                model.Id = newId;
                flag = newId > 0;
            }
            return flag;
        }

        /// <summary>
        /// 根据编号获取招聘详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public RB_Web_Recruitment_ViewModel GetWebRecruitmentModule(object Id)
        {
            return web_RecruitmentRepository.GetEntity<RB_Web_Recruitment_ViewModel>(Id);
        }

        /// <summary>
        /// 修改招聘状态
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="Status">0-正常,1-删除</param>
        /// <returns></returns>
        public bool RemoveWebRecruitmentStatusModule(int Id, int Status)
        {
            Dictionary<string, object> fileds = new Dictionary<string, object>()
            {
                {nameof(RB_Web_Recruitment_ViewModel.Status),Status },
            };
            var flag = web_RecruitmentRepository.Update(fileds, new WhereHelper(nameof(RB_Web_Recruitment_ViewModel.Id), Id));
            return flag;
        }
     
        #endregion

        #region 招聘申请管理

        /// <summary>
        /// 获取招聘申请分页列表
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="rowsCount"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Web_JobApply_ViewModel> GetWebJobApplyPageModule(int pageIndex, int pageSize, out long rowsCount, RB_Web_JobApply_ViewModel query)
        {
            return web_JobApplyRepository.GetWebJobApplyPageRepository(pageIndex, pageSize, out rowsCount, query);
        }

        /// <summary>
        /// 新增招聘申请
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddWebJobApplyModule(RB_Web_JobApply_ViewModel model)
        {
            bool flag;
            var newId = web_JobApplyRepository.Insert(model);
            model.Id = newId;
            flag = newId > 0;
            return flag;
        }

        /// <summary>
        /// 根据编号获取招聘申请
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public RB_Web_JobApply_ViewModel GetWebJobApplyModule(object Id)
        {
            return web_JobApplyRepository.GetEntity<RB_Web_JobApply_ViewModel>(Id);
        }

        /// <summary>
        /// 修改招聘申请状态
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="Status">0-正常,1-删除</param>
        /// <returns></returns>
        public bool RemoveWebJobApplyStatusModule(int Id, int Status)
        {
            Dictionary<string, object> fileds = new Dictionary<string, object>()
            {
                {nameof(RB_Web_JobApply_ViewModel.Status),Status },
            };
            var flag = web_JobApplyRepository.Update(fileds, new WhereHelper(nameof(RB_Web_JobApply_ViewModel.Id), Id));
            return flag;
        }

        /// <summary>
        /// 修改招聘申请信息
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="ApplyStatus"></param>
        /// <param name="ApplyContent"></param>
        /// <returns></returns>
        public bool UpdateWebJobApplyModule(int Id, int ApplyStatus,string ApplyContent)
        {
            Dictionary<string, object> fileds = new Dictionary<string, object>()
            {
                {nameof(RB_Web_JobApply_ViewModel.ApplyStatus),ApplyStatus },
                {nameof(RB_Web_JobApply_ViewModel.ApplyContent),ApplyContent },
            };
            var flag = web_JobApplyRepository.Update(fileds, new WhereHelper(nameof(RB_Web_JobApply_ViewModel.Id), Id));
            return flag;
        }
        #endregion
    }
}