mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-18 04:33:27 +08:00
97 lines
2.5 KiB
Plaintext
97 lines
2.5 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="模块名称" %>
|
|
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
|
|
<%@ Assembly Name="SchemaExplorer" %>
|
|
<%@ Import Namespace="SchemaExplorer" %>
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Infrastructure;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using OpenAuth.App;
|
|
using OpenAuth.App.Interface;
|
|
using OpenAuth.App.Request;
|
|
using OpenAuth.Repository.Domain;
|
|
|
|
namespace OpenAuth.Mvc.Controllers
|
|
{
|
|
public class <%=ModuleName%>sController : BaseController
|
|
{
|
|
private readonly <%=ModuleName%>App _app;
|
|
|
|
public <%=ModuleName%>sController(<%=ModuleName%>App app, IAuth auth) : base(auth)
|
|
{
|
|
_app = app;
|
|
}
|
|
|
|
//主页
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
//添加或修改
|
|
[HttpPost]
|
|
public string Add(<%=ModuleName%> obj)
|
|
{
|
|
try
|
|
{
|
|
_app.Add(obj);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Result.Code = 500;
|
|
Result.Message = ex.Message;
|
|
}
|
|
return JsonHelper.Instance.Serialize(Result);
|
|
}
|
|
|
|
//添加或修改
|
|
[HttpPost]
|
|
public string Update(<%=ModuleName%> obj)
|
|
{
|
|
try
|
|
{
|
|
_app.Update(obj);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Result.Code = 500;
|
|
Result.Message = ex.Message;
|
|
}
|
|
return JsonHelper.Instance.Serialize(Result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载列表
|
|
/// </summary>
|
|
public string Load([FromQuery]Query<%=ModuleName%>ListReq request)
|
|
{
|
|
return JsonHelper.Instance.Serialize(_app.Load(request));
|
|
}
|
|
|
|
[HttpPost]
|
|
public string Delete(string[] ids)
|
|
{
|
|
try
|
|
{
|
|
_app.Delete(ids);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Result.Code = 500;
|
|
Result.Message = e.Message;
|
|
}
|
|
|
|
return JsonHelper.Instance.Serialize(Result);
|
|
}
|
|
}
|
|
} |