
// 








namespace SafeCampus.Web.Core;

/// <summary>
/// 职位管理控制器
/// </summary>
[ApiDescriptionSettings(Tag = "职位管理")]
[Route("sys/organization/[controller]")]
[SuperAdmin]
public class PositionController : BaseController
{
    private readonly ISysPositionService _sysPositionService;

    public PositionController(ISysPositionService sysPositionService)
    {
        _sysPositionService = sysPositionService;
    }

    #region Get

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

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

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

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

    #endregion

    #region Post

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

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

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

    #endregion
}
