From e39c42f67b99cd8bffb1441c19a174f7c6f3820b Mon Sep 17 00:00:00 2001 From: ndbs Date: Tue, 28 Dec 2021 16:13:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=93=E4=B8=9A=E5=BC=80=E8=AF=BE=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E5=B7=A6=E4=BE=A7=E6=A0=91=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/CdDeptController.cs | 13 ++++ .../CdDept/CdDeptBLL.cs | 72 +++++++++++++++++++ .../CdDept/CdDeptIBLL.cs | 15 ++++ .../CdDept/CdDeptService.cs | 29 ++++++++ 4 files changed, 129 insertions(+) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/CdDeptController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/CdDeptController.cs index 66f6f7c25..8841da681 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/CdDeptController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/CdDeptController.cs @@ -94,6 +94,19 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers return Success(data); } + /// + /// 获取树形数据 + /// + /// 父级id + /// + [HttpGet] + [AjaxOnly] + public ActionResult GetTree(string parentId) + { + var data = cdDeptIBLL.GetTree(parentId); + return JsonResult(data); + } + #endregion #region 提交数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/CdDept/CdDeptBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/CdDept/CdDeptBLL.cs index c31f74746..cfd7413b7 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/CdDept/CdDeptBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/CdDept/CdDeptBLL.cs @@ -2,6 +2,8 @@ using System; using System.Data; using System.Collections.Generic; +using Learun.Cache.Base; +using Learun.Cache.Factory; namespace Learun.Application.TwoDevelopment.EducationalAdministration { @@ -15,6 +17,11 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration public class CdDeptBLL : CdDeptIBLL { private CdDeptService cdDeptService = new CdDeptService(); + #region 缓存定义 + private ICache cache = CacheFactory.CaChe(); + private string cacheKey = "Learun_adms_cddept"; + + #endregion #region 获取数据 @@ -201,5 +208,70 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration #endregion + #region 扩展数据 + /// + /// 获取列表数据 + /// + /// + public List GetList() + { + try + { + List list = cache.Read>(cacheKey); + if (list == null) + { + list = (List)cdDeptService.GetList(); + cache.Write>(cacheKey, list, CacheId.company); + } + return list; + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } + + public List GetTree(string parentId) + { + try + { + List list = GetList(); + List treeList = new List(); + foreach (var item in list) + { + TreeModel node = new TreeModel + { + id = item.DeptNo, + text = item.DeptName, + value = item.DeptNo, + showcheck = false, + checkstate = 0, + isexpand = true, + parentId = item.DeptId + }; + treeList.Add(node); + } + return treeList.ToTree(); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } + #endregion } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/CdDept/CdDeptIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/CdDept/CdDeptIBLL.cs index 979da4bec..9b0ea2300 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/CdDept/CdDeptIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/CdDept/CdDeptIBLL.cs @@ -55,5 +55,20 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration IEnumerable GetListBySchoolId(string schoolId); IEnumerable GetAllList(); + + #region 扩展数据 + /// + /// 获取树形数据 + /// + /// 父级id + /// + List GetTree(string parentId); + + /// + /// 获取列表数据 + /// + /// + List GetList(); + #endregion } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/CdDept/CdDeptService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/CdDept/CdDeptService.cs index 507cdd93a..b3a7fb925 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/CdDept/CdDeptService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/CdDept/CdDeptService.cs @@ -250,5 +250,34 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } } + + #region 扩展数据 + /// + /// 获取公司列表信息(全部) + /// + /// + public IEnumerable GetList() + { + try + { + var strSql = new StringBuilder(); + strSql.Append("SELECT "); + strSql.Append(" * "); + strSql.Append(" FROM CdDept t WHERE 1=1 order by t.deptSort "); + return this.BaseRepository("CollegeMIS").FindList(strSql.ToString()); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } + #endregion } }