using System.Dynamic;
|
using Microsoft.AspNetCore.Mvc;
|
using NewPdaSqlServer.Dto.@base;
|
using NewPdaSqlServer.service.@base;
|
using NewPdaSqlServer.util;
|
using Newtonsoft.Json.Linq;
|
|
namespace NewPdaSqlServer.Controllers;
|
|
/// <summary>
|
/// 用户
|
/// </summary>
|
[Route("api/[controller]")]
|
[ApiController]
|
public class LoginController : ControllerBase
|
{
|
/// <summary>
|
/// 登录
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost("login")]
|
public ResponseResult login([FromBody] LoginModel model)
|
{
|
//登录
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList =
|
new LoginService().login(model.userID, model.userPass);
|
resultInfos.tbBillList = tbBillList;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 重设密码
|
/// </summary>
|
/// <param name="data"></param>
|
/// <returns></returns>
|
[HttpPost("resetPassword")]
|
public ResponseResult resetPassword([FromBody] JObject data)
|
{
|
var name = data["name"].ToString();
|
var pwd = data["pwd"].ToString();
|
var newPwd = data["newPwd"].ToString();
|
//登录
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList =
|
new LoginService().resetPassword(newPwd, name, pwd);
|
if (tbBillList > 0)
|
return new ResponseResult
|
{
|
status = 0,
|
message = "修改成功",
|
data = resultInfos
|
};
|
return new ResponseResult
|
{
|
status = 1,
|
message = "修改失败",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 用户菜单
|
/// </summary>
|
/// <param name="data"></param>
|
/// <returns></returns>
|
[HttpPost("getUserMenu")]
|
public ResponseResult getUserMenu([FromBody] JObject data)
|
{
|
var name = data["name"].ToString();
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList = new LoginService().getUserMenu(name);
|
resultInfos.tbBillList = tbBillList;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
|
/// <summary>
|
/// 获取账号信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost("getUserInfo")]
|
public ResponseResult getUserInfo([FromBody] dynamic model)
|
{
|
//登录
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var tbBillList =
|
new LoginService().getUserInfo(model.Guid);
|
resultInfos.tbBillList = tbBillList;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
}
|