diff --git a/CodeSmith/CSharp/Web/Index.cshtml.cst b/CodeSmith/CSharp/Web/Index.cshtml.cst
index e9740de3..4ff073c3 100644
--- a/CodeSmith/CSharp/Web/Index.cshtml.cst
+++ b/CodeSmith/CSharp/Web/Index.cshtml.cst
@@ -18,31 +18,38 @@ Description="连接的数据库" %>
{
}
-
- @Html.Action("MenuHeader", "Home")
+
-
-
-
-
-
- |
- <% foreach (ColumnSchema column in this.SourceTable.Columns) {%>
- <%=Tools.GetDescription(column)%> |
- <% }%>
- |
-
-
-
-
+
+
+
+
+
+
+ |
+ <% foreach (ColumnSchema column in this.SourceTable.Columns) {%>
+ <%=Tools.GetDescription(column)%> |
+ <% }%>
+ |
+
+
+
+
+
+
-
+
+
-
+
diff --git a/CodeSmith/CSharp/Web/index.js.cst b/CodeSmith/CSharp/Web/index.js.cst
index 391bf002..89f5942b 100644
--- a/CodeSmith/CSharp/Web/index.js.cst
+++ b/CodeSmith/CSharp/Web/index.js.cst
@@ -13,14 +13,16 @@ Author: yubaolee
layui.config({
base: "/js/"
-}).use(['form','vue', 'ztree', 'layer', 'jquery', 'table','droptree','openauth'], function () {
+}).use(['form','vue', 'ztree', 'layer', 'jquery', 'table','droptree','openauth', 'utils'], function () {
var form = layui.form,
- //layer = (parent == undefined || parent.layer === undefined )? layui.layer : parent.layer,
layer = layui.layer,
$ = layui.jquery;
var table = layui.table;
var openauth = layui.openauth;
+ var toplayer = (top == undefined || top.layer === undefined) ? layer : top.layer; //顶层的LAYER
layui.droptree("/UserSession/GetOrgs", "#Organizations", "#OrganizationIds");
+
+ $("#menus").loadMenus("<%=ModuleName%>");
//主列表加载,可反复调用进行刷新
var config= {}; //table的参数,如搜索key,点击tree的id
diff --git a/OpenAuth.App/OpenAuth.App.csproj b/OpenAuth.App/OpenAuth.App.csproj
index 1324924d..b14a4433 100644
--- a/OpenAuth.App/OpenAuth.App.csproj
+++ b/OpenAuth.App/OpenAuth.App.csproj
@@ -105,6 +105,7 @@
+
@@ -114,6 +115,7 @@
+
diff --git a/OpenAuth.App/Request/QueryResourcesReq.cs b/OpenAuth.App/Request/QueryResourcesReq.cs
new file mode 100644
index 00000000..11274fd6
--- /dev/null
+++ b/OpenAuth.App/Request/QueryResourcesReq.cs
@@ -0,0 +1,11 @@
+namespace OpenAuth.App.Request
+{
+ public class QueryResourcesReq : PageReq
+ {
+ ///
+ /// TypeID
+ ///
+ public string TypeId { get; set; }
+
+ }
+}
diff --git a/OpenAuth.App/ResourceApp.cs b/OpenAuth.App/ResourceApp.cs
new file mode 100644
index 00000000..db4ddf6d
--- /dev/null
+++ b/OpenAuth.App/ResourceApp.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using OpenAuth.App.Request;
+using OpenAuth.App.Response;
+using OpenAuth.Repository.Domain;
+
+namespace OpenAuth.App
+{
+ ///
+ /// 分类管理
+ ///
+ public class ResourceApp:BaseApp
+ {
+
+ public IEnumerable Get(string type)
+ {
+ return Repository.Find(u => u.TypeId == type);
+ }
+
+ public void Add(Resource resource)
+ {
+ if (string.IsNullOrEmpty(resource.Id))
+ {
+ resource.Id = Guid.NewGuid().ToString();
+ }
+ Repository.Add(resource);
+ }
+
+ public void Update(Resource resource)
+ {
+ Repository.Update(u =>u.Id,resource);
+ }
+
+
+ public TableData All(QueryResourcesReq request)
+ {
+ var result = new TableData();
+ var resources = UnitWork.Find(null) ;
+ if (!string.IsNullOrEmpty(request.key))
+ {
+ resources = resources.Where(u => u.Name.Contains(request.key) || u.Id.Contains(request.key));
+ }
+
+ if (!string.IsNullOrEmpty(request.TypeId))
+ {
+ resources = resources.Where(u => u.TypeId == request.TypeId);
+ }
+
+
+ result.data = resources.OrderBy(u => u.TypeId)
+ .Skip((request.page - 1) * request.limit)
+ .Take(request.limit).ToList();
+ result.count = resources.Count();
+ return result;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/OpenAuth.Mvc/Controllers/ResourcesController.cs b/OpenAuth.Mvc/Controllers/ResourcesController.cs
new file mode 100644
index 00000000..3282c574
--- /dev/null
+++ b/OpenAuth.Mvc/Controllers/ResourcesController.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Web.Http;
+using System.Web.Mvc;
+using Infrastructure;
+using OpenAuth.App;
+using OpenAuth.App.Request;
+using OpenAuth.App.Response;
+using OpenAuth.Repository.Domain;
+
+namespace OpenAuth.Mvc.Controllers
+{
+ public class ResourcesController : BaseController
+ {
+ public ResourceApp App { get; set; }
+
+ //
+ // GET: /UserManager/
+ public ActionResult Index()
+ {
+ return View();
+ }
+
+ public string All([FromUri]QueryResourcesReq request)
+ {
+ TableData data = new TableData();
+ data = App.All(request);
+ return JsonHelper.Instance.Serialize(data);
+ }
+
+ [System.Web.Mvc.HttpPost]
+ public string Delete(string[] ids)
+ {
+ Response resp = new Response();
+ try
+ {
+ App.Delete(ids);
+ }
+ catch (Exception e)
+ {
+ resp.Code = 500;
+ resp.Message = e.Message;
+ }
+ return JsonHelper.Instance.Serialize(resp);
+ }
+
+ [System.Web.Mvc.HttpPost]
+ public string Add(Resource obj)
+ {
+ Response resp = new Response();
+ try
+ {
+ App.Add(obj);
+ }
+ catch (Exception e)
+ {
+ resp.Code = 500;
+ resp.Message = e.Message;
+ }
+ return JsonHelper.Instance.Serialize(resp);
+ }
+
+ [System.Web.Mvc.HttpPost]
+ public string Update(Resource obj)
+ {
+ Response resp = new Response();
+ try
+ {
+ App.Update(obj);
+ }
+ catch (Exception e)
+ {
+ resp.Code = 500;
+ resp.Message = e.Message;
+ }
+ return JsonHelper.Instance.Serialize(resp);
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/OpenAuth.Mvc/OpenAuth.Mvc.csproj b/OpenAuth.Mvc/OpenAuth.Mvc.csproj
index cfa89f1e..1bdf4008 100644
--- a/OpenAuth.Mvc/OpenAuth.Mvc.csproj
+++ b/OpenAuth.Mvc/OpenAuth.Mvc.csproj
@@ -24,6 +24,7 @@
..\
true
..\packages\WebGrease.1.5.2\lib
+
true
@@ -142,6 +143,7 @@
+
@@ -200,6 +202,7 @@
+
@@ -645,6 +648,7 @@
+
diff --git a/OpenAuth.Mvc/Views/Resources/Index.cshtml b/OpenAuth.Mvc/Views/Resources/Index.cshtml
new file mode 100644
index 00000000..67ac8dfe
--- /dev/null
+++ b/OpenAuth.Mvc/Views/Resources/Index.cshtml
@@ -0,0 +1,131 @@
+@section header
+{
+
+}
+
+
+
+
+
+
+
+
+ |
+ 资源表ID |
+ 节点语义ID |
+ 资源英文唯一标识 |
+ 名称 |
+ 当前状态 |
+ 排序号 |
+ 描述 |
+ 父节点流水号 |
+ 资源所属应用 |
+ 分类名称 |
+ 分类ID |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OpenAuth.Mvc/userJs/resources.js b/OpenAuth.Mvc/userJs/resources.js
new file mode 100644
index 00000000..0bf52628
--- /dev/null
+++ b/OpenAuth.Mvc/userJs/resources.js
@@ -0,0 +1,158 @@
+layui.config({
+ base: "/js/"
+}).use(['form', 'vue', 'ztree', 'layer', 'jquery', 'table', 'droptree', 'openauth', 'utils'], function () {
+ var form = layui.form,
+ layer = layui.layer,
+ $ = layui.jquery;
+ var table = layui.table;
+ var openauth = layui.openauth;
+ var toplayer = (top == undefined || top.layer === undefined) ? layer : top.layer; //顶层的LAYER
+ //layui.droptree("/UserSession/GetOrgs", "#Organizations", "#OrganizationIds");
+
+ $("#menus").loadMenus("Resource");
+
+ //主列表加载,可反复调用进行刷新
+ var config = {}; //table的参数,如搜索key,点击tree的id
+ var mainList = function (options) {
+ if (options != undefined) {
+ $.extend(config, options);
+ }
+ table.reload('mainList', {
+ url: '/Resources/Load',
+ where: config
+ });
+ }
+ //左边树状机构列表
+ var ztree = function () {
+ var url = '/UserSession/GetOrgs';
+ var zTreeObj;
+ var setting = {
+ view: { selectedMulti: false },
+ data: {
+ key: {
+ name: 'Name',
+ title: 'Name'
+ },
+ simpleData: {
+ enable: true,
+ idKey: 'Id',
+ pIdKey: 'ParentId',
+ rootPId: 'null'
+ }
+ },
+ callback: {
+ onClick: function (event, treeId, treeNode) {
+ mainList({ orgId: treeNode.Id });
+ }
+ }
+ };
+ var load = function () {
+ $.getJSON(url, function (json) {
+ zTreeObj = $.fn.zTree.init($("#tree"), setting);
+ var newNode = { Name: "根节点", Id: null, ParentId: "" };
+ json.push(newNode);
+ zTreeObj.addNodes(null, json);
+ mainList({ orgId: "" });
+ zTreeObj.expandAll(true);
+ });
+ };
+ load();
+ return {
+ reload: load
+ }
+ }();
+
+ //添加(编辑)对话框
+ var editDlg = function () {
+ var vm = new Vue({
+ el: "#formEdit"
+ });
+ var update = false; //是否为更新
+ var show = function (data) {
+ var title = update ? "编辑信息" : "添加";
+ layer.open({
+ title: title,
+ area: ["500px", "400px"],
+ type: 1,
+ content: $('#divEdit'),
+ success: function () {
+ vm.$set('$data', data);
+ },
+ end: mainList
+ });
+ var url = "/Resources/Add";
+ if (update) {
+ url = "/Resources/Update";
+ }
+ //提交数据
+ form.on('submit(formSubmit)',
+ function (data) {
+ $.post(url,
+ data.field,
+ function (data) {
+ layer.msg(data.Message);
+ },
+ "json");
+ return false;
+ });
+ }
+ return {
+ add: function () { //弹出添加
+ update = false;
+ show({
+ Id: ''
+ });
+ },
+ update: function (data) { //弹出编辑框
+ update = true;
+ show(data);
+ }
+ };
+ }();
+
+ //监听表格内部按钮
+ table.on('tool(list)', function (obj) {
+ var data = obj.data;
+ if (obj.event === 'detail') { //查看
+ layer.msg('ID:' + data.Id + ' 的查看操作');
+ }
+ });
+
+
+ //监听页面主按钮操作
+ var active = {
+ btnDel: function () { //批量删除
+ var checkStatus = table.checkStatus('mainList')
+ , data = checkStatus.data;
+ openauth.del("/Resources/Delete",
+ data.map(function (e) { return e.Id; }),
+ mainList);
+ }
+ , btnAdd: function () { //添加
+ editDlg.add();
+ }
+ , btnEdit: function () { //编辑
+ var checkStatus = table.checkStatus('mainList')
+ , data = checkStatus.data;
+ if (data.length != 1) {
+ layer.msg("请选择编辑的行,且同时只能编辑一行");
+ return;
+ }
+ editDlg.update(data[0]);
+ }
+
+ , search: function () { //搜索
+ mainList({ key: $('#key').val() });
+ }
+ , btnRefresh: function () {
+ mainList();
+ }
+ };
+
+ $('.toolList .layui-btn').on('click', function () {
+ var type = $(this).data('type');
+ active[type] ? active[type].call(this) : '';
+ });
+
+ //监听页面主按钮操作 end
+})
\ No newline at end of file