Commit 58db7150 authored by 黄奎's avatar 黄奎

页面修改

parent 8a800efb
using EduSpider.Model.Entity;
using EduSpider.Model.Extend;
using EduSpider.Model.Query;
using System.Collections.Generic;
using VTX.FW.Config;
using VTX.FW.DB;
......@@ -11,17 +12,11 @@ namespace EduSpider.IRepository
/// </summary>
public interface ICommentRepository : IDBRepository<RB_Comment>, IDependency
{
/// <summary>
/// 新增修改默认配置
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetCommentRepository(RB_Comment_Extend model);
/// <summary>
/// 获取系统配置评价列表
/// </summary>
/// <returns></returns>
public RB_Comment_Extend GetCommentListRepository(string KeyWords,int CommentTimes);
public List<RB_Comment_Extend> GetCommentListRepository(CourseQuery query);
}
}
......@@ -24,7 +24,7 @@ namespace EduSpider.IRepository
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public bool BatchSetStuCommentRepository(List<RB_Stu_Comment> list);
public bool BatchSetStuCommentRepository(List<RB_Stu_Comment> list, StuCommentType commentType );
/// <summary>
......
......@@ -19,6 +19,14 @@ namespace EduSpider.IRepository
/// <returns></returns>
public bool BatchSetStuHomeWorkRepository(List<RB_Stu_HomeWork> homeWorks);
/// <summary>
/// 获取家庭作业列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Stu_HomeWork_Extend> GetStuHomeWorkDetailsListRepository(CourseQuery query);
/// <summary>
/// 创建课程作业评论
/// </summary>
......@@ -31,12 +39,5 @@ namespace EduSpider.IRepository
/// </summary>
/// <returns></returns>
public List<ExamWorkResult> GetStuHomeWorkListRepository(CourseQuery query);
/// <summary>
/// 获取家庭作业列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Stu_HomeWork_Extend> GetStuHomeWorkDetailsListRepository(CourseQuery query);
}
}
\ No newline at end of file
......@@ -92,7 +92,7 @@ namespace EduSpider.IServices
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public bool BatchSetStuComment(List<RB_Stu_Comment> list);
public bool BatchSetStuComment(List<RB_Stu_Comment> list, StuCommentType commentType);
/// <summary>
/// 获取学员评价列表
......@@ -136,7 +136,7 @@ namespace EduSpider.IServices
/// 获取系统评价配置
/// </summary>
/// <returns></returns>
public RB_Comment_Extend GetSysComment(string KeyWords,int CommentTimes);
public List<RB_Comment_Extend> GetSysComment(CourseQuery query);
/// <summary>
/// 创建课程作业评论
......
......@@ -75,4 +75,6 @@ namespace EduSpider.Model.Entity
/// </summary>
public int Status { get; set; }
}
}
......@@ -45,6 +45,16 @@
/// </summary>
public int HomeWorkId { get; set; }
/// <summary>
/// 开始作业编号
/// </summary>
public int StartHomeWorkId { get; set; }
/// <summary>
/// 结束作业编号
/// </summary>
public int EndHomeWorkId { get; set; }
/// <summary>
/// 创建类型(1-系统创建,2-老师创建)
/// </summary>
......@@ -54,5 +64,10 @@
/// 评论次数
/// </summary>
public int CommentTimes { get; set; }
/// <summary>
/// 默认评价编号
/// </summary>
public int DefaultCommentId { get; set; }
}
}
using EduSpider.IRepository;
using EduSpider.Model.Entity;
using EduSpider.Model.Extend;
using EduSpider.Model.Query;
using EduSpider.Repository.Base;
using System.Collections.Generic;
using System.Linq;
......@@ -18,46 +19,14 @@ namespace EduSpider.Repository
/// <summary>
/// 默认评论详情接口
/// </summary>
ICommentDetailsRepository commentDetailsRepository = new CommentDetailsRepository();
CommentDetailsRepository commentDetailsRepository = new CommentDetailsRepository();
/// <summary>
/// 新增修改默认配置
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetCommentRepository(RB_Comment_Extend model)
{
bool flag = false;
if (model.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Comment_Extend.KeyWords),model.KeyWords.Trim() }
};
flag = base.UpdateOne(fileds, new WhereHelper(nameof(RB_Comment_Extend.Id), model.Id));
}
else
{
var newId = base.Insert(model);
model.Id = newId;
flag = newId > 0;
}
if (model.Details != null && model.Details.Count > 0)
{
foreach (var item in model.Details)
{
item.CommentId = model.Id;
}
commentDetailsRepository.BatchSetCommentDetailsRepository(model.Details);
}
return flag;
}
/// <summary>
/// 获取系统配置评价列表
/// </summary>
/// <returns></returns>
public RB_Comment_Extend GetCommentListRepository(string KeyWords,int CommentTimes)
public List<RB_Comment_Extend> GetCommentListRepository(CourseQuery query)
{
DynamicParameters parameters = new DynamicParameters();
StringBuilder builder = new();
......@@ -66,45 +35,53 @@ SELECT A.*
FROM RB_Comment AS A
WHERE 1=1
");
if (!string.IsNullOrEmpty(KeyWords))
if (!string.IsNullOrEmpty(query.KeyWords))
{
if (KeyWords.Contains("高"))
if (query.KeyWords.Contains("高"))
{
builder.AppendFormat(" AND A.{0} LIKE @KeyWords1 ",nameof(RB_Comment_Extend.KeyWords));
parameters.Add("KeyWords1", "%高%");
}
if (KeyWords.Contains("初"))
if (query.KeyWords.Contains("初"))
{
builder.AppendFormat(" AND A.{0} LIKE @KeyWords2 ", nameof(RB_Comment_Extend.KeyWords));
parameters.Add("KeyWords2", "%初%");
}
if (KeyWords.Contains("化学"))
if (query.KeyWords.Contains("化学"))
{
builder.AppendFormat(" AND A.{0} LIKE @KeyWords3 ", nameof(RB_Comment_Extend.KeyWords));
parameters.Add("KeyWords3", "%化学%");
}
if (KeyWords.Contains("数学"))
if (query.KeyWords.Contains("数学"))
{
builder.AppendFormat(" AND A.{0} LIKE @KeyWords4 ",nameof(RB_Comment_Extend.KeyWords));
parameters.Add("KeyWords4", "%数学%");
}
}
if (CommentTimes > 0)
if (query.CommentTimes > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Comment_Extend.Times), CommentTimes);
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Comment_Extend.Times), query.CommentTimes);
}
var model = base.Get<RB_Comment_Extend>(builder.ToString(),parameters).ToList().FirstOrDefault();
if (model != null && model.Id>0)
if (query.DefaultCommentId > 0)
{
string Ids = model.Id.ToString();
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Comment_Extend.Id), query.DefaultCommentId);
}
var list = base.Get<RB_Comment_Extend>(builder.ToString(),parameters).ToList();
if (list != null && list.Count>0)
{
string Ids = string.Join(",", list.Select(qitem => qitem.Id));
List<RB_Comment_Details> subList = new List<RB_Comment_Details>();
if (!string.IsNullOrEmpty(Ids))
{
subList = commentDetailsRepository.GetCommentDetailsListRepository(Ids);
}
model.Details = subList?.Where(qitem => qitem.CommentId == model.Id)?.OrderBy(qitem => qitem.StartNum)?.ToList();
foreach (var item in list)
{
item.Details = subList?.Where(qitem => qitem.CommentId == item.Id)?.OrderBy(qitem => qitem.StartNum)?.ToList();
}
}
return model;
return list;
}
}
}
......@@ -17,6 +17,8 @@ namespace EduSpider.Repository
/// </summary>
public class StuCommentRepository : BaseRepository<RB_Stu_Comment>, IStuCommentRepository
{
/// <summary>
/// 获取学员评语列表
/// </summary>
......@@ -45,6 +47,14 @@ WHERE 1=1
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Stu_Comment.HomeWorkId), query.HomeWorkId);
}
if (query.StartHomeWorkId > 0)
{
builder.AppendFormat(" AND A.{0}>={1} ", nameof(RB_Stu_Comment.HomeWorkId), query.StartHomeWorkId);
}
if (query.EndHomeWorkId > 0)
{
builder.AppendFormat(" AND A.{0}<={1} ", nameof(RB_Stu_Comment.HomeWorkId), query.EndHomeWorkId);
}
if (query.CommentTimes > 0)
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Stu_Comment.Times), query.CommentTimes);
......@@ -83,10 +93,99 @@ WHERE 1=1
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public bool BatchSetStuCommentRepository(List<RB_Stu_Comment> list)
public bool BatchSetStuCommentRepository(List<RB_Stu_Comment> list, StuCommentType commentType)
{
bool flag = false;
// 以前批量添加接口
if (commentType != null)
{
if (commentType.CommentType == 2)
{
flag = AddTemplateStuComment(list, commentType.IsDefault, commentType.CommentId);
}
else
{
flag = AddDefaultStuComment(list);
}
}
else
{
flag = AddDefaultStuComment(list);
}
return flag;
}
/// <summary>
/// 根据模板生成评价
/// </summary>
/// <param name="list"></param>
/// <param name="IsDefault"></param>
/// <param name="CommentId"></param>
/// <returns></returns>
private bool AddTemplateStuComment(List<RB_Stu_Comment> list, int IsDefault, int CommentId)
{
bool flag = false;
if (list != null && list.Count > 0)
{
var homeworkList =new StuHomeWorkRepository().GetStuHomeWorkDetailsListRepository(new CourseQuery()
{
CourseId = list[0].CourseId,
StartHomeWorkId = list[0].StartHomeWorkId,
EndHomeWorkId = list[0].HomeWorkId
});
var courseComment = new RB_Course_Comment_Extend();
var defaultComment = new RB_Comment_Extend();
if (IsDefault == 1)
{
defaultComment =new CommentRepository().GetCommentListRepository(new CourseQuery() { DefaultCommentId = CommentId }).FirstOrDefault();
}
else
{
courseComment =new CourseCommentRepository().GetCourseCommentListRepository(new CourseQuery() { CourseId = list[0].CourseId }).Where(qitem => qitem.Id == CommentId).FirstOrDefault();
}
foreach (var item in list)
{
var tempList = homeworkList.Where(qitem => qitem.student_uid == item.StuUid).ToList();
item.CreateTime = tempList.LastOrDefault().add_time.AddSeconds(1);
var Score = tempList.Sum(qitem => qitem.score_p) * 100;
string info = "";
if (IsDefault == 1)
{
if (defaultComment != null && defaultComment.Details != null && defaultComment.Details.Count > 0)
{
var tempModel = defaultComment.Details.Where(qitem => qitem.StartNum <= Score && Score < qitem.EndNum)?.FirstOrDefault();
if (tempModel != null)
{
info = tempModel?.Info ?? "";
}
}
}
else
{
if (courseComment != null && courseComment.CommentDetails != null && courseComment.CommentDetails.Count > 0)
{
var tempModel = courseComment.CommentDetails.Where(qitem => qitem.StartNum <= Score && Score < qitem.EndNum)?.FirstOrDefault();
if (tempModel != null)
{
info = tempModel?.Info ?? "";
}
}
}
item.Info = info;
flag = base.Insert(item) > 0;
}
}
return flag;
}
/// <summary>
/// 自定义添加评价
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
private bool AddDefaultStuComment(List<RB_Stu_Comment> list)
{
bool flag = false;
foreach (var item in list)
{
var defaultModel = GetStuCommentListRepository(new CourseQuery()
......@@ -94,7 +193,7 @@ WHERE 1=1
CourseId = item.CourseId,
CommentTimes = item.Times,
StuIds = item.StuUid.ToString(),
HomeWorkId=item.HomeWorkId,
HomeWorkId = item.HomeWorkId,
}).FirstOrDefault();
item.CreateTime = defaultModel.CreateTime.AddSeconds(1);
item.HomeWorkId = defaultModel.HomeWorkId;
......@@ -103,6 +202,8 @@ WHERE 1=1
return flag;
}
/// <summary>
/// 修改学员评论状态
/// </summary>
......
......@@ -382,9 +382,9 @@ namespace EduSpider.Services
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public bool BatchSetStuComment(List<RB_Stu_Comment> list)
public bool BatchSetStuComment(List<RB_Stu_Comment> list, StuCommentType commentType)
{
return StuCommentRepository.BatchSetStuCommentRepository(list);
return StuCommentRepository.BatchSetStuCommentRepository(list,commentType);
}
/// <summary>
......@@ -472,9 +472,9 @@ namespace EduSpider.Services
/// 获取系统评价配置
/// </summary>
/// <returns></returns>
public RB_Comment_Extend GetSysComment(string KeyWords, int CommentTimes)
public List<RB_Comment_Extend> GetSysComment(CourseQuery query)
{
var model = CommentRepository.GetCommentListRepository(KeyWords, CommentTimes);
var model = CommentRepository.GetCommentListRepository(query);
return model;
}
......
......@@ -166,7 +166,7 @@ namespace EduSpider.WebApi.Controllers
}
else
{
var sysModel = CourseService.GetSysComment(query.CourseName,query.CommentTimes);
var sysModel = CourseService.GetSysComment(new CourseQuery() { KeyWords= query.CourseName ,CommentTimes= query.CommentTimes }).FirstOrDefault();
if (sysModel != null)
{
result = new
......@@ -205,52 +205,57 @@ namespace EduSpider.WebApi.Controllers
{
CourseId = base.ReqParameters.GetInt("CourseId"),
CourseName = base.ReqParameters.GetString("CourseName"),
};
var courseRuleList = CourseService.GetCourseCommentList(query);
object result = new object();
if (courseRuleList != null)
List<object> result = new List<object>();
if (courseRuleList != null && courseRuleList.Count > 0)
{
result = new
foreach (var item in courseRuleList)
{
query.CourseId,
query.CourseName,
CommentDetails = courseRuleList,
};
result.Add(new
{
IsDefault = 0,
item.Id,
item.Times,
CommentDetails = item.CommentDetails.Select(qitem => new
{
qitem.DetailId,
qitem.CourseCommentId,
qitem.StartNum,
qitem.EndNum,
qitem.Info,
}),
});
}
}
else
{
var sysModel = CourseService.GetSysComment(query.CourseName, query.CommentTimes);
if (sysModel != null)
{
result = new
var sysCommentList = CourseService.GetSysComment(new CourseQuery() { KeyWords = query.CourseName, CommentTimes = query.CommentTimes });
if (sysCommentList != null && sysCommentList.Count > 0)
{
Id = 0,
Title = "系统默认配置",
query.CourseId,
Times = query.CommentTimes,
CommentDetails = sysModel.Details,
};
}
else
foreach (var item in sysCommentList)
{
result = new
result.Add(new
{
Id = 0,
Title = "系统默认配置",
query.CourseId,
Times = query.CommentTimes,
CommentDetails = new List<RB_Comment_Details>()
};
IsDefault = 1,
item.Id,
item.Times,
CommentDetails = item.Details.Select(qitem => new
{
DetailId = 0,
CourseCommentId = 0,
qitem.StartNum,
qitem.EndNum,
qitem.Info,
}),
});
}
}
}
return ApiResult.Success(data: result);
}
/// <summary>
/// 新增可以课程评语
/// </summary>
......@@ -336,6 +341,12 @@ namespace EduSpider.WebApi.Controllers
public ApiResult BatchSetStuComment()
{
var stuListStr = base.ReqParameters.GetString("ChooseStuList");
StuCommentType commentType = new StuCommentType()
{
CommentId = base.ReqParameters.GetInt("CommentId"),
CommentType = base.ReqParameters.GetInt("CommentType"),
IsDefault = base.ReqParameters.GetInt("IsDefault")
};
List<RB_Stu_Comment> list = new();
if (!string.IsNullOrWhiteSpace(stuListStr))
{
......@@ -365,7 +376,7 @@ namespace EduSpider.WebApi.Controllers
}
}
}
var flag = CourseService.BatchSetStuComment(list);
var flag = CourseService.BatchSetStuComment(list, commentType);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
......
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