Commit 35ec1595 authored by 黄奎's avatar 黄奎

新增页面

parent b41b170b
......@@ -8,6 +8,24 @@ namespace Edu.Model.ViewModel.Course
[Serializable]
public class RB_Course_ViewModel : Model.Entity.Course.RB_Course
{
/// <summary>
/// 创建人
/// </summary>
public string CreateByName { get; set; }
/// <summary>
/// 修改人
/// </summary>
public string UpdateByName { get; set; }
/// <summary>
/// 创建时间字符串
/// </summary>
public string CreateTimeStr { get { return Common.ConvertHelper.FormatTime(this.CreateTime); } }
/// <summary>
/// 更新时间
/// </summary>
public string UpdateTimeStr { get { return Common.ConvertHelper.FormatTime(this.UpdateTime); } }
}
}
\ No newline at end of file
namespace Edu.Model.ViewModel.Question
using System.Collections.Generic;
namespace Edu.Model.ViewModel.Question
{
/// <summary>
/// 题库视图实体类
/// </summary>
public class RB_Question_ViewModel : Model.Entity.Question.RB_Question
{
/// <summary>
/// 创建人
/// </summary>
public string CreateByName { get; set; }
/// <summary>
/// 修改人
/// </summary>
public string UpdateByName { get; set; }
/// <summary>
/// 创建时间字符串
/// </summary>
public string CreateTimeStr { get { return Common.ConvertHelper.FormatTime(this.CreateTime); } }
/// <summary>
/// 更新时间字符串
/// </summary>
public string UpdateTimeStr { get { return Common.ConvertHelper.FormatTime(this.UpdateTime); } }
/// <summary>
/// 问题答案列表
/// </summary>
public List<RB_Question_Answer_ViewModel> AnswerList { get; set; }
}
}
\ No newline at end of file
......@@ -509,7 +509,7 @@ namespace Edu.Module.Course
/// <returns></returns>
public bool SetCourseJobModule(RB_Course_Job_ViewModel model)
{
bool flag = false;
bool flag;
if (model.JobId > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
......
......@@ -36,6 +36,29 @@ namespace Edu.Module.Question
return question_TypeRepository.GetQuestionTypeListRepository(query);
}
/// <summary>
/// 获取题库分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Question_ViewModel> GetQuestionPageListModule(int pageIndex, int pageSize, out long rowsCount, RB_Question_ViewModel query)
{
return questionRepository.GetQuestionPageListRepository(pageIndex, pageSize, out rowsCount, query);
}
/// <summary>
/// 获取题库列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Question_ViewModel> GetQuestionListModule(RB_Question_ViewModel query)
{
return questionRepository.GetQuestionListRepository(query);
}
/// <summary>
/// 新增修改题目
/// </summary>
......@@ -65,6 +88,28 @@ namespace Edu.Module.Question
model.QuestionId = newId;
flag = newId > 0;
}
if (flag && model.AnswerList != null)
{
foreach (var item in model.AnswerList)
{
item.QuestionId = model.QuestionId;
if (item.AnswerId > 0)
{
Dictionary<string, object> subFileds = new Dictionary<string, object>()
{
{nameof(RB_Question_Answer_ViewModel.AnswerContent) ,item.AnswerContent},
{nameof(RB_Question_Answer_ViewModel.IsRight) ,item.IsRight},
};
flag = question_AnswerRepository.Update(subFileds, new WhereHelper(nameof(RB_Question_Answer_ViewModel.AnswerId), item.AnswerId));
}
else
{
var subNewId = question_AnswerRepository.Insert(item);
item.AnswerId = subNewId;
flag = subNewId > 0;
}
}
}
return flag;
}
......@@ -93,4 +138,4 @@ namespace Edu.Module.Question
return questionRepository.GetEntity<RB_Question_ViewModel>(QuestionId);
}
}
}
}
\ No newline at end of file
......@@ -36,5 +36,36 @@ WHERE 1=1
return Get<RB_Question_ViewModel>(builder.ToString()).ToList();
}
}
/// <summary>
/// 获取题库分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Question_ViewModel> GetQuestionPageListRepository(int pageIndex, int pageSize, out long rowsCount, RB_Question_ViewModel query)
{
rowsCount = 0;
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT *
FROM RB_Question
WHERE 1=1
");
if (query == null)
{
return new List<RB_Question_ViewModel>();
}
else
{
if (query.CourseId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Question_ViewModel.CourseId), query.CourseId);
}
return GetPage<RB_Question_ViewModel>(pageIndex,pageSize,out rowsCount,builder.ToString()).ToList();
}
}
}
}
\ No newline at end of file
......@@ -21,7 +21,12 @@ namespace Edu.WebApi.Controllers.Course
/// </summary>
private readonly CourseCategoryModule categoryModule = new CourseCategoryModule();
#region 课程管理
/// <summary>
/// 课程处理类对象
/// </summary>
private readonly CourseModule courseModule = new CourseModule();
#region 课程分类管理
/// <summary>
/// 获取课程分类分页列表
/// </summary>
......@@ -120,5 +125,93 @@ namespace Edu.WebApi.Controllers.Course
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();
}
#endregion
}
}
using Edu.Cache.User;
using Edu.Common.API;
using Edu.Common.Plugin;
using Edu.Model.ViewModel.Question;
using Edu.Module.Question;
using Edu.WebApi.Filter;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using System;
namespace Edu.WebApi.Controllers.Course
{
[Route("api/[controller]/[action]")]
[ApiExceptionFilter]
[ApiController]
[EnableCors("AllowCors")]
public class QuestionController : BaseController
{
/// <summary>
/// 题库处理类对象
/// </summary>
private readonly QuestionModule questionModule = new QuestionModule();
#region 题库管理
/// <summary>
/// 获取题目类型列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetQuestionTypeList()
{
var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Question_Type_ViewModel>(RequestParm.Msg.ToString());
var list = questionModule.GetQuestionTypeListModule(query);
return ApiResult.Success(data: list);
}
/// <summary>
/// 获取课程问题分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetQuestionPageList()
{
var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Question_ViewModel>(RequestParm.Msg.ToString());
var list = questionModule.GetQuestionPageListModule(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 GetQuestionList()
{
var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Question_ViewModel>(RequestParm.Msg.ToString());
var list = questionModule.GetQuestionListModule(query);
return ApiResult.Success(data: list);
}
/// <summary>
/// 添加修改问题
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetQuestion()
{
var extModel = Common.Plugin.JsonHelper.DeserializeObject<RB_Question_ViewModel>(RequestParm.Msg.ToString());
extModel.CreateTime = DateTime.Now;
extModel.CreateBy = base.UserInfo.Id;
extModel.UpdateBy = base.UserInfo.Id;
extModel.UpdateTime = DateTime.Now;
bool flag = questionModule.SetQuestionModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 获取课程问题
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetQuestion()
{
var QuestionId = base.ParmJObj.GetInt("QuestionId", 0);
var extModel = questionModule.GetQuestionModule(QuestionId);
return ApiResult.Success(data: extModel);
}
/// <summary>
/// 删除课程问题
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult RemoveCourseCategory()
{
var QuestionId = base.ParmJObj.GetInt("QuestionId", 0);
var flag = questionModule.RemoveQuestionModule(QuestionId);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
#endregion
}
}
......@@ -23,6 +23,7 @@
<ProjectReference Include="..\Edu.Common\Edu.Common.csproj" />
<ProjectReference Include="..\Edu.Model\Edu.Model.csproj" />
<ProjectReference Include="..\Edu.Module.Course\Edu.Module.Course.csproj" />
<ProjectReference Include="..\Edu.Module.Question\Edu.Module.Question.csproj" />
<ProjectReference Include="..\Edu.Module.System\Edu.Module.System.csproj" />
<ProjectReference Include="..\Edu.Module.User\Edu.Module.User.csproj" />
<ProjectReference Include="..\Edu.Repository\Edu.Repository.csproj" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment