部分功能新增数据缓存
This commit is contained in:
parent
89293adcf0
commit
0e83ba64ce
@ -202,10 +202,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
{
|
{
|
||||||
return ToResponse(ResultCode.CAPTCHA_ERROR, "验证码错误");
|
return ToResponse(ResultCode.CAPTCHA_ERROR, "验证码错误");
|
||||||
}
|
}
|
||||||
if (UserConstants.NOT_UNIQUE.Equals(sysUserService.CheckUserNameUnique(dto.Username)))
|
|
||||||
{
|
|
||||||
return ToResponse(ResultCode.CUSTOM_ERROR, $"保存用户{dto.Username}失败,注册账号已存在");
|
|
||||||
}
|
|
||||||
SysUser user = sysUserService.Register(dto);
|
SysUser user = sysUserService.Register(dto);
|
||||||
if (user.UserId > 0)
|
if (user.UserId > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -205,6 +205,7 @@ namespace ZR.Service
|
|||||||
JoinType.Left, rm.Role_id == ur.RoleId,
|
JoinType.Left, rm.Role_id == ur.RoleId,
|
||||||
JoinType.Left, ur.RoleId == r.RoleId
|
JoinType.Left, ur.RoleId == r.RoleId
|
||||||
))
|
))
|
||||||
|
.WithCache(60 * 10)
|
||||||
.Where((m, rm, ur, r) => m.Status == "0" && r.Status == 0 && ur.UserId == userId)
|
.Where((m, rm, ur, r) => m.Status == "0" && r.Status == 0 && ur.UserId == userId)
|
||||||
.Select((m, rm, ur, r) => m).ToList();
|
.Select((m, rm, ur, r) => m).ToList();
|
||||||
var menuList = menus.Where(f => !string.IsNullOrEmpty(f.Perms));
|
var menuList = menus.Where(f => !string.IsNullOrEmpty(f.Perms));
|
||||||
@ -281,6 +282,7 @@ namespace ZR.Service
|
|||||||
int parentId = menu.ParentId != null ? (int)menu.ParentId : 0;
|
int parentId = menu.ParentId != null ? (int)menu.ParentId : 0;
|
||||||
|
|
||||||
var list = Queryable()
|
var list = Queryable()
|
||||||
|
.WithCache(60 * 10)
|
||||||
.WhereIF(!string.IsNullOrEmpty(menu.MenuName), it => it.MenuName.Contains(menu.MenuName))
|
.WhereIF(!string.IsNullOrEmpty(menu.MenuName), it => it.MenuName.Contains(menu.MenuName))
|
||||||
.WhereIF(!string.IsNullOrEmpty(menu.Visible), it => it.Visible == menu.Visible)
|
.WhereIF(!string.IsNullOrEmpty(menu.Visible), it => it.Visible == menu.Visible)
|
||||||
.WhereIF(!string.IsNullOrEmpty(menu.Status), it => it.Status == menu.Status)
|
.WhereIF(!string.IsNullOrEmpty(menu.Status), it => it.Status == menu.Status)
|
||||||
|
|||||||
@ -294,6 +294,7 @@ namespace ZR.Service
|
|||||||
public List<SysRole> SelectUserRoleListByUserId(long userId)
|
public List<SysRole> SelectUserRoleListByUserId(long userId)
|
||||||
{
|
{
|
||||||
return Context.Queryable<SysUserRole>()
|
return Context.Queryable<SysUserRole>()
|
||||||
|
.WithCache(60 * 10)
|
||||||
.LeftJoin<SysRole>((ur, r) => ur.RoleId == r.RoleId)
|
.LeftJoin<SysRole>((ur, r) => ur.RoleId == r.RoleId)
|
||||||
.Where((ur, r) => ur.UserId == userId && r.RoleId > 0)
|
.Where((ur, r) => ur.UserId == userId && r.RoleId > 0)
|
||||||
.Select((ur, r) => r)
|
.Select((ur, r) => r)
|
||||||
|
|||||||
@ -64,11 +64,12 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<SysUser> GetSysUsersByRoleId(long roleId)
|
public List<SysUser> GetSysUsersByRoleId(long roleId)
|
||||||
{
|
{
|
||||||
return Context.Queryable<SysUserRole, SysUser > ((t1, u) => new JoinQueryInfos(
|
return Context.Queryable<SysUserRole, SysUser>((t1, u) => new JoinQueryInfos(
|
||||||
JoinType.Left, t1.UserId == u.UserId))
|
JoinType.Left, t1.UserId == u.UserId))
|
||||||
.Where((t1, u) => t1.RoleId == roleId && u.DelFlag == 0)
|
.WithCache(60 * 10)
|
||||||
.Select((t1, u) => u)
|
.Where((t1, u) => t1.RoleId == roleId && u.DelFlag == 0)
|
||||||
.ToList();
|
.Select((t1, u) => u)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -2,7 +2,6 @@ using Infrastructure;
|
|||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
using Infrastructure.Extensions;
|
using Infrastructure.Extensions;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using SqlSugar.IOC;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -81,7 +80,8 @@ namespace ZR.Service
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public SysUser SelectUserById(long userId)
|
public SysUser SelectUserById(long userId)
|
||||||
{
|
{
|
||||||
var user = Queryable().Filter(null, true).Where(f => f.UserId == userId).First();
|
var user = Queryable().Filter(null, true).WithCache(60 * 5)
|
||||||
|
.Where(f => f.UserId == userId).First();
|
||||||
if (user != null && user.UserId > 0)
|
if (user != null && user.UserId > 0)
|
||||||
{
|
{
|
||||||
user.Roles = RoleService.SelectUserRoleListByUserId(userId);
|
user.Roles = RoleService.SelectUserRoleListByUserId(userId);
|
||||||
@ -219,12 +219,13 @@ namespace ZR.Service
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public SysUser Register(RegisterDto dto)
|
public SysUser Register(RegisterDto dto)
|
||||||
{
|
{
|
||||||
//密码md5
|
|
||||||
string password = NETCore.Encrypt.EncryptProvider.Md5(dto.Password);
|
|
||||||
if (!Tools.PasswordStrength(dto.Password))
|
if (!Tools.PasswordStrength(dto.Password))
|
||||||
{
|
{
|
||||||
throw new CustomException("密码强度不符合要求");
|
throw new CustomException("密码强度不符合要求");
|
||||||
}
|
}
|
||||||
|
//密码md5
|
||||||
|
string password = NETCore.Encrypt.EncryptProvider.Md5(dto.Password);
|
||||||
|
|
||||||
SysUser user = new()
|
SysUser user = new()
|
||||||
{
|
{
|
||||||
Create_time = DateTime.Now,
|
Create_time = DateTime.Now,
|
||||||
@ -235,7 +236,10 @@ namespace ZR.Service
|
|||||||
DeptId = 0,
|
DeptId = 0,
|
||||||
Remark = "用户注册"
|
Remark = "用户注册"
|
||||||
};
|
};
|
||||||
|
if (UserConstants.NOT_UNIQUE.Equals(CheckUserNameUnique(dto.Username)))
|
||||||
|
{
|
||||||
|
throw new CustomException($"保存用户{dto.Username}失败,注册账号已存在");
|
||||||
|
}
|
||||||
user.UserId = Insertable(user).ExecuteReturnIdentity();
|
user.UserId = Insertable(user).ExecuteReturnIdentity();
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
@ -300,7 +304,7 @@ namespace ZR.Service
|
|||||||
x.TotalList.Count);
|
x.TotalList.Count);
|
||||||
//输出统计
|
//输出统计
|
||||||
Console.WriteLine(msg);
|
Console.WriteLine(msg);
|
||||||
|
|
||||||
//输出错误信息
|
//输出错误信息
|
||||||
foreach (var item in x.ErrorList)
|
foreach (var item in x.ErrorList)
|
||||||
{
|
{
|
||||||
@ -310,7 +314,7 @@ namespace ZR.Service
|
|||||||
{
|
{
|
||||||
Console.WriteLine("userName为" + item.Item.UserName + " : " + item.StorageMessage);
|
Console.WriteLine("userName为" + item.Item.UserName + " : " + item.StorageMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (msg, x.ErrorList, x.IgnoreList);
|
return (msg, x.ErrorList, x.IgnoreList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user