diff --git a/src/main/java/com/lz/modules/command/BaseCommand.java b/src/main/java/com/lz/modules/command/BaseCommand.java index b689aa9a..05ce204f 100644 --- a/src/main/java/com/lz/modules/command/BaseCommand.java +++ b/src/main/java/com/lz/modules/command/BaseCommand.java @@ -14,6 +14,10 @@ public abstract class BaseCommand { public static final String task = "task"; public static final String record = "record"; public static final String help = "help"; + public static final String en = "en"; + public static final String de = "de"; + public static final String ent = "ten"; + public static final String det = "tde"; protected String[] tokens; diff --git a/src/main/java/com/lz/modules/command/base1000/DeCommand.java b/src/main/java/com/lz/modules/command/base1000/DeCommand.java new file mode 100644 index 00000000..7ee9f4b3 --- /dev/null +++ b/src/main/java/com/lz/modules/command/base1000/DeCommand.java @@ -0,0 +1,44 @@ +package com.lz.modules.command.base1000; + +import com.lz.common.utils.Constant; +import com.lz.common.utils.R; +import com.lz.modules.app.utils.t.Tuple; +import com.lz.modules.command.BaseCommand; +import com.lz.modules.command.ICommand; +import com.lz.modules.command.annotation.Description; +import com.lz.modules.command.annotation.Name; +import com.lz.modules.command.annotation.Summary; +import com.lz.modules.command.utils.PAesUtil; +import com.lz.modules.performance.service.ResultTaskService; +import com.lz.modules.third.service.TaskRespService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @Author: djc + * @Desc: 绩效任务删除命令 + * @Date: 2021/1/28 16:12 + */ +@Slf4j +@Name("de") +@Component("de") +@Summary("解密数据 ") +@Description(Constant.EXAMPLE + + " de xxx " +) +public class DeCommand extends BaseCommand implements ICommand{ + + @Autowired + private ResultTaskService resultTaskService; + @Autowired + private TaskRespService taskRespService; + + @Override + public R process(Tuple tuple) throws Exception { + String online = "RiZUH6CU9JK7x5LVou9d8Q1"; + String de = PAesUtil.decrypt(tokens[1], online); + log.info("de data :" + de); + return R.ok(250, de); + } +} diff --git a/src/main/java/com/lz/modules/command/base1000/EnCommand.java b/src/main/java/com/lz/modules/command/base1000/EnCommand.java new file mode 100644 index 00000000..e1e561f6 --- /dev/null +++ b/src/main/java/com/lz/modules/command/base1000/EnCommand.java @@ -0,0 +1,48 @@ +package com.lz.modules.command.base1000; + +import com.alibaba.fastjson.JSON; +import com.lz.common.utils.Constant; +import com.lz.common.utils.NumberUtil; +import com.lz.common.utils.R; +import com.lz.modules.app.utils.t.Tuple; +import com.lz.modules.app.utils.t.TwoTuple; +import com.lz.modules.command.BaseCommand; +import com.lz.modules.command.ICommand; +import com.lz.modules.command.annotation.Description; +import com.lz.modules.command.annotation.Name; +import com.lz.modules.command.annotation.Summary; +import com.lz.modules.command.utils.PAesUtil; +import com.lz.modules.flow.model.TaskDto; +import com.lz.modules.performance.service.ResultTaskService; +import com.lz.modules.third.service.TaskRespService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @Author: djc + * @Desc: 绩效任务删除命令 + * @Date: 2021/1/28 16:12 + */ +@Slf4j +@Name("en") +@Component("en") +@Summary("加密 ") +@Description(Constant.EXAMPLE + + " 加密 数据 en xxx " +) +public class EnCommand extends BaseCommand implements ICommand{ + + @Autowired + private ResultTaskService resultTaskService; + @Autowired + private TaskRespService taskRespService; + + @Override + public R process(Tuple tuple) throws Exception { + String online = "RiZUH6CU9JK7x5LVou9d8Q1"; + String de = PAesUtil.encrypt(tokens[1], online); + log.info("de data :" + de); + return R.ok(250, de); + } +} diff --git a/src/main/java/com/lz/modules/command/base1000/TDeCommand.java b/src/main/java/com/lz/modules/command/base1000/TDeCommand.java new file mode 100644 index 00000000..4fd62b19 --- /dev/null +++ b/src/main/java/com/lz/modules/command/base1000/TDeCommand.java @@ -0,0 +1,44 @@ +package com.lz.modules.command.base1000; + +import com.lz.common.utils.Constant; +import com.lz.common.utils.R; +import com.lz.modules.app.utils.t.Tuple; +import com.lz.modules.command.BaseCommand; +import com.lz.modules.command.ICommand; +import com.lz.modules.command.annotation.Description; +import com.lz.modules.command.annotation.Name; +import com.lz.modules.command.annotation.Summary; +import com.lz.modules.command.utils.PAesUtil; +import com.lz.modules.performance.service.ResultTaskService; +import com.lz.modules.third.service.TaskRespService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @Author: djc + * @Desc: 绩效任务删除命令 + * @Date: 2021/1/28 16:12 + */ +@Slf4j +@Name("tde") +@Component("tde") +@Summary("测试环境解密数据 ") +@Description(Constant.EXAMPLE + + " tde xxx " +) +public class TDeCommand extends BaseCommand implements ICommand{ + + @Autowired + private ResultTaskService resultTaskService; + @Autowired + private TaskRespService taskRespService; + + @Override + public R process(Tuple tuple) throws Exception { + String test = "123456"; + String de = PAesUtil.decrypt(tokens[1], test); + log.info("de data :" + de); + return R.ok(250, de); + } +} diff --git a/src/main/java/com/lz/modules/command/base1000/TEnCommand.java b/src/main/java/com/lz/modules/command/base1000/TEnCommand.java new file mode 100644 index 00000000..0daf2047 --- /dev/null +++ b/src/main/java/com/lz/modules/command/base1000/TEnCommand.java @@ -0,0 +1,44 @@ +package com.lz.modules.command.base1000; + +import com.lz.common.utils.Constant; +import com.lz.common.utils.R; +import com.lz.modules.app.utils.t.Tuple; +import com.lz.modules.command.BaseCommand; +import com.lz.modules.command.ICommand; +import com.lz.modules.command.annotation.Description; +import com.lz.modules.command.annotation.Name; +import com.lz.modules.command.annotation.Summary; +import com.lz.modules.command.utils.PAesUtil; +import com.lz.modules.performance.service.ResultTaskService; +import com.lz.modules.third.service.TaskRespService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @Author: djc + * @Desc: 绩效任务删除命令 + * @Date: 2021/1/28 16:12 + */ +@Slf4j +@Name("ten") +@Component("ten") +@Summary("测试环境加密数据 ") +@Description(Constant.EXAMPLE + + " 测试环境加密数据 ten xxx " +) +public class TEnCommand extends BaseCommand implements ICommand{ + + @Autowired + private ResultTaskService resultTaskService; + @Autowired + private TaskRespService taskRespService; + + @Override + public R process(Tuple tuple) throws Exception { + String online = "123456"; + String de = PAesUtil.encrypt(tokens[1], online); + log.info("ten data :" + de); + return R.ok(250, de); + } +} diff --git a/src/main/java/com/lz/modules/command/utils/PAesUtil.java b/src/main/java/com/lz/modules/command/utils/PAesUtil.java new file mode 100644 index 00000000..a08f236b --- /dev/null +++ b/src/main/java/com/lz/modules/command/utils/PAesUtil.java @@ -0,0 +1,100 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by Fernflower decompiler) +// + +package com.lz.modules.command.utils; + +import org.apache.commons.codec.binary.Base64; + +import javax.crypto.*; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; + +public class PAesUtil { + + + public PAesUtil() { + } + + + private static byte[] doEncrypt(String content, String password) { + try { + KeyGenerator kgen = KeyGenerator.getInstance("AES"); + SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); + secureRandom.setSeed(password.getBytes()); + kgen.init(128, secureRandom); + SecretKey secretKey = kgen.generateKey(); + byte[] enCodeFormat = secretKey.getEncoded(); + SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES"); + Cipher cipher = Cipher.getInstance("AES"); + byte[] byteContent = content.getBytes("UTF-8"); + cipher.init(1, key); + byte[] result = cipher.doFinal(byteContent); + return result; + } catch (NoSuchAlgorithmException var10) { + System.out.println("encrypt NoSuchAlgorithmException"); + } catch (NoSuchPaddingException var11) { + System.out.println("encrypt NoSuchPaddingException"); + } catch (InvalidKeyException var12) { + System.out.println("encrypt InvalidKeyException"); + } catch (UnsupportedEncodingException var13) { + System.out.println("encrypt UnsupportedEncodingException"); + } catch (IllegalBlockSizeException var14) { + System.out.println("encrypt IllegalBlockSizeException"); + } catch (BadPaddingException var15) { + System.out.println("encrypt BadPaddingException"); + } + + return null; + } + + public static String decrypt(String contentStr, String password) { + try { + byte[] content = Base64.decodeBase64(contentStr.getBytes()); + KeyGenerator kgen = KeyGenerator.getInstance("AES"); + SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); + secureRandom.setSeed(password.getBytes()); + kgen.init(128, secureRandom); + SecretKey secretKey = kgen.generateKey(); + byte[] enCodeFormat = secretKey.getEncoded(); + SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES"); + Cipher cipher = Cipher.getInstance("AES"); + cipher.init(2, key); + byte[] result = cipher.doFinal(content); + return new String(result); + } catch (NoSuchAlgorithmException var10) { + System.out.println("decrypt NoSuchAlgorithmException"); + } catch (NoSuchPaddingException var11) { + System.out.println("decrypt NoSuchPaddingException"); + } catch (InvalidKeyException var12) { + System.out.println("decrypt InvalidKeyException"); + } catch (IllegalBlockSizeException var13) { + System.out.println("decrypt IllegalBlockSizeException"); + } catch (BadPaddingException var14) { + System.out.println("decrypt BadPaddingException"); + } + + return null; + } + + public static String encrypt(String value, String encrypt_password) { + return new String(Base64.encodeBase64(doEncrypt(value, encrypt_password))); + } + + public static void main(String[] args) { + + String test = "123456"; + String online = "RiZUH6CU9JK7x5LVou9d8Q1"; + + System.out.println(encrypt("18458195149", test)); + + + System.out.println(decrypt("tORUYS+eS9+3SpaZv9uLMQ==", test)); + + } + +} diff --git a/src/test/java/com/lz/Test2.java b/src/test/java/com/lz/Test2.java new file mode 100644 index 00000000..34980406 --- /dev/null +++ b/src/test/java/com/lz/Test2.java @@ -0,0 +1,52 @@ +package com.lz; + +import com.alibaba.druid.sql.ast.SQLStatement; +import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser; +import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor; +import com.alibaba.druid.sql.parser.SQLStatementParser; +import org.omg.CORBA.UNKNOWN; + +public class Test2 { + + public static void main(String[] args) { + String sql = "SELECT lai.item_code itemCode, " + + " lai.auth_type, " + + " lai.url, " + + " lua.`status`, " + + " lua.gmt_auth gmtAuth , " + + " lai.detail_desc detailDesc , " + + " lai.item_name authName " + + " from lt_user_authInfo lua\n" + + " LEFT JOIN lt_auth_item lai ON lua.auth_item_code = lai.item_code\n" + + " LEFT JOIN lt_fund_auth lfa ON lai.id = lfa.auth_item_id\n" + + " where lua.unique_code = xxxx\n" + + " AND lua.is_delete = 0 " + + " AND lai.is_delete = 0 " + + " AND lfa.is_delete = 0 " + + " AND lfa.supplier_code =xxx " + + " order by lfa.sort;"; + + + +// 新建 MySQL Parser + + SQLStatementParser parser = new MySqlStatementParser(sql); + +// 使用Parser解析生成AST,这里SQLStatement就是AST + + SQLStatement statement = parser.parseStatement(); + +// 使用visitor来访问AST + + MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor(); + + statement.accept(visitor); + +// 从visitor中拿出你所关注的信息 + + System.out.println(visitor.getColumns()); + + } + + +}