代码拉取完成,页面将自动刷新
同步操作将从 uncle wang/OAuthApp 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using OAuthApp.Data;
using Swashbuckle.AspNetCore.Annotations;
using OAuthApp.Filters;
using OAuthApp.Services;
namespace OAuthApp.Apis
{
[SwaggerTag("API CodeGen")]
[ServiceFilter(typeof(ApiRequestLoggingAttribute))]
public class ApiCodeGeneratorsController : BaseController
{
private readonly ApiDbContext _context;
public ApiCodeGeneratorsController(ApiDbContext context)
{
_context = context;
}
[HttpGet]
[SwaggerOperation(OperationId = "ApiCodeGens")]
[EncryptResultFilter]
public IActionResult List(long apiId, int skip, int take)
{
var q = _context.ApiCodeGenerators.Where(x => x.ApiID == apiId).AsQueryable();
var total = q.Count();
var data = q.Skip(skip).Take(take).OrderByDescending(x => x.ID).ToList();
return OK(new
{
total,
data
});
}
[HttpGet("{id}")]
[SwaggerOperation(OperationId = "ApiCodeGen")]
[EncryptResultFilter]
public IActionResult Get(long id)
{
var result = _context.ApiCodeGenerators
.FirstOrDefault(x => x.ID == id);
if (result == null)
{
return NotFound();
}
return OK(result);
}
[HttpPost]
[SwaggerOperation(OperationId = "ApiCodeGenPost")]
public IActionResult Post(ApiCodeGenerator apiCodeGenerator)
{
if(_context.ApiCodeGenerators.Any(x=>x.ApiID==apiCodeGenerator.ApiID
&&x.CodeGeneratorID==apiCodeGenerator.CodeGeneratorID))
{
return Error("请勿重复添加");
}
_context.ApiCodeGenerators.Add(apiCodeGenerator);
_context.SaveChanges();
return OK(new { id = apiCodeGenerator.ID });
}
[HttpDelete("{id}")]
[SwaggerOperation(OperationId = "ApiCodeGenDelete")]
public IActionResult Delete(long id)
{
var result = _context.ApiCodeGenerators
.FirstOrDefault(x => x.ID == id);
if (result == null)
{
return NotFound();
}
_context.ApiCodeGenerators.Remove(result);
_context.SaveChanges();
return OK(true);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。