updates
This commit is contained in:
parent
954b15b9b6
commit
683432317f
|
|
@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
|
|
@ -26,6 +27,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
|
@ -35,6 +37,7 @@ import javax.crypto.spec.IvParameterSpec;
|
|||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.security.Security;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -59,6 +62,8 @@ public class MiniUserController {
|
|||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Autowired
|
||||
public RedisTemplate redisTemplate;
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
@Autowired
|
||||
private MiniUserService miniUserService;
|
||||
|
|
@ -151,7 +156,8 @@ public class MiniUserController {
|
|||
result.error500("用户名或密码错误");
|
||||
return result;
|
||||
}
|
||||
|
||||
//仅保留一端登录
|
||||
oneUserLogin(sysUser);
|
||||
//用户登录信息
|
||||
//1.生成token
|
||||
String token = JwtUtil.sign(sysUser.getUsername(), syspassword);
|
||||
|
|
@ -175,7 +181,6 @@ public class MiniUserController {
|
|||
return Result.OK(obj);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/phoneLogin")
|
||||
@ApiOperation(value = "微信小程序手机号登录")
|
||||
public Result<?> wechatLogin(@NotNull @RequestBody WxModel wxModel) {
|
||||
|
|
@ -219,6 +224,9 @@ public class MiniUserController {
|
|||
sysUserService.updateById(user);
|
||||
}
|
||||
}
|
||||
//仅保留一端登录
|
||||
oneUserLogin(user);
|
||||
|
||||
String username = user.getUsername();
|
||||
String syspassword = user.getPassword();
|
||||
//1.生成token
|
||||
|
|
@ -264,7 +272,6 @@ public class MiniUserController {
|
|||
return Result.OK();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/dy/login")
|
||||
@ApiOperation("抖音-登录接口")
|
||||
public Result<?> dyLogin(@RequestBody DyLoginVo vo) {
|
||||
|
|
@ -307,6 +314,10 @@ public class MiniUserController {
|
|||
user.setOrgCode(null);
|
||||
sysUserService.saveUser(user, null, null, null);
|
||||
}
|
||||
|
||||
//仅保留一端登录
|
||||
oneUserLogin(user);
|
||||
|
||||
String username = user.getUsername();
|
||||
String syspassword = user.getPassword();
|
||||
//1.生成token
|
||||
|
|
@ -370,6 +381,23 @@ public class MiniUserController {
|
|||
return Result.OK(2);
|
||||
}
|
||||
|
||||
|
||||
public void oneUserLogin(SysUser user){
|
||||
//仅保留一端登录
|
||||
Collection<String> keys = redisTemplate.keys(CommonConstant.PREFIX_USER_TOKEN + "*");
|
||||
for (String token : keys) {
|
||||
SysUser sysUser = sysUserService.getUserByName(JwtUtil.getUsername(token));
|
||||
if (sysUser.getId().equals(user.getId())) {
|
||||
//清空用户登录Token缓存
|
||||
redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token);
|
||||
//清空用户登录Shiro权限缓存
|
||||
redisUtil.del(CommonConstant.PREFIX_USER_SHIRO_CACHE + sysUser.getId());
|
||||
//清空用户的缓存信息(包括部门信息),例如sys:cache:user::<username>
|
||||
redisUtil.del(String.format("%s::%s", CacheConstant.SYS_USERS_CACHE, sysUser.getUsername()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String phoneDecrypt(String encrypted, String sessionKey, String iv) {
|
||||
String phoneNumber = null;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
|
@ -15,10 +13,8 @@ import org.apache.commons.collections.CollectionUtils;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.yx.entity.YxMajor;
|
||||
import org.jeecg.modules.yx.entity.YxSchool;
|
||||
import org.jeecg.modules.yx.entity.YxSchoolDoubleFirstPlan;
|
||||
import org.jeecg.modules.yx.entity.YxSubjectEvaluation;
|
||||
import org.jeecg.modules.yx.service.IYxSchoolService;
|
||||
import org.jeecg.modules.yx.service.IYxSubjectEvaluationService;
|
||||
|
|
@ -29,17 +25,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
|
|
|
|||
Loading…
Reference in New Issue