Commit aac60bd1 sunke

架构调整

1 个父辈 da084776
正在显示 35 个修改的文件 包含 597 行增加57 行删除
package com.neotel.smfcore; package com.neotel.smfcore;
import com.neotel.smfcore.common.annotation.AnonymousGetMapping; import com.neotel.smfcore.common.annotation.security.AnonymousGetMapping;
import com.neotel.smfcore.common.utils.SpringContextHolder; import com.neotel.smfcore.common.utils.SpringContextHolder;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
......
package com.neotel.smfcore.common.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface QueryCondition {
/**
* 查询字段
*/
String propName() default "";
Type type() default Type.EQ;
/**
* 多字段模糊搜索,仅支持String类型字段,多个用逗号隔开, 如@Query(blurry = "email,username")
*/
String blurry() default "";
enum Type {
/**
* 等于
*/
EQ,
/**
* 不等于
*/
NE,
/**
* 大于
*/
GT,
/**
* 大于等于
*/
GTE,
/**
* 小于
*/
LT,
/**
* 小于等于
*/
LTE,
// 包含
IN,
/**
* 不包含
*/
NIN,
/**
* between
*/
BETWEEN
// 不为空
,NOT
// 为空
,IS_NULL,
//存在
EXISTS
}
}
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.neotel.smfcore.common.annotation; package com.neotel.smfcore.common.annotation.security;
import java.lang.annotation.*; import java.lang.annotation.*;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.neotel.smfcore.common.annotation; package com.neotel.smfcore.common.annotation.security;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.neotel.smfcore.common.annotation; package com.neotel.smfcore.common.annotation.security;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.neotel.smfcore.common.annotation; package com.neotel.smfcore.common.annotation.security;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.neotel.smfcore.common.annotation; package com.neotel.smfcore.common.annotation.security;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.neotel.smfcore.common.annotation; package com.neotel.smfcore.common.annotation.security;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
......
package com.neotel.smfcore.common.enums;
import com.google.common.collect.Lists;
import java.util.List;
/**
* Created by sunke on 2021/7/13.
*/
public enum DeviceType {
/**
* 料仓类型:0单台自动料仓,1手动料仓2流水线料仓
*/
/**
*0单台自动料仓
*/
AUTO("storage.type.auto"),
/**
* 1手动料仓
*/
MANUAL("storage.type.manual"),
/**
* 2流水线料仓
*/
LINE("storage.type.line"),
/**
* 3 虚拟料仓
*/
VIRTUAL("storage.type.virtual"),
/**
* 4 在线料仓(上下层两个 BOX)
*/
ONLINE("storage.type.online"),
/**
* 5批量上下料料仓
*/
BATCH("storage.type.batch"),
/**
* 6智能料架
*/
SHELF("storage.type.shelf"),
/**
* 7 料柜
*/
CABINET("storage.type.cabinet"),
/**
* 8 料架
*/
ACCSHELF("storage.type.accShelf"),
/**
* 9 新料架,支持合并库位确认
*/
NEWSHELF("storage.type.newShelf"),
/**
* 9 扫码料架
*/
CODESHELF("storage.type.codeShelf"),
/**
* 10 锡膏料仓
*/
SOLDERPASTE("storage.type.solderPaste"),
/**
* 11 垂直货柜
*/
VERTICALBOX("storage.type.smdVl"),
/**
* 12 SMD-XL(方仓)
*/
SMD_XL("storage.type.smdXl"),
/**
* 13 SMD-DUO(DUO料仓)
*/
SMD_DUO("storage.type.smdDuo")
;
private String key;
TYPE(String key) {
this.key = key;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getName(){
return name();
}
public static List<TYPE> availableTypeList(){
return Lists.newArrayList(AUTO,LINE,BATCH,ACCSHELF,CODESHELF,SOLDERPASTE,VERTICALBOX,SMD_XL,SMD_DUO);
}
}
package com.neotel.smfcore.core.device;
import com.neotel.smfcore.core.listener.IDeviceListener;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* Created by sunke on 2021/7/12.
*/
@Service
public class BaseDeviceHandler implements IDeviceHandler{
@Override
public String getDeviceType() {
return "";
}
}
package com.neotel.smfcore.core.device;
/**
* Created by sunke on 2021/7/13.
*/
public interface IDeviceHandler {
String getDeviceType();
}
package com.neotel.smfcore.core.device;
/**
* Created by sunke on 2021/7/12.
*/
public class SmdXlBoxHandler implements IDeviceHandler{
@Override
public String getDeviceType() {
return null;
}
}
package com.neotel.smfcore.core.listener;
import org.springframework.stereotype.Service;
/**
* Created by sunke on 2021/7/12.
*/
@Service
public class ApiListener implements IDeviceListener {
@Override
public String onScanCode(String codeStr) {
return "LiteOrderListener";
}
}
package com.neotel.smfcore.core.listener;
/**
* Created by sunke on 2021/7/12.
*/
public interface IDeviceListener {
String onScanCode(String codeStr);
}
package com.neotel.smfcore.core.listener;
import org.springframework.stereotype.Service;
/**
* Created by sunke on 2021/7/12.
*/
@Service
public class LiteOrderListener implements IDeviceListener {
@Override
public String onScanCode(String codeStr) {
return "LiteOrderListener";
}
}
package com.neotel.smfcore.core.rest;
import com.neotel.smfcore.core.device.IDeviceHandler;
import com.neotel.smfcore.core.listener.IDeviceListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by sunke on 2021/7/13.
*/
public class TaskService {
private List<IDeviceListener> listenerList = new ArrayList<>();
private Map<String, IDeviceHandler> handlerMap = new HashMap<>();
public TaskService(List<IDeviceHandler> deviceHandlerList, List<IDeviceListener> deviceListenerList){
for (IDeviceHandler deviceHandler : deviceHandlerList) {
}
for (IDeviceListener deviceListener: deviceListenerList) {
listenerList.add(deviceListener);
}
}
}
...@@ -19,7 +19,7 @@ import cn.hutool.core.util.StrUtil; ...@@ -19,7 +19,7 @@ import cn.hutool.core.util.StrUtil;
import com.neotel.smfcore.security.bean.SecurityProperties; import com.neotel.smfcore.security.bean.SecurityProperties;
import com.neotel.smfcore.security.service.OnlineUserService; import com.neotel.smfcore.security.service.OnlineUserService;
import com.neotel.smfcore.security.service.UserCacheClean; import com.neotel.smfcore.security.service.UserCacheClean;
import com.neotel.smfcore.security.service.dto.OnlineUserDto; import com.neotel.smfcore.security.rest.bean.dto.OnlineUserDto;
import io.jsonwebtoken.ExpiredJwtException; import io.jsonwebtoken.ExpiredJwtException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
*/ */
package com.neotel.smfcore.security.config; package com.neotel.smfcore.security.config;
import com.neotel.smfcore.common.annotation.AnonymousAccess; import com.neotel.smfcore.common.annotation.security.AnonymousAccess;
import com.neotel.smfcore.common.enums.RequestMethodEnum; import com.neotel.smfcore.common.enums.RequestMethodEnum;
import com.neotel.smfcore.security.JwtAccessDeniedHandler; import com.neotel.smfcore.security.JwtAccessDeniedHandler;
import com.neotel.smfcore.security.JwtAuthenticationEntryPoint; import com.neotel.smfcore.security.JwtAuthenticationEntryPoint;
......
...@@ -15,22 +15,26 @@ ...@@ -15,22 +15,26 @@
*/ */
package com.neotel.smfcore.security.rest; package com.neotel.smfcore.security.rest;
import com.neotel.smfcore.common.annotation.AnonymousDeleteMapping; import com.neotel.smfcore.common.annotation.security.AnonymousDeleteMapping;
import com.neotel.smfcore.common.annotation.AnonymousGetMapping; import com.neotel.smfcore.common.annotation.security.AnonymousGetMapping;
import com.neotel.smfcore.common.annotation.AnonymousPostMapping; import com.neotel.smfcore.common.annotation.security.AnonymousPostMapping;
import com.neotel.smfcore.common.utils.EncryptUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.security.bean.RsaProperties; import com.neotel.smfcore.security.bean.RsaProperties;
import com.neotel.smfcore.security.TokenProvider; import com.neotel.smfcore.security.TokenProvider;
import com.neotel.smfcore.security.bean.LoginProperties; import com.neotel.smfcore.security.bean.LoginProperties;
import com.neotel.smfcore.security.bean.SecurityProperties; import com.neotel.smfcore.security.bean.SecurityProperties;
import com.neotel.smfcore.security.rest.bean.dto.OnlineUserDto;
import com.neotel.smfcore.security.service.OnlineUserService; import com.neotel.smfcore.security.service.OnlineUserService;
import com.neotel.smfcore.security.service.dto.AuthUserDto; import com.neotel.smfcore.security.rest.bean.dto.AuthUserDto;
import com.neotel.smfcore.security.service.dto.JwtUserDto; import com.neotel.smfcore.security.rest.bean.dto.JwtUserDto;
import com.neotel.smfcore.common.utils.RsaUtils; import com.neotel.smfcore.common.utils.RsaUtils;
import com.neotel.smfcore.common.utils.SecurityUtils; import com.neotel.smfcore.common.utils.SecurityUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
...@@ -45,6 +49,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -45,6 +49,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -56,9 +61,12 @@ import java.util.Map; ...@@ -56,9 +61,12 @@ import java.util.Map;
@Api(tags = "系统:系统授权接口") @Api(tags = "系统:系统授权接口")
public class AuthorizationController { public class AuthorizationController {
private final SecurityProperties properties; private final SecurityProperties properties;
// private final RedisUtils redisUtils;
private final OnlineUserService onlineUserService; @Autowired
private final TokenProvider tokenProvider; private OnlineUserService onlineUserService;
@Autowired
private TokenProvider tokenProvider;
private final AuthenticationManagerBuilder authenticationManagerBuilder; private final AuthenticationManagerBuilder authenticationManagerBuilder;
@Resource @Resource
private LoginProperties loginProperties; private LoginProperties loginProperties;
...@@ -89,7 +97,17 @@ public class AuthorizationController { ...@@ -89,7 +97,17 @@ public class AuthorizationController {
String token = tokenProvider.createToken(authentication); String token = tokenProvider.createToken(authentication);
final JwtUserDto jwtUserDto = (JwtUserDto) authentication.getPrincipal(); final JwtUserDto jwtUserDto = (JwtUserDto) authentication.getPrincipal();
// 保存在线信息 // 保存在线信息
onlineUserService.save(jwtUserDto, token, request); String ip = StringUtils.getIp(request);
String browser = StringUtils.getBrowser(request);
String address = StringUtils.getCityInfo(ip);
OnlineUserDto onlineUserDto = null;
try {
long seconds = onlineUserService.properties.getTokenValidityInSeconds() / 1000;
onlineUserDto = new OnlineUserDto(jwtUserDto.getUsername(), browser , ip, address, EncryptUtils.desEncrypt(token), new Date());
} catch (Exception e) {
log.error(e.getMessage(),e);
}
OnlineUserService.onlineUserMap.put(onlineUserService.properties.getOnlineKey() + token, onlineUserDto);
// 返回 token 与 用户信息 // 返回 token 与 用户信息
Map<String, Object> authInfo = new HashMap<String, Object>(2) {{ Map<String, Object> authInfo = new HashMap<String, Object>(2) {{
put("token", properties.getTokenStartWith() + token); put("token", properties.getTokenStartWith() + token);
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.neotel.smfcore.security.rest;
import cn.hutool.core.collection.CollectionUtil;
import com.neotel.smfcore.common.annotation.QueryCondition;
import com.neotel.smfcore.security.service.manager.IMenuManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author Zheng Jie
* @date 2018-12-03
*/
@RestController
@RequiredArgsConstructor
@Api(tags = "系统:菜单管理")
@RequestMapping("/api/menus")
public class MenuController {
// @Autowired
// private final IMenuManager menuManager;
// private final MenuMapper menuMapper;
// private static final String ENTITY_NAME = "menu";
//
// @ApiOperation("导出菜单数据")
// @GetMapping(value = "/download")
// @PreAuthorize("@el.check('menu:list')")
// public void download(HttpServletResponse response, QueryCondition criteria) throws Exception {
// menuService.download(menuService.queryAll(criteria, false), response);
// }
//
// @GetMapping(value = "/build")
// @ApiOperation("获取前端所需菜单")
// public ResponseEntity<Object> buildMenus(){
// List<MenuDto> menuDtoList = menuService.findByUser(SecurityUtils.getCurrentUserId());
// List<MenuDto> menuDtos = menuService.buildTree(menuDtoList);
// return new ResponseEntity<>(menuService.buildMenus(menuDtos), HttpStatus.OK);
// }
//
// @ApiOperation("返回全部的菜单")
// @GetMapping(value = "/lazy")
// @PreAuthorize("@el.check('menu:list','roles:list')")
// public ResponseEntity<Object> query(@RequestParam Long pid){
// return new ResponseEntity<>(menuService.getMenus(pid), HttpStatus.OK);
// }
//
// @ApiOperation("根据菜单ID返回所有子节点ID,包含自身ID")
// @GetMapping(value = "/child")
// @PreAuthorize("@el.check('menu:list','roles:list')")
// public ResponseEntity<Object> child(@RequestParam Long id){
// Set<Menu> menuSet = new HashSet<>();
// List<MenuDto> menuList = menuService.getMenus(id);
// menuSet.add(menuService.findOne(id));
// menuSet = menuService.getChildMenus(menuMapper.toEntity(menuList), menuSet);
// Set<Long> ids = menuSet.stream().map(Menu::getId).collect(Collectors.toSet());
// return new ResponseEntity<>(ids, HttpStatus.OK);
// }
//
// @GetMapping
// @ApiOperation("查询菜单")
// @PreAuthorize("@el.check('menu:list')")
// public ResponseEntity<Object> query(MenuQueryCriteria criteria) throws Exception {
// List<MenuDto> menuDtoList = menuService.queryAll(criteria, true);
// return new ResponseEntity<>(PageUtil.toPage(menuDtoList, menuDtoList.size()), HttpStatus.OK);
// }
//
// @ApiOperation("查询菜单:根据ID获取同级与上级数据")
// @PostMapping("/superior")
// @PreAuthorize("@el.check('menu:list')")
// public ResponseEntity<Object> getSuperior(@RequestBody List<Long> ids) {
// Set<MenuDto> menuDtos = new LinkedHashSet<>();
// if(CollectionUtil.isNotEmpty(ids)){
// for (Long id : ids) {
// MenuDto menuDto = menuService.findById(id);
// menuDtos.addAll(menuService.getSuperior(menuDto, new ArrayList<>()));
// }
// return new ResponseEntity<>(menuService.buildTree(new ArrayList<>(menuDtos)), HttpStatus.OK);
// }
// return new ResponseEntity<>(menuService.getMenus(null), HttpStatus.OK);
// }
//
// @Log("新增菜单")
// @ApiOperation("新增菜单")
// @PostMapping
// @PreAuthorize("@el.check('menu:add')")
// public ResponseEntity<Object> create(@Validated @RequestBody Menu resources){
// if (resources.getId() != null) {
// throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
// }
// menuService.create(resources);
// return new ResponseEntity<>(HttpStatus.CREATED);
// }
//
// @Log("修改菜单")
// @ApiOperation("修改菜单")
// @PutMapping
// @PreAuthorize("@el.check('menu:edit')")
// public ResponseEntity<Object> update(@Validated(Menu.Update.class) @RequestBody Menu resources){
// menuService.update(resources);
// return new ResponseEntity<>(HttpStatus.NO_CONTENT);
// }
//
// @Log("删除菜单")
// @ApiOperation("删除菜单")
// @DeleteMapping
// @PreAuthorize("@el.check('menu:del')")
// public ResponseEntity<Object> delete(@RequestBody Set<Long> ids){
// Set<Menu> menuSet = new HashSet<>();
// for (Long id : ids) {
// List<MenuDto> menuList = menuService.getMenus(id);
// menuSet.add(menuService.findOne(id));
// menuSet = menuService.getChildMenus(menuMapper.toEntity(menuList), menuSet);
// }
// menuService.delete(menuSet);
// return new ResponseEntity<>(HttpStatus.OK);
// }
}
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.neotel.smfcore.security.service.dto; package com.neotel.smfcore.security.rest.bean.dto;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.neotel.smfcore.security.service.dto; package com.neotel.smfcore.security.rest.bean.dto;
import lombok.Data; import lombok.Data;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.neotel.smfcore.security.service.dto; package com.neotel.smfcore.security.rest.bean.dto;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.neotel.smfcore.security.service.po.User; import com.neotel.smfcore.security.service.po.User;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.neotel.smfcore.security.service.dto; package com.neotel.smfcore.security.rest.bean.dto;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
......
...@@ -13,16 +13,12 @@ ...@@ -13,16 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.neotel.smfcore.security.service.dto; package com.neotel.smfcore.security.rest.bean.dto;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
/**
* @author Zheng Jie
* @date 2018-11-23
*/
@Data @Data
public class RoleSmallDto implements Serializable { public class RoleSmallDto implements Serializable {
......
package com.neotel.smfcore.security.rest.bean.query;
import com.neotel.smfcore.common.annotation.QueryCondition;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class MenuQueryCondition {
@QueryCondition(blurry = "title,component,permission")
private String blurry;
@QueryCondition(type = QueryCondition.Type.BETWEEN)
private List<Date> createTime;
@QueryCondition(type = QueryCondition.Type.IS_NULL, propName = "pid")
private Boolean pidIsNull;
@QueryCondition
private Long pid;
}
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
package com.neotel.smfcore.security.service; package com.neotel.smfcore.security.service;
import com.neotel.smfcore.security.bean.SecurityProperties; import com.neotel.smfcore.security.bean.SecurityProperties;
import com.neotel.smfcore.security.service.dto.JwtUserDto; import com.neotel.smfcore.security.rest.bean.dto.JwtUserDto;
import com.neotel.smfcore.security.service.dto.OnlineUserDto; import com.neotel.smfcore.security.rest.bean.dto.OnlineUserDto;
import com.neotel.smfcore.common.utils.EncryptUtils; import com.neotel.smfcore.common.utils.EncryptUtils;
import com.neotel.smfcore.common.utils.FileUtil; import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.PageUtil; import com.neotel.smfcore.common.utils.PageUtil;
...@@ -41,35 +41,15 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -41,35 +41,15 @@ import java.util.concurrent.ConcurrentHashMap;
@Slf4j @Slf4j
public class OnlineUserService { public class OnlineUserService {
private final SecurityProperties properties; public final SecurityProperties properties;
static Map<String, OnlineUserDto> onlineUserMap = new ConcurrentHashMap<>(); public static Map<String, OnlineUserDto> onlineUserMap = new ConcurrentHashMap<>();
public OnlineUserService(SecurityProperties properties) { public OnlineUserService(SecurityProperties properties) {
this.properties = properties; this.properties = properties;
} }
/** /**
* 保存在线用户信息
* @param jwtUserDto /
* @param token /
* @param request /
*/
public void save(JwtUserDto jwtUserDto, String token, HttpServletRequest request){
String ip = StringUtils.getIp(request);
String browser = StringUtils.getBrowser(request);
String address = StringUtils.getCityInfo(ip);
OnlineUserDto onlineUserDto = null;
try {
long seconds = properties.getTokenValidityInSeconds() / 1000;
onlineUserDto = new OnlineUserDto(jwtUserDto.getUsername(), browser , ip, address, EncryptUtils.desEncrypt(token), new Date());
} catch (Exception e) {
log.error(e.getMessage(),e);
}
onlineUserMap.put(properties.getOnlineKey() + token, onlineUserDto);
}
/**
* 查询全部数据 * 查询全部数据
* @param filter / * @param filter /
* @param pageable / * @param pageable /
......
...@@ -18,7 +18,7 @@ package com.neotel.smfcore.security.service; ...@@ -18,7 +18,7 @@ package com.neotel.smfcore.security.service;
import com.neotel.smfcore.common.exception.BadRequestException; import com.neotel.smfcore.common.exception.BadRequestException;
import com.neotel.smfcore.common.exception.EntityNotFoundException; import com.neotel.smfcore.common.exception.EntityNotFoundException;
import com.neotel.smfcore.security.bean.LoginProperties; import com.neotel.smfcore.security.bean.LoginProperties;
import com.neotel.smfcore.security.service.dto.JwtUserDto; import com.neotel.smfcore.security.rest.bean.dto.JwtUserDto;
import com.neotel.smfcore.security.service.manager.IRoleManager; import com.neotel.smfcore.security.service.manager.IRoleManager;
import com.neotel.smfcore.security.service.manager.IUserManager; import com.neotel.smfcore.security.service.manager.IUserManager;
import com.neotel.smfcore.security.service.po.Menu; import com.neotel.smfcore.security.service.po.Menu;
......
package com.neotel.smfcore.security.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
/**
* Created by sunke on 2021/7/8.
*/
public interface IMenuDao extends IBaseDao {
}
package com.neotel.smfcore.security.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.security.service.dao.IMenuDao;
import com.neotel.smfcore.security.service.dao.IRoleDao;
import com.neotel.smfcore.security.service.po.Menu;
import com.neotel.smfcore.security.service.po.User;
import org.springframework.stereotype.Service;
/**
* Created by sunke on 2021/7/7.
*/
@Service
public class MenuDaoImpl extends AbstractBaseDao implements IMenuDao {
@Override
public Class getEntityClass() {
return Menu.class;
}
}
package com.neotel.smfcore.security.service.manager;
import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.security.service.po.Menu;
import com.neotel.smfcore.security.service.po.Role;
public interface IMenuManager extends IBaseManager<Menu> {
}
package com.neotel.smfcore.security.service.manager.impl;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.security.service.dao.IMenuDao;
import com.neotel.smfcore.security.service.dao.IRoleDao;
import com.neotel.smfcore.security.service.manager.IMenuManager;
import com.neotel.smfcore.security.service.manager.IRoleManager;
import com.neotel.smfcore.security.service.po.Menu;
import com.neotel.smfcore.security.service.po.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class MenuManagerImpl implements IMenuManager {
@Autowired
protected IMenuDao menuDao;
@Override
public Menu get(String id) {
return menuDao.findOneById(id);
}
@Override
public Menu save(Menu menu) throws ValidateException {
return menuDao.save(menu);
}
@Override
public void delete(Menu object) throws ValidateException {
menuDao.removeOne(object);
}
@Override
public List<Menu> findByPage(Query query, Pageable pageable) {
return menuDao.findByQuery(query, pageable);
}
@Override
public List<Menu> findByQuery(Query query) {
return menuDao.findByQuery(query);
}
}
...@@ -17,16 +17,12 @@ package com.neotel.smfcore.security.service.po; ...@@ -17,16 +17,12 @@ package com.neotel.smfcore.security.service.po;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.neotel.smfcore.common.base.BasePo; import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.security.service.dto.DeptSmallDto;
import com.neotel.smfcore.security.service.dto.RoleSmallDto;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.Set;
/** /**
* @author Zheng Jie * @author Zheng Jie
......
server: server:
port: 8500 port: 8800
spring: spring:
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!