diff --git a/README.md b/README.md
index d51f18b..905c149 100644
--- a/README.md
+++ b/README.md
@@ -1,27 +1,30 @@
-##springboot-SpringSecurity0
+## 致歉
+由于自己懒以及身体对issuse 解决的不及时。请大家以后提issuse 的时候写清楚 模块名 比如“springboot-SpringSecurity4” 和问题,我会抽时间抓紧解决。
+
+## springboot-SpringSecurity0
+
包含两部分代码:
* 第一是 博客 springboot+mybatis+SpringSecurity 实现用户角色数据库管理 地址:http://blog.csdn.net/u012373815/article/details/54632176
* 第二是 博客 springBoot+springSecurity验证密码MD5加密 地址:http://blog.csdn.net/u012373815/article/details/54927070
-##springboot-SpringSecurity1
+## springboot-SpringSecurity1
* 博客 springBoot+springSecurity 数据库动态管理用户、角色、权限(二) 地址:http://blog.csdn.net/u012373815/article/details/54633046
-##springboot-SpringSecurity2
+## springboot-SpringSecurity2
* 博客 springboot+security restful权限控制官方推荐(五) 地址:http://blog.csdn.net/u012373815/article/details/59749385
-* 博客:spring security 同时只有一个用户在线,session 并发问题 地址:
-##springboot-SpringSecurity3
+## springboot-SpringSecurity3
* 博客 springBoot+springSecurity 动态管理Restful风格权限(三) 地址:http://blog.csdn.net/u012373815/article/details/55225079
-##springboot-SpringSecurity4
+## springboot-SpringSecurity4
* 实战,项目中正在用
-##springboot-WebSocket
+## springboot-WebSocket
包含三部分代码,三部分代码有交合:
@@ -33,7 +36,7 @@
-##springboot-Cache
+## springboot-Cache
包含两部分代码:
@@ -41,12 +44,45 @@
* 第二部分是 博客 springboot缓存篇(二)-redis 做缓存 地址:http://blog.csdn.net/u012373815/article/details/54572687
-##springboot-Cache2
+## springboot-Cache2
* 是 博客 springboot缓存 之 GuavaCacheManager 地址:http://blog.csdn.net/u012373815/article/details/60468033
-##springboot-shiro
+
+
+## springboot-shiro
* 是博客 springboot集成shiro 实现权限控制 地址:http://blog.csdn.net/u012373815/article/details/57532292
+##springboot-shior2
+
+是使用shior 框架调取用户权限服务,进行登录权限验证的例子,其中的用户权限服务没有写,都是用TODO 标示出来了,使用时可以根据各自的用户权限服务进行编码替换
+
+springboot-shiro2 也是和dubbo 的结合例子是 消费者的示例。
+
+## springboot-swagger-ui
+* 博客 spring boot +Swagger-ui 自动生成API文档 地址: https://blog.csdn.net/u012373815/article/details/82685962
+
+## springBoot-Quartz
+* 博客 springBoot-Quartz 定时任务 地址: https://abelyang.blog.csdn.net/article/details/86740625
+
+## springboot 整合mybatis2
+* springboot 整合mybatis2 更简便的整合方式地址: https://abelyang.blog.csdn.net/article/details/89296273
+
+## springboot+Kafka
+* kafka 与 sprigboot 的结合,springboot 从Kafka中读取数据的小例子地址: https://abelyang.blog.csdn.net/article/details/89296305
+
+## springboot+es
+* Elasticsearch 与 sprigboot 的结合,springboot 操作es的小例子地址: https://abelyang.blog.csdn.net/article/details/89296320
+
+## Springboot多数据源切换
+* springboot 多个数据源的配置, 一个springboot 项目操作多个数据库的数据:https://abelyang.blog.csdn.net/article/details/89296341
+
+##springboot-dubbo
+
+该项目是Springboot 和 dubbo 结合的例子,是provider 的示例,提供服务。简单的写了一些用户和权限的接口没有写的很完整,主要是为了提现dubbo 服务
+Springboot-shiro2 也是和dubbo 的结合例子是 消费者的示例。
+
+
+
##未完待续。。。
diff --git a/abel-parent/pom.xml b/abel-parent/pom.xml
new file mode 100644
index 0000000..d87f059
--- /dev/null
+++ b/abel-parent/pom.xml
@@ -0,0 +1,378 @@
+
+
+ 4.0.0
+
+ cn.abel
+ abel-parent
+ pom
+ 1.0.0-SNAPSHOT
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.0.4.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.4.0
+ 5.1.47
+
+
+
+
+
+
+
+
+ org.apache.commons
+ commons-lang3
+ 3.7
+
+
+ org.apache.commons
+ commons-collections4
+ 4.2
+
+
+ org.apache.commons
+ commons-pool2
+ 2.6.0
+
+
+
+ dom4j
+ dom4j
+ 1.6.1
+
+
+
+ mysql
+ mysql-connector-java
+ ${mysql.version}
+ runtime
+
+
+
+ com.alibaba
+ druid
+ 1.1.10
+
+
+
+ org.apache.shiro
+ shiro-spring
+ ${shiro.version}
+
+
+ org.apache.shiro
+ shiro-ehcache
+ ${shiro.version}
+
+
+ org.apache.shiro
+ shiro-quartz
+ ${shiro.version}
+
+
+ org.opensymphony.quartz
+ quartz
+
+
+
+
+ net.mingsoft
+ shiro-freemarker-tags
+ 1.0.0
+
+
+
+ org.hibernate
+ hibernate-core
+ 5.3.4.Final
+
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ 2.9.7
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.9.9.1
+
+
+
+ com.alibaba
+ fastjson
+ 1.2.58
+
+
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ 1.3.2
+
+
+ com.github.pagehelper
+ pagehelper-spring-boot-starter
+ 1.2.5
+
+
+
+ org.quartz-scheduler
+ quartz
+ 2.2.1
+
+
+
+
+ com.alibaba
+ dubbo
+ 2.8.4
+
+
+ log4j
+ log4j
+
+
+
+
+ org.slf4j
+ log4j-over-slf4j
+ 1.7.25
+
+
+ org.apache.zookeeper
+ zookeeper
+ 3.4.13
+
+
+ org.slf4j
+ slf4j-log4j12
+
+
+ log4j
+ log4j
+
+
+
+
+
+
+ org.jboss.resteasy
+ resteasy-jaxrs
+ 3.0.26.Final
+
+
+ org.jboss.resteasy
+ resteasy-client
+ 3.0.26.Final
+
+
+ org.jboss.resteasy
+ resteasy-jackson-provider
+ 3.0.26.Final
+
+
+ javax.validation
+ validation-api
+ 2.0.1.Final
+
+
+ org.hibernate.validator
+ hibernate-validator
+ 6.0.13.Final
+
+
+ com.101tec
+ zkclient
+ 0.10
+
+
+
+
+ com.google.code.gson
+ gson
+ 2.8.5
+
+
+ org.apache.httpcomponents
+ httpcore
+ 4.4.10
+
+
+ org.apache.httpcomponents
+ httpcore-nio
+ 4.4.10
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.6
+
+
+ org.apache.httpcomponents
+ httpasyncclient
+ 4.1.4
+
+
+
+ com.aliyun.oss
+ aliyun-sdk-oss
+ 3.3.0
+
+
+ com.aliyun
+ aliyun-java-sdk-sts
+ 3.0.0
+
+
+
+ com.aliyun
+ aliyun-java-sdk-core
+ 4.2.0
+
+
+ com.aliyun
+ aliyun-java-sdk-dysmsapi
+ 1.1.0
+
+
+ com.aliyun.mns
+ aliyun-sdk-mns
+ 1.1.8.6
+
+
+
+
+
+ org.mapstruct
+ mapstruct-jdk8
+ 1.1.0.Final
+
+
+
+
+
+
+ Releases
+ http://maven.aliyun.com/nexus/content/groups/public/releases
+
+
+ Snapshots
+ http://maven.aliyun.com/nexus/content/groups/public/snapshots
+
+
+
+
+
+ local
+
+ local
+
+
+ true
+
+
+
+ dev
+
+ dev
+
+
+
+ online
+
+ online
+
+
+
+ test
+
+ test
+
+
+
+ test-ali
+
+ test-ali
+
+
+
+
+
+ ${project.artifactId}-${project.version}
+
+
+ src/main/resources/${package.environment}
+
+ *.*
+
+
+
+ src/main/resources
+
+ local/**
+ dev/**
+ test/**
+ test-ali/**
+ online/**
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+ true
+
+ true
+
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.6.0
+
+ UTF-8
+ 1.8
+ 1.8
+
+
+ org.mapstruct
+ mapstruct-processor
+ 1.1.0.Final
+
+
+
+
+
+
+
+
+
diff --git a/abel-util/pom.xml b/abel-util/pom.xml
new file mode 100644
index 0000000..faea57f
--- /dev/null
+++ b/abel-util/pom.xml
@@ -0,0 +1,61 @@
+
+
+ 4.0.0
+
+ cn.abel
+ abel-util
+ 1.0.0-SNAPSHOT
+ jar
+
+ cn.abel
+ abel-parent
+ 1.0.0-SNAPSHOT
+
+
+ UTF-8
+
+
+
+ org.apache.commons
+ commons-lang3
+
+
+ org.apache.commons
+ commons-collections4
+
+
+ org.springframework
+ spring-web
+ 5.1.3.RELEASE
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+ 2.0.4.RELEASE
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.9.8
+
+
+ com.alibaba
+ fastjson
+
+
+ javax.servlet
+ javax.servlet-api
+ 4.0.1
+ provided
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
+
\ No newline at end of file
diff --git a/abel-util/src/main/java/cn/abel/code/InfoCode.java b/abel-util/src/main/java/cn/abel/code/InfoCode.java
new file mode 100644
index 0000000..be6d98e
--- /dev/null
+++ b/abel-util/src/main/java/cn/abel/code/InfoCode.java
@@ -0,0 +1,64 @@
+package cn.abel.code;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 返回响应 Created by liyunfeng
+ */
+public enum InfoCode {
+
+ //系统错误从200~10000
+ SUCCESS(200, "OK"),
+ TIME_OUT(300, "超时"),
+
+ //业务相关从10000自增
+ // 10000开始
+ INVALID_REQUEST(10000, "不支持的请求方式"),
+
+ //用户相关(20000自增)
+ REQUEST_PARAM_ERROR(20000, "传入参数错误"),
+ REGISTER_TYPE_ERROR(20001, "不支持的注册类型"),
+ INVALID_SIGN(20002, "签名无效"),
+ USER_LOGIN_EXIST(20003, "用户已存在"),
+ USER_LOGIN_NOT_EXIST(20008, "用户不存在"),
+ PASSWORD_ERROR(20009, "用户名或密码错误"),
+ INVALID_TOKEN(20010, "无效token"),
+ INVALID_LOGIN(20011, "登录失效,重新登录"),
+ PASSWORD_SAME(20017, "密码重复"),
+ OLD_PASSWORD_ERROR(20018, "密码错误,不能修改"),
+ LOGIN_FAIL(20024, "登录失败"),
+ VISITOR_REGISTER_FAIL(20025, "游客注册失败"),
+ TOKEN_EXIST(20033, "token重复"),
+ LOGIN_TYPE_EXIST(20034, "登录方式已存在"),
+ USER_PROFILE_SEARCH_ERROR(20035, "用户查询失败"),
+ USER_PROFILE_LOCK(20036, "用户已锁定"),
+ ACCOUNT_SEARCH_FAIL(20037, "账号查询失败"),
+ LOGIN_NAME_TYPE_ERROR(20038, "登录名不为空时,登录方式不能为空"),
+ PASSWORD_SIMPLE_ERROR(20042, "密码错误,长度应为6-18,包含字母、数字和特殊字符"),
+ PASSWORD_ERROR_MORE_THAN(20043,"用户名密码连续错误已达5次,请15分钟后再试"),
+ LOGIN_TYPE_ERROR(20044, "不支持的登录类型"),
+ SERVICE_UNAVAILABLE(50000, "操作失败,请重试");
+
+ private int status;
+
+ private String msg;
+
+ private InfoCode(int status, String msg) {
+ this.status = status;
+ this.msg = msg;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
+ }
+}
diff --git a/abel-util/src/main/java/cn/abel/exception/AppRuntimeException.java b/abel-util/src/main/java/cn/abel/exception/AppRuntimeException.java
new file mode 100644
index 0000000..aa0173e
--- /dev/null
+++ b/abel-util/src/main/java/cn/abel/exception/AppRuntimeException.java
@@ -0,0 +1,33 @@
+package cn.abel.exception;
+
+
+import cn.abel.code.InfoCode;
+
+/**
+ * 接口服务抛出的异常
+ *
+ */
+public class AppRuntimeException extends RuntimeException {
+
+ private static final long serialVersionUID = 2963760410777899525L;
+ private InfoCode infoCode;
+
+ public AppRuntimeException() {
+ infoCode = InfoCode.SERVICE_UNAVAILABLE;
+
+ }
+
+ public AppRuntimeException(InfoCode infoCode) {
+ this.infoCode = infoCode;
+ }
+
+ public AppRuntimeException(InfoCode infoCode, String message) {
+ super(message);
+ this.infoCode = infoCode;
+ }
+
+ public InfoCode getInfoCode() {
+ return infoCode;
+ }
+
+}
diff --git a/abel-util/src/main/java/cn/abel/exception/HttpExeption.java b/abel-util/src/main/java/cn/abel/exception/HttpExeption.java
new file mode 100644
index 0000000..3e5cca8
--- /dev/null
+++ b/abel-util/src/main/java/cn/abel/exception/HttpExeption.java
@@ -0,0 +1,21 @@
+package cn.abel.exception;
+
+public class HttpExeption extends Exception {
+
+ private static final long serialVersionUID = -4707210535385221192L;
+
+ public HttpExeption() {
+ }
+
+ public HttpExeption(String msg) {
+ super(msg);
+ }
+
+ public HttpExeption(String msg, Throwable e) {
+ super(msg, e);
+ }
+
+ public HttpExeption(Throwable e) {
+ super(e);
+ }
+}
\ No newline at end of file
diff --git a/abel-util/src/main/java/cn/abel/exception/ServiceException.java b/abel-util/src/main/java/cn/abel/exception/ServiceException.java
new file mode 100644
index 0000000..267a197
--- /dev/null
+++ b/abel-util/src/main/java/cn/abel/exception/ServiceException.java
@@ -0,0 +1,60 @@
+package cn.abel.exception;
+
+import cn.abel.code.*;
+
+/**
+ * 服务异常类
+ *
+ */
+@SuppressWarnings("serial")
+public class ServiceException extends Exception {
+
+ //默认的错误码
+ private int errorCode = 500;
+
+ private String errorCodes;
+
+ public ServiceException() {
+ }
+
+ public ServiceException(Throwable e) {
+ super(e);
+ }
+
+ public ServiceException(int errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ public int getErrorCode() {
+ return errorCode;
+ }
+
+ public String getErrorCodes() {
+ return errorCodes;
+ }
+
+ public ServiceException(InfoCode infoCode){
+ super(infoCode.getMsg());
+ this.errorCode = infoCode.getStatus();
+ }
+
+ public ServiceException(int errorCode, String msg) {
+ super(msg);
+ this.errorCode = errorCode;
+ }
+
+ public ServiceException(String errorCode, String msg) {
+ super(msg);
+ this.errorCodes = errorCode;
+ }
+
+ public ServiceException(int errorCode, String msg, Throwable e) {
+ super(msg, e);
+ this.errorCode = errorCode;
+ }
+
+ public ServiceException(int errorCode, Throwable e) {
+ super(e);
+ this.errorCode = errorCode;
+ }
+}
diff --git a/abel-util/src/main/java/cn/abel/response/ResponseEntity.java b/abel-util/src/main/java/cn/abel/response/ResponseEntity.java
new file mode 100644
index 0000000..b9a5de5
--- /dev/null
+++ b/abel-util/src/main/java/cn/abel/response/ResponseEntity.java
@@ -0,0 +1,72 @@
+package cn.abel.response;
+
+
+import cn.abel.code.*;
+
+import java.util.HashMap;
+
+/**
+ * Created by guoshan on 2018/3/21.
+ *
+ * 服务端返回给前端或客户端使用
+ */
+public class ResponseEntity {
+ int status = 200;
+
+ String message = "ok";
+
+ Object data = new HashMap();
+
+
+ private ResponseEntity() {
+ }
+
+ public static ResponseEntity ok(Object data) {
+ ResponseEntity ResponseEntity = new ResponseEntity();
+ ResponseEntity.setData(data);
+ return ResponseEntity;
+ }
+
+ public static ResponseEntity error(InfoCode infoCode) {
+ ResponseEntity ResponseEntity = new ResponseEntity();
+ ResponseEntity.setStatus(infoCode.getStatus());
+ ResponseEntity.setMessage(infoCode.getMsg());
+ return ResponseEntity;
+ }
+
+ public static ResponseEntity ok() {
+ ResponseEntity ResponseEntity = new ResponseEntity();
+ return ResponseEntity;
+ }
+
+ public static ResponseEntity error(int code, String msg) {
+ ResponseEntity ResponseEntity = new ResponseEntity();
+ ResponseEntity.setStatus(code);
+ ResponseEntity.setMessage(msg);
+ return ResponseEntity;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public Object getData() {
+ return data == null ? new HashMap() : data;
+ }
+
+ public void setData(Object data) {
+ this.data = data;
+ }
+}
diff --git a/abel-util/src/main/java/cn/abel/utils/DateTimeUtils.java b/abel-util/src/main/java/cn/abel/utils/DateTimeUtils.java
new file mode 100644
index 0000000..6ceae80
--- /dev/null
+++ b/abel-util/src/main/java/cn/abel/utils/DateTimeUtils.java
@@ -0,0 +1,283 @@
+package cn.abel.utils;
+
+import cn.abel.exception.ServiceException;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.apache.commons.lang3.time.DateUtils;
+
+import java.text.ParseException;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * 日期util。
+ */
+public class DateTimeUtils {
+
+ /**
+ * 一分钟。
+ */
+ public static final int ONE_MINUTE = 60 * 1000;
+
+ /**
+ * 一小时。
+ */
+ public static final int ONE_HOUR = 60 * ONE_MINUTE;
+
+ /**
+ * 一天。
+ */
+ public static final int ONE_DAY = 24 * ONE_HOUR;
+
+
+ public static final String DEFAULT_DATETIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
+ public static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd";
+ private static final int ARG_ERROR_CODE = 400;
+ private static final String ARG_ERROR = "输入的参数有误";
+
+
+ /**
+ * 根据给定的格式将时间转为字符串。
+ *
+ * @param dateTime
+ * @param pattern
+ * @return
+ */
+ public static String format(Date dateTime, String pattern) {
+ if (dateTime == null || pattern == null) {
+ return StringUtils.EMPTY;
+ }
+
+ return DateFormatUtils.format(dateTime, pattern);
+ }
+
+ /**
+ * 将时间转为默认格式的字符串。
+ *
+ * @param dateTime
+ * @return
+ */
+ public static String format(Date dateTime) {
+ return format(dateTime, DEFAULT_DATETIME_PATTERN);
+ }
+
+ /**
+ * 根据给定的格式获取当前日期的字符串。
+ *
+ * @param pattern
+ * @return
+ */
+ public static String formatCurrent(String pattern) {
+ return format(new Date(), pattern);
+ }
+
+ /**
+ * 获取当前日期的字符串。
+ *
+ * @return
+ */
+ public static String formatCurrent() {
+ return format(new Date(), DEFAULT_DATE_PATTERN);
+ }
+
+ /**
+ * 去除时间中的时分秒毫秒,只保留日期部分。
+ *
+ * @param dateTime
+ * @return
+ */
+ public static Date removeTime(Date dateTime) {
+ if (dateTime == null) {
+ return null;
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(dateTime);
+ calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE), 0, 0, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+ return calendar.getTime();
+ }
+
+ /**
+ * 获取明天的日期。
+ *
+ * @return
+ */
+ public static Date getTomorrowDate() {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(new Date());
+ calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE), 0, 0, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+ calendar.add(Calendar.DATE, 1);
+ return calendar.getTime();
+ }
+
+ /**
+ * 获取昨天的日期。
+ *
+ * @return
+ */
+ public static Date getYesterdayDate() {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(new Date());
+ calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE), 0, 0, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+ calendar.add(Calendar.DATE, -1);
+ return calendar.getTime();
+ }
+
+ /**
+ * 根据给定的格式将时间字符串转化成{@link Date}对象。
+ *
+ * @param dateTimeStr
+ * @param pattern
+ * @return
+ * @throws ServiceException
+ */
+ public static Date parse(String dateTimeStr, String pattern) throws ServiceException {
+ if (dateTimeStr == null || pattern == null) {
+ return null;
+ }
+ try {
+ return DateUtils.parseDate(dateTimeStr, pattern);
+ } catch (ParseException e) {
+ throw new ServiceException(ARG_ERROR_CODE, ARG_ERROR);
+ }
+ }
+
+ /**
+ * 将时间字符串根据默认格式转换成{@link Date}对象。
+ *
+ * @param dateTimeStr
+ * @return
+ * @throws ServiceException
+ */
+ public static Date parse(String dateTimeStr) throws ServiceException {
+ return parse(dateTimeStr, DEFAULT_DATETIME_PATTERN);
+ }
+
+ /**
+ * 获取日期中的月份。
+ *
+ * @param date
+ * @return
+ */
+ public static int getMonth(Date date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ return calendar.get(Calendar.MONTH) + 1;
+ }
+
+ /**
+ * 获取日期中的年份。
+ *
+ * @param date
+ * @return
+ */
+ public static int getYear(Date date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ return calendar.get(Calendar.YEAR);
+ }
+
+ /**
+ * 增加日期。
+ *
+ * @param date
+ * @param days
+ * @return
+ * @throws ServiceException
+ */
+ public static Date dateAdd(Date date, int days) throws ServiceException {
+ if (date == null) {
+ throw new ServiceException(ARG_ERROR_CODE, ARG_ERROR);
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ calendar.add(Calendar.DATE, days);
+ return calendar.getTime();
+ }
+
+ /**
+ * 增加月份。
+ *
+ * @param date
+ * @param months
+ * @return
+ * @throws ServiceException
+ */
+ public static Date monthAdd(Date date, int months) throws ServiceException {
+ if (date == null) {
+ throw new ServiceException(ARG_ERROR_CODE, ARG_ERROR);
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ calendar.add(Calendar.MONTH, months);
+ return calendar.getTime();
+ }
+
+ /**
+ * 获取两个日期之间的差值。
+ *
+ * @param one
+ * @param two
+ * @return
+ * @throws ServiceException
+ */
+ public static int dateDiff(Date one, Date two) throws ServiceException {
+ if (one == null || two == null) {
+ throw new ServiceException(ARG_ERROR_CODE, ARG_ERROR);
+ }
+ long diff = Math.abs((one.getTime() - two.getTime()) / (1000 * 3600 * 24));
+ return new Long(diff).intValue();
+ }
+
+
+ /**
+ * 计算几天前的时间
+ *
+ * @param date 当前时间
+ * @param day 几天前
+ * @return
+ */
+ public static Date getDateBefore(Date date, int day) {
+ Calendar now = Calendar.getInstance();
+ now.setTime(date);
+ now.set(Calendar.DATE, now.get(Calendar.DATE) - day);
+ return now.getTime();
+ }
+
+ /**
+ * 获取当前月第一天
+ *
+ * @return Date
+ * @throws ParseException
+ */
+ public static Date getFirstAndLastOfMonth() {
+ LocalDate today = LocalDate.now();
+ LocalDate firstDay = LocalDate.of(today.getYear(),today.getMonth(),1);
+ ZoneId zone = ZoneId.systemDefault();
+ Instant instant = firstDay.atStartOfDay().atZone(zone).toInstant();
+ return Date.from(instant);
+ }
+
+ /**
+ * 获取当前周第一天
+ *
+ * @return Date
+ * @throws ParseException
+ */
+ public static Date getWeekFirstDate(){
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ Date date = cal.getTime();
+ return date;
+ }
+
+}
diff --git a/springboot-Cache/pom.xml b/springboot-Cache/pom.xml
index fb8b681..eda2a37 100644
--- a/springboot-Cache/pom.xml
+++ b/springboot-Cache/pom.xml
@@ -63,7 +63,7 @@
com.mchange
c3p0
- 0.9.5.2
+ 0.9.5.4
commons-logging
diff --git a/springboot-Cache2/pom.xml b/springboot-Cache2/pom.xml
index 67364da..f255f15 100644
--- a/springboot-Cache2/pom.xml
+++ b/springboot-Cache2/pom.xml
@@ -52,7 +52,7 @@
com.mchange
c3p0
- 0.9.5.2
+ 0.9.5.4
commons-logging
diff --git a/springboot-Quartz/pom.xml b/springboot-Quartz/pom.xml
new file mode 100644
index 0000000..4a96830
--- /dev/null
+++ b/springboot-Quartz/pom.xml
@@ -0,0 +1,77 @@
+
+
+ 4.0.0
+
+ com.abel.quartz
+ springboot-Quartz
+ 1.0-SNAPSHOT
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.0.4.RELEASE
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+ org.quartz-scheduler
+ quartz
+ 2.2.1
+
+
+
+ org.springframework.boot
+ spring-boot-starter-mail
+
+
+
+ mysql
+ mysql-connector-java
+
+
+
+ com.zaxxer
+ HikariCP
+ 3.2.0
+
+
+
+ org.springframework
+ spring-jdbc
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.18.1
+
+ true
+
+
+
+
+
\ No newline at end of file
diff --git a/springboot-Quartz/src/main/java/com/abel/quartz/Application.java b/springboot-Quartz/src/main/java/com/abel/quartz/Application.java
new file mode 100644
index 0000000..38d1a0a
--- /dev/null
+++ b/springboot-Quartz/src/main/java/com/abel/quartz/Application.java
@@ -0,0 +1,18 @@
+package com.abel.quartz;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ImportResource;
+
+/**
+ * Created by yangyibo on 2019/2/1.
+ */
+@SpringBootApplication
+@ImportResource("classpath*:META-INF/spring/*.xml")
+public class Application {
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+
+
+}
diff --git a/springboot-Quartz/src/main/java/com/abel/quartz/config/InvokingJobDetailFactory.java b/springboot-Quartz/src/main/java/com/abel/quartz/config/InvokingJobDetailFactory.java
new file mode 100644
index 0000000..c8211b9
--- /dev/null
+++ b/springboot-Quartz/src/main/java/com/abel/quartz/config/InvokingJobDetailFactory.java
@@ -0,0 +1,57 @@
+package com.abel.quartz.config;
+
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.scheduling.quartz.QuartzJobBean;
+import java.lang.reflect.Method;
+
+
+/**
+ * Created by yangyibo on 2019/2/1.
+ */
+public class InvokingJobDetailFactory extends QuartzJobBean {
+
+ /**
+ * 计划任务所在类
+ */
+ private String targetObject;
+
+ /**
+ * 具体需要执行的计划任务
+ */
+ private String targetMethod;
+
+ private ApplicationContext ctx;
+
+ @Override
+ protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
+ try {
+ Object obj = ctx.getBean(targetObject);
+ Method m = null;
+ try {
+ m = obj.getClass().getMethod(targetMethod);
+ //调用被代理对象的方法
+ m.invoke(obj);
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ }
+ } catch (Exception e) {
+ throw new JobExecutionException(e);
+ }
+ }
+
+ public void setApplicationContext(ApplicationContext applicationContext) {
+ this.ctx = applicationContext;
+ }
+
+ public void setTargetObject(String targetObject) {
+ this.targetObject = targetObject;
+ }
+
+ public void setTargetMethod(String targetMethod) {
+ this.targetMethod = targetMethod;
+ }
+}
diff --git a/springboot-Quartz/src/main/java/com/abel/quartz/config/QuartzConfig.java b/springboot-Quartz/src/main/java/com/abel/quartz/config/QuartzConfig.java
new file mode 100644
index 0000000..2dbef04
--- /dev/null
+++ b/springboot-Quartz/src/main/java/com/abel/quartz/config/QuartzConfig.java
@@ -0,0 +1,225 @@
+package com.abel.quartz.config;
+
+import java.beans.PropertyVetoException;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import com.zaxxer.hikari.HikariDataSource;
+import org.quartz.Job;
+import org.quartz.JobDetail;
+import org.quartz.Trigger;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.quartz.CronTriggerFactoryBean;
+import org.springframework.scheduling.quartz.JobDetailFactoryBean;
+import org.springframework.scheduling.quartz.SchedulerFactoryBean;
+
+/**
+ * Created by yangyibo on 2019/1/16.
+ */
+@Configuration
+public class QuartzConfig {
+
+ /**
+ * 1.通过name+group获取唯一的jobKey;2.通过groupname来获取其下的所有jobkey
+ */
+ final static String GROUP_NAME = "QuartzJobGroups";
+
+ @Value("${quartz.scheduler.instanceName}")
+ private String quartzInstanceName;
+
+ @Value("${spring.datasource.driverClassName}")
+ private String myDSDriver;
+
+ @Value("${spring.datasource.url}")
+ private String myDSUrl;
+
+ @Value("${spring.datasource.username}")
+ private String myDSUser;
+
+ @Value("${spring.datasource.password}")
+ private String myDSPassword;
+
+ @Value("${org.quartz.dataSource.myDS.maxConnections}")
+ private int myDSMaxConnections;
+
+ /**
+ * 设置属性
+ *
+ * @return
+ * @throws IOException
+ */
+ private Properties quartzProperties() throws IOException {
+ Properties prop = new Properties();
+ // 调度标识名 集群中每一个实例都必须使用相同的名称
+ prop.put("quartz.scheduler.instanceName", quartzInstanceName);
+ // ID设置为自动获取 每一个必须不同
+ prop.put("org.quartz.scheduler.instanceId", "AUTO");
+ // 禁用quartz软件更新
+ prop.put("org.quartz.scheduler.skipUpdateCheck", "true");
+ prop.put("org.quartz.scheduler.jmx.export", "true");
+
+
+ // 数据库代理类,一般org.quartz.impl.jdbcjobstore.StdJDBCDelegate可以满足大部分数据库
+ prop.put("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.StdJDBCDelegate");
+ // 数据保存方式为数据库持久化
+ prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
+ // 数据库别名 随便取
+ prop.put("org.quartz.jobStore.dataSource", "quartzDataSource");
+ //prop.put("org.quartz.jobStore.dataSource", "myDS");
+ // 表的前缀,默认QRTZ_
+ prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
+ // 是否加入集群
+ prop.put("org.quartz.jobStore.isClustered", "true");
+
+ // 调度实例失效的检查时间间隔
+ prop.put("org.quartz.jobStore.clusterCheckinInterval", "20000");
+ prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
+ // 信息保存时间 ms 默认值60秒
+ prop.put("org.quartz.jobStore.misfireThreshold", "120000");
+ prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true");
+ prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS WHERE LOCK_NAME = ? FOR UPDATE");
+
+ // 程池的实现类(一般使用SimpleThreadPool即可满足几乎所有用户的需求)
+ prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
+ // 定线程数,至少为1(无默认值)(一般设置为1-100之间的整数合适)
+ prop.put("org.quartz.threadPool.threadCount", "10");
+ // 设置线程的优先级(最大为java.lang.Thread.MAX_PRIORITY 10,最小为Thread.MIN_PRIORITY 1,默认为5)
+ prop.put("org.quartz.threadPool.threadPriority", "5");
+ prop.put("org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread", "true");
+
+ prop.put("org.quartz.plugin.triggHistory.class", "org.quartz.plugins.history.LoggingJobHistoryPlugin");
+ prop.put("org.quartz.plugin.shutdownhook.class", "org.quartz.plugins.management.ShutdownHookPlugin");
+ prop.put("org.quartz.plugin.shutdownhook.cleanShutdown", "true");
+
+ //#自定义连接池
+ //org.quartz.dataSource.myDS.connectionProvider.class=com.poly.pay.schedule.DruidConnectionProvider
+
+ return prop;
+ }
+
+ /**
+ * 数据源
+ *
+ * @return
+ * @throws PropertyVetoException
+ */
+ @Bean
+ public HikariDataSource createDataSource() throws PropertyVetoException {
+ HikariDataSource dataSource = new HikariDataSource();
+ dataSource.setJdbcUrl(myDSUrl);
+ dataSource.setDriverClassName(myDSDriver);
+ dataSource.setUsername(myDSUser);
+ dataSource.setPassword(myDSPassword);
+ dataSource.setMaximumPoolSize(myDSMaxConnections);
+ return dataSource;
+ }
+
+
+ /**
+ * 创建触发器工厂
+ *
+ * @param jobDetail
+ * @param cronExpression
+ * @return
+ */
+ private static CronTriggerFactoryBean cronTriggerFactoryBean(JobDetail jobDetail, String cronExpression) {
+ CronTriggerFactoryBean factoryBean = new CronTriggerFactoryBean();
+ factoryBean.setJobDetail(jobDetail);
+ factoryBean.setCronExpression(cronExpression);
+ return factoryBean;
+ }
+
+
+/****************************************************以下配置需要注意******************************************************/
+
+
+ /**
+ * 调度工厂
+ * 此处配置需要调度的触发器 例如 executeJobTrigger
+ *
+ * @param executeJobTrigger
+ * @return
+ * @throws IOException
+ * @throws PropertyVetoException
+ */
+ @Bean
+ public SchedulerFactoryBean schedulerFactoryBean(@Qualifier("executeJobTrigger") Trigger executeJobTrigger) throws IOException, PropertyVetoException {
+ SchedulerFactoryBean factory = new SchedulerFactoryBean();
+ // this allows to update triggers in DB when updating settings in config file:
+ //用于quartz集群,QuartzScheduler 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
+ factory.setOverwriteExistingJobs(true);
+ //用于quartz集群,加载quartz数据源
+ //factory.setDataSource(dataSource);
+ //QuartzScheduler 延时启动,应用启动完10秒后 QuartzScheduler 再启动
+ //factory.setStartupDelay(10);
+ //用于quartz集群,加载quartz数据源配置
+ factory.setAutoStartup(true);
+ factory.setQuartzProperties(quartzProperties());
+ factory.setApplicationContextSchedulerContextKey("applicationContext");
+ factory.setDataSource(createDataSource());
+ //注册触发器
+ Trigger[] triggers = {executeJobTrigger};
+ factory.setTriggers(triggers);
+
+ return factory;
+ }
+
+
+ /**
+ * 加载触发器
+ *
+ * 新建触发器进行job 的调度 例如 executeJobDetail
+ * @param jobDetail
+ * @return
+ */
+ @Bean(name = "executeJobTrigger")
+ public CronTriggerFactoryBean executeJobTrigger(@Qualifier("executeJobDetail") JobDetail jobDetail) {
+ //每天凌晨3点执行
+ return cronTriggerFactoryBean(jobDetail, "0 1 0 * * ? ");
+ }
+
+
+ /**
+ * 加载job
+ *
+ * 新建job 类用来代理
+ *
+ *
+ * @return
+ */
+ @Bean
+ public JobDetailFactoryBean executeJobDetail() {
+ return createJobDetail(InvokingJobDetailFactory.class, GROUP_NAME, "executeJob");
+ }
+
+
+ /**
+ * 执行规则job工厂
+ *
+ * 配置job 类中需要定时执行的 方法 execute
+ * @param jobClass
+ * @param groupName
+ * @param targetObject
+ * @return
+ */
+ private static JobDetailFactoryBean createJobDetail(Class extends Job> jobClass,
+ String groupName,
+ String targetObject) {
+ JobDetailFactoryBean factoryBean = new JobDetailFactoryBean();
+ factoryBean.setJobClass(jobClass);
+ factoryBean.setDurability(true);
+ factoryBean.setRequestsRecovery(true);
+ factoryBean.setGroup(groupName);
+ Map map = new HashMap<>();
+ map.put("targetMethod", "execute");
+ map.put("targetObject", targetObject);
+ factoryBean.setJobDataAsMap(map);
+ return factoryBean;
+ }
+
+}
\ No newline at end of file
diff --git a/springboot-Quartz/src/main/java/com/abel/quartz/job/ExecuteJob.java b/springboot-Quartz/src/main/java/com/abel/quartz/job/ExecuteJob.java
new file mode 100644
index 0000000..205b451
--- /dev/null
+++ b/springboot-Quartz/src/main/java/com/abel/quartz/job/ExecuteJob.java
@@ -0,0 +1,21 @@
+package com.abel.quartz.job;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created by yangyibo on 2019/2/1.
+ */
+@Service
+public class ExecuteJob {
+ private static final Logger logger = LoggerFactory.getLogger(ExecuteJob.class);
+
+ /**
+ * 方法名在quartz定义
+ */
+ public void execute() {
+ System.out.println("定时任务执行了。。。。。");
+
+ }
+}
diff --git a/springboot-Quartz/src/main/resources/application.properties b/springboot-Quartz/src/main/resources/application.properties
new file mode 100644
index 0000000..096d108
--- /dev/null
+++ b/springboot-Quartz/src/main/resources/application.properties
@@ -0,0 +1,47 @@
+## tomcat\u914D\u7F6E
+server.port=8090
+#server.tomcat.maxHttpHeaderSize=8192
+server.tomcat.uri-encoding=UTF-8
+spring.http.encoding.charset=UTF-8
+spring.http.encoding.enabled=true
+spring.http.encoding.force=true
+spring.abel.encoding=UTF-8
+# tomcat\u6700\u5927\u7EBF\u7A0B\u6570\uFF0C\u9ED8\u8BA4\u4E3A200
+server.tomcat.max-threads=800
+# session\u6700\u5927\u8D85\u65F6\u65F6\u95F4(\u5206\u949F)\uFF0C\u9ED8\u8BA4\u4E3A30
+server.session-timeout=60
+
+## spring \u914D\u7F6E
+spring.application.name=springboot-Quartz
+application.main=com.abel.quartz.Application
+
+
+## \u4E3B\u6570\u636E\u6E90\uFF0C\u9ED8\u8BA4\u7684
+spring.datasource.url=jdbc:mysql://localhost:3306/quartz?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&useSSL=false
+spring.datasource.username=root
+spring.datasource.password=admin
+spring.datasource.driverClassName=com.mysql.jdbc.Driver
+
+## \u8FDE\u63A5\u6C60\u914D\u7F6E
+spring.datasource.type=com.zaxxer.hikari.HikariDataSource
+#\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5
+spring.datasource.hikari.minimum-idle=10
+#\u8FDE\u63A5\u6C60\u4E2D\u5141\u8BB8\u7684\u6700\u5927\u8FDE\u63A5\u6570\u3002\u7F3A\u7701\u503C\uFF1A10\uFF1B\u63A8\u8350\u7684\u516C\u5F0F\uFF1A((core_count * 2) + effective_spindle_count)
+spring.datasource.hikari.maximum-pool-size=30
+#spring.datasource.hikari.auto-commit=true
+#\u4E00\u4E2A\u8FDE\u63A5idle\u72B6\u6001\u7684\u6700\u5927\u65F6\u957F\uFF08\u6BEB\u79D2\uFF09\uFF0C\u8D85\u65F6\u5219\u88AB\u91CA\u653E\uFF08retired\uFF09\uFF0C\u7F3A\u7701:10\u5206\u949F\u3002minimumIdle
+
+ springboot-quartz
+
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%method - %msg%n
+
+
+
+
+
+ ${LOG_FILE}
+
+
+ ${LOG_FILE}.%d{yyyy-MM-dd}
+
+ 60
+
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%method - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springboot-SpringSecurity0/pom.xml b/springboot-SpringSecurity0/pom.xml
index 6245cd1..22e6fd8 100644
--- a/springboot-SpringSecurity0/pom.xml
+++ b/springboot-SpringSecurity0/pom.xml
@@ -5,7 +5,7 @@
4.0.0
com.us
- springboot-security
+ springboot-security0
1.0-SNAPSHOT
@@ -49,7 +49,7 @@
com.mchange
c3p0
- 0.9.5.2
+ 0.9.5.4
commons-logging
diff --git a/springboot-SpringSecurity1/pom.xml b/springboot-SpringSecurity1/pom.xml
index b1072e5..79b8c52 100644
--- a/springboot-SpringSecurity1/pom.xml
+++ b/springboot-SpringSecurity1/pom.xml
@@ -5,7 +5,7 @@
4.0.0
com.us
- springboot-security
+ springboot-security1
1.0-SNAPSHOT
@@ -49,7 +49,7 @@
com.mchange
c3p0
- 0.9.5.2
+ 0.9.5.4
commons-logging
diff --git a/springboot-dubbo/README.md b/springboot-dubbo/README.md
new file mode 100644
index 0000000..16441b5
--- /dev/null
+++ b/springboot-dubbo/README.md
@@ -0,0 +1,10 @@
+##springboot-dubbo
+
+该项目是Springboot 和 dubbo 结合的例子,是provider 的示例,提供服务。简单的写了一些用户和权限的接口没有写的很完整,主要是为了提现dubbo 服务
+Springboot-shiro2 也是和dubbo 的结合例子是 消费者的示例。
+
+### abel-user-api
+该模块是让消费者 引用的 api 模块,主要用来定义接口和数据传输实体
+
+### abel-user-provider
+该模块是真正的微服务提供者
diff --git a/springboot-dubbo/abel-user-api/pom.xml b/springboot-dubbo/abel-user-api/pom.xml
new file mode 100644
index 0000000..650cd03
--- /dev/null
+++ b/springboot-dubbo/abel-user-api/pom.xml
@@ -0,0 +1,50 @@
+
+
+ 4.0.0
+
+ cn.abel
+ abel-parent
+ 1.0.0-SNAPSHOT
+
+
+ cn.abel
+ abel-user-api
+ 1.0.0-SNAPSHOT
+ jar
+
+
+
+ com.github.pagehelper
+ pagehelper-spring-boot-starter
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/models/Permission.java b/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/models/Permission.java
new file mode 100644
index 0000000..e5059e7
--- /dev/null
+++ b/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/models/Permission.java
@@ -0,0 +1,65 @@
+package cn.abel.user.models;
+
+
+import java.io.Serializable;
+
+public class Permission implements Serializable {
+
+ private static final long serialVersionUID = 2079120477173696231L;
+ private Integer id;
+ private String name;
+ private String permissionUrl;
+ private String method;
+ private String description;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPermissionUrl() {
+ return permissionUrl;
+ }
+
+ public void setPermissionUrl(String permissionUrl) {
+ this.permissionUrl = permissionUrl;
+ }
+
+ public String getMethod() {
+ return method;
+ }
+
+ public void setMethod(String method) {
+ this.method = method;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @Override
+ public String toString() {
+ return "Permission{" +
+ "id=" + id +
+ ", name=" + name +
+ ", permissionUrl=" + permissionUrl +
+ ", method=" + method +
+ ", description=" + description +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/models/Role.java b/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/models/Role.java
new file mode 100644
index 0000000..6a55c5b
--- /dev/null
+++ b/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/models/Role.java
@@ -0,0 +1,55 @@
+package cn.abel.user.models;
+
+
+import java.io.Serializable;
+
+public class Role implements Serializable {
+
+ private static final long serialVersionUID = -4873217276773065821L;
+ private Integer id;
+ private String name;
+ private Integer roleLevel;
+ private String description;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Integer getRoleLevel() {
+ return roleLevel;
+ }
+
+ public void setRoleLevel(Integer roleLevel) {
+ this.roleLevel = roleLevel;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @Override
+ public String toString() {
+ return "Role{" +
+ "id=" + id +
+ ", name=" + name +
+ ", roleLevel=" + roleLevel +
+ ", description=" + description +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/models/User.java b/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/models/User.java
new file mode 100644
index 0000000..07f8ab6
--- /dev/null
+++ b/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/models/User.java
@@ -0,0 +1,88 @@
+package cn.abel.user.models;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class User implements Serializable {
+
+ private static final long serialVersionUID = -4523695542426439365L;
+ private Integer id;
+ private String cnname;
+ private String username;
+
+ @JsonIgnore
+ private String password;
+ private String email;
+ private String mobilePhone;
+
+
+ private List roles;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getCnname() {
+ return cnname;
+ }
+
+ public void setCnname(String cnname) {
+ this.cnname = cnname;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+
+ public String getMobilePhone() {
+ return mobilePhone;
+ }
+
+ public void setMobilePhone(String mobilePhone) {
+ this.mobilePhone = mobilePhone;
+ }
+
+ public List getRoles() {
+ return roles;
+ }
+
+ public void setRoles(List roles) {
+ this.roles = roles;
+ }
+
+ @Override
+ public String toString() {
+ return "User{" +
+ "id=" + id +
+ ", cnname=" + cnname +
+ ", username=" + username +
+ ", password=" + password +
+ ", email=" + email +
+ ", mobilePhone=" + mobilePhone +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/service/PermissionService.java b/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/service/PermissionService.java
new file mode 100644
index 0000000..5b03f89
--- /dev/null
+++ b/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/service/PermissionService.java
@@ -0,0 +1,21 @@
+package cn.abel.user.service;
+
+import cn.abel.user.models.Permission;
+
+import java.util.List;
+import java.util.Map;
+
+public interface PermissionService {
+
+ List getByMap(Map map);
+
+ Permission getById(Integer id);
+
+ Permission create(Permission permission);
+
+
+ Permission update(Permission permission);
+
+ int delete(Integer id);
+
+}
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/service/RoleService.java b/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/service/RoleService.java
new file mode 100644
index 0000000..7c3cc0d
--- /dev/null
+++ b/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/service/RoleService.java
@@ -0,0 +1,22 @@
+package cn.abel.user.service;
+
+
+import cn.abel.user.models.Role;
+
+import java.util.List;
+import java.util.Map;
+
+public interface RoleService {
+
+
+ List getByMap(Map map);
+
+ Role getById(Integer id);
+
+ Role create(Role role);
+
+ Role update(Role role);
+
+ int delete(Integer id);
+
+}
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/service/UserService.java b/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/service/UserService.java
new file mode 100644
index 0000000..c19eed5
--- /dev/null
+++ b/springboot-dubbo/abel-user-api/src/main/java/cn/abel/user/service/UserService.java
@@ -0,0 +1,21 @@
+package cn.abel.user.service;
+
+import cn.abel.user.models.User;
+
+import java.util.List;
+import java.util.Map;
+
+public interface UserService {
+
+ List getByMap(Map map);
+
+ User getById(Integer id);
+
+ User create(User user);
+
+ User update(User user);
+
+ int delete(Integer id);
+
+ User getByUserName(String userName);
+}
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/doc/user.sql b/springboot-dubbo/abel-user-provider/doc/user.sql
new file mode 100644
index 0000000..107c5ca
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/doc/user.sql
@@ -0,0 +1,83 @@
+/*
+ Navicat Premium Data Transfer
+
+ Source Server : localhost
+ Source Server Type : MySQL
+ Source Server Version : 50719
+ Source Host : 127.0.0.1:3306
+ Source Schema : shiro
+
+ Target Server Type : MySQL
+ Target Server Version : 50719
+ File Encoding : 65001
+
+ Date: 20/03/2020 10:51:00
+*/
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for permission
+-- ----------------------------
+DROP TABLE IF EXISTS `permission`;
+CREATE TABLE `permission` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` varchar(100) COLLATE utf8_bin NOT NULL,
+ `permission_url` varchar(100) COLLATE utf8_bin DEFAULT NULL,
+ `method` varchar(100) COLLATE utf8_bin DEFAULT NULL,
+ `description` varchar(1000) COLLATE utf8_bin DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name` (`name`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+
+-- ----------------------------
+-- Table structure for role
+-- ----------------------------
+DROP TABLE IF EXISTS `role`;
+CREATE TABLE `role` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` varchar(100) COLLATE utf8_bin NOT NULL,
+ `role_level` int(1) DEFAULT NULL,
+ `description` varchar(1000) COLLATE utf8_bin DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name` (`name`)
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+
+-- ----------------------------
+-- Table structure for role_permission
+-- ----------------------------
+DROP TABLE IF EXISTS `role_permission`;
+CREATE TABLE `role_permission` (
+ `role_id` int(11) NOT NULL,
+ `permission_id` int(11) NOT NULL,
+ PRIMARY KEY (`role_id`,`permission_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+
+-- ----------------------------
+-- Table structure for user
+-- ----------------------------
+DROP TABLE IF EXISTS `user`;
+CREATE TABLE `user` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `cnname` varchar(50) COLLATE utf8_bin DEFAULT NULL,
+ `username` varchar(50) COLLATE utf8_bin NOT NULL,
+ `password` varchar(100) COLLATE utf8_bin NOT NULL,
+ `email` varchar(100) COLLATE utf8_bin DEFAULT NULL,
+ `mobile_phone` varchar(50) COLLATE utf8_bin DEFAULT NULL,
+ `status` int(11) DEFAULT '4' COMMENT '用户登录状态,1 : 在线 2 离开 3 忙碌 4 离线',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `username` (`username`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+
+-- ----------------------------
+-- Table structure for user_role
+-- ----------------------------
+DROP TABLE IF EXISTS `user_role`;
+CREATE TABLE `user_role` (
+ `user_id` int(11) NOT NULL,
+ `role_id` int(11) NOT NULL,
+ PRIMARY KEY (`user_id`,`role_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+
+SET FOREIGN_KEY_CHECKS = 1;
diff --git a/springboot-dubbo/abel-user-provider/pom.xml b/springboot-dubbo/abel-user-provider/pom.xml
new file mode 100644
index 0000000..8c87478
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/pom.xml
@@ -0,0 +1,177 @@
+
+
+ 4.0.0
+
+ cn.abel
+ abel-parent
+ 1.0.0-SNAPSHOT
+
+
+ cn.abel
+ abel-user-provider
+ 1.0.0
+ jar
+
+
+
+
+ cn.abel
+ abel-user-api
+ 1.0.0-SNAPSHOT
+
+
+ cn.abel
+ abel-util
+ 1.0.0-SNAPSHOT
+
+
+ org.apache.commons
+ commons-pool2
+
+
+
+ com.alibaba
+ fastjson
+ 1.2.58
+
+
+
+
+ org.apache.commons
+ commons-collections4
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+
+
+ com.github.pagehelper
+ pagehelper-spring-boot-starter
+
+
+ mysql
+ mysql-connector-java
+
+
+
+
+ com.alibaba
+ dubbo
+
+
+ org.slf4j
+ log4j-over-slf4j
+
+
+ org.apache.zookeeper
+ zookeeper
+
+
+ org.jboss.resteasy
+ resteasy-jaxrs
+
+
+ org.jboss.resteasy
+ resteasy-client
+
+
+ org.jboss.resteasy
+ resteasy-jackson-provider
+
+
+ javax.validation
+ validation-api
+
+
+ org.hibernate.validator
+ hibernate-validator
+
+
+ com.101tec
+ zkclient
+
+
+ org.apache.httpcomponents
+ httpcore
+
+
+ org.apache.httpcomponents
+ httpcore-nio
+
+
+ org.apache.httpcomponents
+ httpclient
+
+
+ org.apache.httpcomponents
+ httpasyncclient
+
+
+ it.uniroma1.dis.wsngroup.gexf4j
+ gexf4j
+ 1.0.0
+
+
+
+ io.sentry
+ sentry-logback
+ 1.7.3
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
+
+ org.apache.curator
+ curator-framework
+ 2.5.0
+
+
+ org.javassist
+ javassist
+ 3.15.0-GA
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+
+
+
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/UserProviderApplication.java b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/UserProviderApplication.java
new file mode 100644
index 0000000..3a148b4
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/UserProviderApplication.java
@@ -0,0 +1,14 @@
+package cn.abel.user;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ImportResource;
+
+@SpringBootApplication
+@ImportResource("classpath*:META-INF/spring/*.xml")
+public class UserProviderApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(UserProviderApplication.class, args);
+ }
+}
diff --git a/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/constants/Constants.java b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/constants/Constants.java
new file mode 100644
index 0000000..a614bc1
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/constants/Constants.java
@@ -0,0 +1,7 @@
+package cn.abel.user.constants;
+
+/**
+ * 公用的常量类。
+ */
+public interface Constants {
+}
diff --git a/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/dao/PermissionDao.java b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/dao/PermissionDao.java
new file mode 100644
index 0000000..4542b7d
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/dao/PermissionDao.java
@@ -0,0 +1,29 @@
+package cn.abel.user.dao;
+
+
+import cn.abel.user.models.Permission;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
+
+@Repository
+@Mapper
+public interface PermissionDao {
+
+ List getByMap(Map map);
+
+ Permission getById(Integer id);
+
+ Integer create(Permission permission);
+
+ int update(Permission permission);
+
+ int delete(Integer id);
+
+ List getList();
+
+ List getByUserId(Integer userId);
+
+}
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/dao/RoleDao.java b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/dao/RoleDao.java
new file mode 100644
index 0000000..20f3c92
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/dao/RoleDao.java
@@ -0,0 +1,20 @@
+package cn.abel.user.dao;
+
+
+
+import cn.abel.user.models.Role;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
+@Repository
+@Mapper
+public interface RoleDao {
+
+ List getByMap(Map map);
+ Role getById(Integer id);
+ Integer create(Role role);
+ int update(Role role);
+ int delete(Integer id);
+}
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/dao/UserDao.java b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/dao/UserDao.java
new file mode 100644
index 0000000..9303a55
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/dao/UserDao.java
@@ -0,0 +1,20 @@
+package cn.abel.user.dao;
+
+
+import cn.abel.user.models.User;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
+@Repository
+@Mapper
+public interface UserDao {
+
+ List getByMap(Map map);
+ User getById(Integer id);
+ Integer create(User user);
+ int update(User user);
+ int delete(Integer id);
+ User getByUserName(String userName);
+}
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/exception/JsonExceptionMapper.java b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/exception/JsonExceptionMapper.java
new file mode 100644
index 0000000..93b8ef0
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/exception/JsonExceptionMapper.java
@@ -0,0 +1,31 @@
+package cn.abel.user.exception;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+import cn.abel.code.InfoCode;
+import cn.abel.response.ResponseEntity;
+import org.codehaus.jackson.JsonProcessingException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * json转换错误
+ *
+ * @author ye
+ * @date 2018/11/02 14:20
+ */
+public class JsonExceptionMapper implements ExceptionMapper {
+
+ /** logger */
+ private static final Logger logger = LoggerFactory.getLogger(JsonExceptionMapper.class);
+
+ @Override
+ public Response toResponse(JsonProcessingException exception) {
+ ResponseEntity entity = ResponseEntity.error(InfoCode.REQUEST_PARAM_ERROR);
+ logger.info("{}", InfoCode.REQUEST_PARAM_ERROR.getMsg());
+ return Response.ok(entity, MediaType.APPLICATION_JSON).build();
+ }
+
+}
diff --git a/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/exception/ReaderExceptionMapper.java b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/exception/ReaderExceptionMapper.java
new file mode 100644
index 0000000..1b20cc8
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/exception/ReaderExceptionMapper.java
@@ -0,0 +1,31 @@
+package cn.abel.user.exception;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+import cn.abel.code.InfoCode;
+import cn.abel.response.ResponseEntity;
+import org.jboss.resteasy.spi.ReaderException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * json转换错误
+ *
+ * @author ye
+ * @date 2018/11/02 14:20
+ */
+public class ReaderExceptionMapper implements ExceptionMapper {
+
+ /** logger */
+ private static final Logger logger = LoggerFactory.getLogger(ReaderExceptionMapper.class);
+
+ @Override
+ public Response toResponse(ReaderException exception) {
+ ResponseEntity entity = ResponseEntity.error(InfoCode.REQUEST_PARAM_ERROR);
+ logger.info("{}", InfoCode.REQUEST_PARAM_ERROR.getMsg());
+ return Response.ok(entity, MediaType.APPLICATION_JSON).build();
+ }
+
+}
diff --git a/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/exception/RestExceptionMapper.java b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/exception/RestExceptionMapper.java
new file mode 100644
index 0000000..311e3bb
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/exception/RestExceptionMapper.java
@@ -0,0 +1,45 @@
+package cn.abel.user.exception;
+
+import javax.ws.rs.NotAllowedException;
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.NotSupportedException;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * http调用错误
+ *
+ * @author ye
+ * @date 2018/11/02 14:20
+ */
+public class RestExceptionMapper implements ExceptionMapper {
+
+ /** logger */
+ private static final Logger logger = LoggerFactory.getLogger(WebApplicationException.class);
+
+ @Override
+ public Response toResponse(WebApplicationException e) {
+ if (e instanceof NotAllowedException) {
+ logger.info("method错误。{}", e.getMessage());
+ return null;
+ }
+
+ //415
+ if (e instanceof NotSupportedException) {
+ logger.info("content-type错误。{}", e.getMessage());
+ return null;
+ }
+
+ if (e instanceof NotFoundException) {
+ logger.info("url错误。{}", e.getMessage());
+ return null;
+ }
+
+ return null;
+ }
+
+}
diff --git a/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/exception/ServiceExceptionMapper.java b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/exception/ServiceExceptionMapper.java
new file mode 100644
index 0000000..6f76d12
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/exception/ServiceExceptionMapper.java
@@ -0,0 +1,29 @@
+package cn.abel.user.exception;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+import cn.abel.exception.ServiceException;
+import cn.abel.response.ResponseEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ServiceExceptionMapper
+ *
+ * @author ye
+ * @date 2018/11/02 14:20
+ */
+public class ServiceExceptionMapper implements ExceptionMapper {
+
+ /** logger */
+ private static final Logger logger = LoggerFactory.getLogger(ServiceException.class);
+
+ @Override
+ public Response toResponse(ServiceException exception) {
+ ResponseEntity entity = ResponseEntity.error(exception.getErrorCode(), exception.getMessage());
+ logger.error("{},{}", exception.getErrorCode(), exception.getMessage());
+ return Response.ok(entity, MediaType.APPLICATION_JSON).build();
+ }
+}
diff --git a/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/exception/ValidationExceptionMapper.java b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/exception/ValidationExceptionMapper.java
new file mode 100644
index 0000000..a464d1b
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/exception/ValidationExceptionMapper.java
@@ -0,0 +1,36 @@
+package cn.abel.user.exception;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
+import javax.ws.rs.core.Response;
+
+import cn.abel.code.InfoCode;
+import cn.abel.response.ResponseEntity;
+import com.alibaba.dubbo.rpc.protocol.rest.RpcExceptionMapper;
+import com.alibaba.dubbo.rpc.protocol.rest.support.ContentType;
+
+/**
+ * 参数校验异常
+ *
+ * @author ye
+ * @date 2018/11/04 16:53
+ */
+public class ValidationExceptionMapper extends RpcExceptionMapper {
+
+ @Override
+ protected Response handleConstraintViolationException(ConstraintViolationException cve) {
+ //ViolationReport report = new ViolationReport();
+ String msg = "";
+ for (ConstraintViolation cv : cve.getConstraintViolations()) {
+ //report.addConstraintViolation(new RestConstraintViolation(cv.getPropertyPath().toString(),
+ // cv.getMessage(), cv.getInvalidValue() == null ? "null" : cv.getInvalidValue().toString()));
+ msg = cv.getPropertyPath().toString() + " " + cv.getMessage();
+ }
+
+ ResponseEntity entity = ResponseEntity.error(InfoCode.REQUEST_PARAM_ERROR.getStatus(),
+ InfoCode.REQUEST_PARAM_ERROR.getMsg() + "(" + msg + ")");
+
+ // 采用json输出代替xml输出
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(entity).type(ContentType.APPLICATION_JSON_UTF_8).build();
+ }
+}
diff --git a/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/filter/RestFilter.java b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/filter/RestFilter.java
new file mode 100644
index 0000000..617b7c9
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/filter/RestFilter.java
@@ -0,0 +1,71 @@
+package cn.abel.user.filter;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Priority;
+import javax.ws.rs.client.ClientRequestContext;
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.client.ClientResponseContext;
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.ContainerResponseContext;
+import javax.ws.rs.container.ContainerResponseFilter;
+import javax.ws.rs.container.PreMatching;
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 日志-复制并替代com.alibaba.dubbo.rpc.protocol.rest.support.LoggingFilter
+ *
+ * @author ye
+ * @date 2018/11/02 15:20
+ */
+@Priority(900)
+@PreMatching
+public class RestFilter implements ContainerRequestFilter, ClientRequestFilter, ContainerResponseFilter,
+ ClientResponseFilter {
+
+ /** logger */
+ private static final Logger logger = LoggerFactory.getLogger(RestFilter.class);
+
+ @Override
+ public void filter(ClientRequestContext context) throws IOException {
+ logHttpHeaders(context.getStringHeaders());
+ }
+
+ @Override
+ public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
+ logHttpHeaders(responseContext.getHeaders());
+ }
+
+ @Override
+ public void filter(ContainerRequestContext context) throws IOException {
+ logHttpHeaders(context.getHeaders());
+ }
+
+ @Override
+ public void filter(ContainerRequestContext requestContext,
+ ContainerResponseContext responseContext) throws IOException {
+ logHttpHeaders(responseContext.getStringHeaders());
+ }
+
+ protected void logHttpHeaders(MultivaluedMap headers) {
+ StringBuilder msg = new StringBuilder("The HTTP headers are: \n");
+ for (Map.Entry> entry : headers.entrySet()) {
+ msg.append(entry.getKey()).append(": ");
+ for (int i = 0; i < entry.getValue().size(); i++) {
+ msg.append(entry.getValue().get(i));
+ if (i < entry.getValue().size() - 1) {
+ msg.append(", ");
+ }
+ }
+ msg.append("\n");
+ }
+ logger.info(msg.toString());
+ }
+}
diff --git a/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/filter/RestInterceptor.java b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/filter/RestInterceptor.java
new file mode 100644
index 0000000..75170c2
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/filter/RestInterceptor.java
@@ -0,0 +1,88 @@
+package cn.abel.user.filter;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.ext.ReaderInterceptor;
+import javax.ws.rs.ext.ReaderInterceptorContext;
+import javax.ws.rs.ext.WriterInterceptor;
+import javax.ws.rs.ext.WriterInterceptorContext;
+
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 日志-复制并替代com.alibaba.dubbo.rpc.protocol.rest.support.LoggingFilter
+ *
+ * @author ye
+ * @date 2018/11/04 16:34
+ */
+public class RestInterceptor implements WriterInterceptor, ReaderInterceptor {
+
+ /** logger */
+ private static final Logger logger = LoggerFactory.getLogger(RestInterceptor.class);
+
+ @Override
+ public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException {
+ byte[] buffer = IOUtils.toByteArray(context.getInputStream());
+ logger.info("The contents of request body is: \n" + new String(buffer, "UTF-8") + "\n");
+ context.setInputStream(new ByteArrayInputStream(buffer));
+ return context.proceed();
+ }
+
+ @Override
+ public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
+ RestInterceptor.OutputStreamWrapper wrapper =
+ new RestInterceptor.OutputStreamWrapper(context.getOutputStream());
+ context.setOutputStream(wrapper);
+ context.proceed();
+ logger.info("The contents of response body is: \n" + new String(wrapper.getBytes(), "UTF-8") + "\n");
+ }
+
+ protected static class OutputStreamWrapper extends OutputStream {
+
+ private final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ private final OutputStream output;
+
+ private OutputStreamWrapper(OutputStream output) {
+ this.output = output;
+ }
+
+ @Override
+ public void write(int i) throws IOException {
+ buffer.write(i);
+ output.write(i);
+ }
+
+ @Override
+ public void write(byte[] b) throws IOException {
+ buffer.write(b);
+ output.write(b);
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len) throws IOException {
+ buffer.write(b, off, len);
+ output.write(b, off, len);
+ }
+
+ @Override
+ public void flush() throws IOException {
+ output.flush();
+ }
+
+ @Override
+ public void close() throws IOException {
+ output.close();
+ }
+
+ public byte[] getBytes() {
+ return buffer.toByteArray();
+ }
+ }
+
+}
diff --git a/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/service/impl/PermissionServiceImpl.java b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/service/impl/PermissionServiceImpl.java
new file mode 100644
index 0000000..69531f9
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/service/impl/PermissionServiceImpl.java
@@ -0,0 +1,44 @@
+package cn.abel.user.service.impl;
+
+import cn.abel.user.dao.PermissionDao;
+import cn.abel.user.models.Permission;
+import cn.abel.user.service.PermissionService;
+import com.alibaba.dubbo.config.annotation.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+import java.util.Map;
+
+@Service(protocol = {"dubbo"}, validation = "false")
+public class PermissionServiceImpl implements PermissionService {
+ @Autowired
+ private PermissionDao permissionDao;
+
+ @Override
+ public List getByMap(Map map) {
+ return permissionDao.getByMap(map);
+ }
+
+ @Override
+ public Permission getById(Integer id) {
+ return permissionDao.getById(id);
+ }
+
+ @Override
+ public Permission create(Permission permission) {
+ permissionDao.create(permission);
+ return permission;
+ }
+
+ @Override
+ public Permission update(Permission permission) {
+ permissionDao.update(permission);
+ return permission;
+ }
+
+ @Override
+ public int delete(Integer id) {
+ return permissionDao.delete(id);
+ }
+
+}
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/service/impl/RoleServiceImpl.java b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/service/impl/RoleServiceImpl.java
new file mode 100644
index 0000000..d24eec1
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/service/impl/RoleServiceImpl.java
@@ -0,0 +1,40 @@
+package cn.abel.user.service.impl;
+
+
+import cn.abel.user.dao.RoleDao;
+import cn.abel.user.models.Role;
+import cn.abel.user.service.RoleService;
+import com.alibaba.dubbo.config.annotation.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+import java.util.Map;
+
+@Service(protocol = {"dubbo"}, validation = "false")
+public class RoleServiceImpl implements RoleService{
+ @Autowired
+ private RoleDao roleDao;
+ @Override
+ public List getByMap(Map map) {
+ return roleDao.getByMap(map);
+ }
+ @Override
+ public Role getById(Integer id) {
+ return roleDao.getById(id);
+ }
+ @Override
+ public Role create(Role role) {
+ roleDao.create(role);
+ return role;
+ }
+ @Override
+ public Role update(Role role) {
+ roleDao.update(role);
+ return role;
+ }
+ @Override
+ public int delete(Integer id) {
+ return roleDao.delete(id);
+ }
+
+}
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/service/impl/UserServiceImpl.java b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/service/impl/UserServiceImpl.java
new file mode 100644
index 0000000..3d2ab10
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/service/impl/UserServiceImpl.java
@@ -0,0 +1,49 @@
+package cn.abel.user.service.impl;
+
+import cn.abel.user.dao.UserDao;
+import cn.abel.user.models.User;
+import cn.abel.user.service.UserService;
+import com.alibaba.dubbo.config.annotation.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+import java.util.Map;
+
+@Service(protocol = {"dubbo"}, validation = "false")
+public class UserServiceImpl implements UserService {
+ @Autowired
+ private UserDao userDao;
+
+ @Override
+ public List getByMap(Map map) {
+ return userDao.getByMap(map);
+ }
+
+ @Override
+ public User getById(Integer id) {
+ return userDao.getById(id);
+ }
+
+ @Override
+ public User create(User user) {
+ userDao.create(user);
+ return user;
+ }
+
+ @Override
+ public User update(User user) {
+ userDao.update(user);
+ return user;
+ }
+
+ @Override
+ public int delete(Integer id) {
+ return userDao.delete(id);
+ }
+
+ @Override
+ public User getByUserName(String userName) {
+ return userDao.getByUserName(userName);
+ }
+
+}
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/utils/CommentUtils.java b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/utils/CommentUtils.java
new file mode 100644
index 0000000..6ffa68a
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/java/cn/abel/user/utils/CommentUtils.java
@@ -0,0 +1,28 @@
+package cn.abel.user.utils;
+
+import com.alibaba.fastjson.JSON;
+import org.apache.commons.collections4.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author yyb
+ * @time 2020/3/10
+ */
+public class CommentUtils {
+
+ /**
+ *
+ * @param list
+ * @param
+ * @return
+ */
+ public static List copyList(List list) {
+ if (CollectionUtils.isEmpty(list)) {
+ return new ArrayList();
+ }
+ return JSON.parseArray(JSON.toJSONString(list), list.get(0).getClass());
+ }
+
+}
diff --git a/springboot-dubbo/abel-user-provider/src/main/resources/META-INF/spring/provider.xml b/springboot-dubbo/abel-user-provider/src/main/resources/META-INF/spring/provider.xml
new file mode 100644
index 0000000..c65bacf
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/resources/META-INF/spring/provider.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/src/main/resources/dev/application.properties b/springboot-dubbo/abel-user-provider/src/main/resources/dev/application.properties
new file mode 100644
index 0000000..f2da32a
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/resources/dev/application.properties
@@ -0,0 +1,53 @@
+#application
+spring.application.name=abel-user-provider
+application.main=cn.abel.user.UserProviderApplication
+server.port=9658
+server.tomcat.uri-encoding=UTF-8
+spring.http.encoding.charset=UTF-8
+spring.http.encoding.enabled=true
+spring.http.encoding.force=true
+spring.messages.encoding=UTF-8
+server.tomcat.max-threads=200
+server.session-timeout=60
+log4j.logger.java.sql.Connection=DEBUG
+
+
+#dubbo
+dubbo.application.name=abel-user-provider
+dubbo.registry.group=abel
+dubbo.registry.address=127.0.0.1:2181
+dubbo.registry.version=1.0.0
+dubbo.protocol.port=12885
+dubbo.protocol.rest.port=12886
+dubbo.annotation.package=cn.abel.user
+dubbo.log.file=/logs/abel-user-provider/abel-user-provider-dubbo.log
+
+#db
+spring.datasource.url=jdbc:mysql://127.0.0.1:3306/shiro?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&useSSL=false
+spring.datasource.username=root
+spring.datasource.password=admin
+spring.datasource.driverClassName=com.mysql.jdbc.Driver
+
+#DataSource
+spring.datasource.type=com.zaxxer.hikari.HikariDataSource
+spring.datasource.hikari.minimum-idle=10
+spring.datasource.hikari.maximum-pool-size=30
+spring.datasource.hikari.idle-timeout=120000
+spring.datasource.hikari.max-lifetime=1800000
+spring.datasource.hikari.connection-timeout=30000
+spring.datasource.hikari.validation-timeout=3000
+spring.datasource.hikari.connection-test-query=SELECT 1
+
+
+#mybatis
+logging.level.cn.abel.user.dao=info
+mybatis.type-aliases-package=cn.abel.user.model
+mybatis.mapper-locations=classpath*:mapper/*Mapper.xml
+
+#PageHelper
+pagehelper.helperDialect=mysql
+pagehelper.reasonable=true
+pagehelper.supportMethodsArguments=true
+pagehelper.params=count=countSql
+
+logging.file=/logs/abel-user-provider/abel-user-provider.log
diff --git a/springboot-dubbo/abel-user-provider/src/main/resources/dev/banner.txt b/springboot-dubbo/abel-user-provider/src/main/resources/dev/banner.txt
new file mode 100644
index 0000000..07d3606
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/resources/dev/banner.txt
@@ -0,0 +1,5 @@
+########################################################
+# #
+# dev #
+# #
+########################################################
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/src/main/resources/dev/logback-spring.xml b/springboot-dubbo/abel-user-provider/src/main/resources/dev/logback-spring.xml
new file mode 100644
index 0000000..78f9a29
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/resources/dev/logback-spring.xml
@@ -0,0 +1,40 @@
+
+
+ abel_user
+
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%method - %msg%n
+
+
+
+
+
+ ${LOG_FILE}
+
+
+ ${LOG_FILE}.%d{yyyy-MM-dd}
+
+ 60
+
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%method - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/src/main/resources/local/application.properties b/springboot-dubbo/abel-user-provider/src/main/resources/local/application.properties
new file mode 100644
index 0000000..9c996b1
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/resources/local/application.properties
@@ -0,0 +1,53 @@
+#application
+spring.application.name=abel-user-provider
+application.main=cn.abel.user.UserProviderApplication
+server.port=9658
+server.tomcat.uri-encoding=UTF-8
+spring.http.encoding.charset=UTF-8
+spring.http.encoding.enabled=true
+spring.http.encoding.force=true
+spring.messages.encoding=UTF-8
+server.tomcat.max-threads=200
+server.session-timeout=60
+log4j.logger.java.sql.Connection=DEBUG
+
+
+#dubbo
+dubbo.application.name=abel-user-provider
+dubbo.registry.group=abel
+dubbo.registry.address=127.0.0.1:2181
+dubbo.registry.version=1.0.0
+dubbo.protocol.port=12885
+dubbo.protocol.rest.port=12886
+dubbo.annotation.package=cn.abel.user
+dubbo.log.file=./logs/abel-user-provider/abel-user-provider-dubbo.log
+
+#db
+spring.datasource.url=jdbc:mysql://127.0.0.1:3306/shiro?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&useSSL=false
+spring.datasource.username=root
+spring.datasource.password=admin
+spring.datasource.driverClassName=com.mysql.jdbc.Driver
+
+#DataSource
+spring.datasource.type=com.zaxxer.hikari.HikariDataSource
+spring.datasource.hikari.minimum-idle=10
+spring.datasource.hikari.maximum-pool-size=30
+spring.datasource.hikari.idle-timeout=120000
+spring.datasource.hikari.max-lifetime=1800000
+spring.datasource.hikari.connection-timeout=30000
+spring.datasource.hikari.validation-timeout=3000
+spring.datasource.hikari.connection-test-query=SELECT 1
+
+
+#mybatis
+logging.level.cn.abel.user.dao=info
+mybatis.type-aliases-package=cn.abel.user.model
+mybatis.mapper-locations=classpath*:mapper/*Mapper.xml
+
+#PageHelper
+pagehelper.helperDialect=mysql
+pagehelper.reasonable=true
+pagehelper.supportMethodsArguments=true
+pagehelper.params=count=countSql
+
+logging.file=./logs/abel-user-provider/abel-user-provider.log
diff --git a/springboot-dubbo/abel-user-provider/src/main/resources/local/banner.txt b/springboot-dubbo/abel-user-provider/src/main/resources/local/banner.txt
new file mode 100644
index 0000000..42f7c59
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/resources/local/banner.txt
@@ -0,0 +1,5 @@
+########################################################
+# #
+# local #
+# #
+########################################################
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/src/main/resources/local/logback-spring.xml b/springboot-dubbo/abel-user-provider/src/main/resources/local/logback-spring.xml
new file mode 100644
index 0000000..29daaef
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/resources/local/logback-spring.xml
@@ -0,0 +1,41 @@
+
+
+ abel_user
+
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%method - %msg%n
+
+
+
+
+
+ ${LOG_FILE}
+
+
+ ${LOG_FILE}.%d{yyyy-MM-dd}
+
+ 60
+
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%method - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/src/main/resources/mapper/PermissionDaoMapper.xml b/springboot-dubbo/abel-user-provider/src/main/resources/mapper/PermissionDaoMapper.xml
new file mode 100644
index 0000000..1f0c2b5
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/resources/mapper/PermissionDaoMapper.xml
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ and id = #{id}
+
+
+ and name = #{name}
+
+
+ and permission_url = #{permissionUrl}
+
+
+ and method = #{method}
+
+
+ and description = #{description}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SELECT LAST_INSERT_ID()
+
+ INSERT INTO permission(
+ id,
+ name,
+ permission_url,
+ method,
+ description
+ )VALUES(
+ #{id},
+ #{name},
+ #{permissionUrl},
+ #{method},
+ #{description}
+ )
+
+
+
+ UPDATE permission SET
+ name = #{name},
+ permission_url = #{permissionUrl},
+ method = #{method},
+ description = #{description}
+ WHERE id = #{id}
+
+
+
+ DELETE FROM permission WHERE id = #{id}
+
+
+
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/src/main/resources/mapper/RoleDaoMapper.xml b/springboot-dubbo/abel-user-provider/src/main/resources/mapper/RoleDaoMapper.xml
new file mode 100644
index 0000000..34242c2
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/resources/mapper/RoleDaoMapper.xml
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ and id = #{id}
+
+
+ and name = #{name}
+
+
+ and role_level = #{roleLevel}
+
+
+ and description = #{description}
+
+
+
+
+
+
+
+
+
+
+
+ SELECT LAST_INSERT_ID()
+
+ INSERT INTO role(
+ id,
+ name,
+ role_level,
+ description
+ )VALUES(
+ #{id},
+ #{name},
+ #{roleLevel},
+ #{description}
+ )
+
+
+
+ UPDATE role SET
+ name = #{name},
+ role_level = #{roleLevel},
+ description = #{description}
+ WHERE id = #{id}
+
+
+
+ DELETE FROM role WHERE id = #{id}
+
+
+
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/src/main/resources/mapper/UserDaoMapper.xml b/springboot-dubbo/abel-user-provider/src/main/resources/mapper/UserDaoMapper.xml
new file mode 100644
index 0000000..d7cb24c
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/resources/mapper/UserDaoMapper.xml
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ and id = #{id}
+
+
+ and cnname = #{cnname}
+
+
+ and username = #{username}
+
+
+ and password = #{password}
+
+
+ and email = #{email}
+
+
+ and mobile_phone = #{mobilePhone}
+
+
+ and (
+ cnname like CONCAT('%', #{keywords},'%')
+ OR username like CONCAT('%', #{keywords},'%')
+ OR mobile_phone like CONCAT('%', #{keywords},'%')
+ OR email like CONCAT('%', #{keywords},'%')
+ )
+
+
+
+
+
+
+
+
+
+
+
+
+ SELECT LAST_INSERT_ID()
+
+ INSERT INTO user(
+ id,
+ cnname,
+ username,
+ password,
+ email,
+ mobile_phone
+ )VALUES(
+ #{id},
+ #{cnname},
+ #{username},
+ #{password},
+ #{email},
+ #{mobilePhone}
+ )
+
+
+
+ UPDATE user SET
+ cnname = #{cnname},
+ username = #{username},
+ password = #{password},
+ email = #{email},
+ mobile_phone = #{mobilePhone}
+ WHERE id = #{id}
+
+
+
+ DELETE FROM user WHERE id = #{id}
+
+
+
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/src/main/test/cn/abel/user/BaseTest.java b/springboot-dubbo/abel-user-provider/src/main/test/cn/abel/user/BaseTest.java
new file mode 100644
index 0000000..27a7973
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/test/cn/abel/user/BaseTest.java
@@ -0,0 +1,33 @@
+package cn.abel.user;
+
+/**
+ * @author yyb
+ * @time 2020/3/9
+ */
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = UserProviderApplication.class)
+@TestPropertySource("/application.properties")
+public class BaseTest {
+
+ @Configuration
+ @ComponentScan(basePackages = {"cn.abel.user"}, excludeFilters = @ComponentScan.Filter(type = FilterType.ANNOTATION, value = Configuration.class))
+ static class ComponentScanConfig {
+
+ }
+
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
\ No newline at end of file
diff --git a/springboot-dubbo/abel-user-provider/src/main/test/cn/abel/user/service/impl/PermissionServiceImplTest.java b/springboot-dubbo/abel-user-provider/src/main/test/cn/abel/user/service/impl/PermissionServiceImplTest.java
new file mode 100644
index 0000000..5513a6c
--- /dev/null
+++ b/springboot-dubbo/abel-user-provider/src/main/test/cn/abel/user/service/impl/PermissionServiceImplTest.java
@@ -0,0 +1,55 @@
+package cn.abel.user.service.impl;
+
+import cn.abel.user.BaseTest;
+import cn.abel.user.models.Permission;
+import cn.abel.user.service.PermissionService;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import static org.junit.Assert.*;
+
+/**
+ * @author yyb
+ * @time 2020/3/20
+ */
+public class PermissionServiceImplTest extends BaseTest {
+ @Autowired
+ private PermissionService permissionService;
+ @Test
+ public void getByMap() throws Exception {
+ permissionService.getByMap(null);
+ }
+
+ @Test
+ public void getById() throws Exception {
+ Permission permission = permissionService.getById(1);
+ System.out.println();
+ }
+
+ @Test
+ public void create() throws Exception {
+ Permission permission = new Permission();
+ permission.setDescription("234234");
+ permission.setName("新增");
+ permission.setMethod("nicai");
+ permission.setPermissionUrl("zsdfsf_sf");
+ permissionService.create(permission);
+ }
+
+ @Test
+ public void update() throws Exception {
+ Permission permission = new Permission();
+ permission.setId(1);
+ permission.setDescription("234234");
+ permission.setName("新增");
+ permission.setMethod("nicai");
+ permission.setPermissionUrl("zsdfsf_sf");
+ permissionService.update(permission);
+ }
+
+ @Test
+ public void delete() throws Exception {
+ permissionService.delete(1);
+ }
+
+}
\ No newline at end of file
diff --git a/springboot-dynamicDataSource/pom.xml b/springboot-dynamicDataSource/pom.xml
new file mode 100644
index 0000000..9992b8b
--- /dev/null
+++ b/springboot-dynamicDataSource/pom.xml
@@ -0,0 +1,57 @@
+
+
+ 4.0.0
+
+ cn.abel
+ springboot-dynamicDataSource
+ 1.0-SNAPSHOT
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.0.4.RELEASE
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.springframework.boot
+ spring-boot-starter-freemarker
+
+
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ 1.3.2
+
+
+ com.github.pagehelper
+ pagehelper-spring-boot-starter
+ 1.2.5
+
+
+ mysql
+ mysql-connector-java
+ 5.1.40
+
+
+
+ org.apache.commons
+ commons-lang3
+ 3.4
+
+
+
+
\ No newline at end of file
diff --git a/springboot-dynamicDataSource/sql/news.sql b/springboot-dynamicDataSource/sql/news.sql
new file mode 100644
index 0000000..82fd1e2
--- /dev/null
+++ b/springboot-dynamicDataSource/sql/news.sql
@@ -0,0 +1,33 @@
+/*
+ Navicat Premium Data Transfer
+
+ Source Server : localhost
+ Source Server Type : MySQL
+ Source Server Version : 50719
+ Source Host : 127.0.0.1
+ Source Database : oldMan
+
+ Target Server Type : MySQL
+ Target Server Version : 50719
+ File Encoding : utf-8
+
+ Date: 04/02/2019 15:38:58 PM
+*/
+
+SET NAMES utf8;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for `news`
+-- ----------------------------
+DROP TABLE IF EXISTS `news`;
+CREATE TABLE `news` (
+ `id` int(11) NOT NULL,
+ `title` varchar(100) DEFAULT NULL,
+ `content` text,
+ `image_path` varchar(100) DEFAULT NULL,
+ `read_sum` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+SET FOREIGN_KEY_CHECKS = 1;
diff --git a/springboot-dynamicDataSource/sql/user.sql b/springboot-dynamicDataSource/sql/user.sql
new file mode 100644
index 0000000..a42941a
--- /dev/null
+++ b/springboot-dynamicDataSource/sql/user.sql
@@ -0,0 +1,35 @@
+/*
+ Navicat Premium Data Transfer
+
+ Source Server : localhost
+ Source Server Type : MySQL
+ Source Server Version : 50719
+ Source Host : 127.0.0.1
+ Source Database : oldMan
+
+ Target Server Type : MySQL
+ Target Server Version : 50719
+ File Encoding : utf-8
+
+ Date: 04/02/2019 15:27:32 PM
+*/
+
+SET NAMES utf8;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for `user`
+-- ----------------------------
+DROP TABLE IF EXISTS `user`;
+CREATE TABLE `user` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` varchar(100) DEFAULT NULL,
+ `address` varchar(200) DEFAULT NULL,
+ `mobile` varchar(50) DEFAULT NULL,
+ `email` varchar(100) DEFAULT NULL,
+ `create_time` datetime DEFAULT NULL,
+ `role` int(11) NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;
+
+SET FOREIGN_KEY_CHECKS = 1;
diff --git a/springboot-dynamicDataSource/src/main/java/cn/abel/Application.java b/springboot-dynamicDataSource/src/main/java/cn/abel/Application.java
new file mode 100644
index 0000000..4c77f67
--- /dev/null
+++ b/springboot-dynamicDataSource/src/main/java/cn/abel/Application.java
@@ -0,0 +1,16 @@
+package cn.abel;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @author yyb
+ * @time 2019/3/26
+ */
+@SpringBootApplication
+public class Application {
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+
+}
diff --git a/springboot-dynamicDataSource/src/main/java/cn/abel/bean/News.java b/springboot-dynamicDataSource/src/main/java/cn/abel/bean/News.java
new file mode 100644
index 0000000..5462104
--- /dev/null
+++ b/springboot-dynamicDataSource/src/main/java/cn/abel/bean/News.java
@@ -0,0 +1,50 @@
+package cn.abel.bean;
+
+
+public class News {
+ private Integer id;
+ private String title;
+ private String content;
+ private String imagePath;
+ private Integer readSum;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ public String getImagePath() {
+ return imagePath;
+ }
+
+ public void setImagePath(String imagePath) {
+ this.imagePath = imagePath;
+ }
+
+ public Integer getReadSum() {
+ return readSum;
+ }
+
+ public void setReadSum(Integer readSum) {
+ this.readSum = readSum;
+ }
+}
\ No newline at end of file
diff --git a/springboot-dynamicDataSource/src/main/java/cn/abel/bean/User.java b/springboot-dynamicDataSource/src/main/java/cn/abel/bean/User.java
new file mode 100644
index 0000000..58acdf2
--- /dev/null
+++ b/springboot-dynamicDataSource/src/main/java/cn/abel/bean/User.java
@@ -0,0 +1,70 @@
+package cn.abel.bean;
+
+import java.util.Date;
+
+
+public class User {
+ private Integer id;
+ private String name;
+ private String address;
+ private String mobile;
+ private String email;
+ private Date createTime;
+ private Integer role;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public String getMobile() {
+ return mobile;
+ }
+
+ public void setMobile(String mobile) {
+ this.mobile = mobile;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public Date getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(Date createTime) {
+ this.createTime = createTime;
+ }
+
+ public Integer getRole() {
+ return role;
+ }
+
+ public void setRole(Integer role) {
+ this.role = role;
+ }
+}
\ No newline at end of file
diff --git a/springboot-dynamicDataSource/src/main/java/cn/abel/config/DynamicDataSource.java b/springboot-dynamicDataSource/src/main/java/cn/abel/config/DynamicDataSource.java
new file mode 100644
index 0000000..99e3af5
--- /dev/null
+++ b/springboot-dynamicDataSource/src/main/java/cn/abel/config/DynamicDataSource.java
@@ -0,0 +1,15 @@
+package cn.abel.config;
+
+import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
+
+/**
+ * @author yyb
+ * @time 2019/3/27
+ */
+public class DynamicDataSource extends AbstractRoutingDataSource {
+ @Override
+ protected Object determineCurrentLookupKey() {
+ return DynamicDataSourceContextHolder.getDatabaseType();
+ }
+}
+
diff --git a/springboot-dynamicDataSource/src/main/java/cn/abel/config/DynamicDataSourceConfig.java b/springboot-dynamicDataSource/src/main/java/cn/abel/config/DynamicDataSourceConfig.java
new file mode 100644
index 0000000..3cbc3cd
--- /dev/null
+++ b/springboot-dynamicDataSource/src/main/java/cn/abel/config/DynamicDataSourceConfig.java
@@ -0,0 +1,83 @@
+package cn.abel.config;
+
+import cn.abel.enums.DatabaseTypeEnum;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.SqlSessionFactoryBean;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+
+import javax.sql.DataSource;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author yyb
+ * @time 2019/3/27
+ */
+@Configuration
+@MapperScan(basePackages = "cn.abel.dao")
+public class DynamicDataSourceConfig {
+ @Value("${spring.datasource.primary.url}")
+ private String primaryUrl;
+ @Value("${spring.datasource.user.url}")
+ private String userUrl;
+ @Value("${mybatis.mapper-locations}")
+ private String resources;
+ //当两个数据库连接账号密码不一样时
+// @Value("${spring.datasource.user.username}")
+// private String userName;
+// @Value("${spring.datasource.user.password}")
+// private String password;
+
+ @Autowired
+ private HikariConfig hikariConfig;
+
+ @Primary
+ @Bean(name = "primaryDataSource")
+ public DataSource getPrimaryDataSource() {
+ return hikariConfig.getHikariDataSource(primaryUrl);
+ }
+
+ @Bean(name = "userDataSource")
+ public DataSource getUserDataSource() {
+ return hikariConfig.getHikariDataSource(userUrl);
+ }
+
+
+ //当两个数据库连接账号密码不一样时使用
+// @Bean(name = "userDataSource")
+// public DataSource getUserDataSource() {
+// return hikariConfig.getHikariDataSource(userUrl, userName, password);
+// }
+
+
+ @Bean("dynamicDataSource")
+ public DynamicDataSource dynamicDataSource(@Qualifier("primaryDataSource") DataSource primaryDataSource,
+ @Qualifier("userDataSource") DataSource userDataSource) {
+ Map