题库查询优化(关联课程、分类 显示对象编号)

master
xiaochanghai 11 months ago
parent 71eecae0bd
commit 061002a741
  1. 34
      Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs

@ -180,8 +180,8 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt
RefAsync<int> totalCount = 0;
string sql = @"SELECT *
FROM (SELECT A.*,
B.CourseName,
B.CourseClassId CourseTypeId,
B.CourseName + ' (' + B.CourseNo + ')' CourseName,
B.CourseClassId,
G.UserName CreateDataInfo,
H.UserName UpdateDataInfo,
ISNULL(A.UpdateTime, A.CreateTime) CreateTime1
@ -227,6 +227,34 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt
case "NotEqual":
conditions += $" AND {name} !='{jsonParam.columnValue}'";
break;
case "GreaterOrEqual"://大于等于
conditions += $" AND {name} >='{jsonParam.columnValue}'";
break;
case "Greater"://大于
conditions += $" AND {name} >'{jsonParam.columnValue}'";
break;
case "LessOrEqual"://小于等于
conditions += $" AND {name} <='{jsonParam.columnValue}'";
break;
case "Less"://小于
conditions += $" AND {name} <'{jsonParam.columnValue}'";
break;
case "EqualAny"://
if (jsonParam.columnValue != null)
{
var ids1 = JsonHelper.JsonToObj<List<string>>(jsonParam.columnValue.ToString());
conditions += $" AND {name} IN ({string.Join(",", ids1.Select(id => "'" + id + "'"))})";
}
break;
case "NotEqualAny"://
if (jsonParam.columnValue != null)
{
var ids1 = JsonHelper.JsonToObj<List<string>>(jsonParam.columnValue.ToString());
conditions += $" AND ({name} NOT IN ({string.Join(",", ids1.Select(id => "'" + id + "'"))}) OR {name} IS NULL)";
}
break;
default:
break;
}
@ -260,7 +288,7 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt
if (!string.IsNullOrEmpty(x.QuestionContent))
x.QuestionContent = WebUtility.HtmlDecode(x.QuestionContent);
var courseClass = classs.Where(a => x.CourseClassId.Contains(a.Id.ToString())).ToList();
x.CourseType = string.Join(",", courseClass.Select(a => a.ClassName));
x.CourseType = string.Join(",", courseClass.Select(a => a.ClassName + " (" + a.ClassNo + ")"));
});

Loading…
Cancel
Save