using Admin.Core.Common.Input;
using Admin.Core.Common.Output;
using Admin.Core.Model.Admin;
using Admin.Core.Service.Admin.Api;
using Admin.Core.Service.Admin.Api.Input;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
namespace Admin.Core.Controllers.Admin
{
///
/// 接口管理
///
public class ApiController : AreaController
{
private readonly IApiService _apiService;
public ApiController(IApiService apiService)
{
_apiService = apiService;
}
///
/// 查询单条接口
///
///
///
[HttpGet]
public async Task Get(long id)
{
return await _apiService.GetAsync(id);
}
///
/// 查询全部接口
///
///
///
[HttpGet]
public async Task GetList(string key)
{
return await _apiService.ListAsync(key);
}
///
/// 查询分页接口
///
/// 分页模型
///
[HttpPost]
public async Task GetPage(PageInput model)
{
return await _apiService.PageAsync(model);
}
///
/// 新增接口
///
///
///
[HttpPost]
public async Task Add(ApiAddInput input)
{
return await _apiService.AddAsync(input);
}
///
/// 修改接口
///
///
///
[HttpPut]
public async Task Update(ApiUpdateInput input)
{
return await _apiService.UpdateAsync(input);
}
///
/// 删除接口
///
///
///
[HttpDelete]
public async Task SoftDelete(long id)
{
return await _apiService.SoftDeleteAsync(id);
}
///
/// 批量删除接口
///
///
///
[HttpPut]
public async Task BatchSoftDelete(long[] ids)
{
return await _apiService.BatchSoftDeleteAsync(ids);
}
///
/// 同步接口
/// 支持新增和修改接口
/// 根据接口是否存在自动禁用和启用api
///
///
///
[HttpPost]
public async Task Sync(ApiSyncInput input)
{
return await _apiService.SyncAsync(input);
}
}
}