using Edu.Cache.User;
using Edu.Common.API;
using Edu.Common.Enum;
using Edu.Common.Enum.Web;
using Edu.Common.Plugin;
using Edu.Model.ViewModel.Web;
using Edu.Module.Web;
using Edu.WebApi.Filter;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using System;

namespace Edu.WebApi.Controllers.Web
{
    [Route("api/[controller]/[action]")]
    [ApiExceptionFilter]
    [ApiController]
    [EnableCors("AllowCors")]
    public class WebManagerController : BaseController
    {
        /// <summary>
        /// 网站导航处理类对象
        /// </summary>
        private readonly WebNavModule navModule = new WebNavModule();

        /// <summary>
        /// 网站菜单管理处理类对象
        /// </summary>
        private readonly WebMenuModule menuModule = new WebMenuModule();

        /// <summary>
        /// 网站新闻管理处理类对象
        /// </summary>
        private readonly WebNewsModule newsModule = new WebNewsModule();

        /// <summary>
        /// 教师团队管理处理类对象
        /// </summary>
        private readonly WebTeacherModule teacherModule = new WebTeacherModule();

        /// <summary>
        /// 咨询管理处理类对象
        /// </summary>
        private readonly WebAdvisoryModule advisoryModule = new WebAdvisoryModule();

        /// <summary>
        /// 招聘管理处理类对象
        /// </summary>
        private readonly WebRecruitmentModule webRecruitmentModule = new WebRecruitmentModule();

