提交修改

This commit is contained in:
quyixiao 2021-05-11 14:54:17 +08:00
parent ceabf20f48
commit b23bb5b4ed
7 changed files with 336 additions and 0 deletions

View File

@ -14,6 +14,10 @@ public abstract class BaseCommand<T> {
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;

View File

@ -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<Tuple> implements ICommand<Tuple>{
@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);
}
}

View File

@ -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<Tuple> implements ICommand<Tuple>{
@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);
}
}

View File

@ -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<Tuple> implements ICommand<Tuple>{
@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);
}
}

View File

@ -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<Tuple> implements ICommand<Tuple>{
@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);
}
}

View File

@ -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));
}
}

View File

@ -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());
}
}