You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

82 lines
2.6 KiB

using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using Znyc.Cloudcar.Admin.AspNetCore.Controllers;
using Znyc.Cloudcar.Admin.AspNetCore.Entitys;
using Znyc.Cloudcar.Admin.AspNetCore.Mvc;
using Znyc.Cloudcar.Admin.Commons.Entitys;
using Znyc.Cloudcar.Admin.Security.Dtos;
using Znyc.Cloudcar.Admin.Security.Entitys;
using Znyc.Cloudcar.Admin.Security.IServices;
namespace Znyc.Cloudcar.Admin.WebApi.Controllers
{
/// <summary>
/// 角色数据权限接口
/// </summary>
[ApiController]
[Route("api/Security/[controller]")]
public class
RoleDataController : AreaApiController<RoleDataEntity, RoleDataOutputDto, RoleDataInputDto, IRoleDataService,
long>
{
/// <summary>
/// 构造函数
/// </summary>
/// <param name="service"></param>
public RoleDataController(IRoleDataService service) : base(service)
{
_service = service;
}
/// <summary>
/// 新增前处理数据
/// </summary>
/// <param name="info"></param>
protected override void OnBeforeInsert(RoleDataEntity info)
{
info.Id = 0;
}
/// <summary>
/// 在更新数据前对数据的修改操作
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
protected override void OnBeforeUpdate(RoleDataEntity info)
{
}
/// <summary>
/// 在软删除数据前对数据的修改操作
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
protected override void OnBeforeSoftDelete(RoleDataEntity info)
{
}
/// <summary>
/// 角色可以访问数据
/// </summary>
/// <param name="roleId">角色Id</param>
/// <returns></returns>
[HttpGet("GetAllRoleDataByRoleId")]
[FunctionAuthorize("List")]
public async Task<IActionResult> GetAllRoleDataByRoleId(string roleId)
{
CommonResult result = new CommonResult();
string where = string.Format("RoleId='{0}'", roleId);
List<string> resultlist = new List<string>();
IEnumerable<RoleDataEntity> list = await _service.GetListWhereAsync(where);
foreach (RoleDataEntity info in list)
{
resultlist.Add(info.AuthorizeData);
}
result.ResData = resultlist;
result.ErrCode = ErrCode.successCode;
return ToJsonContent(result);
}
}
}