Commit d062aefa authored by 黄奎's avatar 黄奎

页面修改

parent 1a397e90
using EduSpider.Model.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VTX.FW.Config;
using VTX.FW.DB;
namespace EduSpider.IRepository
{
public interface ICommentDetailsRepository : IDBRepository<RB_Comment_Details>, IDependency
{
/// <summary>
/// 批量新增默认规则详情
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public bool BatchSetCommentDetailsRepository(List<RB_Comment_Details> list);
/// <summary>
/// 获取默认规则详情列表
/// </summary>
/// <param name="CommentIds"></param>
/// <returns></returns>
public List<RB_Comment_Details> GetCommentDetailsListRepository(string CommentIds);
}
}
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
using EduSpider.Model.Extend;
using System.Collections.Generic; using System.Collections.Generic;
using VTX.FW.Config; using VTX.FW.Config;
using VTX.FW.DB; using VTX.FW.DB;
...@@ -10,17 +11,24 @@ namespace EduSpider.IRepository ...@@ -10,17 +11,24 @@ namespace EduSpider.IRepository
/// </summary> /// </summary>
public interface ICommentRepository : IDBRepository<RB_Comment>, IDependency public interface ICommentRepository : IDBRepository<RB_Comment>, IDependency
{ {
/// <summary>
/// 新增修改默认配置
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetCommentRepository(RB_Comment_Extend model);
/// <summary> /// <summary>
/// 根据查询条件获取评语 /// 根据查询条件获取评语
/// </summary> /// </summary>
/// <param name="Score"></param> /// <param name="Score"></param>
/// <returns></returns> /// <returns></returns>
public RB_Comment GetComment(decimal Score); public RB_Comment_Extend GetComment(decimal Score);
/// <summary> /// <summary>
/// 获取系统配置评价列表 /// 获取系统配置评价列表
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<RB_Comment> GetCommentListRepository(); public RB_Comment_Extend GetCommentListRepository(string KeyWords,int CommentTimes);
} }
} }
...@@ -136,7 +136,7 @@ namespace EduSpider.IServices ...@@ -136,7 +136,7 @@ namespace EduSpider.IServices
/// 获取系统评价配置 /// 获取系统评价配置
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<RB_Comment> GetSysComment(); public RB_Comment_Extend GetSysComment(string KeyWords,int CommentTimes);
/// <summary> /// <summary>
/// 创建课程作业评论 /// 创建课程作业评论
......
...@@ -8,30 +8,25 @@ using VTX.FW.Attr; ...@@ -8,30 +8,25 @@ using VTX.FW.Attr;
namespace EduSpider.Model.Entity namespace EduSpider.Model.Entity
{ {
/// <summary> /// <summary>
/// 评语配置 /// 默认评语配置
/// </summary> /// </summary>
[Serializable] [Serializable]
[DB(ConnectionName = "DefaultConnection")] [DB(ConnectionName = "DefaultConnection")]
public class RB_Comment public class RB_Comment
{ {
/// <summary> /// <summary>
/// 评语 /// 主键编号
/// </summary> /// </summary>
public int Id { get; set; } public int Id { get; set; }
/// <summary> /// <summary>
/// 开始值 /// 次数
/// </summary> /// </summary>
public decimal StartNum { get; set; } public int? Times { get; set; }
/// <summary> /// <summary>
/// 结束值 /// 关键词
/// </summary> /// </summary>
public decimal EndNum { get; set; } public string KeyWords { get; set; }
}
/// <summary>
/// 评语
/// </summary>
public string Info { get; set; }
}
} }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VTX.FW.Attr;
namespace EduSpider.Model.Entity
{
/// <summary>
/// 默认评语配置详情
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Comment_Details
{
/// <summary>
/// 评语详情编号
/// </summary>
public int Id { get; set; }
/// <summary>
/// 评语主表编号
/// </summary>
public int CommentId { get; set; }
/// <summary>
/// 开始值
/// </summary>
public decimal StartNum { get; set; }
/// <summary>
/// 结束值
/// </summary>
public decimal EndNum { get; set; }
/// <summary>
/// 评语
/// </summary>
public string Info { get; set; }
}
}
...@@ -48,5 +48,10 @@ namespace EduSpider.Model.Entity ...@@ -48,5 +48,10 @@ namespace EduSpider.Model.Entity
/// 删除状态(0-正常,1-删除) /// 删除状态(0-正常,1-删除)
/// </summary> /// </summary>
public int Status { get; set; } public int Status { get; set; }
/// <summary>
/// 次数
/// </summary>
public int Times { get; set; }
} }
} }
using EduSpider.Model.Entity;
using System;
using System.Collections.Generic;
namespace EduSpider.Model.Extend
{
/// <summary>
/// 默认评语扩展实体类
/// </summary>
public class RB_Comment_Extend : RB_Comment
{
/// <summary>
/// 默认评语详情列表
/// </summary>
public List<RB_Comment_Details> Details { get; set; }
}
}
using EduSpider.IRepository;
using EduSpider.Model.Entity;
using EduSpider.Repository.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EduSpider.Repository
{
/// <summary>
/// 默认评论详情接口
/// </summary>
public class CommentDetailsRepository : BaseRepository<RB_Comment_Details>, ICommentDetailsRepository
{
/// <summary>
/// 批量新增默认规则详情
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public bool BatchSetCommentDetailsRepository(List<RB_Comment_Details> list)
{
bool flag = false;
flag = base.BatchInsert(list);
return flag;
}
/// <summary>
/// 获取默认规则详情列表
/// </summary>
/// <param name="CommentIds"></param>
/// <returns></returns>
public List<RB_Comment_Details> GetCommentDetailsListRepository(string CommentIds)
{
StringBuilder builder = new StringBuilder();
builder.Append(@"
SELECT A.*
FROM RB_Comment_Details AS A
WHERE 1=1
");
if (!string.IsNullOrEmpty(CommentIds))
{
builder.AppendFormat(@" AND A.{0} IN ({1}) ", nameof(RB_Comment_Details.CommentId), CommentIds);
}
return Get<RB_Comment_Details>(builder.ToString()).ToList();
}
}
}
using EduSpider.IRepository; using EduSpider.IRepository;
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
using EduSpider.Model.Extend;
using EduSpider.Repository.Base; using EduSpider.Repository.Base;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using VTX.FW.DB;
using VTX.FW.DB.Dapper; using VTX.FW.DB.Dapper;
namespace EduSpider.Repository namespace EduSpider.Repository
{ {
/// <summary> /// <summary>
/// 课程仓储层 /// 默认评论仓储接口实现
/// </summary> /// </summary>
public class CommentRepository : BaseRepository<RB_Comment>, ICommentRepository public class CommentRepository : BaseRepository<RB_Comment>, ICommentRepository
{ {
/// <summary>
/// 默认评论详情接口
/// </summary>
ICommentDetailsRepository 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>
/// 获取评语 /// 获取评语
/// </summary> /// </summary>
/// <param name="Score"></param> /// <param name="Score"></param>
/// <returns></returns> /// <returns></returns>
public RB_Comment GetComment(decimal Score) public RB_Comment_Extend GetComment(decimal Score)
{ {
StringBuilder builder = new(); StringBuilder builder = new();
builder.AppendFormat(@" builder.AppendFormat(@"
...@@ -35,23 +75,61 @@ WHERE 1=1 ...@@ -35,23 +75,61 @@ WHERE 1=1
builder.AppendFormat(@" AND A.StartNum<={0} AND {0}<=A.EndNum ", Score); builder.AppendFormat(@" AND A.StartNum<={0} AND {0}<=A.EndNum ", Score);
} }
return base.Get<RB_Comment>(builder.ToString()).ToList().FirstOrDefault(); return base.Get<RB_Comment_Extend>(builder.ToString()).ToList().FirstOrDefault();
} }
/// <summary> /// <summary>
/// 获取系统配置评价列表 /// 获取系统配置评价列表
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<RB_Comment> GetCommentListRepository() public RB_Comment_Extend GetCommentListRepository(string KeyWords,int CommentTimes)
{ {
DynamicParameters parameters = new DynamicParameters();
StringBuilder builder = new(); StringBuilder builder = new();
builder.AppendFormat(@" builder.AppendFormat(@"
SELECT A.* SELECT A.*
FROM RB_Comment AS A FROM RB_Comment AS A
WHERE 1=1 WHERE 1=1
"); ");
if (!string.IsNullOrEmpty(KeyWords))
return base.Get<RB_Comment>(builder.ToString()).ToList(); {
if (KeyWords.Contains("高中"))
{
builder.AppendFormat(" AND A.{0} LIKE @KeyWords1 ",nameof(RB_Comment_Extend.KeyWords));
parameters.Add("KeyWords1", "高中");
}
if (KeyWords.Contains("初中"))
{
builder.AppendFormat(" AND A.{0} LIKE @KeyWords2 ", nameof(RB_Comment_Extend.KeyWords));
parameters.Add("KeyWords2", "初中");
}
if (KeyWords.Contains("化学"))
{
builder.AppendFormat(" AND A.{0} LIKE @KeyWords3 ", nameof(RB_Comment_Extend.KeyWords));
parameters.Add("KeyWords3", "化学");
}
if (KeyWords.Contains("数学"))
{
builder.AppendFormat(" AND A.{0} LIKE @KeyWords4 ",nameof(RB_Comment_Extend.KeyWords));
parameters.Add("KeyWords4", "数学");
}
}
if (CommentTimes > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Comment_Extend.Times), CommentTimes);
}
var model = base.Get<RB_Comment_Extend>(builder.ToString()).ToList().FirstOrDefault();
if (model != null && model.Id>0)
{
string Ids = model.Id.ToString();
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();
}
return model;
} }
} }
} }
...@@ -77,6 +77,10 @@ WHERE 1=1 ...@@ -77,6 +77,10 @@ WHERE 1=1
{ {
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Course_Comment_Extend.CourseId), query.QCourseIds); builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Course_Comment_Extend.CourseId), query.QCourseIds);
} }
if (query.CommentTimes > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Course_Comment_Extend.Times), query.CommentTimes);
}
} }
var list = Get<RB_Course_Comment_Extend>(builder.ToString()).ToList(); var list = Get<RB_Course_Comment_Extend>(builder.ToString()).ToList();
if (list != null && list.Count > 0) if (list != null && list.Count > 0)
......
...@@ -443,23 +443,23 @@ WHERE 1=1 ...@@ -443,23 +443,23 @@ WHERE 1=1
private string GetCommentInfo(RB_Course_Comment_Extend courseCommentModel, decimal Score) private string GetCommentInfo(RB_Course_Comment_Extend courseCommentModel, decimal Score)
{ {
string info = ""; string info = "";
var commentModel = commentRepository.GetComment(Score); //var commentModel = commentRepository.GetComment(Score);
if (courseCommentModel != null && courseCommentModel.CommentDetails != null && courseCommentModel.CommentDetails.Count > 0) //if (courseCommentModel != null && courseCommentModel.CommentDetails != null && courseCommentModel.CommentDetails.Count > 0)
{ //{
var tempModel = courseCommentModel.CommentDetails.Where(qitem => qitem.StartNum <= Score && Score < qitem.EndNum)?.FirstOrDefault(); // var tempModel = courseCommentModel.CommentDetails.Where(qitem => qitem.StartNum <= Score && Score < qitem.EndNum)?.FirstOrDefault();
if (tempModel != null) // if (tempModel != null)
{ // {
info = tempModel?.Info ?? ""; // info = tempModel?.Info ?? "";
} // }
else // else
{ // {
info = commentModel?.Info ?? ""; // info = commentModel?.Info ?? "";
} // }
} //}
else //else
{ //{
info = commentModel?.Info ?? ""; // info = commentModel?.Info ?? "";
} //}
return info; return info;
} }
} }
......
...@@ -472,10 +472,10 @@ namespace EduSpider.Services ...@@ -472,10 +472,10 @@ namespace EduSpider.Services
/// 获取系统评价配置 /// 获取系统评价配置
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<RB_Comment> GetSysComment() public RB_Comment_Extend GetSysComment(string KeyWords,int CommentTimes)
{ {
var list = CommentRepository.GetCommentListRepository(); var model = CommentRepository.GetCommentListRepository(KeyWords, CommentTimes);
return list; return model;
} }
/// <summary> /// <summary>
......
...@@ -147,10 +147,12 @@ namespace EduSpider.WebApi.Controllers ...@@ -147,10 +147,12 @@ namespace EduSpider.WebApi.Controllers
{ {
var query = new Model.Query.CourseQuery() var query = new Model.Query.CourseQuery()
{ {
CourseId = base.ReqParameters.GetInt("CourseId") CourseId = base.ReqParameters.GetInt("CourseId"),
CourseName=base.ReqParameters.GetString("CourseName"),
CommentTimes=base.ReqParameters.GetInt("Times"),
}; };
var courseRule = CourseService.GetCourseCommentList(query).FirstOrDefault(); var courseRule = CourseService.GetCourseCommentList(query).FirstOrDefault();
object result; object result=new object();
if (courseRule != null) if (courseRule != null)
{ {
result = new result = new
...@@ -158,18 +160,20 @@ namespace EduSpider.WebApi.Controllers ...@@ -158,18 +160,20 @@ namespace EduSpider.WebApi.Controllers
courseRule.Id, courseRule.Id,
courseRule.Title, courseRule.Title,
courseRule.CourseId, courseRule.CourseId,
CommentDetails=courseRule.CommentDetails.OrderBy(qitem=>qitem.StartNum).ToList() courseRule.Times,
CommentDetails =courseRule.CommentDetails.OrderBy(qitem=>qitem.StartNum).ToList()
}; };
} }
else else
{ {
var sysList = CourseService.GetSysComment(); var sysModel = CourseService.GetSysComment(query.CourseName,query.CommentTimes);
result = new result = new
{ {
Id = 0, Id = 0,
Title = "系统默认配置", Title = "系统默认配置",
query.CourseId, query.CourseId,
CommentDetails = sysList.OrderBy(qitem => qitem.StartNum).ToList() Times=query.CommentTimes,
CommentDetails = sysModel.Details,
}; };
} }
return ApiResult.Success(data: result); return ApiResult.Success(data: result);
...@@ -189,6 +193,7 @@ namespace EduSpider.WebApi.Controllers ...@@ -189,6 +193,7 @@ namespace EduSpider.WebApi.Controllers
CourseId = base.ReqParameters.GetInt("CourseId"), CourseId = base.ReqParameters.GetInt("CourseId"),
Title = base.ReqParameters.GetString("Title"), Title = base.ReqParameters.GetString("Title"),
ShowType = base.ReqParameters.GetInt("ShowType"), ShowType = base.ReqParameters.GetInt("ShowType"),
Times=base.ReqParameters.GetInt("Times"),
}; };
model.CreateBy = base.BaseUserId; model.CreateBy = base.BaseUserId;
model.CreateTime = System.DateTime.Now; model.CreateTime = System.DateTime.Now;
......
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