diff --git a/Tiobon.Core.Api/Controllers/Base/BaseController.cs b/Tiobon.Core.Api/Controllers/Base/BaseController.cs index d5a6fb67..759a01b6 100644 --- a/Tiobon.Core.Api/Controllers/Base/BaseController.cs +++ b/Tiobon.Core.Api/Controllers/Base/BaseController.cs @@ -1,4 +1,8 @@ -using System.Reflection; +using System.Collections; +using System.Data; +using System.Reflection; +using SqlSugar; +using Tiobon.Core.Common.DB.Dapper; namespace Tiobon.Core.Controllers; @@ -76,7 +80,7 @@ public class BaseController> QueryById(long Id) { - var entity = await InvokeServiceAsync("QueryById", [Id]); + var entity = await InvokeServiceAsync("QueryById", [Id]); if (entity is null) return Failed("获取失败"); else @@ -209,11 +213,167 @@ public class BaseController /// /// + //[HttpPost, Route("ExportExcel")] + //public async Task> ExportExcel([FromBody] QueryExport body) + //{ + // var data = (await InvokeServiceAsync("ExportExcel", [body])) as ServiceResult; + // return data; + //} + [HttpPost, Route("ExportExcel")] - public async Task> ExportExcel([FromBody] QueryExport body) + public virtual async Task> ExportExcel([FromBody] QueryExport body) { - var data = (await InvokeServiceAsync("ExportExcel", [body])) as ServiceResult; - return data; + QueryBody filter = new QueryBody(); + filter.pageNum = 1; + filter.pageSize = 1000000; + filter.langId = body.langId; + + var condition = "1=1"; + if (body.exportSet.SelectRowKeys != null && body.exportSet.SelectRowKeys.Any()) + condition += $" AND Id IN({string.Join(",", body.exportSet.SelectRowKeys)})"; + + var data = (await InvokeServiceAsync("QueryFilterPage", [filter, condition, true])) as ServicePageResult; + + string sql = $@"SELECT * + FROM Ghrs_PageSettingQuery + WHERE IsEnable = 1 + AND PageNo = '{body.menuName}' + AND (defaultHidden = 'false' OR defaultHidden is null) + ORDER BY SortNo ASC"; + + var columns = DbAccess.QueryList(sql); + + var fieldDescs = new Dictionary(); + if (body.exportSet.ExFields.Any()) + body.exportSet.ExFields.ForEach(x => + { + if (columns.Any(o => o.field == x)) + fieldDescs.Add(x, columns.FirstOrDefault(o => o.field == x)?.label); + }); + else + fieldDescs = columns.ToDictionary(item => item.field, item => item.label); + var dt = ToDataTable(data.result.DT_TableDataT1, fieldDescs, null); + // 获取所有列名 + var dtColumns = dt.Columns; + + var id = SnowFlakeSingle.instance.getID(); + var physicsPath = $"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot"; + var path = $"{$"{Path.DirectorySeparatorChar}files{Path.DirectorySeparatorChar}export{Path.DirectorySeparatorChar}{id}{Path.DirectorySeparatorChar}"}"; + if (!Directory.Exists(physicsPath + path)) + Directory.CreateDirectory(physicsPath + path); + + path = path + body.exportSet.TitleName + ".xlsx"; + NPOIHelper.ExportExcel(dt, body.exportSet.TitleName, "sheet1", physicsPath + path); + + var result = new ExcelData(); + result.filePath = path; + result.fileName = body.exportSet.TitleName + ".xlsx"; + return ServiceResult.OprateSuccess("导出成功", result); + } + /// + /// 列名按照前端显示顺序导出 + /// + /// + /// + /// + public static (List, List) Sort(Dictionary columns, List ExportFields) + { + List fields = new List(); + List colunms = new List(); + if (ExportFields == null || ExportFields.Count == 0) + { + return (columns.Keys.ToList(), columns.Values.ToList()); + } + + foreach (var field in ExportFields) + { + foreach (var item in columns) + { + if (item.Key == field) + { + fields.Add(item.Key); + colunms.Add(item.Value); + } + } + } + + return (fields, colunms); + } + + public static DataTable ToDataTable(List list, Dictionary fieldDescs = null, params string[] propertyName) + { + var (fields, colunms) = Sort(fieldDescs, null); + + List propertyNameList = new List(); + if (propertyName != null) + { + propertyNameList.AddRange(propertyName); + } + DataTable result = new DataTable(); + if (list.Count > 0) + { + PropertyInfo[] propertys = list[0].GetType().GetProperties(); + for (int i = 0; i < fields.Count; i++) + { + foreach (PropertyInfo pi in propertys) + { + if (propertyNameList.Count == 0) + { + //if (DBNull.Value.Equals(pi.PropertyType)) + //{ + // // pi.PropertyType = DateTime; + //} + Type colType = pi.PropertyType; + if (colType.IsGenericType && colType.GetGenericTypeDefinition() == typeof(Nullable<>)) + { + colType = colType.GetGenericArguments()[0]; + } + if (fields[i] == pi.Name) + { + result.Columns.Add(colunms[i], colType); + } + //result.Columns.Add(pi.Name, pi.PropertyType); + } + else + { + if (propertyNameList.Contains(pi.Name)) + { + if (fields[i] == pi.Name) + result.Columns.Add(fields[i], pi.PropertyType); + } + } + } + } + for (int i = 0; i < list.Count; i++) + { + ArrayList tempList = new ArrayList(); + for (int j = 0; j < fields.Count; j++) + { + foreach (PropertyInfo pi in propertys) + { + if (fields[j] == pi.Name) + { + if (propertyNameList.Count == 0) + { + object obj = pi.GetValue(list[i], null); + tempList.Add(obj); + } + else + { + if (propertyNameList.Contains(pi.Name)) + { + object obj = pi.GetValue(list[i], null); + tempList.Add(obj); + } + } + } + } + } + object[] array = tempList.ToArray(); + result.LoadDataRow(array, true); + } + } + return result; } #endregion diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_CreditPointController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_CreditPointController.cs index 024ffae2..c9425c42 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_CreditPointController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_CreditPointController.cs @@ -1,4 +1,10 @@ -namespace Tiobon.Core.Api.Controllers; +using System.Collections; +using System.Data; +using System.Reflection; +using SqlSugar; +using Tiobon.Core.Common.DB.Dapper; + +namespace Tiobon.Core.Api.Controllers; /// /// 学分记录(Controller) @@ -21,7 +27,7 @@ public class Ghre_CreditPointController : BaseController> QueryTotal([FromBody] QueryBody body) { - return await _service.QueryTotal(body); + return await _service.QueryTotal(body, null); } @@ -41,4 +47,132 @@ public class Ghre_CreditPointController : BaseController> ExportExcel([FromBody] QueryExport body) + { + QueryBody filter = new QueryBody(); + filter.pageNum = 1; + filter.pageSize = 1000000; + filter.langId = body.langId; + + var condition = "1=1"; + if (body.exportSet.SelectRowKeys != null && body.exportSet.SelectRowKeys.Any()) + condition += $" AND Id IN({string.Join(",", body.exportSet.SelectRowKeys)})"; + + var data = await _service.QueryTotal(filter, condition); + + string sql = $@"SELECT * + FROM Ghrs_PageSettingQuery + WHERE IsEnable = 1 + AND PageNo = '{body.menuName}' + AND (defaultHidden = 'false' OR defaultHidden is null) + ORDER BY SortNo ASC"; + + var columns = DbAccess.QueryList(sql); + + var fieldDescs = new Dictionary(); + if (body.exportSet.ExFields.Any()) + body.exportSet.ExFields.ForEach(x => + { + if (columns.Any(o => o.field == x)) + fieldDescs.Add(x, columns.FirstOrDefault(o => o.field == x)?.label); + }); + else + fieldDescs = columns.ToDictionary(item => item.field, item => item.label); + var dt = ToDataTable1(data.result.DT_TableDataT1, fieldDescs, null); + // 获取所有列名 + var dtColumns = dt.Columns; + + var id = SnowFlakeSingle.instance.getID(); + var physicsPath = $"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot"; + var path = $"{$"{Path.DirectorySeparatorChar}files{Path.DirectorySeparatorChar}export{Path.DirectorySeparatorChar}{id}{Path.DirectorySeparatorChar}"}"; + if (!Directory.Exists(physicsPath + path)) + Directory.CreateDirectory(physicsPath + path); + + path = path + body.exportSet.TitleName + ".xlsx"; + NPOIHelper.ExportExcel(dt, body.exportSet.TitleName, "sheet1", physicsPath + path); + + var result = new ExcelData(); + result.filePath = path; + result.fileName = body.exportSet.TitleName + ".xlsx"; + return ServiceResult.OprateSuccess("导出成功", result); + } + public static DataTable ToDataTable1(List list, Dictionary fieldDescs = null, params string[] propertyName) + { + var (fields, colunms) = Sort(fieldDescs, null); + + List propertyNameList = new List(); + if (propertyName != null) + { + propertyNameList.AddRange(propertyName); + } + DataTable result = new DataTable(); + if (list.Count > 0) + { + PropertyInfo[] propertys = list[0].GetType().GetProperties(); + for (int i = 0; i < fields.Count; i++) + { + foreach (PropertyInfo pi in propertys) + { + if (propertyNameList.Count == 0) + { + //if (DBNull.Value.Equals(pi.PropertyType)) + //{ + // // pi.PropertyType = DateTime; + //} + Type colType = pi.PropertyType; + if (colType.IsGenericType && colType.GetGenericTypeDefinition() == typeof(Nullable<>)) + { + colType = colType.GetGenericArguments()[0]; + } + if (fields[i] == pi.Name) + { + result.Columns.Add(colunms[i], colType); + } + //result.Columns.Add(pi.Name, pi.PropertyType); + } + else + { + if (propertyNameList.Contains(pi.Name)) + { + if (fields[i] == pi.Name) + result.Columns.Add(fields[i], pi.PropertyType); + } + } + } + } + for (int i = 0; i < list.Count; i++) + { + ArrayList tempList = new ArrayList(); + for (int j = 0; j < fields.Count; j++) + { + foreach (PropertyInfo pi in propertys) + { + if (fields[j] == pi.Name) + { + if (propertyNameList.Count == 0) + { + object obj = pi.GetValue(list[i], null); + tempList.Add(obj); + } + else + { + if (propertyNameList.Contains(pi.Name)) + { + object obj = pi.GetValue(list[i], null); + tempList.Add(obj); + } + } + } + } + } + object[] array = tempList.ToArray(); + result.LoadDataRow(array, true); + } + } + return result; + } } \ No newline at end of file diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamPaperController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamPaperController.cs index e40bfcf9..0c849102 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamPaperController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamPaperController.cs @@ -108,7 +108,7 @@ public class Ghre_ExamPaperController : BaseController> ExportExcel([FromBody] QueryExport body, string status) + public async Task> ExportExcel([FromBody] QueryExport body, string status) { return await _service.ExportExcel(body, status); } diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index 9406a2d1..54df935d 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -148,6 +148,14 @@ + + + 列名按照前端显示顺序导出 + + + + + 博客管理 diff --git a/Tiobon.Core.Common/DB/Dapper/Utilities/DbAccess.cs b/Tiobon.Core.Common/DB/Dapper/Utilities/DbAccess.cs index fee6644b..9f28f5b7 100644 --- a/Tiobon.Core.Common/DB/Dapper/Utilities/DbAccess.cs +++ b/Tiobon.Core.Common/DB/Dapper/Utilities/DbAccess.cs @@ -1,10 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Data; +using System.Data; using System.Data.SqlClient; using System.Linq.Expressions; using System.Text; -using System.Threading.Tasks; using Tiobon.Core.Common.DB.Dapper.Const; using Tiobon.Core.Common.DB.Dapper.DBManager; using Tiobon.Core.Common.DB.Dapper.Enums; diff --git a/Tiobon.Core.Common/Helper/NPOIHelper.cs b/Tiobon.Core.Common/Helper/NPOIHelper.cs index 289267f6..71641da7 100644 --- a/Tiobon.Core.Common/Helper/NPOIHelper.cs +++ b/Tiobon.Core.Common/Helper/NPOIHelper.cs @@ -195,7 +195,7 @@ public class NPOIHelper style.BorderRight = BorderStyle.Thin; style.BorderTop = BorderStyle.Thin; // 字体 - var font1 = workbook.CreateFont(); + var font1 = workbook.CreateFont(); font1.FontHeightInPoints = (short)10; font1.FontName = "宋体"; style.SetFont(font1); @@ -217,19 +217,28 @@ public class NPOIHelper { DateTime.TryParse(drValue, out dateV); //dateV = DateTimeHelper.ConvertToSecondString(dateV); - newCell.SetCellValue(dateV); - if (column.Caption == "renderDateTime") - { - newCell.CellStyle.DataFormat = format.GetFormat("yyyy-mm-dd hh:mm"); - } - else if (column.Caption == "renderDate") - { - newCell.CellStyle.DataFormat = format.GetFormat("yyyy-mm-dd"); - } - else - { - newCell.CellStyle.DataFormat = format.GetFormat("yyyy-mm-dd hh:mm:ss"); - } + newCell.SetCellValue(DateTimeHelper.ConvertToSecondString(dateV)); + //if (column.Caption == "renderDateTime") + //{ + // newCell.CellStyle.DataFormat = format.GetFormat("yyyy-mm-dd hh:mm"); + //} + //else if (column.Caption == "renderDate") + //{ + // newCell.CellStyle.DataFormat = format.GetFormat("yyyy-mm-dd"); + //} + //else + //{ + // + //} + + //try + //{ + // Convert.ToDateTime(drValue); newCell.CellStyle.DataFormat = format.GetFormat("yyyy-mm-dd hh:mm:ss"); + //} + //catch (Exception) + //{ + + //} } break; case "System.Boolean"://布尔型 @@ -261,50 +270,52 @@ public class NPOIHelper } #endregion - //获取当前列的宽度,然后对比本列的长度,取最大值 - if (true) - for (int columnNum = 0; columnNum <= dtSource.Columns.Count; columnNum++) - { - sheet.AutoSizeColumn(columnNum);//先来个常规自适应 - var columnWidth = sheet.GetColumnWidth(columnNum) / 256; - for (int rowNum = 1; rowNum <= sheet.LastRowNum; rowNum++) + + rowIndex++; + } + + //获取当前列的宽度,然后对比本列的长度,取最大值 + if (true) + for (int columnNum = 0; columnNum <= dtSource.Columns.Count; columnNum++) + { + sheet.AutoSizeColumn(columnNum);//先来个常规自适应 + + var columnWidth = sheet.GetColumnWidth(columnNum) / 256; + for (int rowNum = 1; rowNum <= sheet.LastRowNum; rowNum++) + { + IRow currentRow; + //当前行未被使用过 + if (sheet.GetRow(rowNum) == null) { - IRow currentRow; - //当前行未被使用过 - if (sheet.GetRow(rowNum) == null) - { - currentRow = sheet.CreateRow(rowNum); - } - else - { - currentRow = sheet.GetRow(rowNum); - } - if (currentRow.GetCell(columnNum) != null) - { - ICell currentCell = currentRow.GetCell(columnNum); - int length = Encoding.Default.GetBytes(currentCell.ToString()).Length; - if (columnWidth < length) - { - columnWidth = length; - if (columnWidth > 30) columnWidth = 30; - } - } + currentRow = sheet.CreateRow(rowNum); } - try + else { - sheet.SetColumnWidth(columnNum, columnWidth * 300); // 256 - + currentRow = sheet.GetRow(rowNum); } - catch (Exception e) + if (currentRow.GetCell(columnNum) != null) { - + ICell currentCell = currentRow.GetCell(columnNum); + int length = Encoding.Default.GetBytes(currentCell.ToString()).Length; + if (columnWidth < length) + { + columnWidth = length; + if (columnWidth > 30) columnWidth = 30; + } } + } + try + { + sheet.SetColumnWidth(columnNum, columnWidth * 300); // 256 + + } + catch (Exception e) + { } - rowIndex++; - } + } using (MemoryStream ms = new MemoryStream()) { workbook.Write(ms); diff --git a/Tiobon.Core.IServices/BASE/IBaseServices.cs b/Tiobon.Core.IServices/BASE/IBaseServices.cs index a804e022..65775941 100644 --- a/Tiobon.Core.IServices/BASE/IBaseServices.cs +++ b/Tiobon.Core.IServices/BASE/IBaseServices.cs @@ -152,7 +152,7 @@ namespace Tiobon.Core.IServices.BASE Task> QueryPage(Expression> whereExpression, int pageIndex = 1, int pageSize = 20, string orderByFields = null); Task> QueryFilterPage([FromBody] QueryBody body); Task> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true); - Task> ExportExcel([FromBody] QueryExport body); + Task> ExportExcel([FromBody] QueryExport body); Task> ImportExcel(IFormFile file); diff --git a/Tiobon.Core.IServices/Ghre/IGhre_CreditPointServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_CreditPointServices.cs index 6037357d..26d828c9 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_CreditPointServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_CreditPointServices.cs @@ -10,7 +10,7 @@ namespace Tiobon.Core.IServices; /// public interface IGhre_CreditPointServices : IBaseServices { - Task> QueryTotal(QueryBody filter); + Task> QueryTotal(QueryBody filter, string condition); Task> QueryDetail(QueryBody filter, string staffId); } \ No newline at end of file diff --git a/Tiobon.Core.IServices/Ghre/IGhre_ExamPaperServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_ExamPaperServices.cs index 8a3b9ee8..1a87fa14 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_ExamPaperServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_ExamPaperServices.cs @@ -23,6 +23,6 @@ namespace Tiobon.Core.IServices Task> GetSelectAsync(long? linkId, string KeyWords); - Task> ExportExcel(QueryExport body, string status); + Task> ExportExcel(QueryExport body, string status); } } \ No newline at end of file diff --git a/Tiobon.Core.Services/BASE/BaseServices.cs b/Tiobon.Core.Services/BASE/BaseServices.cs index bb6edf3f..bc1218b6 100644 --- a/Tiobon.Core.Services/BASE/BaseServices.cs +++ b/Tiobon.Core.Services/BASE/BaseServices.cs @@ -781,7 +781,7 @@ public class BaseServices : IBaseServ return new ServicePageResult(filter.pageNum, total, filter.pageSize, entitys); } - public async Task> ExportExcel(QueryExport body) + public async Task> ExportExcel(QueryExport body) { QueryBody filter = new QueryBody(); filter.pageNum = 1; @@ -810,8 +810,6 @@ public class BaseServices : IBaseServ { if (columns.Any(o => o.field == x)) fieldDescs.Add(x, columns.FirstOrDefault(o => o.field == x)?.label); - - }); else fieldDescs = columns.ToDictionary(item => item.field, item => item.label); @@ -827,7 +825,11 @@ public class BaseServices : IBaseServ path = path + body.exportSet.TitleName + ".xlsx"; NPOIHelper.ExportExcel(dt, null, "sheet1", physicsPath + path); - return ServiceResult.OprateSuccess("导出成功", path); + + var result = new ExcelData(); + result.filePath = path; + result.fileName = body.exportSet.TitleName + ".xlsx"; + return ServiceResult.OprateSuccess("导出成功", result); } /// /// 列名按照前端显示顺序导出 diff --git a/Tiobon.Core.Services/Ghre/Ghre_CertificateRuleServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CertificateRuleServices.cs index 642b11c2..7015edbe 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CertificateRuleServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CertificateRuleServices.cs @@ -33,6 +33,7 @@ public class Ghre_CertificateRuleServices : BaseServices> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) { + string condition1 = string.Empty; if (filter.jsonParam != null) foreach (JProperty jProperty in filter.jsonParam.Properties()) { @@ -45,16 +46,20 @@ public class Ghre_CertificateRuleServices : BaseServices x.CourseSceneId != null || x.CourseId != null).Select(x => x.CourseId ?? x.CourseSceneId).Distinct().ToList(); diff --git a/Tiobon.Core.Services/Ghre/Ghre_CreditPointServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CreditPointServices.cs index dd94d09b..7e362a6e 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CreditPointServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CreditPointServices.cs @@ -9,6 +9,9 @@ using SqlSugar; using Tiobon.Core.Common; using Tiobon.Core.Model; using Newtonsoft.Json; +using Microsoft.AspNetCore.Mvc; +using Tiobon.Core.Common.DB.Dapper; +using Tiobon.Core.Common.Helper; namespace Tiobon.Core.Services; @@ -25,7 +28,7 @@ public class Ghre_CreditPointServices : BaseServices> QueryTotal(QueryBody filter) + public async Task> QueryTotal(QueryBody filter,string condition) { RefAsync totalCount = 0; string sql = @"SELECT * @@ -128,7 +131,8 @@ public class Ghre_CreditPointServices : BaseServices(body.pageNum, data.result.DT_TablePageInfoT1.TotalCount, body.pageSize, data1); } - public async Task> ExportExcel(QueryExport body, string status) + public async Task> ExportExcel(QueryExport body, string status) { QueryBody filter = new QueryBody(); filter.pageNum = 1; @@ -185,7 +185,10 @@ public class Ghre_ExamPaperServices : BaseServices.OprateSuccess("导出成功", path); + var result = new ExcelData(); + result.filePath = path; + result.fileName = body.exportSet.TitleName + ".xlsx"; + return ServiceResult.OprateSuccess("导出成功", result); } //public async Task> QueryFilterPage1(QueryBody filter, string status = null) diff --git a/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs b/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs index a6172d70..0ee5bad5 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs @@ -210,6 +210,9 @@ public class Ghre_QuestionServices : BaseServices(sql) .OrderBy(filter.orderBy) .ToPageListAsync(filter.pageNum, filter.pageSize, totalCount); diff --git a/Tiobon.Core.Services/Ghre/Ghre_RequiredCourseServices.cs b/Tiobon.Core.Services/Ghre/Ghre_RequiredCourseServices.cs index 95e7f44f..8dfaf128 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_RequiredCourseServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_RequiredCourseServices.cs @@ -25,7 +25,7 @@ public class Ghre_RequiredCourseServices : BaseServices> QueryFilterPage(QueryBody filter) + public override async Task> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) { if (string.IsNullOrWhiteSpace(filter.orderBy)) filter.orderBy = "CreateTime1 DESC"; diff --git a/Tiobon.Core.Services/Ghre/Ghre_SchoolServices.cs b/Tiobon.Core.Services/Ghre/Ghre_SchoolServices.cs index 8565743e..7064c82c 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_SchoolServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_SchoolServices.cs @@ -32,22 +32,25 @@ public class Ghre_SchoolServices : BaseServices> QueryFilterPage(QueryBody filter) + public override async Task> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) { string schoolNo1 = string.Empty; - foreach (JProperty jProperty in filter.jsonParam.Properties()) - { - var name = jProperty.Name; - var value = jProperty.Value.ToString(); - if (name == "SchoolNo1") + if (filter.jsonParam != null) + foreach (JProperty jProperty in filter.jsonParam.Properties()) { - var jsonParam = JsonConvert.DeserializeObject(value); - schoolNo1 = jsonParam?.columnValue?.ToString(); + var name = jProperty.Name; + var value = jProperty.Value.ToString(); + if (name == "SchoolNo1") + { + var jsonParam = JsonConvert.DeserializeObject(value); + schoolNo1 = jsonParam?.columnValue?.ToString(); + } } - } - var condition = string.Empty; if (!string.IsNullOrWhiteSpace(schoolNo1)) - condition = $"(SchoolNo LIKE '%{schoolNo1}%' OR SchoolName LIKE '%{schoolNo1}%')"; + if (condition.IsNull()) + condition = $"(SchoolNo LIKE '%{schoolNo1}%' OR SchoolName LIKE '%{schoolNo1}%')"; + else condition = $" AND (SchoolNo LIKE '%{schoolNo1}%' OR SchoolName LIKE '%{schoolNo1}%')"; + var data = await base.QueryFilterPage(filter, condition); data.result.DT_TableDataT1.ForEach(x => { diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index 9406a2d1..54df935d 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -148,6 +148,14 @@ + + + 列名按照前端显示顺序导出 + + + + + 博客管理