2024-09-12 13:56:09 +08:00
|
|
|
|
using Bunny.Common.Attribute;
|
|
|
|
|
using Bunny.Dao.Common.Result;
|
2024-09-02 21:28:21 +08:00
|
|
|
|
using Bunny.Dao.Dto.System;
|
2024-09-12 09:59:18 +08:00
|
|
|
|
using Bunny.Dao.Entity.System.User;
|
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-12 09:59:18 +08:00
|
|
|
|
[Inject] public required IUserService UserService { 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-09-12 09:59:18 +08:00
|
|
|
|
public Result<object> AddBlog(Users dto)
|
2024-08-09 00:16:40 +08:00
|
|
|
|
{
|
2024-09-12 09:59:18 +08:00
|
|
|
|
UserService.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-09-12 13:56:09 +08:00
|
|
|
|
[Cacheable("QueryBlog", "00:00:59")]
|
2024-09-12 09:59:18 +08:00
|
|
|
|
public Result<List<Users>> QueryBlog()
|
2024-08-09 09:26:32 +08:00
|
|
|
|
{
|
2024-09-12 09:59:18 +08:00
|
|
|
|
var vo = UserService.QueryBlog();
|
|
|
|
|
return Result<List<Users>>.Success(vo);
|
2024-08-09 09:26:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <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-12 09:59:18 +08:00
|
|
|
|
UserService.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-12 09:59:18 +08:00
|
|
|
|
UserService.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-12 09:59:18 +08:00
|
|
|
|
UserService.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-12 09:59:18 +08:00
|
|
|
|
UserService.DeleteBatchBlogs();
|
2024-08-10 04:18:03 +08:00
|
|
|
|
return Result<string>.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量更新_带事务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public Result<string> UseTransaction()
|
|
|
|
|
{
|
2024-09-12 09:59:18 +08:00
|
|
|
|
UserService.UseTransaction();
|
2024-08-10 04:18:03 +08:00
|
|
|
|
return Result<string>.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
2024-09-12 09:59:18 +08:00
|
|
|
|
public Result<PageResult<Users>> QueryPage(int page = 1, int limit = 10)
|
2024-08-10 04:18:03 +08:00
|
|
|
|
{
|
2024-09-12 09:59:18 +08:00
|
|
|
|
var vo = UserService.QueryPage(page, limit);
|
2024-08-10 04:18:03 +08:00
|
|
|
|
|
2024-09-12 09:59:18 +08:00
|
|
|
|
return Result<PageResult<Users>>.Success(vo);
|
2024-08-10 04:18:03 +08:00
|
|
|
|
}
|
2024-08-09 00:16:40 +08:00
|
|
|
|
}
|