diff --git a/lms/nladmin-system/pom.xml b/lms/nladmin-system/pom.xml
index c84cc3d54..4ca994362 100644
--- a/lms/nladmin-system/pom.xml
+++ b/lms/nladmin-system/pom.xml
@@ -174,7 +174,31 @@
lombok
true
-
+
+ cn.dev33
+ sa-token-dao-redis
+ 1.31.0
+
+
+ org.apache.commons
+ commons-pool2
+ 2.5.0
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ 3.4.0
+
+
+ org.apache.velocity
+ velocity-engine-core
+ 2.3
+
+
+ com.baomidou
+ mybatis-plus-generator
+ 3.4.0
+
org.apache.poi
diff --git a/lms/nladmin-system/src/main/java/org/nl/AppRun.java b/lms/nladmin-system/src/main/java/org/nl/AppRun.java
index 2fa3edd13..0e1af39e3 100644
--- a/lms/nladmin-system/src/main/java/org/nl/AppRun.java
+++ b/lms/nladmin-system/src/main/java/org/nl/AppRun.java
@@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaIgnore;
import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation;
import com.alicp.jetcache.anno.config.EnableMethodCache;
import io.swagger.annotations.Api;
+import org.mybatis.spring.annotation.MapperScan;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -35,6 +36,7 @@ import org.springframework.web.bind.annotation.RestController;
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
@EnableMethodCache(basePackages = "org.nl")
@EnableCreateCacheAnnotation
+@MapperScan("org.nl.**.mapper")
public class AppRun {
public static void main(String[] args) {
diff --git a/lms/nladmin-system/src/main/java/org/nl/common/TableDataInfo.java b/lms/nladmin-system/src/main/java/org/nl/common/TableDataInfo.java
new file mode 100644
index 000000000..b070572f5
--- /dev/null
+++ b/lms/nladmin-system/src/main/java/org/nl/common/TableDataInfo.java
@@ -0,0 +1,78 @@
+package org.nl.common;
+
+import cn.hutool.http.HttpStatus;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 表格分页数据对象
+ *
+ * @author Lion Li
+ */
+
+@Data
+@NoArgsConstructor
+public class TableDataInfo implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 总记录数
+ */
+ private long totalElements;
+
+ /**
+ * 列表数据
+ */
+ private List content;
+
+ /**
+ * 消息状态码
+ */
+ private int code;
+
+ /**
+ * 消息内容
+ */
+ private String msg;
+
+ /**
+ * 分页
+ *
+ * @param list 列表数据
+ * @param total 总记录数
+ */
+ public TableDataInfo(List list, long total) {
+ this.content = list;
+ this.totalElements = total;
+ }
+
+ public static TableDataInfo build(IPage page) {
+ TableDataInfo rspData = new TableDataInfo<>();
+ rspData.setCode(HttpStatus.HTTP_OK);
+ rspData.setMsg("查询成功");
+ rspData.setContent(page.getRecords());
+ rspData.setTotalElements(page.getTotal());
+ return rspData;
+ }
+
+ public static TableDataInfo build(List list) {
+ TableDataInfo rspData = new TableDataInfo<>();
+ rspData.setCode(HttpStatus.HTTP_OK);
+ rspData.setMsg("查询成功");
+ rspData.setContent(list);
+ rspData.setTotalElements(list.size());
+ return rspData;
+ }
+
+ public static TableDataInfo build() {
+ TableDataInfo rspData = new TableDataInfo<>();
+ rspData.setCode(HttpStatus.HTTP_OK);
+ rspData.setMsg("查询成功");
+ return rspData;
+ }
+
+}
diff --git a/lms/nladmin-system/src/main/java/org/nl/common/domain/constant/DictConstantPool.java b/lms/nladmin-system/src/main/java/org/nl/common/domain/constant/DictConstantPool.java
new file mode 100644
index 000000000..860d84659
--- /dev/null
+++ b/lms/nladmin-system/src/main/java/org/nl/common/domain/constant/DictConstantPool.java
@@ -0,0 +1,11 @@
+package org.nl.common.domain.constant;
+
+/*
+ * @author ZZQ
+ * @Date 2022/12/26 9:29 上午
+ */
+public class DictConstantPool {
+
+ public static final String DICT_SYS_CODE = "system_type";
+ public static final String DICT_SYS_NAME = "所属系统";
+}
diff --git a/lms/nladmin-system/src/main/java/org/nl/common/domain/entity/BaseDto.java b/lms/nladmin-system/src/main/java/org/nl/common/domain/entity/BaseDto.java
new file mode 100644
index 000000000..ef93a801b
--- /dev/null
+++ b/lms/nladmin-system/src/main/java/org/nl/common/domain/entity/BaseDto.java
@@ -0,0 +1,33 @@
+package org.nl.common.domain.entity;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author Zheng Jie
+ * @date 2019年10月24日20:48:53
+ */
+@Data
+public class BaseDto implements Serializable {
+
+ private String create_name;
+
+ private String create_id;
+
+ private String update_optname;
+
+ private String update_optid;
+
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+ private Date create_time;
+
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+ private Date update_time;
+
+}
diff --git a/lms/nladmin-system/src/main/java/org/nl/common/domain/entity/RedisKeyDefine.java b/lms/nladmin-system/src/main/java/org/nl/common/domain/entity/RedisKeyDefine.java
new file mode 100644
index 000000000..99c7c09ce
--- /dev/null
+++ b/lms/nladmin-system/src/main/java/org/nl/common/domain/entity/RedisKeyDefine.java
@@ -0,0 +1,112 @@
+package org.nl.common.domain.entity;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.Getter;
+
+import java.time.Duration;
+
+/**
+ * @Author: lyd
+ * @Description: Redis Key 定义类
+ * @Date: 2022-08-04
+ */
+@Data
+public class RedisKeyDefine {
+
+ @Getter
+ @AllArgsConstructor
+ public enum KeyTypeEnum {
+
+ STRING("String"),
+ LIST("List"),
+ HASH("Hash"),
+ SET("Set"),
+ ZSET("Sorted Set"),
+ STREAM("Stream"),
+ PUBSUB("Pub/Sub");
+
+ /**
+ * 类型
+ */
+ @JsonValue
+ private final String type;
+
+ }
+
+ @Getter
+ @AllArgsConstructor
+ public enum TimeoutTypeEnum {
+
+ FOREVER(1), // 永不超时
+ DYNAMIC(2), // 动态超时
+ FIXED(3); // 固定超时
+
+ /**
+ * 类型
+ */
+ @JsonValue
+ private final Integer type;
+
+ }
+
+ /**
+ * Key 模板
+ */
+ private final String keyTemplate;
+ /**
+ * Key 类型的枚举
+ */
+ private final KeyTypeEnum keyType;
+ /**
+ * Value 类型
+ *
+ * 如果是使用分布式锁,设置为 {@link java.util.concurrent.locks.Lock} 类型
+ */
+ private final Class> valueType;
+ /**
+ * 超时类型
+ */
+ private final TimeoutTypeEnum timeoutType;
+ /**
+ * 过期时间
+ */
+ private final Duration timeout;
+ /**
+ * 备注
+ */
+ private final String memo;
+
+ private RedisKeyDefine(String memo, String keyTemplate, KeyTypeEnum keyType, Class> valueType,
+ TimeoutTypeEnum timeoutType, Duration timeout) {
+ this.memo = memo;
+ this.keyTemplate = keyTemplate;
+ this.keyType = keyType;
+ this.valueType = valueType;
+ this.timeout = timeout;
+ this.timeoutType = timeoutType;
+ // 添加注册表
+ RedisKeyRegistry.add(this);
+ }
+
+ public RedisKeyDefine(String memo, String keyTemplate, KeyTypeEnum keyType, Class> valueType, Duration timeout) {
+ this(memo, keyTemplate, keyType, valueType, TimeoutTypeEnum.FIXED, timeout);
+ }
+
+ public RedisKeyDefine(String memo, String keyTemplate, KeyTypeEnum keyType, Class> valueType, TimeoutTypeEnum timeoutType) {
+ this(memo, keyTemplate, keyType, valueType, timeoutType, Duration.ZERO);
+ }
+
+ /**
+ * 格式化 Key
+ *
+ * 注意,内部采用 {@link String#format(String, Object...)} 实现
+ *
+ * @param args 格式化的参数
+ * @return Key
+ */
+ public String formatKey(Object... args) {
+ return String.format(keyTemplate, args);
+ }
+}
diff --git a/lms/nladmin-system/src/main/java/org/nl/common/domain/entity/RedisKeyRegistry.java b/lms/nladmin-system/src/main/java/org/nl/common/domain/entity/RedisKeyRegistry.java
new file mode 100644
index 000000000..857859173
--- /dev/null
+++ b/lms/nladmin-system/src/main/java/org/nl/common/domain/entity/RedisKeyRegistry.java
@@ -0,0 +1,28 @@
+package org.nl.common.domain.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Author: lyd
+ * @Description: {@link RedisKeyDefine} 注册表
+ * @Date: 2022-08-04
+ */
+public class RedisKeyRegistry {
+ /**
+ * Redis RedisKeyDefine 数组
+ */
+ private static final List defines = new ArrayList<>();
+
+ public static void add(RedisKeyDefine define) {
+ defines.add(define);
+ }
+
+ public static List list() {
+ return defines;
+ }
+
+ public static int size() {
+ return defines.size();
+ }
+}
diff --git a/lms/nladmin-system/src/main/java/org/nl/common/domain/query/BaseQuery.java b/lms/nladmin-system/src/main/java/org/nl/common/domain/query/BaseQuery.java
new file mode 100644
index 000000000..08ad6082b
--- /dev/null
+++ b/lms/nladmin-system/src/main/java/org/nl/common/domain/query/BaseQuery.java
@@ -0,0 +1,73 @@
+package org.nl.common.domain.query;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.LambdaUtils;
+import com.baomidou.mybatisplus.core.toolkit.support.ColumnCache;
+import lombok.Data;
+import org.nl.common.enums.QueryTEnum;
+import org.nl.common.utils.MapOf;
+import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
+
+import java.lang.reflect.Type;
+import java.util.Date;
+import java.util.Map;
+
+/*
+ * @author ZZQ
+ * @Date 2022/12/14 6:33 下午
+ * 泛型必须为数据tb对应do:由mybatis管理
+ */
+@Data
+public class BaseQuery {
+ /**
+ * 模糊查询
+ */
+ private String blurry;
+ /**
+ * 是否启用
+ */
+ private Boolean isUsed;
+ /**
+ * 创建时间范围查询
+ */
+ private Date startTime;
+ private Date endTime;
+
+
+ /**
+ * 字段映射Map:指定字段对应QueryWrapper的查询类型
+ * 字段与数据库字段对应,不支持驼峰
+ * @see QueryTEnum
+ * 通过buid构建
+ */
+ public Map doP = MapOf.of("blurry", QParam.builder().k(new String[]{"name"}).type(QueryTEnum.LK).build()
+ ,"startTime", QParam.builder().k(new String[]{"create_time"}).type(QueryTEnum.LT).build()
+ ,"endTime", QParam.builder().k(new String[]{"create_time"}).type(QueryTEnum.LE).build()
+ ,"sort", QParam.builder().k(new String[]{"sort"}).type(QueryTEnum.BY).build()
+ );
+
+ public QueryWrapper build(){
+ this.paramMapping();
+ QueryWrapper wrapper = new QueryWrapper<>();
+ JSONObject json = (JSONObject)JSONObject.toJSON(this);
+ Type[] types = ((ParameterizedTypeImpl) this.getClass().getGenericSuperclass()).getActualTypeArguments();
+ Map columnMap = LambdaUtils.getColumnMap((Class>) types[0]);
+ json.forEach((key, vel) -> {
+ if (vel != null && !key.equals("doP")){
+ QParam qParam = doP.get(key);
+ if (qParam != null){
+ QueryTEnum.build(qParam.type,wrapper,qParam.k,vel);
+ }else {
+ ColumnCache columnCache = columnMap.get(LambdaUtils.formatKey(key));
+ if (columnCache!=null){
+ wrapper.eq(columnCache.getColumn(),vel);
+ }
+ }
+ }
+ });
+ return wrapper;
+ }
+
+ public void paramMapping(){};
+}
diff --git a/lms/nladmin-system/src/main/java/org/nl/common/domain/query/LConsumer.java b/lms/nladmin-system/src/main/java/org/nl/common/domain/query/LConsumer.java
new file mode 100644
index 000000000..94e775cc3
--- /dev/null
+++ b/lms/nladmin-system/src/main/java/org/nl/common/domain/query/LConsumer.java
@@ -0,0 +1,14 @@
+package org.nl.common.domain.query;
+
+import java.util.Objects;
+
+/*
+ * @author ZZQ
+ * @Date 2022/12/14 8:40 下午
+ */
+@FunctionalInterface
+public interface LConsumer {
+
+ void accept(X x,Y y,Z z);
+
+}
diff --git a/lms/nladmin-system/src/main/java/org/nl/common/domain/query/PageQuery.java b/lms/nladmin-system/src/main/java/org/nl/common/domain/query/PageQuery.java
new file mode 100644
index 000000000..e268c0be7
--- /dev/null
+++ b/lms/nladmin-system/src/main/java/org/nl/common/domain/query/PageQuery.java
@@ -0,0 +1,111 @@
+package org.nl.common.domain.query;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.util.Locale;
+
+
+/**
+ * 分页参数
+ */
+@Data
+public class PageQuery implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 分页大小
+ */
+ private Integer size;
+
+ /**
+ * 当前页数
+ */
+ private Integer page;
+
+ /**
+ * 排序列
+ */
+ private String sort;
+
+ /**
+ * 排序的方向desc或者asc
+ */
+ private Boolean isAsc;
+
+ /**
+ * 当前记录起始索引 默认值
+ */
+ public static final int DEFAULT_PAGE_NUM = 1;
+
+ /**
+ * 每页显示记录数 默认值 默认查全部
+ */
+ public static final int DEFAULT_PAGE_SIZE = Integer.MAX_VALUE;
+
+ public Page build() {
+ Integer pageNum = ObjectUtil.defaultIfNull(getPage(), DEFAULT_PAGE_NUM);
+ Integer pageSize = ObjectUtil.defaultIfNull(getSize(), DEFAULT_PAGE_SIZE);
+ if (pageNum <= 0) {
+ pageNum = DEFAULT_PAGE_NUM;
+ }
+ Page page = new Page<>(pageNum, pageSize);
+ if (StringUtils.isNotEmpty(sort)){
+ String[] split = sort.split(",");
+ for (int i = 0; i < (split.length & ~1); i=i+2) {
+ String col = split[i];
+ OrderItem item = new OrderItem();
+ item.setColumn(col);
+ item.setAsc(split[i+1].toLowerCase(Locale.ROOT).equals("asc"));
+ page.addOrder(item);
+ }
+ }
+ return page;
+ }
+
+ public Page build(Class r) {
+ Integer pageNum = ObjectUtil.defaultIfNull(getPage(), DEFAULT_PAGE_NUM);
+ Integer pageSize = ObjectUtil.defaultIfNull(getSize(), DEFAULT_PAGE_SIZE);
+ if (pageNum <= 0) {
+ pageNum = DEFAULT_PAGE_NUM;
+ }
+ Page page = new Page<>(pageNum, pageSize);
+ if (StringUtils.isNotEmpty(sort)){
+ String[] split = sort.split(",");
+ for (int i = 0; i < (split.length & ~1); i=i+2) {
+ String col = split[i];
+ if ("id".equals(col)){
+ String mId = mappingId(r);
+ col = StringUtils.isNotEmpty(mId)?mId:col;
+ }
+ OrderItem item = new OrderItem();
+ item.setColumn(col);
+ item.setAsc(split[i+1].toLowerCase(Locale.ROOT).equals("asc"));
+ page.addOrder(item);
+ }
+
+ }
+ return page;
+ }
+
+ private String mappingId(R r){
+ if (r instanceof Class){
+ Field[] fields = ((Class) r).getDeclaredFields();
+ for (Field field : fields) {
+ TableId[] byType = field.getAnnotationsByType(TableId.class);
+ if (byType !=null && byType.length>0){
+ TableId tableId = byType[0];
+ return tableId.value();
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/lms/nladmin-system/src/main/java/org/nl/common/domain/query/QParam.java b/lms/nladmin-system/src/main/java/org/nl/common/domain/query/QParam.java
new file mode 100644
index 000000000..dee5c8d4d
--- /dev/null
+++ b/lms/nladmin-system/src/main/java/org/nl/common/domain/query/QParam.java
@@ -0,0 +1,17 @@
+package org.nl.common.domain.query;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.nl.common.enums.QueryTEnum;
+
+/*
+ * @author ZZQ
+ * @Date 2022/12/15 1:41 下午
+ */
+@Builder
+public class QParam {
+ public String[] k;
+ public QueryTEnum type;
+}
diff --git a/lms/nladmin-system/src/main/java/org/nl/common/enums/QueryTEnum.java b/lms/nladmin-system/src/main/java/org/nl/common/enums/QueryTEnum.java
new file mode 100644
index 000000000..5a56212c2
--- /dev/null
+++ b/lms/nladmin-system/src/main/java/org/nl/common/enums/QueryTEnum.java
@@ -0,0 +1,35 @@
+package org.nl.common.enums;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.Getter;
+import org.apache.commons.lang3.StringUtils;
+import org.nl.common.domain.query.LConsumer;
+
+import java.util.Collection;
+
+/*
+ * @author ZZQ
+ * @Date 2022/12/14 8:26 下午
+ */
+@Getter
+public enum QueryTEnum {
+ //
+ EQ((q, k, v) -> { q.eq(k[0],v); }),
+ IN((q, key, o) -> { if (o instanceof Collection){ q.in(key[0],(Collection) o); } }),
+ LK((q, keys, o) -> { for (String key : keys) { q.like(key,o); } }),
+ LE((q, k, v) -> { q.le(k[0],v); }),
+ BY((q, k, v) -> { q.orderByDesc(k[0],v); }),
+ NO((q, k, v) -> { q.isNull(k[0]); }),
+ LT((q, k, v) -> { q.lt(k[0],v); }),
+ OREQ((q, k, v) -> { if (StringUtils.isBlank((String)v)){ q.isNull(k[0]); }else { q.eq(k[0],v); } });
+
+ private LConsumer doP;
+
+ QueryTEnum(LConsumer doP) {
+ this.doP = doP;
+ }
+
+ public static void build(QueryTEnum type, QueryWrapper q, String[] k , Object v){
+ type.getDoP().accept(q,k,v);
+ }
+}
diff --git a/lms/nladmin-system/src/main/java/org/nl/common/utils/CopyUtil.java b/lms/nladmin-system/src/main/java/org/nl/common/utils/CopyUtil.java
new file mode 100644
index 000000000..69f315319
--- /dev/null
+++ b/lms/nladmin-system/src/main/java/org/nl/common/utils/CopyUtil.java
@@ -0,0 +1,36 @@
+package org.nl.common.utils;
+
+import org.springframework.beans.BeanUtils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+/*
+ * @author ZZQ
+ * @Date 2022/12/1 3:35 下午
+ */
+public class CopyUtil {
+ public static List copyList(final Collection sources, final Class clazz) {
+ if (sources == null) {
+ return new ArrayList(0);
+ } else {
+ List list = new ArrayList(sources.size());
+ Iterator var3 = sources.iterator();
+
+ while(var3.hasNext()) {
+ Object source = var3.next();
+
+ try {
+ T dest = clazz.newInstance();
+ BeanUtils.copyProperties(source, dest);
+ list.add(dest);
+ } catch (Throwable var6) {
+ }
+ }
+ return list;
+ }
+ }
+
+}
diff --git a/lms/nladmin-system/src/main/java/org/nl/common/utils/DesUtil.java b/lms/nladmin-system/src/main/java/org/nl/common/utils/DesUtil.java
new file mode 100644
index 000000000..35f7c49bc
--- /dev/null
+++ b/lms/nladmin-system/src/main/java/org/nl/common/utils/DesUtil.java
@@ -0,0 +1,129 @@
+package org.nl.common.utils;
+
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by FernFlower decompiler)
+//
+
+
+import sun.misc.BASE64Decoder;
+import sun.misc.BASE64Encoder;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.DESKeySpec;
+import javax.crypto.spec.IvParameterSpec;
+import java.io.IOException;
+import java.security.SecureRandom;
+
+/**
+ * Des加密解密算法工具类
+ */
+public class DesUtil {
+ //加密算法是des
+ private static final String ALGORITHM = "DES";
+ //转换格式
+ private static final String TRANSFORMATION = "DES/CBC/PKCS5Padding";
+
+ /**
+ * 加密
+ *
+ * @param src 数据源
+ * @param key 密钥,长度必须是8的倍数
+ * @return 返回加密后的数据
+ * @throws Exception 出错
+ */
+ public static byte[] encrypt(byte[] src, byte[] key) throws Exception {
+ // DES算法要求有一个可信任的随机数源
+ SecureRandom sr = new SecureRandom();
+ // 从原始密匙数据建立 DESKeySpec对象
+ DESKeySpec dks = new DESKeySpec(key);
+ // 建立一个密匙工厂,然后用它把DESKeySpec转换成
+ // 一个SecretKey对象
+ SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM);
+ SecretKey securekey = keyFactory.generateSecret(dks);
+ // Cipher对象实际完成加密操作
+ Cipher cipher = Cipher.getInstance(TRANSFORMATION);
+ // 用密匙原始化Cipher对象
+ cipher.init(Cipher.ENCRYPT_MODE, securekey, new IvParameterSpec(key));
+ // 现在,获取数据并加密
+ // 正式执行加密操作
+ return cipher.doFinal(src);
+ }
+
+ /**
+ * 解密
+ *
+ * @param src 数据源
+ * @param key 密钥,长度必须是8的倍数
+ * @return 返回解密后的原始数据
+ * @throws Exception 出错
+ */
+ public static byte[] decrypt(byte[] src, byte[] key) throws Exception {
+ // DES算法要求有一个可信任的随机数源
+ SecureRandom sr = new SecureRandom();
+ // 从原始密匙数据建立一个DESKeySpec对象
+ DESKeySpec dks = new DESKeySpec(key);
+ // 建立一个密匙工厂,然后用它把DESKeySpec对象转换成
+ // 一个SecretKey对象
+ SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM);
+ SecretKey securekey = keyFactory.generateSecret(dks);
+ // Cipher对象实际完成解密操作
+ Cipher cipher = Cipher.getInstance(TRANSFORMATION);
+ // 用密匙原始化Cipher对象
+ cipher.init(Cipher.DECRYPT_MODE, securekey, new IvParameterSpec(key));
+ // 现在,获取数据并解密
+ // 正式执行解密操作
+ return cipher.doFinal(src);
+ }
+
+ /**
+ * Description 根据键值进行加密
+ *
+ * @param data
+ * @param key 加密键byte数组
+ * @return
+ * @throws Exception
+ */
+ public static String encrypt(String data, String key) throws Exception {
+ byte[] bt = encrypt(data.getBytes("UTF-8"), key.getBytes("UTF-8"));
+
+ BASE64Encoder encoder = new BASE64Encoder();
+ return encoder.encode(bt);
+
+ //return new String(Base64.encodeBase64(bt), "UTF-8");
+ }
+
+ /**
+ * Description 根据键值进行解密
+ *
+ * @param data
+ * @param key 加密键byte数组
+ * @return
+ * @throws IOException
+ * @throws Exception
+ */
+ public static String decrypt(String data, String key) throws Exception {
+ if (data == null)
+ return null;
+ BASE64Decoder decoder = new BASE64Decoder();
+ byte[] buf = decoder.decodeBuffer(data);
+
+ byte[] bt = decrypt(buf, key.getBytes("UTF-8"));
+ return new String(bt, "UTF-8");
+ }
+
+
+ public static void main(String[] args) throws Exception {
+ //uL8fXioyU2M=
+ String key = "11111111";
+ String pp = encrypt("123456", key);
+ System.out.println("加密:" + pp);
+
+ String mm2 = decrypt(pp, key);
+ System.out.println("解密:" + mm2);
+
+ }
+
+}
diff --git a/lms/nladmin-system/src/main/java/org/nl/common/utils/IdUtil.java b/lms/nladmin-system/src/main/java/org/nl/common/utils/IdUtil.java
new file mode 100644
index 000000000..41f47c0b4
--- /dev/null
+++ b/lms/nladmin-system/src/main/java/org/nl/common/utils/IdUtil.java
@@ -0,0 +1,11 @@
+package org.nl.common.utils;
+
+public class IdUtil {
+ public static Long getLongId() {
+ return cn.hutool.core.util.IdUtil.getSnowflake(1, 1).nextId();
+ }
+
+ public static String getStringId() {
+ return String.valueOf(IdUtil.getLongId());
+ }
+}
diff --git a/lms/nladmin-system/src/main/java/org/nl/common/utils/MapOf.java b/lms/nladmin-system/src/main/java/org/nl/common/utils/MapOf.java
new file mode 100644
index 000000000..fc8dc01da
--- /dev/null
+++ b/lms/nladmin-system/src/main/java/org/nl/common/utils/MapOf.java
@@ -0,0 +1,20 @@
+package org.nl.common.utils;
+
+
+import java.io.Serializable;
+import java.util.HashMap;
+
+/*
+ * @author ZZQ
+ * @Date 2022/11/29 2:55 下午
+ */
+public class MapOf implements Serializable {
+
+ public static HashMap of(K... key){
+ HashMap map = new HashMap<>();
+ for (int i = 0; i < (key.length & ~1); i=i+2) {
+ map.put(key[i],key[i+1]);
+ }
+ return map;
+ }
+}
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/common/utils/SecurityUtils.java b/lms/nladmin-system/src/main/java/org/nl/common/utils/SecurityUtils.java
similarity index 69%
rename from lms/nladmin-system/src/main/java/org/nl/modules/common/utils/SecurityUtils.java
rename to lms/nladmin-system/src/main/java/org/nl/common/utils/SecurityUtils.java
index c97afd49f..ba78697cd 100644
--- a/lms/nladmin-system/src/main/java/org/nl/modules/common/utils/SecurityUtils.java
+++ b/lms/nladmin-system/src/main/java/org/nl/common/utils/SecurityUtils.java
@@ -1,14 +1,11 @@
-package org.nl.modules.common.utils;
+package org.nl.common.utils;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import lombok.extern.slf4j.Slf4j;
-import org.nl.modules.common.utils.dto.CurrentUser;
-import org.nl.modules.system.service.dto.UserDto;
-import org.nl.modules.system.service.impl.UserServiceImpl;
-import org.nl.modules.wql.util.SpringContextHolder;
+import org.nl.system.service.user.dto.CurrentUser;
import java.util.List;
@@ -32,13 +29,7 @@ public class SecurityUtils {
return json.toBean(CurrentUser.class);
}
} catch (Exception e) {
- CurrentUser currentUser=new CurrentUser();
- currentUser.setId((long) 2);
- currentUser.setNickName("默认用户");
- currentUser.setUsername("default");
- UserDto userDto = SpringContextHolder.getBean(UserServiceImpl.class).findById(2);
- currentUser.setUser(userDto);
- return currentUser;
+ return new CurrentUser();
}
return null;
}
@@ -58,7 +49,7 @@ public class SecurityUtils {
* @return 系统用户名称
*/
public static String getCurrentNickName() {
- return getCurrentUser().getNickName();
+ return getCurrentUser().getPresonName();
}
/**
@@ -66,7 +57,7 @@ public class SecurityUtils {
*
* @return 系统用户Id
*/
- public static Long getCurrentUserId() {
+ public static String getCurrentUserId() {
return getCurrentUser().getId();
}
@@ -76,7 +67,8 @@ public class SecurityUtils {
* @return 系统用户Id
*/
public static Long getDeptId() {
- return getCurrentUser().getUser().getDept().getId();
+// return getCurrentUser().getUser().getDept().getId();
+ return 1L;
}
/**
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/common/base/BaseDTO.java b/lms/nladmin-system/src/main/java/org/nl/modules/common/base/BaseDTO.java
index ccb2a517b..93f608e94 100644
--- a/lms/nladmin-system/src/main/java/org/nl/modules/common/base/BaseDTO.java
+++ b/lms/nladmin-system/src/main/java/org/nl/modules/common/base/BaseDTO.java
@@ -1,5 +1,7 @@
package org.nl.modules.common.base;
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder;
@@ -7,6 +9,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.sql.Timestamp;
+import java.util.Date;
/**
* @author Zheng Jie
@@ -20,22 +23,9 @@ public class BaseDTO implements Serializable {
private String updatedBy;
- private Timestamp createTime;
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date createTime;
- private Timestamp updateTime;
-
- @Override
- public String toString() {
- ToStringBuilder builder = new ToStringBuilder(this);
- Field[] fields = this.getClass().getDeclaredFields();
- try {
- for (Field f : fields) {
- f.setAccessible(true);
- builder.append(f.getName(), f.get(this)).append("\n");
- }
- } catch (Exception e) {
- builder.append("toString builder encounter an error");
- }
- return builder.toString();
- }
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date updateTime;
}
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/logging/aspect/LogAspect.java b/lms/nladmin-system/src/main/java/org/nl/modules/logging/aspect/LogAspect.java
index 24e8e05f4..53c68b192 100644
--- a/lms/nladmin-system/src/main/java/org/nl/modules/logging/aspect/LogAspect.java
+++ b/lms/nladmin-system/src/main/java/org/nl/modules/logging/aspect/LogAspect.java
@@ -26,7 +26,7 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.nl.modules.common.utils.RequestHolder;
-import org.nl.modules.common.utils.SecurityUtils;
+import org.nl.common.utils.SecurityUtils;
import org.nl.modules.common.utils.StringUtils;
import org.nl.modules.common.utils.ThrowableUtil;
import org.nl.modules.logging.domain.Log;
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/logging/rest/LogController.java b/lms/nladmin-system/src/main/java/org/nl/modules/logging/rest/LogController.java
index 27e5d2d84..d7a6f6b97 100644
--- a/lms/nladmin-system/src/main/java/org/nl/modules/logging/rest/LogController.java
+++ b/lms/nladmin-system/src/main/java/org/nl/modules/logging/rest/LogController.java
@@ -18,7 +18,7 @@ package org.nl.modules.logging.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
-import org.nl.modules.common.utils.SecurityUtils;
+import org.nl.common.utils.SecurityUtils;
import org.nl.modules.logging.annotation.Log;
import org.nl.modules.logging.service.LogService;
import org.nl.modules.logging.service.dto.LogQueryCriteria;
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/logicflow/service/impl/StageImageServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/modules/logicflow/service/impl/StageImageServiceImpl.java
index 09ab23b3f..7a0843909 100644
--- a/lms/nladmin-system/src/main/java/org/nl/modules/logicflow/service/impl/StageImageServiceImpl.java
+++ b/lms/nladmin-system/src/main/java/org/nl/modules/logicflow/service/impl/StageImageServiceImpl.java
@@ -7,7 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.exception.BadRequestException;
-import org.nl.modules.common.utils.SecurityUtils;
+import org.nl.common.utils.SecurityUtils;
import org.nl.modules.logicflow.service.StageImageService;
import org.nl.modules.logicflow.service.dto.StageImageDto;
import org.nl.modules.wql.core.bean.ResultBean;
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/logicflow/service/impl/StageServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/modules/logicflow/service/impl/StageServiceImpl.java
index d37abd98b..9e6eb6abb 100644
--- a/lms/nladmin-system/src/main/java/org/nl/modules/logicflow/service/impl/StageServiceImpl.java
+++ b/lms/nladmin-system/src/main/java/org/nl/modules/logicflow/service/impl/StageServiceImpl.java
@@ -7,7 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.exception.BadRequestException;
-import org.nl.modules.common.utils.SecurityUtils;
+import org.nl.common.utils.SecurityUtils;
import org.nl.modules.logicflow.service.StageService;
import org.nl.modules.logicflow.service.dto.StageDto;
import org.nl.modules.wql.core.bean.ResultBean;
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/config/JobRunner.java b/lms/nladmin-system/src/main/java/org/nl/modules/quartz/config/JobRunner.java
deleted file mode 100644
index 85f1b8b74..000000000
--- a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/config/JobRunner.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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 org.nl.modules.quartz.config;
-
-import lombok.RequiredArgsConstructor;
-import org.nl.modules.quartz.domain.QuartzJob;
-import org.nl.modules.quartz.repository.QuartzJobRepository;
-import org.nl.modules.quartz.utils.QuartzManage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.ApplicationArguments;
-import org.springframework.boot.ApplicationRunner;
-import org.springframework.core.annotation.Order;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-
-/**
- * @author Zheng Jie
- * @date 2019-01-07
- */
-@Component
-@RequiredArgsConstructor
-@Order(100)
-public class JobRunner implements ApplicationRunner {
- private static final Logger log = LoggerFactory.getLogger(JobRunner.class);
- private final QuartzJobRepository quartzJobRepository;
- private final QuartzManage quartzManage;
-
- /**
- * 项目启动时重新激活启用的定时任务
- *
- * @param applicationArguments /
- */
- @Override
- public void run(ApplicationArguments applicationArguments) {
- log.info("--------------------注入定时任务---------------------");
- List quartzJobs = quartzJobRepository.findByIsPauseIsFalse();
- quartzJobs.forEach(quartzManage::addJob);
- log.info("--------------------定时任务注入完成---------------------");
- }
-}
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/config/QuartzConfig.java b/lms/nladmin-system/src/main/java/org/nl/modules/quartz/config/QuartzConfig.java
deleted file mode 100644
index 27baea90b..000000000
--- a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/config/QuartzConfig.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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 org.nl.modules.quartz.config;
-
-import org.quartz.Scheduler;
-import org.quartz.spi.TriggerFiredBundle;
-import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.quartz.AdaptableJobFactory;
-import org.springframework.scheduling.quartz.SchedulerFactoryBean;
-import org.springframework.stereotype.Component;
-
-/**
- * 定时任务配置
- * @author /
- * @date 2019-01-07
- */
-@Configuration
-public class QuartzConfig {
-
- /**
- * 解决Job中注入Spring Bean为null的问题
- */
- @Component("quartzJobFactory")
- public static class QuartzJobFactory extends AdaptableJobFactory {
-
- private final AutowireCapableBeanFactory capableBeanFactory;
-
- public QuartzJobFactory(AutowireCapableBeanFactory capableBeanFactory) {
- this.capableBeanFactory = capableBeanFactory;
- }
-
- @Override
- protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
-
- //调用父类的方法
- Object jobInstance = super.createJobInstance(bundle);
- capableBeanFactory.autowireBean(jobInstance);
- return jobInstance;
- }
- }
-
- /**
- * 注入scheduler到spring
- * @param quartzJobFactory /
- * @return Scheduler
- * @throws Exception /
- */
- @Bean(name = "scheduler")
- public Scheduler scheduler(QuartzJobFactory quartzJobFactory) throws Exception {
- SchedulerFactoryBean factoryBean=new SchedulerFactoryBean();
- factoryBean.setJobFactory(quartzJobFactory);
- factoryBean.afterPropertiesSet();
- Scheduler scheduler=factoryBean.getScheduler();
- scheduler.start();
- return scheduler;
- }
-}
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/domain/QuartzJob.java b/lms/nladmin-system/src/main/java/org/nl/modules/quartz/domain/QuartzJob.java
deleted file mode 100644
index bce16045d..000000000
--- a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/domain/QuartzJob.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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 org.nl.modules.quartz.domain;
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Getter;
-import lombok.Setter;
-import org.nl.modules.common.base.BaseEntity;
-
-import javax.persistence.*;
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-import java.io.Serializable;
-
-/**
- * @author Zheng Jie
- * @date 2019-01-07
- */
-@Getter
-@Setter
-@Entity
-@Table(name = "sys_quartz_job")
-public class QuartzJob extends BaseEntity implements Serializable {
-
- public static final String JOB_KEY = "JOB_KEY";
-
- @Id
- @Column(name = "job_id")
- @NotNull(groups = {Update.class})
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
-
- @Transient
- @ApiModelProperty(value = "用于子任务唯一标识", hidden = true)
- private String uuid;
-
- @ApiModelProperty(value = "定时器名称")
- private String jobName;
-
- @NotBlank
- @ApiModelProperty(value = "Bean名称")
- private String beanName;
-
- @NotBlank
- @ApiModelProperty(value = "方法名称")
- private String methodName;
-
- @ApiModelProperty(value = "参数")
- private String params;
-
- @NotBlank
- @ApiModelProperty(value = "cron表达式")
- private String cronExpression;
-
- @ApiModelProperty(value = "状态,暂时或启动")
- private Boolean isPause = false;
-
- @ApiModelProperty(value = "负责人")
- private String personInCharge;
-
- @ApiModelProperty(value = "报警邮箱")
- private String email;
-
- @ApiModelProperty(value = "子任务")
- private String subTask;
-
- @ApiModelProperty(value = "失败后暂停")
- private Boolean pauseAfterFailure;
-
- @NotBlank
- @ApiModelProperty(value = "备注")
- private String description;
-}
\ No newline at end of file
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/domain/QuartzLog.java b/lms/nladmin-system/src/main/java/org/nl/modules/quartz/domain/QuartzLog.java
deleted file mode 100644
index fbdb2d1e4..000000000
--- a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/domain/QuartzLog.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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 org.nl.modules.quartz.domain;
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import org.hibernate.annotations.CreationTimestamp;
-
-import javax.persistence.*;
-import java.io.Serializable;
-import java.sql.Timestamp;
-
-/**
- * @author Zheng Jie
- * @date 2019-01-07
- */
-@Entity
-@Data
-@Table(name = "sys_quartz_log")
-public class QuartzLog implements Serializable {
-
- @Id
- @Column(name = "log_id")
- @ApiModelProperty(value = "ID", hidden = true)
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
-
- @ApiModelProperty(value = "任务名称", hidden = true)
- private String jobName;
-
- @ApiModelProperty(value = "bean名称", hidden = true)
- private String beanName;
-
- @ApiModelProperty(value = "方法名称", hidden = true)
- private String methodName;
-
- @ApiModelProperty(value = "参数", hidden = true)
- private String params;
-
- @ApiModelProperty(value = "cron表达式", hidden = true)
- private String cronExpression;
-
- @ApiModelProperty(value = "状态", hidden = true)
- private Boolean isSuccess;
-
- @ApiModelProperty(value = "异常详情", hidden = true)
- private String exceptionDetail;
-
- @ApiModelProperty(value = "执行耗时", hidden = true)
- private Long time;
-
- @CreationTimestamp
- @ApiModelProperty(value = "创建时间", hidden = true)
- private Timestamp createTime;
-}
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/repository/QuartzJobRepository.java b/lms/nladmin-system/src/main/java/org/nl/modules/quartz/repository/QuartzJobRepository.java
deleted file mode 100644
index a63fcf291..000000000
--- a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/repository/QuartzJobRepository.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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 org.nl.modules.quartz.repository;
-
-import org.nl.modules.quartz.domain.QuartzJob;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-
-import java.util.List;
-
-/**
- * @author Zheng Jie
- * @date 2019-01-07
- */
-public interface QuartzJobRepository extends JpaRepository, JpaSpecificationExecutor {
-
- /**
- * 查询启用的任务
- * @return List
- */
- List findByIsPauseIsFalse();
-}
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/repository/QuartzLogRepository.java b/lms/nladmin-system/src/main/java/org/nl/modules/quartz/repository/QuartzLogRepository.java
deleted file mode 100644
index 54c5101fb..000000000
--- a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/repository/QuartzLogRepository.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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 org.nl.modules.quartz.repository;
-
-import org.nl.modules.quartz.domain.QuartzLog;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-
-/**
- * @author Zheng Jie
- * @date 2019-01-07
- */
-public interface QuartzLogRepository extends JpaRepository, JpaSpecificationExecutor {
-
-}
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/service/QuartzJobService.java b/lms/nladmin-system/src/main/java/org/nl/modules/quartz/service/QuartzJobService.java
deleted file mode 100644
index 74ec177f6..000000000
--- a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/service/QuartzJobService.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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 org.nl.modules.quartz.service;
-
-import org.nl.modules.quartz.domain.QuartzJob;
-import org.nl.modules.quartz.domain.QuartzLog;
-import org.nl.modules.quartz.service.dto.JobQueryCriteria;
-import org.springframework.data.domain.Pageable;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Zheng Jie
- * @date 2019-01-07
- */
-public interface QuartzJobService {
-
- /**
- * 分页查询
- *
- * @param criteria 条件
- * @param pageable 分页参数
- * @return /
- */
- Object queryAll(JobQueryCriteria criteria, Pageable pageable);
-
- /**
- * 查询全部
- *
- * @param criteria 条件
- * @return /
- */
- List queryAll(JobQueryCriteria criteria);
-
- /**
- * 分页查询日志
- *
- * @param criteria 条件
- * @param pageable 分页参数
- * @return /
- */
- Object queryAllLog(JobQueryCriteria criteria, Pageable pageable);
-
- /**
- * 查询全部
- *
- * @param criteria 条件
- * @return /
- */
- List queryAllLog(JobQueryCriteria criteria);
-
- /**
- * 创建
- *
- * @param resources /
- */
- void create(QuartzJob resources);
-
- /**
- * 编辑
- *
- * @param resources /
- */
- void update(QuartzJob resources);
-
- /**
- * 删除任务
- *
- * @param ids /
- */
- void delete(Set ids);
-
- /**
- * 根据ID查询
- *
- * @param id ID
- * @return /
- */
- QuartzJob findById(Long id);
-
- /**
- * 更改定时任务状态
- *
- * @param quartzJob /
- */
- void updateIsPause(QuartzJob quartzJob);
-
- /**
- * 立即执行定时任务
- *
- * @param quartzJob /
- */
- void execution(QuartzJob quartzJob);
-
-
- /**
- * 执行子任务
- *
- * @param tasks /
- * @throws InterruptedException /
- */
- void executionSubJob(String[] tasks) throws InterruptedException;
-}
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/service/dto/JobQueryCriteria.java b/lms/nladmin-system/src/main/java/org/nl/modules/quartz/service/dto/JobQueryCriteria.java
deleted file mode 100644
index 2279effc9..000000000
--- a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/service/dto/JobQueryCriteria.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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 org.nl.modules.quartz.service.dto;
-
-import lombok.Data;
-import org.nl.modules.common.annotation.Query;
-
-import java.sql.Timestamp;
-import java.util.List;
-
-/**
- * @author Zheng Jie
- * @date 2019-6-4 10:33:02
- */
-@Data
-public class JobQueryCriteria {
-
- @Query(type = Query.Type.INNER_LIKE)
- private String jobName;
-
- @Query
- private Boolean isSuccess;
-
- @Query(type = Query.Type.BETWEEN)
- private List createTime;
-}
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/service/impl/QuartzJobServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/modules/quartz/service/impl/QuartzJobServiceImpl.java
deleted file mode 100644
index edc15b6b6..000000000
--- a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/service/impl/QuartzJobServiceImpl.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * 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 org.nl.modules.quartz.service.impl;
-
-import cn.hutool.core.util.IdUtil;
-import cn.hutool.core.util.StrUtil;
-import lombok.RequiredArgsConstructor;
-import org.nl.modules.common.exception.BadRequestException;
-import org.nl.modules.common.utils.PageUtil;
-import org.nl.modules.common.utils.QueryHelp;
-import org.nl.modules.common.utils.RedisUtils;
-import org.nl.modules.common.utils.ValidationUtil;
-import org.nl.modules.quartz.domain.QuartzJob;
-import org.nl.modules.quartz.domain.QuartzLog;
-import org.nl.modules.quartz.repository.QuartzJobRepository;
-import org.nl.modules.quartz.repository.QuartzLogRepository;
-import org.nl.modules.quartz.service.QuartzJobService;
-import org.nl.modules.quartz.service.dto.JobQueryCriteria;
-import org.nl.modules.quartz.utils.QuartzManage;
-import org.quartz.CronExpression;
-import org.springframework.data.domain.Pageable;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Zheng Jie
- * @date 2019-01-07
- */
-@RequiredArgsConstructor
-@Service(value = "quartzJobService")
-public class QuartzJobServiceImpl implements QuartzJobService {
-
- private final QuartzJobRepository quartzJobRepository;
- private final QuartzLogRepository quartzLogRepository;
- private final QuartzManage quartzManage;
- private final RedisUtils redisUtils;
-
- @Override
- public Object queryAll(JobQueryCriteria criteria, Pageable pageable) {
- return PageUtil.toPage(quartzJobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable));
- }
-
- @Override
- public Object queryAllLog(JobQueryCriteria criteria, Pageable pageable) {
- return PageUtil.toPage(quartzLogRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable));
- }
-
- @Override
- public List queryAll(JobQueryCriteria criteria) {
- return quartzJobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder));
- }
-
- @Override
- public List queryAllLog(JobQueryCriteria criteria) {
- return quartzLogRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder));
- }
-
- @Override
- public QuartzJob findById(Long id) {
- QuartzJob quartzJob = quartzJobRepository.findById(id).orElseGet(QuartzJob::new);
- ValidationUtil.isNull(quartzJob.getId(), "QuartzJob", "id", id);
- return quartzJob;
- }
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void create(QuartzJob resources) {
- if (!CronExpression.isValidExpression(resources.getCronExpression())) {
- throw new BadRequestException("cron表达式格式错误");
- }
- resources = quartzJobRepository.save(resources);
- quartzManage.addJob(resources);
- }
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void update(QuartzJob resources) {
- if (!CronExpression.isValidExpression(resources.getCronExpression())) {
- throw new BadRequestException("cron表达式格式错误");
- }
- if (StrUtil.isNotEmpty(resources.getSubTask())) {
- List tasks = Arrays.asList(resources.getSubTask().split("[,,]"));
- if (tasks.contains(resources.getId().toString())) {
- throw new BadRequestException("子任务中不能添加当前任务ID");
- }
- }
- resources = quartzJobRepository.save(resources);
- quartzManage.updateJobCron(resources);
- }
-
- @Override
- public void updateIsPause(QuartzJob quartzJob) {
- if (quartzJob.getIsPause()) {
- quartzManage.resumeJob(quartzJob);
- quartzJob.setIsPause(false);
- } else {
- quartzManage.pauseJob(quartzJob);
- quartzJob.setIsPause(true);
- }
- quartzJobRepository.save(quartzJob);
- }
-
- @Override
- public void execution(QuartzJob quartzJob) {
- quartzManage.runJobNow(quartzJob);
- }
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void delete(Set ids) {
- for (Long id : ids) {
- QuartzJob quartzJob = findById(id);
- quartzManage.deleteJob(quartzJob);
- quartzJobRepository.delete(quartzJob);
- }
- }
-
- @Async
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void executionSubJob(String[] tasks) throws InterruptedException {
- for (String id : tasks) {
- QuartzJob quartzJob = findById(Long.parseLong(id));
- // 执行任务
- String uuid = IdUtil.simpleUUID();
- quartzJob.setUuid(uuid);
- // 执行任务
- execution(quartzJob);
- // 获取执行状态,如果执行失败则停止后面的子任务执行
- Boolean result = (Boolean) redisUtils.get(uuid);
- while (result == null) {
- // 休眠5秒,再次获取子任务执行情况
- Thread.sleep(5000);
- result = (Boolean) redisUtils.get(uuid);
- }
- if (!result) {
- redisUtils.del(uuid);
- break;
- }
- }
- }
-
-}
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/task/TestTask.java b/lms/nladmin-system/src/main/java/org/nl/modules/quartz/task/TestTask.java
deleted file mode 100644
index 0d67ce09e..000000000
--- a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/task/TestTask.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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 org.nl.modules.quartz.task;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-/**
- * 测试用
- * @author Zheng Jie
- * @date 2019-01-08
- */
-@Slf4j
-@Component
-public class TestTask {
-
- public void run(){
- log.info("run 执行成功");
- }
-
- public void run1(String str){
- log.info("run1 执行成功,参数为: {}" + str);
- }
-
- public void run2(){
- log.info("run2 执行成功");
- }
-}
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/utils/QuartzRunnable.java b/lms/nladmin-system/src/main/java/org/nl/modules/quartz/utils/QuartzRunnable.java
deleted file mode 100644
index e2ef49bad..000000000
--- a/lms/nladmin-system/src/main/java/org/nl/modules/quartz/utils/QuartzRunnable.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 org.nl.modules.quartz.utils;
-
-import cn.hutool.core.util.StrUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.nl.modules.wql.util.SpringContextHolder;
-import org.springframework.util.ReflectionUtils;
-
-import java.lang.reflect.Method;
-import java.util.concurrent.Callable;
-
-/**
- * 执行定时任务
- * @author /
- */
-@Slf4j
-public class QuartzRunnable implements Callable {
-
- private final Object target;
- private final Method method;
- private final String params;
-
- QuartzRunnable(String beanName, String methodName, String params)
- throws NoSuchMethodException, SecurityException {
- this.target = SpringContextHolder.getBean(beanName);
- this.params = params;
-
- if (StrUtil.isNotEmpty(params)) {
- this.method = target.getClass().getDeclaredMethod(methodName, String.class);
- } else {
- this.method = target.getClass().getDeclaredMethod(methodName);
- }
- }
-
- @Override
- public Object call() throws Exception {
- ReflectionUtils.makeAccessible(method);
- if (StrUtil.isNotEmpty(params)) {
- method.invoke(target, params);
- } else {
- method.invoke(target);
- }
- return null;
- }
-}
diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/security/rest/AuthorizationController.java b/lms/nladmin-system/src/main/java/org/nl/modules/security/rest/AuthorizationController.java
deleted file mode 100644
index e87128f6a..000000000
--- a/lms/nladmin-system/src/main/java/org/nl/modules/security/rest/AuthorizationController.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * 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 org.nl.modules.security.rest;
-
-import cn.dev33.satoken.secure.SaSecureUtil;
-import cn.dev33.satoken.stp.SaLoginModel;
-import cn.dev33.satoken.stp.StpUtil;
-import cn.hutool.core.util.IdUtil;
-import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSONObject;
-import com.wf.captcha.base.Captcha;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.nl.modules.common.config.RsaProperties;
-import org.nl.modules.common.exception.BadRequestException;
-import org.nl.modules.common.utils.RedisUtils;
-import org.nl.modules.common.utils.RsaUtils;
-import org.nl.modules.common.utils.SecurityUtils;
-import org.nl.modules.common.utils.dto.CurrentUser;
-import org.nl.modules.security.config.bean.LoginCodeEnum;
-import org.nl.modules.security.config.bean.LoginProperties;
-import org.nl.modules.security.service.OnlineUserService;
-import org.nl.modules.security.service.dto.AuthUserDto;
-import org.nl.modules.system.service.RoleService;
-import org.nl.modules.system.service.UserService;
-import org.nl.modules.system.service.dto.UserDto;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author Zheng Jie
- * @date 2018-11-23
- * 授权、根据token获取用户详细信息
- */
-@Slf4j
-@RestController
-@RequestMapping("/auth")
-@RequiredArgsConstructor
-@Api(tags = "系统:系统授权接口")
-public class AuthorizationController {
- private final RedisUtils redisUtils;
- private final OnlineUserService onlineUserService;
- private final UserService userService;
- private final RoleService roleService;
-
- @Resource
- private LoginProperties loginProperties;
-
- @ApiOperation("登录授权")
- @PostMapping(value = "/login")
- public ResponseEntity