代码优化

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. 4
      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. 10
      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 string searchOperator1 { get; set; }
public List<searchOperator> searchOperator { get; set; }
public string searchColumnDefaultValue { get; set; }
public object searchColumnDefaultValue { get; set; } = "";
public string AppColumnType { get; set; }
public int pageColumnID { get; set; }
}

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

@ -65,8 +65,10 @@ public class Ghre_CertificateRuleServices : BaseServices<Ghre_CertificateRule, G
{
x.RuleTypeLabel = await GetParaLabel("TrainingCertificateRuleType", x.RuleType);
x.SendRuleLabel = await GetParaLabel("TrainingCertificateSendRule", x.SendRule);
string staticType = x.StaticType == "month" ? "月" : (x.StaticType == "year" ? "年" : "天");
if (x.ValidityType == "StaticDuration")
x.ValidityLabel = $"自颁发日起 【{x.StaticNum}】{x.StaticType}内有效";
x.ValidityLabel = $"自颁发日起 【{x.StaticNum}】{staticType}内有效";
else
if (x.ValidityType == "Unlimited")
x.ValidityLabel = $"自颁发日起终生有效";

@ -8,6 +8,7 @@ using Newtonsoft.Json.Linq;
using Tiobon.Core.Common;
using Tiobon.Core.Model;
using Newtonsoft.Json;
using Tiobon.Core.Common.Helper;
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);
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);
}

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

@ -831,9 +831,17 @@ delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';");
if (status == "Released" && entity.Status != "Released")
{
if (entity.LinkType == "CourseId" && !await _ghre_CourseServices.AnyAsync(entity.LinkId))
if (entity.LinkType == "CourseId")
{
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))
return ServiceResult.OprateFailed($"试卷【{entity.PaperName}({entity.PaperNo})】,关联的课程场景,已被删除,请重新维护数据!");

@ -8,6 +8,7 @@ using Newtonsoft.Json.Linq;
using Tiobon.Core.Common;
using Tiobon.Core.Model;
using Newtonsoft.Json;
using Tiobon.Core.Common.Helper;
namespace Tiobon.Core.Services
{
@ -113,6 +114,12 @@ namespace Tiobon.Core.Services
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);
}
@ -161,7 +168,7 @@ namespace Tiobon.Core.Services
});
entity.SearchFields.Add(new CoursePublicSearchField()
{
label = "'课程场景",
label = "课程场景",
field = "CourseSceneId",
elementType = "ApiSelect",
dataSource = "CommonList_TrainingCourseScene",
@ -171,7 +178,7 @@ namespace Tiobon.Core.Services
});
entity.SearchFields.Add(new CoursePublicSearchField()
{
label = "'课程状态",
label = "课程状态",
field = "CourseStatus",
elementType = "ApiSelect",
dataSource = "TBParaDetail_Train_CourseIsOpen",
@ -181,7 +188,7 @@ namespace Tiobon.Core.Services
});
entity.SearchFields.Add(new CoursePublicSearchField()
{
label = "'学习状态",
label = "学习状态",
field = "StudyStatus",
elementType = "ApiSelect",
dataSource = "TBParaDetail_Train_CourseIsOpen",
@ -249,13 +256,20 @@ namespace Tiobon.Core.Services
var value = jProperty.Value.ToString();
if (name == "page" || name == "pageSize")
continue;
//if (name == "Date")
//{
// var jsonParam = JsonConvert.DeserializeObject<JsonParam1>(value);
// conditions += $" AND (Date BETWEEN '{jsonParam.columnValue[0]}' AND '{jsonParam.columnValue[1]}')";
if (name == "CourseNoOrName")
{
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
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))
{
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);

Loading…
Cancel
Save