diff --git a/Tiobon.Core.Api/Controllers/CommonController.cs b/Tiobon.Core.Api/Controllers/CommonController.cs index 8a074776..b3bed081 100644 --- a/Tiobon.Core.Api/Controllers/CommonController.cs +++ b/Tiobon.Core.Api/Controllers/CommonController.cs @@ -47,4 +47,18 @@ public class CommonController : BaseApiController return await _commonServices.GetModuleInfoAsync(param); } #endregion + + + #region 获取模块信息接口 + /// + /// 获取模块信息接口 + /// + /// + /// + [HttpPost, Route("GetSelect")] + public async Task> GetSelectAsync(string type) + { + return await _commonServices.GetSelectAsync(type); + } + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.IServices/ICommonServices.cs b/Tiobon.Core.IServices/ICommonServices.cs index b3d513d5..01f76720 100644 --- a/Tiobon.Core.IServices/ICommonServices.cs +++ b/Tiobon.Core.IServices/ICommonServices.cs @@ -19,4 +19,6 @@ public interface ICommonServices : IBaseServices> Task> GetModuleInfoAsync([FromBody] ModuleParam param); + + Task> GetSelectAsync(string type); } diff --git a/Tiobon.Core.Model/ViewModels/Extend/CommonSelect.cs b/Tiobon.Core.Model/ViewModels/Extend/CommonSelect.cs new file mode 100644 index 00000000..21d40a3a --- /dev/null +++ b/Tiobon.Core.Model/ViewModels/Extend/CommonSelect.cs @@ -0,0 +1,12 @@ +using System.Dynamic; +using Newtonsoft.Json.Linq; + +namespace Tiobon.Core.Model; + +public class CommonSelect +{ + public JArray DT_TableDataT1 { get; set; } + public JArray DT_TablePageInfoT1 { get; set; } + public dynamic JM_TableColumnT1 { get; set; }= new ExpandoObject(); + +} \ No newline at end of file diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index 34569359..0117d356 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -1,10 +1,12 @@ using System.Data; using AgileObjects.AgileMapper; using AgileObjects.AgileMapper.Extensions; +using Elasticsearch.Net; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using SqlSugar; using Tiobon.Core.Common; using Tiobon.Core.Common.DB.Dapper; @@ -24,6 +26,7 @@ public partial class CommonServices : BaseServices>, ICommon _logger = logger; _httpContextAccessor = httpContextAccessor; } + #region 获取菜单 /// /// 获取菜单 @@ -1032,4 +1035,65 @@ public partial class CommonServices : BaseServices>, ICommon } #endregion + #region 获取模块信息 + /// + /// 获取模块信息 + /// + /// + /// + public async Task> GetSelectAsync(string type) + { + var result = new CommonSelect(); + JArray TableColumn = new JArray(); + JArray DT_TablePageInfoT1 = new JArray(); + JArray DT_TableDataT1 = new JArray(); + if (type == "Ghre_Course") + { + JObject searchItem = [ + new JProperty("defaultHidden", true), + new JProperty("field","value"), + new JProperty("label","课程ID"), + ]; + TableColumn.Add(searchItem); + searchItem = [ + new JProperty("field","label"), + new JProperty("label","课程编号"), + ]; + TableColumn.Add(searchItem); + searchItem = [ + new JProperty("field","label1"), + new JProperty("label1","课程名称"), + ]; + TableColumn.Add(searchItem); + + string sql = "SELECT Id, CourseNo, CourseName FROM Ghre_Course"; + DataTable dt = await Db.Ado.GetDataTableAsync(sql); + + for (int i = 0; i < dt.Rows.Count; i++) + { + JObject item = [ + new JProperty("value",long.Parse(dt.Rows[i]["Id"].ToString())), + new JProperty("label",dt.Rows[i]["CourseNo"].ToString()), + new JProperty("label1",dt.Rows[i]["CourseName"].ToString()) + ]; + DT_TableDataT1.Add(item); + } + + JObject item1 = [ + new JProperty("ListMax",100), + new JProperty("ListMin",10), + new JProperty("PageNum",1), + new JProperty("PageSize",99999), + new JProperty("TotalCount",dt.Rows.Count), + new JProperty("UIType","Auto") + ]; + DT_TablePageInfoT1.Add(item1); + } + result.JM_TableColumnT1.TableColumn = TableColumn; + result.DT_TableDataT1 = DT_TableDataT1; + result.DT_TablePageInfoT1 = DT_TablePageInfoT1; + return new ServiceResult() { Success = true, Message = "查询成功", Data = result, }; + } + #endregion + }