
// 








namespace SafeCampus.Web.Core;

/// <summary>
/// 岗位管理控制器
/// </summary>
[ApiDescriptionSettings("Application", Tag = "岗位管理")]
[Route("biz/organization/position")]
[RolePermission]
public class BizPositionController
{
    private readonly IPositionService _positionService;

    public BizPositionController(IPositionService positionService)
    {
        _positionService = positionService;
    }

    #region Get请求

    /// <summary>
    /// 获取职位树
    /// </summary>
    /// <returns></returns>
    [HttpGet("tree")]
    [DisplayName("获取职位树")]
    public async Task<dynamic> Tree([FromQuery] PositionTreeInput input)
    {
        return await _positionService.Tree(input);
    }

    /// <summary>
    /// 岗位分页查询
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpGet("page")]
    [DisplayName("岗位分页查询")]
    public async Task<dynamic> Page([FromQuery] PositionPageInput input)
    {
        return await _positionService.Page(input);
    }

    /// <summary>
    /// 岗位详情
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpGet("detail")]
    [DisplayName("岗位详情")]
    public async Task<dynamic> Detail([FromQuery] BaseIdInput input)
    {
        return await _positionService.Detail(input);
    }

    /// <summary>
    /// 岗位选择器
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpGet("selector")]
    [DisplayName("岗位选择器")]
    public async Task<dynamic> Selector([FromQuery] PositionSelectorInput input)
    {
        return await _positionService.Selector(input);
    }

    #endregion

    #region Post请求

    /// <summary>
    /// 添加岗位
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("add")]
    [DisplayName("添加岗位")]
    public async Task Add([FromBody] PositionAddInput input)
    {
        await _positionService.Add(input);
    }

    /// <summary>
    /// 修改岗位
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("edit")]
    [DisplayName("修改岗位")]
    public async Task Edit([FromBody] PositionEditInput input)
    {
        await _positionService.Edit(input);
    }

    /// <summary>
    /// 删除岗位
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("delete")]
    [DisplayName("删除岗位")]
    public async Task Delete([FromBody] BaseIdListInput input)
    {
        await _positionService.Delete(input);
    }

    #endregion
}
