From 00967186e3b6d07e61229e1229186f22bca3cd57 Mon Sep 17 00:00:00 2001
From: lishouyu <18332763730@163.com>
Date: Sat, 19 Aug 2017 09:49:08 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE=E5=92=8C?=
=?UTF-8?q?=E6=96=B0=E5=A2=9Esql=E8=AF=AD=E5=8F=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 8 +-
{bash => all/bash}/docker_shipyarn_run.sh | 0
{bash => all/bash}/docker_shipyarn_stop.sh | 0
all/sql/cms.sql | 20 ++
all/sql/upms.sql | 266 ++++++++++++++++++
common/pom.xml | 171 ++++++++---
.../micro/fast/common/CommonApplication.java | 1 -
.../com/micro/fast/common/util/AESUtil.java | 147 ----------
.../com/micro/fast/common/util/JdbcUtil.java | 89 ------
.../common/util/MybatisGeneratorUtil.java | 173 ------------
.../micro/fast/common/util/StringUtil.java | 157 -----------
.../micro/fast/common/util/VelocityUtil.java | 68 -----
common/src/main/resources/generatorConfig.xml | 85 ++++++
.../main/resources/templates/Controller.vm | 25 --
.../src/main/resources/templates/Service.vm | 13 -
.../main/resources/templates/ServiceImpl.vm | 29 --
.../main/resources/templates/ServiceMock.vm | 14 -
.../resources/templates/generatorConfig.vm | 74 -----
.../src/main/resources/application.yml | 4 +-
docker-compose.yml | 2 +-
.../src/main/resources/application.yml | 27 --
.../src/main/resources/bootstrap.yml | 2 +-
.../src/main/resources/application.yml | 27 --
.../src/main/resources/bootstrap.yml | 2 +-
pom.xml | 57 ++--
upms/src/main/resources/application.yml | 30 --
upms/src/main/resources/bootstrap.yml | 2 +-
27 files changed, 546 insertions(+), 947 deletions(-)
rename {bash => all/bash}/docker_shipyarn_run.sh (100%)
rename {bash => all/bash}/docker_shipyarn_stop.sh (100%)
create mode 100644 all/sql/cms.sql
create mode 100644 all/sql/upms.sql
delete mode 100644 common/src/main/java/com/micro/fast/common/util/AESUtil.java
delete mode 100644 common/src/main/java/com/micro/fast/common/util/JdbcUtil.java
delete mode 100644 common/src/main/java/com/micro/fast/common/util/MybatisGeneratorUtil.java
delete mode 100644 common/src/main/java/com/micro/fast/common/util/StringUtil.java
delete mode 100644 common/src/main/java/com/micro/fast/common/util/VelocityUtil.java
create mode 100644 common/src/main/resources/generatorConfig.xml
delete mode 100644 common/src/main/resources/templates/Controller.vm
delete mode 100644 common/src/main/resources/templates/Service.vm
delete mode 100644 common/src/main/resources/templates/ServiceImpl.vm
delete mode 100644 common/src/main/resources/templates/ServiceMock.vm
delete mode 100644 common/src/main/resources/templates/generatorConfig.vm
delete mode 100644 eureka-server/src/main/resources/application.yml
delete mode 100644 eureka-server2/src/main/resources/application.yml
delete mode 100644 upms/src/main/resources/application.yml
diff --git a/README.md b/README.md
index 20ddb97..9f1e8c7 100644
--- a/README.md
+++ b/README.md
@@ -7,11 +7,11 @@
中心外所有服务的注册空间的配置空间都指定正
确,本项目中本地运行时则是都指定到本机的
ip地址**
-###配置中心 端口号 10001
+###配置中心 端口号 9999 监控 19999
www.config.server.com
-###注册中心 端口号 10002
+###注册中心 端口号 10002 监控 20002
www.eureka.server.com
-###注册中心2 端口号 10003
+###注册中心2 端口号 10003 监控 20003
www.eureka.server2.com
-###用户权限管理中心 端口号 10004
+###用户权限管理中心 端口号 10004 监控 20004
www.upms.com
diff --git a/bash/docker_shipyarn_run.sh b/all/bash/docker_shipyarn_run.sh
similarity index 100%
rename from bash/docker_shipyarn_run.sh
rename to all/bash/docker_shipyarn_run.sh
diff --git a/bash/docker_shipyarn_stop.sh b/all/bash/docker_shipyarn_stop.sh
similarity index 100%
rename from bash/docker_shipyarn_stop.sh
rename to all/bash/docker_shipyarn_stop.sh
diff --git a/all/sql/cms.sql b/all/sql/cms.sql
new file mode 100644
index 0000000..3d7a0a2
--- /dev/null
+++ b/all/sql/cms.sql
@@ -0,0 +1,20 @@
+/*
+ Source Server : 127.0.0.1
+ Source Host : localhost:3306
+ Source Database : micro
+
+ Target Server Type : MYSQL
+ Target Server Version : 5.7
+ File Encoding : utf-8
+*/
+# 外键检查,不能有外键
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- -------------------
+-- 创建micro数据库
+-- -------------------
+CREATE DATABASE IF NOT EXISTS micro
+ CHARACTER SET utf8;
+USE micro;
+
+-- cms内容管理系统
diff --git a/all/sql/upms.sql b/all/sql/upms.sql
new file mode 100644
index 0000000..48e3875
--- /dev/null
+++ b/all/sql/upms.sql
@@ -0,0 +1,266 @@
+/*
+ Source Server : 127.0.0.1
+ Source Host : localhost:3306
+ Source Database : micro
+
+ Target Server Type : MYSQL
+ Target Server Version : 5.7
+ File Encoding : utf-8
+*/
+# 外键检查,不能有外键
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- -------------------
+-- 创建micro数据库
+-- -------------------
+CREATE DATABASE IF NOT EXISTS micro
+ CHARACTER SET utf8;
+USE micro;
+-- upms用户权限管理系统
+
+-- -------------------------
+-- upms_log upms操作日志
+-- -------------------------
+DROP TABLE IF EXISTS upms_log;
+CREATE TABLE `upms_log` (
+ `id` INT AUTO_INCREMENT NOT NULL
+ COMMENT '日志编号',
+ `descirption` VARCHAR(100) DEFAULT NULL
+ COMMENT '操作描述',
+ `username` VARCHAR(20) DEFAULT NULL
+ COMMENT '操作用户',
+ `start_time` BIGINT(20) DEFAULT NULL
+ COMMENT '操作时间',
+ `spend_time` INT DEFAULT NULL
+ COMMENT '消耗时间',
+ `base_path` VARCHAR(100) DEFAULT NULL
+ COMMENT '根路径',
+ `uri` VARCHAR(200) DEFAULT NULL
+ COMMENT 'URI',
+ `url` VARCHAR(200) DEFAULT NULL
+ COMMENT 'URL',
+ `method` VARCHAR(10) DEFAULT NULL
+ COMMENT '请求的类型',
+ `parameter` MEDIUMTEXT DEFAULT NULL
+ COMMENT '请求参数',
+ `user_agent` VARCHAR(200) DEFAULT NULL
+ COMMENT '用户标识',
+ `ip` VARCHAR(30) DEFAULT NULL
+ COMMENT 'ip地址',
+ `result` MEDIUMTEXT DEFAULT NULL
+ COMMENT '响应结果',
+ `permissions` VARCHAR(100) DEFAULT NULL
+ COMMENT '权限值',
+ PRIMARY KEY (`id`)
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
+
+-- ------------------
+-- upms_user upms用户表
+-- ------------------
+DROP TABLE IF EXISTS upms_user;
+CREATE TABLE upms_user (
+ `id` INT(10) AUTO_INCREMENT NOT NULL
+ COMMENT '用户的编号',
+ `username` VARCHAR(20) NOT NULL
+ COMMENT '用户名',
+ `password` VARCHAR(32) NOT NULL
+ COMMENT '密码加密后的md5值(密码+盐值)',
+ `salt` VARCHAR(32) DEFAULT NULL
+ COMMENT '盐值',
+ `realname` VARCHAR(20) DEFAULT NULL
+ COMMENT '真实姓名',
+ `avatar` VARCHAR(150) DEFAULT NULL
+ COMMENT '头像',
+ `phone` VARCHAR(20) DEFAULT NULL
+ COMMENT '电话',
+ `email` VARCHAR(50) DEFAULT NULL
+ COMMENT '电子邮箱',
+ `sex` TINYINT(4) DEFAULT NULL
+ COMMENT '性别',
+ `locked` TINYINT(4) DEFAULT NULL
+ COMMENT '账号状态',
+ `ctime` BIGINT(20) DEFAULT NULL
+ COMMENT '创建时间',
+ PRIMARY KEY (`id`)
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
+
+-- --------------------------
+-- upms_organization upms组织表
+-- ---------------------------
+DROP TABLE IF EXISTS upms_organization;
+CREATE TABLE upms_organization (
+ `id` INT(10) AUTO_INCREMENT NOT NULL
+ COMMENT '组织的编号',
+ `pid` INT(10) DEFAULT NULL
+ COMMENT '所属上级',
+ `name` VARCHAR(20) DEFAULT NULL
+ COMMENT '组织名称',
+ `description` VARCHAR(1000) DEFAULT NULL
+ COMMENT '组织描述',
+ `ctime` BIGINT(20) DEFAULT NULL
+ COMMENT '创建时间',
+ PRIMARY KEY (`id`)
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
+
+-- ---------------------
+-- upms_role upms角色表
+-- ---------------------
+DROP TABLE IF EXISTS upms_role;
+CREATE TABLE upms_role (
+ `id` INT(10) AUTO_INCREMENT NOT NULL
+ COMMENT '角色编号',
+ `name` VARCHAR(20) DEFAULT NULL
+ COMMENT '角色名称',
+ `description` VARCHAR(1000) DEFAULT NULL
+ COMMENT '角色描述',
+ `ctime` BIGINT(20) DEFAULT NULL
+ COMMENT '创建时间',
+ `orders` BIGINT(20) DEFAULT NULL
+ COMMENT '排序',
+ PRIMARY KEY (`id`)
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
+
+-- ---------------------------
+-- upms_permission upms权限
+-- ---------------------------
+DROP TABLE IF EXISTS upms_permission;
+CREATE TABLE upms_permission (
+ `id` INT(10) AUTO_INCREMENT NOT NULL
+ COMMENT '权限编号',
+ `system_id` INT(10) DEFAULT NULL
+ COMMENT '所属系统',
+ `pid` INT(10) DEFAULT NULL
+ COMMENT '所属上级',
+ `name` VARCHAR(20) DEFAULT NULL
+ COMMENT '名称',
+ `type` TINYINT(4) DEFAULT NULL
+ COMMENT '类型 1.目录2.菜单3.按钮',
+ `permission_value` VARCHAR(50) DEFAULT NULL
+ COMMENT '权限值',
+ `uri` VARCHAR(100) DEFAULT NULL
+ COMMENT '路径',
+ `icon` VARCHAR(50) DEFAULT NULL
+ COMMENT '图标',
+ `status` TINYINT(4) DEFAULT NULL
+ COMMENT '状态 0 禁止 1 正常',
+ `ctime` BIGINT(20) DEFAULT NULL
+ COMMENT '创建时间',
+ `orders` BIGINT(20) DEFAULT NULL
+ COMMENT '排序',
+ PRIMARY KEY (`id`),
+ KEY `system_id_index` (`system_id`) USING BTREE COMMENT 'B+树索引'
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
+
+-- -------------------------
+-- upms_system upms系统表
+-- -------------------------
+DROP TABLE IF EXISTS upms_system;
+CREATE TABLE upms_system (
+ `id` INT(10) NOT NULL AUTO_INCREMENT
+ COMMENT '系统编号',
+ `icon` VARCHAR(50) DEFAULT NULL
+ COMMENT '图标',
+ `banner` VARCHAR(150) DEFAULT NULL
+ COMMENT '背景',
+ `theme` VARCHAR(50) DEFAULT NULL
+ COMMENT '主题',
+ `basepath` VARCHAR(100) DEFAULT NULL
+ COMMENT '根目录',
+ `status` TINYINT(4) DEFAULT NULL
+ COMMENT '状态 -1 黑名单 1 正常',
+ `name` VARCHAR(20) DEFAULT NULL
+ COMMENT '系统名称',
+ `title` VARCHAR(20) DEFAULT NULL
+ COMMENT '系统标题',
+ `description` VARCHAR(300) DEFAULT NULL
+ COMMENT '系统描述',
+ `ctime` BIGINT(20) DEFAULT NULL
+ COMMENT '创建时间',
+ `orders` BIGINT(20) DEFAULT NULL
+ COMMENT '排序',
+ PRIMARY KEY (`id`)
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
+
+-- --------------------------
+-- upms_user_organization 用户_组织关联表
+-- --------------------------
+DROP TABLE IF EXISTS upms_user_organization;
+CREATE TABLE upms_user_organization (
+ `user_organization_id` INT(10) AUTO_INCREMENT NOT NULL
+ COMMENT '编号',
+ `user_id` INT(10) NOT NULL
+ COMMENT '用户编号',
+ `organization_id` INT(10) NOT NULL
+ COMMENT '组织编号',
+ PRIMARY KEY (`user_organization_id`),
+ KEY `user_id_index` (`user_id`) USING BTREE COMMENT 'B+树索引',
+ KEY `organization_id_index` (`organization_id`) USING BTREE COMMENT 'B+树索引'
+)
+ ENGINE = InnoDB
+ DEFAULT CHARACTER SET = utf8;
+
+-- ----------------------------
+-- upms_user_role 用户_角色关联表
+-- ----------------------------
+DROP TABLE IF EXISTS upms_user_role;
+CREATE TABLE upms_user_role (
+ `user_role_id` INT(10) AUTO_INCREMENT NOT NULL
+ COMMENT '编号',
+ `user_id` INT(10) NOT NULL
+ COMMENT '用户编号',
+ `role_id` INT(10) NOT NULL
+ COMMENT '角色编号',
+ PRIMARY KEY (`user_role_id`),
+ KEY `user_id_index` (`user_id`) USING BTREE COMMENT 'B+树索引',
+ KEY `role_id_index` (`role_id`) USING BTREE COMMENT 'B+树索引'
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
+
+-- ----------------------------------
+-- upms_user_permission 用户_权限关联表
+-- ----------------------------------
+DROP TABLE IF EXISTS upms_user_permission;
+DROP TABLE IF EXISTS upms_user_permissioon;
+CREATE TABLE upms_user_permission (
+ `user_permission_id` INT(10) AUTO_INCREMENT NOT NULL
+ COMMENT '编号',
+ `user_id` INT(10) NOT NULL
+ COMMENT '用户编号',
+ `permission_id` INT(10) NOT NULL
+ COMMENT '权限编号',
+ `type` TINYINT(4) NOT NULL
+ COMMENT '权限类型 -1 减权限',
+ PRIMARY KEY (`user_permission_id`),
+ KEY `user_id_index` (`user_id`) USING BTREE COMMENT 'B+树索引',
+ KEY `permission_id_index` (`permission_id`) USING BTREE COMMENT 'B+树索引'
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET utf8;
+
+-- ----------------------------------
+-- upms_role_permission 角色_权限关联表
+-- ----------------------------------
+DROP TABLE IF EXISTS upms_role_permission;
+CREATE TABLE upms_role_permission (
+ `role_permission_id` INT(10) AUTO_INCREMENT NOT NULL COMMENT '编号',
+ `role_id` INT(10) NOT NULL COMMENT '角色编号',
+ `permission_id` INT(10) NOT NULL COMMENT '权限编号',
+ PRIMARY KEY (`role_permission_id`),
+ KEY `role_id_index` (`role_id`) USING BTREE COMMENT 'B+树索引',
+ KEY `permission_id_index` (`permission_id`) USING BTREE COMMENT 'B+书索引'
+)
+ ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
diff --git a/common/pom.xml b/common/pom.xml
index a607881..a639e06 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -15,7 +15,7 @@
org.springframework.boot
spring-boot-starter-parent
1.5.4.RELEASE
-
+
@@ -26,38 +26,47 @@
1.8
1.8
1.8
+ 3.4.1
+ 1.3.0
-
- org.springframework.boot
- spring-boot-starter-actuator
-
+
+
org.springframework.cloud
spring-cloud-starter-bus-amqp
+
org.springframework.cloud
spring-cloud-starter-config
+
org.springframework.cloud
spring-cloud-starter-eureka
+
org.springframework.cloud
spring-cloud-starter-feign
org.springframework.cloud
- spring-cloud-starter-hystrix
+ spring-cloud-starter-ribbon
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
org.springframework.cloud
- spring-cloud-starter-ribbon
+ spring-cloud-starter-hystrix
-
+
+
org.springframework.cloud
spring-cloud-starter-sleuth
@@ -65,50 +74,106 @@
org.springframework.cloud
spring-cloud-starter-zipkin
-
- org.springframework.boot
- spring-boot-starter-data-redis
-
+
+ io.zipkin.java
+ zipkin-autoconfigure-ui
+ runtime
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+ org.springframework.session
+ spring-session-data-redis
+
+
org.springframework.boot
spring-boot-starter-freemarker
+
org.springframework.boot
spring-boot-starter-web
-
+
+
+ org.springframework.boot
+ spring-boot-starter-aop
+
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ 1.3.0
+
+
+
+ com.github.pagehelper
+ pagehelper
+ 4.1.0
+
+
+ com.github.miemiedev
+ mybatis-paginator
+ 1.2.17
+
+
+ com.github.jsqlparser
+ jsqlparser
+ 0.9.4
+
+
mysql
mysql-connector-java
runtime
-
- io.zipkin.java
- zipkin-autoconfigure-ui
- runtime
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
+
+
+ com.alibaba
+ druid
+ 1.0.26
+
+
+
+ org.hibernate
+ hibernate-validator
+
+
+ org.apache.tomcat.embed
+ tomcat-embed-el
+
+
+
+ commons-io
+ commons-io
+ 2.4
+
+
+
+ io.springfox
+ springfox-swagger2
+ 2.6.1
+
+
+ io.springfox
+ springfox-swagger-ui
+ 2.6.1
+
org.mybatis.generator
mybatis-generator-core
1.3.5
+
- org.apache.velocity
- velocity
- 1.7
-
-
-
- commons-io
- commons-io
- 2.4
+ org.springframework.boot
+ spring-boot-starter-test
+ test
@@ -123,15 +188,51 @@
-
org.springframework.boot
spring-boot-maven-plugin
+
+
+ org.mybatis.generator
+ mybatis-generator-maven-plugin
+ 1.3.2
+
+ true
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ compile
+ compile
+
+ compile
+
+
+
+ testCompile
+ test-compile
+
+ testCompile
+
+
+
+
+ 1.8
+ 1.8
+ UTF-8
+
+ ${project.basedir}/src/main/resources/lib
+
+
+
-
-
diff --git a/common/src/main/java/com/micro/fast/common/CommonApplication.java b/common/src/main/java/com/micro/fast/common/CommonApplication.java
index 18aee0a..cbdd424 100644
--- a/common/src/main/java/com/micro/fast/common/CommonApplication.java
+++ b/common/src/main/java/com/micro/fast/common/CommonApplication.java
@@ -1,7 +1,6 @@
package com.micro.fast.common;
import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
diff --git a/common/src/main/java/com/micro/fast/common/util/AESUtil.java b/common/src/main/java/com/micro/fast/common/util/AESUtil.java
deleted file mode 100644
index a504b19..0000000
--- a/common/src/main/java/com/micro/fast/common/util/AESUtil.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package com.micro.fast.common.util;
-
-
-
-import javax.crypto.*;
-import javax.crypto.spec.SecretKeySpec;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
-
-import sun.misc.BASE64Decoder;
-import sun.misc.BASE64Encoder;
-/**
- * AES加解密工具类
- * Created by shuzheng on 2017/2/5.
- */
-public class AESUtil {
- /**
- * 注释 .
- */
- private static final String encodeRules = "zheng";
-
- /**
- * 加密
- * 1.构造密钥生成器
- * 2.根据ecnodeRules规则初始化密钥生成器
- * 3.产生密钥
- * 4.创建和初始化密码器
- * 5.内容加密
- * 6.返回字符串.
- */
- private static String AESEncode(String content) {
- try {
- //1.构造密钥生成器,指定为AES算法,不区分大小写
- KeyGenerator keygen = KeyGenerator.getInstance("AES");
- //2.根据ecnodeRules规则初始化密钥生成器
- //生成一个128位的随机源,根据传入的字节数组
- SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
- random.setSeed(encodeRules.getBytes());
- keygen.init(128, random);
- //3.产生原始对称密钥
- SecretKey original_key = keygen.generateKey();
- //4.获得原始对称密钥的字节数组
- byte[] raw = original_key.getEncoded();
- //5.根据字节数组生成AES密钥
- SecretKey key = new SecretKeySpec(raw, "AES");
- //6.根据指定算法AES自成密码器
- Cipher cipher = Cipher.getInstance("AES");
- //7.初始化密码器,第一个参数为加密(Encrypt_mode)或者解密解密(Decrypt_mode)操作,第二个参数为使用的KEY
- cipher.init(Cipher.ENCRYPT_MODE, key);
- //8.获取加密内容的字节数组(这里要设置为utf-8)不然内容中如果有中文和英文混合中文就会解密为乱码
- byte[] byte_encode = content.getBytes("utf-8");
- //9.根据密码器的初始化方式--加密:将数据加密
- byte[] byte_AES = cipher.doFinal(byte_encode);
- //10.将加密后的数据转换为字符串
- //这里用Base64Encoder中会找不到包
- //解决办法:
- //在项目的Build path中先移除JRE System Library,再添加库JRE System Library,重新编译后就一切正常了。
- String AES_encode = new String(new BASE64Encoder().encode(byte_AES));
- //11.将字符串返回
- return AES_encode;
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- } catch (NoSuchPaddingException e) {
- e.printStackTrace();
- } catch (InvalidKeyException e) {
- e.printStackTrace();
- } catch (IllegalBlockSizeException e) {
- e.printStackTrace();
- } catch (BadPaddingException e) {
- e.printStackTrace();
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- //如果有错就返加nulll
- return null;
- }
-
- /**
- * 解密
- * 解密过程:
- * 1.同加密1-4步
- * 2.将加密后的字符串反纺成byte[]数组
- * 3.将加密内容解密
- */
- public static String AESDecode(String content) {
- try {
- //1.构造密钥生成器,指定为AES算法,不区分大小写
- KeyGenerator keygen = KeyGenerator.getInstance("AES");
- //2.根据ecnodeRules规则初始化密钥生成器
- //生成一个128位的随机源,根据传入的字节数组
- SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
- random.setSeed(encodeRules.getBytes());
- keygen.init(128, random);
- //3.产生原始对称密钥
- SecretKey original_key = keygen.generateKey();
- //4.获得原始对称密钥的字节数组
- byte[] raw = original_key.getEncoded();
- //5.根据字节数组生成AES密钥
- SecretKey key = new SecretKeySpec(raw, "AES");
- //6.根据指定算法AES自成密码器
- Cipher cipher = Cipher.getInstance("AES");
- //7.初始化密码器,第一个参数为加密(Encrypt_mode)或者解密(Decrypt_mode)操作,第二个参数为使用的KEY
- cipher.init(Cipher.DECRYPT_MODE, key);
- //8.将加密并编码后的内容解码成字节数组
- byte[] byte_content = new BASE64Decoder().decodeBuffer(content);
- /*
- * 解密
- */
- byte[] byte_decode = cipher.doFinal(byte_content);
- String AES_decode = new String(byte_decode, "utf-8");
- return AES_decode;
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- } catch (NoSuchPaddingException e) {
- e.printStackTrace();
- } catch (InvalidKeyException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (IllegalBlockSizeException e) {
- throw new RuntimeException("兄弟,配置文件中的密码需要使用AES加密,请使用com.zheng.common.util.AESUtil工具类修改这些值!");
- //e.printStackTrace();
- } catch (BadPaddingException e) {
- e.printStackTrace();
- }
- //如果有错就返加nulll
- return null;
- }
-
- public static void main(String[] args) {
- String[] keys = {
- "", "123456"
- };
- System.out.println("key | AESEncode | AESDecode");
- for (String key : keys) {
- System.out.print(key + " | ");
- String encryptString = AESEncode(key);
- System.out.print(encryptString + " | ");
- String decryptString = AESDecode(encryptString);
- System.out.println(decryptString);
- }
- }
-
-}
diff --git a/common/src/main/java/com/micro/fast/common/util/JdbcUtil.java b/common/src/main/java/com/micro/fast/common/util/JdbcUtil.java
deleted file mode 100644
index 8cebb93..0000000
--- a/common/src/main/java/com/micro/fast/common/util/JdbcUtil.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package com.micro.fast.common.util;
-
-import java.sql.*;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * JDBC工具类
- * Created by ZhangShuzheng on 2017/1/10.
- */
-public class JdbcUtil {
-
- // 定义数据库的链接
- private Connection conn;
- // 定义sql语句的执行对象
- private PreparedStatement pstmt;
- // 定义查询返回的结果集合
- private ResultSet rs;
-
- // 初始化
- public JdbcUtil(String driver, String url, String username, String password) {
- try {
- Class.forName(driver);
- conn = DriverManager.getConnection(url, username, password);
- System.out.println("数据库连接成功");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- // 更新数据
- public boolean updateByParams(String sql, List params) throws SQLException {
- // 影响行数
- int result = -1;
- pstmt = conn.prepareStatement(sql);
- int index = 1;
- // 填充sql语句中的占位符
- if (null != params && !params.isEmpty()) {
- for (int i = 0; i < params.size(); i ++) {
- pstmt.setObject(index ++, params.get(i));
- }
- }
- result = pstmt.executeUpdate();
- return result > 0 ? true : false;
- }
-
- // 查询多条记录
- public List