using Microsoft.AspNetCore.Mvc;
|
using IStation.Model.Api;
|
using System.Net;
|
using System.Net.Http.Headers;
|
using Microsoft.Extensions.Hosting.Internal;
|
using Microsoft.AspNetCore.Http.Extensions;
|
using IStation.Untity;
|
|
namespace IStation.WebApi.Controllers.V1
|
{
|
/// <summary>
|
/// UserLogin标准Api
|
/// </summary>
|
[ApiController]
|
[Route("v1/Standard/UserLogin")]
|
[ApiExplorerSettings(GroupName = "v1")]
|
public class UserLoginController : ControllerBase
|
{
|
private readonly Service.UserLogin _service = new Service.UserLogin();
|
|
/// <summary>
|
/// 标准登录
|
/// </summary>
|
[Route("FromStandard")]
|
[HttpPost]
|
public Result FromStandard(Model.UserLogin model)
|
{
|
if (model == null)
|
{
|
return new Result("参数错误");
|
}
|
if (string.IsNullOrEmpty(model.SoftTag))
|
{
|
return new Result("SoftTag 参数错误");
|
}
|
if (string.IsNullOrEmpty(model.LoginName))
|
{
|
return new Result("LoginName 参数错误");
|
}
|
if (string.IsNullOrEmpty(model.LoginPwd))
|
{
|
return new Result("LoginPwd 参数错误");
|
}
|
|
var response = _service.Login(model.SoftType, model.SoftTag, model.LoginName, model.LoginPwd, HttpContextHelper.GetRemoteIpAddress(HttpContext.Request), null);
|
var vm = new Model.UserLoginSecretResponse()
|
{
|
Status=response.Status,
|
User=response.User==null?null:new Model.UserSecret(response.User)
|
};
|
return new Result<Model.UserLoginSecretResponse>(vm);
|
}
|
|
/// <summary>
|
/// 标准客户登录
|
/// </summary>
|
[Route("FromCorpStandard")]
|
[HttpPost]
|
public Result FromCorpStandard(Model.UserLoginCorp model)
|
{
|
if (model == null)
|
{
|
return new Result("参数错误");
|
}
|
if (model.CorpID < 1)
|
{
|
return new Result("CorpID 参数错误");
|
}
|
if (string.IsNullOrEmpty(model.SoftTag))
|
{
|
return new Result("SoftTag 参数错误");
|
}
|
if (string.IsNullOrEmpty(model.LoginName))
|
{
|
return new Result("LoginName 参数错误");
|
}
|
if (string.IsNullOrEmpty(model.LoginPwd))
|
{
|
return new Result("LoginPwd 参数错误");
|
}
|
|
|
var response = _service.LoginCorp(model.CorpID, model.SoftType, model.SoftTag, model.LoginName, model.LoginPwd, HttpContextHelper.GetRemoteIpAddress(HttpContext.Request), null);
|
var vm = new Model.UserLoginSecretResponse()
|
{
|
Status = response.Status,
|
User = response.User == null ? null : new Model.UserSecret(response.User)
|
};
|
return new Result<Model.UserLoginSecretResponse>(vm);
|
}
|
|
|
|
|
|
}
|
}
|