From b8fb3f7a2d27c28560089dffb420283d535f2f6d Mon Sep 17 00:00:00 2001 From: yubaolee Date: Sat, 19 Dec 2015 21:48:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B5=84=E6=BA=90=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=EF=BC=8C=E4=B8=BA=E6=95=B0=E6=8D=AE=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E3=80=81=E7=AC=AC=E4=B8=89=E6=96=B9=E7=BD=91?= =?UTF-8?q?=E7=AB=99=E6=8E=88=E6=9D=83=E5=81=9A=E5=87=86=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CodeSmith/proj/cshtml.csp | 30 -- CodeSmith/{ => 带其他级联}/Add.cshtml.cst | 288 ++++++++--------- CodeSmith/{ => 带其他级联}/Application.cst | 274 ++++++++-------- CodeSmith/{ => 带其他级联}/Controller.cst | 217 ++++++------- CodeSmith/{ => 带其他级联}/IRepository.cst | 54 ++-- CodeSmith/{ => 带其他级联}/Index.cshtml.cst | 296 +++++++++--------- CodeSmith/本身带级联/Add.cshtml.cst | 145 +++++++++ CodeSmith/本身带级联/Application.cst | 138 ++++++++ CodeSmith/本身带级联/Controller.cst | 110 +++++++ CodeSmith/本身带级联/IRepository.cst | 28 ++ CodeSmith/本身带级联/Index.cshtml.cst | 148 +++++++++ OpenAuth.App/OpenAuth.App.csproj | 1 + OpenAuth.App/ResourceManagerApp.cs | 107 +++++++ .../Interface/IResourceRepository.cs | 17 + OpenAuth.Domain/OpenAuth.Domain.csproj | 1 + .../Controllers/ResourceManagerController.cs | 87 +++++ OpenAuth.Mvc/OpenAuth.Mvc.csproj | 3 + .../Views/CategoryManager/Index.cshtml | 3 - OpenAuth.Mvc/Views/ResourceManager/Add.cshtml | 152 +++++++++ .../Views/ResourceManager/Index.cshtml | 170 ++++++++++ .../OpenAuth.Repository.csproj | 1 + OpenAuth.Repository/ResourceRepository.cs | 41 +++ OpenAuth.Repository/RoleRepository.cs | 42 ++- 建表&初始化数据.sql | Bin 129830 -> 133242 bytes 24 files changed, 1733 insertions(+), 620 deletions(-) delete mode 100644 CodeSmith/proj/cshtml.csp rename CodeSmith/{ => 带其他级联}/Add.cshtml.cst (97%) rename CodeSmith/{ => 带其他级联}/Application.cst (96%) rename CodeSmith/{ => 带其他级联}/Controller.cst (96%) rename CodeSmith/{ => 带其他级联}/IRepository.cst (97%) rename CodeSmith/{ => 带其他级联}/Index.cshtml.cst (97%) create mode 100644 CodeSmith/本身带级联/Add.cshtml.cst create mode 100644 CodeSmith/本身带级联/Application.cst create mode 100644 CodeSmith/本身带级联/Controller.cst create mode 100644 CodeSmith/本身带级联/IRepository.cst create mode 100644 CodeSmith/本身带级联/Index.cshtml.cst create mode 100644 OpenAuth.App/ResourceManagerApp.cs create mode 100644 OpenAuth.Domain/Interface/IResourceRepository.cs create mode 100644 OpenAuth.Mvc/Controllers/ResourceManagerController.cs create mode 100644 OpenAuth.Mvc/Views/ResourceManager/Add.cshtml create mode 100644 OpenAuth.Mvc/Views/ResourceManager/Index.cshtml create mode 100644 OpenAuth.Repository/ResourceRepository.cs diff --git a/CodeSmith/proj/cshtml.csp b/CodeSmith/proj/cshtml.csp deleted file mode 100644 index 50829c3d..00000000 --- a/CodeSmith/proj/cshtml.csp +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - $(ConnectionString1) - SchemaExplorer.SqlSchemaProvider,SchemaExplorer.SqlSchemaProvider - - dbo - Module -
-
- Module -
- - - $(ConnectionString1) - SchemaExplorer.SqlSchemaProvider,SchemaExplorer.SqlSchemaProvider - - dbo - Role -
-
- Role -
-
-
\ No newline at end of file diff --git a/CodeSmith/Add.cshtml.cst b/CodeSmith/带其他级联/Add.cshtml.cst similarity index 97% rename from CodeSmith/Add.cshtml.cst rename to CodeSmith/带其他级联/Add.cshtml.cst index 6c1dab2b..5b4f093e 100644 --- a/CodeSmith/Add.cshtml.cst +++ b/CodeSmith/带其他级联/Add.cshtml.cst @@ -1,145 +1,145 @@ -<%-- -Name: Database Table Properties -Author: Paul Welter -Description: Create a list of properties from a database table ---%> -<%@ CodeTemplate Language="C#" TargetLanguage="C#" Debug="False" Encoding="utf-8" Description="添加模块" %> -<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" -Description="连接的数据库" %> -<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %> -<%@ Property Name="NeedViewModel" Type="Boolean" Category="Context" Default="False" Description="是否需要ViewModel" %> -<%@ Property Name="CascadeId" Type="String" Category="" Default="ParentId" Description="级联字段" %> -<%@ Property Name="CascadeName" Type="String" Category="" Default="ParentName" Description="级联显示的文字" %> -<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %> -<%@ Assembly Name="SchemaExplorer" %> -<%@ Import Namespace="SchemaExplorer" %> - -<%if(NeedViewModel){ %> -@model OpenAuth.App.ViewModel.<%=GetModelName()%> -<%} else{ %> -@model OpenAuth.Domain.<%=GetModelName()%> -<%} %> -@{ - ViewBag.Title = "<%=GetModelName()%>编辑界面"; - Layout = null; -} - -
-
- - - <% foreach (ColumnSchema column in this.SourceTable.Columns) { - if(column.Name == CascadeName) continue; - %> - - - - <% } %> - -
- <%if(column.IsPrimaryKeyMember){ %> - @Html.HiddenFor(m =>m.Id) - <% } else if(column.Name == CascadeId) {%> - - - -
    - - <% } else if(CSharpAlias[column.SystemType.FullName] == "bool") {%> - - - - <%} else if(CSharpAlias[column.SystemType.FullName] == "int") {%> - - - <%} else{%> - - - <%} %> -
    -
    -
    - - - +<%if(NeedViewModel){ %> +@model OpenAuth.App.ViewModel.<%=GetModelName()%> +<%} else{ %> +@model OpenAuth.Domain.<%=GetModelName()%> +<%} %> +@{ + ViewBag.Title = "<%=GetModelName()%>编辑界面"; + Layout = null; +} + +
    +
    + + + <% foreach (ColumnSchema column in this.SourceTable.Columns) { + if(column.Name == CascadeName) continue; + %> + + + + <% } %> + +
    + <%if(column.IsPrimaryKeyMember){ %> + @Html.HiddenFor(m =>m.Id) + <% } else if(column.Name == CascadeId) {%> + + + +
      + + <% } else if(CSharpAlias[column.SystemType.FullName] == "bool") {%> + + + + <%} else if(CSharpAlias[column.SystemType.FullName] == "int") {%> + + + <%} else{%> + + + <%} %> +
      +
      +
      + + + \ No newline at end of file diff --git a/CodeSmith/Application.cst b/CodeSmith/带其他级联/Application.cst similarity index 96% rename from CodeSmith/Application.cst rename to CodeSmith/带其他级联/Application.cst index c2636ff5..d6120175 100644 --- a/CodeSmith/Application.cst +++ b/CodeSmith/带其他级联/Application.cst @@ -1,138 +1,138 @@ -<%-- -Name: Database Table Properties -Author: Paul Welter -Description: Create a list of properties from a database table ---%> -<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="应用层" %> -<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %> -<%@ Property Name="NeedViewModel" Type="Boolean" Category="Context" Default="False" Description="是否需要ViewModel" %> -<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %> -<%@ Assembly Name="SchemaExplorer" %> -<%@ Import Namespace="SchemaExplorer" %> - - -<%if(NeedViewModel){ %> -using OpenAuth.App.ViewModel; -<%} %> -using OpenAuth.Domain; -using OpenAuth.Domain.Interface; -using System; -using System.Collections.Generic; -using System.Linq; - -namespace OpenAuth.App -{ - public class <%=ModuleName%>ManagerApp - { - private I<%=ModuleName%>Repository _repository; - private IOrgRepository _orgRepository; - - public <%=ModuleName%>ManagerApp(I<%=ModuleName%>Repository repository, - IOrgRepository orgRepository) - { - _repository = repository; - _orgRepository = orgRepository; - } - - public int Get<%=GetModelName()%>CntInOrg(int orgId) - { - if (orgId == 0) - { - return _repository.Find(null).Count(); - } - else - { - return _repository.Get<%=GetModelName()%>CntInOrgs(GetSubOrgIds(orgId)); - } - } - - public List<<%=GetModelName()%>> LoadAll() - { - return _repository.Find(null).ToList(); - } - - /// - /// 加载一个节点下面的一个或全部<%=GetModelName()%>s - /// - public dynamic Load(int orgId, int pageindex, int pagesize) - { - IEnumerable<<%=ModuleName%>> <%=ModuleName%>s; - int total = 0; - if (orgId == 0) - { - <%=ModuleName%>s = _repository.Load<%=ModuleName%>s(pageindex, pagesize); - total = _repository.GetCount(); - } - else - { - <%=ModuleName%>s = _repository.LoadInOrgs(pageindex, pagesize,GetSubOrgIds(orgId)); - total = _repository.Get<%=ModuleName%>CntInOrgs(orgId); - } - <%if(NeedViewModel){ %> - var <%=ModuleName%>views = new List<<%=ModuleName%>View>(); - foreach (var <%=ModuleName%> in <%=ModuleName%>s) - { - <%=ModuleName%>View uv = <%=ModuleName%>; - uv.Organizations = string.Join(",", _orgRepository.LoadBy<%=ModuleName%>(<%=ModuleName%>.Id).Select(u => u.Name).ToList()); - <%=ModuleName%>views.Add(uv); - } - <%} %> - - return new - { - total = total, - list = <%=GetModelName()%>s, - pageCurrent = pageindex - }; - } - - /// - /// 获取当前节点的所有下级节点 - /// - private int[] GetSubOrgIds(int orgId) - { - var org = _orgRepository.FindSingle(u => u.Id == orgId); - var orgs = _orgRepository.Find(u => u.CascadeId.Contains(org.CascadeId)).Select(u => u.Id).ToArray(); - return orgs; - } - - public <%=GetModelName()%> Find(int id) - { - var <%=ModuleName.ToLower()%> = _repository.FindSingle(u => u.Id == id); - if (<%=ModuleName.ToLower()%> == null) return new <%=GetModelName()%>(); - - return <%=ModuleName.ToLower() %>; - } - - public void Delete(int id) - { - _repository.Delete(id); - } - - public void AddOrUpdate(<%=GetModelName()%> model) - { - <%=ModuleName%> <%=ModuleName.ToLower()%> = new <%=ModuleName%>(); - model.CopyTo(<%=ModuleName.ToLower()%>); - - if (<%=ModuleName.ToLower()%>.Id == 0) - { - _repository.Add(<%=ModuleName.ToLower()%>); - } - else - { - _repository.Update(<%=ModuleName.ToLower()%>); - } - - } - - - } +<%-- +Name: Database Table Properties +Author: Paul Welter +Description: Create a list of properties from a database table +--%> +<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="应用层" %> +<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %> +<%@ Property Name="NeedViewModel" Type="Boolean" Category="Context" Default="False" Description="是否需要ViewModel" %> +<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %> +<%@ Assembly Name="SchemaExplorer" %> +<%@ Import Namespace="SchemaExplorer" %> + + +<%if(NeedViewModel){ %> +using OpenAuth.App.ViewModel; +<%} %> +using OpenAuth.Domain; +using OpenAuth.Domain.Interface; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace OpenAuth.App +{ + public class <%=ModuleName%>ManagerApp + { + private I<%=ModuleName%>Repository _repository; + private IOrgRepository _orgRepository; + + public <%=ModuleName%>ManagerApp(I<%=ModuleName%>Repository repository, + IOrgRepository orgRepository) + { + _repository = repository; + _orgRepository = orgRepository; + } + + public int Get<%=GetModelName()%>CntInOrg(int orgId) + { + if (orgId == 0) + { + return _repository.Find(null).Count(); + } + else + { + return _repository.Get<%=GetModelName()%>CntInOrgs(GetSubOrgIds(orgId)); + } + } + + public List<<%=GetModelName()%>> LoadAll() + { + return _repository.Find(null).ToList(); + } + + /// + /// 加载一个节点下面的一个或全部<%=GetModelName()%>s + /// + public dynamic Load(int orgId, int pageindex, int pagesize) + { + IEnumerable<<%=ModuleName%>> <%=ModuleName%>s; + int total = 0; + if (orgId == 0) + { + <%=ModuleName%>s = _repository.Load<%=ModuleName%>s(pageindex, pagesize); + total = _repository.GetCount(); + } + else + { + <%=ModuleName%>s = _repository.LoadInOrgs(pageindex, pagesize,GetSubOrgIds(orgId)); + total = _repository.Get<%=ModuleName%>CntInOrgs(orgId); + } + <%if(NeedViewModel){ %> + var <%=ModuleName%>views = new List<<%=ModuleName%>View>(); + foreach (var <%=ModuleName%> in <%=ModuleName%>s) + { + <%=ModuleName%>View uv = <%=ModuleName%>; + uv.Organizations = string.Join(",", _orgRepository.LoadBy<%=ModuleName%>(<%=ModuleName%>.Id).Select(u => u.Name).ToList()); + <%=ModuleName%>views.Add(uv); + } + <%} %> + + return new + { + total = total, + list = <%=GetModelName()%>s, + pageCurrent = pageindex + }; + } + + /// + /// 获取当前节点的所有下级节点 + /// + private int[] GetSubOrgIds(int orgId) + { + var org = _orgRepository.FindSingle(u => u.Id == orgId); + var orgs = _orgRepository.Find(u => u.CascadeId.Contains(org.CascadeId)).Select(u => u.Id).ToArray(); + return orgs; + } + + public <%=GetModelName()%> Find(int id) + { + var <%=ModuleName.ToLower()%> = _repository.FindSingle(u => u.Id == id); + if (<%=ModuleName.ToLower()%> == null) return new <%=GetModelName()%>(); + + return <%=ModuleName.ToLower() %>; + } + + public void Delete(int id) + { + _repository.Delete(id); + } + + public void AddOrUpdate(<%=GetModelName()%> model) + { + <%=ModuleName%> <%=ModuleName.ToLower()%> = new <%=ModuleName%>(); + model.CopyTo(<%=ModuleName.ToLower()%>); + + if (<%=ModuleName.ToLower()%>.Id == 0) + { + _repository.Add(<%=ModuleName.ToLower()%>); + } + else + { + _repository.Update(<%=ModuleName.ToLower()%>); + } + + } + + + } } \ No newline at end of file diff --git a/CodeSmith/Controller.cst b/CodeSmith/带其他级联/Controller.cst similarity index 96% rename from CodeSmith/Controller.cst rename to CodeSmith/带其他级联/Controller.cst index 6fe89062..6e45e6a8 100644 --- a/CodeSmith/Controller.cst +++ b/CodeSmith/带其他级联/Controller.cst @@ -1,109 +1,110 @@ -<%-- -Name: Database Table Properties -Author: Paul Welter -Description: Create a list of properties from a database table ---%> -<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="控制器" %> -<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %> -<%@ Property Name="NeedViewModel" Type="Boolean" Category="Context" Default="False" Description="是否需要ViewModel" %> -<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %> -<%@ Assembly Name="SchemaExplorer" %> -<%@ Import Namespace="SchemaExplorer" %> - - -using System; -using System.Web.Mvc; -using Infrastructure; -using OpenAuth.App; -<%if(NeedViewModel){ %> -using OpenAuth.App.ViewModel; -<%} %> - -namespace OpenAuth.Mvc.Controllers -{ - public class <%=ModuleName%>ManagerController : BaseController - { - private <%=ModuleName%>ManagerApp _app; - - public <%=ModuleName%>ManagerController() - { - _app = AutofacExt.GetFromFac<<%=ModuleName%>ManagerApp>(); - } - - // - // GET: /UserManager/ - public ActionResult Index() - { - return View(); - } - - public ActionResult Add(int id = 0) - { - return View(_app.Find(id)); - } - - //添加或修改<%=ModuleName %> - [HttpPost] - public string Add(<%=GetModelName()%> model) - { - try - { - _app.AddOrUpdate(model); - - } - catch (Exception ex) - { - BjuiResponse.statusCode = "300"; - BjuiResponse.message = ex.Message; - } - return JsonHelper.Instance.Serialize(BjuiResponse); - } - - /// - /// 加载节点下面的所有<%=ModuleName %>s - /// - public string Load(int parentidId, int pageCurrent = 1, int pageSize = 30) - { - return JsonHelper.Instance.Serialize(_app.Load(parentidId, pageCurrent, pageSize)); - } - - public string LoadForTree() - { - var models = _app.LoadAll(); - //添加根节点 - models.Add(new <%=ModuleName %> - { - Id = 0, - ParentId = -1, - Name = "根结点", - CascadeId = "0" - }); - return JsonHelper.Instance.Serialize(models); - } - - public string Delete(int Id) - { - try - { - _app.Delete(Id); - } - catch (Exception e) - { - BjuiResponse.statusCode = "300"; - BjuiResponse.message = e.Message; - } - - return JsonHelper.Instance.Serialize(BjuiResponse); - } - - - } +<%-- +Name: Database Table Properties +Author: Paul Welter +Description: Create a list of properties from a database table +--%> +<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="控制器" %> +<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %> +<%@ Property Name="NeedViewModel" Type="Boolean" Category="Context" Default="False" Description="是否需要ViewModel" %> +<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %> +<%@ Assembly Name="SchemaExplorer" %> +<%@ Import Namespace="SchemaExplorer" %> + + +using System; +using System.Web.Mvc; +using Infrastructure; +using OpenAuth.App; +<%if(NeedViewModel){ %> +using OpenAuth.App.ViewModel; +<%} %> +using OpenAuth.Domain; + +namespace OpenAuth.Mvc.Controllers +{ + public class <%=ModuleName%>ManagerController : BaseController + { + private <%=ModuleName%>ManagerApp _app; + + public <%=ModuleName%>ManagerController() + { + _app = AutofacExt.GetFromFac<<%=ModuleName%>ManagerApp>(); + } + + // + // GET: /UserManager/ + public ActionResult Index() + { + return View(); + } + + public ActionResult Add(int id = 0) + { + return View(_app.Find(id)); + } + + //添加或修改<%=ModuleName %> + [HttpPost] + public string Add(<%=GetModelName()%> model) + { + try + { + _app.AddOrUpdate(model); + + } + catch (Exception ex) + { + BjuiResponse.statusCode = "300"; + BjuiResponse.message = ex.Message; + } + return JsonHelper.Instance.Serialize(BjuiResponse); + } + + /// + /// 加载节点下面的所有<%=ModuleName %>s + /// + public string Load(int parentidId, int pageCurrent = 1, int pageSize = 30) + { + return JsonHelper.Instance.Serialize(_app.Load(parentidId, pageCurrent, pageSize)); + } + + public string LoadForTree() + { + var models = _app.LoadAll(); + //添加根节点 + models.Add(new <%=ModuleName %> + { + Id = 0, + ParentId = -1, + Name = "根结点", + CascadeId = "0" + }); + return JsonHelper.Instance.Serialize(models); + } + + public string Delete(int Id) + { + try + { + _app.Delete(Id); + } + catch (Exception e) + { + BjuiResponse.statusCode = "300"; + BjuiResponse.message = e.Message; + } + + return JsonHelper.Instance.Serialize(BjuiResponse); + } + + + } } \ No newline at end of file diff --git a/CodeSmith/IRepository.cst b/CodeSmith/带其他级联/IRepository.cst similarity index 97% rename from CodeSmith/IRepository.cst rename to CodeSmith/带其他级联/IRepository.cst index 4be8b648..4e1ec96c 100644 --- a/CodeSmith/IRepository.cst +++ b/CodeSmith/带其他级联/IRepository.cst @@ -1,28 +1,28 @@ -<%-- -Name: Database Table Properties -Author: Paul Welter -Description: Create a list of properties from a database table ---%> -<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="创建包含组织机构的接口" %> -<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %> -<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %> -<%@ Assembly Name="SchemaExplorer" %> -<%@ Import Namespace="SchemaExplorer" %> - -using System.Collections.Generic; -using System.Linq; - -namespace OpenAuth.Domain.Interface -{ - public interface I<%=ModuleName%>Repository :IRepository<<%=ModuleName%>> - { - IEnumerable<<%=ModuleName%>> Load<%=ModuleName%>s(int pageindex, int pagesize); - - IEnumerable<<%=ModuleName%>> LoadInOrgs(params int[] orgId); - int Get<%=ModuleName%>CntInOrgs(params int[] orgIds); - IEnumerable<<%=ModuleName%>> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds); - - void Delete(int id); - - } +<%-- +Name: Database Table Properties +Author: Paul Welter +Description: Create a list of properties from a database table +--%> +<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="创建包含组织机构的接口" %> +<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %> +<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %> +<%@ Assembly Name="SchemaExplorer" %> +<%@ Import Namespace="SchemaExplorer" %> + +using System.Collections.Generic; +using System.Linq; + +namespace OpenAuth.Domain.Interface +{ + public interface I<%=ModuleName%>Repository :IRepository<<%=ModuleName%>> + { + IEnumerable<<%=ModuleName%>> Load<%=ModuleName%>s(int pageindex, int pagesize); + + IEnumerable<<%=ModuleName%>> LoadInOrgs(params int[] orgId); + int Get<%=ModuleName%>CntInOrgs(params int[] orgIds); + IEnumerable<<%=ModuleName%>> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds); + + void Delete(int id); + + } } \ No newline at end of file diff --git a/CodeSmith/Index.cshtml.cst b/CodeSmith/带其他级联/Index.cshtml.cst similarity index 97% rename from CodeSmith/Index.cshtml.cst rename to CodeSmith/带其他级联/Index.cshtml.cst index f3d1d099..a674c30a 100644 --- a/CodeSmith/Index.cshtml.cst +++ b/CodeSmith/带其他级联/Index.cshtml.cst @@ -1,148 +1,148 @@ -<%-- -Name: Database Table Properties -Author: Paul Welter -Description: Create a list of properties from a database table ---%> -<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="True" Description="Create a list of properties from database table." %> -<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="Table that the object is based on." %> -<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %> -<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %> -<%@ Assembly Name="SchemaExplorer" %> -<%@ Import Namespace="SchemaExplorer" %> - -@{ - string _prefix = "<%=ModuleName%>"; - var _treeId = _prefix + "Tree"; - var _gridId = _prefix + "Grid"; - var _treeDetail = _prefix + "Detail"; -} - -@{ Html.RenderAction("MenuHeader", "Home");} -
      -
      -
      -
        -
        - -
        -
        -
        -
        - - - +<%-- +Name: Database Table Properties +Author: Paul Welter +Description: Create a list of properties from a database table +--%> +<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="True" Description="Create a list of properties from database table." %> +<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="Table that the object is based on." %> +<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %> +<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %> +<%@ Assembly Name="SchemaExplorer" %> +<%@ Import Namespace="SchemaExplorer" %> + +@{ + string _prefix = "<%=ModuleName%>"; + var _treeId = _prefix + "Tree"; + var _gridId = _prefix + "Grid"; + var _treeDetail = _prefix + "Detail"; +} + +@{ Html.RenderAction("MenuHeader", "Home");} +
        +
        +
        +
          +
          + +
          +
          +
          +
          + + + diff --git a/CodeSmith/本身带级联/Add.cshtml.cst b/CodeSmith/本身带级联/Add.cshtml.cst new file mode 100644 index 00000000..5b4f093e --- /dev/null +++ b/CodeSmith/本身带级联/Add.cshtml.cst @@ -0,0 +1,145 @@ +<%-- +Name: Database Table Properties +Author: Paul Welter +Description: Create a list of properties from a database table +--%> +<%@ CodeTemplate Language="C#" TargetLanguage="C#" Debug="False" Encoding="utf-8" Description="添加模块" %> +<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" +Description="连接的数据库" %> +<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %> +<%@ Property Name="NeedViewModel" Type="Boolean" Category="Context" Default="False" Description="是否需要ViewModel" %> +<%@ Property Name="CascadeId" Type="String" Category="" Default="ParentId" Description="级联字段" %> +<%@ Property Name="CascadeName" Type="String" Category="" Default="ParentName" Description="级联显示的文字" %> +<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %> +<%@ Assembly Name="SchemaExplorer" %> +<%@ Import Namespace="SchemaExplorer" %> + +<%if(NeedViewModel){ %> +@model OpenAuth.App.ViewModel.<%=GetModelName()%> +<%} else{ %> +@model OpenAuth.Domain.<%=GetModelName()%> +<%} %> +@{ + ViewBag.Title = "<%=GetModelName()%>编辑界面"; + Layout = null; +} + +
          +
          + + + <% foreach (ColumnSchema column in this.SourceTable.Columns) { + if(column.Name == CascadeName) continue; + %> + + + + <% } %> + +
          + <%if(column.IsPrimaryKeyMember){ %> + @Html.HiddenFor(m =>m.Id) + <% } else if(column.Name == CascadeId) {%> + + + +
            + + <% } else if(CSharpAlias[column.SystemType.FullName] == "bool") {%> + + + + <%} else if(CSharpAlias[column.SystemType.FullName] == "int") {%> + + + <%} else{%> + + + <%} %> +
            +
            +
            + + + \ No newline at end of file diff --git a/CodeSmith/本身带级联/Application.cst b/CodeSmith/本身带级联/Application.cst new file mode 100644 index 00000000..d6120175 --- /dev/null +++ b/CodeSmith/本身带级联/Application.cst @@ -0,0 +1,138 @@ +<%-- +Name: Database Table Properties +Author: Paul Welter +Description: Create a list of properties from a database table +--%> +<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="应用层" %> +<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %> +<%@ Property Name="NeedViewModel" Type="Boolean" Category="Context" Default="False" Description="是否需要ViewModel" %> +<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %> +<%@ Assembly Name="SchemaExplorer" %> +<%@ Import Namespace="SchemaExplorer" %> + + +<%if(NeedViewModel){ %> +using OpenAuth.App.ViewModel; +<%} %> +using OpenAuth.Domain; +using OpenAuth.Domain.Interface; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace OpenAuth.App +{ + public class <%=ModuleName%>ManagerApp + { + private I<%=ModuleName%>Repository _repository; + private IOrgRepository _orgRepository; + + public <%=ModuleName%>ManagerApp(I<%=ModuleName%>Repository repository, + IOrgRepository orgRepository) + { + _repository = repository; + _orgRepository = orgRepository; + } + + public int Get<%=GetModelName()%>CntInOrg(int orgId) + { + if (orgId == 0) + { + return _repository.Find(null).Count(); + } + else + { + return _repository.Get<%=GetModelName()%>CntInOrgs(GetSubOrgIds(orgId)); + } + } + + public List<<%=GetModelName()%>> LoadAll() + { + return _repository.Find(null).ToList(); + } + + /// + /// 加载一个节点下面的一个或全部<%=GetModelName()%>s + /// + public dynamic Load(int orgId, int pageindex, int pagesize) + { + IEnumerable<<%=ModuleName%>> <%=ModuleName%>s; + int total = 0; + if (orgId == 0) + { + <%=ModuleName%>s = _repository.Load<%=ModuleName%>s(pageindex, pagesize); + total = _repository.GetCount(); + } + else + { + <%=ModuleName%>s = _repository.LoadInOrgs(pageindex, pagesize,GetSubOrgIds(orgId)); + total = _repository.Get<%=ModuleName%>CntInOrgs(orgId); + } + <%if(NeedViewModel){ %> + var <%=ModuleName%>views = new List<<%=ModuleName%>View>(); + foreach (var <%=ModuleName%> in <%=ModuleName%>s) + { + <%=ModuleName%>View uv = <%=ModuleName%>; + uv.Organizations = string.Join(",", _orgRepository.LoadBy<%=ModuleName%>(<%=ModuleName%>.Id).Select(u => u.Name).ToList()); + <%=ModuleName%>views.Add(uv); + } + <%} %> + + return new + { + total = total, + list = <%=GetModelName()%>s, + pageCurrent = pageindex + }; + } + + /// + /// 获取当前节点的所有下级节点 + /// + private int[] GetSubOrgIds(int orgId) + { + var org = _orgRepository.FindSingle(u => u.Id == orgId); + var orgs = _orgRepository.Find(u => u.CascadeId.Contains(org.CascadeId)).Select(u => u.Id).ToArray(); + return orgs; + } + + public <%=GetModelName()%> Find(int id) + { + var <%=ModuleName.ToLower()%> = _repository.FindSingle(u => u.Id == id); + if (<%=ModuleName.ToLower()%> == null) return new <%=GetModelName()%>(); + + return <%=ModuleName.ToLower() %>; + } + + public void Delete(int id) + { + _repository.Delete(id); + } + + public void AddOrUpdate(<%=GetModelName()%> model) + { + <%=ModuleName%> <%=ModuleName.ToLower()%> = new <%=ModuleName%>(); + model.CopyTo(<%=ModuleName.ToLower()%>); + + if (<%=ModuleName.ToLower()%>.Id == 0) + { + _repository.Add(<%=ModuleName.ToLower()%>); + } + else + { + _repository.Update(<%=ModuleName.ToLower()%>); + } + + } + + + } +} \ No newline at end of file diff --git a/CodeSmith/本身带级联/Controller.cst b/CodeSmith/本身带级联/Controller.cst new file mode 100644 index 00000000..6e45e6a8 --- /dev/null +++ b/CodeSmith/本身带级联/Controller.cst @@ -0,0 +1,110 @@ +<%-- +Name: Database Table Properties +Author: Paul Welter +Description: Create a list of properties from a database table +--%> +<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="控制器" %> +<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %> +<%@ Property Name="NeedViewModel" Type="Boolean" Category="Context" Default="False" Description="是否需要ViewModel" %> +<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %> +<%@ Assembly Name="SchemaExplorer" %> +<%@ Import Namespace="SchemaExplorer" %> + + +using System; +using System.Web.Mvc; +using Infrastructure; +using OpenAuth.App; +<%if(NeedViewModel){ %> +using OpenAuth.App.ViewModel; +<%} %> +using OpenAuth.Domain; + +namespace OpenAuth.Mvc.Controllers +{ + public class <%=ModuleName%>ManagerController : BaseController + { + private <%=ModuleName%>ManagerApp _app; + + public <%=ModuleName%>ManagerController() + { + _app = AutofacExt.GetFromFac<<%=ModuleName%>ManagerApp>(); + } + + // + // GET: /UserManager/ + public ActionResult Index() + { + return View(); + } + + public ActionResult Add(int id = 0) + { + return View(_app.Find(id)); + } + + //添加或修改<%=ModuleName %> + [HttpPost] + public string Add(<%=GetModelName()%> model) + { + try + { + _app.AddOrUpdate(model); + + } + catch (Exception ex) + { + BjuiResponse.statusCode = "300"; + BjuiResponse.message = ex.Message; + } + return JsonHelper.Instance.Serialize(BjuiResponse); + } + + /// + /// 加载节点下面的所有<%=ModuleName %>s + /// + public string Load(int parentidId, int pageCurrent = 1, int pageSize = 30) + { + return JsonHelper.Instance.Serialize(_app.Load(parentidId, pageCurrent, pageSize)); + } + + public string LoadForTree() + { + var models = _app.LoadAll(); + //添加根节点 + models.Add(new <%=ModuleName %> + { + Id = 0, + ParentId = -1, + Name = "根结点", + CascadeId = "0" + }); + return JsonHelper.Instance.Serialize(models); + } + + public string Delete(int Id) + { + try + { + _app.Delete(Id); + } + catch (Exception e) + { + BjuiResponse.statusCode = "300"; + BjuiResponse.message = e.Message; + } + + return JsonHelper.Instance.Serialize(BjuiResponse); + } + + + } +} \ No newline at end of file diff --git a/CodeSmith/本身带级联/IRepository.cst b/CodeSmith/本身带级联/IRepository.cst new file mode 100644 index 00000000..4e1ec96c --- /dev/null +++ b/CodeSmith/本身带级联/IRepository.cst @@ -0,0 +1,28 @@ +<%-- +Name: Database Table Properties +Author: Paul Welter +Description: Create a list of properties from a database table +--%> +<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="创建包含组织机构的接口" %> +<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %> +<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %> +<%@ Assembly Name="SchemaExplorer" %> +<%@ Import Namespace="SchemaExplorer" %> + +using System.Collections.Generic; +using System.Linq; + +namespace OpenAuth.Domain.Interface +{ + public interface I<%=ModuleName%>Repository :IRepository<<%=ModuleName%>> + { + IEnumerable<<%=ModuleName%>> Load<%=ModuleName%>s(int pageindex, int pagesize); + + IEnumerable<<%=ModuleName%>> LoadInOrgs(params int[] orgId); + int Get<%=ModuleName%>CntInOrgs(params int[] orgIds); + IEnumerable<<%=ModuleName%>> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds); + + void Delete(int id); + + } +} \ No newline at end of file diff --git a/CodeSmith/本身带级联/Index.cshtml.cst b/CodeSmith/本身带级联/Index.cshtml.cst new file mode 100644 index 00000000..a674c30a --- /dev/null +++ b/CodeSmith/本身带级联/Index.cshtml.cst @@ -0,0 +1,148 @@ +<%-- +Name: Database Table Properties +Author: Paul Welter +Description: Create a list of properties from a database table +--%> +<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="True" Description="Create a list of properties from database table." %> +<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="Table that the object is based on." %> +<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %> +<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %> +<%@ Assembly Name="SchemaExplorer" %> +<%@ Import Namespace="SchemaExplorer" %> + +@{ + string _prefix = "<%=ModuleName%>"; + var _treeId = _prefix + "Tree"; + var _gridId = _prefix + "Grid"; + var _treeDetail = _prefix + "Detail"; +} + +@{ Html.RenderAction("MenuHeader", "Home");} +
            +
            +
            +
              +
              + +
              +
              +
              +
              + + + diff --git a/OpenAuth.App/OpenAuth.App.csproj b/OpenAuth.App/OpenAuth.App.csproj index 5ec499cd..85d85cc9 100644 --- a/OpenAuth.App/OpenAuth.App.csproj +++ b/OpenAuth.App/OpenAuth.App.csproj @@ -47,6 +47,7 @@ + diff --git a/OpenAuth.App/ResourceManagerApp.cs b/OpenAuth.App/ResourceManagerApp.cs new file mode 100644 index 00000000..70c5b934 --- /dev/null +++ b/OpenAuth.App/ResourceManagerApp.cs @@ -0,0 +1,107 @@ + +using OpenAuth.Domain; +using OpenAuth.Domain.Interface; +using System; +using System.Collections.Generic; +using System.Linq; +using Infrastructure; + +namespace OpenAuth.App +{ + public class ResourceManagerApp + { + private IResourceRepository _repository; + private readonly ICategoryRepository _categoryRepository; + + public ResourceManagerApp(IResourceRepository repository, + ICategoryRepository categoryRepository) + { + _repository = repository; + _categoryRepository = categoryRepository; + } + + public int GetResourceCntInOrg(int orgId) + { + if (orgId == 0) + { + return _repository.Find(null).Count(); + } + else + { + return _repository.GetResourceCntInOrgs(GetSubOrgIds(orgId)); + } + } + + public List LoadAll() + { + return _repository.Find(null).ToList(); + } + + /// + /// 加载一个节点下面的一个或全部Resources + /// + public dynamic Load(int categoryId, int pageindex, int pagesize) + { + IEnumerable Resources; + int total = 0; + if (categoryId == 0) + { + Resources = _repository.LoadResources(pageindex, pagesize); + total = _repository.GetCount(); + } + else + { + Resources = _repository.LoadInOrgs(pageindex, pagesize,GetSubOrgIds(categoryId)); + total = _repository.GetResourceCntInOrgs(categoryId); + } + + return new + { + total = total, + list = Resources, + pageCurrent = pageindex + }; + } + + /// + /// 获取当前节点的所有下级节点 + /// + private int[] GetSubOrgIds(int orgId) + { + var org = _categoryRepository.FindSingle(u => u.Id == orgId); + var orgs = _categoryRepository.Find(u => u.CascadeId.Contains(org.CascadeId)).Select(u => u.Id).ToArray(); + return orgs; + } + + public Resource Find(int id) + { + var resource = _repository.FindSingle(u => u.Id == id); + if (resource == null) return new Resource(); + + return resource; + } + + public void Delete(int id) + { + _repository.Delete(id); + } + + public void AddOrUpdate(Resource model) + { + Resource resource = new Resource(); + model.CopyTo(resource); + + if (resource.Id == 0) + { + _repository.Add(resource); + } + else + { + _repository.Update(resource); + } + + } + + + } +} \ No newline at end of file diff --git a/OpenAuth.Domain/Interface/IResourceRepository.cs b/OpenAuth.Domain/Interface/IResourceRepository.cs new file mode 100644 index 00000000..540daf00 --- /dev/null +++ b/OpenAuth.Domain/Interface/IResourceRepository.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using System.Linq; + +namespace OpenAuth.Domain.Interface +{ + public interface IResourceRepository :IRepository + { + IEnumerable LoadResources(int pageindex, int pagesize); + + IEnumerable LoadInOrgs(params int[] orgId); + int GetResourceCntInOrgs(params int[] orgIds); + IEnumerable LoadInOrgs(int pageindex, int pagesize, params int[] orgIds); + + void Delete(int id); + + } +} \ No newline at end of file diff --git a/OpenAuth.Domain/OpenAuth.Domain.csproj b/OpenAuth.Domain/OpenAuth.Domain.csproj index 510ab64f..cd91bf56 100644 --- a/OpenAuth.Domain/OpenAuth.Domain.csproj +++ b/OpenAuth.Domain/OpenAuth.Domain.csproj @@ -50,6 +50,7 @@ + diff --git a/OpenAuth.Mvc/Controllers/ResourceManagerController.cs b/OpenAuth.Mvc/Controllers/ResourceManagerController.cs new file mode 100644 index 00000000..b521f6a2 --- /dev/null +++ b/OpenAuth.Mvc/Controllers/ResourceManagerController.cs @@ -0,0 +1,87 @@ + +using System; +using System.Web.Mvc; +using Infrastructure; +using OpenAuth.App; +using OpenAuth.Domain; + +namespace OpenAuth.Mvc.Controllers +{ + public class ResourceManagerController : BaseController + { + private ResourceManagerApp _app; + + public ResourceManagerController() + { + _app = AutofacExt.GetFromFac(); + } + + // + // GET: /UserManager/ + public ActionResult Index() + { + return View(); + } + + public ActionResult Add(int id = 0) + { + return View(_app.Find(id)); + } + + //添加或修改Resource + [HttpPost] + public string Add(Resource model) + { + try + { + _app.AddOrUpdate(model); + + } + catch (Exception ex) + { + BjuiResponse.statusCode = "300"; + BjuiResponse.message = ex.Message; + } + return JsonHelper.Instance.Serialize(BjuiResponse); + } + + /// + /// 加载某分类的所有Resources + /// + public string Load(int categoryId, int pageCurrent = 1, int pageSize = 30) + { + return JsonHelper.Instance.Serialize(_app.Load(categoryId, pageCurrent, pageSize)); + } + + public string LoadForTree() + { + var models = _app.LoadAll(); + //添加根节点 + models.Add(new Resource + { + Id = 0, + ParentId = -1, + Name = "根结点", + CascadeId = "0" + }); + return JsonHelper.Instance.Serialize(models); + } + + public string Delete(int Id) + { + try + { + _app.Delete(Id); + } + catch (Exception e) + { + BjuiResponse.statusCode = "300"; + BjuiResponse.message = e.Message; + } + + return JsonHelper.Instance.Serialize(BjuiResponse); + } + + + } +} \ No newline at end of file diff --git a/OpenAuth.Mvc/OpenAuth.Mvc.csproj b/OpenAuth.Mvc/OpenAuth.Mvc.csproj index 6a66c47f..3f75f336 100644 --- a/OpenAuth.Mvc/OpenAuth.Mvc.csproj +++ b/OpenAuth.Mvc/OpenAuth.Mvc.csproj @@ -133,6 +133,7 @@ + @@ -571,6 +572,8 @@ + + diff --git a/OpenAuth.Mvc/Views/CategoryManager/Index.cshtml b/OpenAuth.Mvc/Views/CategoryManager/Index.cshtml index 9905e9da..7dfbb569 100644 --- a/OpenAuth.Mvc/Views/CategoryManager/Index.cshtml +++ b/OpenAuth.Mvc/Views/CategoryManager/Index.cshtml @@ -54,9 +54,6 @@ name: 'ParentId', label: '父节点流水号', width: 100 - ,type: 'select', - align: 'center', - items: [{ '0': '默认' }, { '1': '状态1' }], }, { name: 'Status', diff --git a/OpenAuth.Mvc/Views/ResourceManager/Add.cshtml b/OpenAuth.Mvc/Views/ResourceManager/Add.cshtml new file mode 100644 index 00000000..18cd0a91 --- /dev/null +++ b/OpenAuth.Mvc/Views/ResourceManager/Add.cshtml @@ -0,0 +1,152 @@ +@model OpenAuth.Domain.Resource +@{ + ViewBag.Title = "Resource编辑界面"; + Layout = null; +} + +
              +
              + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
              + @Html.HiddenFor(m =>m.Id) +
              + + +
              + + +
              + + +
              + + + +
                + +
                + + +
                + + +
                + + +
                + + +
                +
                +
                + + + \ No newline at end of file diff --git a/OpenAuth.Mvc/Views/ResourceManager/Index.cshtml b/OpenAuth.Mvc/Views/ResourceManager/Index.cshtml new file mode 100644 index 00000000..ee4098d1 --- /dev/null +++ b/OpenAuth.Mvc/Views/ResourceManager/Index.cshtml @@ -0,0 +1,170 @@ +@{ + string _prefix = "Resource"; + var _treeId = _prefix + "Tree"; + var _gridId = _prefix + "Grid"; + var _treeDetail = _prefix + "Detail"; +} + +@{ Html.RenderAction("MenuHeader", "Home");} +
                +
                +
                +
                  +
                  + +
                  +
                  +
                  +
                  + + + diff --git a/OpenAuth.Repository/OpenAuth.Repository.csproj b/OpenAuth.Repository/OpenAuth.Repository.csproj index d9f1f7c2..d82d7ce5 100644 --- a/OpenAuth.Repository/OpenAuth.Repository.csproj +++ b/OpenAuth.Repository/OpenAuth.Repository.csproj @@ -71,6 +71,7 @@ + diff --git a/OpenAuth.Repository/ResourceRepository.cs b/OpenAuth.Repository/ResourceRepository.cs new file mode 100644 index 00000000..d57977cd --- /dev/null +++ b/OpenAuth.Repository/ResourceRepository.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using OpenAuth.Domain; +using OpenAuth.Domain.Interface; + +namespace OpenAuth.Repository +{ + public class RoleRepository :BaseRepository, IRoleRepository + { + public IEnumerable LoadRoles(int pageindex, int pagesize) + { + return Context.Roles.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize); + } + + public int GetRoleCntInOrgs(params int[] orgIds) + { + return LoadInOrgs(orgIds).Count(); + } + + public IEnumerable LoadInOrgs(int pageindex, int pagesize, params int[] orgIds) + { + return LoadInOrgs(orgIds).OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize); + } + + public void Delete(int id) + { + Delete(u =>u.Id == id); + } + + public IEnumerable LoadInOrgs(params int[] orgId) + { + var result = from role in Context.Roles.Where(u => orgId.Contains(u.OrgId)) select role; + + return result; + + } + } +} diff --git a/OpenAuth.Repository/RoleRepository.cs b/OpenAuth.Repository/RoleRepository.cs index b72cc005..f414ddeb 100644 --- a/OpenAuth.Repository/RoleRepository.cs +++ b/OpenAuth.Repository/RoleRepository.cs @@ -1,41 +1,37 @@ -using System; +using OpenAuth.Domain; +using OpenAuth.Domain.Interface; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using OpenAuth.Domain; -using OpenAuth.Domain.Interface; namespace OpenAuth.Repository { - public class RoleRepository :BaseRepository, IRoleRepository + public class ResourceRepository : BaseRepository, IResourceRepository { - public IEnumerable LoadRoles(int pageindex, int pagesize) - { - return Context.Roles.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize); - } - - public int GetRoleCntInOrgs(params int[] orgIds) - { - return LoadInOrgs(orgIds).Count(); - } - - public IEnumerable LoadInOrgs(int pageindex, int pagesize, params int[] orgIds) + public IEnumerable LoadInOrgs(int pageindex, int pagesize, params int[] orgIds) { return LoadInOrgs(orgIds).OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize); } public void Delete(int id) { - Delete(u =>u.Id == id); + Delete(u => u.Id == id); } - public IEnumerable LoadInOrgs(params int[] orgId) + public IEnumerable LoadInOrgs(params int[] orgId) { - var result = from role in Context.Roles.Where(u => orgId.Contains(u.OrgId)) select role; - - return result; + var result = from resource in Context.Resources.Where(u => orgId.Contains(u.CategoryId)) select resource; + return result; + } + + public IEnumerable LoadResources(int pageindex, int pagesize) + { + return Context.Resources.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize); + } + + public int GetResourceCntInOrgs(params int[] orgIds) + { + return LoadInOrgs(orgIds).Count(); } } -} +} \ No newline at end of file diff --git a/建表&初始化数据.sql b/建表&初始化数据.sql index 8dc0777c420443fef71677aa344d829d8d9caa41..db61168f3c45db94126df94618a636a7e3246c0d 100644 GIT binary patch delta 8363 zcmb7J3s98T75;p#ZbhmKP8Z56&{YHHF<%ivm4YEvkq}4So!>Sz=$+nF&kWZ%2 zxSqePH`m(Ozn*Nv(y`??jY4C#@jX1x8s9a_Ezj)-22D5S8OyEK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