2017-11-29 18:26:36 +08:00
|
|
|
<%--
|
|
|
|
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="模块名称" %>
|
|
|
|
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
|
|
|
|
<%@ Assembly Name="SchemaExplorer" %>
|
|
|
|
<%@ Import Namespace="SchemaExplorer" %>
|
|
|
|
|
|
|
|
using System;
|
2017-12-15 00:03:06 +08:00
|
|
|
using System.Web.Http;
|
2017-11-29 18:26:36 +08:00
|
|
|
using System.Web.Mvc;
|
|
|
|
using Infrastructure;
|
|
|
|
using OpenAuth.App;
|
2017-12-15 00:03:06 +08:00
|
|
|
using OpenAuth.App.Request;
|
|
|
|
using OpenAuth.App.Response;
|
|
|
|
using OpenAuth.Mvc.Models;
|
2017-11-29 18:26:36 +08:00
|
|
|
|
|
|
|
namespace OpenAuth.Mvc.Controllers
|
|
|
|
{
|
2017-12-18 22:37:51 +08:00
|
|
|
public class <%=ModuleName%>sController : BaseController
|
2017-11-29 18:26:36 +08:00
|
|
|
{
|
2017-12-15 00:03:06 +08:00
|
|
|
public <%=ModuleName%>App App { get; set; }
|
2017-11-29 18:26:36 +08:00
|
|
|
|
|
|
|
//
|
2017-12-15 00:03:06 +08:00
|
|
|
[Authenticate]
|
2017-11-29 18:26:36 +08:00
|
|
|
public ActionResult Index()
|
|
|
|
{
|
|
|
|
return View();
|
|
|
|
}
|
|
|
|
|
2017-12-18 22:37:51 +08:00
|
|
|
//添加或修改
|
2017-12-15 00:03:06 +08:00
|
|
|
[System.Web.Mvc.HttpPost]
|
|
|
|
public string Add(<%=ModuleName%> obj)
|
2017-11-29 18:26:36 +08:00
|
|
|
{
|
2017-12-15 00:03:06 +08:00
|
|
|
try
|
|
|
|
{
|
|
|
|
App.Add(obj);
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
Result.Code = 500;
|
|
|
|
Result.Message = ex.Message;
|
|
|
|
}
|
|
|
|
return JsonHelper.Instance.Serialize(Result);
|
2017-11-29 18:26:36 +08:00
|
|
|
}
|
|
|
|
|
2017-12-18 22:37:51 +08:00
|
|
|
//添加或修改
|
2017-12-15 00:03:06 +08:00
|
|
|
[System.Web.Mvc.HttpPost]
|
|
|
|
public string Update(<%=ModuleName%> obj)
|
2017-11-29 18:26:36 +08:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2017-12-15 00:03:06 +08:00
|
|
|
App.Update(obj);
|
|
|
|
|
2017-11-29 18:26:36 +08:00
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2017-12-15 00:03:06 +08:00
|
|
|
Result.Code = 500;
|
|
|
|
Result.Message = ex.Message;
|
2017-11-29 18:26:36 +08:00
|
|
|
}
|
2017-12-15 00:03:06 +08:00
|
|
|
return JsonHelper.Instance.Serialize(Result);
|
2017-11-29 18:26:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-18 22:37:51 +08:00
|
|
|
/// 加载列表
|
2017-11-29 18:26:36 +08:00
|
|
|
/// </summary>
|
2017-12-15 00:03:06 +08:00
|
|
|
public string Load([FromUri]Query<%=ModuleName%>ListReq request)
|
2017-11-29 18:26:36 +08:00
|
|
|
{
|
2017-12-15 00:03:06 +08:00
|
|
|
return JsonHelper.Instance.Serialize(App.Load(request));
|
2017-11-29 18:26:36 +08:00
|
|
|
}
|
|
|
|
|
2017-12-15 00:03:06 +08:00
|
|
|
[System.Web.Mvc.HttpPost]
|
|
|
|
public string Delete(string[] ids)
|
2017-11-29 18:26:36 +08:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2017-12-15 00:03:06 +08:00
|
|
|
App.Delete(ids);
|
2017-11-29 18:26:36 +08:00
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
2017-12-15 00:03:06 +08:00
|
|
|
Result.Code = 500;
|
|
|
|
Result.Message = e.Message;
|
2017-11-29 18:26:36 +08:00
|
|
|
}
|
|
|
|
|
2017-12-15 00:03:06 +08:00
|
|
|
return JsonHelper.Instance.Serialize(Result);
|
2017-11-29 18:26:36 +08:00
|
|
|
}
|
|
|
|
}
|
2015-11-22 23:54:21 +08:00
|
|
|
}
|