From c01727934c7769d289cd1ef7f3a8aeb028ddb593 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Thu, 16 May 2024 16:00:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=80=9A=E7=94=A8=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=8F=9C=E5=8D=95=E8=A1=A8=E5=8D=95=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Base/BaseController.cs | 13 +- Tiobon.Core.Api/Tiobon.Core.Model.xml | 15 ++ Tiobon.Core.Api/Tiobon.Core.xml | 7 + Tiobon.Core.Common/Attribute/QueryFilter.cs | 34 +++- Tiobon.Core.IServices/BASE/IBaseServices.cs | 2 + .../View/Ghre/Ghre_Course.Dto.View.cs | 17 +- .../ViewModels/Extend/ServiceFormResult.cs | 12 ++ Tiobon.Core.Services/BASE/BaseServices.cs | 171 +++++++++++++++++- .../Ghre/Ghre_CourseServices.cs | 43 ++++- Tiobon.Core/Tiobon.Core.Model.xml | 15 ++ Tiobon.Core/Tiobon.Core.xml | 7 + 11 files changed, 320 insertions(+), 16 deletions(-) create mode 100644 Tiobon.Core.Model/ViewModels/Extend/ServiceFormResult.cs diff --git a/Tiobon.Core.Api/Controllers/Base/BaseController.cs b/Tiobon.Core.Api/Controllers/Base/BaseController.cs index 576ec5b9..6aa8b3f4 100644 --- a/Tiobon.Core.Api/Controllers/Base/BaseController.cs +++ b/Tiobon.Core.Api/Controllers/Base/BaseController.cs @@ -83,6 +83,17 @@ public class BaseController(entity, "获取成功"); } + /// + /// 查询菜单表单信息 + /// + /// body + /// + [HttpPost("QueryForm")] + public virtual async Task QueryForm([FromBody] QueryForm body) + { + var entity = await InvokeServiceAsync("QueryForm", [body]) as ServiceFormResult; + return entity; + } #endregion #region 新增 @@ -201,7 +212,7 @@ public class BaseController [HttpPost, Route("Export")] public async Task> Export([FromBody] QueryBody body) - { + { var data = (await InvokeServiceAsync("Export", [body])) as ServiceResult; return data; } diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index 5b027bea..838dc5fd 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -4019,6 +4019,21 @@ Ghre_Course(Dto.View) + + + 课程分类 + + + + + 创建信息 + + + + + 修改信息 + + 课程分类(Dto.View) diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index d773c557..fbce25c4 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -93,6 +93,13 @@ 主键ID + + + 查询菜单表单信息 + + body + + 新增数据 diff --git a/Tiobon.Core.Common/Attribute/QueryFilter.cs b/Tiobon.Core.Common/Attribute/QueryFilter.cs index 9aaa6a0f..e7c4742a 100644 --- a/Tiobon.Core.Common/Attribute/QueryFilter.cs +++ b/Tiobon.Core.Common/Attribute/QueryFilter.cs @@ -65,7 +65,7 @@ public class QueryFilter /// 动态查询条件 /// public class QueryBody -{ +{ /// /// 起始位置(e.g. 0) /// @@ -93,12 +93,40 @@ public class QueryBody /// 排序条件表达式(e.g. LoginName ASC,Name DESC) /// public string orderBy { get; set; } - + } public class JsonParam { public string columnValue { get; set; } public string operationKey { get; set; } public string token { get; set; } - + +} + +/// +/// 动态查询条件 +/// +public class QueryForm +{ + public string doType { get; set; } + public long id { get; set; } + public int langId { get; set; } + public string menuName { get; set; } + public string token { get; set; } + public string procName { get; set; } + public string timestamp { get; set; } + public string userId { get; set; } + private JObject _jsonParam; + /// + /// 查询条件( 例如:id = 1 and name = 小明) + /// + public JObject jsonParam + { + get { return _jsonParam; } + set + { + _jsonParam = value; + } + } + } \ No newline at end of file diff --git a/Tiobon.Core.IServices/BASE/IBaseServices.cs b/Tiobon.Core.IServices/BASE/IBaseServices.cs index d49ffac3..0156eb62 100644 --- a/Tiobon.Core.IServices/BASE/IBaseServices.cs +++ b/Tiobon.Core.IServices/BASE/IBaseServices.cs @@ -92,6 +92,8 @@ namespace Tiobon.Core.IServices.BASE Task QueryById(object objId, bool blnUseCache = false); Task> QueryByIDs(object[] lstIds); + Task QueryForm(QueryForm body); + Task Add(TInsertDto model); Task> Add(List listEntity); diff --git a/Tiobon.Core.Model/View/Ghre/Ghre_Course.Dto.View.cs b/Tiobon.Core.Model/View/Ghre/Ghre_Course.Dto.View.cs index 01e7bd2a..3f566367 100644 --- a/Tiobon.Core.Model/View/Ghre/Ghre_Course.Dto.View.cs +++ b/Tiobon.Core.Model/View/Ghre/Ghre_Course.Dto.View.cs @@ -13,7 +13,7 @@ *│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │ *│ 作者:SimonHsiao │ *└──────────────────────────────────┘ -*/ +*/ namespace Tiobon.Core.Model.Models { @@ -23,5 +23,20 @@ namespace Tiobon.Core.Model.Models /// public class Ghre_CourseDto : Ghre_Course { + /// + /// 课程分类 + /// + public string CourseClassName { get; set; } + + + /// + /// 创建信息 + /// + public string CreateDataInfo { get; set; } + + /// + /// 修改信息 + /// + public string UpdateDataInfo { get; set; } } } diff --git a/Tiobon.Core.Model/ViewModels/Extend/ServiceFormResult.cs b/Tiobon.Core.Model/ViewModels/Extend/ServiceFormResult.cs new file mode 100644 index 00000000..f554df36 --- /dev/null +++ b/Tiobon.Core.Model/ViewModels/Extend/ServiceFormResult.cs @@ -0,0 +1,12 @@ +using System.Dynamic; + +namespace Tiobon.Core.Model; + +public class ServiceFormResult +{ + public int code { get; set; } = 0; + public string message { get; set; } + public dynamic result { get; set; } = new ExpandoObject(); + public string type { get; set; } = "success"; + +} diff --git a/Tiobon.Core.Services/BASE/BaseServices.cs b/Tiobon.Core.Services/BASE/BaseServices.cs index 91c9284b..093c5844 100644 --- a/Tiobon.Core.Services/BASE/BaseServices.cs +++ b/Tiobon.Core.Services/BASE/BaseServices.cs @@ -1,7 +1,10 @@ using System.Data; +using System.Dynamic; using System.Linq.Expressions; using AgileObjects.AgileMapper; using Microsoft.AspNetCore.Http; +using Newtonsoft.Json.Linq; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; using SqlSugar; using Tiobon.Core.Common; using Tiobon.Core.Common.Caches; @@ -124,6 +127,172 @@ public class BaseServices : IBaseServ return Mapper.Map(data).ToANew>(); } + + public async Task QueryForm(QueryForm body) + { + var result = new ServiceFormResult(); + var data = await BaseDal.QueryById(body.id); + var dto = Mapper.Map(data).ToANew(); + string sql = string.Empty; + var dt = new DataTable(); + + Type entityType = typeof(TEntity); + sql = @$"DECLARE @langId INT = '{body.langId}',@ID BIGINT = '{body.id}'; + + SELECT *, + isnull + ((SELECT CASE WHEN @langId = 1 THEN UserName ELSE UserEname END + FROM Ghrs_User kk + WHERE kk.UserId = a.CreateBy), + '') + + ' ' + + [dbo].[FLangKeyToValue] ('GHR_Common_000078', @langId, '于 ') + + ' ' + + CONVERT (NVARCHAR (16), CreateTime, 121) + + ' ' + + [dbo].[FLangKeyToValue] ('GHR_Common_000079', @langId, ' 创建') + CreateDataInfo, + isnull + ((SELECT CASE WHEN @langId = 1 THEN UserName ELSE UserEname END + FROM Ghrs_User kk + WHERE kk.UserId = a.UpdateBy), + '') + + ' ' + + [dbo].[FLangKeyToValue] ('GHR_Common_000078', @langId, '于') + + ' ' + + CONVERT (NVARCHAR (16), UpdateTime, 121) + + ' ' + + [dbo].[FLangKeyToValue] + ('GHR_Common_000080', @langId, ' 最后修改') + UpdateDataInfo + FROM {entityType.GetEntityTableName()} a + WHERE a.Id = @ID"; + + result.result.DT_TableDataT1 = Db.Ado.SqlQuery(sql); + + + #region JM_PageFormActionsT1 + dynamic JM_PageFormActionsT1 = new ExpandoObject(); + + var toolbars = new JArray(); + + sql = @$"SELECT field fnKey, [dbo].[FLangKeyToValue] (mkey, {body.langId}, label) fnTitle, icon + FROM Ghrs_PageSettingEdit + WHERE IsEnable = 1 AND pageNo = '{body.menuName}' AND elementType = 'FnKey'"; + dt = await Db.Ado.GetDataTableAsync(sql); + + for (int i = 0; i < dt.Rows.Count; i++) + { + JObject item = + [ + new JProperty("fnKey", dt.Rows[i]["fnKey"].ToString()), + new JProperty("fnTitle", dt.Rows[i]["fnTitle"].ToString()), + new JProperty("icon", dt.Rows[i]["icon"].ToString()), + new JProperty("display", true) + ]; + toolbars.Add(item); + } + JM_PageFormActionsT1.Toolbar = toolbars; + #endregion + + #region JM_TableColumnT1 + dynamic JM_TableColumnT1 = new ExpandoObject(); + var tableColumn = new JArray(); + sql = @$"SELECT field, + [dbo].[FLangKeyToValue] (mkey, {body.langId}, label) + label, + required, + editable, + rowNum, + colNum, + elementType, + dbo.FS_GetdataSourceBySet + (dataSource, APIDataSourceType, Ghrs_PageSettingEdit.APIDataSourceID) + dataSource, + defaultHidden, + isPrimaryKey, + isSingleColumn + FROM Ghrs_PageSettingEdit + WHERE IsEnable = 1 + AND pageNo = '{body.menuName}' + AND elementType NOT IN ('FnKey', 'PageGroup');"; + dt = await Db.Ado.GetDataTableAsync(sql); + + for (int i = 0; i < dt.Rows.Count; i++) + { + JObject item = + [ + new JProperty("field", dt.Rows[i]["field"].ToString()), + new JProperty("label", dt.Rows[i]["label"].ToString()), + new JProperty("required",!string.IsNullOrWhiteSpace(dt.Rows[i]["required"].ToString())? Convert.ToBoolean(dt.Rows[i]["required"]):null), + new JProperty("editable",!string.IsNullOrWhiteSpace(dt.Rows[i]["editable"].ToString())? Convert.ToBoolean(dt.Rows[i]["editable"]):null), + new JProperty("rowNum",!string.IsNullOrWhiteSpace(dt.Rows[i]["rowNum"].ToString())? Convert.ToInt32(dt.Rows[i]["rowNum"]):null), + new JProperty("colNum",!string.IsNullOrWhiteSpace(dt.Rows[i]["colNum"].ToString())? Convert.ToInt32(dt.Rows[i]["colNum"]):null), + new JProperty("elementType", dt.Rows[i]["elementType"].ToString()), + new JProperty("dataSource", dt.Rows[i]["dataSource"].ToString()), + new JProperty("defaultHidden", dt.Rows[i]["defaultHidden"].ToString()), + new JProperty("isPrimaryKey", dt.Rows[i]["isPrimaryKey"].ToString()), + new JProperty("isSingleColumn",!string.IsNullOrWhiteSpace(dt.Rows[i]["isSingleColumn"].ToString())? Convert.ToInt32(dt.Rows[i]["isSingleColumn"]):null), + ]; + tableColumn.Add(item); + } + JM_TableColumnT1.TableColumn = tableColumn; + #endregion + + #region JM_PageFormT1 + dynamic JM_PageFormT1 = new ExpandoObject(); + var pageForm = new JArray(); + JObject pageFormItem = + [ + new JProperty("disabled", false), + new JProperty("labelAlign", "right"), + new JProperty("labelCol", "{span: 6}"), + new JProperty("labelWidth",120), + new JProperty("layout", "horizontal") + ]; + + sql = $@"SELECT [dbo].[FLangKeyToValue] (MKey, {body.langId}, MenuName) pageTitle, + IUDProcedure apiName + FROM Ghrs_Menu + WHERE MenuNo = '{body.menuName}' AND IsEnable = 1"; + dt = await Db.Ado.GetDataTableAsync(sql); + if (dt.Rows.Count > 0) + { + pageFormItem.Add(new JProperty("pageTitle", dt.Rows[0]["pageTitle"].ToString())); + pageFormItem.Add(new JProperty("apiName", dt.Rows[0]["apiName"].ToString())); + } + pageForm.Add(pageFormItem); + JM_PageFormT1.PageForm = pageForm; + #endregion + + #region DT_PageMutiMsg + var DT_PageMutiMsg = new List(); + sql = $@"SELECT Langkey field, + CASE {body.langId} + WHEN 1 THEN isnull (Value01, LangValue) + WHEN 2 THEN isnull (Value02, LangValue) + WHEN 3 THEN isnull (Value03, LangValue) + WHEN 4 THEN isnull (Value04, LangValue) + WHEN 5 THEN isnull (Value05, LangValue) + WHEN 6 THEN isnull (Value06, LangValue) + WHEN 7 THEN isnull (Value07, LangValue) + WHEN 8 THEN isnull (Value08, LangValue) + WHEN 9 THEN isnull (Value09, LangValue) + WHEN 10 THEN isnull (Value10, LangValue) + END label + FROM Ghrs_LangKey + WHERE (LangKey LIKE 'GHR_Page%' OR LangKey LIKE 'GHR_Common%') + AND IsEnable = 1"; + DT_PageMutiMsg = Db.Ado.SqlQuery(sql); + #endregion + + result.result.JM_PageFormActionsT1 = JM_PageFormActionsT1; + result.result.JM_TableColumnT1 = JM_TableColumnT1; + result.result.JM_PageFormT1 = JM_PageFormT1; + result.result.DT_PageMutiMsg = DT_PageMutiMsg; + return result; + } + #region 新增 /// @@ -806,7 +975,7 @@ public class BaseServices : IBaseServ if (list == null || (list != null && !list.Any())) { string sql = $"SELECT * FROM Ghrs_ParaDetail WHERE ParaMasterNo ='{key}' ORDER BY SortNo ASC"; - list = DbAccess.QueryList(sql); + list = DbAccess.QueryList(sql); if (list.Any()) await _caching.SetAsync(key, list); } diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs index 72b41541..77a1ae5f 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs @@ -3,19 +3,42 @@ using Tiobon.Core.IServices; using Tiobon.Core.Model.Models; using Tiobon.Core.Services.BASE; using Tiobon.Core.IRepository.Base; +using Tiobon.Core.Common; +using Tiobon.Core.Model; +using AgileObjects.AgileMapper; -namespace Tiobon.Core.Services +namespace Tiobon.Core.Services; + +/// +/// Ghre_Course (服务) +/// +public class Ghre_CourseServices : BaseServices, IGhre_CourseServices { - /// - /// Ghre_Course (服务) - /// - public class Ghre_CourseServices : BaseServices, IGhre_CourseServices + private readonly IBaseRepository _dal; + private IGhre_CourseClassServices _ghre_CourseClassServices; + public Ghre_CourseServices(IBaseRepository dal, + IGhre_CourseClassServices ghre_CourseClassServices) + { + this._dal = dal; + base.BaseDal = dal; + _ghre_CourseClassServices = ghre_CourseClassServices; + } + + public override async Task> QueryFilterPage(QueryBody body) { - private readonly IBaseRepository _dal; - public Ghre_CourseServices(IBaseRepository dal) + var data = await BaseDal.QueryFilterPage(body); + var list = Mapper.Map(data.result.DT_TableDataT1).ToANew>(); + + var classIds = list.Select(x => x.CourseClassId).Distinct().ToList(); + var classs = await _ghre_CourseClassServices.Query(x => classIds.Contains(x.Id)); + + list.ForEach(x => { - this._dal = dal; - base.BaseDal = dal; - } + if (x.CourseClassId != null) + x.CourseClassName = classs.FirstOrDefault(o => o.Id == x.CourseClassId)?.ClassName; + }); + + return new ServicePageResult(body.pageNum, data.result.DT_TablePageInfoT1.TotalCount, body.pageSize, list); + } } \ No newline at end of file diff --git a/Tiobon.Core/Tiobon.Core.Model.xml b/Tiobon.Core/Tiobon.Core.Model.xml index 5b027bea..838dc5fd 100644 --- a/Tiobon.Core/Tiobon.Core.Model.xml +++ b/Tiobon.Core/Tiobon.Core.Model.xml @@ -4019,6 +4019,21 @@ Ghre_Course(Dto.View) + + + 课程分类 + + + + + 创建信息 + + + + + 修改信息 + + 课程分类(Dto.View) diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index d773c557..fbce25c4 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -93,6 +93,13 @@ 主键ID + + + 查询菜单表单信息 + + body + + 新增数据