删除WebApi生成

This commit is contained in:
wintel 2024-06-23 20:57:41 +08:00
parent d923e708a4
commit 360182b297
2 changed files with 0 additions and 150 deletions

View File

@ -83,9 +83,6 @@ Category="1.Database" Description="可以选择一个或多个表使用Ctrl
<%@ Register Name="ModifyReqGenerateClass"
Template="ApiGenerate\ModifyReq.cst"
MergeProperties="False" %>
<%@ Register Name="ControllerGenerateClass"
Template="ApiGenerate\Controller.cst"
MergeProperties="False" %>
开始创建OpenAuth.Core WebApi相关代码 ...
<% Generate(); %>
@ -105,7 +102,6 @@ Category="1.Database" Description="可以选择一个或多个表使用Ctrl
}
CreateEntityClasses();
CreateControllerClass();
CreateApplicationClass();
CreateReqClass();
CreateContextClass();
@ -154,24 +150,6 @@ Category="1.Database" Description="可以选择一个或多个表使用Ctrl
}
//创建控制器,如UserManagerController.cs
public void CreateControllerClass()
{
ControllerGenerateClass generatedClass = this.Create<ControllerGenerateClass>();
this.CopyPropertiesTo(generatedClass);
foreach(TableSchema table in tables)
{
string generatedFile = Path.GetFullPath(directory) + "OpenAuth.WebApi\\Controllers\\"+ table.Name + "sController.cs";
generatedClass.ModuleName = table.Name;
Response.WriteLine("已生成"+generatedFile);
generatedClass.RenderToFile(generatedFile, generatedFile, true);
}
}
//创建APP层,如UserManagerApp.cs
public void CreateApplicationClass()
{

View File

@ -1,128 +0,0 @@
<%--
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;
/// <summary>
/// //获取详情
/// </summary>
[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;
}
/// <summary>
/// 添加
/// </summary>
[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;
}
/// <summary>
/// 修改
/// </summary>
[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;
}
}
}