Files
Yi.Admin/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RABC/RoleController.cs

119 lines
3.7 KiB
C#
Raw Normal View History

2022-04-16 00:16:32 +08:00
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
2023-01-02 14:29:16 +08:00
using Yi.Framework.DtoModel.Base.Dto;
2022-04-16 00:16:32 +08:00
using Yi.Framework.Interface;
2023-01-01 23:06:11 +08:00
using Yi.Framework.Interface.RABC;
using Yi.Framework.Model.RABC.Entitys;
2022-04-16 00:16:32 +08:00
using Yi.Framework.Repository;
using Yi.Framework.Service;
2022-04-16 00:16:32 +08:00
using Yi.Framework.WebCore;
using Yi.Framework.WebCore.AttributeExtend;
using Yi.Framework.WebCore.AuthorizationPolicy;
namespace Yi.Framework.ApiMicroservice.Controllers
{
2022-04-26 01:31:14 +08:00
/// <summary>
/// 角色管理
/// </summary>
2022-04-16 00:16:32 +08:00
[ApiController]
[Route("api/[controller]/[action]")]
2022-09-11 15:55:08 +08:00
public class RoleController : BaseSimpleRdController<RoleEntity>
2022-04-16 00:16:32 +08:00
{
private IRoleService _iRoleService;
public RoleController(ILogger<RoleEntity> logger, IRoleService iRoleService) : base(logger, iRoleService)
{
_iRoleService = iRoleService;
}
2022-04-26 01:31:14 +08:00
2022-09-09 16:52:32 +08:00
/// <summary>
/// 动态条件分页查询
/// </summary>
/// <returns></returns>
2022-10-24 21:22:03 +08:00
[Permission("system:role:query")]
[HttpGet]
2022-09-09 16:52:32 +08:00
public async Task<Result> PageList([FromQuery] RoleEntity role, [FromQuery] PageParModel page)
{
2022-09-09 16:52:32 +08:00
return Result.Success().SetData(await _iRoleService.SelctPageList(role, page));
}
2022-09-09 16:52:32 +08:00
2022-04-26 01:31:14 +08:00
/// <summary>
/// 给多用户设置多角色
/// </summary>
/// <param name="giveRoleSetMenuDto"></param>
/// <returns></returns>
[HttpPut]
2022-10-24 21:22:03 +08:00
[Permission("system:role:edit")]
2022-04-26 01:31:14 +08:00
public async Task<Result> GiveRoleSetMenu(GiveRoleSetMenuDto giveRoleSetMenuDto)
{
return Result.Success().SetStatus(await _iRoleService.GiveRoleSetMenu(giveRoleSetMenuDto.RoleIds, giveRoleSetMenuDto.MenuIds));
}
2022-09-11 14:52:54 +08:00
/// <summary>
/// 添加角色包含菜单
/// </summary>
/// <param name="roleDto"></param>
/// <returns></returns>
2022-10-24 21:22:03 +08:00
[Permission("system:role:add")]
2022-09-11 14:52:54 +08:00
[HttpPost]
2022-09-11 15:55:08 +08:00
public async Task<Result> Add(RoleInfoDto roleDto)
2022-09-11 14:52:54 +08:00
{
return Result.Success().SetData(await _iRoleService.AddInfo(roleDto));
}
/// <summary>
/// 更新角色信息
/// </summary>
/// <returns></returns>
2022-10-24 21:22:03 +08:00
[Permission("system:role:edit")]
[HttpPut]
2022-09-11 15:55:08 +08:00
public async Task<Result> Update(RoleInfoDto roleDto)
{
return Result.Success().SetStatus(await _iRoleService.UpdateInfo(roleDto));
}
2022-09-11 16:49:40 +08:00
/// <summary>
/// 更改角色状态
/// </summary>
/// <param name="roleId"></param>
/// <param name="isDel"></param>
/// <returns></returns>
2022-10-24 21:22:03 +08:00
[Permission("system:role:edit")]
2022-09-11 16:49:40 +08:00
[HttpPut]
public async Task<Result> UpdateStatus(long roleId, bool isDel)
{
return Result.Success().SetData(await _iRoleService._repository.UpdateIgnoreNullAsync(new RoleEntity() { Id = roleId, IsDeleted = isDel }));
}
2022-09-15 19:45:51 +08:00
2022-09-16 18:57:32 +08:00
/// <summary>
///更改角色数据权限
/// </summary>
/// <returns></returns>
2022-10-24 21:22:03 +08:00
[Permission("system:role:edit")]
2022-09-16 18:57:32 +08:00
[HttpPut]
public async Task<Result> UpdateDataScpoce(RoleInfoDto roleDto)
{
return Result.Success().SetStatus(await _iRoleService.UpdateDataScpoce(roleDto));
}
2022-10-24 21:22:03 +08:00
/// <summary>
/// 删除
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
[Permission("system:role:remove")]
[HttpDelete]
public override async Task<Result> DelList(List<long> ids)
{
return await base.DelList(ids);
}
2022-04-16 00:16:32 +08:00
}
}