300 lines
7.6 KiB
Plaintext
300 lines
7.6 KiB
Plaintext
@{
|
|
var dataPermission=@Model.DataPermission=="Y";//是否启用数据权限
|
|
var isOrgTree=@Model.LeftTree=="org";//是否启用组织树
|
|
var funcList=@Model.FuncList;//获取功能列表
|
|
var isTreeList = @Model.ModuleType=="treeList";//是否是树表-列表
|
|
var isTreeTree = @Model.ModuleType=="treeTree"; //是否是树-树
|
|
var tableFieIds=@Model.TableFields;//获取字段
|
|
}
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.ComponentModel;
|
|
using MoYu.DynamicApiController;
|
|
using @(@Model.ServicePosition);
|
|
|
|
namespace @(@Model.ControllerPosition);
|
|
|
|
/// <summary>
|
|
/// @(@Model.FunctionName)控制器
|
|
/// </summary>
|
|
[ApiDescriptionSettings("@(@Model.ApiGroup)", Tag = "@(@Model.FunctionName)")]
|
|
[Route("@(@Model.RouteName)/@(@Model.BusName)")]
|
|
@if(dataPermission) @:[RolePermission]
|
|
public class @(@Model.ClassName)Controller: IDynamicApiController
|
|
{
|
|
private readonly I@(@Model.ServiceName) _@(@Model.ServiceFirstLower);
|
|
@if(isOrgTree){
|
|
@if(dataPermission){
|
|
@:private readonly IOrgService _orgService;
|
|
}
|
|
else{
|
|
@:private readonly ISysOrgService _sysOrgService;
|
|
}
|
|
}
|
|
public @(@Model.ClassName)Controller(I@(@Model.ServiceName) @(@Model.ServiceFirstLower)
|
|
@if(isOrgTree){
|
|
@if(dataPermission){
|
|
@:,IOrgService orgService
|
|
}
|
|
else{
|
|
@:,ISysOrgService sysOrgService
|
|
}
|
|
}
|
|
)
|
|
{
|
|
this._@(@Model.ServiceFirstLower) = @(@Model.ServiceFirstLower);
|
|
@if(isOrgTree){
|
|
@if(dataPermission){
|
|
@:_orgService = orgService;
|
|
}
|
|
else{
|
|
@:_sysOrgService = sysOrgService;
|
|
}
|
|
}
|
|
}
|
|
#region Get请求
|
|
|
|
/// <summary>
|
|
/// @(@Model.DescriptionPage)
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("page")]
|
|
[DisplayName("@(@Model.DescriptionPage)")]
|
|
public async Task<dynamic> Page([FromQuery] @Model.PageInput input)
|
|
{
|
|
return await _@(@Model.ServiceFirstLower).Page(input);
|
|
}
|
|
|
|
/// <summary>
|
|
/// @(@Model.DescriptionList)
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("list")]
|
|
[DisplayName("@(@Model.DescriptionList)")]
|
|
public async Task<dynamic> List([FromQuery] @Model.PageInput input)
|
|
{
|
|
return await _@(@Model.ServiceFirstLower).List(input);
|
|
}
|
|
|
|
/// <summary>
|
|
/// @(@Model.DescriptionDetail)
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("detail")]
|
|
[DisplayName("@(@Model.DescriptionDetail)")]
|
|
public async Task<dynamic> Detail([FromQuery] BaseIdInput input)
|
|
{
|
|
return await _@(@Model.ServiceFirstLower).Detail(input);
|
|
}
|
|
|
|
@{Fk();}
|
|
|
|
@{Tree();}
|
|
|
|
@{OtherGet();}
|
|
|
|
#endregion
|
|
|
|
|
|
#region Post请求
|
|
|
|
/// <summary>
|
|
/// @(@Model.DescriptionAdd)
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("add")]
|
|
[DisplayName("@(@Model.DescriptionAdd)")]
|
|
public async Task Add([FromBody] @(@Model.ClassName)AddInput input)
|
|
{
|
|
await _@(@Model.ServiceFirstLower).Add(input);
|
|
}
|
|
|
|
/// <summary>
|
|
/// @(@Model.DescriptionEdit)
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("edit")]
|
|
[DisplayName("@(@Model.DescriptionEdit)")]
|
|
public async Task Edit([FromBody] @(@Model.ClassName)EditInput input)
|
|
{
|
|
await _@(@Model.ServiceFirstLower).Edit(input);
|
|
}
|
|
|
|
/// <summary>
|
|
/// @(@Model.DescriptionDelete)
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("delete")]
|
|
[DisplayName("@(@Model.DescriptionDelete)")]
|
|
public async Task Delete([FromBody] BaseIdListInput input)
|
|
{
|
|
await _@(@Model.ServiceFirstLower).Delete(input);
|
|
}
|
|
|
|
@{OtherPost();}
|
|
#endregion
|
|
}
|
|
|
|
@{
|
|
|
|
void Fk(){
|
|
foreach (var column in tableFieIds){//遍历字段
|
|
if(column.EffectType=="fk"){//如果是外键
|
|
@:/// <summary>
|
|
@:/// @(column.FieldRemark)选择器
|
|
@:/// </summary>
|
|
@:/// <returns></returns>
|
|
@:[HttpGet("fk@(column.FkEntityName)Selector")]
|
|
@:[DisplayName("@(column.FieldRemark)选择器")]
|
|
@:public async Task<dynamic> Fk@(column.FkEntityName)Selector()
|
|
@:{
|
|
@:return await _@(@Model.ServiceFirstLower).Fk@(column.FkEntityName)Selector();
|
|
@:}
|
|
@:
|
|
}
|
|
}
|
|
}
|
|
|
|
void OtherGet(){
|
|
foreach(var func in funcList){
|
|
switch (func)//根据类型生成不同请求
|
|
{
|
|
//导入
|
|
case "import":
|
|
@:/// <summary>
|
|
@:/// @(@Model.DescriptionPreview)
|
|
@:/// </summary>
|
|
@:/// <param name="input"></param>
|
|
@:/// <returns></returns>
|
|
@:[HttpPost("preview")]
|
|
@:[DisableRequestSizeLimit]
|
|
@:[SuppressMonitor]
|
|
@:[DisplayName("@(@Model.DescriptionPreview)")]
|
|
@:public async Task<dynamic> Preview([FromForm] ImportPreviewInput input)
|
|
@:{
|
|
@:return await _@(@Model.ServiceFirstLower).Preview(input);
|
|
@:}
|
|
@:
|
|
@:/// <summary>
|
|
@:/// @(@Model.DescriptionTemplate)
|
|
@:/// </summary>
|
|
@:/// <returns></returns>
|
|
@:[HttpGet("template")]
|
|
@:[SuppressMonitor]
|
|
@:public async Task<dynamic> Template()
|
|
@:{
|
|
@:return await _@(@Model.ServiceFirstLower).Template();
|
|
@:}
|
|
@:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//左侧树接口
|
|
void Tree(){
|
|
if(isOrgTree){
|
|
@:/// <summary>
|
|
@:/// 获取组织树选择器
|
|
@:/// </summary>
|
|
@:/// <returns></returns>
|
|
@:[HttpGet("orgTreeSelector")]
|
|
@:[DisplayName("组织树查询")]
|
|
@:public async Task<dynamic> OrgTreeSelector()
|
|
@:{
|
|
@if(dataPermission){
|
|
@:return await _orgService.Tree();
|
|
}
|
|
else{
|
|
@:return await _sysOrgService.Tree();
|
|
}
|
|
@:}
|
|
}
|
|
else if(isTreeList){
|
|
@:/// <summary>
|
|
@:/// @(@Model.DescriptionTree)
|
|
@:/// </summary>
|
|
@:/// <returns></returns>
|
|
@:[HttpGet("tree")]
|
|
@:[DisplayName("@(@Model.DescriptionTree)")]
|
|
@:public async Task<dynamic> Tree()
|
|
@:{
|
|
@:return await _@(@Model.ServiceFirstLower).Tree();
|
|
@:}
|
|
}
|
|
else if(isTreeTree){
|
|
@:/// <summary>
|
|
@:/// @(@Model.DescriptionTree)
|
|
@:/// </summary>
|
|
@:/// <returns></returns>
|
|
@:[HttpGet("tree")]
|
|
@:[DisplayName("@(@Model.DescriptionTree)")]
|
|
@:public async Task<dynamic> Tree([FromQuery] @Model.TreeInput input)
|
|
@:{
|
|
@:return await _@(@Model.ServiceFirstLower).Tree(input);
|
|
@:}
|
|
}
|
|
|
|
}
|
|
|
|
void OtherPost(){
|
|
foreach(var func in funcList){
|
|
switch (func)//根据类型生成不同请求
|
|
{
|
|
//导入
|
|
case "import":
|
|
@:/// <summary>
|
|
@:/// @(@Model.DescriptionImport)
|
|
@:/// </summary>
|
|
@:/// <param name="input"></param>
|
|
@:/// <returns></returns>
|
|
@:[HttpPost("import")]
|
|
@:[DisplayName("@(@Model.DescriptionImport)")]
|
|
@:public async Task<dynamic> Import([SuppressMonitor][FromBody] ImportResultInput<@(@Model.ClassName)ImportInput> input)
|
|
@:{
|
|
@:return await _@(@Model.ServiceFirstLower).Import(input);
|
|
@:}
|
|
@:
|
|
break;
|
|
//导出
|
|
case "export":
|
|
@:/// <summary>
|
|
@:/// @(@Model.DescriptionExport)
|
|
@:/// </summary>
|
|
@:/// <param name="input"></param>
|
|
@:/// <returns></returns>
|
|
@:[HttpPost("export")]
|
|
@:[DisplayName("@(@Model.DescriptionExport)")]
|
|
@:public async Task<dynamic> Export([FromBody] @Model.PageInput input)
|
|
@:{
|
|
@:return await _@(@Model.ServiceFirstLower).Export(input);
|
|
@:}
|
|
@:
|
|
break;
|
|
//批量编辑
|
|
case "batchEdit":
|
|
@:/// <summary>
|
|
@:/// @(@Model.DescriptionEdits)
|
|
@:/// </summary>
|
|
@:/// <param name="input"></param>
|
|
@:/// <returns></returns>
|
|
@:[HttpPost("edits")]
|
|
@:[DisplayName("@(@Model.DescriptionEdits)")]
|
|
@:public async Task Edits([FromBody] BatchEditInput input)
|
|
@:{
|
|
@:await _@(@Model.ServiceFirstLower).Edits(input);
|
|
@:}
|
|
@:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|