refactor: 拆分微信API到独立项目并迁移相关代码
1. 新增WeChatApi独立项目,将原WebApi中的微信相关控制器迁移至新项目 2. 新增后台权限管理相关实体、服务接口和基础控制器 3. 完善管理员用户服务,增加角色关联查询和赋值逻辑 4. 修复WebApi Swagger文档过滤微信API版本的问题 5. 更新解决方案文件,添加新的微信API项目引用 6. 新增微信API基础配置文件和项目属性配置
This commit is contained in:
@ -0,0 +1,139 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using QYZH.InteractiveMagazine.IService;
|
||||
using QYZH.InteractiveMagazine.Models.Common;
|
||||
using QYZH.InteractiveMagazine.Models.Dto;
|
||||
using QYZH.InteractiveMagazine.Models.Enum;
|
||||
|
||||
namespace QYZH.InteractiveMagazine.WebApi.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 后台权限管理
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
[ApiExplorerSettings(GroupName = nameof(ApiVersionEnum.Platform))]
|
||||
public class PermissionController(IAdminPermissionService adminPermissionService) : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建菜单
|
||||
/// </summary>
|
||||
[HttpPost("menus")]
|
||||
public async Task<BaseResponse<AdminMenuOutput>> CreateMenuAsync([FromBody] AdminMenuInput input)
|
||||
{
|
||||
var result = await adminPermissionService.CreateMenuAsync(input);
|
||||
return Success(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新菜单
|
||||
/// </summary>
|
||||
[HttpPut("menus/{id}")]
|
||||
public async Task<BaseResponse<AdminMenuOutput>> UpdateMenuAsync(long id, [FromBody] AdminMenuInput input)
|
||||
{
|
||||
var result = await adminPermissionService.UpdateMenuAsync(id, input);
|
||||
return Success(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除菜单
|
||||
/// </summary>
|
||||
[HttpDelete("menus/{id}")]
|
||||
public async Task<BaseResponse<object>> DeleteMenuAsync(long id)
|
||||
{
|
||||
await adminPermissionService.DeleteMenuAsync(id);
|
||||
return Success(new object());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取菜单树
|
||||
/// </summary>
|
||||
[HttpPost("menus/tree")]
|
||||
public async Task<BaseResponse<List<AdminMenuOutput>>> GetMenuTreeAsync([FromBody] AdminMenuQueryInput input)
|
||||
{
|
||||
var result = await adminPermissionService.GetMenuTreeAsync(input);
|
||||
return Success(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前管理员菜单树
|
||||
/// </summary>
|
||||
[HttpGet("menus/current")]
|
||||
public async Task<BaseResponse<List<AdminMenuOutput>>> GetCurrentMenuTreeAsync()
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
BusinessException.ThrowIf(userId == null, "未获取到用户信息", ResultCode.DENY);
|
||||
|
||||
var result = await adminPermissionService.GetAdminUserMenuTreeAsync(userId!.Value);
|
||||
return Success(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建角色
|
||||
/// </summary>
|
||||
[HttpPost("roles")]
|
||||
public async Task<BaseResponse<AdminRoleOutput>> CreateRoleAsync([FromBody] AdminRoleInput input)
|
||||
{
|
||||
var result = await adminPermissionService.CreateRoleAsync(input);
|
||||
return Success(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新角色
|
||||
/// </summary>
|
||||
[HttpPut("roles/{id}")]
|
||||
public async Task<BaseResponse<AdminRoleOutput>> UpdateRoleAsync(long id, [FromBody] AdminRoleInput input)
|
||||
{
|
||||
var result = await adminPermissionService.UpdateRoleAsync(id, input);
|
||||
return Success(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除角色
|
||||
/// </summary>
|
||||
[HttpDelete("roles/{id}")]
|
||||
public async Task<BaseResponse<object>> DeleteRoleAsync(long id)
|
||||
{
|
||||
await adminPermissionService.DeleteRoleAsync(id);
|
||||
return Success(new object());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取角色详情
|
||||
/// </summary>
|
||||
[HttpGet("roles/{id}")]
|
||||
public async Task<BaseResponse<AdminRoleOutput>> GetRoleByIdAsync(long id)
|
||||
{
|
||||
var result = await adminPermissionService.GetRoleByIdAsync(id);
|
||||
return Success(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取角色分页列表
|
||||
/// </summary>
|
||||
[HttpPost("roles/list")]
|
||||
public async Task<BaseResponse<PageListModel<AdminRoleOutput>>> GetRoleListAsync([FromBody] AdminRoleQueryInput input)
|
||||
{
|
||||
var result = await adminPermissionService.GetRoleListAsync(input);
|
||||
return Success(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分配角色菜单
|
||||
/// </summary>
|
||||
[HttpPut("roles/{roleId}/menus")]
|
||||
public async Task<BaseResponse<object>> AssignRoleMenusAsync(long roleId, [FromBody] AssignRoleMenusInput input)
|
||||
{
|
||||
await adminPermissionService.AssignRoleMenusAsync(roleId, input);
|
||||
return Success(new object());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分配管理员角色
|
||||
/// </summary>
|
||||
[HttpPut("users/{adminUserId}/roles")]
|
||||
public async Task<BaseResponse<object>> AssignAdminUserRolesAsync(long adminUserId, [FromBody] AssignAdminUserRolesInput input)
|
||||
{
|
||||
await adminPermissionService.AssignAdminUserRolesAsync(adminUserId, input);
|
||||
return Success(new object());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user