109 lines
2.6 KiB
C#
109 lines
2.6 KiB
C#
|
using Bunny.Common.Attribute;
|
|||
|
using Bunny.Dao.Common.Result;
|
|||
|
using Bunny.Dao.Dto.System;
|
|||
|
using Bunny.Dao.Entity.System.User;
|
|||
|
using Bunny.Service.IService;
|
|||
|
using Microsoft.AspNetCore.Components;
|
|||
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
|
|||
|
namespace Bunny.WebApi.Controllers;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// BLog相关接口
|
|||
|
/// </summary>
|
|||
|
[Microsoft.AspNetCore.Mvc.Route("/api/[controller]/[action]")]
|
|||
|
public class UserController : ControllerBase
|
|||
|
{
|
|||
|
[Inject] public required IUserService UserService { get; set; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 添加Blog
|
|||
|
/// </summary>
|
|||
|
/// <param name="dto"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
public Result<object> AddBlog(Users dto)
|
|||
|
{
|
|||
|
UserService.AddBlog(dto);
|
|||
|
return Result<object>.Success();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 查询BLog
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpGet]
|
|||
|
[Cacheable("QueryBlog", "00:00:59")]
|
|||
|
public Result<List<Users>> QueryBlog()
|
|||
|
{
|
|||
|
var vo = UserService.QueryBlog();
|
|||
|
return Result<List<Users>>.Success(vo);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 更新Blog内容
|
|||
|
/// </summary>
|
|||
|
/// <param name="dto"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
public Result<object> UpdateBlog(BlogUpdateDto dto)
|
|||
|
{
|
|||
|
UserService.UpdateBlog(dto);
|
|||
|
return Result<object>.Success();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 删除BLog
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpDelete]
|
|||
|
public Result<string> DeleteBlog(string id)
|
|||
|
{
|
|||
|
UserService.DeleteBlog(id);
|
|||
|
return Result<string>.Success();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 批量添加数据
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
public Result<string> AddBatchBlogs(string url)
|
|||
|
{
|
|||
|
UserService.AddBatchBlogs(url);
|
|||
|
return Result<string>.Success();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 批量删除BLog
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpGet]
|
|||
|
public Result<string> DeleteBatchBlogs()
|
|||
|
{
|
|||
|
UserService.DeleteBatchBlogs();
|
|||
|
return Result<string>.Success();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 批量更新_带事务
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpGet]
|
|||
|
public Result<string> UseTransaction()
|
|||
|
{
|
|||
|
UserService.UseTransaction();
|
|||
|
return Result<string>.Success();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 分页查询
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
public async Task<Result<PageResult<Users>>> QueryPage(int page = 1, int limit = 10)
|
|||
|
{
|
|||
|
var vo = await UserService.QueryPage(page, limit);
|
|||
|
return Result<PageResult<Users>>.Success(vo);
|
|||
|
}
|
|||
|
}
|