using Infrastructure;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App;
using OpenAuth.App.Request;
using OpenAuth.Repository.Domain;

namespace OpenAuth.WebApi.Controllers
{
    /// <summary>
    /// 职级组
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SysPosGroupController : ControllerBase
    {
        SysPosGroupApp posGroupApp;
        public SysPosGroupController(SysPosGroupApp sysPosGroupApp)
        {
            posGroupApp = sysPosGroupApp;
        }

        /// <summary>
        /// 职级组查询
        /// key 为空，查全部
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<List<SysPosGroup>>> Load(string name)
        {
            return await posGroupApp.Load(name);
        }

        /// <summary>
        /// 职级组添加
        /// </summary>
        /// <param name="pos"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> Add(PosGroupForm pos)
        {
            return await posGroupApp.Add(pos);
        }
    }
}
