代码优化

master
xiaochanghai 11 months ago
parent a9a2ae32e8
commit 3a87d1aec7
  1. 533
      Model/Tiobon.Web.pdm
  2. 2
      Tiobon.Core.Model/ViewModels/Menu.cs
  3. 3
      Tiobon.Core.Services/CommonServices.cs
  4. 12
      Tiobon.Core.Services/Ghre/Ghre_CertificateRuleServices.cs
  5. 7
      Tiobon.Core.Services/Ghre/Ghre_CertificateServices.cs
  6. 27
      Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs
  7. 12
      Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs
  8. 32
      Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs

File diff suppressed because it is too large Load Diff

@ -107,7 +107,7 @@ public class TableColumn
public int SortNo { get; set; } public int SortNo { get; set; }
public string searchOperator1 { get; set; } public string searchOperator1 { get; set; }
public List<searchOperator> searchOperator { get; set; } public List<searchOperator> searchOperator { get; set; }
public string searchColumnDefaultValue { get; set; } public object searchColumnDefaultValue { get; set; } = "";
public string AppColumnType { get; set; } public string AppColumnType { get; set; }
public int pageColumnID { get; set; } public int pageColumnID { get; set; }
} }

@ -819,6 +819,9 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon
if (!string.IsNullOrWhiteSpace(x.searchOperator1)) if (!string.IsNullOrWhiteSpace(x.searchOperator1))
x.searchOperator = JsonConvert.DeserializeObject<List<searchOperator>>(x.searchOperator1); x.searchOperator = JsonConvert.DeserializeObject<List<searchOperator>>(x.searchOperator1);
x.searchOperator1 = null; x.searchOperator1 = null;
if (x.multipleSearchValue == "true")
x.searchColumnDefaultValue = new List<string>();
}); });
Db.Ado.CommitTran(); Db.Ado.CommitTran();

