wrapper = new QueryWrapper<>();
+ wrapper.eq("username", username);
+ return getOne(wrapper);
+ }
+
+}
diff --git a/cooperop-app-base/src/main/java/business/cooperop/base/vo/CompanyVO.java b/cooperop-app-base/src/main/java/business/cooperop/base/vo/CompanyVO.java
new file mode 100644
index 0000000..daf11db
--- /dev/null
+++ b/cooperop-app-base/src/main/java/business/cooperop/base/vo/CompanyVO.java
@@ -0,0 +1,19 @@
+package business.cooperop.base.vo;
+
+
+import lombok.Data;
+
+/**
+ * @author china
+ */
+@Data
+public class CompanyVO {
+ private int limit;
+ private int start;
+ private String name;
+ private String businessLicense;
+ private String address;
+ private String mobile;
+ private String tel;
+ private String icpNo;
+}
diff --git a/cooperop-app-base/src/main/java/business/cooperop/base/vo/PopedomVo.java b/cooperop-app-base/src/main/java/business/cooperop/base/vo/PopedomVo.java
new file mode 100644
index 0000000..7ffcbf2
--- /dev/null
+++ b/cooperop-app-base/src/main/java/business/cooperop/base/vo/PopedomVo.java
@@ -0,0 +1,72 @@
+package business.cooperop.base.vo;
+
+import business.cooperop.base.entity.Application;
+import business.cooperop.base.entity.ApplicationPopedom;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 节点实体类, 用于接收传入参数
+ * @Author: deadline
+ * @Date: 2021-01-04 20:04
+ */
+@Data
+public class PopedomVo {
+ private String applicationCode;
+ private String id;
+ private String name;
+ private String parentId;
+ private Integer type;
+ private String url;
+ private String icon;
+ private Integer isMenu;
+ private Integer orderNo;
+ private String description;
+ private String path;
+ private String redirect;
+ private String component;
+ private String title;
+ private Boolean alwaysShow;
+ private Boolean hidden;
+
+ /**
+ * 将popedom vo转换为application po
+ * @return
+ */
+ public Application convertApplication() {
+ Application application = new Application();
+ application.setCode(this.applicationCode);
+ application.setName(this.name);
+ application.setType(this.type);
+ application.setDescription(this.description);
+ application.setDeployedTime(new Date());
+ application.setOrderNo(this.orderNo);
+ return application;
+ }
+
+ /**
+ * 将popedom vo转换为applicationPopedom po
+ * @return
+ */
+ public ApplicationPopedom convertApplicationPopedom() {
+ ApplicationPopedom applicationPopedom = new ApplicationPopedom();
+ applicationPopedom.setApplicationCode(this.applicationCode);
+ applicationPopedom.setId(this.id);
+ applicationPopedom.setName(this.name);
+ applicationPopedom.setParentId(this.parentId);
+ applicationPopedom.setUrl(this.url);
+ applicationPopedom.setIcon(this.icon);
+ applicationPopedom.setIsMenu(this.isMenu);
+ applicationPopedom.setOrderNo(this.orderNo);
+ applicationPopedom.setDescription(this.description);
+ applicationPopedom.setPath(this.path);
+ applicationPopedom.setRedirect(this.redirect);
+ applicationPopedom.setComponent(this.component);
+ applicationPopedom.setTitle(this.title);
+ applicationPopedom.setAlwaysShow(this.alwaysShow);
+ applicationPopedom.setHidden(this.hidden);
+ return applicationPopedom;
+ }
+
+}
diff --git a/cooperop-app-base/src/main/resources/application.yml b/cooperop-app-base/src/main/resources/application.yml
new file mode 100644
index 0000000..1c6acb3
--- /dev/null
+++ b/cooperop-app-base/src/main/resources/application.yml
@@ -0,0 +1,88 @@
+server:
+ port: 8088
+
+# QQ邮箱
+spring:
+ mail:
+ host: smtp.qq.com #发送邮件服务器
+ username: 943359729@qq.com #发送邮件的邮箱地址
+ password: gemhokyelabnbfdb #客户端授权码,不是邮箱密码,这个在qq邮箱设置里面自动生成的
+ properties.mail.smtp.port: 465 #端口号465或587
+ from: 943359729@qq.com # 发送邮件的地址,和上面username一致
+ properties.mail.smtp.starttls.enable: true
+ properties.mail.smtp.starttls.required: true
+ properties.mail.smtp.ssl.enable: true
+ default-encoding: utf-8
+# 网易邮箱
+#spring:
+# mail:
+# host: smtp.163.com #发送邮件服务器
+# username: imayfly1997@163.com #发送邮件的邮箱地址
+# password: GLMMWPUOLRFOWYBU #客户端授权码,不是邮箱密码,网易的是自己设置的
+# properties.mail.smtp.port: 994 #465或者994
+# from: imayfly1997@163.com # 发送邮件的地址,和上面username一致
+# properties.mail.smtp.starttls.enable: true
+# properties.mail.smtp.starttls.required: true
+# properties.mail.smtp.ssl.enable: true
+# default-encoding: utf-8
+
+ # 连接池
+ datasource:
+ # 填写你数据库的url、登录名、密码和数据库名
+ url: jdbc:mysql://chaoran.crtech.cn:3506/xin_cloudauth?useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=CTT&allowPublicKeyRetrieval=true
+ username: root
+ password: www.Crtech2018.cn
+ druid:
+ # 连接池的配置信息
+ # 初始化大小,最小,最大
+ initial-size: 5
+ min-idle: 5
+ maxActive: 20
+ # 配置获取连接等待超时的时间
+ maxWait: 60000
+ # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+ timeBetweenEvictionRunsMillis: 60000
+ # 配置一个连接在池中最小生存的时间,单位是毫秒
+ minEvictableIdleTimeMillis: 300000
+ validationQuery: SELECT 1
+ testWhileIdle: true
+ testOnBorrow: false
+ testOnReturn: false
+ # 打开PSCache,并且指定每个连接上PSCache的大小
+ poolPreparedStatements: true
+ maxPoolPreparedStatementPerConnectionSize: 20
+ # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
+ filters: stat,wall,slf4j
+ # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
+ connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
+ # 配置DruidStatFilter
+ web-stat-filter:
+ enabled: true
+ url-pattern: "/*"
+ exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*"
+ # 配置DruidStatViewServlet
+ stat-view-servlet:
+ enabled: true
+ url-pattern: "/druid/*"
+ # IP白名单(没有配置或者为空,则允许所有访问)
+ allow: 127.0.0.1
+ # IP黑名单 (存在共同时,deny优先于allow)
+ deny: all
+ # 禁用HTML页面上的“Reset All”功能
+ reset-enable: false
+ # 登录名
+ login-username: crtech
+ # 登录密码
+ login-password: Crtech@2020
+ driver-class-name: com.mysql.cj.jdbc.Driver
+
+# pagehelper
+#pagehelper:
+# helperDialect: mysql
+# reasonable: true
+# supportMethodsArguments: true
+# params: count=countSql
+
+logging:
+ level:
+ bussiness.cooperop.base.mapper: debug
diff --git a/cooperop-app-base/src/main/resources/bootstrap.yml b/cooperop-app-base/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..cb74b59
--- /dev/null
+++ b/cooperop-app-base/src/main/resources/bootstrap.yml
@@ -0,0 +1,10 @@
+spring:
+ application:
+ name: app-base
+ cloud:
+ nacos:
+ discovery:
+ server-addr: ${REGISTER_HOST:localhost}:${REGISTER_PORT:8848}
+ config:
+ server-addr: ${REGISTER_HOST:localhost}:${REGISTER_PORT:8848}
+ file-extension: yml
diff --git a/cooperop-app-base/src/main/resources/logback-spring.xml b/cooperop-app-base/src/main/resources/logback-spring.xml
new file mode 100644
index 0000000..c453993
--- /dev/null
+++ b/cooperop-app-base/src/main/resources/logback-spring.xml
@@ -0,0 +1,51 @@
+
+
+ logback-spring
+
+
+
+
+
+
+
+
+
+ ${pattern}
+
+
+
+
+
+
+ ${pattern-color}
+
+
+
+
+
+
+ ${LOG_HOME}/all.%d.%i.log
+
+
+ 10MB
+
+
+ 1
+
+
+
+ ${pattern}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cooperop-app-base/src/main/resources/mybatis-generator/generatorConfig.xml b/cooperop-app-base/src/main/resources/mybatis-generator/generatorConfig.xml
new file mode 100644
index 0000000..39d6fff
--- /dev/null
+++ b/cooperop-app-base/src/main/resources/mybatis-generator/generatorConfig.xml
@@ -0,0 +1,116 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cooperop-app-base/src/test/java/business/cooperop/base/AuthTests.java b/cooperop-app-base/src/test/java/business/cooperop/base/AuthTests.java
new file mode 100644
index 0000000..52cf789
--- /dev/null
+++ b/cooperop-app-base/src/test/java/business/cooperop/base/AuthTests.java
@@ -0,0 +1,31 @@
+package business.cooperop.base;
+
+import business.cooperop.base.controller.ApplicationController;
+import business.cooperop.base.service.IUserService;
+import business.cooperop.common.result.Result;
+import com.alibaba.fastjson.JSONArray;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * @Author: deadline
+ * @Date: 2020-12-29 17:00
+ */
+@SpringBootTest
+public class AuthTests {
+
+ @Autowired
+ ApplicationController authController;
+
+ @Autowired
+ IUserService iUserService;
+
+ @Test
+ public void getTreeTest() {
+ Result result = authController.getTree();
+ String json = JSONArray.toJSONString(result);
+ System.out.println(json);
+ }
+
+}
diff --git a/cooperop-app-base/src/test/java/business/cooperop/base/CooperopAppBaseApplicationTests.java b/cooperop-app-base/src/test/java/business/cooperop/base/CooperopAppBaseApplicationTests.java
new file mode 100644
index 0000000..53b7994
--- /dev/null
+++ b/cooperop-app-base/src/test/java/business/cooperop/base/CooperopAppBaseApplicationTests.java
@@ -0,0 +1,59 @@
+package business.cooperop.base;
+
+//import business.cooperop.base.entity.Message;
+import business.cooperop.base.message.InternalMessage;
+import business.cooperop.base.message.InternalMessageImpl;
+import business.cooperop.base.message.email.service.EmailService;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.lang.reflect.Array;
+import java.util.*;
+
+//@RunWith(SpringRunner.class)
+@SpringBootTest
+class CooperopAppBaseApplicationTests {
+
+ @Autowired
+ private EmailService emailService;
+ @Autowired
+ private InternalMessage InternalMessage;
+
+ private static String to = "943359729@qq.com";
+
+ @Test
+ public void sendSimpleEmail(){
+ String content = "你好,恭喜你...";
+ emailService.sendSimpleMail(new String[]{to},"祝福邮件",content);
+ }
+
+ @Test
+ public void sendMimeEmail(){
+ String content = "你好,欢迎注册网站,请点击链接激活";
+ emailService.sendHtmlMail(new String[]{to},"激活邮件",content);
+ }
+
+ @Test
+ public void sendAttachment(){
+ emailService.sendAttachmentsMail(new String[]{to},"关于java体系图","你好, 这是Java体系图","G:\\测试图片\\01.jpg", "G:\\测试图片\\02.jpg");
+ }
+ @Test
+ public void sendInternalMessage(){
+ /*Message message = new Message();
+ message.setTitle("系统通知");
+ message.setType("T");
+ message.setTarget("A");
+ message.setContent("系统通知");
+ message.setState(1);
+ message.setCreate_time(new Date());
+ message.setCreate_user("admin");
+ message.setStart_time(new Date());
+ Calendar curr = Calendar.getInstance();
+ curr.set(Calendar.MONTH,curr.get(Calendar.MONTH)+1); //增加一月
+ Date date=curr.getTime();
+ message.setEnd_time(date);
+ InternalMessage.settingInternalMessage(message);*/
+ }
+
+}
diff --git a/cooperop-app-common/pom.xml b/cooperop-app-common/pom.xml
new file mode 100644
index 0000000..ddaf91d
--- /dev/null
+++ b/cooperop-app-common/pom.xml
@@ -0,0 +1,27 @@
+
+
+ 4.0.0
+
+
+ business.chaoran
+ cooperop-app
+ 1.0-SNAPSHOT
+
+
+ business.chaoran
+ cooperop-app-common
+ 1.0-SNAPSHOT
+
+
+
+
+
+ com.esotericsoftware
+ reflectasm
+
+
+
+
+
diff --git a/cooperop-app-common/src/main/java/business/cooperop/common/constant/Base.java b/cooperop-app-common/src/main/java/business/cooperop/common/constant/Base.java
new file mode 100644
index 0000000..e50679d
--- /dev/null
+++ b/cooperop-app-common/src/main/java/business/cooperop/common/constant/Base.java
@@ -0,0 +1,17 @@
+package business.cooperop.common.constant;
+
+/**
+ * 系统基础常量
+ *
+ * @author FXY
+ *
+ * 2018年1月23日
+ */
+public class Base {
+
+ public static final String ROLE_ADMIN = "admin";
+
+ public static final String CURRENT_USER = "current_user";
+
+ public static final String CURRENT_COMPANY = "current_company";
+}
diff --git a/cooperop-app-common/src/main/java/business/cooperop/common/constant/ResultCode.java b/cooperop-app-common/src/main/java/business/cooperop/common/constant/ResultCode.java
new file mode 100644
index 0000000..8a0f8af
--- /dev/null
+++ b/cooperop-app-common/src/main/java/business/cooperop/common/constant/ResultCode.java
@@ -0,0 +1,106 @@
+package business.cooperop.common.constant;
+
+/**
+ * api接口返回 code和message
+ *
+ * @author FXY
+ *
+ * 2018年1月23日
+ */
+public enum ResultCode {
+
+ /* 成功状态码 */
+ SUCCESS(0, "成功"),
+ ERROR(1, "失败"),
+
+ /* 参数错误:10001-19999 */
+ PARAM_IS_INVALID(10001, "参数无效"),
+ PARAM_IS_BLANK(10002, "参数为空"),
+ PARAM_TYPE_BIND_ERROR(10003, "参数类型错误"),
+ PARAM_NOT_COMPLETE(10004, "参数缺失"),
+
+
+ /* 用户错误:20001-29999*/
+ USER_NOT_LOGGED_IN(20001, "用户未登录"),
+ USER_LOGIN_ERROR(20002, "账号或密码错误"),
+ USER_ACCOUNT_FORBIDDEN(20003, "账号已被禁用"),
+ USER_NOT_EXIST(20004, "用户不存在"),
+ USER_HAS_EXISTED(20005, "用户已存在"),
+ USER_Register_ERROR(20006, "用户注册错误"),
+
+ /* 业务错误:30001-39999 */
+ SPECIFIED_QUESTIONED_USER_NOT_EXIST(30001, "某业务出现问题"),
+ //菜单
+ MENU_ROOT_ELEMENT_NUM_MAX(30002, "一级菜单数量达到最大"),
+ MENU_TERMINAL_ELEMENT_NUM_MAX(30003, "二级菜单数量达到最大"),
+ MENU_LEVEL_PROMOTION(30004, "微信规定:一级菜单最多3个,二级菜单最多7个。最高二级层次菜单"),
+ MENU_ROOT_ELEMENT_CLOSED(30005, "对应的一级菜单未打开"),
+ //模板消息
+ TEMPLATE_MESSAGE_ACTIVE_NUM_MAX(30006, "模板消息激活数量已达最大"),
+
+ /* 系统错误:40001-49999 */
+ SYSTEM_INNER_ERROR(40001, "系统繁忙,请稍后重试"),
+
+ /* 数据错误:50001-599999 */
+ RESULE_DATA_NONE(50001, "数据未找到"),
+ DATA_IS_WRONG(50002, "数据有误"),
+ DATA_ALREADY_EXISTED(50003, "数据已存在"),
+
+ /* 接口错误:60001-69999 */
+ INTERFACE_INNER_INVOKE_ERROR(60001, "内部系统接口调用异常"),
+ INTERFACE_OUTTER_INVOKE_ERROR(60002, "外部系统接口调用异常"),
+ INTERFACE_FORBID_VISIT(60003, "该接口禁止访问"),
+ INTERFACE_ADDRESS_INVALID(60004, "接口地址无效"),
+ INTERFACE_REQUEST_TIMEOUT(60005, "接口请求超时"),
+ INTERFACE_EXCEED_LOAD(60006, "接口负载过高"),
+
+ /* 权限错误:70001-79999 */
+ PERMISSION_NO_ACCESS(70001, "无访问权限"),
+
+ /* 文件上传 */
+ UPLOAD_ERROR(80001, "上传失败"),
+
+ SESSION_TIME_OUT(90001, "Session超时");
+
+
+ private Integer code;
+
+ private String message;
+
+ ResultCode(Integer code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ public Integer code() {
+ return this.code;
+ }
+
+ public String message() {
+ return this.message;
+ }
+
+ public static String getMessage(String name) {
+ for (ResultCode item : ResultCode.values()) {
+ if (item.name().equals(name)) {
+ return item.message;
+ }
+ }
+ return name;
+ }
+
+ public static Integer getCode(String name) {
+ for (ResultCode item : ResultCode.values()) {
+ if (item.name().equals(name)) {
+ return item.code;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return this.name();
+ }
+
+}
diff --git a/cooperop-app-common/src/main/java/business/cooperop/common/exception/BaseException.java b/cooperop-app-common/src/main/java/business/cooperop/common/exception/BaseException.java
new file mode 100644
index 0000000..bee1230
--- /dev/null
+++ b/cooperop-app-common/src/main/java/business/cooperop/common/exception/BaseException.java
@@ -0,0 +1,45 @@
+package business.cooperop.common.exception;
+
+import business.cooperop.common.constant.ResultCode;
+
+/**
+ * 自定义异常
+ *
+ * @author FXY
+ *
+ * 2018年1月23日
+ */
+public abstract class BaseException extends RuntimeException {
+
+ private static final long serialVersionUID = 3506744187536228284L;
+
+ private Integer errCode;
+ private String errMsg;
+
+ public Integer getErrCode() {
+ return errCode;
+ }
+
+ public void setErrCode(Integer errCode) {
+ this.errCode = errCode;
+ }
+
+ public String getErrMsg() {
+ return errMsg;
+ }
+
+ public void setErrMsg(String errMsg) {
+ this.errMsg = errMsg;
+ }
+
+ public BaseException(Integer errCode, String errMsg) {
+ this.errCode = errCode;
+ this.errMsg = errMsg;
+ }
+
+ public BaseException(ResultCode resultCode){
+ this.errCode=resultCode.code();
+ this.errMsg=resultCode.message();
+ }
+
+}
diff --git a/cooperop-app-common/src/main/java/business/cooperop/common/exception/DefaultException.java b/cooperop-app-common/src/main/java/business/cooperop/common/exception/DefaultException.java
new file mode 100644
index 0000000..36e478b
--- /dev/null
+++ b/cooperop-app-common/src/main/java/business/cooperop/common/exception/DefaultException.java
@@ -0,0 +1,27 @@
+package business.cooperop.common.exception;
+
+/*
+ **********************************************
+ * DATE PERSON REASON
+ * 2020/10/23 FXY Created
+ **********************************************
+ */
+
+
+import business.cooperop.common.constant.ResultCode;
+
+/**
+ * 默认异常实现
+ */
+public class DefaultException extends BaseException {
+
+
+ public DefaultException(Integer errCode, String errMsg) {
+ super(errCode, errMsg);
+ }
+
+ //根据枚举建立异常
+ public static DefaultException simple(ResultCode resultCode) {
+ return new DefaultException(resultCode.code(), resultCode.message());
+ }
+}
diff --git a/cooperop-app-common/src/main/java/business/cooperop/common/result/ParameterInvalidItem.java b/cooperop-app-common/src/main/java/business/cooperop/common/result/ParameterInvalidItem.java
new file mode 100644
index 0000000..22245bb
--- /dev/null
+++ b/cooperop-app-common/src/main/java/business/cooperop/common/result/ParameterInvalidItem.java
@@ -0,0 +1,32 @@
+package business.cooperop.common.result;
+
+/**
+ * Controller参数校验 错误返回封装
+ *
+ * @author FXY
+ *
+ * 2018年1月23日
+ */
+public class ParameterInvalidItem {
+
+ private String fieldName;
+
+ private String message;
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ public void setFieldName(String fieldName) {
+ this.fieldName = fieldName;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+}
diff --git a/cooperop-app-common/src/main/java/business/cooperop/common/result/Result.java b/cooperop-app-common/src/main/java/business/cooperop/common/result/Result.java
new file mode 100644
index 0000000..3e23564
--- /dev/null
+++ b/cooperop-app-common/src/main/java/business/cooperop/common/result/Result.java
@@ -0,0 +1,114 @@
+package business.cooperop.common.result;
+
+
+
+import business.cooperop.common.constant.ResultCode;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * api接口数据返回封装
+ *
+ * @author FXY
+ *
+ * 2018年1月23日
+ */
+public class Result implements Serializable {
+
+ private static final long serialVersionUID = -4762928619495260423L;
+
+ private Integer code;
+
+ private String msg;
+
+ private Object data;
+
+ public Result() {
+ }
+
+ public Result(Integer code, String msg) {
+ this.code = code;
+ this.msg = msg;
+ }
+
+ public static Result success() {
+ Result result = new Result();
+ result.setResultCode(ResultCode.SUCCESS);
+ return result;
+ }
+
+ public static Result success(Object data) {
+ Result result = new Result();
+ result.setResultCode(ResultCode.SUCCESS);
+ result.setData(data);
+ return result;
+ }
+
+ public static Result failed() {
+ Result result = new Result();
+ result.setResultCode(ResultCode.SYSTEM_INNER_ERROR);
+ return result;
+ }
+
+ // 带消息的失败返回结果
+ public static Result failed(String msg) {
+ Result result = new Result();
+ result.setResultCode(ResultCode.SYSTEM_INNER_ERROR);
+ result.setMsg(msg);
+ return result;
+ }
+
+ public static Result error(ResultCode resultCode) {
+ Result result = new Result();
+ result.setResultCode(resultCode);
+ return result;
+ }
+
+ public static Result error(ResultCode resultCode, Object data) {
+ Result result = new Result();
+ result.setResultCode(resultCode);
+ result.setData(data);
+ return result;
+ }
+
+ public void setResultCode(ResultCode code) {
+ this.code = code.code();
+ this.msg = code.message();
+ }
+
+
+ public Map simple() {
+ Map simple = new HashMap();
+ this.data = simple;
+
+ return simple;
+ }
+
+ public Integer getCode() {
+ return code;
+ }
+
+ public void setCode(Integer code) {
+ this.code = code;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+
+ public void setMsg(String msg) {
+ this.msg = msg;
+ }
+
+ public Object getData() {
+ return data;
+ }
+
+ public void setData(Object data) {
+ this.data = data;
+ }
+
+
+}
diff --git a/cooperop-app-common/src/main/java/business/cooperop/common/utils/BeanUtilsV2.java b/cooperop-app-common/src/main/java/business/cooperop/common/utils/BeanUtilsV2.java
new file mode 100644
index 0000000..9c06b74
--- /dev/null
+++ b/cooperop-app-common/src/main/java/business/cooperop/common/utils/BeanUtilsV2.java
@@ -0,0 +1,258 @@
+package business.cooperop.common.utils;
+
+/*
+ **********************************************
+ * DATE PERSON REASON
+ * 2020/9/4 FXY Created
+ **********************************************
+ */
+
+
+import com.esotericsoftware.reflectasm.MethodAccess;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+
+/**
+ * 待重写
+ */
+
+public class BeanUtilsV2 {
+
+ /**
+ * 通过 ASM反射 速度比 Spring BeanUtils.copyProperties(source,target) 快一倍
+ * 类型不同可以转换
+ * 大小写可以忽略
+ * 下划线 _ 被忽略
+ * fxy备注:需要操纵字节码,服务器没有性能瓶颈的情况下慎用!
+ *
+ * @param source 数据源
+ * @param target 目标是数据
+ * @param
+ * @return
+ */
+ public static T copyPropertiesASM(Object source, Object target) {
+ MethodAccess sourceMethodAccess = CacheMethodAccess.getMethodAccess(source.getClass());
+ MethodAccess targetMethodAccess = CacheMethodAccess.getMethodAccess(target.getClass());
+ Map sourceGet = CacheAsmFiledMethod.getMethod("get", source.getClass());
+ Map targetSet = CacheAsmFiledMethod.getMethod("set", target.getClass());
+ CacheFieldMap.getFieldMap(target.getClass()).keySet().forEach((it) -> {
+ String sourceIndex = sourceGet.get(it);
+ if (sourceIndex != null) {
+ Object value = sourceMethodAccess.invoke(source, sourceIndex);
+ String setIndex = targetSet.get(it);
+ targetMethodAccess.invoke(target, setIndex, value);
+ }
+ });
+ return (T) target;
+ }
+
+ /**
+ * 模仿Spring中 BeanUtils.copyProperties(source,target)
+ * 目前仅支持整形到布尔类型的单向转换
+ * 但是
+ * 大小写可以忽略
+ * 下划线 _ 被忽略
+ *
+ * @param source
+ * @param target
+ * @param
+ * @return
+ */
+ public static T copyProperties(Object source, Object target) {
+ Map sourceMap = CacheFieldMap.getFieldMap(source.getClass());
+ CacheFieldMap.getFieldMap(target.getClass()).values().forEach((it) -> {
+ Field field = sourceMap.get(it.getName().toLowerCase().replace("_", ""));
+ if (field != null) {
+ it.setAccessible(true);
+ field.setAccessible(true);
+ try {
+ if (field.getType() == Integer.class && it.getType() == Boolean.class) {
+ it.set(target, (Integer) field.get(source) == 1 ? true : false);
+ } else {
+ it.set(target, field.get(source));
+ }
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } finally {
+
+ //及时关闭访问权限
+ field.setAccessible(false);
+ it.setAccessible(false);
+ }
+ }
+ });
+ return (T) target;
+ }
+
+ /**
+ * @param source 源对象
+ * @param target 目标对象
+ * @param ignores 需要忽略的字段数组元素
+ * @param 返回赋了值的目标对象
+ * 目前不同类型之间的转换,仅支持整形向布尔类型的单向转换
+ * @return
+ */
+ public static T copyProperties(Object source, Object target, String... ignores) {
+ Map sourceMap = CacheFieldMap.getFieldMap(source.getClass(), ignores);
+ CacheFieldMap.getFieldMap(target.getClass()).values().forEach((it) -> {
+ Field field = sourceMap.get(it.getName().toLowerCase().replace("_", ""));
+ if (field != null) {
+ it.setAccessible(true);
+ field.setAccessible(true);
+ try {
+ if (field.getType() == Integer.class && it.getType() == Boolean.class) {
+ it.set(target, (Integer) field.get(source) == 1 ? true : false);
+ } else {
+ it.set(target, field.get(source));
+ }
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } finally {
+ field.setAccessible(false);
+ it.setAccessible(false);
+ }
+ }
+ });
+ return (T) target;
+ }
+
+
+ /**
+ * Asm方式缓存变量域到map中,待优化
+ * 可以将加锁操作换做无阻塞的并发容器
+ */
+ private static class CacheAsmFiledMethod {
+ private static Map> cacheGetMethod = new HashMap<>();
+ private static Map> cacheSetMethod = new HashMap<>();
+
+ private static Map getMethod(String type, Class clazz) {
+ MethodAccess methodAccess = CacheMethodAccess.getMethodAccess(clazz);
+ Map allFields = CacheFieldMap.getFieldMap(clazz);
+ Map result = null;
+ if (type.equals("get")) {
+ result = cacheGetMethod.get(clazz.getName());
+ } else if (type.equals("set")) {
+ result = cacheSetMethod.get(clazz.getName());
+ }
+ if (result == null) {
+ synchronized (CacheAsmFiledMethod.class) {
+ if (result == null) {
+ Map set = new HashMap<>();
+ Map get = new HashMap<>();
+ allFields.values().forEach((it) -> {
+ //判断是否是静态
+ if (!Modifier.isStatic(it.getModifiers())) {
+ //首字母大写
+ char[] f = it.getName().toCharArray();
+ f[0] -= 32;
+ String fieldName = new String(f);
+ get.put(fieldName.toLowerCase().replace("_", ""), "get" + fieldName);
+ set.put(fieldName.toLowerCase().replace("_", ""), "set" + fieldName);
+ }
+ });
+ cacheGetMethod.put(clazz.getName(), get);
+ cacheSetMethod.put(clazz.getName(), set);
+ if (type.equals("get")) {
+ result = cacheGetMethod.get(clazz.getName());
+ } else if (type.equals("set")) {
+ result = cacheSetMethod.get(clazz.getName());
+ }
+ }
+ }
+ }
+ return result;
+ }
+ }
+
+ /**
+ * 缓存方法访问权限容器,加锁操作待优化
+ */
+ private static class CacheMethodAccess {
+
+ private CacheMethodAccess() {
+ }
+
+ private static Map cache = new HashMap<>();
+
+ private static MethodAccess getMethodAccess(Class clazz) {
+ MethodAccess result = cache.get(clazz.getName());
+ if (result == null) {
+ synchronized (CacheMethodAccess.class) {
+ if (result == null) {
+ cache.put(clazz.getName(), MethodAccess.get(clazz));
+ result = cache.get(clazz.getName());
+ }
+ }
+ }
+ return result;
+ }
+ }
+
+ /**
+ * 缓存所有域到map中,加锁操作待优化
+ */
+ private static class CacheFieldMap {
+ private static Map> cacheMap = new HashMap<>();
+
+ private static Map getFieldMap(Class clazz) {
+ Map result = cacheMap.get(clazz.getName());
+ if (result == null) {
+ synchronized (CacheFieldMap.class) {
+ if (result == null) {
+ List allFields = getAllFields(clazz);
+ Map fieldMap = allFields.stream().collect(Collectors.toMap(field -> field.getName().toLowerCase().replace("_", ""), Function.identity()));
+ cacheMap.put(clazz.getName(), fieldMap);
+ result = cacheMap.get(clazz.getName());
+ }
+ }
+ }
+ return result;
+ }
+
+
+ /**
+ * 每次反射完成后将数据存放在内存中
+ *
+ * @param clazz
+ * @param ignores
+ * @return
+ */
+ private static Map getFieldMap(Class clazz, String... ignores) {
+ Map result = cacheMap.get(clazz.getName());
+ List list = Arrays.asList(ignores);
+ if (result == null) {
+ synchronized (CacheFieldMap.class) {
+ if (result == null) {
+ List allFields = getAllFields(clazz);
+ Map fieldMap = allFields.stream().filter(a -> !(list.contains(a.getName()))).collect(Collectors.toMap(field -> field.getName().toLowerCase().replace("_", ""), Function.identity()));
+ cacheMap.put(clazz.getName(), fieldMap);
+ result = cacheMap.get(clazz.getName());
+ }
+ }
+ }
+ return result;
+ }
+
+ }
+
+ /**
+ * 得到包括继承而来的所有域
+ *
+ * @param clazz
+ * @return
+ */
+ private static List getAllFields(Class clazz) {
+ List fieldList = new ArrayList<>();
+ while (clazz != null && !clazz.getName().toLowerCase().equals("java.lang.object")) {
+ fieldList.addAll(Arrays.asList(clazz.getDeclaredFields()));
+ clazz = clazz.getSuperclass();
+ }
+ return fieldList;
+ }
+
+}
diff --git a/cooperop-app-ioc/pom.xml b/cooperop-app-ioc/pom.xml
new file mode 100644
index 0000000..454852c
--- /dev/null
+++ b/cooperop-app-ioc/pom.xml
@@ -0,0 +1,101 @@
+
+
+ 4.0.0
+
+
+ cooperop-app
+ business.chaoran
+ 1.0-SNAPSHOT
+
+
+ business.chaoran
+ cooperop-app-ioc
+ 1.0-SNAPSHOT
+
+
+
+
+
+ com.alibaba
+ fastjson
+ ${fastjson.version}
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+ business.chaoran
+ cooperop-app-common
+
+
+
+ business.chaoran
+ cooperop-base-cache
+
+
+
+
+
+
+ internal
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-logging
+
+
+
+
+
+
+ true
+
+
+
+ external
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-tomcat
+
+
+ org.springframework.boot
+ spring-boot-starter-logging
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.1.0
+
+
+
+
+
+
diff --git a/cooperop-app-ioc/src/main/java/business/cooperop/ioc/config/BeanFactory.java b/cooperop-app-ioc/src/main/java/business/cooperop/ioc/config/BeanFactory.java
new file mode 100644
index 0000000..572cbb1
--- /dev/null
+++ b/cooperop-app-ioc/src/main/java/business/cooperop/ioc/config/BeanFactory.java
@@ -0,0 +1,76 @@
+package business.cooperop.ioc.config;
+
+/*
+ **********************************************
+ * DATE PERSON REASON
+ * 2020/9/14 FXY Created
+ **********************************************
+ */
+
+
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.alibaba.fastjson.support.config.FastJsonConfig;
+import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
+import com.alibaba.fastjson.support.spring.FastJsonViewResponseBodyAdvice;
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.MediaType;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Configuration
+public class BeanFactory {
+
+ @Bean
+ public RestTemplate generateTemplate() {
+ return new RestTemplate();
+ }
+
+
+ //json过滤配置
+
+ /**
+ * @see com.fasterxml.jackson.annotation.JsonView
+ * @return
+ */
+ @Bean
+ public FastJsonViewResponseBodyAdvice FastJsonViewResponseBodyAdvice() {
+ FastJsonViewResponseBodyAdvice advice = new FastJsonViewResponseBodyAdvice();
+ return advice;
+ }
+
+ //springboot webmvc自动注入converters
+
+ /**
+ * @see com.fasterxml.jackson.annotation.JsonView
+ * @return
+ */
+ @Bean
+ public HttpMessageConverters configureMessageConverters() {
+ FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
+
+ FastJsonConfig fastJsonConfig = new FastJsonConfig();
+
+ fastJsonConfig.setSerializerFeatures(
+ SerializerFeature.PrettyFormat, SerializerFeature.WriteNullStringAsEmpty,
+ SerializerFeature.DisableCircularReferenceDetect
+ );
+
+
+ List fastMediaTypes = new ArrayList<>();
+ fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
+
+ fastConverter.setFastJsonConfig(fastJsonConfig);
+ fastConverter.setSupportedMediaTypes(fastMediaTypes);
+
+ return new HttpMessageConverters(fastConverter);
+ }
+
+
+}
+
+
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..6ad259b
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,146 @@
+
+
+ 4.0.0
+ pom
+
+
+
+ business.chaoran
+ cooperop-demo-base
+ 1.0-SNAPSHOT
+
+
+ business.chaoran
+ cooperop-app
+ 1.0-SNAPSHOT
+
+
+ cooperop-app-common
+ cooperop-app-ioc
+ cooperop-app-base
+
+
+
+ 1.0-SNAPSHOT
+ 1.0-SNAPSHOT
+ 1.0-SNAPSHOT
+ Hoxton.SR8
+ 2.2.3.RELEASE
+ 3.4.0
+ 1.3.0
+ 1.2.4
+ 1.11.7
+ 2.8.6
+ 1.2.73
+ 1.4.0
+ 3.0.0
+ UTF-8
+ UTF-8
+ 1.8
+ 1.8
+ 0.0.1-SNAPSHOT
+
+
+
+
+
+
+
+ business.chaoran
+ web
+ ${xin.cloud}
+
+
+
+
+ business.chaoran
+ cooperop-app-common
+ ${app-common.version}
+
+
+
+
+ business.chaoran
+ cooperop-base-cache
+ ${base-cache.version}
+
+
+
+
+ business.chaoran
+ cooperop-base-message
+ ${base-message.version}
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-alibaba-dependencies
+ ${spring-cloud-alibaba.version}
+ pom
+ import
+
+
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ ${mybatis-plus.version}
+
+
+
+
+ com.github.pagehelper
+ pagehelper-spring-boot-starter
+ ${pagehelper.version}
+
+
+
+
+ com.alibaba
+ druid-spring-boot-starter
+ ${druid.version}
+
+
+
+
+ com.esotericsoftware
+ reflectasm
+ ${asm.version}
+
+
+
+
+ com.google.code.gson
+ gson
+ ${gson.version}
+
+
+
+
+ com.alibaba
+ fastjson
+ ${fastjson.version}
+
+
+
+
+ io.springfox
+ springfox-boot-starter
+ ${swagger.version}
+
+
+
+
+