using System.Threading.Tasks; using GxPress.Repository.Interface; using GxPress.Request.Department; using GxPress.Result.Department; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using GxPress.Service.Interface.Department; using System.Collections.Generic; using GxPress.Auth; namespace GxPress.Api.AppControllers { [Route("api/app/department")] [ApiController] [Authorize] public class DepartmentController : ControllerBase { private readonly IDepartmentRepository _departmentRepository; private readonly IDepartmentService departmentService; private readonly ILoginContext _loginContext; public DepartmentController(IDepartmentRepository departmentRepository, IDepartmentService departmentService, ILoginContext _loginContext) { _departmentRepository = departmentRepository; this.departmentService = departmentService; this._loginContext = _loginContext; } /// <summary> /// 根据部门ID获取成员以及下级部门 /// </summary> /// <param name="request"></param> /// <returns></returns> [HttpPost("user-list")] public async Task<DepartmentUserResult> GetDepartmentUserResult(DepartmentUserRequest request) { request.UserId = _loginContext.AccountId; return await departmentService.GetDepartmentUserResultAsync(request); } [HttpGet("{userId}")] public async Task<IEnumerable<Entity.Department>> GetUserInDepartmentAsync(int userId) { return await departmentService.GetUserInDepartmentAsync(userId); } } }