@ -38,18 +38,18 @@ public class Ghre_CertificateRuleServices : BaseServices<Ghre_CertificateRule, G
{ {
var name = jProperty.Name; var name = jProperty.Name;
var value = jProperty.Value.ToString(); var value = jProperty.Value.ToString();
if (!string.IsNullOrWhiteSpace(value) && name == "CourseName") if (!string.IsNullOrWhiteSpace(value) && name == "CourseName")
{ {
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value); var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
switch (jsonParam.operationKey) switch (jsonParam.operationKey)
{ {
case "Equal": case "Equal":
condition = $" ( CourseSceneId='{jsonParam.columnValue}' or CourseId='{jsonParam.columnValue}' )"; condition = $" ( CourseSceneId='{jsonParam.columnValue}' or CourseId='{jsonParam.columnValue}' )";
break; break;
case "NotEqual": case "NotEqual":
condition = $"( CourseSceneId!='{{jsonParam.columnValue}}' AND CourseId!='{{jsonParam.columnValue}}' )\";"; condition = $"( CourseSceneId!='{{jsonParam.columnValue}}' AND CourseId!='{{jsonParam.columnValue}}' )\";";
break; break;
default: default:
break; break;
} }
@ -65,8 +65,10 @@ public class Ghre_CertificateRuleServices : BaseServices<Ghre_CertificateRule, G
{ {
x.RuleTypeLabel = await GetParaLabel("TrainingCertificateRuleType", x.RuleType); x.RuleTypeLabel = await GetParaLabel("TrainingCertificateRuleType", x.RuleType);
x.SendRuleLabel = await GetParaLabel("TrainingCertificateSendRule", x.SendRule); x.SendRuleLabel = await GetParaLabel("TrainingCertificateSendRule", x.SendRule);
string staticType = x.StaticType == "month" ? "月" : (x.StaticType == "year" ? "年" : "天");
if (x.ValidityType == "StaticDuration") if (x.ValidityType == "StaticDuration")
x.ValidityLabel = $"自颁发日起 【{x.StaticNum}】{x.StaticType}内有效"; x.ValidityLabel = $"自颁发日起 【{x.StaticNum}】{staticType}内有效";
else else
if (x.ValidityType == "Unlimited") if (x.ValidityType == "Unlimited")
x.ValidityLabel = $"自颁发日起终生有效"; x.ValidityLabel = $"自颁发日起终生有效";

@ -8,6 +8,7 @@ using Newtonsoft.Json.Linq;
using Tiobon.Core.Common; using Tiobon.Core.Common;
using Tiobon.Core.Model; using Tiobon.Core.Model;
using Newtonsoft.Json; using Newtonsoft.Json;
using Tiobon.Core.Common.Helper;
namespace Tiobon.Core.Services; namespace Tiobon.Core.Services;
@ -114,6 +115,12 @@ public class Ghre_CertificateServices : BaseServices<Ghre_Certificate, Ghre_Cert
var entitys = await Db.Ado.SqlQueryAsync<Ghre_CertificateDto>(sql); var entitys = await Db.Ado.SqlQueryAsync<Ghre_CertificateDto>(sql);
entitys.ForEach(entity =>
{
if (!string.IsNullOrWhiteSpace(entity.Indate))
entity.Indate = DateTimeHelper.ConvertToDayString(entity.Indate);
});
return new ServicePageResult<Ghre_CertificateDto>(filter.pageNum, total, filter.pageSize, entitys); return new ServicePageResult<Ghre_CertificateDto>(filter.pageNum, total, filter.pageSize, entitys);
} }

@ -452,7 +452,7 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
}); });
entity.SearchFields.Add(new CoursePublicSearchField() entity.SearchFields.Add(new CoursePublicSearchField()
{ {
label = "'课程场景", label = "课程场景",
field = "CourseSceneId", field = "CourseSceneId",
elementType = "ApiSelect", elementType = "ApiSelect",
dataSource = "CommonList_TrainingCourseScene", dataSource = "CommonList_TrainingCourseScene",
@ -462,7 +462,7 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
}); });
entity.SearchFields.Add(new CoursePublicSearchField() entity.SearchFields.Add(new CoursePublicSearchField()
{ {
label = "'是否学过", label = "是否学过",
field = "HasStudy", field = "HasStudy",
elementType = "ApiSelect", elementType = "ApiSelect",
dataSource = "TBParaDetail_Train_CourseIsOpen", dataSource = "TBParaDetail_Train_CourseIsOpen",
@ -506,7 +506,7 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
if (string.IsNullOrWhiteSpace(filter.orderBy)) if (string.IsNullOrWhiteSpace(filter.orderBy))
filter.orderBy = "CourseName ASC"; filter.orderBy = "CourseName ASC";
string conditions = "1=1"; string conditions = " AND 1=1";
if (filter.jsonParam != null) if (filter.jsonParam != null)
foreach (JProperty jProperty in filter.jsonParam.Properties()) foreach (JProperty jProperty in filter.jsonParam.Properties())
{ {
@ -515,13 +515,20 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
if (name == "page" || name == "pageSize") if (name == "page" || name == "pageSize")
continue; continue;
//if (name == "Indate") if (name == "CourseNoOrName")
//{ {
// var jsonParam = JsonConvert.DeserializeObject<JsonParam1>(value); var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
// conditions += $" AND (Indate BETWEEN '{jsonParam.columnValue[0]}' AND '{jsonParam.columnValue[1]}')"; conditions += $" AND (CourseNo LIKE '%{jsonParam.columnValue}%' OR CourseName LIKE '%{jsonParam.columnValue}%')";
// continue; continue;
//} }
if (name == "CourseClassId")
{
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
conditions += $" AND CourseClassId LIKE '%{jsonParam.columnValue}%' ";
continue;
}
//if (name == "Date") //if (name == "Date")
//{ //{
// var jsonParam = JsonConvert.DeserializeObject<JsonParam1>(value); // var jsonParam = JsonConvert.DeserializeObject<JsonParam1>(value);
@ -605,7 +612,7 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
//if (ids != null && ids.Any()) //if (ids != null && ids.Any())
// conditions += $" AND Id IN({string.Join(",", ids)})"; // conditions += $" AND Id IN({string.Join(",", ids)})";
sql = string.Format(sql, conditions); sql += conditions;
if (filter.pageSize == 0) if (filter.pageSize == 0)
filter.pageSize = 10000; filter.pageSize = 10000;
var data = await Db.SqlQueryable<CoursePublic>(sql) var data = await Db.SqlQueryable<CoursePublic>(sql)

@ -831,8 +831,16 @@ delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';");
if (status == "Released" && entity.Status != "Released") if (status == "Released" && entity.Status != "Released")
{ {
if (entity.LinkType == "CourseId" && !await _ghre_CourseServices.AnyAsync(entity.LinkId)) if (entity.LinkType == "CourseId")
return ServiceResult.OprateFailed($"试卷【{entity.PaperName}({entity.PaperNo})】,关联的课程,已被删除,请重新维护数据!"); {
if (!await _ghre_CourseServices.AnyAsync(entity.LinkId))
return ServiceResult.OprateFailed($"试卷【{entity.PaperName}({entity.PaperNo})】,关联的课程,已被删除,请重新维护数据!");
var course = await _ghre_CourseServices.QueryById(entity.LinkId);
if (course.Status != "Released")
return ServiceResult.OprateFailed($"试卷【{entity.PaperName}({entity.PaperNo})】,关联的课程【{course.CourseName}】,尚未被启用,请重新维护数据!");
}
if (entity.LinkType == "CourseSceneId" && !await _ghre_CourseSceneServices.AnyAsync(entity.LinkId)) if (entity.LinkType == "CourseSceneId" && !await _ghre_CourseSceneServices.AnyAsync(entity.LinkId))
return ServiceResult.OprateFailed($"试卷【{entity.PaperName}({entity.PaperNo})】,关联的课程场景,已被删除,请重新维护数据!"); return ServiceResult.OprateFailed($"试卷【{entity.PaperName}({entity.PaperNo})】,关联的课程场景,已被删除,请重新维护数据!");

@ -8,6 +8,7 @@ using Newtonsoft.Json.Linq;
using Tiobon.Core.Common; using Tiobon.Core.Common;
using Tiobon.Core.Model; using Tiobon.Core.Model;
using Newtonsoft.Json; using Newtonsoft.Json;
using Tiobon.Core.Common.Helper;
namespace Tiobon.Core.Services namespace Tiobon.Core.Services
{ {
@ -113,6 +114,12 @@ namespace Tiobon.Core.Services
var entitys = await Db.Ado.SqlQueryAsync<Ghre_StudyRecordDto>(sql); var entitys = await Db.Ado.SqlQueryAsync<Ghre_StudyRecordDto>(sql);
entitys.ForEach(entity =>
{
if (!string.IsNullOrWhiteSpace(entity.Indate))
entity.Indate = DateTimeHelper.ConvertToDayString(entity.Indate);
});
return new ServicePageResult<Ghre_StudyRecordDto>(filter.pageNum, total, filter.pageSize, entitys); return new ServicePageResult<Ghre_StudyRecordDto>(filter.pageNum, total, filter.pageSize, entitys);
} }
@ -161,7 +168,7 @@ namespace Tiobon.Core.Services
}); });
entity.SearchFields.Add(new CoursePublicSearchField() entity.SearchFields.Add(new CoursePublicSearchField()
{ {
label = "'课程场景", label = "课程场景",
field = "CourseSceneId", field = "CourseSceneId",
elementType = "ApiSelect", elementType = "ApiSelect",
dataSource = "CommonList_TrainingCourseScene", dataSource = "CommonList_TrainingCourseScene",
@ -171,7 +178,7 @@ namespace Tiobon.Core.Services
}); });
entity.SearchFields.Add(new CoursePublicSearchField() entity.SearchFields.Add(new CoursePublicSearchField()
{ {
label = "'课程状态", label = "课程状态",
field = "CourseStatus", field = "CourseStatus",
elementType = "ApiSelect", elementType = "ApiSelect",
dataSource = "TBParaDetail_Train_CourseIsOpen", dataSource = "TBParaDetail_Train_CourseIsOpen",
@ -181,7 +188,7 @@ namespace Tiobon.Core.Services
}); });
entity.SearchFields.Add(new CoursePublicSearchField() entity.SearchFields.Add(new CoursePublicSearchField()
{ {
label = "'学习状态", label = "学习状态",
field = "StudyStatus", field = "StudyStatus",
elementType = "ApiSelect", elementType = "ApiSelect",
dataSource = "TBParaDetail_Train_CourseIsOpen", dataSource = "TBParaDetail_Train_CourseIsOpen",
@ -249,13 +256,20 @@ namespace Tiobon.Core.Services
var value = jProperty.Value.ToString(); var value = jProperty.Value.ToString();
if (name == "page" || name == "pageSize") if (name == "page" || name == "pageSize")
continue; continue;
//if (name == "Date") if (name == "CourseNoOrName")
//{ {
// var jsonParam = JsonConvert.DeserializeObject<JsonParam1>(value); var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
// conditions += $" AND (Date BETWEEN '{jsonParam.columnValue[0]}' AND '{jsonParam.columnValue[1]}')"; conditions += $" AND CourseName LIKE '%{jsonParam.columnValue}%'";
continue;
}
if (name == "CourseClassId")
{
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
conditions += $" AND CourseClassId LIKE '%{jsonParam.columnValue}%' ";
// continue; continue;
//} }
if (!string.IsNullOrWhiteSpace(value)) if (!string.IsNullOrWhiteSpace(value))
{ {
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value); var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);

Loading…
Cancel
Save