yshop1.8.2移除idworker,移动端springsecuriry+jwt验证改进,明细可登陆后台查看
This commit is contained in:
@ -33,16 +33,20 @@ public class OnlineController {
|
||||
@ApiOperation("查询在线用户")
|
||||
@GetMapping
|
||||
@PreAuthorize("@el.check()")
|
||||
public ResponseEntity<Object> getAll(String filter, Pageable pageable){
|
||||
return new ResponseEntity<>(onlineUserService.getAll(filter, pageable),HttpStatus.OK);
|
||||
public ResponseEntity<Object> getAll(@RequestParam(value = "filter",defaultValue = "") String filter,
|
||||
@RequestParam(value = "type",defaultValue = "0") int type,
|
||||
Pageable pageable){
|
||||
return new ResponseEntity<>(onlineUserService.getAll(filter, type,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check()")
|
||||
public void download(HttpServletResponse response, String filter) throws IOException {
|
||||
onlineUserService.download(onlineUserService.getAll(filter), response);
|
||||
public void download(HttpServletResponse response,
|
||||
@RequestParam(value = "filter",defaultValue = "") String filter,
|
||||
@RequestParam(value = "type",defaultValue = "0") int type) throws IOException {
|
||||
onlineUserService.download(onlineUserService.getAll(filter,type), response);
|
||||
}
|
||||
|
||||
@ApiOperation("踢出用户")
|
||||
@ -55,4 +59,15 @@ public class OnlineController {
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("踢出移动端用户")
|
||||
@PostMapping("/delete" )
|
||||
@PreAuthorize("@el.check()")
|
||||
public ResponseEntity<Object> deletet(@RequestBody Set<String> keys) throws Exception {
|
||||
//if(StrUtil.isNotEmpty("22")) throw new BadRequestException("演示环境禁止操作");
|
||||
for (String key : keys) {
|
||||
onlineUserService.kickOutT(key);
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
@ -55,8 +55,8 @@ public class OnlineUserService {
|
||||
* @param pageable /
|
||||
* @return /
|
||||
*/
|
||||
public Map<String,Object> getAll(String filter, Pageable pageable){
|
||||
List<OnlineUser> onlineUsers = getAll(filter);
|
||||
public Map<String,Object> getAll(String filter, int type, Pageable pageable){
|
||||
List<OnlineUser> onlineUsers = getAll(filter,type);
|
||||
return PageUtil.toPage(
|
||||
PageUtil.toPage(pageable.getPageNumber(),pageable.getPageSize(),onlineUsers),
|
||||
onlineUsers.size()
|
||||
@ -68,8 +68,15 @@ public class OnlineUserService {
|
||||
* @param filter /
|
||||
* @return /
|
||||
*/
|
||||
public List<OnlineUser> getAll(String filter){
|
||||
List<String> keys = redisUtils.scan(properties.getOnlineKey() + "*");
|
||||
public List<OnlineUser> getAll(String filter,int type){
|
||||
List<String> keys = null;
|
||||
if(type == 1){
|
||||
keys = redisUtils.scan("m-online-token*");
|
||||
}else{
|
||||
keys = redisUtils.scan(properties.getOnlineKey() + "*");
|
||||
}
|
||||
|
||||
|
||||
Collections.reverse(keys);
|
||||
List<OnlineUser> onlineUsers = new ArrayList<>();
|
||||
for (String key : keys) {
|
||||
@ -94,6 +101,19 @@ public class OnlineUserService {
|
||||
public void kickOut(String key) throws Exception {
|
||||
key = properties.getOnlineKey() + EncryptUtils.desDecrypt(key);
|
||||
redisUtils.del(key);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 踢出移动端用户
|
||||
* @param key /
|
||||
* @throws Exception /
|
||||
*/
|
||||
public void kickOutT(String key) throws Exception {
|
||||
|
||||
String keyt = "m-online-token" + EncryptUtils.desDecrypt(key);
|
||||
redisUtils.del(keyt);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -140,7 +160,7 @@ public class OnlineUserService {
|
||||
* @param userName 用户名
|
||||
*/
|
||||
public void checkLoginOnUser(String userName, String igoreToken){
|
||||
List<OnlineUser> onlineUsers = getAll(userName);
|
||||
List<OnlineUser> onlineUsers = getAll(userName,0);
|
||||
if(onlineUsers ==null || onlineUsers.isEmpty()){
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user