This commit is contained in:
qianhao.xu
2024-01-04 09:01:03 +08:00
parent 8935a6ff97
commit b8f030b68b
436 changed files with 43639 additions and 15 deletions

View File

@@ -63,7 +63,11 @@ namespace ZR.Admin.WebApi.Controllers.System
public IActionResult Login([FromBody] LoginBodyDto loginBody)
{
if (loginBody == null) { throw new CustomException("请求参数错误"); }
// todo: HttpContext存了什么东西
//todo: ControllerBase.HttpContext和httpContextAccessor.HttpContext 有啥区别啊???
loginBody.LoginIP = HttpContextExtension.GetClientUserIp(HttpContext);
//todo 判断验证码
SysConfig sysConfig = sysConfigService.GetSysConfigByKey("sys.account.captchaOnOff");
if (sysConfig?.ConfigValue != "off" && !SecurityCodeHelper.Validate(loginBody.Uuid, loginBody.Code))
{
@@ -75,10 +79,14 @@ namespace ZR.Admin.WebApi.Controllers.System
List<SysRole> roles = roleService.SelectUserRoleListByUserId(user.UserId);
//权限集合 eg *:*:*,system:user:list
List<string> permissions = permissionService.GetMenuPermission(user);
// 权限
LoginUser loginUser = new(user, roles, permissions);
//todo 把权限加到缓存里
CacheService.SetUserPerms(GlobalConstant.UserPermKEY + user.UserId, permissions);
Console.WriteLine("1 用户信息--》" + HttpContext.User.Identity.Name);
return SUCCESS(JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser), jwtSettings.JwtSettings));
}
@@ -168,7 +176,7 @@ namespace ZR.Admin.WebApi.Controllers.System
Browser = clientInfo.ToString(),
Os = clientInfo.OS.ToString(),
Ipaddr = ipAddr,
UserName = context.GetName(),
UserName = context.GetName(),//空的 获取不到 null
LoginLocation = ip_info?.Province + "-" + ip_info?.City
};

View File

@@ -6,6 +6,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Text.Json;
using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Model.mes.md;
using ZR.Model.mes.pro;
using ZR.Model.MES.pro.DTO;
@@ -52,6 +53,7 @@ namespace ZR.Admin.WebApi.Controllers.MES.pro
/// <param name="week"></param>
/// <param name="date"></param>
/// <returns></returns>
[HttpGet("GetGanttList")]
public IActionResult GetGanttList(int year = -1, int week = -1, int date = -1)
{