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

namespace Edu.WebApi.Controllers.Course
{
    [Route("api/[controller]/[action]")]
    [ApiExceptionFilter]
    [ApiController]
    [EnableCors("AllowCors")]
    public class CourseController : BaseController
    {
        /// <summary>
        /// 课程分类处理类
        /// </summary>
        private readonly CourseCategoryModule categoryModule = new CourseCategoryModule();

        /// <summary>
        /// 课程处理类对象
        /// </summary>
        private readonly CourseModule courseModule = new CourseModule();

        #region 课程分类管理
        /// <summary>
        /// 获取课程分类分页列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetCourseCategoryPageList()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Category_ViewModel>(RequestParm.Msg.ToString());
            query.Group_Id = base.UserInfo.Group_Id;
            query.School_Id = base.UserInfo.School_Id;
            var list = categoryModule.GetCourseCategoryPageListModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            foreach (var item in list)
            {
                if (item.CreateBy > 0)
                {
                    item.CreateByName = UserReidsCache.GetUserLoginInfo(item.CreateBy)?.AccountName ?? "";
                }
                if (item.UpdateBy > 0)
                {
                    item.UpdateByName = UserReidsCache.GetUserLoginInfo(item.UpdateBy)?.AccountName ?? "";
                }
            }
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 获取课程分类列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetCourseCategoryList()
        {
            var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Category_ViewModel>(RequestParm.Msg.ToString());
            query.Group_Id = base.UserInfo.Group_Id;
            query.School_Id = base.UserInfo.School_Id;
            var list = categoryModule.GetCourseCategoryListModule(query);
            return ApiResult.Success(data: list);
        }

        /// <summary>
        /// 获取课程分类树形列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetChildCategoryList()
        {
            var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Category_ViewModel>(RequestParm.Msg.ToString());
            query.Group_Id = base.UserInfo.Group_Id;
            query.School_Id = base.UserInfo.School_Id;
            var cateIds = base.ParmJObj.GetStringValue("cateIds");
            var list = categoryModule.GetChildCategoryStringModule(cateIds);
            return ApiResult.Success(data: list);
        }

        /// <summary>
        /// 获取课程分类树形列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetCourseCategoryTree()
        {
            var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Category_ViewModel>(RequestParm.Msg.ToString());
            query.Group_Id = base.UserInfo.Group_Id;
            query.School_Id = base.UserInfo.School_Id;
            var list = categoryModule.GetCourseCategoryTreeListModule(query);
            return ApiResult.Success(data: list);
        }

