using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using GxPress.Service.Interface.ArticleLabel;
using System.Threading.Tasks;
using System.Collections.Generic;
using GxPress.Common.Exceptions;
namespace GxPress.Api.AdminControllers
{
///
/// APP版本管理
///
[Route("api/admin/article-label")]
[ApiController]
[Authorize]
public class AdminArticleLabelController : ControllerBase
{
private readonly IArticleLabelService _articleLabelService;
public AdminArticleLabelController(IArticleLabelService articleLabelService)
{
_articleLabelService = articleLabelService;
}
///
/// 获取标签列表
///
///
[HttpGet("list")]
public async Task> GetArticleLabelsAsync()
{
return await _articleLabelService.GetArticleLabelsAsync();
}
///
/// 添加标签
///
///
///
[HttpGet("add/{labelName}")]
public async Task InsertAsync(string labelName)
{
if (string.IsNullOrWhiteSpace(labelName))
throw new BusinessException("标签名称不能为空!");
labelName = labelName.Trim();
return await _articleLabelService.InsertAsync(labelName);
}
}
}