using Attribute;
using Common;
using Dto;
using Vo;
using Enums;
using Filters;
using Infrastructure;
using Infrastructure.Model;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Middleware;
using Model;
using Services;
using Model.Base;
namespace Controllers
{
///
/// ApiInfo)Controller
///
// [Route("ApiInfo")]
// [ApiExplorerSettings(GroupName = "ApiInfo")]
public class ApiInfoController : BaseController
{
///
/// api分组接口
///
private readonly IApiInfoService _ApiInfoService;
public ApiInfoController(IApiInfoService ApiInfoService)
{
_ApiInfoService = ApiInfoService;
}
///
/// api接口列表
///
/// 请求参数
/// api接口列表
[HttpGet]
[Route("/v1/api/ApiInfo/list")]
public IActionResult List([FromQuery] PagerInfo page, [FromQuery] ApiInfoListDto parm)
{
var response = _ApiInfoService.List(page, parm);
return SUCCESS(response);
}
///
/// api接口详情
///
/// 请求参数
/// api接口详情
[HttpGet]
[Route("/v1/api/ApiInfo/query")]
public IActionResult Query([FromQuery] ApiInfoQueryDto parm)
{
var response = _ApiInfoService.Queryable()
.First(x => x.id == parm.id)
.Adapt() ?? new ApiInfoQueryVo();
return SUCCESS(response);
}
///
/// api接口添加
///
/// 请求参数
/// api接口添加
[HttpPost]
[Route("/v1/api/ApiInfo/add")]
public IActionResult Add([FromBody] ApiInfoAddDto parm)
{
var modal = parm.Adapt().ToCreate(HttpContext);
var response = _ApiInfoService.Add(modal);
return SUCCESS(response);
}
///
/// api接口设置版本号
///
/// 请求参数
/// api接口设置版本号
[HttpPut]
[Route("/v1/api/ApiInfo/setVersion")]
public IActionResult SetVersion([FromBody] ApiInfoSetVersionDto parm)
{
var modal = parm.Adapt().ToUpdate(HttpContext);
var response = _ApiInfoService.Update(modal, true);
return SUCCESS(response);
}
///
/// api接口删除
///
/// ID
/// api接口删除
[HttpDelete]
[Route("/v1/api/ApiInfo/delete/{id}")]
public IActionResult Delete(int id)
{
var response = _ApiInfoService.Delete(id);
return SUCCESS(response);
}
///
/// api接口修改
///
/// 请求参数
/// api接口修改
[HttpPut]
[Route("/v1/api/ApiInfo/update")]
public IActionResult Update([FromBody] ApiInfoUpdateDto parm)
{
var modal = parm.Adapt().ToUpdate(HttpContext);
var response = _ApiInfoService.Update(modal, true);
return SUCCESS(response);
}
///
/// api接口设置请求地址
///
/// 请求参数
/// api接口设置请求地址
[HttpPut]
[Route("/v1/api/ApiInfo/setRouter")]
public IActionResult SetRouter([FromBody] ApiInfoSetRouterDto parm)
{
var modal = parm.Adapt().ToUpdate(HttpContext);
var response = _ApiInfoService.Update(modal, true);
return SUCCESS(response);
}
}
}