Commit 7942b065 authored by 黄奎's avatar 黄奎

新增老师相关

parent cac2db6d
using EduSpider.Model.Entity;
using EduSpider.Model.Extend;
using EduSpider.Model.Query;
using System.Collections.Generic;
using VTX.FW.Config;
using VTX.FW.DB;
......@@ -17,5 +19,12 @@ namespace EduSpider.Repository
/// <returns></returns>
public bool BatchSetCourseTeacherRepository(List<RB_Course_Teacher> courses);
/// <summary>
/// 获取老师课程列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Course_Teacher_Extend> GetTeacherCourseListRepository(CourseQuery query);
}
}
......@@ -22,11 +22,19 @@ namespace EduSpider.IServices
/// <returns></returns>
public List<RB_Course_Student_Extend> GetStuCourseList(CourseQuery query);
/// <summary>
/// 获取学员考试和家庭作业列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<object> GetStuWorkAndExamList(CourseQuery query);
/// <summary>
/// 获取老师课程列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Course_Teacher_Extend> GetTeacherCourseList(CourseQuery query);
}
}
using EduSpider.Model.Entity;
namespace EduSpider.Model.Extend
{
/// <summary>
/// 课程老师管理扩展实体类
/// </summary>
public class RB_Course_Teacher_Extend : RB_Course_Teacher
{
/// <summary>
/// 课程名称
/// </summary>
public string courseName { get; set; }
/// <summary>
/// 教师编号
/// </summary>
public int teacherId { get; set; }
/// <summary>
/// 教师名称
/// </summary>
public string teacherName { get; set; }
/// <summary>
/// 教师头像
/// </summary>
public string teacherLogo { get; set; }
/// <summary>
/// 封面图
/// </summary>
public string CoverImg { get; set; }
/// <summary>
/// 课程状态
/// </summary>
public int courseStatus { get; set; }
/// <summary>
/// 完成次数
/// </summary>
public int completeNum { get; set; }
/// <summary>
/// 总次数
/// </summary>
public int totalClassNum { get; set; }
}
}
using EduSpider.Model.Entity;
using EduSpider.Model.Extend;
using EduSpider.Model.Query;
using EduSpider.Repository.Base;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VTX.FW.DB.Dapper;
namespace EduSpider.Repository
{
......@@ -20,5 +25,35 @@ namespace EduSpider.Repository
flag = base.BatchInsert(courses, isReplace: true);
return flag;
}
/// <summary>
/// 获取老师课程列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Course_Teacher_Extend> GetTeacherCourseListRepository(CourseQuery query)
{
var parameters = new DynamicParameters();
StringBuilder builder = new();
builder.AppendFormat(@"
SELECT A.*,B.courseName,B.teacherId,B.teacherName,B.teacherLogo,B.CoverImg,B.courseStatus,B.completeNum,B.totalClassNum
FROM RB_Course_Teacher AS A INNER JOIN RB_Course AS B ON A.courseId=B.courseId
WHERE 1=1
");
if (query != null)
{
if (query.courseId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Course_Student.courseId), query.courseId);
}
if (!string.IsNullOrWhiteSpace(query.TeacherIds))
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Course_Student.uid), query.TeacherIds);
}
}
builder.AppendFormat(" ORDER BY A.courseId DESC ");
return Get<RB_Course_Teacher_Extend>(builder.ToString(), parameters).ToList();
}
}
}
......@@ -37,6 +37,12 @@ namespace EduSpider.Services
[Autowired]
public ICommentRepository CommentRepository { get; set; }
/// <summary>
/// 老师课程关联仓储接口
/// </summary>
[Autowired]
public ICourseTeacherRepository CourseTeacherRepository { get; set; }
/// <summary>
/// 获取学员课程列表
......@@ -49,6 +55,17 @@ namespace EduSpider.Services
return list;
}
/// <summary>
/// 获取老师课程列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Course_Teacher_Extend> GetTeacherCourseList(CourseQuery query)
{
var list = CourseTeacherRepository.GetTeacherCourseListRepository(query);
return list;
}
/// <summary>
/// 获取学员考试和家庭作业列表
/// </summary>
......@@ -72,7 +89,7 @@ namespace EduSpider.Services
item.ResultType,
item.ResultTypeStr,
item.Title,
CreateTime = VTX.FW.Helper.ConvertHelper.FormatTime(item.CreateTime,2),
CreateTime = VTX.FW.Helper.ConvertHelper.FormatTime(item.CreateTime, 2),
item.Score,
item.Score_p,
item.ScoreType,
......
using EduSpider.IServices;
using EduSpider.WebApi.Controllers.Base;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using VTX.FW.Api;
using VTX.FW.Attr;
using VTX.FW.Helper;
namespace EduSpider.WebApi.Controllers
{
/// <summary>
/// 老师相关控制器
/// </summary>
public class TeacherController : BaseController
{
/// <summary>
/// 课程仓储接口
/// </summary>
[Autowired]
public ICourseService CourseService { get; set; }
/// <summary>
/// 获取老师课程列表
/// </summary>
/// <returns></returns>
[HttpPost]
[HttpGet]
public ApiResult GetTeacherCourse()
{
var query = new Model.Query.CourseQuery()
{
TeacherIds = base.BaseUserId.ToString()
};
List<object> result = new List<object>();
var list = CourseService.GetTeacherCourseList(query);
if (list != null && list.Count > 0)
{
foreach (var item in list)
{
result.Add(new
{
item.courseId,
item.courseName,
item.CoverImg,
item.completeNum,
item.totalClassNum,
item.teacherName,
});
}
}
return ApiResult.Success(data: result);
}
/// <summary>
/// 获取课程学员列表
/// </summary>
/// <returns></returns>
[HttpPost]
[HttpGet]
public ApiResult GetCourseStu()
{
var query = new Model.Query.CourseQuery()
{
courseId = base.ReqParameters.GetInt("courseId")
};
List<object> result = new List<object>();
var list = CourseService.GetStuCourseList(query);
if (list != null && list.Count > 0)
{
foreach (var item in list)
{
result.Add(new
{
StuId = item.uid,
StuName = item.name,
StuAccount = item.account
});
}
}
return ApiResult.Success(data: result);
}
}
}
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