2020-10-22 14:59: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="True" 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 Infrastructure;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using OpenAuth.App;
|
|
|
|
using OpenAuth.App.Request;
|
|
|
|
using OpenAuth.App.Response;
|
|
|
|
using OpenAuth.Repository.Domain;
|
|
|
|
|
|
|
|
namespace OpenAuth.WebApi.Controllers
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// <%=ModuleName%>操作
|
|
|
|
/// </summary>
|
|
|
|
[Route("api/[controller]/[action]")]
|
|
|
|
[ApiController]
|
|
|
|
public class <%=ModuleName%>sController : ControllerBase
|
|
|
|
{
|
|
|
|
private readonly <%=ModuleName%>App _app;
|
|
|
|
|
2021-05-07 23:38:53 +08:00
|
|
|
/// <summary>
|
|
|
|
/// //获取详情
|
|
|
|
/// </summary>
|
2020-10-22 14:59:36 +08:00
|
|
|
[HttpGet]
|
|
|
|
public Response<<%=ModuleName%>> Get(string id)
|
|
|
|
{
|
|
|
|
var result = new Response<<%=ModuleName%>>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
result.Result = _app.Get(id);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
result.Code = 500;
|
|
|
|
result.Message = ex.InnerException?.Message ?? ex.Message;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-05-07 23:38:53 +08:00
|
|
|
/// <summary>
|
|
|
|
/// 添加
|
|
|
|
/// </summary>
|
2020-10-22 14:59:36 +08:00
|
|
|
[HttpPost]
|
|
|
|
public Response Add(AddOrUpdate<%=ModuleName%>Req obj)
|
|
|
|
{
|
|
|
|
var result = new Response();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
_app.Add(obj);
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
result.Code = 500;
|
|
|
|
result.Message = ex.InnerException?.Message ?? ex.Message;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-05-07 23:38:53 +08:00
|
|
|
/// <summary>
|
|
|
|
/// 修改
|
|
|
|
/// </summary>
|
2020-10-22 14:59:36 +08:00
|
|
|
[HttpPost]
|
|
|
|
public Response Update(AddOrUpdate<%=ModuleName%>Req obj)
|
|
|
|
{
|
|
|
|
var result = new Response();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
_app.Update(obj);
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
result.Code = 500;
|
|
|
|
result.Message = ex.InnerException?.Message ?? ex.Message;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 加载列表
|
|
|
|
/// </summary>
|
|
|
|
[HttpGet]
|
|
|
|
public TableData Load([FromQuery]Query<%=ModuleName%>ListReq request)
|
|
|
|
{
|
|
|
|
return _app.Load(request);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 批量删除
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost]
|
|
|
|
public Response Delete([FromBody]string[] ids)
|
|
|
|
{
|
|
|
|
var result = new Response();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
_app.Delete(ids);
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
result.Code = 500;
|
|
|
|
result.Message = ex.InnerException?.Message ?? ex.Message;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public <%=ModuleName%>sController(<%=ModuleName%>App app)
|
|
|
|
{
|
|
|
|
_app = app;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|