mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-11-09 10:54:46 +08:00
添加Category
This commit is contained in:
@@ -1,102 +1,95 @@
|
||||
<%--
|
||||
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" %>
|
||||
<script runat="template">
|
||||
public String GetModelName()
|
||||
{
|
||||
if(NeedViewModel)
|
||||
return ModuleName +"View";
|
||||
else
|
||||
return ModuleName;
|
||||
}
|
||||
</script>
|
||||
|
||||
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 = (<%=ModuleName%>ManagerApp)DependencyResolver.Current.GetService(typeof(<%=ModuleName%>ManagerApp));
|
||||
}
|
||||
|
||||
//
|
||||
// GET: /<%=ModuleName%>Manager/
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult Add(int id = 0)
|
||||
{
|
||||
return View(_app.Find(id));
|
||||
}
|
||||
|
||||
//添加或修改组织
|
||||
[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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载组织下面的所有用户
|
||||
/// </summary>
|
||||
public string Load(int orgId, int pageCurrent = 1, int pageSize = 30)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.Load(orgId, pageCurrent, pageSize));
|
||||
}
|
||||
|
||||
//获取组织下面用户个数
|
||||
public int GetCount(int orgId)
|
||||
{
|
||||
return _app.Get<%=GetModelName()%>CntInOrg(orgId);
|
||||
}
|
||||
|
||||
public string Delete(string Id)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var obj in Id.Split(','))
|
||||
{
|
||||
_app.Delete(int.Parse(obj));
|
||||
}
|
||||
}
|
||||
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" %>
|
||||
<script runat="template">
|
||||
public String GetModelName()
|
||||
{
|
||||
if(NeedViewModel)
|
||||
return ModuleName +"View";
|
||||
else
|
||||
return ModuleName;
|
||||
}
|
||||
</script>
|
||||
|
||||
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 = (<%=ModuleName%>ManagerApp)DependencyResolver.Current.GetService(typeof(<%=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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载组织下面的所有用户
|
||||
/// </summary>
|
||||
public string Load(int orgId, int pageCurrent = 1, int pageSize = 30)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.Load(orgId, pageCurrent, pageSize));
|
||||
}
|
||||
|
||||
public string Delete(int Id)
|
||||
{
|
||||
try
|
||||
{
|
||||
_app.Delete(Id);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BjuiResponse.statusCode = "300";
|
||||
BjuiResponse.message = e.Message;
|
||||
}
|
||||
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user