using Long.Common.Basedata;
using Long.Core.Api;
using Long.Core.Query;
using Long.Service.AdminService.Basedata;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace WebApi.Controllers.Basedata;

[Route("api/Basedata/[controller]")]
[ApiController]
public class SystemUserController : AdminControllerBase
{
    private readonly ISystemUserService _systemUserService;

    /// <summary>
    /// 构造
    /// </summary>
    /// <param name="systemUserService"></param>
    public SystemUserController(ISystemUserService systemUserService)
    {
        _systemUserService = systemUserService;
    }

    /// <summary>
    /// 获取系统用户列表
    /// </summary>
    /// <param name="queryParamater">查询参数</param>
    /// <returns>系统用户列表</returns>
    [HttpGet("Get")]
    public async Task<ApiResult<IEnumerable<SystemUser>>> Get([FromQuery] QueryParamenter queryParamater)
    {
        var output = new ApiResult<IEnumerable<SystemUser>>();
        output.Result = await _systemUserService.Get(queryParamater);
        return output;
    }

    /// <summary>
    /// 获取当前用户
    /// </summary>
    /// <returns>当前用户</returns>
    [HttpGet("GetCurrent")]
    public async Task<ApiResult<SystemUser>> GetCurrent()
    {
        var result = new ApiResult<SystemUser>();
        result.Result = await _systemUserService.GetById(CurrentUserId);

        return result;
    }
}
