【修复】修复因代码生成器编写错误,导致webapi继承controller的问题,改回ControllerBase。Aciont修改为统一返回实体类,方便swagger之类的工具生成更具体的返回结构;

This commit is contained in:
JianWeie
2021-10-14 17:41:29 +08:00
parent ff26d21a4c
commit 86c04ca1ed
103 changed files with 2230 additions and 2387 deletions
@@ -41,7 +41,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
[ApiController]
[RequiredErrorForAdmin]
[Authorize]
public class {{ModelClassName}}Controller : Controller
public class {{ModelClassName}}Controller : ControllerBase
{
private readonly IWebHostEnvironment _webHostEnvironment;
private readonly I{{ModelClassName}}Services _{{ModelClassName}}Services;
@@ -65,7 +65,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
/// <returns></returns>
[HttpPost]
[Description("获取列表")]
public async Task<JsonResult> GetPageList()
public async Task<AdminUiCallBack> GetPageList()
{
var jm = new AdminUiCallBack();
var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1);
@@ -149,7 +149,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
jm.code = 0;
jm.count = list.TotalCount;
jm.msg = "数据调用成功!";
return Json(jm);
return jm;
}
#endregion
@@ -161,11 +161,11 @@ namespace CoreCms.Net.Web.Admin.Controllers
/// <returns></returns>
[HttpPost]
[Description("首页数据")]
public JsonResult GetIndex()
public AdminUiCallBack GetIndex()
{
//返回数据
var jm = new AdminUiCallBack { code = 0 };
return Json(jm);
return jm;
}
#endregion
@@ -177,11 +177,11 @@ namespace CoreCms.Net.Web.Admin.Controllers
/// <returns></returns>
[HttpPost]
[Description("创建数据")]
public JsonResult GetCreate()
public AdminUiCallBack GetCreate()
{
//返回数据
var jm = new AdminUiCallBack { code = 0 };
return Json(jm);
return jm;
}
#endregion
@@ -194,10 +194,10 @@ namespace CoreCms.Net.Web.Admin.Controllers
/// <returns></returns>
[HttpPost]
[Description("创建提交")]
public async Task<JsonResult> DoCreate([FromBody]{{ModelClassName}} entity)
public async Task<AdminUiCallBack> DoCreate([FromBody]{{ModelClassName}} entity)
{
var jm = await _{{ModelClassName}}Services.InsertAsync(entity);
return Json(jm);
return jm;
}
#endregion
@@ -210,7 +210,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
/// <returns></returns>
[HttpPost]
[Description("编辑数据")]
public async Task<JsonResult> GetEdit([FromBody]FMIntId entity)
public async Task<AdminUiCallBack> GetEdit([FromBody]FMIntId entity)
{
var jm = new AdminUiCallBack();
@@ -218,12 +218,12 @@ namespace CoreCms.Net.Web.Admin.Controllers
if (model == null)
{
jm.msg = "不存在此信息";
return Json(jm);
return jm;
}
jm.code = 0;
jm.data = model;
return Json(jm);
return jm;
}
#endregion
@@ -236,10 +236,10 @@ namespace CoreCms.Net.Web.Admin.Controllers
/// <returns></returns>
[HttpPost]
[Description("编辑提交")]
public async Task<JsonResult> DoEdit([FromBody]{{ModelClassName}} entity)
public async Task<AdminUiCallBack> DoEdit([FromBody]{{ModelClassName}} entity)
{
var jm = await _{{ModelClassName}}Services.UpdateAsync(entity);
return Json(jm);
return jm;
}
#endregion
@@ -252,7 +252,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
/// <returns></returns>
[HttpPost]
[Description("单选删除")]
public async Task<JsonResult> DoDelete([FromBody]FMIntId entity)
public async Task<AdminUiCallBack> DoDelete([FromBody]FMIntId entity)
{
var jm = new AdminUiCallBack();
@@ -260,11 +260,11 @@ namespace CoreCms.Net.Web.Admin.Controllers
if (!model)
{
jm.msg = GlobalConstVars.DataisNo;
return Json(jm);
return jm;
}
jm = await _{{ModelClassName}}Services.DeleteByIdAsync(entity.id);
return Json(jm);
return jm;
}
#endregion
@@ -277,10 +277,10 @@ namespace CoreCms.Net.Web.Admin.Controllers
/// <returns></returns>
[HttpPost]
[Description("批量删除")]
public async Task<JsonResult> DoBatchDelete([FromBody]FMArrayIntIds entity)
public async Task<AdminUiCallBack> DoBatchDelete([FromBody]FMArrayIntIds entity)
{
var jm = await _{{ModelClassName}}Services.DeleteByIdsAsync(entity.id);
return Json(jm);
return jm;
}
#endregion
@@ -294,7 +294,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
/// <returns></returns>
[HttpPost]
[Description("预览数据")]
public async Task<JsonResult> GetDetails([FromBody]FMIntId entity)
public async Task<AdminUiCallBack> GetDetails([FromBody]FMIntId entity)
{
var jm = new AdminUiCallBack();
@@ -302,12 +302,12 @@ namespace CoreCms.Net.Web.Admin.Controllers
if (model == null)
{
jm.msg = "不存在此信息";
return Json(jm);
return jm;
}
jm.code = 0;
jm.data = model;
return Json(jm);
return jm;
}
#endregion
@@ -320,7 +320,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
/// <returns></returns>
[HttpPost]
[Description("选择导出")]
public async Task<JsonResult> SelectExportExcel([FromBody]FMArrayIntIds entity)
public async Task<AdminUiCallBack> SelectExportExcel([FromBody]FMArrayIntIds entity)
{
var jm = new AdminUiCallBack();
@@ -370,7 +370,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
jm.msg = GlobalConstVars.ExcelExportSuccess;
jm.data = tpath + fileName;
return Json(jm);
return jm;
}
#endregion
@@ -382,7 +382,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
/// <returns></returns>
[HttpPost]
[Description("查询导出")]
public async Task<JsonResult> QueryExportExcel()
public async Task<AdminUiCallBack> QueryExportExcel()
{
var jm = new AdminUiCallBack();
@@ -474,7 +474,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
jm.msg = GlobalConstVars.ExcelExportSuccess;
jm.data = tpath + fileName;
return Json(jm);
return jm;
}
#endregion
@@ -488,7 +488,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
/// <returns></returns>
[HttpPost]
[Description("设置{{field.ColumnDescription}}")]
public async Task<JsonResult> DoSet{{field.DbColumnName}}([FromBody]FMUpdateBoolDataByIntId entity)
public async Task<AdminUiCallBack> DoSet{{field.DbColumnName}}([FromBody]FMUpdateBoolDataByIntId entity)
{
var jm = new AdminUiCallBack();
@@ -496,7 +496,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
if (oldModel == null)
{
jm.msg = "不存在此信息";
return Json(jm);
return jm;
}
oldModel.{{field.DbColumnName}} = (bool)entity.data;
@@ -504,7 +504,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
jm.code = bl ? 0 : 1;
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
return Json(jm);
return jm;
}
#endregion
{% endif %}{% endfor %}