mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00

1 完成进出库实例Stock; 2 全面实现组织数据分离,参考Stock实例; 3 全新的基于CodeSmith EF生成机制; 4 全面完成菜单授权; 5 增加Anonymous机制,可以灵活控制Action是否需要权限控制;
110 lines
2.9 KiB
Plaintext
110 lines
2.9 KiB
Plaintext
<%--
|
|
Name: Database Table Properties
|
|
Author: yubaolee
|
|
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;
|
|
<%} %>
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载节点下面的所有<%=ModuleName %>s
|
|
/// </summary>
|
|
public string Load(int parentId, int pageCurrent = 1, int pageSize = 30)
|
|
{
|
|
return JsonHelper.Instance.Serialize(_app.Load(parentId, 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);
|
|
}
|
|
|
|
|
|
}
|
|
} |