using BPA.SAAS.Manage.Application.Org.Dtos.Role;
using BPA.SAAS.Manage.Application.Org.Interface;
using BPA.SAAS.Manage.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application.Org
{
    [ApiDescriptionSettings("Org", Tag = "角色信息")]
    public class RolesServices: IDynamicApiController
    {
        IRoleService _roleService;
        public RolesServices(IRoleService roleService)
        {
            _roleService=roleService;
        }
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("/api/roles/page")]
        public async Task<PageUtil> Page(RoleDtoPageInput input)
        {
            return await _roleService.Page(input);
        }
        /// <summary>
        /// 根据角色查询角色菜单
        /// </summary>
        /// <param name="RoleId"></param>
        /// <returns></returns>
        [HttpGet("/api/roles/getmenurole")]
        public async Task<List<QueryRoleMenuListDto>> GetMenuRole(string RoleId)
        {
            return await _roleService.GetMenuRole(RoleId);
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("/api/roles/add")]
        public async Task<bool> Add(RoleDtoInput input)
        {
            return await _roleService.Add(input);
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("/api/roles/update")]
        public async Task<bool> Update(RoleDtoInput input)
        {
            return await _roleService.Update(input);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("/api/roles/delete")]
        public async Task<bool> Delete(List<string> input)
        {
            return await _roleService.Delete(input);
        }
        /// <summary>
        /// 编辑角色菜单
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("/api/roles/addorupdatemenurole")]
        public async Task<bool> AddOrUpdateMenuRole(RoleMenuDtoInput input)
        {
            return await _roleService.AddOrUpdateMenuRole(input);
        }
        /// <summary>
        /// 启用
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("/api/roles/enable")]
        public async Task<bool> Enable(string Id)
        {
            return await _roleService.Enable(Id);
        }
        /// <summary>
        /// 禁用
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("/api/roles/disable")]
        public async Task<bool> Disable(string Id)
        {
            return await _roleService.Disable(Id);
        }
        /// <summary>
        /// 获取所有角色
        /// </summary>
        /// <returns></returns>
        [HttpGet("/api/roles/getrole")]
        public async Task<Dictionary<string, object>> GetRole()
        {
            return await _roleService.GetRole();
        }
    }
}
