using System.Threading.Tasks;
using GxPress.Repository.Interface;
using GxPress.Request.Department;
using GxPress.Result.Department;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace GxPress.Api.AppControllers
{
    [Route("api/app/department")]
    [ApiController]
    [Authorize]
    public class DepartmentController : ControllerBase
    {
        private readonly IDepartmentRepository _departmentRepository;

        public DepartmentController(IDepartmentRepository departmentRepository)
        {
            _departmentRepository = departmentRepository;
        }

        /// <summary>
        /// 根据部门ID获取成员以及下级部门
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("user-list")]
        public async Task<DepartmentUserResult> GetDepartmentUserResult(DepartmentUserRequest request)
        {
            return await _departmentRepository.GetDepartmentUserResultAsync(request);
        }
    }
}