Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit aac60bd1
由
sunke
编写于
2021-07-13 09:44:19 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
架构调整
1 个父辈
da084776
隐藏空白字符变更
内嵌
并排
正在显示
35 个修改的文件
包含
733 行增加
和
402 行删除
src/main/java/com/neotel/smfcore/SmfCoreApplication.java
src/main/java/com/neotel/smfcore/common/annotation/QueryCondition.java
src/main/java/com/neotel/smfcore/common/annotation/AnonymousAccess.java → src/main/java/com/neotel/smfcore/common/annotation/security/AnonymousAccess.java
src/main/java/com/neotel/smfcore/common/annotation/AnonymousDeleteMapping.java → src/main/java/com/neotel/smfcore/common/annotation/security/AnonymousDeleteMapping.java
src/main/java/com/neotel/smfcore/common/annotation/AnonymousGetMapping.java → src/main/java/com/neotel/smfcore/common/annotation/security/AnonymousGetMapping.java
src/main/java/com/neotel/smfcore/common/annotation/AnonymousPatchMapping.java → src/main/java/com/neotel/smfcore/common/annotation/security/AnonymousPatchMapping.java
src/main/java/com/neotel/smfcore/common/annotation/AnonymousPostMapping.java → src/main/java/com/neotel/smfcore/common/annotation/security/AnonymousPostMapping.java
src/main/java/com/neotel/smfcore/common/annotation/AnonymousPutMapping.java → src/main/java/com/neotel/smfcore/common/annotation/security/AnonymousPutMapping.java
src/main/java/com/neotel/smfcore/common/enums/DeviceType.java
src/main/java/com/neotel/smfcore/common/utils/QueryHelp.java
src/main/java/com/neotel/smfcore/core/device/BaseDeviceHandler.java
src/main/java/com/neotel/smfcore/core/device/IDeviceHandler.java
src/main/java/com/neotel/smfcore/core/device/SmdXlBoxHandler.java
src/main/java/com/neotel/smfcore/core/listener/ApiListener.java
src/main/java/com/neotel/smfcore/core/listener/IDeviceListener.java
src/main/java/com/neotel/smfcore/core/listener/LiteOrderListener.java
src/main/java/com/neotel/smfcore/core/rest/TaskService.java
src/main/java/com/neotel/smfcore/security/TokenFilter.java
src/main/java/com/neotel/smfcore/security/config/SpringSecurityConfig.java
src/main/java/com/neotel/smfcore/security/rest/AuthorizationController.java
src/main/java/com/neotel/smfcore/security/rest/MenuController.java
src/main/java/com/neotel/smfcore/security/service/dto/AuthUserDto.java → src/main/java/com/neotel/smfcore/security/rest/bean/dto/AuthUserDto.java
src/main/java/com/neotel/smfcore/security/service/dto/DeptSmallDto.java → src/main/java/com/neotel/smfcore/security/rest/bean/dto/DeptSmallDto.java
src/main/java/com/neotel/smfcore/security/service/dto/JwtUserDto.java → src/main/java/com/neotel/smfcore/security/rest/bean/dto/JwtUserDto.java
src/main/java/com/neotel/smfcore/security/service/dto/OnlineUserDto.java → src/main/java/com/neotel/smfcore/security/rest/bean/dto/OnlineUserDto.java
src/main/java/com/neotel/smfcore/security/service/dto/RoleSmallDto.java → src/main/java/com/neotel/smfcore/security/rest/bean/dto/RoleSmallDto.java
src/main/java/com/neotel/smfcore/security/rest/bean/query/MenuQueryCondition.java
src/main/java/com/neotel/smfcore/security/service/OnlineUserService.java
src/main/java/com/neotel/smfcore/security/service/UserDetailsServiceImpl.java
src/main/java/com/neotel/smfcore/security/service/dao/IMenuDao.java
src/main/java/com/neotel/smfcore/security/service/dao/impl/MenuDaoImpl.java
src/main/java/com/neotel/smfcore/security/service/manager/IMenuManager.java
src/main/java/com/neotel/smfcore/security/service/manager/impl/MenuManagerImpl.java
src/main/java/com/neotel/smfcore/security/service/po/User.java
src/main/resources/config/application.yml
src/main/java/com/neotel/smfcore/SmfCoreApplication.java
查看文件 @
aac60bd
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
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
...
...
src/main/java/com/neotel/smfcore/common/annotation/QueryCondition.java
0 → 100644
查看文件 @
aac60bd
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
}
}
src/main/java/com/neotel/smfcore/common/annotation/AnonymousAccess.java
→
src/main/java/com/neotel/smfcore/common/annotation/
security/
AnonymousAccess.java
查看文件 @
aac60bd
...
...
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
neotel
.
smfcore
.
common
.
annotation
;
package
com
.
neotel
.
smfcore
.
common
.
annotation
.
security
;
import
java.lang.annotation.*
;
...
...
src/main/java/com/neotel/smfcore/common/annotation/AnonymousDeleteMapping.java
→
src/main/java/com/neotel/smfcore/common/annotation/
security/
AnonymousDeleteMapping.java
查看文件 @
aac60bd
...
...
@@ -14,7 +14,7 @@
* 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.web.bind.annotation.RequestMapping
;
...
...
src/main/java/com/neotel/smfcore/common/annotation/AnonymousGetMapping.java
→
src/main/java/com/neotel/smfcore/common/annotation/
security/
AnonymousGetMapping.java
查看文件 @
aac60bd
...
...
@@ -14,7 +14,7 @@
* 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.web.bind.annotation.RequestMapping
;
...
...
src/main/java/com/neotel/smfcore/common/annotation/AnonymousPatchMapping.java
→
src/main/java/com/neotel/smfcore/common/annotation/
security/
AnonymousPatchMapping.java
查看文件 @
aac60bd
...
...
@@ -14,7 +14,7 @@
* 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.web.bind.annotation.RequestMapping
;
...
...
src/main/java/com/neotel/smfcore/common/annotation/AnonymousPostMapping.java
→
src/main/java/com/neotel/smfcore/common/annotation/
security/
AnonymousPostMapping.java
查看文件 @
aac60bd
...
...
@@ -14,7 +14,7 @@
* 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.web.bind.annotation.RequestMapping
;
...
...
src/main/java/com/neotel/smfcore/common/annotation/AnonymousPutMapping.java
→
src/main/java/com/neotel/smfcore/common/annotation/
security/
AnonymousPutMapping.java
查看文件 @
aac60bd
...
...
@@ -14,7 +14,7 @@
* 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.web.bind.annotation.RequestMapping
;
...
...
src/main/java/com/neotel/smfcore/common/enums/DeviceType.java
0 → 100644
查看文件 @
aac60bd
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
);
}
}
src/main/java/com/neotel/smfcore/common/utils/QueryHelp.java
查看文件 @
aac60bd
///*
// * 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.common.utils;
//
//import cn.hutool.core.collection.CollUtil;
//import cn.hutool.core.collection.CollectionUtil;
//import cn.hutool.core.util.ObjectUtil;
//import lombok.extern.slf4j.Slf4j;
//import me.zhengjie.annotation.DataPermission;
//import me.zhengjie.annotation.Query;
//import org.springframework.data.mongodb.core.query.Criteria;
//import org.springframework.data.mongodb.core.query.Query;
//
//import javax.persistence.criteria.*;
//import java.lang.reflect.Field;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.Collection;
//import java.util.List;
//
///**
// * @author Zheng Jie
// * @date 2019-6-4 14:59:48
// */
//@Slf4j
//@SuppressWarnings({"unchecked","all"})
//public class QueryHelp {
//
//
//
// public static <C> Query getQuery(C c){
// Criteria criteria = new Criteria();
// if(c == null){
// return new Query(criteria);
// }
// try {
// List<Field> fields = getAllFields(c.getClass(), new ArrayList<>());
// for (Field field : fields) {
// boolean accessible = field.isAccessible();
// // 设置对象的访问权限,保证对private的属性的访
// field.setAccessible(true);
// Query q = field.getAnnotation(Query.class);
// if (q != null) {
// String propName = q.propName();
// String joinName = q.joinName();
// String blurry = q.blurry();
// String attributeName = isBlank(propName) ? field.getName() : propName;
// Class<?> fieldType = field.getType();
// Object val = field.get(query);
// if (ObjectUtil.isNull(val) || "".equals(val)) {
// continue;
// }
// Join join = null;
// // 模糊多字段
// if (ObjectUtil.isNotEmpty(blurry)) {
// String[] blurrys = blurry.split(",");
// List<Predicate> orPredicate = new ArrayList<>();
// for (String s : blurrys) {
// orPredicate.add(cb.like(root.get(s)
// .as(String.class), "%" + val.toString() + "%"));
// }
// Predicate[] p = new Predicate[orPredicate.size()];
// list.add(cb.or(orPredicate.toArray(p)));
// continue;
// }
// if (ObjectUtil.isNotEmpty(joinName)) {
// String[] joinNames = joinName.split(">");
// for (String name : joinNames) {
// switch (q.join()) {
// case LEFT:
// if(ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)){
// join = join.join(name, JoinType.LEFT);
// } else {
// join = root.join(name, JoinType.LEFT);
// }
// break;
// case RIGHT:
// if(ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)){
// join = join.join(name, JoinType.RIGHT);
// } else {
// join = root.join(name, JoinType.RIGHT);
// }
// break;
// case INNER:
// if(ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)){
// join = join.join(name, JoinType.INNER);
// } else {
// join = root.join(name, JoinType.INNER);
// }
// break;
// default: break;
// }
// }
// }
// switch (q.type()) {
// case EQUAL:
// list.add(cb.equal(getExpression(attributeName,join,root)
// .as((Class<? extends Comparable>) fieldType),val));
// break;
// case GREATER_THAN:
// list.add(cb.greaterThanOrEqualTo(getExpression(attributeName,join,root)
// .as((Class<? extends Comparable>) fieldType), (Comparable) val));
// break;
// case LESS_THAN:
// list.add(cb.lessThanOrEqualTo(getExpression(attributeName,join,root)
// .as((Class<? extends Comparable>) fieldType), (Comparable) val));
// break;
// case LESS_THAN_NQ:
// list.add(cb.lessThan(getExpression(attributeName,join,root)
// .as((Class<? extends Comparable>) fieldType), (Comparable) val));
// break;
// case INNER_LIKE:
// list.add(cb.like(getExpression(attributeName,join,root)
// .as(String.class), "%" + val.toString() + "%"));
// break;
// case LEFT_LIKE:
// list.add(cb.like(getExpression(attributeName,join,root)
// .as(String.class), "%" + val.toString()));
// break;
// case RIGHT_LIKE:
// list.add(cb.like(getExpression(attributeName,join,root)
// .as(String.class), val.toString() + "%"));
// break;
// case IN:
// if (CollUtil.isNotEmpty((Collection<Object>)val)) {
// list.add(getExpression(attributeName,join,root).in((Collection<Object>) val));
// }
// break;
// case NOT_IN:
// if (CollUtil.isNotEmpty((Collection<Object>)val)) {
// list.add(getExpression(attributeName,join,root).in((Collection<Object>) val).not());
// }
// break;
// case NOT_EQUAL:
// list.add(cb.notEqual(getExpression(attributeName,join,root), val));
// break;
// case NOT_NULL:
// list.add(cb.isNotNull(getExpression(attributeName,join,root)));
// break;
// case IS_NULL:
// list.add(cb.isNull(getExpression(attributeName,join,root)));
// break;
// case BETWEEN:
// List<Object> between = new ArrayList<>((List<Object>)val);
// list.add(cb.between(getExpression(attributeName, join, root).as((Class<? extends Comparable>) between.get(0).getClass()),
// (Comparable) between.get(0), (Comparable) between.get(1)));
// break;
// default: break;
// }
// }
// field.setAccessible(accessible);
// }
// } catch (Exception e) {
// log.error(e.getMessage(), e);
// }
// int size = list.size();
// return cb.and(list.toArray(new Predicate[size]));
// }
//
// public static <R, Q> Predicate getPredicate(Root<R> root, Q query, CriteriaBuilder cb) {
// List<Predicate> list = new ArrayList<>();
// if(query == null){
// return cb.and(list.toArray(new Predicate[0]));
// }
// // 数据权限验证
// DataPermission permission = query.getClass().getAnnotation(DataPermission.class);
// if(permission != null){
// // 获取数据权限
// List<Long> dataScopes = SecurityUtils.getCurrentUserDataScope();
// if(CollectionUtil.isNotEmpty(dataScopes)){
// if(StringUtils.isNotBlank(permission.joinName()) && StringUtils.isNotBlank(permission.fieldName())) {
// Join join = root.join(permission.joinName(), JoinType.LEFT);
// list.add(getExpression(permission.fieldName(),join, root).in(dataScopes));
// } else if (StringUtils.isBlank(permission.joinName()) && StringUtils.isNotBlank(permission.fieldName())) {
// list.add(getExpression(permission.fieldName(),null, root).in(dataScopes));
// }
// }
// }
// try {
// List<Field> fields = getAllFields(query.getClass(), new ArrayList<>());
// for (Field field : fields) {
// boolean accessible = field.isAccessible();
// // 设置对象的访问权限,保证对private的属性的访
// field.setAccessible(true);
// Query q = field.getAnnotation(Query.class);
// if (q != null) {
// String propName = q.propName();
// String joinName = q.joinName();
// String blurry = q.blurry();
// String attributeName = isBlank(propName) ? field.getName() : propName;
// Class<?> fieldType = field.getType();
// Object val = field.get(query);
// if (ObjectUtil.isNull(val) || "".equals(val)) {
// continue;
// }
// Join join = null;
// // 模糊多字段
// if (ObjectUtil.isNotEmpty(blurry)) {
// String[] blurrys = blurry.split(",");
// List<Predicate> orPredicate = new ArrayList<>();
// for (String s : blurrys) {
// orPredicate.add(cb.like(root.get(s)
// .as(String.class), "%" + val.toString() + "%"));
// }
// Predicate[] p = new Predicate[orPredicate.size()];
// list.add(cb.or(orPredicate.toArray(p)));
// continue;
// }
// if (ObjectUtil.isNotEmpty(joinName)) {
// String[] joinNames = joinName.split(">");
// for (String name : joinNames) {
// switch (q.join()) {
// case LEFT:
// if(ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)){
// join = join.join(name, JoinType.LEFT);
// } else {
// join = root.join(name, JoinType.LEFT);
// }
// break;
// case RIGHT:
// if(ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)){
// join = join.join(name, JoinType.RIGHT);
// } else {
// join = root.join(name, JoinType.RIGHT);
// }
// break;
// case INNER:
// if(ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)){
// join = join.join(name, JoinType.INNER);
// } else {
// join = root.join(name, JoinType.INNER);
// }
// break;
// default: break;
// }
// }
// }
// switch (q.type()) {
// case EQUAL:
// list.add(cb.equal(getExpression(attributeName,join,root)
// .as((Class<? extends Comparable>) fieldType),val));
// break;
// case GREATER_THAN:
// list.add(cb.greaterThanOrEqualTo(getExpression(attributeName,join,root)
// .as((Class<? extends Comparable>) fieldType), (Comparable) val));
// break;
// case LESS_THAN:
// list.add(cb.lessThanOrEqualTo(getExpression(attributeName,join,root)
// .as((Class<? extends Comparable>) fieldType), (Comparable) val));
// break;
// case LESS_THAN_NQ:
// list.add(cb.lessThan(getExpression(attributeName,join,root)
// .as((Class<? extends Comparable>) fieldType), (Comparable) val));
// break;
// case INNER_LIKE:
// list.add(cb.like(getExpression(attributeName,join,root)
// .as(String.class), "%" + val.toString() + "%"));
// break;
// case LEFT_LIKE:
// list.add(cb.like(getExpression(attributeName,join,root)
// .as(String.class), "%" + val.toString()));
// break;
// case RIGHT_LIKE:
// list.add(cb.like(getExpression(attributeName,join,root)
// .as(String.class), val.toString() + "%"));
// break;
// case IN:
// if (CollUtil.isNotEmpty((Collection<Object>)val)) {
// list.add(getExpression(attributeName,join,root).in((Collection<Object>) val));
// }
// break;
// case NOT_IN:
// if (CollUtil.isNotEmpty((Collection<Object>)val)) {
// list.add(getExpression(attributeName,join,root).in((Collection<Object>) val).not());
// }
// break;
// case NOT_EQUAL:
// list.add(cb.notEqual(getExpression(attributeName,join,root), val));
// break;
// case NOT_NULL:
// list.add(cb.isNotNull(getExpression(attributeName,join,root)));
// break;
// case IS_NULL:
// list.add(cb.isNull(getExpression(attributeName,join,root)));
// break;
// case BETWEEN:
// List<Object> between = new ArrayList<>((List<Object>)val);
// list.add(cb.between(getExpression(attributeName, join, root).as((Class<? extends Comparable>) between.get(0).getClass()),
// (Comparable) between.get(0), (Comparable) between.get(1)));
// break;
// default: break;
// }
// }
// field.setAccessible(accessible);
// }
// } catch (Exception e) {
// log.error(e.getMessage(), e);
// }
// int size = list.size();
// return cb.and(list.toArray(new Predicate[size]));
// }
//
// @SuppressWarnings("unchecked")
// private static <T, R> Expression<T> getExpression(String attributeName, Join join, Root<R> root) {
// if (ObjectUtil.isNotEmpty(join)) {
// return join.get(attributeName);
// } else {
// return root.get(attributeName);
// }
// }
//
// private static boolean isBlank(final CharSequence cs) {
// int strLen;
// if (cs == null || (strLen = cs.length()) == 0) {
// return true;
// }
// for (int i = 0; i < strLen; i++) {
// if (!Character.isWhitespace(cs.charAt(i))) {
// return false;
// }
// }
// return true;
// }
//
// public static List<Field> getAllFields(Class clazz, List<Field> fields) {
// if (clazz != null) {
// fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
// getAllFields(clazz.getSuperclass(), fields);
// }
// return fields;
// }
//}
package
com
.
neotel
.
smfcore
.
common
.
utils
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.annotation.QueryCondition
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.regex.Pattern
;
@Slf4j
public
class
QueryHelp
{
public
static
<
C
>
Query
getQuery
(
C
c
){
Criteria
criteria
=
new
Criteria
();
if
(
c
!=
null
){
try
{
List
<
Field
>
fields
=
getAllFields
(
c
.
getClass
(),
new
ArrayList
<>());
for
(
Field
field
:
fields
)
{
boolean
accessible
=
field
.
isAccessible
();
// 设置对象的访问权限,保证对private的属性的访
field
.
setAccessible
(
true
);
QueryCondition
q
=
field
.
getAnnotation
(
QueryCondition
.
class
);
if
(
q
!=
null
)
{
String
propName
=
q
.
propName
();
String
attributeName
=
isBlank
(
propName
)
?
field
.
getName
()
:
propName
;
Class
<?>
fieldType
=
field
.
getType
();
Object
val
=
field
.
get
(
c
);
if
(
ObjectUtil
.
isNull
(
val
)
||
""
.
equals
(
val
))
{
continue
;
}
// 如果是多字段
String
blurry
=
q
.
blurry
();
String
[]
blurrys
=
blurry
.
split
(
","
);
if
(
ObjectUtil
.
isNotEmpty
(
blurry
))
{
for
(
String
s
:
blurrys
)
{
Pattern
pattern
=
Pattern
.
compile
(
escapeExprSpecialWord
(
val
.
toString
()),
Pattern
.
CASE_INSENSITIVE
);
criteria
=
criteria
.
and
(
s
).
regex
(
pattern
);
}
continue
;
}
switch
(
q
.
type
())
{
case
EQ:
criteria
=
criteria
.
and
(
propName
).
is
(
val
);
break
;
case
GT:
criteria
=
criteria
.
and
(
propName
).
gt
(
val
);
break
;
case
LT:
criteria
=
criteria
.
and
(
propName
).
lt
(
val
);
break
;
case
LTE:
criteria
=
criteria
.
and
(
propName
).
lte
(
val
);
break
;
case
IN:
if
(
CollUtil
.
isNotEmpty
((
Collection
<
Object
>)
val
))
{
criteria
=
criteria
.
and
(
propName
).
in
((
Collection
<
Object
>)
val
);
}
break
;
case
NIN:
if
(
CollUtil
.
isNotEmpty
((
Collection
<
Object
>)
val
))
{
criteria
=
criteria
.
and
(
propName
).
nin
((
Collection
<
Object
>)
val
);
}
break
;
case
NE:
criteria
=
criteria
.
and
(
propName
).
ne
(
val
);
break
;
case
NOT:
criteria
=
criteria
.
and
(
propName
).
not
();
break
;
case
IS_NULL:
criteria
=
criteria
.
and
(
propName
).
is
(
null
);
break
;
case
EXISTS:
criteria
=
criteria
.
and
(
propName
).
exists
(
true
);
break
;
case
BETWEEN:
List
<
Object
>
between
=
new
ArrayList
<>((
List
<
Object
>)
val
);
criteria
=
criteria
.
and
(
propName
).
gte
(
between
.
get
(
0
)).
lte
(
between
.
get
(
1
));
break
;
default
:
break
;
}
}
field
.
setAccessible
(
accessible
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
}
return
new
Query
(
criteria
);
}
private
static
boolean
isBlank
(
final
CharSequence
cs
)
{
int
strLen
;
if
(
cs
==
null
||
(
strLen
=
cs
.
length
())
==
0
)
{
return
true
;
}
for
(
int
i
=
0
;
i
<
strLen
;
i
++)
{
if
(!
Character
.
isWhitespace
(
cs
.
charAt
(
i
)))
{
return
false
;
}
}
return
true
;
}
private
static
List
<
Field
>
getAllFields
(
Class
clazz
,
List
<
Field
>
fields
)
{
if
(
clazz
!=
null
)
{
fields
.
addAll
(
Arrays
.
asList
(
clazz
.
getDeclaredFields
()));
getAllFields
(
clazz
.
getSuperclass
(),
fields
);
}
return
fields
;
}
private
static
String
escapeExprSpecialWord
(
String
keyword
)
{
if
(
ObjectUtil
.
isNotEmpty
(
keyword
))
{
String
[]
fbsArr
=
{
"\\"
,
"$"
,
"("
,
")"
,
"*"
,
"+"
,
"."
,
"["
,
"]"
,
"?"
,
"^"
,
"{"
,
"}"
,
"|"
};
for
(
String
key
:
fbsArr
)
{
if
(
keyword
.
contains
(
key
))
{
keyword
=
keyword
.
replace
(
key
,
"\\"
+
key
);
}
}
}
return
keyword
;
}
}
src/main/java/com/neotel/smfcore/core/device/BaseDeviceHandler.java
0 → 100644
查看文件 @
aac60bd
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
""
;
}
}
src/main/java/com/neotel/smfcore/core/device/IDeviceHandler.java
0 → 100644
查看文件 @
aac60bd
package
com
.
neotel
.
smfcore
.
core
.
device
;
/**
* Created by sunke on 2021/7/13.
*/
public
interface
IDeviceHandler
{
String
getDeviceType
();
}
src/main/java/com/neotel/smfcore/core/device/SmdXlBoxHandler.java
0 → 100644
查看文件 @
aac60bd
package
com
.
neotel
.
smfcore
.
core
.
device
;
/**
* Created by sunke on 2021/7/12.
*/
public
class
SmdXlBoxHandler
implements
IDeviceHandler
{
@Override
public
String
getDeviceType
()
{
return
null
;
}
}
src/main/java/com/neotel/smfcore/core/listener/ApiListener.java
0 → 100644
查看文件 @
aac60bd
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"
;
}
}
src/main/java/com/neotel/smfcore/core/listener/IDeviceListener.java
0 → 100644
查看文件 @
aac60bd
package
com
.
neotel
.
smfcore
.
core
.
listener
;
/**
* Created by sunke on 2021/7/12.
*/
public
interface
IDeviceListener
{
String
onScanCode
(
String
codeStr
);
}
src/main/java/com/neotel/smfcore/core/listener/LiteOrderListener.java
0 → 100644
查看文件 @
aac60bd
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"
;
}
}
src/main/java/com/neotel/smfcore/core/rest/TaskService.java
0 → 100644
查看文件 @
aac60bd
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
);
}
}
}
src/main/java/com/neotel/smfcore/security/TokenFilter.java
查看文件 @
aac60bd
...
...
@@ -19,7 +19,7 @@ import cn.hutool.core.util.StrUtil;
import
com.neotel.smfcore.security.bean.SecurityProperties
;
import
com.neotel.smfcore.security.service.OnlineUserService
;
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
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
src/main/java/com/neotel/smfcore/security/config/SpringSecurityConfig.java
查看文件 @
aac60bd
...
...
@@ -15,7 +15,7 @@
*/
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.security.JwtAccessDeniedHandler
;
import
com.neotel.smfcore.security.JwtAuthenticationEntryPoint
;
...
...
src/main/java/com/neotel/smfcore/security/rest/AuthorizationController.java
查看文件 @
aac60bd
...
...
@@ -15,22 +15,26 @@
*/
package
com
.
neotel
.
smfcore
.
security
.
rest
;
import
com.neotel.smfcore.common.annotation.AnonymousDeleteMapping
;
import
com.neotel.smfcore.common.annotation.AnonymousGetMapping
;
import
com.neotel.smfcore.common.annotation.AnonymousPostMapping
;
import
com.neotel.smfcore.common.annotation.security.AnonymousDeleteMapping
;
import
com.neotel.smfcore.common.annotation.security.AnonymousGetMapping
;
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.TokenProvider
;
import
com.neotel.smfcore.security.bean.LoginProperties
;
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
.dto.AuthUserDto
;
import
com.neotel.smfcore.security.
service
.dto.JwtUserDto
;
import
com.neotel.smfcore.security.
rest.bean
.dto.AuthUserDto
;
import
com.neotel.smfcore.security.
rest.bean
.dto.JwtUserDto
;
import
com.neotel.smfcore.common.utils.RsaUtils
;
import
com.neotel.smfcore.common.utils.SecurityUtils
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
...
...
@@ -45,6 +49,7 @@ import org.springframework.web.bind.annotation.RestController;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -56,9 +61,12 @@ import java.util.Map;
@Api
(
tags
=
"系统:系统授权接口"
)
public
class
AuthorizationController
{
private
final
SecurityProperties
properties
;
// private final RedisUtils redisUtils;
private
final
OnlineUserService
onlineUserService
;
private
final
TokenProvider
tokenProvider
;
@Autowired
private
OnlineUserService
onlineUserService
;
@Autowired
private
TokenProvider
tokenProvider
;
private
final
AuthenticationManagerBuilder
authenticationManagerBuilder
;
@Resource
private
LoginProperties
loginProperties
;
...
...
@@ -89,7 +97,17 @@ public class AuthorizationController {
String
token
=
tokenProvider
.
createToken
(
authentication
);
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 与 用户信息
Map
<
String
,
Object
>
authInfo
=
new
HashMap
<
String
,
Object
>(
2
)
{{
put
(
"token"
,
properties
.
getTokenStartWith
()
+
token
);
...
...
src/main/java/com/neotel/smfcore/security/rest/MenuController.java
0 → 100644
查看文件 @
aac60bd
/*
* 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);
// }
}
src/main/java/com/neotel/smfcore/security/
service
/dto/AuthUserDto.java
→
src/main/java/com/neotel/smfcore/security/
rest/bean
/dto/AuthUserDto.java
查看文件 @
aac60bd
...
...
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
neotel
.
smfcore
.
security
.
service
.
dto
;
package
com
.
neotel
.
smfcore
.
security
.
rest
.
bean
.
dto
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
src/main/java/com/neotel/smfcore/security/
service
/dto/DeptSmallDto.java
→
src/main/java/com/neotel/smfcore/security/
rest/bean
/dto/DeptSmallDto.java
查看文件 @
aac60bd
...
...
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
neotel
.
smfcore
.
security
.
service
.
dto
;
package
com
.
neotel
.
smfcore
.
security
.
rest
.
bean
.
dto
;
import
lombok.Data
;
...
...
src/main/java/com/neotel/smfcore/security/
service
/dto/JwtUserDto.java
→
src/main/java/com/neotel/smfcore/security/
rest/bean
/dto/JwtUserDto.java
查看文件 @
aac60bd
...
...
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* 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.neotel.smfcore.security.service.po.User
;
...
...
src/main/java/com/neotel/smfcore/security/
service
/dto/OnlineUserDto.java
→
src/main/java/com/neotel/smfcore/security/
rest/bean
/dto/OnlineUserDto.java
查看文件 @
aac60bd
...
...
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
neotel
.
smfcore
.
security
.
service
.
dto
;
package
com
.
neotel
.
smfcore
.
security
.
rest
.
bean
.
dto
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
...
...
src/main/java/com/neotel/smfcore/security/
service
/dto/RoleSmallDto.java
→
src/main/java/com/neotel/smfcore/security/
rest/bean
/dto/RoleSmallDto.java
查看文件 @
aac60bd
...
...
@@ -13,16 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
neotel
.
smfcore
.
security
.
service
.
dto
;
package
com
.
neotel
.
smfcore
.
security
.
rest
.
bean
.
dto
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author Zheng Jie
* @date 2018-11-23
*/
@Data
public
class
RoleSmallDto
implements
Serializable
{
...
...
src/main/java/com/neotel/smfcore/security/rest/bean/query/MenuQueryCondition.java
0 → 100644
查看文件 @
aac60bd
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
;
}
src/main/java/com/neotel/smfcore/security/service/OnlineUserService.java
查看文件 @
aac60bd
...
...
@@ -16,8 +16,8 @@
package
com
.
neotel
.
smfcore
.
security
.
service
;
import
com.neotel.smfcore.security.bean.SecurityProperties
;
import
com.neotel.smfcore.security.
service
.dto.JwtUserDto
;
import
com.neotel.smfcore.security.
service
.dto.OnlineUserDto
;
import
com.neotel.smfcore.security.
rest.bean
.dto.JwtUserDto
;
import
com.neotel.smfcore.security.
rest.bean
.dto.OnlineUserDto
;
import
com.neotel.smfcore.common.utils.EncryptUtils
;
import
com.neotel.smfcore.common.utils.FileUtil
;
import
com.neotel.smfcore.common.utils.PageUtil
;
...
...
@@ -41,35 +41,15 @@ import java.util.concurrent.ConcurrentHashMap;
@Slf4j
public
class
OnlineUserService
{
p
rivate
final
SecurityProperties
properties
;
p
ublic
final
SecurityProperties
properties
;
static
Map
<
String
,
OnlineUserDto
>
onlineUserMap
=
new
ConcurrentHashMap
<>();
public
static
Map
<
String
,
OnlineUserDto
>
onlineUserMap
=
new
ConcurrentHashMap
<>();
public
OnlineUserService
(
SecurityProperties
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 pageable /
...
...
src/main/java/com/neotel/smfcore/security/service/UserDetailsServiceImpl.java
查看文件 @
aac60bd
...
...
@@ -18,7 +18,7 @@ package com.neotel.smfcore.security.service;
import
com.neotel.smfcore.common.exception.BadRequestException
;
import
com.neotel.smfcore.common.exception.EntityNotFoundException
;
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.IUserManager
;
import
com.neotel.smfcore.security.service.po.Menu
;
...
...
src/main/java/com/neotel/smfcore/security/service/dao/IMenuDao.java
0 → 100644
查看文件 @
aac60bd
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
{
}
src/main/java/com/neotel/smfcore/security/service/dao/impl/MenuDaoImpl.java
0 → 100644
查看文件 @
aac60bd
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
;
}
}
src/main/java/com/neotel/smfcore/security/service/manager/IMenuManager.java
0 → 100644
查看文件 @
aac60bd
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
>
{
}
src/main/java/com/neotel/smfcore/security/service/manager/impl/MenuManagerImpl.java
0 → 100644
查看文件 @
aac60bd
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
);
}
}
src/main/java/com/neotel/smfcore/security/service/po/User.java
查看文件 @
aac60bd
...
...
@@ -17,16 +17,12 @@ package com.neotel.smfcore.security.service.po;
import
com.alibaba.fastjson.annotation.JSONField
;
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.Setter
;
import
org.springframework.data.annotation.Transient
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.Set
;
/**
* @author Zheng Jie
...
...
src/main/resources/config/application.yml
查看文件 @
aac60bd
server
:
port
:
8
5
00
port
:
8
8
00
spring
:
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论