commit 77a809eb3f41892e67a53d62fae48a71425fb04d Author: 刘力 Date: Fri Jan 14 17:21:37 2022 +0800 提交公共模块代码 diff --git a/admin/pom.xml b/admin/pom.xml new file mode 100644 index 0000000..33df279 --- /dev/null +++ b/admin/pom.xml @@ -0,0 +1,103 @@ + + + + yxk_canvasScreen + com.canvas.web + 1.0-SNAPSHOT + + 4.0.0 + + admin + 启动入口 + + + 17 + 17 + + + + + + + + com.canvas.web + system + 1.0-SNAPSHOT + + + + com.canvas.web + generator + 1.0-SNAPSHOT + + + + com.canvas.web + quartz + 1.0-SNAPSHOT + + + + com.canvas.web + queue + 1.0-SNAPSHOT + + + + + + org.projectlombok + lombok + true + + + + org.springframework.amqp + spring-rabbit-test + test + + + + com.alibaba + druid-spring-boot-starter + 1.2.8 + + + + log4j + log4j + 1.2.17 + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.1.11.RELEASE + + JavaWeb_Vue + + + + + repackage + + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/admin/src/main/java/com/canvas/web/AdminApplication.java b/admin/src/main/java/com/canvas/web/AdminApplication.java new file mode 100644 index 0000000..65cfe35 --- /dev/null +++ b/admin/src/main/java/com/canvas/web/AdminApplication.java @@ -0,0 +1,18 @@ +package com.canvas.web; + + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@SpringBootApplication(scanBasePackages = {"com.canvas.*"}) +@EnableTransactionManagement +@EnableScheduling +public class AdminApplication { + + public static void main(String[] args){ + SpringApplication.run(AdminApplication.class,args); + System.out.println("多媒体后台管理系统启动成功!"); + } +} diff --git a/admin/src/main/java/com/canvas/web/controller/TestController.java b/admin/src/main/java/com/canvas/web/controller/TestController.java new file mode 100644 index 0000000..575496b --- /dev/null +++ b/admin/src/main/java/com/canvas/web/controller/TestController.java @@ -0,0 +1,11 @@ +package com.canvas.web.controller; + + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +//业务测试接口 +@RestController +@RequestMapping("/test") +public class TestController { +} diff --git a/admin/src/main/resources/application-dev.yml b/admin/src/main/resources/application-dev.yml new file mode 100644 index 0000000..1b6584d --- /dev/null +++ b/admin/src/main/resources/application-dev.yml @@ -0,0 +1,126 @@ +#自定义配置 +canvasweb: + image-url: https://images.canvase.com/ + app-debug: true + + + +spring: + # 配置数据源 + datasource: + # 使用阿里的Druid连接池 + druid: + db-type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy + url: jdbc:mysql://192.168.99.207:3306/javaweb.vue?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false + username: root + password: ftzn83560792 + + + # 连接池的配置信息 + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 5 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + # 打开PSCache,并且指定每个连接上PSCache的大小 + poolPreparedStatements: true + maxPoolPreparedStatementPerConnectionSize: 20 + # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙 + filters: stat,wall,log4j + # 通过connectProperties属性来打开mergeSql功能;慢SQL记录 + connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 + # 配置DruidStatFilter + webStatFilter: + enabled: true + url-pattern: "/*" + exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*" + # 配置DruidStatViewServlet + statViewServlet: + url-pattern: "/druid/*" + # IP白名单(没有配置或者为空,则允许所有访问) + allow: 127.0.0.1,192.168.163.1 + # IP黑名单 (存在共同时,deny优先于allow) + deny: 192.168.1.73 + # 禁用HTML页面上的“Reset All”功能 + reset-enable: false + # 登录名 + login-username: admin + # 登录密码 + login-password: 123456 + + # Redis数据源 + redis: + # 缓存库默认索引0 + database: 0 + # Redis服务器地址 + host: 127.0.0.1 + # Redis服务器连接端口 + port: 6379 + # Redis服务器连接密码(默认为空) + password: + # 连接超时时间(毫秒) + timeout: 6000 + # 默认的数据过期时间,主要用于shiro权限管理 + expire: 2592000 + jedis: + pool: + max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) + max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制) + max-idle: 10 # 连接池中的最大空闲连接 + min-idle: 1 # 连接池中的最小空闲连接 + +file: + #上传的服务器上的映射文件夹 + accessPath: /uploads/ + #静态资源对外暴露的访问路径 + staticAccessPath: /** + #静态资源实际存储路径 + uploadFolder: E:\JavaWeb_Vue\JavaWeb\uploads\ + + +# Shiro +shiro: + cipher-key: f/SX5TIve5WWzT4aQlABJA== + cookie-name: shiro-cookie2 + user: + # 登录地址 + loginUrl: /login + # 权限认证失败地址 + unauthorizedUrl: /unauth + # 首页地址 + indexUrl: /index + # 验证码开关 + captchaEnabled: true + # 验证码类型 math 数组计算 char 字符 + captchaType: math + cookie: + # 设置Cookie的域名 默认空,即当前访问的域名 + domain: + # 设置cookie的有效访问路径 + path: / + # 设置HttpOnly属性 + httpOnly: true + # 设置Cookie的过期时间,天为单位 + maxAge: 30 + session: + # Session超时时间(默认30分钟) + expireTime: 300 + # 同步session到数据库的周期(默认1分钟) + dbSyncPeriod: 1 + # 相隔多久检查一次session的有效性,默认就是10分钟 + validationInterval: 10 \ No newline at end of file diff --git a/admin/src/main/resources/application-prod.yml b/admin/src/main/resources/application-prod.yml new file mode 100644 index 0000000..e69de29 diff --git a/admin/src/main/resources/application.yml b/admin/src/main/resources/application.yml new file mode 100644 index 0000000..6c6f659 --- /dev/null +++ b/admin/src/main/resources/application.yml @@ -0,0 +1,27 @@ +server: + port: 9030 + servlet: + context-path: /api + +spring: + profiles: + active: dev + + #配置 Jpa + jpa: + properties: + hibernate: + ddl-auto: none + open-in-view: true + + +task: + pool: + # 核心线程池大小 + core-pool-size: 10 + # 最大线程数 + max-pool-size: 30 + # 活跃时间 + keep-alive-seconds: 60 + # 队列容量 + queue-capacity: 50 \ No newline at end of file diff --git a/common/pom.xml b/common/pom.xml new file mode 100644 index 0000000..f52e2f4 --- /dev/null +++ b/common/pom.xml @@ -0,0 +1,137 @@ + + + + yxk_canvasScreen + com.canvas.web + 1.0-SNAPSHOT + + 4.0.0 + + common + 公共模块 + + + 17 + 17 + + + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-data-redis-reactive + + + + org.projectlombok + lombok + true + + + com.alibaba + fastjson + 1.2.79 + + + org.apache.commons + commons-lang3 + + + commons-io + commons-io + 20030203.000550 + + + org.springframework.boot + spring-boot-starter-aop + + + + eu.bitwalker + UserAgentUtils + 1.21 + + + + com.alibaba + easyexcel + 3.0.5 + + + + commons-fileupload + commons-fileupload + 1.4 + + + + com.aliyun + aliyun-java-sdk-core + 4.5.30 + + + + org.springframework.boot + spring-boot-starter-mail + + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + cn.jpush.api + jpush-client + 3.5.5 + + + + org.apache.commons + commons-compress + 1.21 + + + + io.jsonwebtoken + jjwt + 0.9.1 + + + com.auth0 + java-jwt + 3.18.2 + + + + com.google.zxing + core + 3.4.1 + + + com.google.zxing + javase + 3.4.1 + + + + mysql + mysql-connector-java + runtime + + + + \ No newline at end of file diff --git a/common/src/main/java/com/canvas/web/exception/BaseException.java b/common/src/main/java/com/canvas/web/exception/BaseException.java new file mode 100644 index 0000000..29b776a --- /dev/null +++ b/common/src/main/java/com/canvas/web/exception/BaseException.java @@ -0,0 +1,68 @@ +package com.canvas.web.exception; + + +import com.canvas.web.utils.MessageUtils; +import org.springframework.util.StringUtils; + +//异常基础类 +public class BaseException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + + //所属模块 + private String module; + + //错误码 + private String code; + + //错误消息 + private Object[] args; + + //错误消息 + private String defaultMessage; + + + public BaseException(String module, String code, Object[] args, String defaultMessage) { + this.module = module; + this.code = code; + this.args = args; + this.defaultMessage = defaultMessage; + } + + public BaseException(String module, String code, Object[] args) { + this(module, code, args, null); + } + + public BaseException(String module, String defaultMessage) { + this(module, null, null, defaultMessage); + } + + public BaseException(String code, Object[] args) { + this(null, code, args, null); + } + + public BaseException(String defaultMessage){ + this(null,null,null,defaultMessage); + } + + @Override + public String getMessage(){ + String message=null; + if (!StringUtils.hasLength(code)){ + message= MessageUtils.message(code,args); + } + if (message==null){ + message=defaultMessage; + } + return message; + } + + public String getModule() {return module;} + + public String getCode() {return code;} + + public Object[] getArgs() {return args;} + + public String getDefaultMessage() {return defaultMessage;} +} diff --git a/common/src/main/java/com/canvas/web/exception/CustomException.java b/common/src/main/java/com/canvas/web/exception/CustomException.java new file mode 100644 index 0000000..a43d42d --- /dev/null +++ b/common/src/main/java/com/canvas/web/exception/CustomException.java @@ -0,0 +1,4 @@ +package com.canvas.web.exception; + +public class CustomException { +} diff --git a/common/src/main/java/com/canvas/web/exception/user/CaptchaException.java b/common/src/main/java/com/canvas/web/exception/user/CaptchaException.java new file mode 100644 index 0000000..6d303c8 --- /dev/null +++ b/common/src/main/java/com/canvas/web/exception/user/CaptchaException.java @@ -0,0 +1,4 @@ +package com.canvas.web.exception.user; + +public class CaptchaException { +} diff --git a/common/src/main/java/com/canvas/web/utils/MessageUtils.java b/common/src/main/java/com/canvas/web/utils/MessageUtils.java new file mode 100644 index 0000000..b222434 --- /dev/null +++ b/common/src/main/java/com/canvas/web/utils/MessageUtils.java @@ -0,0 +1,15 @@ +package com.canvas.web.utils; + + +import org.springframework.context.MessageSource; +import org.springframework.context.i18n.LocaleContextHolder; + +public class MessageUtils { + + + //根据消息键和参数 获取消息 委托给spring messageSource + public static String message(String code, Object... args) { + MessageSource messageSource = SpringUtils.getBean(MessageSource.class); + return messageSource.getMessage(code, args, LocaleContextHolder.getLocale()); + } +} diff --git a/common/src/main/java/com/canvas/web/utils/SpringUtils.java b/common/src/main/java/com/canvas/web/utils/SpringUtils.java new file mode 100644 index 0000000..85411e0 --- /dev/null +++ b/common/src/main/java/com/canvas/web/utils/SpringUtils.java @@ -0,0 +1,56 @@ +package com.canvas.web.utils; + +import org.springframework.aop.framework.AopContext; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.beans.factory.config.BeanFactoryPostProcessor; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.stereotype.Component; + + +@Component +public class SpringUtils implements BeanFactoryPostProcessor { + + + //Spring 应用上下文环境 + private static ConfigurableListableBeanFactory beanFactory; + + + @Override + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { + SpringUtils.beanFactory = beanFactory; + } + + //获取对象 + public static T getBean(String name) throws BeansException { + return (T) beanFactory.getBean(name); + } + + + //获取类型为requiredType对象 + public static T getBean(Class clz) throws BeansException { + T result = (T) beanFactory.getBean(clz); + return result; + } + + //判断以给定名字注册的bean定义是一个singleton还是一个prototype。 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException) + public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException { + return beanFactory.isSingleton(name); + } + + //Class 注册对象的类型 + public static Class getType(String name) throws NoSuchBeanDefinitionException { + return beanFactory.getType(name); + } + + //如果给定的bean名字在bean定义中有别名,则返回这些别名 + public static String[] getAliases(String name) throws NoSuchBeanDefinitionException { + return beanFactory.getAliases(name); + } + + //获取aop代理对象 + @SuppressWarnings("unchecked") + public static T getAopProxy(T invoker) { + return (T) AopContext.currentProxy(); + } +} diff --git a/generator/pom.xml b/generator/pom.xml new file mode 100644 index 0000000..c550a82 --- /dev/null +++ b/generator/pom.xml @@ -0,0 +1,52 @@ + + + + yxk_canvasScreen + com.canvas.web + 1.0-SNAPSHOT + + 4.0.0 + + generator + 代码生成 + + + 17 + 17 + + + + + + + com.canvas.web + common + 1.0-SNAPSHOT + + + + mysql + mysql-connector-java + runtime + + + + com.baomidou + mybatis-plus-generator + 3.2.0 + + + + org.freemarker + freemarker + 2.3.28 + + + org.projectlombok + lombok + true + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..bed6888 --- /dev/null +++ b/pom.xml @@ -0,0 +1,86 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 2.6.2 + + + com.canvas.web + yxk_canvasScreen + pom + 1.0-SNAPSHOT + + admin + common + generator + quartz + queue + system + + + 多媒体后台管理系统 + + + 17 + 17 + + true + + 1.0-SNAPSHOT + + + + + + + com.javaweb + javaweb-common + ${version} + + + com.javaweb + javaweb-generator + ${version} + + + com.javaweb + javaweb-system + ${version} + + + com.javaweb + javaweb-admin + ${version} + + + com.javaweb + javaweb-quartz + ${version} + + + com.javaweb + javaweb-queue + ${version} + + + + + org.projectlombok + lombok + 1.18.10 + true + + + com.alibaba + fastjson + 1.2.62 + + + + + \ No newline at end of file diff --git a/quartz/pom.xml b/quartz/pom.xml new file mode 100644 index 0000000..fe28274 --- /dev/null +++ b/quartz/pom.xml @@ -0,0 +1,35 @@ + + + + yxk_canvasScreen + com.canvas.web + 1.0-SNAPSHOT + + 4.0.0 + + quartz + 定时任务 + + + 17 + 17 + + + + + + + com.canvas.web + common + 1.0-SNAPSHOT + + + org.projectlombok + lombok + true + + + + \ No newline at end of file diff --git a/queue/pom.xml b/queue/pom.xml new file mode 100644 index 0000000..a65abff --- /dev/null +++ b/queue/pom.xml @@ -0,0 +1,43 @@ + + + + yxk_canvasScreen + com.canvas.web + 1.0-SNAPSHOT + + 4.0.0 + + queue + 消息队列 + + + 17 + 17 + + + + + + + com.canvas.web + common + 1.0-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-activemq + + + org.springframework.boot + spring-boot-starter-amqp + + + org.projectlombok + lombok + true + + + + \ No newline at end of file diff --git a/system/pom.xml b/system/pom.xml new file mode 100644 index 0000000..14a3d2e --- /dev/null +++ b/system/pom.xml @@ -0,0 +1,52 @@ + + + + yxk_canvasScreen + com.canvas.web + 1.0-SNAPSHOT + + 4.0.0 + + system + 系统模块 + + + 17 + 17 + + + + + + + com.canvas.web + common + + + org.projectlombok + lombok + true + + + + org.apache.shiro + shiro-spring + 1.7.1 + + + + org.crazycake + shiro-redis + 3.3.1 + + + + com.alibaba + druid-spring-boot-starter + 1.2.8 + + + + \ No newline at end of file