新增通用下拉数据接口

master
xiaochanghai 1 year ago
parent ae52ce2390
commit ca31a8986a
  1. 14
      Tiobon.Core.Api/Controllers/CommonController.cs
  2. 2
      Tiobon.Core.IServices/ICommonServices.cs
  3. 12
      Tiobon.Core.Model/ViewModels/Extend/CommonSelect.cs
  4. 64
      Tiobon.Core.Services/CommonServices.cs

@ -47,4 +47,18 @@ public class CommonController : BaseApiController
return await _commonServices.GetModuleInfoAsync(param);
}
#endregion
#region 获取模块信息接口
/// <summary>
/// 获取模块信息接口
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
[HttpPost, Route("GetSelect")]
public async Task<ServiceResult<CommonSelect>> GetSelectAsync(string type)
{
return await _commonServices.GetSelectAsync(type);
}
#endregion
}

@ -19,4 +19,6 @@ public interface ICommonServices : IBaseServices<RootEntityTkey<int>>
Task<ServiceResult<ModuleReturn>> GetModuleInfoAsync([FromBody] ModuleParam param);
Task<ServiceResult<CommonSelect>> GetSelectAsync(string type);
}

@ -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();
}

@ -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<RootEntityTkey<int>>, ICommon
_logger = logger;
_httpContextAccessor = httpContextAccessor;
}
#region 获取菜单
/// <summary>
/// 获取菜单
@ -1032,4 +1035,65 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon
}
#endregion
#region 获取模块信息
/// <summary>
/// 获取模块信息
/// </summary>
/// <param name="param"></param>
/// <returns></returns>
public async Task<ServiceResult<CommonSelect>> 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<CommonSelect>() { Success = true, Message = "查询成功", Data = result, };
}
#endregion
}

Loading…
Cancel
Save