zjh
2025-03-07 97a73035e8391fb60cdb26c00f7ff8b05296c68c
StandardPda/MESApplication/Controllers/Base/LoginController.cs
对比新文件
@@ -0,0 +1,108 @@
锘縰sing System.Dynamic;
using MES.Service.Dto.@base;
using MES.Service.service;
using MES.Service.util;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
namespace MESApplication.Controllers.Base;
/// <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);
        }
    }
}