66 lines
1.5 KiB
C#
66 lines
1.5 KiB
C#
using Bunny.Dao.Models.System;
|
|
using Bunny.Dao.Result;
|
|
using Bunny.Service.IService;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Bunny.WebApi.Controllers;
|
|
|
|
/// <summary>
|
|
/// BLog相关接口
|
|
/// </summary>
|
|
[Route("/api/[controller]")]
|
|
public class BlogController : ControllerBase
|
|
{
|
|
private readonly IBlogService _blogService;
|
|
|
|
public BlogController(IBlogService blogService)
|
|
{
|
|
_blogService = blogService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加Blog
|
|
/// </summary>
|
|
/// <param name="dto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("AddBlog")]
|
|
public Result<string> AddBlog(Blog dto)
|
|
{
|
|
_blogService.AddBlog(dto);
|
|
return Result<string>.Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询BLog
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("QueryBlog")]
|
|
public Result<List<Blog>> QueryBlog()
|
|
{
|
|
var vo = _blogService.QueryBlog();
|
|
return Result<List<Blog>>.Success(vo);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新Blog内容
|
|
/// </summary>
|
|
/// <param name="dto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("UpdateBlog")]
|
|
public Result<string> UpdateBlog(Blog dto)
|
|
{
|
|
_blogService.UpdateBlog(dto);
|
|
return Result<string>.Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除BLog
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpDelete("DeleteBlog")]
|
|
public Result<string> DeleteBlog(string id)
|
|
{
|
|
_blogService.DeleteBlog(id);
|
|
return Result<string>.Success();
|
|
}
|
|
} |