        #region 网站导航管理
        /// <summary>
        /// 获取网站导航列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebNavList()
        {
            var query = new RB_Web_Nav_ViewModel()
            {
                NavTitle = base.ParmJObj.GetStringValue("NavTitle"),
                SubTitle = base.ParmJObj.GetStringValue("SubTitle"),
                NavType = (NavTypeEnum)base.ParmJObj.GetInt("NavType"),
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = navModule.GetWebNavListModule(query);
            return ApiResult.Success(data: list);
        }

        /// <summary>
        /// 获取网站导航分页
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebNavPage()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = new RB_Web_Nav_ViewModel()
            {
                NavTitle = base.ParmJObj.GetStringValue("NavTitle"),
                SubTitle = base.ParmJObj.GetStringValue("SubTitle"),
                NavType = (NavTypeEnum)base.ParmJObj.GetInt("NavType"),
                Status = (DateStateEnum)base.ParmJObj.GetInt("Status"),
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = navModule.GetWebNavPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 新增修改网站导航
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetWebNav()
        {
            var extModel = new RB_Web_Nav_ViewModel()
            {
                Id = base.ParmJObj.GetInt("Id"),
                NavTitle = base.ParmJObj.GetStringValue("NavTitle"),
                SubTitle = base.ParmJObj.GetStringValue("SubTitle"),
                NavType = (NavTypeEnum)base.ParmJObj.GetInt("NavType"),
                LinkUrl = base.ParmJObj.GetStringValue("LinkUrl"),
                BgImg = base.ParmJObj.GetStringValue("BgImg"),
            };
            extModel.School_Id = base.UserInfo.School_Id;
            extModel.Group_Id = base.UserInfo.Group_Id;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.CreateDate = DateTime.Now;
            extModel.Status = DateStateEnum.Normal;
            bool flag = navModule.SetWebNavModule(extModel);
            return flag ? ApiResult.Success(data: extModel) : ApiResult.Failed();
        }

        /// <summary>
        /// 获取网站导航详情
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebNav()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var extModel = navModule.GetWebNavModule(Id);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 修改网站导航状态
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveWebNavStatus()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var Status = base.ParmJObj.GetInt("Status", 0);
            var flag = navModule.RemoveWebNavStatusModule(Id, Status);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        /// <summary>
        /// 获取导航类型列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetNavTypeList()
        {
            var list = Common.Plugin.EnumHelper.EnumToList(typeof(NavTypeEnum));
            return ApiResult.Success(data: list);
        }

        #endregion

        #region 网站菜单管理

        /// <summary>
        /// 获取网站菜单列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebMenuList()
        {
            var query = new RB_Web_Menu_ViewModel()
            {
                Name = base.ParmJObj.GetStringValue("Name"),
                MenuLevel = base.ParmJObj.GetInt("MenuLevel"),
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = menuModule.GetWebMenuListModule(query);
            return ApiResult.Success(data: list);
        }

        /// <summary>
        /// 获取网站菜单分页
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebMenuPage()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = new RB_Web_Menu_ViewModel()
            {
                Name = base.ParmJObj.GetStringValue("Name"),
                Status = (DateStateEnum)base.ParmJObj.GetInt("Status"),
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = menuModule.GetWebMenuPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 新增修改网站菜单
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetWebMenu()
        {
            var extModel = new RB_Web_Menu_ViewModel()
            {
                Id = base.ParmJObj.GetInt("Id"),
                Name = base.ParmJObj.GetStringValue("Name"),
                MenuUrl = base.ParmJObj.GetStringValue("MenuUrl"),
                ParentId = base.ParmJObj.GetInt("ParentId"),
                MenuLevel = base.ParmJObj.GetInt("MenuLevel"),
                ClassName = base.ParmJObj.GetStringValue("ClassName"),
                Icon = base.ParmJObj.GetStringValue("Icon"),
                SortNum = base.ParmJObj.GetInt("SortNum"),
            };
            extModel.School_Id = base.UserInfo.School_Id;
            extModel.Group_Id = base.UserInfo.Group_Id;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.CreateDate = DateTime.Now;
            extModel.Status = DateStateEnum.Normal;
            bool flag = menuModule.SetWebMenuModule(extModel);
            return flag ? ApiResult.Success(data: extModel) : ApiResult.Failed();
        }

        /// <summary>
        /// 获取网站菜单详情
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebMenu()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var extModel = menuModule.GetWebMenuModule(Id);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 修改网站菜单状态
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveWebMenuStatus()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var Status = base.ParmJObj.GetInt("Status", 0);
            var flag = menuModule.RemoveWebMenuStatusModule(Id, Status);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        #endregion

        #region 新闻管理
        /// <summary>
        /// 获取网站新闻类型列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebNewsTypeList()
        {
            var query = new RB_Web_NewsType_ViewModel()
            {
                TypeName = base.ParmJObj.GetStringValue("TypeName"),
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = newsModule.GetWebNewsTypeListModule(query);
            return ApiResult.Success(data: list);
        }

        /// <summary>
        /// 获取新闻类型分页
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebNewsTypePage()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = new RB_Web_NewsType_ViewModel()
            {
                TypeName = base.ParmJObj.GetStringValue("TypeName"),
                Status = (DateStateEnum)base.ParmJObj.GetInt("Status"),
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = newsModule.GetWebNewsTypePageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 新增修改网站新闻类型
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetWebNewsType()
        {
            var extModel = new RB_Web_NewsType_ViewModel()
            {
                Id = base.ParmJObj.GetInt("Id"),
                TypeName = base.ParmJObj.GetStringValue("TypeName"),
                Image = base.ParmJObj.GetStringValue("Image"),
            };
            extModel.School_Id = base.UserInfo.School_Id;
            extModel.Group_Id = base.UserInfo.Group_Id;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.CreateDate = DateTime.Now;
            extModel.Status = DateStateEnum.Normal;
            bool flag = newsModule.SetWebNewsTypeModule(extModel);
            return flag ? ApiResult.Success(data: extModel) : ApiResult.Failed();
        }

        /// <summary>
        /// 获取网站新闻类型详情
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebNewsType()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var extModel = newsModule.GetWebNewsTypeModule(Id);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 修改网站新闻类型状态
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveWebNewsTypeStatus()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var Status = base.ParmJObj.GetInt("Status", 0);
            var flag = newsModule.RemoveWebNewsTypeStatusModule(Id, Status);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }


        /// <summary>
        /// 获取网站新闻列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebNewsList()
        {
            var query = new RB_Web_News_ViewModel()
            {
                Title = base.ParmJObj.GetStringValue("Title"),
                TypeId = base.ParmJObj.GetInt("TypeId"),
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = newsModule.GetWebNewsListModule(query);
            return ApiResult.Success(data: list);
        }

        /// <summary>
        /// 获取新闻分页
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebNewsPage()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = new RB_Web_News_ViewModel()
            {
                Title = base.ParmJObj.GetStringValue("Title"),
                TypeId = base.ParmJObj.GetInt("TypeId"),
                Status = (DateStateEnum)base.ParmJObj.GetInt("Status"),
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = newsModule.GetWebNewsPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 新增修改网站新闻
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetWebNews()
        {
            var extModel = new RB_Web_News_ViewModel()
            {
                Id = base.ParmJObj.GetInt("Id"),
                Title = base.ParmJObj.GetStringValue("Title"),
                Img = base.ParmJObj.GetStringValue("Img"),
                Content = base.ParmJObj.GetStringValue("Content"),
                TypeId = base.ParmJObj.GetInt("TypeId"),
            };
            extModel.School_Id = base.UserInfo.School_Id;
            extModel.Group_Id = base.UserInfo.Group_Id;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.CreateDate = DateTime.Now;
            extModel.Status = DateStateEnum.Normal;
            bool flag = newsModule.SetWebNewsModule(extModel);
            return flag ? ApiResult.Success(data: extModel) : ApiResult.Failed();
        }

        /// <summary>
        /// 获取网站新闻详情
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebNews()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var extModel = newsModule.GetWebNewsModule(Id);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 修改网站新闻状态
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveWebNewsStatus()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var Status = base.ParmJObj.GetInt("Status", 0);
            var flag = newsModule.RemoveWebNewsStatusModule(Id, Status);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }
        #endregion

        #region 教师团队管理

        /// <summary>
        /// 获取教师团队列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebTeacherList()
        {
            var query = new RB_Web_Teacher_ViewModel()
            {
                Name = base.ParmJObj.GetStringValue("Name"),
                Type = base.ParmJObj.GetInt("Type"),
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = teacherModule.GetWebTeacherListModule(query);
            return ApiResult.Success(data: list);
        }

        /// <summary>
        /// 获取教师团队分页
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebTeacherPage()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = new RB_Web_Teacher_ViewModel()
            {
                Name = base.ParmJObj.GetStringValue("Name"),
                Type = base.ParmJObj.GetInt("Type"),
                Status = (DateStateEnum)base.ParmJObj.GetInt("Status"),
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = teacherModule.GetWebTeacherPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 新增修改教师团队
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetWebTeacher()
        {
            var extModel = new RB_Web_Teacher_ViewModel()
            {
                Id = base.ParmJObj.GetInt("Id"),
                Name = base.ParmJObj.GetStringValue("Name"),
                Icon = base.ParmJObj.GetStringValue("Icon"),
                Intro = base.ParmJObj.GetStringValue("Intro"),
                Type = base.ParmJObj.GetInt("Type"),
                Sex = base.ParmJObj.GetInt("Sex"),
            };
            extModel.School_Id = base.UserInfo.School_Id;
            extModel.Group_Id = base.UserInfo.Group_Id;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.CreateDate = DateTime.Now;
            extModel.Status = DateStateEnum.Normal;
            bool flag = teacherModule.SetWebTeacherModule(extModel);
            return flag ? ApiResult.Success(data: extModel) : ApiResult.Failed();
        }

        /// <summary>
        /// 根据编号获取教师团队详情
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebTeacher()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var extModel = teacherModule.GetWebTeacherModule(Id);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 修改教师团队状态
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveWebTeacherStatus()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var Status = base.ParmJObj.GetInt("Status", 0);
            var flag = teacherModule.RemoveWebTeacherStatusModule(Id, Status);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        #endregion

        #region 咨询管理

        /// <summary>
        /// 获取咨询管理分页
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebAdvisoryPage()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = new RB_Web_Advisory_ViewModel()
            {
                LinkMan = base.ParmJObj.GetStringValue("LinkMan"),
                DealStatus = base.ParmJObj.GetInt("DealStatus"),
                Status = (DateStateEnum)base.ParmJObj.GetInt("Status"),
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = advisoryModule.GetWebAdvisoryPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            foreach (var item in list)
            {
                if (item.DealBy > 0)
                {
                    item.DealByName = UserReidsCache.GetUserLoginInfo(item.DealBy)?.AccountName ?? "";
                }
            }
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 根据编号获取咨询详情
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebAdvisory()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var extModel = advisoryModule.GetWebAdvisoryModule(Id);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 修改咨询
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult UpdateWebAdvisory()
        {
            var extModel = new RB_Web_Advisory_ViewModel()
            {
                Id = base.ParmJObj.GetInt("Id"),
                DealContent = base.ParmJObj.GetStringValue("DealContent"),
                DealStatus = base.ParmJObj.GetInt("DealStatus"),
            };
            extModel.School_Id = base.UserInfo.School_Id;
            extModel.DealBy = base.UserInfo.Id;
            extModel.DealTime = DateTime.Now;
            bool flag = advisoryModule.UpdateWebAdvisoryModule(extModel);
            return flag ? ApiResult.Success(data: extModel) : ApiResult.Failed();
        }

        /// <summary>
        /// 修改咨询状态
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveWebAdvisoryStatus()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var Status = base.ParmJObj.GetInt("Status", 0);
            var flag = advisoryModule.RemoveWebAdvisoryStatusModule(Id, Status);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }
        #endregion

        #region 品牌动漫管理

        /// <summary>
        /// 获取品牌卡通分页列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebCartoonPage()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = new RB_Web_Cartoon_ViewModel()
            {
                Name = base.ParmJObj.GetStringValue("Name"),
                Status = (DateStateEnum)base.ParmJObj.GetInt("Status"),
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = newsModule.GetWebCartoonPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 新增修改品牌动漫
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetWebCartoon()
        {
            var extModel = new RB_Web_Cartoon_ViewModel()
            {
                Id = base.ParmJObj.GetInt("Id"),
                Name = base.ParmJObj.GetStringValue("Name"),
                LinkUrl = base.ParmJObj.GetStringValue("LinkUrl"),
            };
            extModel.School_Id = base.UserInfo.School_Id;
            extModel.Group_Id = base.UserInfo.Group_Id;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.CreateDate = DateTime.Now;
            extModel.Status = DateStateEnum.Normal;
            bool flag = newsModule.SetWebCartoonModule(extModel);
            return flag ? ApiResult.Success(data: extModel) : ApiResult.Failed();
        }

        /// <summary>
        /// 根据编号获取品牌卡通详情
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebCartoon()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var extModel = newsModule.GetWebCartoonModule(Id);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 修改品牌卡通状态
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveWebCartoonStatus()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var Status = base.ParmJObj.GetInt("Status", 0);
            var flag = newsModule.RemoveWebCartoonStatusModule(Id, Status);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        #endregion

        #region 品牌月刊管理

        /// <summary>
        /// 获取品牌月刊分页列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebMonthlyPage()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = new RB_Web_Monthly_ViewModel()
            {
                Name = base.ParmJObj.GetStringValue("Name"),
                Status = (DateStateEnum)base.ParmJObj.GetInt("Status"),
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = newsModule.GetWebMonthlyPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 新增修改品牌月刊
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetWebMonthly()
        {
            var extModel = new RB_Web_Monthly_ViewModel()
            {
                Id = base.ParmJObj.GetInt("Id"),
                Name = base.ParmJObj.GetStringValue("Name"),
                CoverImg = base.ParmJObj.GetStringValue("CoverImg"),
                LinkUrl = base.ParmJObj.GetStringValue("LinkUrl"),
            };
            extModel.School_Id = base.UserInfo.School_Id;
            extModel.Group_Id = base.UserInfo.Group_Id;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.CreateDate = DateTime.Now;
            extModel.Status = DateStateEnum.Normal;
            bool flag = newsModule.SetWebMonthlyModule(extModel);
            return flag ? ApiResult.Success(data: extModel) : ApiResult.Failed();
        }

        /// <summary>
        /// 根据编号获取品牌月刊详情
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebMonthly()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var extModel = newsModule.GetWebMonthlyModule(Id);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 修改品牌月刊状态
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveWebMonthlyStatus()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var Status = base.ParmJObj.GetInt("Status", 0);
            var flag = newsModule.RemoveWebMonthlyStatusModule(Id, Status);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        #endregion

        #region 招聘管理

        /// <summary>
        /// 获取招聘类型分页列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebRecruitmentTypePage()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = new RB_Web_RecruitmentType_ViewModel()
            {
                TypeName = base.ParmJObj.GetStringValue("TypeName"),
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = webRecruitmentModule.GetWebRecruitmentTypePageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 获取招聘类型列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebRecruitmentTypeList()
        {
            var query = new RB_Web_RecruitmentType_ViewModel()
            {
                TypeName = base.ParmJObj.GetStringValue("TypeName"),
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = webRecruitmentModule.GetWebRecruitmentTypeListModule(query);
            return ApiResult.Success(data: list);
        }

        /// <summary>
        /// 新增修改招聘类型
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetWebRecruitmentType()
        {
            var extModel = new RB_Web_RecruitmentType_ViewModel()
            {
                Id = base.ParmJObj.GetInt("Id"),
                TypeName = base.ParmJObj.GetStringValue("TypeName"),
                ImgCover = base.ParmJObj.GetStringValue("ImgCover"),
                CheckImg=base.ParmJObj.GetStringValue("CheckImg"),
            };
            extModel.School_Id = base.UserInfo.School_Id;
            extModel.Group_Id = base.UserInfo.Group_Id;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.CreateDate = DateTime.Now;
            extModel.Status = DateStateEnum.Normal;
            bool flag = webRecruitmentModule.SetWebRecruitmentTypeModule(extModel);
            return flag ? ApiResult.Success(data: extModel) : ApiResult.Failed();
        }

        /// <summary>
        /// 根据编号获取招聘类型详情
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebRecruitmentType()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var extModel = webRecruitmentModule.GetWebRecruitmentTypeModule(Id);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 修改招聘类型状态
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveWebRecruitmentTypeStatus()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var Status = base.ParmJObj.GetInt("Status", 0);
            var flag = webRecruitmentModule.RemoveWebRecruitmentTypeStatusModule(Id, Status);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }


        /// <summary>
        /// 获取招聘信息分页列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebRecruitmentPage()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = new RB_Web_Recruitment_ViewModel()
            {
                PositionName = base.ParmJObj.GetStringValue("PositionName"),
                TypeId = base.ParmJObj.GetInt("TypeId")
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = webRecruitmentModule.GetWebRecruitmentPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 新增修改招聘信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetWebRecruitment()
        {
            var extModel = new RB_Web_Recruitment_ViewModel()
            {
                Id = base.ParmJObj.GetInt("Id"),
                TypeId = base.ParmJObj.GetInt("TypeId"),
                PositionName = base.ParmJObj.GetStringValue("PositionName"),
                SalaryType = base.ParmJObj.GetInt("SalaryType"),
                SalaryStart = base.ParmJObj.GetDecimal("SalaryStart"),
                SalaryEnd = base.ParmJObj.GetDecimal("SalaryEnd"),
                SalaryNum = base.ParmJObj.GetInt("SalaryNum"),
                Experience = base.ParmJObj.GetStringValue("Experience"),
                Education = base.ParmJObj.GetStringValue("Education"),
                WorkPlace = base.ParmJObj.GetStringValue("WorkPlace"),
                PositionDesc = base.ParmJObj.GetStringValue("PositionDesc"),
            };
            extModel.PublishTime = DateTime.Now;
            extModel.School_Id = base.UserInfo.School_Id;
            extModel.Group_Id = base.UserInfo.Group_Id;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.CreateDate = DateTime.Now;
            extModel.Status = DateStateEnum.Normal;
            bool flag = webRecruitmentModule.SetWebRecruitmentModule(extModel);
            return flag ? ApiResult.Success(data: extModel) : ApiResult.Failed();
        }

        /// <summary>
        /// 根据编号获取招聘详情
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebRecruitment()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var extModel = webRecruitmentModule.GetWebRecruitmentModule(Id);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 修改招聘状态
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveWebRecruitmentStatus()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var Status = base.ParmJObj.GetInt("Status", 0);
            var flag = webRecruitmentModule.RemoveWebRecruitmentStatusModule(Id, Status);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }
        #endregion

        #region 招聘申请管理

        /// <summary>
        /// 获取招聘类型分页列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebJobApplyPage()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = new RB_Web_JobApply_ViewModel()
            {
                LinkMan = base.ParmJObj.GetStringValue("LinkMan"),
                PositionName = base.ParmJObj.GetStringValue("PositionName"),
            };
            query.Group_Id = base.UserInfo.Group_Id;
            var list = webRecruitmentModule.GetWebJobApplyPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 根据编号获取招聘申请
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetWebJobApply()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var extModel = webRecruitmentModule.GetWebJobApplyModule(Id);
            var obj = new object();
            if (extModel != null && extModel.Id > 0)
            {
                RB_Web_Recruitment_ViewModel model = new RB_Web_Recruitment_ViewModel();
                if (extModel.RecruitmentId > 0)
                {
                    model = webRecruitmentModule.GetWebRecruitmentModule(extModel.RecruitmentId);
                }
                obj = new
                {
                    RecruitmentInfo= model,
                    JobInfo = extModel,
                };
            }
            return ApiResult.Success(data: obj);
        }

        /// <summary>
        /// 修改招聘申请状态
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveWebJobApplyStatus()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var Status = base.ParmJObj.GetInt("Status", 0);
            var flag = webRecruitmentModule.RemoveWebJobApplyStatusModule(Id, Status);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        /// <summary>
        /// 修改招聘申请信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult UpdateWebJobApply()
        {
            var Id = base.ParmJObj.GetInt("Id", 0);
            var ApplyStatus = base.ParmJObj.GetInt("ApplyStatus", 0);
            string ApplyContent = base.ParmJObj.GetStringValue("ApplyContent");
            var flag = webRecruitmentModule.UpdateWebJobApplyModule(Id, ApplyStatus, ApplyContent);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }
        #endregion
    }
}
