You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.1 KiB
C#

using Microsoft.AspNetCore.Mvc;
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service;
namespace SlnMesnac.Controllers
{
/// <summary>
/// 人员基础信息
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class BaseUserController : ControllerBase
{
private readonly ILogger<BaseUserController> _logger;
private readonly IBaseUserService _service;
/// <summary>
///
/// </summary>
/// <param name="logger"></param>
/// <param name="service"></param>
public BaseUserController(ILogger<BaseUserController> logger, IBaseUserService service)
{
_logger = logger;
_service = service;
}
/// <summary>
/// 获取人员基础信息
/// </summary>
/// <returns></returns>
[HttpGet]
public IEnumerable<BaseUser> Get()
{
IEnumerable<BaseUser> users = null;
try
{
users = _service.GetUsers();
}
catch (Exception ex)
{
_logger.LogError($"获取用户信息接口调用异常:{ex.Message}");
}
return users;
}
/// <summary>
/// 通过用户名称获取指定用户信息
/// </summary>
/// <param name="userName">用户名称</param>
/// <returns></returns>
[HttpGet("Gets/{userName}")]
public IEnumerable<BaseUser> GetUserByUserName(string userName)
{
IEnumerable<BaseUser> users = null;
try
{
users = _service.GetUsers();
}
catch (Exception ex)
{
_logger.LogError($"获取用户信息接口调用异常:{ex.Message}");
}
return users;
}
/// <summary>
/// 添加用户信息
/// </summary>
/// <param name="users">用户列表</param>
/// <returns></returns>
[HttpPost]
public bool InsertUserInfo(List<BaseUser> users)
{
return _service.InsertUsers(users);
}
}
}