2024-09-02 09:31:34 +08:00
|
|
|
|
using Bunny.Dao.Dto.System;
|
2024-08-30 16:08:08 +08:00
|
|
|
|
using Bunny.Dao.Entity.System;
|
2024-09-02 09:00:50 +08:00
|
|
|
|
using Bunny.Dao.Model.Result;
|
2024-08-09 00:16:40 +08:00
|
|
|
|
using Bunny.Service.IService;
|
2024-09-02 09:31:34 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components;
|
2024-08-09 00:16:40 +08:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
namespace Bunny.WebApi.Controllers;
|
|
|
|
|
|
2024-08-09 09:26:32 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// BLog相关接口
|
|
|
|
|
/// </summary>
|
2024-09-02 09:31:34 +08:00
|
|
|
|
[Microsoft.AspNetCore.Mvc.Route("/api/[controller]/[action]")]
|
2024-08-09 00:16:40 +08:00
|
|
|
|
public class BlogController : ControllerBase
|
|
|
|
|
{
|
2024-09-02 09:31:34 +08:00
|
|
|
|
[Inject] public required IBlogService BlogService { get; set; }
|
2024-08-09 00:16:40 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加Blog
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dto"></param>
|
|
|
|
|
/// <returns></returns>
|
2024-08-10 04:18:03 +08:00
|
|
|
|
[HttpPost]
|
2024-08-30 16:08:08 +08:00
|
|
|
|
public Result<object> AddBlog(Blog dto)
|
2024-08-09 00:16:40 +08:00
|
|
|
|
{
|
2024-09-02 09:31:34 +08:00
|
|
|
|
BlogService.AddBlog(dto);
|
2024-08-30 16:08:08 +08:00
|
|
|
|
return Result<object>.Success();
|
2024-08-09 00:16:40 +08:00
|
|
|
|
}
|
2024-08-09 09:26:32 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询BLog
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2024-08-10 04:18:03 +08:00
|
|
|
|
[HttpGet]
|
2024-08-09 09:26:32 +08:00
|
|
|
|
public Result<List<Blog>> QueryBlog()
|
|
|
|
|
{
|
2024-09-02 09:31:34 +08:00
|
|
|
|
var vo = BlogService.QueryBlog();
|
2024-08-09 09:26:32 +08:00
|
|
|
|
return Result<List<Blog>>.Success(vo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新Blog内容
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dto"></param>
|
|
|
|
|
/// <returns></returns>
|
2024-08-10 04:18:03 +08:00
|
|
|
|
[HttpPost]
|
2024-09-02 09:31:34 +08:00
|
|
|
|
public Result<object> UpdateBlog(BlogUpdateDto dto)
|
2024-08-09 09:26:32 +08:00
|
|
|
|
{
|
2024-09-02 09:31:34 +08:00
|
|
|
|
BlogService.UpdateBlog(dto);
|
2024-08-30 16:08:08 +08:00
|
|
|
|
return Result<object>.Success();
|
2024-08-09 09:26:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除BLog
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2024-08-10 04:18:03 +08:00
|
|
|
|
[HttpDelete]
|
2024-08-09 09:26:32 +08:00
|
|
|
|
public Result<string> DeleteBlog(string id)
|
|
|
|
|
{
|
2024-09-02 09:31:34 +08:00
|
|
|
|
BlogService.DeleteBlog(id);
|
2024-08-09 09:26:32 +08:00
|
|
|
|
return Result<string>.Success();
|
|
|
|
|
}
|
2024-08-10 04:18:03 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量添加数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public Result<string> AddBatchBlogs(string url)
|
|
|
|
|
{
|
2024-09-02 09:31:34 +08:00
|
|
|
|
BlogService.AddBatchBlogs(url);
|
2024-08-10 04:18:03 +08:00
|
|
|
|
return Result<string>.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量删除BLog
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public Result<string> DeleteBatchBlogs()
|
|
|
|
|
{
|
2024-09-02 09:31:34 +08:00
|
|
|
|
BlogService.DeleteBatchBlogs();
|
2024-08-10 04:18:03 +08:00
|
|
|
|
return Result<string>.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量更新_带事务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public Result<string> UseTransaction()
|
|
|
|
|
{
|
2024-09-02 09:31:34 +08:00
|
|
|
|
BlogService.UseTransaction();
|
2024-08-10 04:18:03 +08:00
|
|
|
|
return Result<string>.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public Result<PageResult<Blog>> QueryPage(int page = 1, int limit = 10)
|
|
|
|
|
{
|
2024-09-02 09:31:34 +08:00
|
|
|
|
var vo = BlogService.QueryPage(page, limit);
|
2024-08-10 04:18:03 +08:00
|
|
|
|
|
|
|
|
|
return Result<PageResult<Blog>>.Success(vo);
|
|
|
|
|
}
|
2024-08-09 00:16:40 +08:00
|
|
|
|
}
|