        /// <summary>
        /// 添加修改课程分类
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetCourseCategory()
        {
            var extModel = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Category_ViewModel>(RequestParm.Msg.ToString());
            extModel.CreateTime = DateTime.Now;
            extModel.CreateBy = UserInfo.Id;
            extModel.UpdateBy = UserInfo.Id;
            extModel.UpdateTime = DateTime.Now;
            extModel.Group_Id = this.UserInfo.Group_Id;
            extModel.School_Id = this.UserInfo.School_Id;
            bool flag = categoryModule.SetCourseCategoryModule(extModel);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        /// <summary>
        /// 获取课程分类
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetCourseCategory()
        {
            var CateId = base.ParmJObj.GetInt("CateId", 0);
            var extModel = categoryModule.GetCourseCategoryModule(CateId);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 删除课程分类
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveCourseCategory()
        {
            var CateId = base.ParmJObj.GetInt("CateId", 0);
            var flag = categoryModule.RemoveCourseCategoryModule(CateId);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }
        #endregion

        #region 课程管理

        /// <summary>
        /// 获取课程分页列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetCoursePageList()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_ViewModel>(RequestParm.Msg.ToString());
            query.Group_Id = base.UserInfo.Group_Id;
            query.School_Id = base.UserInfo.School_Id;
            var list = courseModule.GetCoursePageListModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            foreach (var item in list)
            {
                if (item.CreateBy > 0)
                {
                    item.CreateByName = UserReidsCache.GetUserLoginInfo(item.CreateBy)?.AccountName ?? "";
                }
                if (item.UpdateBy > 0)
                {
                    item.UpdateByName = UserReidsCache.GetUserLoginInfo(item.UpdateBy)?.AccountName ?? "";
                }
            }
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 获取课程列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetCourseList()
        {
            var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_ViewModel>(RequestParm.Msg.ToString());
            query.Group_Id = base.UserInfo.Group_Id;
            query.School_Id = base.UserInfo.School_Id;
            var list = courseModule.GetCourseListModule(query);
            return ApiResult.Success(data: list);
        }


        /// <summary>
        /// 添加修改课程
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetCourse()
        {
            var extModel = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_ViewModel>(RequestParm.Msg.ToString());
            extModel.CreateTime = DateTime.Now;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.UpdateBy = base.UserInfo.Id;
            extModel.UpdateTime = DateTime.Now;
            extModel.Group_Id = this.UserInfo.Group_Id;
            extModel.School_Id = this.UserInfo.School_Id;
            bool flag = courseModule.SetCourseModule(extModel);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        /// <summary>
        /// 获取课程
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetCourse()
        {
            var CourseId = base.ParmJObj.GetInt("CourseId", 0);
            var extModel = courseModule.GetCourseModule(CourseId);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 删除课程
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveCourse()
        {
            var CourseId = base.ParmJObj.GetInt("CourseId", 0);
            var flag = courseModule.RemoveCourseModule(CourseId);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        /// <summary>
        /// 是否显示章节编号
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetCourseIsShowChapterNo()
        {
            var CourseId = base.ParmJObj.GetInt("CourseId", 0);
            int IsShowChapterNo = base.ParmJObj.GetInt("IsShowChapterNo", 0);
            var flag = courseModule.SetCourseIsShowChapterNoModule(CourseId, IsShowChapterNo);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        /// <summary>
        /// 设置课程教师
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetCourseTeacher()
        {
            var CourseId = base.ParmJObj.GetInt("CourseId", 0);
            int Teacher_Id = base.ParmJObj.GetInt("Teacher_Id", 0);
            var flag = courseModule.SetCourseTeacherModule(CourseId, Teacher_Id);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }
        #endregion

        #region 教案管理

        /// <summary>
        /// 获取课程教案分页列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetCourseTeachPlanPage()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_TeachPlan_ViewModel>(RequestParm.Msg.ToString());
            query.Group_Id = base.UserInfo.Group_Id;
            query.School_Id = base.UserInfo.School_Id;
            var list = courseModule.GetCourseTeachPlanPageListModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            foreach (var item in list)
            {
                if (item.CreateBy > 0)
                {
                    item.CreateByName = UserReidsCache.GetUserLoginInfo(item.CreateBy)?.AccountName ?? "";
                }
                if (item.UpdateBy > 0)
                {
                    item.UpdateByName = UserReidsCache.GetUserLoginInfo(item.UpdateBy)?.AccountName ?? "";
                }
            }
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 添加修改课程教案
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetTeachPlan()
        {
            var extModel = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_TeachPlan_ViewModel>(RequestParm.Msg.ToString());
            extModel.CreateTime = DateTime.Now;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.UpdateBy = base.UserInfo.Id;
            extModel.UpdateTime = DateTime.Now;
            extModel.Group_Id = this.UserInfo.Group_Id;
            extModel.School_Id = this.UserInfo.School_Id;
            bool flag = courseModule.SetTeachPlanModule(extModel);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        /// <summary>
        /// 获取课程教案
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetTeachPlan()
        {
            var PlanId = base.ParmJObj.GetInt("PlanId", 0);
            var extModel = courseModule.GetTeachPlanModule(PlanId);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 删除课程教案
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveTeachPlan()
        {
            var PlanId = base.ParmJObj.GetInt("PlanId", 0);
            var flag = courseModule.RemoveTeachPlanModule(PlanId);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        #endregion

        #region 课程章节管理

        /// <summary>
        /// 添加修改课程章节
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetChapter()
        {
            var extModel = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Chapter_ViewModel>(RequestParm.Msg.ToString());
            extModel.CreateTime = DateTime.Now;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.UpdateBy = base.UserInfo.Id;
            extModel.UpdateTime = DateTime.Now;
            extModel.Group_Id = this.UserInfo.Group_Id;
            extModel.School_Id = this.UserInfo.School_Id;
            bool flag = courseModule.SetChapterModule(extModel);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        /// <summary>
        /// 获取课程章节列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetChapterList()
        {
            var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Chapter_ViewModel>(RequestParm.Msg.ToString());
            query.Group_Id = base.UserInfo.Group_Id;
            query.School_Id = base.UserInfo.School_Id;
            var list = courseModule.GetChapterListModule(query);
            return ApiResult.Success(data: list);
        }

        /// <summary>
        /// 获取章节树形列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetChapterTree()
        {
            var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Chapter_ViewModel>(RequestParm.Msg.ToString());
            query.Group_Id = base.UserInfo.Group_Id;
            query.School_Id = base.UserInfo.School_Id;
            var list = courseModule.GetChapterTreeListModule(query);
            return ApiResult.Success(data: list);
        }

        /// <summary>
        /// 删除课程章节
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveChapter()
        {
            var ChapterId = base.ParmJObj.GetInt("ChapterId", 0);
            var flag = courseModule.RemoveChapterModule(ChapterId);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        /// <summary>
        /// 获取课程章节详情
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetChapter()
        {
            var ChapterId = base.ParmJObj.GetInt("ChapterId", 0);
            var extModel = courseModule.GetChapterModule(ChapterId);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 设置章节开发状态
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetChapterOpenStatus()
        {
            var extModel = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Chapter_ViewModel>(RequestParm.Msg.ToString());
            bool flag = courseModule.SetChapterOpenStatusModule(extModel);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        /// <summary>
        /// 设置章节开发状态
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetChapterProgress()
        {
            var ChapterId = base.ParmJObj.GetInt("ChapterId", 0);
            var Progress = base.ParmJObj.GetInt("Progress", 0);
            bool flag = courseModule.SetChapterProgressModule(ChapterId, Progress);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }
        #endregion

        #region 课程通知管理
        /// <summary>
        /// 获取课程通知分页列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetNoticePageList()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Notice_ViewModel>(RequestParm.Msg.ToString());
            query.Group_Id = base.UserInfo.Group_Id;
            query.School_Id = base.UserInfo.School_Id;
            var list = courseModule.GetNoticePageListModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            foreach (var item in list)
            {
                if (item.CreateBy > 0)
                {
                    item.CreateByName = UserReidsCache.GetUserLoginInfo(item.CreateBy)?.AccountName ?? "";
                }
                if (item.UpdateBy > 0)
                {
                    item.UpdateByName = UserReidsCache.GetUserLoginInfo(item.UpdateBy)?.AccountName ?? "";
                }
            }
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 添加修改课程通知
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetNotice()
        {
            var extModel = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Notice_ViewModel>(RequestParm.Msg.ToString());
            extModel.CreateTime = DateTime.Now;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.UpdateBy = base.UserInfo.Id;
            extModel.UpdateTime = DateTime.Now;
            extModel.Group_Id = this.UserInfo.Group_Id;
            extModel.School_Id = this.UserInfo.School_Id;
            bool flag = courseModule.SetNoticeModule(extModel);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        /// <summary>
        /// 获取课程通知
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetNotice()
        {
            var NoticeId = base.ParmJObj.GetInt("NoticeId", 0);
            var extModel = courseModule.GetNoticeModule(NoticeId);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 删除课程通知
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveNotice()
        {
            var NoticeId = base.ParmJObj.GetInt("NoticeId", 0);
            var flag = courseModule.RemoveNoticeModule(NoticeId);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        /// <summary>
        /// 新增通知阅读
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult AddNoticeRevice()
        {
            var extModel = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_NoticeRevice_ViewModel>(RequestParm.Msg.ToString());
            var flag = courseModule.AddNoticeReviceModule(extModel);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }
        #endregion

        #region 课程讨论管理
        /// <summary>
        /// 获取课程讨论分页列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetDiscussPageList()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Discuss_ViewModel>(RequestParm.Msg.ToString());
            query.Group_Id = base.UserInfo.Group_Id;
            query.School_Id = base.UserInfo.School_Id;
            var list = courseModule.GetDiscussPageListModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            foreach (var item in list)
            {
                if (item.CreateBy > 0)
                {
                    item.CreateByName = UserReidsCache.GetUserLoginInfo(item.CreateBy)?.AccountName ?? "";
                }
                if (item.UpdateBy > 0)
                {
                    item.UpdateByName = UserReidsCache.GetUserLoginInfo(item.UpdateBy)?.AccountName ?? "";
                }
            }
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 添加修改课程讨论
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetDiscuss()
        {
            var extModel = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Discuss_ViewModel>(RequestParm.Msg.ToString());
            extModel.CreateTime = DateTime.Now;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.UpdateBy = base.UserInfo.Id;
            extModel.UpdateTime = DateTime.Now;
            extModel.Group_Id = this.UserInfo.Group_Id;
            extModel.School_Id = this.UserInfo.School_Id;
            bool flag = courseModule.SetDiscussModule(extModel);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        /// <summary>
        /// 获取课程讨论
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetDiscuss()
        {
            var DiscussId = base.ParmJObj.GetInt("DiscussId", 0);
            var extModel = courseModule.GetDiscussModule(DiscussId);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 删除课程讨论
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveDiscuss()
        {
            var DiscussId = base.ParmJObj.GetInt("DiscussId", 0);
            var flag = courseModule.RemoveDiscussModule(DiscussId);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }
        #endregion

        #region 课程配置管理

        /// <summary>
        /// 添加修改课程配置
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetCourseSetting()
        {
            var extModel = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Setting_ViewModel>(RequestParm.Msg.ToString());
            extModel.CreateTime = DateTime.Now;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.UpdateBy = base.UserInfo.Id;
            extModel.UpdateTime = DateTime.Now;
            extModel.Group_Id = this.UserInfo.Group_Id;
            extModel.School_Id = this.UserInfo.School_Id;
            bool flag = courseModule.SetCourseSettingModule(extModel);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }
        #endregion

        #region 课程资料管理

        /// <summary>
        /// 获取课程资料分页列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetSourcePageList()
        {
            var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
            var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Source_ViewModel>(RequestParm.Msg.ToString());
            query.Group_Id = base.UserInfo.Group_Id;
            query.School_Id = base.UserInfo.School_Id;
            var list = courseModule.GetSourcePageListModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
            foreach (var item in list)
            {
                if (item.CreateBy > 0)
                {
                    item.CreateByName = UserReidsCache.GetUserLoginInfo(item.CreateBy)?.AccountName ?? "";
                }
                if (item.UpdateBy > 0)
                {
                    item.UpdateByName = UserReidsCache.GetUserLoginInfo(item.UpdateBy)?.AccountName ?? "";
                }
            }
            pageModel.Count = rowsCount;
            pageModel.PageData = list;
            return ApiResult.Success(data: pageModel);
        }

        /// <summary>
        /// 添加修改课程资料
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetCourseSource()
        {
            var extModel = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Source_ViewModel>(RequestParm.Msg.ToString());
            extModel.CreateTime = DateTime.Now;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.UpdateBy = base.UserInfo.Id;
            extModel.UpdateTime = DateTime.Now;
            extModel.Group_Id = this.UserInfo.Group_Id;
            extModel.School_Id = this.UserInfo.School_Id;
            bool flag = courseModule.SetCourseSourceModule(extModel);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        /// <summary>
        /// 获取课程资料
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult GetCourseSource()
        {
            var SourceId = base.ParmJObj.GetInt("SourceId", 0);
            var extModel = courseModule.GetCourseSourceModule(SourceId);
            return ApiResult.Success(data: extModel);
        }

        /// <summary>
        /// 更新资料共享类型
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetCourseSourceShareType()
        {
            var SourceId = base.ParmJObj.GetInt("SourceId", 0);
            var ShareType = base.ParmJObj.GetInt("ShareType", 0);
            var flag = courseModule.SetCourseSourceShareTypeModule(SourceId, ShareType);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }

        /// <summary>
        /// 删除课程资料
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult RemoveCourseSource()
        {
            var SourceId = base.ParmJObj.GetInt("SourceId", 0);
            var flag = courseModule.RemoveCourseSourceModule(SourceId);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }
        #endregion

        #region 课程作业管理

        /// <summary>
        /// 添加修改课程作业
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ApiResult SetCourseJob()
        {
            var extModel = Common.Plugin.JsonHelper.DeserializeObject<RB_Course_Job_ViewModel>(RequestParm.Msg.ToString());
            extModel.CreateTime = DateTime.Now;
            extModel.CreateBy = base.UserInfo.Id;
            extModel.UpdateBy = base.UserInfo.Id;
            extModel.UpdateTime = DateTime.Now;
            bool flag = courseModule.SetCourseJobModule(extModel);
            return flag ? ApiResult.Success() : ApiResult.Failed();
        }
        #endregion
    }
}