已添加11个文件
已重命名265个文件
已删除2个文件
已修改1个文件
¶Ô±ÈÐÂÎļþ |
| | |
| | | @echo off
|
| | | echo.
|
| | | echo [ä¿¡æ¯] è¿è¡Webå·¥ç¨ã
|
| | | echo.
|
| | |
|
| | | cd %~dp0
|
| | | cd ../ruoyi-admin/target
|
| | |
|
| | | set JAVA_OPTS=-Xms256m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
|
| | |
|
| | | java -jar %JAVA_OPTS% ruoyi-admin.jar
|
| | |
|
| | | cd bin
|
| | | pause |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?>
|
| | | <project xmlns="http://maven.apache.org/POM/4.0.0"
|
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
| | | <modelVersion>4.0.0</modelVersion>
|
| | | |
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi</artifactId>
|
| | | <version>3.0.0</version>
|
| | |
|
| | | <name>ruoyi</name>
|
| | | <url>http://www.ruoyi.vip</url>
|
| | | <description>è¥ä¾ç®¡çç³»ç»</description>
|
| | | |
| | | <properties>
|
| | | <ruoyi.version>3.0.0</ruoyi.version>
|
| | | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
| | | <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
| | | <java.version>1.8</java.version>
|
| | | <mybatis.boot.version>1.3.2</mybatis.boot.version>
|
| | | <druid.version>1.1.14</druid.version>
|
| | | <bitwalker.version>1.19</bitwalker.version>
|
| | | <swagger.version>2.9.2</swagger.version>
|
| | | <pagehelper.boot.version>1.2.5</pagehelper.boot.version>
|
| | | <fastjson.version>1.2.70</fastjson.version>
|
| | | <oshi.version>3.9.1</oshi.version>
|
| | | <commons.io.version>2.5</commons.io.version>
|
| | | <commons.fileupload.version>1.3.3</commons.fileupload.version>
|
| | | <poi.version>3.17</poi.version>
|
| | | <velocity.version>1.7</velocity.version>
|
| | | <jwt.version>0.9.0</jwt.version>
|
| | | </properties>
|
| | | |
| | | <!-- ä¾èµå£°æ -->
|
| | | <dependencyManagement>
|
| | | <dependencies>
|
| | | |
| | | <!-- SpringBootçä¾èµé
ç½®-->
|
| | | <dependency>
|
| | | <groupId>org.springframework.boot</groupId>
|
| | | <artifactId>spring-boot-dependencies</artifactId>
|
| | | <version>2.1.1.RELEASE</version>
|
| | | <type>pom</type>
|
| | | <scope>import</scope>
|
| | | </dependency>
|
| | | |
| | | <!--é¿éæ°æ®åºè¿æ¥æ± -->
|
| | | <dependency>
|
| | | <groupId>com.alibaba</groupId>
|
| | | <artifactId>druid-spring-boot-starter</artifactId>
|
| | | <version>${druid.version}</version>
|
| | | </dependency>
|
| | | |
| | | <!-- è§£æå®¢æ·ç«¯æä½ç³»ç»ãæµè§å¨ç -->
|
| | | <dependency>
|
| | | <groupId>eu.bitwalker</groupId>
|
| | | <artifactId>UserAgentUtils</artifactId>
|
| | | <version>${bitwalker.version}</version>
|
| | | </dependency>
|
| | | |
| | | <!-- pagehelper å页æä»¶ -->
|
| | | <dependency>
|
| | | <groupId>com.github.pagehelper</groupId>
|
| | | <artifactId>pagehelper-spring-boot-starter</artifactId>
|
| | | <version>${pagehelper.boot.version}</version>
|
| | | </dependency>
|
| | | |
| | | <!-- è·åç³»ç»ä¿¡æ¯ -->
|
| | | <dependency>
|
| | | <groupId>com.github.oshi</groupId>
|
| | | <artifactId>oshi-core</artifactId>
|
| | | <version>${oshi.version}</version>
|
| | | </dependency>
|
| | | |
| | | <!-- swagger2-->
|
| | | <dependency>
|
| | | <groupId>io.springfox</groupId>
|
| | | <artifactId>springfox-swagger2</artifactId>
|
| | | <version>${swagger.version}</version>
|
| | | <exclusions>
|
| | | <exclusion>
|
| | | <groupId>io.swagger</groupId>
|
| | | <artifactId>swagger-annotations</artifactId>
|
| | | </exclusion>
|
| | | <exclusion>
|
| | | <groupId>io.swagger</groupId>
|
| | | <artifactId>swagger-models</artifactId>
|
| | | </exclusion>
|
| | | </exclusions>
|
| | | </dependency>
|
| | | |
| | | <!-- swagger2-UI-->
|
| | | <dependency>
|
| | | <groupId>io.springfox</groupId>
|
| | | <artifactId>springfox-swagger-ui</artifactId>
|
| | | <version>${swagger.version}</version>
|
| | | </dependency>
|
| | | |
| | | <!--io常ç¨å·¥å
·ç±» -->
|
| | | <dependency>
|
| | | <groupId>commons-io</groupId>
|
| | | <artifactId>commons-io</artifactId>
|
| | | <version>${commons.io.version}</version>
|
| | | </dependency>
|
| | | |
| | | <!--æä»¶ä¸ä¼ å·¥å
·ç±» -->
|
| | | <dependency>
|
| | | <groupId>commons-fileupload</groupId>
|
| | | <artifactId>commons-fileupload</artifactId>
|
| | | <version>${commons.fileupload.version}</version>
|
| | | </dependency>
|
| | | |
| | | <!-- excelå·¥å
· -->
|
| | | <dependency>
|
| | | <groupId>org.apache.poi</groupId>
|
| | | <artifactId>poi-ooxml</artifactId>
|
| | | <version>${poi.version}</version>
|
| | | </dependency>
|
| | | |
| | | <!--velocity代ç çæä½¿ç¨æ¨¡æ¿ -->
|
| | | <dependency>
|
| | | <groupId>org.apache.velocity</groupId>
|
| | | <artifactId>velocity</artifactId>
|
| | | <version>${velocity.version}</version>
|
| | | </dependency>
|
| | | |
| | | <!-- é¿éJSONè§£æå¨ -->
|
| | | <dependency>
|
| | | <groupId>com.alibaba</groupId>
|
| | | <artifactId>fastjson</artifactId>
|
| | | <version>${fastjson.version}</version>
|
| | | </dependency>
|
| | | |
| | | <!--Tokençæä¸è§£æ-->
|
| | | <dependency>
|
| | | <groupId>io.jsonwebtoken</groupId>
|
| | | <artifactId>jjwt</artifactId>
|
| | | <version>${jwt.version}</version>
|
| | | </dependency>
|
| | | |
| | | <!-- 宿¶ä»»å¡-->
|
| | | <dependency>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi-quartz</artifactId>
|
| | | <version>${ruoyi.version}</version>
|
| | | </dependency>
|
| | | |
| | | <!-- 代ç çæ-->
|
| | | <dependency>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi-generator</artifactId>
|
| | | <version>${ruoyi.version}</version>
|
| | | </dependency>
|
| | | |
| | | <!-- æ ¸å¿æ¨¡å-->
|
| | | <dependency>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi-framework</artifactId>
|
| | | <version>${ruoyi.version}</version>
|
| | | </dependency>
|
| | | |
| | | <!-- ç³»ç»æ¨¡å-->
|
| | | <dependency>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi-system</artifactId>
|
| | | <version>${ruoyi.version}</version>
|
| | | </dependency>
|
| | | |
| | | <!-- éç¨å·¥å
·-->
|
| | | <dependency>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi-common</artifactId>
|
| | | <version>${ruoyi.version}</version>
|
| | | </dependency>
|
| | |
|
| | | </dependencies>
|
| | | </dependencyManagement>
|
| | |
|
| | | <modules>
|
| | | <module>ruoyi-admin</module>
|
| | | <module>ruoyi-framework</module>
|
| | | <module>ruoyi-system</module>
|
| | | <module>ruoyi-quartz</module>
|
| | | <module>ruoyi-generator</module>
|
| | | <module>ruoyi-common</module>
|
| | | </modules>
|
| | | <packaging>pom</packaging>
|
| | |
|
| | |
|
| | | <dependencies>
|
| | |
|
| | | </dependencies>
|
| | |
|
| | | <build>
|
| | | <plugins>
|
| | | <plugin>
|
| | | <groupId>org.apache.maven.plugins</groupId>
|
| | | <artifactId>maven-compiler-plugin</artifactId>
|
| | | <version>3.1</version>
|
| | | <configuration>
|
| | | <source>${java.version}</source>
|
| | | <target>${java.version}</target>
|
| | | <encoding>${project.build.sourceEncoding}</encoding>
|
| | | </configuration>
|
| | | </plugin>
|
| | | </plugins>
|
| | | </build>
|
| | |
|
| | | <repositories>
|
| | | <repository>
|
| | | <id>public</id>
|
| | | <name>aliyun nexus</name>
|
| | | <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
| | | <releases>
|
| | | <enabled>true</enabled>
|
| | | </releases>
|
| | | </repository>
|
| | | </repositories>
|
| | |
|
| | | <pluginRepositories>
|
| | | <pluginRepository>
|
| | | <id>public</id>
|
| | | <name>aliyun nexus</name>
|
| | | <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
| | | <releases>
|
| | | <enabled>true</enabled>
|
| | | </releases>
|
| | | <snapshots>
|
| | | <enabled>false</enabled>
|
| | | </snapshots>
|
| | | </pluginRepository>
|
| | | </pluginRepositories>
|
| | |
|
| | | </project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?>
|
| | | <project xmlns="http://maven.apache.org/POM/4.0.0"
|
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
| | | <parent>
|
| | | <artifactId>ruoyi</artifactId>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <version>3.0.0</version>
|
| | | </parent>
|
| | | <modelVersion>4.0.0</modelVersion>
|
| | | <packaging>jar</packaging>
|
| | | <artifactId>ruoyi-admin</artifactId>
|
| | |
|
| | | <description>
|
| | | webæå¡å
¥å£
|
| | | </description>
|
| | |
|
| | | <dependencies>
|
| | |
|
| | | <!-- spring-boot-devtools -->
|
| | | <dependency>
|
| | | <groupId>org.springframework.boot</groupId>
|
| | | <artifactId>spring-boot-devtools</artifactId>
|
| | | <optional>true</optional> <!-- 表示ä¾èµä¸ä¼ä¼ é -->
|
| | | </dependency>
|
| | |
|
| | | <!-- swagger2-->
|
| | | <dependency>
|
| | | <groupId>io.springfox</groupId>
|
| | | <artifactId>springfox-swagger2</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!--鲿¢è¿å
¥swagger页颿¥ç±»å转æ¢éè¯¯ï¼æé¤2.9.2ä¸çå¼ç¨ï¼æå¨å¢å 1.5.21çæ¬-->
|
| | | <dependency>
|
| | | <groupId>io.swagger</groupId>
|
| | | <artifactId>swagger-annotations</artifactId>
|
| | | <version>1.5.21</version>
|
| | | </dependency>
|
| | |
|
| | | <dependency>
|
| | | <groupId>io.swagger</groupId>
|
| | | <artifactId>swagger-models</artifactId>
|
| | | <version>1.5.21</version>
|
| | | </dependency>
|
| | |
|
| | | <!-- swagger2-UI-->
|
| | | <dependency>
|
| | | <groupId>io.springfox</groupId>
|
| | | <artifactId>springfox-swagger-ui</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- Mysql驱å¨å
-->
|
| | | <dependency>
|
| | | <groupId>mysql</groupId>
|
| | | <artifactId>mysql-connector-java</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- æ ¸å¿æ¨¡å-->
|
| | | <dependency>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi-framework</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- 宿¶ä»»å¡-->
|
| | | <dependency>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi-quartz</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- 代ç çæ-->
|
| | | <dependency>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi-generator</artifactId>
|
| | | </dependency>
|
| | |
|
| | | </dependencies>
|
| | |
|
| | | <build>
|
| | | <plugins>
|
| | | <plugin>
|
| | | <groupId>org.springframework.boot</groupId>
|
| | | <artifactId>spring-boot-maven-plugin</artifactId>
|
| | | <version>2.1.1.RELEASE</version>
|
| | | <configuration>
|
| | | <fork>true</fork> <!-- å¦ææ²¡æè¯¥é
ç½®ï¼devtoolsä¸ä¼çæ -->
|
| | | </configuration>
|
| | | <executions>
|
| | | <execution>
|
| | | <goals>
|
| | | <goal>repackage</goal>
|
| | | </goals>
|
| | | </execution>
|
| | | </executions>
|
| | | </plugin>
|
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-war-plugin</artifactId> |
| | | <version>3.0.0</version> |
| | | <configuration>
|
| | | <failOnMissingWebXml>false</failOnMissingWebXml>
|
| | | <warName>${project.artifactId}</warName>
|
| | | </configuration> |
| | | </plugin> |
| | | </plugins>
|
| | | <finalName>${project.artifactId}</finalName>
|
| | | </build>
|
| | |
|
| | | </project> |
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/common/CaptchaController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.common;
|
| | | package com.ruoyi.web.controller.common;
|
| | |
|
| | | import java.io.ByteArrayOutputStream;
|
| | | import java.io.IOException;
|
| | |
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.utils.IdUtils;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.redis.RedisCache;
|
| | | import com.ruoyi.common.utils.VerifyCodeUtils;
|
| | | import com.ruoyi.common.utils.sign.Base64;
|
| | | import com.ruoyi.framework.redis.RedisCache;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.common.utils.uuid.IdUtils;
|
| | |
|
| | | /**
|
| | | * éªè¯ç æä½å¤ç
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/common/CommonController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.common;
|
| | | package com.ruoyi.web.controller.common;
|
| | |
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
| | | import org.springframework.web.bind.annotation.PostMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import com.ruoyi.common.config.RuoYiConfig;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.file.FileUploadUtils;
|
| | | import com.ruoyi.common.utils.file.FileUtils;
|
| | | import com.ruoyi.framework.config.RuoYiConfig;
|
| | | import com.ruoyi.framework.config.ServerConfig;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | |
|
| | | /**
|
| | | * éç¨è¯·æ±å¤ç
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/controller/ServerController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.controller;
|
| | | package com.ruoyi.web.controller.monitor;
|
| | |
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.domain.Server;
|
| | |
|
| | | /**
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysLogininforController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.controller;
|
| | | package com.ruoyi.web.controller.monitor;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.page.TableDataInfo;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.utils.poi.ExcelUtil;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | import com.ruoyi.project.monitor.domain.SysLogininfor;
|
| | | import com.ruoyi.project.monitor.service.ISysLogininforService;
|
| | | import com.ruoyi.system.domain.SysLogininfor;
|
| | | import com.ruoyi.system.service.ISysLogininforService;
|
| | |
|
| | | /**
|
| | | * ç³»ç»è®¿é®è®°å½
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysOperlogController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.controller;
|
| | | package com.ruoyi.web.controller.monitor;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.page.TableDataInfo;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.utils.poi.ExcelUtil;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | import com.ruoyi.project.monitor.domain.SysOperLog;
|
| | | import com.ruoyi.project.monitor.service.ISysOperLogService;
|
| | | import com.ruoyi.system.domain.SysOperLog;
|
| | | import com.ruoyi.system.service.ISysOperLogService;
|
| | |
|
| | | /**
|
| | | * æä½æ¥å¿è®°å½
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysUserOnlineController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.controller;
|
| | | package com.ruoyi.web.controller.monitor;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collection;
|
| | |
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.domain.model.LoginUser;
|
| | | import com.ruoyi.common.core.page.TableDataInfo;
|
| | | import com.ruoyi.common.core.redis.RedisCache;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.redis.RedisCache;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | import com.ruoyi.project.monitor.domain.SysUserOnline;
|
| | | import com.ruoyi.project.system.service.ISysUserOnlineService;
|
| | | import com.ruoyi.system.domain.SysUserOnline;
|
| | | import com.ruoyi.system.service.ISysUserOnlineService;
|
| | |
|
| | | /**
|
| | | * å¨çº¿ç¨æ·çæ§
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/controller/SysConfigController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.controller;
|
| | | package com.ruoyi.web.controller.system;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.annotation.RepeatSubmit;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.page.TableDataInfo;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.common.utils.poi.ExcelUtil;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | import com.ruoyi.project.system.domain.SysConfig;
|
| | | import com.ruoyi.project.system.service.ISysConfigService;
|
| | | import com.ruoyi.system.domain.SysConfig;
|
| | | import com.ruoyi.system.service.ISysConfigService;
|
| | |
|
| | | /**
|
| | | * åæ°é
ç½® ä¿¡æ¯æä½å¤ç
|
| | |
| | | @PreAuthorize("@ss.hasPermi('system:config:add')")
|
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.INSERT)
|
| | | @PostMapping
|
| | | @RepeatSubmit
|
| | | public AjaxResult add(@Validated @RequestBody SysConfig config)
|
| | | {
|
| | | if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.controller;
|
| | | package com.ruoyi.web.controller.system;
|
| | |
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | |
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.domain.entity.SysDept;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.project.system.domain.SysDept;
|
| | | import com.ruoyi.project.system.service.ISysDeptService;
|
| | | import com.ruoyi.system.service.ISysDeptService;
|
| | |
|
| | | /**
|
| | | * é¨é¨ä¿¡æ¯
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictDataController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.controller;
|
| | | package com.ruoyi.web.controller.system;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.domain.entity.SysDictData;
|
| | | import com.ruoyi.common.core.page.TableDataInfo;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.common.utils.poi.ExcelUtil;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | import com.ruoyi.project.system.domain.SysDictData;
|
| | | import com.ruoyi.project.system.service.ISysDictDataService;
|
| | | import com.ruoyi.project.system.service.ISysDictTypeService;
|
| | | import com.ruoyi.system.service.ISysDictDataService;
|
| | | import com.ruoyi.system.service.ISysDictTypeService;
|
| | |
|
| | | /**
|
| | | * æ°æ®åå
¸ä¿¡æ¯
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictTypeController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.controller;
|
| | | package com.ruoyi.web.controller.system;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.domain.entity.SysDictType;
|
| | | import com.ruoyi.common.core.page.TableDataInfo;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.common.utils.poi.ExcelUtil;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | import com.ruoyi.project.system.domain.SysDictType;
|
| | | import com.ruoyi.project.system.service.ISysDictTypeService;
|
| | | import com.ruoyi.system.service.ISysDictTypeService;
|
| | |
|
| | | /**
|
| | | * æ°æ®åå
¸ä¿¡æ¯
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/controller/SysLoginController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.controller;
|
| | | package com.ruoyi.web.controller.system;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | |
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.domain.entity.SysMenu;
|
| | | import com.ruoyi.common.core.domain.entity.SysUser;
|
| | | import com.ruoyi.common.core.domain.model.LoginBody;
|
| | | import com.ruoyi.common.core.domain.model.LoginUser;
|
| | | import com.ruoyi.common.utils.ServletUtils;
|
| | | import com.ruoyi.framework.security.LoginBody;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | | import com.ruoyi.framework.security.service.SysLoginService;
|
| | | import com.ruoyi.framework.security.service.SysPermissionService;
|
| | | import com.ruoyi.framework.security.service.TokenService;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.project.system.domain.SysMenu;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.project.system.service.ISysMenuService;
|
| | | import com.ruoyi.framework.web.service.SysLoginService;
|
| | | import com.ruoyi.framework.web.service.SysPermissionService;
|
| | | import com.ruoyi.framework.web.service.TokenService;
|
| | | import com.ruoyi.system.service.ISysMenuService;
|
| | |
|
| | | /**
|
| | | * ç»å½éªè¯
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/controller/SysMenuController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.controller;
|
| | | package com.ruoyi.web.controller.system;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.domain.entity.SysMenu;
|
| | | import com.ruoyi.common.core.domain.model.LoginUser;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.common.utils.ServletUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | | import com.ruoyi.framework.security.service.TokenService;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.project.system.domain.SysMenu;
|
| | | import com.ruoyi.project.system.service.ISysMenuService;
|
| | | import com.ruoyi.framework.web.service.TokenService;
|
| | | import com.ruoyi.system.service.ISysMenuService;
|
| | |
|
| | | /**
|
| | | * èåä¿¡æ¯
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.controller;
|
| | | package com.ruoyi.web.controller.system;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.page.TableDataInfo;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | import com.ruoyi.project.system.domain.SysNotice;
|
| | | import com.ruoyi.project.system.service.ISysNoticeService;
|
| | | import com.ruoyi.system.domain.SysNotice;
|
| | | import com.ruoyi.system.service.ISysNoticeService;
|
| | |
|
| | | /**
|
| | | * å
¬å ä¿¡æ¯æä½å¤ç
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/controller/SysPostController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.controller;
|
| | | package com.ruoyi.web.controller.system;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.page.TableDataInfo;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.common.utils.poi.ExcelUtil;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | import com.ruoyi.project.system.domain.SysPost;
|
| | | import com.ruoyi.project.system.service.ISysPostService;
|
| | | import com.ruoyi.system.domain.SysPost;
|
| | | import com.ruoyi.system.service.ISysPostService;
|
| | |
|
| | | /**
|
| | | * å²ä½ä¿¡æ¯æä½å¤ç
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.controller;
|
| | | package com.ruoyi.web.controller.system;
|
| | |
|
| | | import java.io.IOException;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | import org.springframework.web.bind.annotation.RequestParam;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.config.RuoYiConfig;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.domain.entity.SysUser;
|
| | | import com.ruoyi.common.core.domain.model.LoginUser;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.common.utils.ServletUtils;
|
| | | import com.ruoyi.common.utils.file.FileUploadUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.config.RuoYiConfig;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | | import com.ruoyi.framework.security.service.TokenService;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.project.system.service.ISysUserService;
|
| | | import com.ruoyi.framework.web.service.TokenService;
|
| | | import com.ruoyi.system.service.ISysUserService;
|
| | |
|
| | | /**
|
| | | * ä¸ªäººä¿¡æ¯ ä¸å¡å¤ç
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/controller/SysRoleController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.controller;
|
| | | package com.ruoyi.web.controller.system;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.domain.entity.SysRole;
|
| | | import com.ruoyi.common.core.page.TableDataInfo;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.common.utils.poi.ExcelUtil;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | import com.ruoyi.project.system.domain.SysRole;
|
| | | import com.ruoyi.project.system.service.ISysRoleService;
|
| | | import com.ruoyi.system.service.ISysRoleService;
|
| | |
|
| | | /**
|
| | | * è§è²ä¿¡æ¯
|
| | |
| | | {
|
| | | return AjaxResult.success(roleService.selectRoleAll());
|
| | | }
|
| | | } |
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/controller/SysUserController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.controller;
|
| | | package com.ruoyi.web.controller.system;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.stream.Collectors;
|
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.domain.entity.SysRole;
|
| | | import com.ruoyi.common.core.domain.entity.SysUser;
|
| | | import com.ruoyi.common.core.domain.model.LoginUser;
|
| | | import com.ruoyi.common.core.page.TableDataInfo;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.common.utils.ServletUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.poi.ExcelUtil;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | | import com.ruoyi.framework.security.service.TokenService;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | import com.ruoyi.project.system.domain.SysRole;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.project.system.service.ISysPostService;
|
| | | import com.ruoyi.project.system.service.ISysRoleService;
|
| | | import com.ruoyi.project.system.service.ISysUserService;
|
| | | import com.ruoyi.framework.web.service.TokenService;
|
| | | import com.ruoyi.system.service.ISysPostService;
|
| | | import com.ruoyi.system.service.ISysRoleService;
|
| | | import com.ruoyi.system.service.ISysUserService;
|
| | |
|
| | | /**
|
| | | * ç¨æ·ä¿¡æ¯
|
| | |
| | | user.setUpdateBy(SecurityUtils.getUsername());
|
| | | return toAjax(userService.updateUserStatus(user));
|
| | | }
|
| | | } |
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.tool;
|
| | |
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | |
|
| | | /**
|
| | | * swagger æ¥å£
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @Controller
|
| | | @RequestMapping("/tool/swagger")
|
| | | public class SwaggerController extends BaseController
|
| | | {
|
| | | @PreAuthorize("@ss.hasPermi('tool:swagger:view')")
|
| | | @GetMapping()
|
| | | public String index()
|
| | | {
|
| | | return redirect("/swagger-ui.html");
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/tool/swagger/TestController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.tool.swagger;
|
| | | package com.ruoyi.web.controller.tool;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.LinkedHashMap;
|
| | |
| | | import org.springframework.web.bind.annotation.PutMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import io.swagger.annotations.Api;
|
| | | import io.swagger.annotations.ApiImplicitParam;
|
| | | import io.swagger.annotations.ApiModel;
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.config;
|
| | | package com.ruoyi.web.core.config;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.context.annotation.Bean;
|
| | | import org.springframework.context.annotation.Configuration;
|
| | | import com.ruoyi.common.config.RuoYiConfig;
|
| | | import io.swagger.annotations.ApiOperation;
|
| | | import springfox.documentation.builders.ApiInfoBuilder;
|
| | | import springfox.documentation.builders.PathSelectors;
|
ÎļþÃû´Ó ruoyi/src/main/resources/application.yml ÐÞ¸Ä |
| | |
| | | # åç§°
|
| | | name: RuoYi
|
| | | # çæ¬
|
| | | version: 2.3.0
|
| | | version: 3.0.0
|
| | | # çæå¹´ä»½
|
| | | copyrightYear: 2019
|
| | | # å®ä¾æ¼ç¤ºå¼å
³
|
| | |
| | | # MyBatisé
ç½®
|
| | | mybatis:
|
| | | # æç´¢æå®å
å«å
|
| | | typeAliasesPackage: com.ruoyi.project.**.domain
|
| | | typeAliasesPackage: com.ruoyi.**.domain
|
| | | # é
ç½®mapperçæ«æï¼æ¾å°ææçmapper.xmlæ å°æä»¶
|
| | | mapperLocations: classpath*:mybatis/**/*Mapper.xml
|
| | | mapperLocations: classpath*:mapper/**/*Mapper.xml
|
| | | # å è½½å
¨å±çé
ç½®æä»¶
|
| | | configLocation: classpath:mybatis/mybatis-config.xml
|
| | |
|
| | |
| | | excludes: /system/notice/*
|
| | | # å¹é
龿¥
|
| | | urlPatterns: /system/*,/monitor/*,/tool/*
|
| | | |
| | | # 代ç çæ
|
| | | gen: |
| | | # ä½è
|
| | | author: ruoyi
|
| | | # é»è®¤çæå
è·¯å¾ system éæ¹æèªå·±ç模ååç§° å¦ system monitor tool
|
| | | packageName: com.ruoyi.project.system
|
| | | # èªå¨å»é¤è¡¨åç¼ï¼é»è®¤æ¯true
|
| | | autoRemovePre: false
|
| | | # 表åç¼ï¼çæç±»åä¸ä¼å
å«è¡¨åç¼ï¼å¤ä¸ªç¨éå·åéï¼
|
| | | tablePrefix: sys_ |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?>
|
| | | <project xmlns="http://maven.apache.org/POM/4.0.0"
|
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
| | | <parent>
|
| | | <artifactId>ruoyi</artifactId>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <version>3.0.0</version>
|
| | | </parent>
|
| | | <modelVersion>4.0.0</modelVersion>
|
| | |
|
| | | <artifactId>ruoyi-common</artifactId>
|
| | |
|
| | | <description>
|
| | | commonéç¨å·¥å
·
|
| | | </description>
|
| | |
|
| | | <dependencies>
|
| | |
|
| | | <!-- Springæ¡æ¶åºæ¬çæ ¸å¿å·¥å
· -->
|
| | | <dependency>
|
| | | <groupId>org.springframework</groupId>
|
| | | <artifactId>spring-context-support</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- SpringWeb模å -->
|
| | | <dependency>
|
| | | <groupId>org.springframework</groupId>
|
| | | <artifactId>spring-web</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- spring security å®å
¨è®¤è¯ -->
|
| | | <dependency>
|
| | | <groupId>org.springframework.boot</groupId>
|
| | | <artifactId>spring-boot-starter-security</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- pagehelper å页æä»¶ -->
|
| | | <dependency>
|
| | | <groupId>com.github.pagehelper</groupId>
|
| | | <artifactId>pagehelper-spring-boot-starter</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- èªå®ä¹éªè¯æ³¨è§£ -->
|
| | | <dependency>
|
| | | <groupId>javax.validation</groupId>
|
| | | <artifactId>validation-api</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!--常ç¨å·¥å
·ç±» -->
|
| | | <dependency>
|
| | | <groupId>org.apache.commons</groupId>
|
| | | <artifactId>commons-lang3</artifactId>
|
| | | </dependency>
|
| | | |
| | | <!-- JSONå·¥å
·ç±» -->
|
| | | <dependency>
|
| | | <groupId>com.fasterxml.jackson.core</groupId>
|
| | | <artifactId>jackson-databind</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- é¿éJSONè§£æå¨ -->
|
| | | <dependency>
|
| | | <groupId>com.alibaba</groupId>
|
| | | <artifactId>fastjson</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- io常ç¨å·¥å
·ç±» -->
|
| | | <dependency>
|
| | | <groupId>commons-io</groupId>
|
| | | <artifactId>commons-io</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- æä»¶ä¸ä¼ å·¥å
·ç±» -->
|
| | | <dependency>
|
| | | <groupId>commons-fileupload</groupId>
|
| | | <artifactId>commons-fileupload</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- excelå·¥å
· -->
|
| | | <dependency>
|
| | | <groupId>org.apache.poi</groupId>
|
| | | <artifactId>poi-ooxml</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- ymlè§£æå¨ -->
|
| | | <dependency>
|
| | | <groupId>org.yaml</groupId>
|
| | | <artifactId>snakeyaml</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!--Tokençæä¸è§£æ-->
|
| | | <dependency>
|
| | | <groupId>io.jsonwebtoken</groupId>
|
| | | <artifactId>jjwt</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- redis ç¼åæä½ -->
|
| | | <dependency>
|
| | | <groupId>org.springframework.boot</groupId>
|
| | | <artifactId>spring-boot-starter-data-redis</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- pool å¯¹è±¡æ± -->
|
| | | <dependency>
|
| | | <groupId>org.apache.commons</groupId>
|
| | | <artifactId>commons-pool2</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- è§£æå®¢æ·ç«¯æä½ç³»ç»ãæµè§å¨ç -->
|
| | | <dependency>
|
| | | <groupId>eu.bitwalker</groupId>
|
| | | <artifactId>UserAgentUtils</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- servletå
-->
|
| | | <dependency>
|
| | | <groupId>javax.servlet</groupId>
|
| | | <artifactId>javax.servlet-api</artifactId>
|
| | | </dependency>
|
| | |
|
| | | </dependencies>
|
| | |
|
| | | </project> |
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/DataScope.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.aspectj.lang.annotation;
|
| | | package com.ruoyi.common.annotation;
|
| | |
|
| | | import java.lang.annotation.Documented;
|
| | | import java.lang.annotation.ElementType;
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/DataSource.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.aspectj.lang.annotation;
|
| | | package com.ruoyi.common.annotation;
|
| | |
|
| | | import java.lang.annotation.Documented;
|
| | | import java.lang.annotation.ElementType;
|
| | |
| | | import java.lang.annotation.Retention;
|
| | | import java.lang.annotation.RetentionPolicy;
|
| | | import java.lang.annotation.Target;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
|
| | | import com.ruoyi.common.enums.DataSourceType;
|
| | |
|
| | | /**
|
| | | * èªå®ä¹å¤æ°æ®æºåæ¢æ³¨è§£
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Excel.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.aspectj.lang.annotation; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * èªå®ä¹å¯¼åºExcelæ°æ®æ³¨è§£ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Target(ElementType.FIELD) |
| | | public @interface Excel |
| | | { |
| | | /** |
| | | * å¯¼åºæ¶å¨excelä¸æåº |
| | | */ |
| | | public int sort() default Integer.MAX_VALUE; |
| | | |
| | | /** |
| | | * 导åºå°Excelä¸çåå. |
| | | */ |
| | | public String name() default ""; |
| | | |
| | | /** |
| | | * æ¥ææ ¼å¼, å¦: yyyy-MM-dd |
| | | */ |
| | | public String dateFormat() default ""; |
| | | |
| | | /** |
| | | * 读åå
å®¹è½¬è¡¨è¾¾å¼ (å¦: 0=ç·,1=女,2=æªç¥) |
| | | */ |
| | | public String readConverterExp() default ""; |
| | | |
| | | /** |
| | | * 导åºç±»åï¼0æ°å 1åç¬¦ä¸²ï¼ |
| | | */ |
| | | public ColumnType cellType() default ColumnType.STRING; |
| | | |
| | | /** |
| | | * å¯¼åºæ¶å¨excel䏿¯ä¸ªåçé«åº¦ åä½ä¸ºå符 |
| | | */ |
| | | public double height() default 14; |
| | | |
| | | /** |
| | | * å¯¼åºæ¶å¨excel䏿¯ä¸ªåç宽 åä½ä¸ºå符 |
| | | */ |
| | | public double width() default 16; |
| | | |
| | | /** |
| | | * æååç¼,å¦% 90 åæ90% |
| | | */ |
| | | public String suffix() default ""; |
| | | |
| | | /** |
| | | * å½å¼ä¸ºç©ºæ¶,åæ®µçé»è®¤å¼ |
| | | */ |
| | | public String defaultValue() default ""; |
| | | |
| | | /** |
| | | * æç¤ºä¿¡æ¯ |
| | | */ |
| | | public String prompt() default ""; |
| | | |
| | | /** |
| | | * 设置åªè½éæ©ä¸è½è¾å
¥çåå
容. |
| | | */ |
| | | public String[] combo() default {}; |
| | | |
| | | /** |
| | | * æ¯å¦å¯¼åºæ°æ®,åºå¯¹éæ±:ææ¶æä»¬éè¦å¯¼åºä¸ä»½æ¨¡æ¿,è¿æ¯æ é¢éè¦ä½å
容éè¦ç¨æ·æå·¥å¡«å. |
| | | */ |
| | | public boolean isExport() default true; |
| | | |
| | | /** |
| | | * å¦ä¸ä¸ªç±»ä¸ç屿§åç§°,æ¯æå¤çº§è·å,以尿°ç¹éå¼ |
| | | */ |
| | | public String targetAttr() default ""; |
| | | |
| | | /** |
| | | * åæ®µç±»åï¼0ï¼å¯¼åºå¯¼å
¥ï¼1ï¼ä»
导åºï¼2ï¼ä»
导å
¥ï¼ |
| | | */ |
| | | Type type() default Type.ALL; |
| | | |
| | | public enum Type |
| | | { |
| | | ALL(0), EXPORT(1), IMPORT(2); |
| | | private final int value; |
| | | |
| | | Type(int value) |
| | | { |
| | | this.value = value; |
| | | } |
| | | |
| | | public int value() |
| | | { |
| | | return this.value; |
| | | } |
| | | } |
| | | |
| | | public enum ColumnType |
| | | { |
| | | NUMERIC(0), STRING(1); |
| | | private final int value; |
| | | |
| | | ColumnType(int value) |
| | | { |
| | | this.value = value; |
| | | } |
| | | |
| | | public int value() |
| | | { |
| | | return this.value; |
| | | } |
| | | } |
| | | } |
| | | package com.ruoyi.common.annotation;
|
| | |
|
| | | import java.lang.annotation.ElementType;
|
| | | import java.lang.annotation.Retention;
|
| | | import java.lang.annotation.RetentionPolicy;
|
| | | import java.lang.annotation.Target;
|
| | |
|
| | | /**
|
| | | * èªå®ä¹å¯¼åºExcelæ°æ®æ³¨è§£
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @Retention(RetentionPolicy.RUNTIME)
|
| | | @Target(ElementType.FIELD)
|
| | | public @interface Excel
|
| | | {
|
| | | /**
|
| | | * å¯¼åºæ¶å¨excel䏿åº
|
| | | */
|
| | | public int sort() default Integer.MAX_VALUE;
|
| | |
|
| | | /**
|
| | | * 导åºå°Excelä¸çåå.
|
| | | */
|
| | | public String name() default "";
|
| | |
|
| | | /**
|
| | | * æ¥ææ ¼å¼, å¦: yyyy-MM-dd
|
| | | */
|
| | | public String dateFormat() default "";
|
| | |
|
| | | /**
|
| | | * 读åå
å®¹è½¬è¡¨è¾¾å¼ (å¦: 0=ç·,1=女,2=æªç¥)
|
| | | */
|
| | | public String readConverterExp() default "";
|
| | |
|
| | | /**
|
| | | * 导åºç±»åï¼0æ°å 1å符串ï¼
|
| | | */
|
| | | public ColumnType cellType() default ColumnType.STRING;
|
| | |
|
| | | /**
|
| | | * å¯¼åºæ¶å¨excel䏿¯ä¸ªåçé«åº¦ åä½ä¸ºå符
|
| | | */
|
| | | public double height() default 14;
|
| | |
|
| | | /**
|
| | | * å¯¼åºæ¶å¨excel䏿¯ä¸ªåç宽 åä½ä¸ºå符
|
| | | */
|
| | | public double width() default 16;
|
| | |
|
| | | /**
|
| | | * æååç¼,å¦% 90 åæ90%
|
| | | */
|
| | | public String suffix() default "";
|
| | |
|
| | | /**
|
| | | * å½å¼ä¸ºç©ºæ¶,åæ®µçé»è®¤å¼
|
| | | */
|
| | | public String defaultValue() default "";
|
| | |
|
| | | /**
|
| | | * æç¤ºä¿¡æ¯
|
| | | */
|
| | | public String prompt() default "";
|
| | |
|
| | | /**
|
| | | * 设置åªè½éæ©ä¸è½è¾å
¥çåå
容.
|
| | | */
|
| | | public String[] combo() default {};
|
| | |
|
| | | /**
|
| | | * æ¯å¦å¯¼åºæ°æ®,åºå¯¹éæ±:ææ¶æä»¬éè¦å¯¼åºä¸ä»½æ¨¡æ¿,è¿æ¯æ é¢éè¦ä½å
容éè¦ç¨æ·æå·¥å¡«å.
|
| | | */
|
| | | public boolean isExport() default true;
|
| | |
|
| | | /**
|
| | | * å¦ä¸ä¸ªç±»ä¸ç屿§åç§°,æ¯æå¤çº§è·å,以尿°ç¹éå¼
|
| | | */
|
| | | public String targetAttr() default "";
|
| | |
|
| | | /**
|
| | | * åæ®µç±»åï¼0ï¼å¯¼åºå¯¼å
¥ï¼1ï¼ä»
导åºï¼2ï¼ä»
导å
¥ï¼
|
| | | */
|
| | | Type type() default Type.ALL;
|
| | |
|
| | | public enum Type
|
| | | {
|
| | | ALL(0), EXPORT(1), IMPORT(2);
|
| | | private final int value;
|
| | |
|
| | | Type(int value)
|
| | | {
|
| | | this.value = value;
|
| | | }
|
| | |
|
| | | public int value()
|
| | | {
|
| | | return this.value;
|
| | | }
|
| | | }
|
| | |
|
| | | public enum ColumnType
|
| | | {
|
| | | NUMERIC(0), STRING(1);
|
| | | private final int value;
|
| | |
|
| | | ColumnType(int value)
|
| | | {
|
| | | this.value = value;
|
| | | }
|
| | |
|
| | | public int value()
|
| | | {
|
| | | return this.value;
|
| | | }
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Excels.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.aspectj.lang.annotation; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * Excel注解é |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Target(ElementType.FIELD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface Excels |
| | | { |
| | | Excel[] value(); |
| | | } |
| | | package com.ruoyi.common.annotation;
|
| | |
|
| | | import java.lang.annotation.ElementType;
|
| | | import java.lang.annotation.Retention;
|
| | | import java.lang.annotation.RetentionPolicy;
|
| | | import java.lang.annotation.Target;
|
| | |
|
| | | /**
|
| | | * Excel注解é
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @Target(ElementType.FIELD)
|
| | | @Retention(RetentionPolicy.RUNTIME)
|
| | | public @interface Excels
|
| | | {
|
| | | Excel[] value();
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Log.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.aspectj.lang.annotation;
|
| | | package com.ruoyi.common.annotation;
|
| | |
|
| | | import java.lang.annotation.Documented;
|
| | | import java.lang.annotation.ElementType;
|
| | | import java.lang.annotation.Retention;
|
| | | import java.lang.annotation.RetentionPolicy;
|
| | | import java.lang.annotation.Target;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.OperatorType;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.enums.OperatorType;
|
| | |
|
| | | /**
|
| | | * èªå®ä¹æä½æ¥å¿è®°å½æ³¨è§£
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/interceptor/annotation/RepeatSubmit.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.interceptor.annotation; |
| | | |
| | | import java.lang.annotation.Documented; |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Inherited; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * èªå®ä¹æ³¨è§£é²æ¢è¡¨åéå¤æäº¤ |
| | | * |
| | | * @author ruoyi |
| | | * |
| | | */ |
| | | @Inherited |
| | | @Target(ElementType.METHOD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | public @interface RepeatSubmit |
| | | { |
| | | |
| | | } |
| | | package com.ruoyi.common.annotation;
|
| | |
|
| | | import java.lang.annotation.Documented;
|
| | | import java.lang.annotation.ElementType;
|
| | | import java.lang.annotation.Inherited;
|
| | | import java.lang.annotation.Retention;
|
| | | import java.lang.annotation.RetentionPolicy;
|
| | | import java.lang.annotation.Target;
|
| | |
|
| | | /**
|
| | | * èªå®ä¹æ³¨è§£é²æ¢è¡¨åéå¤æäº¤
|
| | | * |
| | | * @author ruoyi
|
| | | *
|
| | | */
|
| | | @Inherited
|
| | | @Target(ElementType.METHOD)
|
| | | @Retention(RetentionPolicy.RUNTIME)
|
| | | @Documented
|
| | | public @interface RepeatSubmit
|
| | | {
|
| | |
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/config/RuoYiConfig.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.config;
|
| | | package com.ruoyi.common.config;
|
| | |
|
| | | import org.springframework.boot.context.properties.ConfigurationProperties;
|
| | | import org.springframework.stereotype.Component;
|
| | |
| | | {
|
| | | return getProfile() + "/upload";
|
| | | }
|
| | | } |
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.constant;
|
| | |
|
| | | import io.jsonwebtoken.Claims;
|
| | |
|
| | | /**
|
| | | * éç¨å¸¸éä¿¡æ¯
|
| | | *
|
| | |
| | | /**
|
| | | * ç¨æ·åç§°
|
| | | */
|
| | | public static final String JWT_USERNAME = Claims.SUBJECT;
|
| | | public static final String JWT_USERNAME = "sub";
|
| | |
|
| | | /**
|
| | | * ç¨æ·å¤´å
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.constant; |
| | | |
| | | /** |
| | | * ä»»å¡è°åº¦éç¨å¸¸é |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class ScheduleConstants |
| | | { |
| | | public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME"; |
| | | |
| | | /** æ§è¡ç®æ key */ |
| | | public static final String TASK_PROPERTIES = "TASK_PROPERTIES"; |
| | | |
| | | /** é»è®¤ */ |
| | | public static final String MISFIRE_DEFAULT = "0"; |
| | | |
| | | /** ç«å³è§¦åæ§è¡ */ |
| | | public static final String MISFIRE_IGNORE_MISFIRES = "1"; |
| | | |
| | | /** 触å䏿¬¡æ§è¡ */ |
| | | public static final String MISFIRE_FIRE_AND_PROCEED = "2"; |
| | | |
| | | /** ä¸è§¦åç«å³æ§è¡ */ |
| | | public static final String MISFIRE_DO_NOTHING = "3"; |
| | | |
| | | public enum Status |
| | | { |
| | | /** |
| | | * æ£å¸¸ |
| | | */ |
| | | NORMAL("0"), |
| | | /** |
| | | * æå |
| | | */ |
| | | PAUSE("1"); |
| | | |
| | | private String value; |
| | | |
| | | private Status(String value) |
| | | { |
| | | this.value = value; |
| | | } |
| | | |
| | | public String getValue() |
| | | { |
| | | return value; |
| | | } |
| | | } |
| | | } |
| | | package com.ruoyi.common.constant;
|
| | |
|
| | | /**
|
| | | * ä»»å¡è°åº¦éç¨å¸¸é
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class ScheduleConstants
|
| | | {
|
| | | public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME";
|
| | |
|
| | | /** æ§è¡ç®æ key */
|
| | | public static final String TASK_PROPERTIES = "TASK_PROPERTIES";
|
| | |
|
| | | /** é»è®¤ */
|
| | | public static final String MISFIRE_DEFAULT = "0";
|
| | |
|
| | | /** ç«å³è§¦åæ§è¡ */
|
| | | public static final String MISFIRE_IGNORE_MISFIRES = "1";
|
| | |
|
| | | /** 触å䏿¬¡æ§è¡ */
|
| | | public static final String MISFIRE_FIRE_AND_PROCEED = "2";
|
| | |
|
| | | /** ä¸è§¦åç«å³æ§è¡ */
|
| | | public static final String MISFIRE_DO_NOTHING = "3";
|
| | |
|
| | | public enum Status
|
| | | {
|
| | | /**
|
| | | * æ£å¸¸
|
| | | */
|
| | | NORMAL("0"),
|
| | | /**
|
| | | * æå
|
| | | */
|
| | | PAUSE("1");
|
| | |
|
| | | private String value;
|
| | |
|
| | | private Status(String value)
|
| | | {
|
| | | this.value = value;
|
| | | }
|
| | |
|
| | | public String getValue()
|
| | | {
|
| | | return value;
|
| | | }
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/web/controller/BaseController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.web.controller;
|
| | | package com.ruoyi.common.core.controller;
|
| | |
|
| | | import java.beans.PropertyEditorSupport;
|
| | | import java.util.Date;
|
| | |
| | | import com.github.pagehelper.PageHelper;
|
| | | import com.github.pagehelper.PageInfo;
|
| | | import com.ruoyi.common.constant.HttpStatus;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.page.PageDomain;
|
| | | import com.ruoyi.common.core.page.TableDataInfo;
|
| | | import com.ruoyi.common.core.page.TableSupport;
|
| | | import com.ruoyi.common.utils.DateUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.sql.SqlUtil;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.page.PageDomain;
|
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | import com.ruoyi.framework.web.page.TableSupport;
|
| | |
|
| | | /**
|
| | | * webå±éç¨æ°æ®å¤ç
|
| | |
| | | {
|
| | | return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 页é¢è·³è½¬
|
| | | */
|
| | | public String redirect(String url)
|
| | | {
|
| | | return StringUtils.format("redirect:{}", url);
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/web/domain/AjaxResult.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.web.domain;
|
| | | package com.ruoyi.common.core.domain;
|
| | |
|
| | | import java.util.HashMap;
|
| | | import com.ruoyi.common.constant.HttpStatus;
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/web/domain/BaseEntity.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.web.domain;
|
| | | package com.ruoyi.common.core.domain;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.util.Date;
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/web/domain/TreeEntity.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.web.domain;
|
| | | package com.ruoyi.common.core.domain;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/web/domain/TreeSelect.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.web.domain;
|
| | | package com.ruoyi.common.core.domain;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.util.List;
|
| | | import java.util.stream.Collectors;
|
| | | import com.fasterxml.jackson.annotation.JsonInclude;
|
| | | import com.ruoyi.project.system.domain.SysDept;
|
| | | import com.ruoyi.project.system.domain.SysMenu;
|
| | | import com.ruoyi.common.core.domain.entity.SysDept;
|
| | | import com.ruoyi.common.core.domain.entity.SysMenu;
|
| | |
|
| | | /**
|
| | | * Treeselectæ ç»æå®ä½ç±»
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDept.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.domain;
|
| | | package com.ruoyi.common.core.domain.entity;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
| | | import javax.validation.constraints.Size;
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | |
|
| | | /**
|
| | | * é¨é¨è¡¨ sys_dept
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDictData.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.domain;
|
| | | package com.ruoyi.common.core.domain.entity;
|
| | |
|
| | | import javax.validation.constraints.NotBlank;
|
| | | import javax.validation.constraints.Size;
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
| | | import com.ruoyi.common.annotation.Excel;
|
| | | import com.ruoyi.common.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | |
|
| | | /**
|
| | | * åå
¸æ°æ®è¡¨ sys_dict_data
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDictType.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.domain;
|
| | | package com.ruoyi.common.core.domain.entity;
|
| | |
|
| | | import javax.validation.constraints.NotBlank;
|
| | | import javax.validation.constraints.Size;
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | | import com.ruoyi.common.annotation.Excel;
|
| | | import com.ruoyi.common.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | |
|
| | | /**
|
| | | * åå
¸ç±»å表 sys_dict_type
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/domain/SysMenu.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.domain;
|
| | | package com.ruoyi.common.core.domain.entity;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
| | | import javax.validation.constraints.Size;
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | |
|
| | | /**
|
| | | * èåæé表 sys_menu
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/domain/SysRole.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.domain;
|
| | | package com.ruoyi.common.core.domain.entity;
|
| | |
|
| | | import javax.validation.constraints.NotBlank;
|
| | | import javax.validation.constraints.Size;
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | | import com.ruoyi.common.annotation.Excel;
|
| | | import com.ruoyi.common.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | |
|
| | | /**
|
| | | * è§è²è¡¨ sys_role
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/domain/SysUser.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.domain;
|
| | | package com.ruoyi.common.core.domain.entity;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
| | | import com.fasterxml.jackson.annotation.JsonIgnore;
|
| | | import com.fasterxml.jackson.annotation.JsonProperty;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel.Type;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excels;
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | | import com.ruoyi.common.annotation.Excel;
|
| | | import com.ruoyi.common.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.common.annotation.Excel.Type;
|
| | | import com.ruoyi.common.annotation.Excels;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | |
|
| | | /**
|
| | | * ç¨æ·å¯¹è±¡ sys_user
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/security/LoginBody.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.security;
|
| | | package com.ruoyi.common.core.domain.model;
|
| | |
|
| | | /**
|
| | | * ç¨æ·ç»å½å¯¹è±¡
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/security/LoginUser.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.security;
|
| | | package com.ruoyi.common.core.domain.model;
|
| | |
|
| | | import java.util.Collection;
|
| | | import java.util.Set;
|
| | | import org.springframework.security.core.GrantedAuthority;
|
| | | import org.springframework.security.core.userdetails.UserDetails;
|
| | | import com.fasterxml.jackson.annotation.JsonIgnore;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.common.core.domain.entity.SysUser;
|
| | |
|
| | | /**
|
| | | * ç»å½ç¨æ·èº«ä»½æé
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/web/page/PageDomain.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.web.page;
|
| | | package com.ruoyi.common.core.page;
|
| | |
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | |
|
| | |
| | | {
|
| | | /** å½åè®°å½èµ·å§ç´¢å¼ */
|
| | | private Integer pageNum;
|
| | |
|
| | | /** æ¯é¡µæ¾ç¤ºè®°å½æ° */
|
| | | private Integer pageSize;
|
| | |
|
| | | /** æåºå */
|
| | | private String orderByColumn;
|
| | |
|
| | | /** æåºçæ¹å "desc" æè
"asc". */
|
| | | private String isAsc;
|
| | |
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/web/page/TableDataInfo.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.web.page;
|
| | | package com.ruoyi.common.core.page;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.util.List;
|
| | |
| | | {
|
| | | this.msg = msg;
|
| | | }
|
| | | } |
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/web/page/TableSupport.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.web.page;
|
| | | package com.ruoyi.common.core.page;
|
| | |
|
| | | import com.ruoyi.common.utils.ServletUtils;
|
| | |
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/redis/RedisCache.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.redis;
|
| | | package com.ruoyi.common.core.redis;
|
| | |
|
| | | import java.util.Collection;
|
| | | import java.util.List;
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/BusinessStatus.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.aspectj.lang.enums;
|
| | | package com.ruoyi.common.enums;
|
| | |
|
| | | /**
|
| | | * æä½ç¶æ
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/BusinessType.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.aspectj.lang.enums;
|
| | | package com.ruoyi.common.enums;
|
| | |
|
| | | /**
|
| | | * ä¸å¡æä½ç±»å
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/DataSourceType.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.aspectj.lang.enums;
|
| | | package com.ruoyi.common.enums;
|
| | |
|
| | | /**
|
| | | * æ°æ®æº
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/OperatorType.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.aspectj.lang.enums;
|
| | | package com.ruoyi.common.enums;
|
| | |
|
| | | /**
|
| | | * æä½äººç±»å«
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/exception/job/TaskException.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.exception.job; |
| | | |
| | | /** |
| | | * 计åçç¥å¼å¸¸ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class TaskException extends Exception |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private Code code; |
| | | |
| | | public TaskException(String msg, Code code) |
| | | { |
| | | this(msg, code, null); |
| | | } |
| | | |
| | | public TaskException(String msg, Code code, Exception nestedEx) |
| | | { |
| | | super(msg, nestedEx); |
| | | this.code = code; |
| | | } |
| | | |
| | | public Code getCode() |
| | | { |
| | | return code; |
| | | } |
| | | |
| | | public enum Code |
| | | { |
| | | TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE |
| | | } |
| | | package com.ruoyi.common.exception.job;
|
| | |
|
| | | /**
|
| | | * 计åçç¥å¼å¸¸
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class TaskException extends Exception
|
| | | {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | private Code code;
|
| | |
|
| | | public TaskException(String msg, Code code)
|
| | | {
|
| | | this(msg, code, null);
|
| | | }
|
| | |
|
| | | public TaskException(String msg, Code code, Exception nestedEx)
|
| | | {
|
| | | super(msg, nestedEx);
|
| | | this.code = code;
|
| | | }
|
| | |
|
| | | public Code getCode()
|
| | | {
|
| | | return code;
|
| | | }
|
| | |
|
| | | public enum Code
|
| | | {
|
| | | TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE
|
| | | }
|
| | | } |
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.filter; |
| | | |
| | | import java.io.IOException; |
| | | import javax.servlet.Filter; |
| | | import javax.servlet.FilterChain; |
| | | import javax.servlet.FilterConfig; |
| | | import javax.servlet.ServletException; |
| | | import javax.servlet.ServletRequest; |
| | | import javax.servlet.ServletResponse; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import org.springframework.http.MediaType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | /** |
| | | * Repeatable è¿æ»¤å¨ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class RepeatableFilter implements Filter |
| | | { |
| | | @Override |
| | | public void init(FilterConfig filterConfig) throws ServletException |
| | | { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) |
| | | throws IOException, ServletException |
| | | { |
| | | ServletRequest requestWrapper = null; |
| | | if (request instanceof HttpServletRequest && StringUtils.equalsAnyIgnoreCase(request.getContentType(), |
| | | MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_UTF8_VALUE)) |
| | | { |
| | | requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response); |
| | | } |
| | | if (null == requestWrapper) |
| | | { |
| | | chain.doFilter(request, response); |
| | | } |
| | | else |
| | | { |
| | | chain.doFilter(requestWrapper, response); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void destroy() |
| | | { |
| | | |
| | | } |
| | | } |
| | | package com.ruoyi.common.filter;
|
| | |
|
| | | import java.io.IOException;
|
| | | import javax.servlet.Filter;
|
| | | import javax.servlet.FilterChain;
|
| | | import javax.servlet.FilterConfig;
|
| | | import javax.servlet.ServletException;
|
| | | import javax.servlet.ServletRequest;
|
| | | import javax.servlet.ServletResponse;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import org.springframework.http.MediaType;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | |
|
| | | /**
|
| | | * Repeatable è¿æ»¤å¨
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class RepeatableFilter implements Filter
|
| | | {
|
| | | @Override
|
| | | public void init(FilterConfig filterConfig) throws ServletException
|
| | | {
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
| | | throws IOException, ServletException
|
| | | {
|
| | | ServletRequest requestWrapper = null;
|
| | | if (request instanceof HttpServletRequest && StringUtils.equalsAnyIgnoreCase(request.getContentType(),
|
| | | MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_UTF8_VALUE))
|
| | | {
|
| | | requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response);
|
| | | }
|
| | | if (null == requestWrapper)
|
| | | {
|
| | | chain.doFilter(request, response);
|
| | | }
|
| | | else
|
| | | {
|
| | | chain.doFilter(requestWrapper, response);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void destroy()
|
| | | {
|
| | |
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.filter; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import javax.servlet.ReadListener; |
| | | import javax.servlet.ServletInputStream; |
| | | import javax.servlet.ServletResponse; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletRequestWrapper; |
| | | import com.ruoyi.common.utils.http.HttpHelper; |
| | | |
| | | /** |
| | | * æå»ºå¯éå¤è¯»åinputStreamçrequest |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper |
| | | { |
| | | private final byte[] body; |
| | | |
| | | public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException |
| | | { |
| | | super(request); |
| | | request.setCharacterEncoding("UTF-8"); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | |
| | | body = HttpHelper.getBodyString(request).getBytes("UTF-8"); |
| | | } |
| | | |
| | | @Override |
| | | public BufferedReader getReader() throws IOException |
| | | { |
| | | return new BufferedReader(new InputStreamReader(getInputStream())); |
| | | } |
| | | |
| | | @Override |
| | | public ServletInputStream getInputStream() throws IOException |
| | | { |
| | | |
| | | final ByteArrayInputStream bais = new ByteArrayInputStream(body); |
| | | |
| | | return new ServletInputStream() |
| | | { |
| | | |
| | | @Override |
| | | public int read() throws IOException |
| | | { |
| | | return bais.read(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean isFinished() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isReady() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public void setReadListener(ReadListener readListener) |
| | | { |
| | | |
| | | } |
| | | }; |
| | | } |
| | | } |
| | | package com.ruoyi.common.filter;
|
| | |
|
| | | import java.io.BufferedReader;
|
| | | import java.io.ByteArrayInputStream;
|
| | | import java.io.IOException;
|
| | | import java.io.InputStreamReader;
|
| | | import javax.servlet.ReadListener;
|
| | | import javax.servlet.ServletInputStream;
|
| | | import javax.servlet.ServletResponse;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletRequestWrapper;
|
| | | import com.ruoyi.common.utils.http.HttpHelper;
|
| | |
|
| | | /**
|
| | | * æå»ºå¯éå¤è¯»åinputStreamçrequest
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper
|
| | | {
|
| | | private final byte[] body;
|
| | |
|
| | | public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException
|
| | | {
|
| | | super(request);
|
| | | request.setCharacterEncoding("UTF-8");
|
| | | response.setCharacterEncoding("UTF-8");
|
| | |
|
| | | body = HttpHelper.getBodyString(request).getBytes("UTF-8");
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BufferedReader getReader() throws IOException
|
| | | {
|
| | | return new BufferedReader(new InputStreamReader(getInputStream()));
|
| | | }
|
| | |
|
| | | @Override
|
| | | public ServletInputStream getInputStream() throws IOException
|
| | | {
|
| | |
|
| | | final ByteArrayInputStream bais = new ByteArrayInputStream(body);
|
| | |
|
| | | return new ServletInputStream()
|
| | | {
|
| | |
|
| | | @Override
|
| | | public int read() throws IOException
|
| | | {
|
| | | return bais.read();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean isFinished()
|
| | | {
|
| | | return false;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean isReady()
|
| | | {
|
| | | return false;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void setReadListener(ReadListener readListener)
|
| | | {
|
| | |
|
| | | }
|
| | | };
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/DictUtils.java ÐÞ¸Ä |
| | |
| | |
|
| | | import java.util.Collection;
|
| | | import java.util.List;
|
| | |
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.core.domain.entity.SysDictData;
|
| | | import com.ruoyi.common.core.redis.RedisCache;
|
| | | import com.ruoyi.common.utils.spring.SpringUtils;
|
| | | import com.ruoyi.framework.redis.RedisCache;
|
| | | import com.ruoyi.project.system.domain.SysDictData;
|
| | |
|
| | | /**
|
| | | * åå
¸å·¥å
·ç±»
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.io.StringWriter; |
| | | import org.apache.commons.lang3.exception.ExceptionUtils; |
| | | |
| | | /** |
| | | * é误信æ¯å¤çç±»ã |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class ExceptionUtil |
| | | { |
| | | /** |
| | | * è·åexceptionç详ç»é误信æ¯ã |
| | | */ |
| | | public static String getExceptionMessage(Throwable e) |
| | | { |
| | | StringWriter sw = new StringWriter(); |
| | | e.printStackTrace(new PrintWriter(sw, true)); |
| | | String str = sw.toString(); |
| | | return str; |
| | | } |
| | | |
| | | public static String getRootErrorMseeage(Exception e) |
| | | { |
| | | Throwable root = ExceptionUtils.getRootCause(e); |
| | | root = (root == null ? e : root); |
| | | if (root == null) |
| | | { |
| | | return ""; |
| | | } |
| | | String msg = root.getMessage(); |
| | | if (msg == null) |
| | | { |
| | | return "null"; |
| | | } |
| | | return StringUtils.defaultString(msg); |
| | | } |
| | | } |
| | | package com.ruoyi.common.utils;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.io.StringWriter;
|
| | | import org.apache.commons.lang3.exception.ExceptionUtils;
|
| | |
|
| | | /**
|
| | | * é误信æ¯å¤çç±»ã
|
| | | *
|
| | | * @author ruoyi
|
| | | */
|
| | | public class ExceptionUtil
|
| | | {
|
| | | /**
|
| | | * è·åexceptionç详ç»é误信æ¯ã
|
| | | */
|
| | | public static String getExceptionMessage(Throwable e)
|
| | | {
|
| | | StringWriter sw = new StringWriter();
|
| | | e.printStackTrace(new PrintWriter(sw, true));
|
| | | String str = sw.toString();
|
| | | return str;
|
| | | }
|
| | |
|
| | | public static String getRootErrorMseeage(Exception e)
|
| | | {
|
| | | Throwable root = ExceptionUtils.getRootCause(e);
|
| | | root = (root == null ? e : root);
|
| | | if (root == null)
|
| | | {
|
| | | return "";
|
| | | }
|
| | | String msg = root.getMessage();
|
| | | if (msg == null)
|
| | | {
|
| | | return "null";
|
| | | }
|
| | | return StringUtils.defaultString(msg);
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/SecurityUtils.java ÐÞ¸Ä |
| | |
| | | import org.springframework.security.core.context.SecurityContextHolder;
|
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
| | | import com.ruoyi.common.constant.HttpStatus;
|
| | | import com.ruoyi.common.core.domain.model.LoginUser;
|
| | | import com.ruoyi.common.exception.CustomException;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | |
|
| | | /**
|
| | | * å®å
¨æå¡å·¥å
·ç±»
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.utils.bean; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * Bean å·¥å
·ç±» |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class BeanUtils extends org.springframework.beans.BeanUtils |
| | | { |
| | | /** Beanæ¹æ³åä¸å±æ§åå¼å§ç䏿 */ |
| | | private static final int BEAN_METHOD_PROP_INDEX = 3; |
| | | |
| | | /** * å¹é
getteræ¹æ³çæ£åè¡¨è¾¾å¼ */ |
| | | private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)"); |
| | | |
| | | /** * å¹é
setteræ¹æ³çæ£åè¡¨è¾¾å¼ */ |
| | | private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)"); |
| | | |
| | | /** |
| | | * Bean屿§å¤å¶å·¥å
·æ¹æ³ã |
| | | * |
| | | * @param dest ç®æ 对象 |
| | | * @param src æºå¯¹è±¡ |
| | | */ |
| | | public static void copyBeanProp(Object dest, Object src) |
| | | { |
| | | try |
| | | { |
| | | copyProperties(src, dest); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·å对象çsetteræ¹æ³ã |
| | | * |
| | | * @param obj 对象 |
| | | * @return 对象çsetteræ¹æ³å表 |
| | | */ |
| | | public static List<Method> getSetterMethods(Object obj) |
| | | { |
| | | // setteræ¹æ³å表 |
| | | List<Method> setterMethods = new ArrayList<Method>(); |
| | | |
| | | // è·åæææ¹æ³ |
| | | Method[] methods = obj.getClass().getMethods(); |
| | | |
| | | // æ¥æ¾setteræ¹æ³ |
| | | |
| | | for (Method method : methods) |
| | | { |
| | | Matcher m = SET_PATTERN.matcher(method.getName()); |
| | | if (m.matches() && (method.getParameterTypes().length == 1)) |
| | | { |
| | | setterMethods.add(method); |
| | | } |
| | | } |
| | | // è¿åsetteræ¹æ³å表 |
| | | return setterMethods; |
| | | } |
| | | |
| | | /** |
| | | * è·å对象çgetteræ¹æ³ã |
| | | * |
| | | * @param obj 对象 |
| | | * @return 对象çgetteræ¹æ³å表 |
| | | */ |
| | | |
| | | public static List<Method> getGetterMethods(Object obj) |
| | | { |
| | | // getteræ¹æ³å表 |
| | | List<Method> getterMethods = new ArrayList<Method>(); |
| | | // è·åæææ¹æ³ |
| | | Method[] methods = obj.getClass().getMethods(); |
| | | // æ¥æ¾getteræ¹æ³ |
| | | for (Method method : methods) |
| | | { |
| | | Matcher m = GET_PATTERN.matcher(method.getName()); |
| | | if (m.matches() && (method.getParameterTypes().length == 0)) |
| | | { |
| | | getterMethods.add(method); |
| | | } |
| | | } |
| | | // è¿ågetteræ¹æ³å表 |
| | | return getterMethods; |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥Beanæ¹æ³åä¸ç屿§åæ¯å¦ç¸çã<br> |
| | | * å¦getName()åsetName()屿§å䏿 ·ï¼getName()åsetAge()屿§åä¸ä¸æ ·ã |
| | | * |
| | | * @param m1 æ¹æ³å1 |
| | | * @param m2 æ¹æ³å2 |
| | | * @return 屿§å䏿 ·è¿åtrueï¼å¦åè¿åfalse |
| | | */ |
| | | |
| | | public static boolean isMethodPropEquals(String m1, String m2) |
| | | { |
| | | return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX)); |
| | | } |
| | | } |
| | | package com.ruoyi.common.utils.bean;
|
| | |
|
| | | import java.lang.reflect.Method;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.regex.Matcher;
|
| | | import java.util.regex.Pattern;
|
| | |
|
| | | /**
|
| | | * Bean å·¥å
·ç±»
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class BeanUtils extends org.springframework.beans.BeanUtils
|
| | | {
|
| | | /** Beanæ¹æ³åä¸å±æ§åå¼å§ç䏿 */
|
| | | private static final int BEAN_METHOD_PROP_INDEX = 3;
|
| | |
|
| | | /** * å¹é
getteræ¹æ³çæ£åè¡¨è¾¾å¼ */
|
| | | private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)");
|
| | |
|
| | | /** * å¹é
setteræ¹æ³çæ£åè¡¨è¾¾å¼ */
|
| | | private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)");
|
| | |
|
| | | /**
|
| | | * Bean屿§å¤å¶å·¥å
·æ¹æ³ã
|
| | | * |
| | | * @param dest ç®æ 对象
|
| | | * @param src æºå¯¹è±¡
|
| | | */
|
| | | public static void copyBeanProp(Object dest, Object src)
|
| | | {
|
| | | try
|
| | | {
|
| | | copyProperties(src, dest);
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·å对象çsetteræ¹æ³ã
|
| | | * |
| | | * @param obj 对象
|
| | | * @return 对象çsetteræ¹æ³å表
|
| | | */
|
| | | public static List<Method> getSetterMethods(Object obj)
|
| | | {
|
| | | // setteræ¹æ³å表
|
| | | List<Method> setterMethods = new ArrayList<Method>();
|
| | |
|
| | | // è·åæææ¹æ³
|
| | | Method[] methods = obj.getClass().getMethods();
|
| | |
|
| | | // æ¥æ¾setteræ¹æ³
|
| | |
|
| | | for (Method method : methods)
|
| | | {
|
| | | Matcher m = SET_PATTERN.matcher(method.getName());
|
| | | if (m.matches() && (method.getParameterTypes().length == 1))
|
| | | {
|
| | | setterMethods.add(method);
|
| | | }
|
| | | }
|
| | | // è¿åsetteræ¹æ³å表
|
| | | return setterMethods;
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·å对象çgetteræ¹æ³ã
|
| | | * |
| | | * @param obj 对象
|
| | | * @return 对象çgetteræ¹æ³å表
|
| | | */
|
| | |
|
| | | public static List<Method> getGetterMethods(Object obj)
|
| | | {
|
| | | // getteræ¹æ³å表
|
| | | List<Method> getterMethods = new ArrayList<Method>();
|
| | | // è·åæææ¹æ³
|
| | | Method[] methods = obj.getClass().getMethods();
|
| | | // æ¥æ¾getteræ¹æ³
|
| | | for (Method method : methods)
|
| | | {
|
| | | Matcher m = GET_PATTERN.matcher(method.getName());
|
| | | if (m.matches() && (method.getParameterTypes().length == 0))
|
| | | {
|
| | | getterMethods.add(method);
|
| | | }
|
| | | }
|
| | | // è¿ågetteræ¹æ³å表
|
| | | return getterMethods;
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ£æ¥Beanæ¹æ³åä¸ç屿§åæ¯å¦ç¸çã<br>
|
| | | * å¦getName()åsetName()屿§å䏿 ·ï¼getName()åsetAge()屿§åä¸ä¸æ ·ã
|
| | | * |
| | | * @param m1 æ¹æ³å1
|
| | | * @param m2 æ¹æ³å2
|
| | | * @return 屿§å䏿 ·è¿åtrueï¼å¦åè¿åfalse
|
| | | */
|
| | |
|
| | | public static boolean isMethodPropEquals(String m1, String m2)
|
| | | {
|
| | | return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX));
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java ÐÞ¸Ä |
| | |
| | | import java.io.IOException;
|
| | | import org.apache.commons.io.FilenameUtils;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import com.ruoyi.common.config.RuoYiConfig;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException;
|
| | | import com.ruoyi.common.exception.file.FileSizeLimitExceededException;
|
| | | import com.ruoyi.common.exception.file.InvalidExtensionException;
|
| | | import com.ruoyi.common.utils.DateUtils;
|
| | | import com.ruoyi.common.utils.IdUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.config.RuoYiConfig;
|
| | | import com.ruoyi.common.utils.uuid.IdUtils;
|
| | |
|
| | | /**
|
| | | * æä»¶ä¸ä¼ å·¥å
·ç±»
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.utils.html; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.ConcurrentMap; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * HTMLè¿æ»¤å¨ï¼ç¨äºå»é¤XSSæ¼æ´éæ£ã |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public final class HTMLFilter |
| | | { |
| | | /** |
| | | * regex flag union representing /si modifiers in php |
| | | **/ |
| | | private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL; |
| | | private static final Pattern P_COMMENTS = Pattern.compile("<!--(.*?)-->", Pattern.DOTALL); |
| | | private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI); |
| | | private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL); |
| | | private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI); |
| | | private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI); |
| | | private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI); |
| | | private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI); |
| | | private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI); |
| | | private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?"); |
| | | private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?"); |
| | | private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?"); |
| | | private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))"); |
| | | private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL); |
| | | private static final Pattern P_END_ARROW = Pattern.compile("^>"); |
| | | private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)"); |
| | | private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)"); |
| | | private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)"); |
| | | private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)"); |
| | | private static final Pattern P_AMP = Pattern.compile("&"); |
| | | private static final Pattern P_QUOTE = Pattern.compile("\""); |
| | | private static final Pattern P_LEFT_ARROW = Pattern.compile("<"); |
| | | private static final Pattern P_RIGHT_ARROW = Pattern.compile(">"); |
| | | private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>"); |
| | | |
| | | // @xxx could grow large... maybe use sesat's ReferenceMap |
| | | private static final ConcurrentMap<String, Pattern> P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<>(); |
| | | private static final ConcurrentMap<String, Pattern> P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<>(); |
| | | |
| | | /** |
| | | * set of allowed html elements, along with allowed attributes for each element |
| | | **/ |
| | | private final Map<String, List<String>> vAllowed; |
| | | /** |
| | | * counts of open tags for each (allowable) html element |
| | | **/ |
| | | private final Map<String, Integer> vTagCounts = new HashMap<>(); |
| | | |
| | | /** |
| | | * html elements which must always be self-closing (e.g. "<img />") |
| | | **/ |
| | | private final String[] vSelfClosingTags; |
| | | /** |
| | | * html elements which must always have separate opening and closing tags (e.g. "<b></b>") |
| | | **/ |
| | | private final String[] vNeedClosingTags; |
| | | /** |
| | | * set of disallowed html elements |
| | | **/ |
| | | private final String[] vDisallowed; |
| | | /** |
| | | * attributes which should be checked for valid protocols |
| | | **/ |
| | | private final String[] vProtocolAtts; |
| | | /** |
| | | * allowed protocols |
| | | **/ |
| | | private final String[] vAllowedProtocols; |
| | | /** |
| | | * tags which should be removed if they contain no content (e.g. "<b></b>" or "<b />") |
| | | **/ |
| | | private final String[] vRemoveBlanks; |
| | | /** |
| | | * entities allowed within html markup |
| | | **/ |
| | | private final String[] vAllowedEntities; |
| | | /** |
| | | * flag determining whether comments are allowed in input String. |
| | | */ |
| | | private final boolean stripComment; |
| | | private final boolean encodeQuotes; |
| | | /** |
| | | * flag determining whether to try to make tags when presented with "unbalanced" angle brackets (e.g. "<b text </b>" |
| | | * becomes "<b> text </b>"). If set to false, unbalanced angle brackets will be html escaped. |
| | | */ |
| | | private final boolean alwaysMakeTags; |
| | | |
| | | /** |
| | | * Default constructor. |
| | | */ |
| | | public HTMLFilter() |
| | | { |
| | | vAllowed = new HashMap<>(); |
| | | |
| | | final ArrayList<String> a_atts = new ArrayList<>(); |
| | | a_atts.add("href"); |
| | | a_atts.add("target"); |
| | | vAllowed.put("a", a_atts); |
| | | |
| | | final ArrayList<String> img_atts = new ArrayList<>(); |
| | | img_atts.add("src"); |
| | | img_atts.add("width"); |
| | | img_atts.add("height"); |
| | | img_atts.add("alt"); |
| | | vAllowed.put("img", img_atts); |
| | | |
| | | final ArrayList<String> no_atts = new ArrayList<>(); |
| | | vAllowed.put("b", no_atts); |
| | | vAllowed.put("strong", no_atts); |
| | | vAllowed.put("i", no_atts); |
| | | vAllowed.put("em", no_atts); |
| | | |
| | | vSelfClosingTags = new String[] { "img" }; |
| | | vNeedClosingTags = new String[] { "a", "b", "strong", "i", "em" }; |
| | | vDisallowed = new String[] {}; |
| | | vAllowedProtocols = new String[] { "http", "mailto", "https" }; // no ftp. |
| | | vProtocolAtts = new String[] { "src", "href" }; |
| | | vRemoveBlanks = new String[] { "a", "b", "strong", "i", "em" }; |
| | | vAllowedEntities = new String[] { "amp", "gt", "lt", "quot" }; |
| | | stripComment = true; |
| | | encodeQuotes = true; |
| | | alwaysMakeTags = true; |
| | | } |
| | | |
| | | /** |
| | | * Map-parameter configurable constructor. |
| | | * |
| | | * @param conf map containing configuration. keys match field names. |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public HTMLFilter(final Map<String, Object> conf) |
| | | { |
| | | |
| | | assert conf.containsKey("vAllowed") : "configuration requires vAllowed"; |
| | | assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags"; |
| | | assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags"; |
| | | assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed"; |
| | | assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols"; |
| | | assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts"; |
| | | assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks"; |
| | | assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities"; |
| | | |
| | | vAllowed = Collections.unmodifiableMap((HashMap<String, List<String>>) conf.get("vAllowed")); |
| | | vSelfClosingTags = (String[]) conf.get("vSelfClosingTags"); |
| | | vNeedClosingTags = (String[]) conf.get("vNeedClosingTags"); |
| | | vDisallowed = (String[]) conf.get("vDisallowed"); |
| | | vAllowedProtocols = (String[]) conf.get("vAllowedProtocols"); |
| | | vProtocolAtts = (String[]) conf.get("vProtocolAtts"); |
| | | vRemoveBlanks = (String[]) conf.get("vRemoveBlanks"); |
| | | vAllowedEntities = (String[]) conf.get("vAllowedEntities"); |
| | | stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true; |
| | | encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true; |
| | | alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true; |
| | | } |
| | | |
| | | private void reset() |
| | | { |
| | | vTagCounts.clear(); |
| | | } |
| | | |
| | | // --------------------------------------------------------------- |
| | | // my versions of some PHP library functions |
| | | public static String chr(final int decimal) |
| | | { |
| | | return String.valueOf((char) decimal); |
| | | } |
| | | |
| | | public static String htmlSpecialChars(final String s) |
| | | { |
| | | String result = s; |
| | | result = regexReplace(P_AMP, "&", result); |
| | | result = regexReplace(P_QUOTE, """, result); |
| | | result = regexReplace(P_LEFT_ARROW, "<", result); |
| | | result = regexReplace(P_RIGHT_ARROW, ">", result); |
| | | return result; |
| | | } |
| | | |
| | | // --------------------------------------------------------------- |
| | | |
| | | /** |
| | | * given a user submitted input String, filter out any invalid or restricted html. |
| | | * |
| | | * @param input text (i.e. submitted by a user) than may contain html |
| | | * @return "clean" version of input, with only valid, whitelisted html elements allowed |
| | | */ |
| | | public String filter(final String input) |
| | | { |
| | | reset(); |
| | | String s = input; |
| | | |
| | | s = escapeComments(s); |
| | | |
| | | s = balanceHTML(s); |
| | | |
| | | s = checkTags(s); |
| | | |
| | | s = processRemoveBlanks(s); |
| | | |
| | | s = validateEntities(s); |
| | | |
| | | return s; |
| | | } |
| | | |
| | | public boolean isAlwaysMakeTags() |
| | | { |
| | | return alwaysMakeTags; |
| | | } |
| | | |
| | | public boolean isStripComments() |
| | | { |
| | | return stripComment; |
| | | } |
| | | |
| | | private String escapeComments(final String s) |
| | | { |
| | | final Matcher m = P_COMMENTS.matcher(s); |
| | | final StringBuffer buf = new StringBuffer(); |
| | | if (m.find()) |
| | | { |
| | | final String match = m.group(1); // (.*?) |
| | | m.appendReplacement(buf, Matcher.quoteReplacement("<!--" + htmlSpecialChars(match) + "-->")); |
| | | } |
| | | m.appendTail(buf); |
| | | |
| | | return buf.toString(); |
| | | } |
| | | |
| | | private String balanceHTML(String s) |
| | | { |
| | | if (alwaysMakeTags) |
| | | { |
| | | // |
| | | // try and form html |
| | | // |
| | | s = regexReplace(P_END_ARROW, "", s); |
| | | s = regexReplace(P_BODY_TO_END, "<$1>", s); |
| | | s = regexReplace(P_XML_CONTENT, "$1<$2", s); |
| | | |
| | | } |
| | | else |
| | | { |
| | | // |
| | | // escape stray brackets |
| | | // |
| | | s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s); |
| | | s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s); |
| | | |
| | | // |
| | | // the last regexp causes '<>' entities to appear |
| | | // (we need to do a lookahead assertion so that the last bracket can |
| | | // be used in the next pass of the regexp) |
| | | // |
| | | s = regexReplace(P_BOTH_ARROWS, "", s); |
| | | } |
| | | |
| | | return s; |
| | | } |
| | | |
| | | private String checkTags(String s) |
| | | { |
| | | Matcher m = P_TAGS.matcher(s); |
| | | |
| | | final StringBuffer buf = new StringBuffer(); |
| | | while (m.find()) |
| | | { |
| | | String replaceStr = m.group(1); |
| | | replaceStr = processTag(replaceStr); |
| | | m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr)); |
| | | } |
| | | m.appendTail(buf); |
| | | |
| | | // these get tallied in processTag |
| | | // (remember to reset before subsequent calls to filter method) |
| | | final StringBuilder sBuilder = new StringBuilder(buf.toString()); |
| | | for (String key : vTagCounts.keySet()) |
| | | { |
| | | for (int ii = 0; ii < vTagCounts.get(key); ii++) |
| | | { |
| | | sBuilder.append("</").append(key).append(">"); |
| | | } |
| | | } |
| | | s = sBuilder.toString(); |
| | | |
| | | return s; |
| | | } |
| | | |
| | | private String processRemoveBlanks(final String s) |
| | | { |
| | | String result = s; |
| | | for (String tag : vRemoveBlanks) |
| | | { |
| | | if (!P_REMOVE_PAIR_BLANKS.containsKey(tag)) |
| | | { |
| | | P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?></" + tag + ">")); |
| | | } |
| | | result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result); |
| | | if (!P_REMOVE_SELF_BLANKS.containsKey(tag)) |
| | | { |
| | | P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>")); |
| | | } |
| | | result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) |
| | | { |
| | | Matcher m = regex_pattern.matcher(s); |
| | | return m.replaceAll(replacement); |
| | | } |
| | | |
| | | private String processTag(final String s) |
| | | { |
| | | // ending tags |
| | | Matcher m = P_END_TAG.matcher(s); |
| | | if (m.find()) |
| | | { |
| | | final String name = m.group(1).toLowerCase(); |
| | | if (allowed(name)) |
| | | { |
| | | if (false == inArray(name, vSelfClosingTags)) |
| | | { |
| | | if (vTagCounts.containsKey(name)) |
| | | { |
| | | vTagCounts.put(name, vTagCounts.get(name) - 1); |
| | | return "</" + name + ">"; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // starting tags |
| | | m = P_START_TAG.matcher(s); |
| | | if (m.find()) |
| | | { |
| | | final String name = m.group(1).toLowerCase(); |
| | | final String body = m.group(2); |
| | | String ending = m.group(3); |
| | | |
| | | // debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" ); |
| | | if (allowed(name)) |
| | | { |
| | | final StringBuilder params = new StringBuilder(); |
| | | |
| | | final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body); |
| | | final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body); |
| | | final List<String> paramNames = new ArrayList<>(); |
| | | final List<String> paramValues = new ArrayList<>(); |
| | | while (m2.find()) |
| | | { |
| | | paramNames.add(m2.group(1)); // ([a-z0-9]+) |
| | | paramValues.add(m2.group(3)); // (.*?) |
| | | } |
| | | while (m3.find()) |
| | | { |
| | | paramNames.add(m3.group(1)); // ([a-z0-9]+) |
| | | paramValues.add(m3.group(3)); // ([^\"\\s']+) |
| | | } |
| | | |
| | | String paramName, paramValue; |
| | | for (int ii = 0; ii < paramNames.size(); ii++) |
| | | { |
| | | paramName = paramNames.get(ii).toLowerCase(); |
| | | paramValue = paramValues.get(ii); |
| | | |
| | | // debug( "paramName='" + paramName + "'" ); |
| | | // debug( "paramValue='" + paramValue + "'" ); |
| | | // debug( "allowed? " + vAllowed.get( name ).contains( paramName ) ); |
| | | |
| | | if (allowedAttribute(name, paramName)) |
| | | { |
| | | if (inArray(paramName, vProtocolAtts)) |
| | | { |
| | | paramValue = processParamProtocol(paramValue); |
| | | } |
| | | params.append(' ').append(paramName).append("=\"").append(paramValue).append("\""); |
| | | } |
| | | } |
| | | |
| | | if (inArray(name, vSelfClosingTags)) |
| | | { |
| | | ending = " /"; |
| | | } |
| | | |
| | | if (inArray(name, vNeedClosingTags)) |
| | | { |
| | | ending = ""; |
| | | } |
| | | |
| | | if (ending == null || ending.length() < 1) |
| | | { |
| | | if (vTagCounts.containsKey(name)) |
| | | { |
| | | vTagCounts.put(name, vTagCounts.get(name) + 1); |
| | | } |
| | | else |
| | | { |
| | | vTagCounts.put(name, 1); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ending = " /"; |
| | | } |
| | | return "<" + name + params + ending + ">"; |
| | | } |
| | | else |
| | | { |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | // comments |
| | | m = P_COMMENT.matcher(s); |
| | | if (!stripComment && m.find()) |
| | | { |
| | | return "<" + m.group() + ">"; |
| | | } |
| | | |
| | | return ""; |
| | | } |
| | | |
| | | private String processParamProtocol(String s) |
| | | { |
| | | s = decodeEntities(s); |
| | | final Matcher m = P_PROTOCOL.matcher(s); |
| | | if (m.find()) |
| | | { |
| | | final String protocol = m.group(1); |
| | | if (!inArray(protocol, vAllowedProtocols)) |
| | | { |
| | | // bad protocol, turn into local anchor link instead |
| | | s = "#" + s.substring(protocol.length() + 1); |
| | | if (s.startsWith("#//")) |
| | | { |
| | | s = "#" + s.substring(3); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return s; |
| | | } |
| | | |
| | | private String decodeEntities(String s) |
| | | { |
| | | StringBuffer buf = new StringBuffer(); |
| | | |
| | | Matcher m = P_ENTITY.matcher(s); |
| | | while (m.find()) |
| | | { |
| | | final String match = m.group(1); |
| | | final int decimal = Integer.decode(match).intValue(); |
| | | m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); |
| | | } |
| | | m.appendTail(buf); |
| | | s = buf.toString(); |
| | | |
| | | buf = new StringBuffer(); |
| | | m = P_ENTITY_UNICODE.matcher(s); |
| | | while (m.find()) |
| | | { |
| | | final String match = m.group(1); |
| | | final int decimal = Integer.valueOf(match, 16).intValue(); |
| | | m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); |
| | | } |
| | | m.appendTail(buf); |
| | | s = buf.toString(); |
| | | |
| | | buf = new StringBuffer(); |
| | | m = P_ENCODE.matcher(s); |
| | | while (m.find()) |
| | | { |
| | | final String match = m.group(1); |
| | | final int decimal = Integer.valueOf(match, 16).intValue(); |
| | | m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); |
| | | } |
| | | m.appendTail(buf); |
| | | s = buf.toString(); |
| | | |
| | | s = validateEntities(s); |
| | | return s; |
| | | } |
| | | |
| | | private String validateEntities(final String s) |
| | | { |
| | | StringBuffer buf = new StringBuffer(); |
| | | |
| | | // validate entities throughout the string |
| | | Matcher m = P_VALID_ENTITIES.matcher(s); |
| | | while (m.find()) |
| | | { |
| | | final String one = m.group(1); // ([^&;]*) |
| | | final String two = m.group(2); // (?=(;|&|$)) |
| | | m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two))); |
| | | } |
| | | m.appendTail(buf); |
| | | |
| | | return encodeQuotes(buf.toString()); |
| | | } |
| | | |
| | | private String encodeQuotes(final String s) |
| | | { |
| | | if (encodeQuotes) |
| | | { |
| | | StringBuffer buf = new StringBuffer(); |
| | | Matcher m = P_VALID_QUOTES.matcher(s); |
| | | while (m.find()) |
| | | { |
| | | final String one = m.group(1); // (>|^) |
| | | final String two = m.group(2); // ([^<]+?) |
| | | final String three = m.group(3); // (<|$) |
| | | // 䏿¿æ¢åå¼å·ä¸º"ï¼é²æ¢jsonæ ¼å¼æ æ regexReplace(P_QUOTE, """, two) |
| | | m.appendReplacement(buf, Matcher.quoteReplacement(one + two + three)); |
| | | } |
| | | m.appendTail(buf); |
| | | return buf.toString(); |
| | | } |
| | | else |
| | | { |
| | | return s; |
| | | } |
| | | } |
| | | |
| | | private String checkEntity(final String preamble, final String term) |
| | | { |
| | | |
| | | return ";".equals(term) && isValidEntity(preamble) ? '&' + preamble : "&" + preamble; |
| | | } |
| | | |
| | | private boolean isValidEntity(final String entity) |
| | | { |
| | | return inArray(entity, vAllowedEntities); |
| | | } |
| | | |
| | | private static boolean inArray(final String s, final String[] array) |
| | | { |
| | | for (String item : array) |
| | | { |
| | | if (item != null && item.equals(s)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private boolean allowed(final String name) |
| | | { |
| | | return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed); |
| | | } |
| | | |
| | | private boolean allowedAttribute(final String name, final String paramName) |
| | | { |
| | | return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName)); |
| | | } |
| | | package com.ruoyi.common.utils.html;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collections;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.concurrent.ConcurrentHashMap;
|
| | | import java.util.concurrent.ConcurrentMap;
|
| | | import java.util.regex.Matcher;
|
| | | import java.util.regex.Pattern;
|
| | |
|
| | | /**
|
| | | * HTMLè¿æ»¤å¨ï¼ç¨äºå»é¤XSSæ¼æ´éæ£ã
|
| | | *
|
| | | * @author ruoyi
|
| | | */
|
| | | public final class HTMLFilter
|
| | | {
|
| | | /**
|
| | | * regex flag union representing /si modifiers in php
|
| | | **/
|
| | | private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL;
|
| | | private static final Pattern P_COMMENTS = Pattern.compile("<!--(.*?)-->", Pattern.DOTALL);
|
| | | private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI);
|
| | | private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL);
|
| | | private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI);
|
| | | private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI);
|
| | | private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI);
|
| | | private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI);
|
| | | private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI);
|
| | | private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?");
|
| | | private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?");
|
| | | private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?");
|
| | | private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))");
|
| | | private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL);
|
| | | private static final Pattern P_END_ARROW = Pattern.compile("^>");
|
| | | private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)");
|
| | | private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)");
|
| | | private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)");
|
| | | private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)");
|
| | | private static final Pattern P_AMP = Pattern.compile("&");
|
| | | private static final Pattern P_QUOTE = Pattern.compile("\"");
|
| | | private static final Pattern P_LEFT_ARROW = Pattern.compile("<");
|
| | | private static final Pattern P_RIGHT_ARROW = Pattern.compile(">");
|
| | | private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>");
|
| | |
|
| | | // @xxx could grow large... maybe use sesat's ReferenceMap
|
| | | private static final ConcurrentMap<String, Pattern> P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<>();
|
| | | private static final ConcurrentMap<String, Pattern> P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<>();
|
| | |
|
| | | /**
|
| | | * set of allowed html elements, along with allowed attributes for each element
|
| | | **/
|
| | | private final Map<String, List<String>> vAllowed;
|
| | | /**
|
| | | * counts of open tags for each (allowable) html element
|
| | | **/
|
| | | private final Map<String, Integer> vTagCounts = new HashMap<>();
|
| | |
|
| | | /**
|
| | | * html elements which must always be self-closing (e.g. "<img />")
|
| | | **/
|
| | | private final String[] vSelfClosingTags;
|
| | | /**
|
| | | * html elements which must always have separate opening and closing tags (e.g. "<b></b>")
|
| | | **/
|
| | | private final String[] vNeedClosingTags;
|
| | | /**
|
| | | * set of disallowed html elements
|
| | | **/
|
| | | private final String[] vDisallowed;
|
| | | /**
|
| | | * attributes which should be checked for valid protocols
|
| | | **/
|
| | | private final String[] vProtocolAtts;
|
| | | /**
|
| | | * allowed protocols
|
| | | **/
|
| | | private final String[] vAllowedProtocols;
|
| | | /**
|
| | | * tags which should be removed if they contain no content (e.g. "<b></b>" or "<b />")
|
| | | **/
|
| | | private final String[] vRemoveBlanks;
|
| | | /**
|
| | | * entities allowed within html markup
|
| | | **/
|
| | | private final String[] vAllowedEntities;
|
| | | /**
|
| | | * flag determining whether comments are allowed in input String.
|
| | | */
|
| | | private final boolean stripComment;
|
| | | private final boolean encodeQuotes;
|
| | | /**
|
| | | * flag determining whether to try to make tags when presented with "unbalanced" angle brackets (e.g. "<b text </b>"
|
| | | * becomes "<b> text </b>"). If set to false, unbalanced angle brackets will be html escaped.
|
| | | */
|
| | | private final boolean alwaysMakeTags;
|
| | |
|
| | | /**
|
| | | * Default constructor.
|
| | | */
|
| | | public HTMLFilter()
|
| | | {
|
| | | vAllowed = new HashMap<>();
|
| | |
|
| | | final ArrayList<String> a_atts = new ArrayList<>();
|
| | | a_atts.add("href");
|
| | | a_atts.add("target");
|
| | | vAllowed.put("a", a_atts);
|
| | |
|
| | | final ArrayList<String> img_atts = new ArrayList<>();
|
| | | img_atts.add("src");
|
| | | img_atts.add("width");
|
| | | img_atts.add("height");
|
| | | img_atts.add("alt");
|
| | | vAllowed.put("img", img_atts);
|
| | |
|
| | | final ArrayList<String> no_atts = new ArrayList<>();
|
| | | vAllowed.put("b", no_atts);
|
| | | vAllowed.put("strong", no_atts);
|
| | | vAllowed.put("i", no_atts);
|
| | | vAllowed.put("em", no_atts);
|
| | |
|
| | | vSelfClosingTags = new String[] { "img" };
|
| | | vNeedClosingTags = new String[] { "a", "b", "strong", "i", "em" };
|
| | | vDisallowed = new String[] {};
|
| | | vAllowedProtocols = new String[] { "http", "mailto", "https" }; // no ftp.
|
| | | vProtocolAtts = new String[] { "src", "href" };
|
| | | vRemoveBlanks = new String[] { "a", "b", "strong", "i", "em" };
|
| | | vAllowedEntities = new String[] { "amp", "gt", "lt", "quot" };
|
| | | stripComment = true;
|
| | | encodeQuotes = true;
|
| | | alwaysMakeTags = true;
|
| | | }
|
| | |
|
| | | /**
|
| | | * Map-parameter configurable constructor.
|
| | | *
|
| | | * @param conf map containing configuration. keys match field names.
|
| | | */
|
| | | @SuppressWarnings("unchecked")
|
| | | public HTMLFilter(final Map<String, Object> conf)
|
| | | {
|
| | |
|
| | | assert conf.containsKey("vAllowed") : "configuration requires vAllowed";
|
| | | assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags";
|
| | | assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags";
|
| | | assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed";
|
| | | assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols";
|
| | | assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts";
|
| | | assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks";
|
| | | assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities";
|
| | |
|
| | | vAllowed = Collections.unmodifiableMap((HashMap<String, List<String>>) conf.get("vAllowed"));
|
| | | vSelfClosingTags = (String[]) conf.get("vSelfClosingTags");
|
| | | vNeedClosingTags = (String[]) conf.get("vNeedClosingTags");
|
| | | vDisallowed = (String[]) conf.get("vDisallowed");
|
| | | vAllowedProtocols = (String[]) conf.get("vAllowedProtocols");
|
| | | vProtocolAtts = (String[]) conf.get("vProtocolAtts");
|
| | | vRemoveBlanks = (String[]) conf.get("vRemoveBlanks");
|
| | | vAllowedEntities = (String[]) conf.get("vAllowedEntities");
|
| | | stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true;
|
| | | encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true;
|
| | | alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true;
|
| | | }
|
| | |
|
| | | private void reset()
|
| | | {
|
| | | vTagCounts.clear();
|
| | | }
|
| | |
|
| | | // ---------------------------------------------------------------
|
| | | // my versions of some PHP library functions
|
| | | public static String chr(final int decimal)
|
| | | {
|
| | | return String.valueOf((char) decimal);
|
| | | }
|
| | |
|
| | | public static String htmlSpecialChars(final String s)
|
| | | {
|
| | | String result = s;
|
| | | result = regexReplace(P_AMP, "&", result);
|
| | | result = regexReplace(P_QUOTE, """, result);
|
| | | result = regexReplace(P_LEFT_ARROW, "<", result);
|
| | | result = regexReplace(P_RIGHT_ARROW, ">", result);
|
| | | return result;
|
| | | }
|
| | |
|
| | | // ---------------------------------------------------------------
|
| | |
|
| | | /**
|
| | | * given a user submitted input String, filter out any invalid or restricted html.
|
| | | *
|
| | | * @param input text (i.e. submitted by a user) than may contain html
|
| | | * @return "clean" version of input, with only valid, whitelisted html elements allowed
|
| | | */
|
| | | public String filter(final String input)
|
| | | {
|
| | | reset();
|
| | | String s = input;
|
| | |
|
| | | s = escapeComments(s);
|
| | |
|
| | | s = balanceHTML(s);
|
| | |
|
| | | s = checkTags(s);
|
| | |
|
| | | s = processRemoveBlanks(s);
|
| | |
|
| | | s = validateEntities(s);
|
| | |
|
| | | return s;
|
| | | }
|
| | |
|
| | | public boolean isAlwaysMakeTags()
|
| | | {
|
| | | return alwaysMakeTags;
|
| | | }
|
| | |
|
| | | public boolean isStripComments()
|
| | | {
|
| | | return stripComment;
|
| | | }
|
| | |
|
| | | private String escapeComments(final String s)
|
| | | {
|
| | | final Matcher m = P_COMMENTS.matcher(s);
|
| | | final StringBuffer buf = new StringBuffer();
|
| | | if (m.find())
|
| | | {
|
| | | final String match = m.group(1); // (.*?)
|
| | | m.appendReplacement(buf, Matcher.quoteReplacement("<!--" + htmlSpecialChars(match) + "-->"));
|
| | | }
|
| | | m.appendTail(buf);
|
| | |
|
| | | return buf.toString();
|
| | | }
|
| | |
|
| | | private String balanceHTML(String s)
|
| | | {
|
| | | if (alwaysMakeTags)
|
| | | {
|
| | | //
|
| | | // try and form html
|
| | | //
|
| | | s = regexReplace(P_END_ARROW, "", s);
|
| | | s = regexReplace(P_BODY_TO_END, "<$1>", s);
|
| | | s = regexReplace(P_XML_CONTENT, "$1<$2", s);
|
| | |
|
| | | }
|
| | | else
|
| | | {
|
| | | //
|
| | | // escape stray brackets
|
| | | //
|
| | | s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s);
|
| | | s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s);
|
| | |
|
| | | //
|
| | | // the last regexp causes '<>' entities to appear
|
| | | // (we need to do a lookahead assertion so that the last bracket can
|
| | | // be used in the next pass of the regexp)
|
| | | //
|
| | | s = regexReplace(P_BOTH_ARROWS, "", s);
|
| | | }
|
| | |
|
| | | return s;
|
| | | }
|
| | |
|
| | | private String checkTags(String s)
|
| | | {
|
| | | Matcher m = P_TAGS.matcher(s);
|
| | |
|
| | | final StringBuffer buf = new StringBuffer();
|
| | | while (m.find())
|
| | | {
|
| | | String replaceStr = m.group(1);
|
| | | replaceStr = processTag(replaceStr);
|
| | | m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr));
|
| | | }
|
| | | m.appendTail(buf);
|
| | |
|
| | | // these get tallied in processTag
|
| | | // (remember to reset before subsequent calls to filter method)
|
| | | final StringBuilder sBuilder = new StringBuilder(buf.toString());
|
| | | for (String key : vTagCounts.keySet())
|
| | | {
|
| | | for (int ii = 0; ii < vTagCounts.get(key); ii++)
|
| | | {
|
| | | sBuilder.append("</").append(key).append(">");
|
| | | }
|
| | | }
|
| | | s = sBuilder.toString();
|
| | |
|
| | | return s;
|
| | | }
|
| | |
|
| | | private String processRemoveBlanks(final String s)
|
| | | {
|
| | | String result = s;
|
| | | for (String tag : vRemoveBlanks)
|
| | | {
|
| | | if (!P_REMOVE_PAIR_BLANKS.containsKey(tag))
|
| | | {
|
| | | P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?></" + tag + ">"));
|
| | | }
|
| | | result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result);
|
| | | if (!P_REMOVE_SELF_BLANKS.containsKey(tag))
|
| | | {
|
| | | P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>"));
|
| | | }
|
| | | result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result);
|
| | | }
|
| | |
|
| | | return result;
|
| | | }
|
| | |
|
| | | private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s)
|
| | | {
|
| | | Matcher m = regex_pattern.matcher(s);
|
| | | return m.replaceAll(replacement);
|
| | | }
|
| | |
|
| | | private String processTag(final String s)
|
| | | {
|
| | | // ending tags
|
| | | Matcher m = P_END_TAG.matcher(s);
|
| | | if (m.find())
|
| | | {
|
| | | final String name = m.group(1).toLowerCase();
|
| | | if (allowed(name))
|
| | | {
|
| | | if (false == inArray(name, vSelfClosingTags))
|
| | | {
|
| | | if (vTagCounts.containsKey(name))
|
| | | {
|
| | | vTagCounts.put(name, vTagCounts.get(name) - 1);
|
| | | return "</" + name + ">";
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // starting tags
|
| | | m = P_START_TAG.matcher(s);
|
| | | if (m.find())
|
| | | {
|
| | | final String name = m.group(1).toLowerCase();
|
| | | final String body = m.group(2);
|
| | | String ending = m.group(3);
|
| | |
|
| | | // debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" );
|
| | | if (allowed(name))
|
| | | {
|
| | | final StringBuilder params = new StringBuilder();
|
| | |
|
| | | final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body);
|
| | | final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body);
|
| | | final List<String> paramNames = new ArrayList<>();
|
| | | final List<String> paramValues = new ArrayList<>();
|
| | | while (m2.find())
|
| | | {
|
| | | paramNames.add(m2.group(1)); // ([a-z0-9]+)
|
| | | paramValues.add(m2.group(3)); // (.*?)
|
| | | }
|
| | | while (m3.find())
|
| | | {
|
| | | paramNames.add(m3.group(1)); // ([a-z0-9]+)
|
| | | paramValues.add(m3.group(3)); // ([^\"\\s']+)
|
| | | }
|
| | |
|
| | | String paramName, paramValue;
|
| | | for (int ii = 0; ii < paramNames.size(); ii++)
|
| | | {
|
| | | paramName = paramNames.get(ii).toLowerCase();
|
| | | paramValue = paramValues.get(ii);
|
| | |
|
| | | // debug( "paramName='" + paramName + "'" );
|
| | | // debug( "paramValue='" + paramValue + "'" );
|
| | | // debug( "allowed? " + vAllowed.get( name ).contains( paramName ) );
|
| | |
|
| | | if (allowedAttribute(name, paramName))
|
| | | {
|
| | | if (inArray(paramName, vProtocolAtts))
|
| | | {
|
| | | paramValue = processParamProtocol(paramValue);
|
| | | }
|
| | | params.append(' ').append(paramName).append("=\"").append(paramValue).append("\"");
|
| | | }
|
| | | }
|
| | |
|
| | | if (inArray(name, vSelfClosingTags))
|
| | | {
|
| | | ending = " /";
|
| | | }
|
| | |
|
| | | if (inArray(name, vNeedClosingTags))
|
| | | {
|
| | | ending = "";
|
| | | }
|
| | |
|
| | | if (ending == null || ending.length() < 1)
|
| | | {
|
| | | if (vTagCounts.containsKey(name))
|
| | | {
|
| | | vTagCounts.put(name, vTagCounts.get(name) + 1);
|
| | | }
|
| | | else
|
| | | {
|
| | | vTagCounts.put(name, 1);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | ending = " /";
|
| | | }
|
| | | return "<" + name + params + ending + ">";
|
| | | }
|
| | | else
|
| | | {
|
| | | return "";
|
| | | }
|
| | | }
|
| | |
|
| | | // comments
|
| | | m = P_COMMENT.matcher(s);
|
| | | if (!stripComment && m.find())
|
| | | {
|
| | | return "<" + m.group() + ">";
|
| | | }
|
| | |
|
| | | return "";
|
| | | }
|
| | |
|
| | | private String processParamProtocol(String s)
|
| | | {
|
| | | s = decodeEntities(s);
|
| | | final Matcher m = P_PROTOCOL.matcher(s);
|
| | | if (m.find())
|
| | | {
|
| | | final String protocol = m.group(1);
|
| | | if (!inArray(protocol, vAllowedProtocols))
|
| | | {
|
| | | // bad protocol, turn into local anchor link instead
|
| | | s = "#" + s.substring(protocol.length() + 1);
|
| | | if (s.startsWith("#//"))
|
| | | {
|
| | | s = "#" + s.substring(3);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return s;
|
| | | }
|
| | |
|
| | | private String decodeEntities(String s)
|
| | | {
|
| | | StringBuffer buf = new StringBuffer();
|
| | |
|
| | | Matcher m = P_ENTITY.matcher(s);
|
| | | while (m.find())
|
| | | {
|
| | | final String match = m.group(1);
|
| | | final int decimal = Integer.decode(match).intValue();
|
| | | m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
| | | }
|
| | | m.appendTail(buf);
|
| | | s = buf.toString();
|
| | |
|
| | | buf = new StringBuffer();
|
| | | m = P_ENTITY_UNICODE.matcher(s);
|
| | | while (m.find())
|
| | | {
|
| | | final String match = m.group(1);
|
| | | final int decimal = Integer.valueOf(match, 16).intValue();
|
| | | m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
| | | }
|
| | | m.appendTail(buf);
|
| | | s = buf.toString();
|
| | |
|
| | | buf = new StringBuffer();
|
| | | m = P_ENCODE.matcher(s);
|
| | | while (m.find())
|
| | | {
|
| | | final String match = m.group(1);
|
| | | final int decimal = Integer.valueOf(match, 16).intValue();
|
| | | m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
| | | }
|
| | | m.appendTail(buf);
|
| | | s = buf.toString();
|
| | |
|
| | | s = validateEntities(s);
|
| | | return s;
|
| | | }
|
| | |
|
| | | private String validateEntities(final String s)
|
| | | {
|
| | | StringBuffer buf = new StringBuffer();
|
| | |
|
| | | // validate entities throughout the string
|
| | | Matcher m = P_VALID_ENTITIES.matcher(s);
|
| | | while (m.find())
|
| | | {
|
| | | final String one = m.group(1); // ([^&;]*)
|
| | | final String two = m.group(2); // (?=(;|&|$))
|
| | | m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two)));
|
| | | }
|
| | | m.appendTail(buf);
|
| | |
|
| | | return encodeQuotes(buf.toString());
|
| | | }
|
| | |
|
| | | private String encodeQuotes(final String s)
|
| | | {
|
| | | if (encodeQuotes)
|
| | | {
|
| | | StringBuffer buf = new StringBuffer();
|
| | | Matcher m = P_VALID_QUOTES.matcher(s);
|
| | | while (m.find())
|
| | | {
|
| | | final String one = m.group(1); // (>|^)
|
| | | final String two = m.group(2); // ([^<]+?)
|
| | | final String three = m.group(3); // (<|$)
|
| | | // 䏿¿æ¢åå¼å·ä¸º"ï¼é²æ¢jsonæ ¼å¼æ æ regexReplace(P_QUOTE, """, two)
|
| | | m.appendReplacement(buf, Matcher.quoteReplacement(one + two + three));
|
| | | }
|
| | | m.appendTail(buf);
|
| | | return buf.toString();
|
| | | }
|
| | | else
|
| | | {
|
| | | return s;
|
| | | }
|
| | | }
|
| | |
|
| | | private String checkEntity(final String preamble, final String term)
|
| | | {
|
| | |
|
| | | return ";".equals(term) && isValidEntity(preamble) ? '&' + preamble : "&" + preamble;
|
| | | }
|
| | |
|
| | | private boolean isValidEntity(final String entity)
|
| | | {
|
| | | return inArray(entity, vAllowedEntities);
|
| | | }
|
| | |
|
| | | private static boolean inArray(final String s, final String[] array)
|
| | | {
|
| | | for (String item : array)
|
| | | {
|
| | | if (item != null && item.equals(s))
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | private boolean allowed(final String name)
|
| | | {
|
| | | return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed);
|
| | | }
|
| | |
|
| | | private boolean allowedAttribute(final String name, final String paramName)
|
| | | {
|
| | | return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName));
|
| | | }
|
| | | } |
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.utils.http; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.nio.charset.Charset; |
| | | import javax.servlet.ServletRequest; |
| | | import org.apache.commons.lang.exception.ExceptionUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | /** |
| | | * éç¨httpå·¥å
·å°è£
|
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class HttpHelper |
| | | { |
| | | private static final Logger LOGGER = LoggerFactory.getLogger(HttpHelper.class); |
| | | |
| | | public static String getBodyString(ServletRequest request) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | BufferedReader reader = null; |
| | | try (InputStream inputStream = request.getInputStream()) |
| | | { |
| | | reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8"))); |
| | | String line = ""; |
| | | while ((line = reader.readLine()) != null) |
| | | { |
| | | sb.append(line); |
| | | } |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | LOGGER.warn("getBodyStringåºç°é®é¢ï¼"); |
| | | } |
| | | finally |
| | | { |
| | | if (reader != null) |
| | | { |
| | | try |
| | | { |
| | | reader.close(); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | LOGGER.error(ExceptionUtils.getFullStackTrace(e)); |
| | | } |
| | | } |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | } |
| | | package com.ruoyi.common.utils.http;
|
| | |
|
| | | import java.io.BufferedReader;
|
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.io.InputStreamReader;
|
| | | import java.nio.charset.Charset;
|
| | | import javax.servlet.ServletRequest;
|
| | | import org.apache.commons.lang3.exception.ExceptionUtils;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | |
|
| | | /**
|
| | | * éç¨httpå·¥å
·å°è£
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class HttpHelper
|
| | | {
|
| | | private static final Logger LOGGER = LoggerFactory.getLogger(HttpHelper.class);
|
| | |
|
| | | public static String getBodyString(ServletRequest request)
|
| | | {
|
| | | StringBuilder sb = new StringBuilder();
|
| | | BufferedReader reader = null;
|
| | | try (InputStream inputStream = request.getInputStream())
|
| | | {
|
| | | reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8")));
|
| | | String line = "";
|
| | | while ((line = reader.readLine()) != null)
|
| | | {
|
| | | sb.append(line);
|
| | | }
|
| | | }
|
| | | catch (IOException e)
|
| | | {
|
| | | LOGGER.warn("getBodyStringåºç°é®é¢ï¼");
|
| | | }
|
| | | finally
|
| | | {
|
| | | if (reader != null)
|
| | | {
|
| | | try
|
| | | {
|
| | | reader.close();
|
| | | }
|
| | | catch (IOException e)
|
| | | {
|
| | | LOGGER.error(ExceptionUtils.getMessage(e));
|
| | | }
|
| | | }
|
| | | }
|
| | | return sb.toString();
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java ÐÞ¸Ä |
| | |
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.ruoyi.common.config.RuoYiConfig;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.http.HttpUtils;
|
| | | import com.ruoyi.framework.config.RuoYiConfig;
|
| | |
|
| | | /**
|
| | | * è·åå°åç±»
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.utils.poi; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Method; |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Comparator; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | import org.apache.poi.hssf.usermodel.HSSFDateUtil; |
| | | import org.apache.poi.ss.usermodel.BorderStyle; |
| | | import org.apache.poi.ss.usermodel.Cell; |
| | | import org.apache.poi.ss.usermodel.CellStyle; |
| | | import org.apache.poi.ss.usermodel.CellType; |
| | | import org.apache.poi.ss.usermodel.DataValidation; |
| | | import org.apache.poi.ss.usermodel.DataValidationConstraint; |
| | | import org.apache.poi.ss.usermodel.DataValidationHelper; |
| | | import org.apache.poi.ss.usermodel.DateUtil; |
| | | import org.apache.poi.ss.usermodel.FillPatternType; |
| | | import org.apache.poi.ss.usermodel.Font; |
| | | import org.apache.poi.ss.usermodel.HorizontalAlignment; |
| | | import org.apache.poi.ss.usermodel.IndexedColors; |
| | | import org.apache.poi.ss.usermodel.Row; |
| | | import org.apache.poi.ss.usermodel.Sheet; |
| | | import org.apache.poi.ss.usermodel.VerticalAlignment; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.apache.poi.ss.usermodel.WorkbookFactory; |
| | | import org.apache.poi.ss.util.CellRangeAddressList; |
| | | import org.apache.poi.xssf.streaming.SXSSFWorkbook; |
| | | import org.apache.poi.xssf.usermodel.XSSFDataValidation; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.reflect.ReflectUtils; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel.Type; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excels; |
| | | import com.ruoyi.framework.config.RuoYiConfig; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | |
| | | /** |
| | | * Excelç¸å
³å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class ExcelUtil<T> |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class); |
| | | |
| | | /** |
| | | * Excel sheetæå¤§è¡æ°ï¼é»è®¤65536 |
| | | */ |
| | | public static final int sheetSize = 65536; |
| | | |
| | | /** |
| | | * å·¥ä½è¡¨åç§° |
| | | */ |
| | | private String sheetName; |
| | | |
| | | /** |
| | | * 导åºç±»åï¼EXPORT:å¯¼åºæ°æ®ï¼IMPORTï¼å¯¼å
¥æ¨¡æ¿ï¼ |
| | | */ |
| | | private Type type; |
| | | |
| | | /** |
| | | * å·¥ä½è对象 |
| | | */ |
| | | private Workbook wb; |
| | | |
| | | /** |
| | | * å·¥ä½è¡¨å¯¹è±¡ |
| | | */ |
| | | private Sheet sheet; |
| | | |
| | | /** |
| | | * æ ·å¼å表 |
| | | */ |
| | | private Map<String, CellStyle> styles; |
| | | |
| | | /** |
| | | * 导å
¥å¯¼åºæ°æ®å表 |
| | | */ |
| | | private List<T> list; |
| | | |
| | | /** |
| | | * 注解å表 |
| | | */ |
| | | private List<Object[]> fields; |
| | | |
| | | /** |
| | | * å®ä½å¯¹è±¡ |
| | | */ |
| | | public Class<T> clazz; |
| | | |
| | | public ExcelUtil(Class<T> clazz) |
| | | { |
| | | this.clazz = clazz; |
| | | } |
| | | |
| | | public void init(List<T> list, String sheetName, Type type) |
| | | { |
| | | if (list == null) |
| | | { |
| | | list = new ArrayList<T>(); |
| | | } |
| | | this.list = list; |
| | | this.sheetName = sheetName; |
| | | this.type = type; |
| | | createExcelField(); |
| | | createWorkbook(); |
| | | } |
| | | |
| | | /** |
| | | * 对excel表åé»è®¤ç¬¬ä¸ä¸ªç´¢å¼åè½¬æ¢ælist |
| | | * |
| | | * @param is è¾å
¥æµ |
| | | * @return 转æ¢åéå |
| | | */ |
| | | public List<T> importExcel(InputStream is) throws Exception |
| | | { |
| | | return importExcel(StringUtils.EMPTY, is); |
| | | } |
| | | |
| | | /** |
| | | * 对excel表åæå®è¡¨æ ¼ç´¢å¼åè½¬æ¢ælist |
| | | * |
| | | * @param sheetName è¡¨æ ¼ç´¢å¼å |
| | | * @param is è¾å
¥æµ |
| | | * @return 转æ¢åéå |
| | | */ |
| | | public List<T> importExcel(String sheetName, InputStream is) throws Exception |
| | | { |
| | | this.type = Type.IMPORT; |
| | | this.wb = WorkbookFactory.create(is); |
| | | List<T> list = new ArrayList<T>(); |
| | | Sheet sheet = null; |
| | | if (StringUtils.isNotEmpty(sheetName)) |
| | | { |
| | | // 妿æå®sheetå,ååæå®sheetä¸çå
容. |
| | | sheet = wb.getSheet(sheetName); |
| | | } |
| | | else |
| | | { |
| | | // å¦æä¼ å
¥çsheetåä¸åå¨åé»è®¤æå第1个sheet. |
| | | sheet = wb.getSheetAt(0); |
| | | } |
| | | |
| | | if (sheet == null) |
| | | { |
| | | throw new IOException("æä»¶sheetä¸åå¨"); |
| | | } |
| | | |
| | | int rows = sheet.getPhysicalNumberOfRows(); |
| | | |
| | | if (rows > 0) |
| | | { |
| | | // å®ä¹ä¸ä¸ªmapç¨äºåæ¾excelåçåºå·åfield. |
| | | Map<String, Integer> cellMap = new HashMap<String, Integer>(); |
| | | // è·å表头 |
| | | Row heard = sheet.getRow(0); |
| | | for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) |
| | | { |
| | | Cell cell = heard.getCell(i); |
| | | if (StringUtils.isNotNull(cell)) |
| | | { |
| | | String value = this.getCellValue(heard, i).toString(); |
| | | cellMap.put(value, i); |
| | | } |
| | | else |
| | | { |
| | | cellMap.put(null, i); |
| | | } |
| | | } |
| | | // ææ°æ®æ¶æå¤ç å¾å°ç±»çææfield. |
| | | Field[] allFields = clazz.getDeclaredFields(); |
| | | // å®ä¹ä¸ä¸ªmapç¨äºåæ¾åçåºå·åfield. |
| | | Map<Integer, Field> fieldsMap = new HashMap<Integer, Field>(); |
| | | for (int col = 0; col < allFields.length; col++) |
| | | { |
| | | Field field = allFields[col]; |
| | | Excel attr = field.getAnnotation(Excel.class); |
| | | if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) |
| | | { |
| | | // 设置类çç§æåæ®µå±æ§å¯è®¿é®. |
| | | field.setAccessible(true); |
| | | Integer column = cellMap.get(attr.name()); |
| | | fieldsMap.put(column, field); |
| | | } |
| | | } |
| | | for (int i = 1; i < rows; i++) |
| | | { |
| | | // ä»ç¬¬2è¡å¼å§åæ°æ®,é»è®¤ç¬¬ä¸è¡æ¯è¡¨å¤´. |
| | | Row row = sheet.getRow(i); |
| | | T entity = null; |
| | | for (Map.Entry<Integer, Field> entry : fieldsMap.entrySet()) |
| | | { |
| | | Object val = this.getCellValue(row, entry.getKey()); |
| | | |
| | | // 妿ä¸åå¨å®ä¾åæ°å»º. |
| | | entity = (entity == null ? clazz.newInstance() : entity); |
| | | // ä»mapä¸å¾å°å¯¹åºåçfield. |
| | | Field field = fieldsMap.get(entry.getKey()); |
| | | // åå¾ç±»å,å¹¶æ ¹æ®å¯¹è±¡ç±»å设置å¼. |
| | | Class<?> fieldType = field.getType(); |
| | | if (String.class == fieldType) |
| | | { |
| | | String s = Convert.toStr(val); |
| | | if (StringUtils.endsWith(s, ".0")) |
| | | { |
| | | val = StringUtils.substringBefore(s, ".0"); |
| | | } |
| | | else |
| | | { |
| | | val = Convert.toStr(val); |
| | | } |
| | | } |
| | | else if ((Integer.TYPE == fieldType) || (Integer.class == fieldType)) |
| | | { |
| | | val = Convert.toInt(val); |
| | | } |
| | | else if ((Long.TYPE == fieldType) || (Long.class == fieldType)) |
| | | { |
| | | val = Convert.toLong(val); |
| | | } |
| | | else if ((Double.TYPE == fieldType) || (Double.class == fieldType)) |
| | | { |
| | | val = Convert.toDouble(val); |
| | | } |
| | | else if ((Float.TYPE == fieldType) || (Float.class == fieldType)) |
| | | { |
| | | val = Convert.toFloat(val); |
| | | } |
| | | else if (BigDecimal.class == fieldType) |
| | | { |
| | | val = Convert.toBigDecimal(val); |
| | | } |
| | | else if (Date.class == fieldType) |
| | | { |
| | | if (val instanceof String) |
| | | { |
| | | val = DateUtils.parseDate(val); |
| | | } |
| | | else if (val instanceof Double) |
| | | { |
| | | val = DateUtil.getJavaDate((Double) val); |
| | | } |
| | | } |
| | | if (StringUtils.isNotNull(fieldType)) |
| | | { |
| | | Excel attr = field.getAnnotation(Excel.class); |
| | | String propertyName = field.getName(); |
| | | if (StringUtils.isNotEmpty(attr.targetAttr())) |
| | | { |
| | | propertyName = field.getName() + "." + attr.targetAttr(); |
| | | } |
| | | else if (StringUtils.isNotEmpty(attr.readConverterExp())) |
| | | { |
| | | val = reverseByExp(String.valueOf(val), attr.readConverterExp()); |
| | | } |
| | | ReflectUtils.invokeSetter(entity, propertyName, val); |
| | | } |
| | | } |
| | | list.add(entity); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 对listæ°æ®æºå°å
¶éé¢çæ°æ®å¯¼å
¥å°excel表å |
| | | * |
| | | * @param list å¯¼åºæ°æ®éå |
| | | * @param sheetName å·¥ä½è¡¨çåç§° |
| | | * @return ç»æ |
| | | */ |
| | | public AjaxResult exportExcel(List<T> list, String sheetName) |
| | | { |
| | | this.init(list, sheetName, Type.EXPORT); |
| | | return exportExcel(); |
| | | } |
| | | |
| | | /** |
| | | * 对listæ°æ®æºå°å
¶éé¢çæ°æ®å¯¼å
¥å°excel表å |
| | | * |
| | | * @param sheetName å·¥ä½è¡¨çåç§° |
| | | * @return ç»æ |
| | | */ |
| | | public AjaxResult importTemplateExcel(String sheetName) |
| | | { |
| | | this.init(null, sheetName, Type.IMPORT); |
| | | return exportExcel(); |
| | | } |
| | | |
| | | /** |
| | | * 对listæ°æ®æºå°å
¶éé¢çæ°æ®å¯¼å
¥å°excel表å |
| | | * |
| | | * @return ç»æ |
| | | */ |
| | | public AjaxResult exportExcel() |
| | | { |
| | | OutputStream out = null; |
| | | try |
| | | { |
| | | // ååºä¸å
±æå¤å°ä¸ªsheet. |
| | | double sheetNo = Math.ceil(list.size() / sheetSize); |
| | | for (int index = 0; index <= sheetNo; index++) |
| | | { |
| | | createSheet(sheetNo, index); |
| | | |
| | | // 产çä¸è¡ |
| | | Row row = sheet.createRow(0); |
| | | int column = 0; |
| | | // åå
¥åä¸ªåæ®µçå头åç§° |
| | | for (Object[] os : fields) |
| | | { |
| | | Excel excel = (Excel) os[1]; |
| | | this.createCell(excel, row, column++); |
| | | } |
| | | if (Type.EXPORT.equals(type)) |
| | | { |
| | | fillExcelData(index, row); |
| | | } |
| | | } |
| | | String filename = encodingFilename(sheetName); |
| | | out = new FileOutputStream(getAbsoluteFile(filename)); |
| | | wb.write(out); |
| | | return AjaxResult.success(filename); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | log.error("导åºExcelå¼å¸¸{}", e.getMessage()); |
| | | throw new CustomException("导åºExcel失败ï¼è¯·èç³»ç½ç«ç®¡çåï¼"); |
| | | } |
| | | finally |
| | | { |
| | | if (wb != null) |
| | | { |
| | | try |
| | | { |
| | | wb.close(); |
| | | } |
| | | catch (IOException e1) |
| | | { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | if (out != null) |
| | | { |
| | | try |
| | | { |
| | | out.close(); |
| | | } |
| | | catch (IOException e1) |
| | | { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å¡«å
excelæ°æ® |
| | | * |
| | | * @param index åºå· |
| | | * @param row åå
æ ¼è¡ |
| | | */ |
| | | public void fillExcelData(int index, Row row) |
| | | { |
| | | int startNo = index * sheetSize; |
| | | int endNo = Math.min(startNo + sheetSize, list.size()); |
| | | for (int i = startNo; i < endNo; i++) |
| | | { |
| | | row = sheet.createRow(i + 1 - startNo); |
| | | // å¾å°å¯¼åºå¯¹è±¡. |
| | | T vo = (T) list.get(i); |
| | | int column = 0; |
| | | for (Object[] os : fields) |
| | | { |
| | | Field field = (Field) os[0]; |
| | | Excel excel = (Excel) os[1]; |
| | | // 设置å®ä½ç±»ç§æå±æ§å¯è®¿é® |
| | | field.setAccessible(true); |
| | | this.addCell(excel, row, vo, field, column++); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * åå»ºè¡¨æ ¼æ ·å¼ |
| | | * |
| | | * @param wb å·¥ä½è对象 |
| | | * @return æ ·å¼å表 |
| | | */ |
| | | private Map<String, CellStyle> createStyles(Workbook wb) |
| | | { |
| | | // åå
¥åæ¡è®°å½,æ¯æ¡è®°å½å¯¹åºexcel表ä¸çä¸è¡ |
| | | Map<String, CellStyle> styles = new HashMap<String, CellStyle>(); |
| | | CellStyle style = wb.createCellStyle(); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | style.setBorderRight(BorderStyle.THIN); |
| | | style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | style.setBorderLeft(BorderStyle.THIN); |
| | | style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | style.setBorderTop(BorderStyle.THIN); |
| | | style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | style.setBorderBottom(BorderStyle.THIN); |
| | | style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | Font dataFont = wb.createFont(); |
| | | dataFont.setFontName("Arial"); |
| | | dataFont.setFontHeightInPoints((short) 10); |
| | | style.setFont(dataFont); |
| | | styles.put("data", style); |
| | | |
| | | style = wb.createCellStyle(); |
| | | style.cloneStyleFrom(styles.get("data")); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | style.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
| | | Font headerFont = wb.createFont(); |
| | | headerFont.setFontName("Arial"); |
| | | headerFont.setFontHeightInPoints((short) 10); |
| | | headerFont.setBold(true); |
| | | headerFont.setColor(IndexedColors.WHITE.getIndex()); |
| | | style.setFont(headerFont); |
| | | styles.put("header", style); |
| | | |
| | | return styles; |
| | | } |
| | | |
| | | /** |
| | | * å建åå
æ ¼ |
| | | */ |
| | | public Cell createCell(Excel attr, Row row, int column) |
| | | { |
| | | // å建å |
| | | Cell cell = row.createCell(column); |
| | | // åå
¥åä¿¡æ¯ |
| | | cell.setCellValue(attr.name()); |
| | | setDataValidation(attr, row, column); |
| | | cell.setCellStyle(styles.get("header")); |
| | | return cell; |
| | | } |
| | | |
| | | /** |
| | | * 设置åå
æ ¼ä¿¡æ¯ |
| | | * |
| | | * @param value åå
æ ¼å¼ |
| | | * @param attr 注解ç¸å
³ |
| | | * @param cell åå
æ ¼ä¿¡æ¯ |
| | | */ |
| | | public void setCellVo(Object value, Excel attr, Cell cell) |
| | | { |
| | | if (ColumnType.STRING == attr.cellType()) |
| | | { |
| | | cell.setCellType(CellType.NUMERIC); |
| | | cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix()); |
| | | } |
| | | else if (ColumnType.NUMERIC == attr.cellType()) |
| | | { |
| | | cell.setCellType(CellType.NUMERIC); |
| | | cell.setCellValue(Integer.parseInt(value + "")); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * åå»ºè¡¨æ ¼æ ·å¼ |
| | | */ |
| | | public void setDataValidation(Excel attr, Row row, int column) |
| | | { |
| | | if (attr.name().indexOf("注ï¼") >= 0) |
| | | { |
| | | sheet.setColumnWidth(column, 6000); |
| | | } |
| | | else |
| | | { |
| | | // 设置å宽 |
| | | sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256)); |
| | | row.setHeight((short) (attr.height() * 20)); |
| | | } |
| | | // å¦æè®¾ç½®äºæç¤ºä¿¡æ¯åé¼ æ æ¾ä¸å»æç¤º. |
| | | if (StringUtils.isNotEmpty(attr.prompt())) |
| | | { |
| | | // è¿éé»è®¤è®¾äº2-101åæç¤º. |
| | | setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column); |
| | | } |
| | | // å¦æè®¾ç½®äºcombo屿§åæ¬ååªè½éæ©ä¸è½è¾å
¥ |
| | | if (attr.combo().length > 0) |
| | | { |
| | | // è¿éé»è®¤è®¾äº2-101ååªè½éæ©ä¸è½è¾å
¥. |
| | | setXSSFValidation(sheet, attr.combo(), 1, 100, column, column); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ·»å åå
æ ¼ |
| | | */ |
| | | public Cell addCell(Excel attr, Row row, T vo, Field field, int column) |
| | | { |
| | | Cell cell = null; |
| | | try |
| | | { |
| | | // 设置è¡é« |
| | | row.setHeight((short) (attr.height() * 20)); |
| | | // æ ¹æ®Excelä¸è®¾ç½®æ
åµå³å®æ¯å¦å¯¼åº,æäºæ
åµéè¦ä¿æä¸ºç©º,å¸æç¨æ·å¡«åè¿ä¸å. |
| | | if (attr.isExport()) |
| | | { |
| | | // å建cell |
| | | cell = row.createCell(column); |
| | | cell.setCellStyle(styles.get("data")); |
| | | |
| | | // ç¨äºè¯»å对象ä¸ç屿§ |
| | | Object value = getTargetValue(vo, field, attr); |
| | | String dateFormat = attr.dateFormat(); |
| | | String readConverterExp = attr.readConverterExp(); |
| | | if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) |
| | | { |
| | | cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value)); |
| | | } |
| | | else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value)) |
| | | { |
| | | cell.setCellValue(convertByExp(String.valueOf(value), readConverterExp)); |
| | | } |
| | | else |
| | | { |
| | | // 设置åç±»å |
| | | setCellVo(value, attr, cell); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | log.error("导åºExcel失败{}", e); |
| | | } |
| | | return cell; |
| | | } |
| | | |
| | | /** |
| | | * 设置 POI XSSFSheet åå
æ ¼æç¤º |
| | | * |
| | | * @param sheet 表å |
| | | * @param promptTitle æç¤ºæ é¢ |
| | | * @param promptContent æç¤ºå
容 |
| | | * @param firstRow å¼å§è¡ |
| | | * @param endRow ç»æè¡ |
| | | * @param firstCol å¼å§å |
| | | * @param endCol ç»æå |
| | | */ |
| | | public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow, |
| | | int firstCol, int endCol) |
| | | { |
| | | DataValidationHelper helper = sheet.getDataValidationHelper(); |
| | | DataValidationConstraint constraint = helper.createCustomConstraint("DD1"); |
| | | CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); |
| | | DataValidation dataValidation = helper.createValidation(constraint, regions); |
| | | dataValidation.createPromptBox(promptTitle, promptContent); |
| | | dataValidation.setShowPromptBox(true); |
| | | sheet.addValidationData(dataValidation); |
| | | } |
| | | |
| | | /** |
| | | * 设置æäºåçå¼åªè½è¾å
¥é¢å¶çæ°æ®,æ¾ç¤ºä¸ææ¡. |
| | | * |
| | | * @param sheet è¦è®¾ç½®çsheet. |
| | | * @param textlist ä¸ææ¡æ¾ç¤ºçå
容 |
| | | * @param firstRow å¼å§è¡ |
| | | * @param endRow ç»æè¡ |
| | | * @param firstCol å¼å§å |
| | | * @param endCol ç»æå |
| | | * @return 设置好çsheet. |
| | | */ |
| | | public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol) |
| | | { |
| | | DataValidationHelper helper = sheet.getDataValidationHelper(); |
| | | // å è½½ä¸æå表å
容 |
| | | DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist); |
| | | // è®¾ç½®æ°æ®æææ§å è½½å¨åªä¸ªåå
æ ¼ä¸,åä¸ªåæ°å嫿¯ï¼èµ·å§è¡ãç»æ¢è¡ãèµ·å§åãç»æ¢å |
| | | CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); |
| | | // æ°æ®æææ§å¯¹è±¡ |
| | | DataValidation dataValidation = helper.createValidation(constraint, regions); |
| | | // å¤çExcelå
¼å®¹æ§é®é¢ |
| | | if (dataValidation instanceof XSSFDataValidation) |
| | | { |
| | | dataValidation.setSuppressDropDownArrow(true); |
| | | dataValidation.setShowErrorBox(true); |
| | | } |
| | | else |
| | | { |
| | | dataValidation.setSuppressDropDownArrow(false); |
| | | } |
| | | |
| | | sheet.addValidationData(dataValidation); |
| | | } |
| | | |
| | | /** |
| | | * è§£æå¯¼åºå¼ 0=ç·,1=女,2=æªç¥ |
| | | * |
| | | * @param propertyValue åæ°å¼ |
| | | * @param converterExp ç¿»è¯æ³¨è§£ |
| | | * @return è§£æåå¼ |
| | | * @throws Exception |
| | | */ |
| | | public static String convertByExp(String propertyValue, String converterExp) throws Exception |
| | | { |
| | | try |
| | | { |
| | | String[] convertSource = converterExp.split(","); |
| | | for (String item : convertSource) |
| | | { |
| | | String[] itemArray = item.split("="); |
| | | if (itemArray[0].equals(propertyValue)) |
| | | { |
| | | return itemArray[1]; |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw e; |
| | | } |
| | | return propertyValue; |
| | | } |
| | | |
| | | /** |
| | | * ååè§£æå¼ ç·=0,女=1,æªç¥=2 |
| | | * |
| | | * @param propertyValue åæ°å¼ |
| | | * @param converterExp ç¿»è¯æ³¨è§£ |
| | | * @return è§£æåå¼ |
| | | * @throws Exception |
| | | */ |
| | | public static String reverseByExp(String propertyValue, String converterExp) throws Exception |
| | | { |
| | | try |
| | | { |
| | | String[] convertSource = converterExp.split(","); |
| | | for (String item : convertSource) |
| | | { |
| | | String[] itemArray = item.split("="); |
| | | if (itemArray[1].equals(propertyValue)) |
| | | { |
| | | return itemArray[0]; |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw e; |
| | | } |
| | | return propertyValue; |
| | | } |
| | | |
| | | /** |
| | | * ç¼ç æä»¶å |
| | | */ |
| | | public String encodingFilename(String filename) |
| | | { |
| | | filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx"; |
| | | return filename; |
| | | } |
| | | |
| | | /** |
| | | * è·åä¸è½½è·¯å¾ |
| | | * |
| | | * @param filename æä»¶åç§° |
| | | */ |
| | | public String getAbsoluteFile(String filename) |
| | | { |
| | | String downloadPath = RuoYiConfig.getDownloadPath() + filename; |
| | | File desc = new File(downloadPath); |
| | | if (!desc.getParentFile().exists()) |
| | | { |
| | | desc.getParentFile().mkdirs(); |
| | | } |
| | | return downloadPath; |
| | | } |
| | | |
| | | /** |
| | | * è·åbeanä¸ç屿§å¼ |
| | | * |
| | | * @param vo å®ä½å¯¹è±¡ |
| | | * @param field åæ®µ |
| | | * @param excel 注解 |
| | | * @return æç»ç屿§å¼ |
| | | * @throws Exception |
| | | */ |
| | | private Object getTargetValue(T vo, Field field, Excel excel) throws Exception |
| | | { |
| | | Object o = field.get(vo); |
| | | if (StringUtils.isNotEmpty(excel.targetAttr())) |
| | | { |
| | | String target = excel.targetAttr(); |
| | | if (target.indexOf(".") > -1) |
| | | { |
| | | String[] targets = target.split("[.]"); |
| | | for (String name : targets) |
| | | { |
| | | o = getValue(o, name); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | o = getValue(o, target); |
| | | } |
| | | } |
| | | return o; |
| | | } |
| | | |
| | | /** |
| | | * 以类ç屿§çgetæ¹æ³æ¹æ³å½¢å¼è·åå¼ |
| | | * |
| | | * @param o |
| | | * @param name |
| | | * @return value |
| | | * @throws Exception |
| | | */ |
| | | private Object getValue(Object o, String name) throws Exception |
| | | { |
| | | if (StringUtils.isNotEmpty(name)) |
| | | { |
| | | Class<?> clazz = o.getClass(); |
| | | String methodName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1); |
| | | Method method = clazz.getMethod(methodName); |
| | | o = method.invoke(o); |
| | | } |
| | | return o; |
| | | } |
| | | |
| | | /** |
| | | * å¾å°ææå®ä¹å段 |
| | | */ |
| | | private void createExcelField() |
| | | { |
| | | this.fields = new ArrayList<Object[]>(); |
| | | List<Field> tempFields = new ArrayList<>(); |
| | | tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields())); |
| | | tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); |
| | | for (Field field : tempFields) |
| | | { |
| | | // åæ³¨è§£ |
| | | if (field.isAnnotationPresent(Excel.class)) |
| | | { |
| | | putToField(field, field.getAnnotation(Excel.class)); |
| | | } |
| | | |
| | | // 夿³¨è§£ |
| | | if (field.isAnnotationPresent(Excels.class)) |
| | | { |
| | | Excels attrs = field.getAnnotation(Excels.class); |
| | | Excel[] excels = attrs.value(); |
| | | for (Excel excel : excels) |
| | | { |
| | | putToField(field, excel); |
| | | } |
| | | } |
| | | } |
| | | this.fields = this.fields.stream().sorted(Comparator.comparing(objects -> ((Excel) objects[1]).sort())).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * æ¾å°å段éåä¸ |
| | | */ |
| | | private void putToField(Field field, Excel attr) |
| | | { |
| | | if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) |
| | | { |
| | | this.fields.add(new Object[] { field, attr }); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å建ä¸ä¸ªå·¥ä½ç°¿ |
| | | */ |
| | | public void createWorkbook() |
| | | { |
| | | this.wb = new SXSSFWorkbook(500); |
| | | } |
| | | |
| | | /** |
| | | * å建工ä½è¡¨ |
| | | * |
| | | * @param sheetNo sheetæ°é |
| | | * @param index åºå· |
| | | */ |
| | | public void createSheet(double sheetNo, int index) |
| | | { |
| | | this.sheet = wb.createSheet(); |
| | | this.styles = createStyles(wb); |
| | | // 设置工ä½è¡¨çåç§°. |
| | | if (sheetNo == 0) |
| | | { |
| | | wb.setSheetName(index, sheetName); |
| | | } |
| | | else |
| | | { |
| | | wb.setSheetName(index, sheetName + index); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·ååå
æ ¼å¼ |
| | | * |
| | | * @param row è·åçè¡ |
| | | * @param column è·ååå
æ ¼åå· |
| | | * @return åå
æ ¼å¼ |
| | | */ |
| | | public Object getCellValue(Row row, int column) |
| | | { |
| | | if (row == null) |
| | | { |
| | | return row; |
| | | } |
| | | Object val = ""; |
| | | try |
| | | { |
| | | Cell cell = row.getCell(column); |
| | | if (StringUtils.isNotNull(cell)) |
| | | { |
| | | if (cell.getCellTypeEnum() == CellType.NUMERIC || cell.getCellTypeEnum() == CellType.FORMULA) |
| | | { |
| | | val = cell.getNumericCellValue(); |
| | | if (HSSFDateUtil.isCellDateFormatted(cell)) |
| | | { |
| | | val = DateUtil.getJavaDate((Double) val); // POI Excel æ¥ææ ¼å¼è½¬æ¢ |
| | | } |
| | | else |
| | | { |
| | | if ((Double) val % 1 > 0) |
| | | { |
| | | val = new DecimalFormat("0.00").format(val); |
| | | } |
| | | else |
| | | { |
| | | val = new DecimalFormat("0").format(val); |
| | | } |
| | | } |
| | | } |
| | | else if (cell.getCellTypeEnum() == CellType.STRING) |
| | | { |
| | | val = cell.getStringCellValue(); |
| | | } |
| | | else if (cell.getCellTypeEnum() == CellType.BOOLEAN) |
| | | { |
| | | val = cell.getBooleanCellValue(); |
| | | } |
| | | else if (cell.getCellTypeEnum() == CellType.ERROR) |
| | | { |
| | | val = cell.getErrorCellValue(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return val; |
| | | } |
| | | return val; |
| | | } |
| | | package com.ruoyi.common.utils.poi;
|
| | |
|
| | | import java.io.File;
|
| | | import java.io.FileOutputStream;
|
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.io.OutputStream;
|
| | | import java.lang.reflect.Field;
|
| | | import java.lang.reflect.Method;
|
| | | import java.math.BigDecimal;
|
| | | import java.text.DecimalFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.Comparator;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.UUID;
|
| | | import java.util.stream.Collectors;
|
| | | import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
| | | import org.apache.poi.ss.usermodel.BorderStyle;
|
| | | import org.apache.poi.ss.usermodel.Cell;
|
| | | import org.apache.poi.ss.usermodel.CellStyle;
|
| | | import org.apache.poi.ss.usermodel.CellType;
|
| | | import org.apache.poi.ss.usermodel.DataValidation;
|
| | | import org.apache.poi.ss.usermodel.DataValidationConstraint;
|
| | | import org.apache.poi.ss.usermodel.DataValidationHelper;
|
| | | import org.apache.poi.ss.usermodel.DateUtil;
|
| | | import org.apache.poi.ss.usermodel.FillPatternType;
|
| | | import org.apache.poi.ss.usermodel.Font;
|
| | | import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
| | | import org.apache.poi.ss.usermodel.IndexedColors;
|
| | | import org.apache.poi.ss.usermodel.Row;
|
| | | import org.apache.poi.ss.usermodel.Sheet;
|
| | | import org.apache.poi.ss.usermodel.VerticalAlignment;
|
| | | import org.apache.poi.ss.usermodel.Workbook;
|
| | | import org.apache.poi.ss.usermodel.WorkbookFactory;
|
| | | import org.apache.poi.ss.util.CellRangeAddressList;
|
| | | import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
| | | import org.apache.poi.xssf.usermodel.XSSFDataValidation;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import com.ruoyi.common.annotation.Excel;
|
| | | import com.ruoyi.common.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.common.annotation.Excel.Type;
|
| | | import com.ruoyi.common.annotation.Excels;
|
| | | import com.ruoyi.common.config.RuoYiConfig;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.text.Convert;
|
| | | import com.ruoyi.common.exception.CustomException;
|
| | | import com.ruoyi.common.utils.DateUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.reflect.ReflectUtils;
|
| | |
|
| | | /**
|
| | | * Excelç¸å
³å¤ç
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class ExcelUtil<T>
|
| | | {
|
| | | private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class);
|
| | |
|
| | | /**
|
| | | * Excel sheetæå¤§è¡æ°ï¼é»è®¤65536
|
| | | */
|
| | | public static final int sheetSize = 65536;
|
| | |
|
| | | /**
|
| | | * å·¥ä½è¡¨åç§°
|
| | | */
|
| | | private String sheetName;
|
| | |
|
| | | /**
|
| | | * 导åºç±»åï¼EXPORT:å¯¼åºæ°æ®ï¼IMPORTï¼å¯¼å
¥æ¨¡æ¿ï¼
|
| | | */
|
| | | private Type type;
|
| | |
|
| | | /**
|
| | | * å·¥ä½è对象
|
| | | */
|
| | | private Workbook wb;
|
| | |
|
| | | /**
|
| | | * å·¥ä½è¡¨å¯¹è±¡
|
| | | */
|
| | | private Sheet sheet;
|
| | |
|
| | | /**
|
| | | * æ ·å¼å表
|
| | | */
|
| | | private Map<String, CellStyle> styles;
|
| | |
|
| | | /**
|
| | | * 导å
¥å¯¼åºæ°æ®å表
|
| | | */
|
| | | private List<T> list;
|
| | |
|
| | | /**
|
| | | * 注解å表
|
| | | */
|
| | | private List<Object[]> fields;
|
| | |
|
| | | /**
|
| | | * å®ä½å¯¹è±¡
|
| | | */
|
| | | public Class<T> clazz;
|
| | |
|
| | | public ExcelUtil(Class<T> clazz)
|
| | | {
|
| | | this.clazz = clazz;
|
| | | }
|
| | |
|
| | | public void init(List<T> list, String sheetName, Type type)
|
| | | {
|
| | | if (list == null)
|
| | | {
|
| | | list = new ArrayList<T>();
|
| | | }
|
| | | this.list = list;
|
| | | this.sheetName = sheetName;
|
| | | this.type = type;
|
| | | createExcelField();
|
| | | createWorkbook();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 对excel表åé»è®¤ç¬¬ä¸ä¸ªç´¢å¼åè½¬æ¢ælist
|
| | | * |
| | | * @param is è¾å
¥æµ
|
| | | * @return 转æ¢åéå
|
| | | */
|
| | | public List<T> importExcel(InputStream is) throws Exception
|
| | | {
|
| | | return importExcel(StringUtils.EMPTY, is);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 对excel表åæå®è¡¨æ ¼ç´¢å¼åè½¬æ¢ælist
|
| | | * |
| | | * @param sheetName è¡¨æ ¼ç´¢å¼å
|
| | | * @param is è¾å
¥æµ
|
| | | * @return 转æ¢åéå
|
| | | */
|
| | | public List<T> importExcel(String sheetName, InputStream is) throws Exception
|
| | | {
|
| | | this.type = Type.IMPORT;
|
| | | this.wb = WorkbookFactory.create(is);
|
| | | List<T> list = new ArrayList<T>();
|
| | | Sheet sheet = null;
|
| | | if (StringUtils.isNotEmpty(sheetName))
|
| | | {
|
| | | // 妿æå®sheetå,ååæå®sheetä¸çå
容.
|
| | | sheet = wb.getSheet(sheetName);
|
| | | }
|
| | | else
|
| | | {
|
| | | // å¦æä¼ å
¥çsheetåä¸åå¨åé»è®¤æå第1个sheet.
|
| | | sheet = wb.getSheetAt(0);
|
| | | }
|
| | |
|
| | | if (sheet == null)
|
| | | {
|
| | | throw new IOException("æä»¶sheetä¸åå¨");
|
| | | }
|
| | |
|
| | | int rows = sheet.getPhysicalNumberOfRows();
|
| | |
|
| | | if (rows > 0)
|
| | | {
|
| | | // å®ä¹ä¸ä¸ªmapç¨äºåæ¾excelåçåºå·åfield.
|
| | | Map<String, Integer> cellMap = new HashMap<String, Integer>();
|
| | | // è·å表头
|
| | | Row heard = sheet.getRow(0);
|
| | | for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++)
|
| | | {
|
| | | Cell cell = heard.getCell(i);
|
| | | if (StringUtils.isNotNull(cell))
|
| | | {
|
| | | String value = this.getCellValue(heard, i).toString();
|
| | | cellMap.put(value, i);
|
| | | }
|
| | | else
|
| | | {
|
| | | cellMap.put(null, i);
|
| | | }
|
| | | }
|
| | | // ææ°æ®æ¶æå¤ç å¾å°ç±»çææfield.
|
| | | Field[] allFields = clazz.getDeclaredFields();
|
| | | // å®ä¹ä¸ä¸ªmapç¨äºåæ¾åçåºå·åfield.
|
| | | Map<Integer, Field> fieldsMap = new HashMap<Integer, Field>();
|
| | | for (int col = 0; col < allFields.length; col++)
|
| | | {
|
| | | Field field = allFields[col];
|
| | | Excel attr = field.getAnnotation(Excel.class);
|
| | | if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
|
| | | {
|
| | | // 设置类çç§æåæ®µå±æ§å¯è®¿é®.
|
| | | field.setAccessible(true);
|
| | | Integer column = cellMap.get(attr.name());
|
| | | fieldsMap.put(column, field);
|
| | | }
|
| | | }
|
| | | for (int i = 1; i < rows; i++)
|
| | | {
|
| | | // ä»ç¬¬2è¡å¼å§åæ°æ®,é»è®¤ç¬¬ä¸è¡æ¯è¡¨å¤´.
|
| | | Row row = sheet.getRow(i);
|
| | | T entity = null;
|
| | | for (Map.Entry<Integer, Field> entry : fieldsMap.entrySet())
|
| | | {
|
| | | Object val = this.getCellValue(row, entry.getKey());
|
| | |
|
| | | // 妿ä¸åå¨å®ä¾åæ°å»º.
|
| | | entity = (entity == null ? clazz.newInstance() : entity);
|
| | | // ä»mapä¸å¾å°å¯¹åºåçfield.
|
| | | Field field = fieldsMap.get(entry.getKey());
|
| | | // åå¾ç±»å,å¹¶æ ¹æ®å¯¹è±¡ç±»å设置å¼.
|
| | | Class<?> fieldType = field.getType();
|
| | | if (String.class == fieldType)
|
| | | {
|
| | | String s = Convert.toStr(val);
|
| | | if (StringUtils.endsWith(s, ".0"))
|
| | | {
|
| | | val = StringUtils.substringBefore(s, ".0");
|
| | | }
|
| | | else
|
| | | {
|
| | | val = Convert.toStr(val);
|
| | | }
|
| | | }
|
| | | else if ((Integer.TYPE == fieldType) || (Integer.class == fieldType))
|
| | | {
|
| | | val = Convert.toInt(val);
|
| | | }
|
| | | else if ((Long.TYPE == fieldType) || (Long.class == fieldType))
|
| | | {
|
| | | val = Convert.toLong(val);
|
| | | }
|
| | | else if ((Double.TYPE == fieldType) || (Double.class == fieldType))
|
| | | {
|
| | | val = Convert.toDouble(val);
|
| | | }
|
| | | else if ((Float.TYPE == fieldType) || (Float.class == fieldType))
|
| | | {
|
| | | val = Convert.toFloat(val);
|
| | | }
|
| | | else if (BigDecimal.class == fieldType)
|
| | | {
|
| | | val = Convert.toBigDecimal(val);
|
| | | }
|
| | | else if (Date.class == fieldType)
|
| | | {
|
| | | if (val instanceof String)
|
| | | {
|
| | | val = DateUtils.parseDate(val);
|
| | | }
|
| | | else if (val instanceof Double)
|
| | | {
|
| | | val = DateUtil.getJavaDate((Double) val);
|
| | | }
|
| | | }
|
| | | if (StringUtils.isNotNull(fieldType))
|
| | | {
|
| | | Excel attr = field.getAnnotation(Excel.class);
|
| | | String propertyName = field.getName();
|
| | | if (StringUtils.isNotEmpty(attr.targetAttr()))
|
| | | {
|
| | | propertyName = field.getName() + "." + attr.targetAttr();
|
| | | }
|
| | | else if (StringUtils.isNotEmpty(attr.readConverterExp()))
|
| | | {
|
| | | val = reverseByExp(String.valueOf(val), attr.readConverterExp());
|
| | | }
|
| | | ReflectUtils.invokeSetter(entity, propertyName, val);
|
| | | }
|
| | | }
|
| | | list.add(entity);
|
| | | }
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 对listæ°æ®æºå°å
¶éé¢çæ°æ®å¯¼å
¥å°excel表å
|
| | | * |
| | | * @param list å¯¼åºæ°æ®éå
|
| | | * @param sheetName å·¥ä½è¡¨çåç§°
|
| | | * @return ç»æ
|
| | | */
|
| | | public AjaxResult exportExcel(List<T> list, String sheetName)
|
| | | {
|
| | | this.init(list, sheetName, Type.EXPORT);
|
| | | return exportExcel();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 对listæ°æ®æºå°å
¶éé¢çæ°æ®å¯¼å
¥å°excel表å
|
| | | * |
| | | * @param sheetName å·¥ä½è¡¨çåç§°
|
| | | * @return ç»æ
|
| | | */
|
| | | public AjaxResult importTemplateExcel(String sheetName)
|
| | | {
|
| | | this.init(null, sheetName, Type.IMPORT);
|
| | | return exportExcel();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 对listæ°æ®æºå°å
¶éé¢çæ°æ®å¯¼å
¥å°excel表å
|
| | | * |
| | | * @return ç»æ
|
| | | */
|
| | | public AjaxResult exportExcel()
|
| | | {
|
| | | OutputStream out = null;
|
| | | try
|
| | | {
|
| | | // ååºä¸å
±æå¤å°ä¸ªsheet.
|
| | | double sheetNo = Math.ceil(list.size() / sheetSize);
|
| | | for (int index = 0; index <= sheetNo; index++)
|
| | | {
|
| | | createSheet(sheetNo, index);
|
| | |
|
| | | // 产çä¸è¡
|
| | | Row row = sheet.createRow(0);
|
| | | int column = 0;
|
| | | // åå
¥åä¸ªåæ®µçå头åç§°
|
| | | for (Object[] os : fields)
|
| | | {
|
| | | Excel excel = (Excel) os[1];
|
| | | this.createCell(excel, row, column++);
|
| | | }
|
| | | if (Type.EXPORT.equals(type))
|
| | | {
|
| | | fillExcelData(index, row);
|
| | | }
|
| | | }
|
| | | String filename = encodingFilename(sheetName);
|
| | | out = new FileOutputStream(getAbsoluteFile(filename));
|
| | | wb.write(out);
|
| | | return AjaxResult.success(filename);
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | log.error("导åºExcelå¼å¸¸{}", e.getMessage());
|
| | | throw new CustomException("导åºExcel失败ï¼è¯·èç³»ç½ç«ç®¡çåï¼");
|
| | | }
|
| | | finally
|
| | | {
|
| | | if (wb != null)
|
| | | {
|
| | | try
|
| | | {
|
| | | wb.close();
|
| | | }
|
| | | catch (IOException e1)
|
| | | {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | if (out != null)
|
| | | {
|
| | | try
|
| | | {
|
| | | out.close();
|
| | | }
|
| | | catch (IOException e1)
|
| | | {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * å¡«å
excelæ°æ®
|
| | | * |
| | | * @param index åºå·
|
| | | * @param row åå
æ ¼è¡
|
| | | */
|
| | | public void fillExcelData(int index, Row row)
|
| | | {
|
| | | int startNo = index * sheetSize;
|
| | | int endNo = Math.min(startNo + sheetSize, list.size());
|
| | | for (int i = startNo; i < endNo; i++)
|
| | | {
|
| | | row = sheet.createRow(i + 1 - startNo);
|
| | | // å¾å°å¯¼åºå¯¹è±¡.
|
| | | T vo = (T) list.get(i);
|
| | | int column = 0;
|
| | | for (Object[] os : fields)
|
| | | {
|
| | | Field field = (Field) os[0];
|
| | | Excel excel = (Excel) os[1];
|
| | | // 设置å®ä½ç±»ç§æå±æ§å¯è®¿é®
|
| | | field.setAccessible(true);
|
| | | this.addCell(excel, row, vo, field, column++);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * åå»ºè¡¨æ ¼æ ·å¼
|
| | | * |
| | | * @param wb å·¥ä½è对象
|
| | | * @return æ ·å¼å表
|
| | | */
|
| | | private Map<String, CellStyle> createStyles(Workbook wb)
|
| | | {
|
| | | // åå
¥åæ¡è®°å½,æ¯æ¡è®°å½å¯¹åºexcel表ä¸çä¸è¡
|
| | | Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
|
| | | CellStyle style = wb.createCellStyle();
|
| | | style.setAlignment(HorizontalAlignment.CENTER);
|
| | | style.setVerticalAlignment(VerticalAlignment.CENTER);
|
| | | style.setBorderRight(BorderStyle.THIN);
|
| | | style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
| | | style.setBorderLeft(BorderStyle.THIN);
|
| | | style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
| | | style.setBorderTop(BorderStyle.THIN);
|
| | | style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
| | | style.setBorderBottom(BorderStyle.THIN);
|
| | | style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
| | | Font dataFont = wb.createFont();
|
| | | dataFont.setFontName("Arial");
|
| | | dataFont.setFontHeightInPoints((short) 10);
|
| | | style.setFont(dataFont);
|
| | | styles.put("data", style);
|
| | |
|
| | | style = wb.createCellStyle();
|
| | | style.cloneStyleFrom(styles.get("data"));
|
| | | style.setAlignment(HorizontalAlignment.CENTER);
|
| | | style.setVerticalAlignment(VerticalAlignment.CENTER);
|
| | | style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
| | | style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
| | | Font headerFont = wb.createFont();
|
| | | headerFont.setFontName("Arial");
|
| | | headerFont.setFontHeightInPoints((short) 10);
|
| | | headerFont.setBold(true);
|
| | | headerFont.setColor(IndexedColors.WHITE.getIndex());
|
| | | style.setFont(headerFont);
|
| | | styles.put("header", style);
|
| | |
|
| | | return styles;
|
| | | }
|
| | |
|
| | | /**
|
| | | * å建åå
æ ¼
|
| | | */
|
| | | public Cell createCell(Excel attr, Row row, int column)
|
| | | {
|
| | | // å建å
|
| | | Cell cell = row.createCell(column);
|
| | | // åå
¥åä¿¡æ¯
|
| | | cell.setCellValue(attr.name());
|
| | | setDataValidation(attr, row, column);
|
| | | cell.setCellStyle(styles.get("header"));
|
| | | return cell;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 设置åå
æ ¼ä¿¡æ¯
|
| | | * |
| | | * @param value åå
æ ¼å¼
|
| | | * @param attr 注解ç¸å
³
|
| | | * @param cell åå
æ ¼ä¿¡æ¯
|
| | | */
|
| | | public void setCellVo(Object value, Excel attr, Cell cell)
|
| | | {
|
| | | if (ColumnType.STRING == attr.cellType())
|
| | | {
|
| | | cell.setCellType(CellType.NUMERIC);
|
| | | cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix());
|
| | | }
|
| | | else if (ColumnType.NUMERIC == attr.cellType())
|
| | | {
|
| | | cell.setCellType(CellType.NUMERIC);
|
| | | cell.setCellValue(Integer.parseInt(value + ""));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * åå»ºè¡¨æ ¼æ ·å¼
|
| | | */
|
| | | public void setDataValidation(Excel attr, Row row, int column)
|
| | | {
|
| | | if (attr.name().indexOf("注ï¼") >= 0)
|
| | | {
|
| | | sheet.setColumnWidth(column, 6000);
|
| | | }
|
| | | else
|
| | | {
|
| | | // 设置å宽
|
| | | sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256));
|
| | | row.setHeight((short) (attr.height() * 20));
|
| | | }
|
| | | // å¦æè®¾ç½®äºæç¤ºä¿¡æ¯åé¼ æ æ¾ä¸å»æç¤º.
|
| | | if (StringUtils.isNotEmpty(attr.prompt()))
|
| | | {
|
| | | // è¿éé»è®¤è®¾äº2-101åæç¤º.
|
| | | setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column);
|
| | | }
|
| | | // å¦æè®¾ç½®äºcombo屿§åæ¬ååªè½éæ©ä¸è½è¾å
¥
|
| | | if (attr.combo().length > 0)
|
| | | {
|
| | | // è¿éé»è®¤è®¾äº2-101ååªè½éæ©ä¸è½è¾å
¥.
|
| | | setXSSFValidation(sheet, attr.combo(), 1, 100, column, column);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ·»å åå
æ ¼
|
| | | */
|
| | | public Cell addCell(Excel attr, Row row, T vo, Field field, int column)
|
| | | {
|
| | | Cell cell = null;
|
| | | try
|
| | | {
|
| | | // 设置è¡é«
|
| | | row.setHeight((short) (attr.height() * 20));
|
| | | // æ ¹æ®Excelä¸è®¾ç½®æ
åµå³å®æ¯å¦å¯¼åº,æäºæ
åµéè¦ä¿æä¸ºç©º,å¸æç¨æ·å¡«åè¿ä¸å.
|
| | | if (attr.isExport())
|
| | | {
|
| | | // å建cell
|
| | | cell = row.createCell(column);
|
| | | cell.setCellStyle(styles.get("data"));
|
| | |
|
| | | // ç¨äºè¯»å对象ä¸ç屿§
|
| | | Object value = getTargetValue(vo, field, attr);
|
| | | String dateFormat = attr.dateFormat();
|
| | | String readConverterExp = attr.readConverterExp();
|
| | | if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
| | | {
|
| | | cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value));
|
| | | }
|
| | | else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
| | | {
|
| | | cell.setCellValue(convertByExp(String.valueOf(value), readConverterExp));
|
| | | }
|
| | | else
|
| | | {
|
| | | // 设置åç±»å
|
| | | setCellVo(value, attr, cell);
|
| | | }
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | log.error("导åºExcel失败{}", e);
|
| | | }
|
| | | return cell;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 设置 POI XSSFSheet åå
æ ¼æç¤º
|
| | | * |
| | | * @param sheet 表å
|
| | | * @param promptTitle æç¤ºæ é¢
|
| | | * @param promptContent æç¤ºå
容
|
| | | * @param firstRow å¼å§è¡
|
| | | * @param endRow ç»æè¡
|
| | | * @param firstCol å¼å§å
|
| | | * @param endCol ç»æå
|
| | | */
|
| | | public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow,
|
| | | int firstCol, int endCol)
|
| | | {
|
| | | DataValidationHelper helper = sheet.getDataValidationHelper();
|
| | | DataValidationConstraint constraint = helper.createCustomConstraint("DD1");
|
| | | CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
|
| | | DataValidation dataValidation = helper.createValidation(constraint, regions);
|
| | | dataValidation.createPromptBox(promptTitle, promptContent);
|
| | | dataValidation.setShowPromptBox(true);
|
| | | sheet.addValidationData(dataValidation);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 设置æäºåçå¼åªè½è¾å
¥é¢å¶çæ°æ®,æ¾ç¤ºä¸ææ¡.
|
| | | * |
| | | * @param sheet è¦è®¾ç½®çsheet.
|
| | | * @param textlist ä¸ææ¡æ¾ç¤ºçå
容
|
| | | * @param firstRow å¼å§è¡
|
| | | * @param endRow ç»æè¡
|
| | | * @param firstCol å¼å§å
|
| | | * @param endCol ç»æå
|
| | | * @return 设置好çsheet.
|
| | | */
|
| | | public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol)
|
| | | {
|
| | | DataValidationHelper helper = sheet.getDataValidationHelper();
|
| | | // å è½½ä¸æå表å
容
|
| | | DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist);
|
| | | // è®¾ç½®æ°æ®æææ§å è½½å¨åªä¸ªåå
æ ¼ä¸,åä¸ªåæ°å嫿¯ï¼èµ·å§è¡ãç»æ¢è¡ãèµ·å§åãç»æ¢å
|
| | | CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
|
| | | // æ°æ®æææ§å¯¹è±¡
|
| | | DataValidation dataValidation = helper.createValidation(constraint, regions);
|
| | | // å¤çExcelå
¼å®¹æ§é®é¢
|
| | | if (dataValidation instanceof XSSFDataValidation)
|
| | | {
|
| | | dataValidation.setSuppressDropDownArrow(true);
|
| | | dataValidation.setShowErrorBox(true);
|
| | | }
|
| | | else
|
| | | {
|
| | | dataValidation.setSuppressDropDownArrow(false);
|
| | | }
|
| | |
|
| | | sheet.addValidationData(dataValidation);
|
| | | }
|
| | |
|
| | | /**
|
| | | * è§£æå¯¼åºå¼ 0=ç·,1=女,2=æªç¥
|
| | | * |
| | | * @param propertyValue åæ°å¼
|
| | | * @param converterExp ç¿»è¯æ³¨è§£
|
| | | * @return è§£æåå¼
|
| | | * @throws Exception
|
| | | */
|
| | | public static String convertByExp(String propertyValue, String converterExp) throws Exception
|
| | | {
|
| | | try
|
| | | {
|
| | | String[] convertSource = converterExp.split(",");
|
| | | for (String item : convertSource)
|
| | | {
|
| | | String[] itemArray = item.split("=");
|
| | | if (itemArray[0].equals(propertyValue))
|
| | | {
|
| | | return itemArray[1];
|
| | | }
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | throw e;
|
| | | }
|
| | | return propertyValue;
|
| | | }
|
| | |
|
| | | /**
|
| | | * ååè§£æå¼ ç·=0,女=1,æªç¥=2
|
| | | * |
| | | * @param propertyValue åæ°å¼
|
| | | * @param converterExp ç¿»è¯æ³¨è§£
|
| | | * @return è§£æåå¼
|
| | | * @throws Exception
|
| | | */
|
| | | public static String reverseByExp(String propertyValue, String converterExp) throws Exception
|
| | | {
|
| | | try
|
| | | {
|
| | | String[] convertSource = converterExp.split(",");
|
| | | for (String item : convertSource)
|
| | | {
|
| | | String[] itemArray = item.split("=");
|
| | | if (itemArray[1].equals(propertyValue))
|
| | | {
|
| | | return itemArray[0];
|
| | | }
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | throw e;
|
| | | }
|
| | | return propertyValue;
|
| | | }
|
| | |
|
| | | /**
|
| | | * ç¼ç æä»¶å
|
| | | */
|
| | | public String encodingFilename(String filename)
|
| | | {
|
| | | filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx";
|
| | | return filename;
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·åä¸è½½è·¯å¾
|
| | | * |
| | | * @param filename æä»¶åç§°
|
| | | */
|
| | | public String getAbsoluteFile(String filename)
|
| | | {
|
| | | String downloadPath = RuoYiConfig.getDownloadPath() + filename;
|
| | | File desc = new File(downloadPath);
|
| | | if (!desc.getParentFile().exists())
|
| | | {
|
| | | desc.getParentFile().mkdirs();
|
| | | }
|
| | | return downloadPath;
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·åbeanä¸ç屿§å¼
|
| | | * |
| | | * @param vo å®ä½å¯¹è±¡
|
| | | * @param field åæ®µ
|
| | | * @param excel 注解
|
| | | * @return æç»ç屿§å¼
|
| | | * @throws Exception
|
| | | */
|
| | | private Object getTargetValue(T vo, Field field, Excel excel) throws Exception
|
| | | {
|
| | | Object o = field.get(vo);
|
| | | if (StringUtils.isNotEmpty(excel.targetAttr()))
|
| | | {
|
| | | String target = excel.targetAttr();
|
| | | if (target.indexOf(".") > -1)
|
| | | {
|
| | | String[] targets = target.split("[.]");
|
| | | for (String name : targets)
|
| | | {
|
| | | o = getValue(o, name);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | o = getValue(o, target);
|
| | | }
|
| | | }
|
| | | return o;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 以类ç屿§çgetæ¹æ³æ¹æ³å½¢å¼è·åå¼
|
| | | * |
| | | * @param o
|
| | | * @param name
|
| | | * @return value
|
| | | * @throws Exception
|
| | | */
|
| | | private Object getValue(Object o, String name) throws Exception
|
| | | {
|
| | | if (StringUtils.isNotEmpty(name))
|
| | | {
|
| | | Class<?> clazz = o.getClass();
|
| | | String methodName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1);
|
| | | Method method = clazz.getMethod(methodName);
|
| | | o = method.invoke(o);
|
| | | }
|
| | | return o;
|
| | | }
|
| | |
|
| | | /**
|
| | | * å¾å°ææå®ä¹å段
|
| | | */
|
| | | private void createExcelField()
|
| | | {
|
| | | this.fields = new ArrayList<Object[]>();
|
| | | List<Field> tempFields = new ArrayList<>();
|
| | | tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields()));
|
| | | tempFields.addAll(Arrays.asList(clazz.getDeclaredFields()));
|
| | | for (Field field : tempFields)
|
| | | {
|
| | | // åæ³¨è§£
|
| | | if (field.isAnnotationPresent(Excel.class))
|
| | | {
|
| | | putToField(field, field.getAnnotation(Excel.class));
|
| | | }
|
| | |
|
| | | // 夿³¨è§£
|
| | | if (field.isAnnotationPresent(Excels.class))
|
| | | {
|
| | | Excels attrs = field.getAnnotation(Excels.class);
|
| | | Excel[] excels = attrs.value();
|
| | | for (Excel excel : excels)
|
| | | {
|
| | | putToField(field, excel);
|
| | | }
|
| | | }
|
| | | }
|
| | | this.fields = this.fields.stream().sorted(Comparator.comparing(objects -> ((Excel) objects[1]).sort())).collect(Collectors.toList());
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ¾å°å段éåä¸
|
| | | */
|
| | | private void putToField(Field field, Excel attr)
|
| | | {
|
| | | if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
|
| | | {
|
| | | this.fields.add(new Object[] { field, attr });
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * å建ä¸ä¸ªå·¥ä½ç°¿
|
| | | */
|
| | | public void createWorkbook()
|
| | | {
|
| | | this.wb = new SXSSFWorkbook(500);
|
| | | }
|
| | |
|
| | | /**
|
| | | * å建工ä½è¡¨
|
| | | * |
| | | * @param sheetNo sheetæ°é
|
| | | * @param index åºå·
|
| | | */
|
| | | public void createSheet(double sheetNo, int index)
|
| | | {
|
| | | this.sheet = wb.createSheet();
|
| | | this.styles = createStyles(wb);
|
| | | // 设置工ä½è¡¨çåç§°.
|
| | | if (sheetNo == 0)
|
| | | {
|
| | | wb.setSheetName(index, sheetName);
|
| | | }
|
| | | else
|
| | | {
|
| | | wb.setSheetName(index, sheetName + index);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·ååå
æ ¼å¼
|
| | | * |
| | | * @param row è·åçè¡
|
| | | * @param column è·ååå
æ ¼åå·
|
| | | * @return åå
æ ¼å¼
|
| | | */
|
| | | public Object getCellValue(Row row, int column)
|
| | | {
|
| | | if (row == null)
|
| | | {
|
| | | return row;
|
| | | }
|
| | | Object val = "";
|
| | | try
|
| | | {
|
| | | Cell cell = row.getCell(column);
|
| | | if (StringUtils.isNotNull(cell))
|
| | | {
|
| | | if (cell.getCellTypeEnum() == CellType.NUMERIC || cell.getCellTypeEnum() == CellType.FORMULA)
|
| | | {
|
| | | val = cell.getNumericCellValue();
|
| | | if (HSSFDateUtil.isCellDateFormatted(cell))
|
| | | {
|
| | | val = DateUtil.getJavaDate((Double) val); // POI Excel æ¥ææ ¼å¼è½¬æ¢
|
| | | }
|
| | | else
|
| | | {
|
| | | if ((Double) val % 1 > 0)
|
| | | {
|
| | | val = new DecimalFormat("0.00").format(val);
|
| | | }
|
| | | else
|
| | | {
|
| | | val = new DecimalFormat("0").format(val);
|
| | | }
|
| | | }
|
| | | }
|
| | | else if (cell.getCellTypeEnum() == CellType.STRING)
|
| | | {
|
| | | val = cell.getStringCellValue();
|
| | | }
|
| | | else if (cell.getCellTypeEnum() == CellType.BOOLEAN)
|
| | | {
|
| | | val = cell.getBooleanCellValue();
|
| | | }
|
| | | else if (cell.getCellTypeEnum() == CellType.ERROR)
|
| | | {
|
| | | val = cell.getErrorCellValue();
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | return val;
|
| | | }
|
| | | return val;
|
| | | }
|
| | | } |
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.utils.reflect; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.lang.reflect.Method; |
| | | import java.lang.reflect.Modifier; |
| | | import java.lang.reflect.ParameterizedType; |
| | | import java.lang.reflect.Type; |
| | | import java.util.Date; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.commons.lang3.Validate; |
| | | import org.apache.poi.ss.usermodel.DateUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | |
| | | /** |
| | | * åå°å·¥å
·ç±». æä¾è°ç¨getter/setteræ¹æ³, 访é®ç§æåé, è°ç¨ç§ææ¹æ³, è·åæ³åç±»åClass, 被AOPè¿ççå®ç±»çå·¥å
·å½æ°. |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @SuppressWarnings("rawtypes") |
| | | public class ReflectUtils |
| | | { |
| | | private static final String SETTER_PREFIX = "set"; |
| | | |
| | | private static final String GETTER_PREFIX = "get"; |
| | | |
| | | private static final String CGLIB_CLASS_SEPARATOR = "$$"; |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class); |
| | | |
| | | /** |
| | | * è°ç¨Getteræ¹æ³. |
| | | * æ¯æå¤çº§ï¼å¦ï¼å¯¹è±¡å.对象å.æ¹æ³ |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public static <E> E invokeGetter(Object obj, String propertyName) |
| | | { |
| | | Object object = obj; |
| | | for (String name : StringUtils.split(propertyName, ".")) |
| | | { |
| | | String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name); |
| | | object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); |
| | | } |
| | | return (E) object; |
| | | } |
| | | |
| | | /** |
| | | * è°ç¨Setteræ¹æ³, ä»
å¹é
æ¹æ³åã |
| | | * æ¯æå¤çº§ï¼å¦ï¼å¯¹è±¡å.对象å.æ¹æ³ |
| | | */ |
| | | public static <E> void invokeSetter(Object obj, String propertyName, E value) |
| | | { |
| | | Object object = obj; |
| | | String[] names = StringUtils.split(propertyName, "."); |
| | | for (int i = 0; i < names.length; i++) |
| | | { |
| | | if (i < names.length - 1) |
| | | { |
| | | String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]); |
| | | object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); |
| | | } |
| | | else |
| | | { |
| | | String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]); |
| | | invokeMethodByName(object, setterMethodName, new Object[] { value }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ç´æ¥è¯»åå¯¹è±¡å±æ§å¼, æ è§private/protected修饰符, ä¸ç»è¿getter彿°. |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public static <E> E getFieldValue(final Object obj, final String fieldName) |
| | | { |
| | | Field field = getAccessibleField(obj, fieldName); |
| | | if (field == null) |
| | | { |
| | | logger.debug("å¨ [" + obj.getClass() + "] ä¸ï¼æ²¡ææ¾å° [" + fieldName + "] åæ®µ "); |
| | | return null; |
| | | } |
| | | E result = null; |
| | | try |
| | | { |
| | | result = (E) field.get(obj); |
| | | } |
| | | catch (IllegalAccessException e) |
| | | { |
| | | logger.error("ä¸å¯è½æåºçå¼å¸¸{}", e.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * ç´æ¥è®¾ç½®å¯¹è±¡å±æ§å¼, æ è§private/protected修饰符, ä¸ç»è¿setter彿°. |
| | | */ |
| | | public static <E> void setFieldValue(final Object obj, final String fieldName, final E value) |
| | | { |
| | | Field field = getAccessibleField(obj, fieldName); |
| | | if (field == null) |
| | | { |
| | | // throw new IllegalArgumentException("å¨ [" + obj.getClass() + "] ä¸ï¼æ²¡ææ¾å° [" + fieldName + "] åæ®µ "); |
| | | logger.debug("å¨ [" + obj.getClass() + "] ä¸ï¼æ²¡ææ¾å° [" + fieldName + "] åæ®µ "); |
| | | return; |
| | | } |
| | | try |
| | | { |
| | | field.set(obj, value); |
| | | } |
| | | catch (IllegalAccessException e) |
| | | { |
| | | logger.error("ä¸å¯è½æåºçå¼å¸¸: {}", e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ç´æ¥è°ç¨å¯¹è±¡æ¹æ³, æ è§private/protected修饰符. |
| | | * ç¨äºä¸æ¬¡æ§è°ç¨çæ
åµï¼å¦ååºä½¿ç¨getAccessibleMethod()彿°è·å¾Methodååå¤è°ç¨. |
| | | * åæ¶å¹é
æ¹æ³å+åæ°ç±»åï¼ |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public static <E> E invokeMethod(final Object obj, final String methodName, final Class<?>[] parameterTypes, |
| | | final Object[] args) |
| | | { |
| | | if (obj == null || methodName == null) |
| | | { |
| | | return null; |
| | | } |
| | | Method method = getAccessibleMethod(obj, methodName, parameterTypes); |
| | | if (method == null) |
| | | { |
| | | logger.debug("å¨ [" + obj.getClass() + "] ä¸ï¼æ²¡ææ¾å° [" + methodName + "] æ¹æ³ "); |
| | | return null; |
| | | } |
| | | try |
| | | { |
| | | return (E) method.invoke(obj, args); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | String msg = "method: " + method + ", obj: " + obj + ", args: " + args + ""; |
| | | throw convertReflectionExceptionToUnchecked(msg, e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ç´æ¥è°ç¨å¯¹è±¡æ¹æ³, æ è§private/protectedä¿®é¥°ç¬¦ï¼ |
| | | * ç¨äºä¸æ¬¡æ§è°ç¨çæ
åµï¼å¦ååºä½¿ç¨getAccessibleMethodByName()彿°è·å¾Methodååå¤è°ç¨. |
| | | * åªå¹é
彿°åï¼å¦ææå¤ä¸ªåå彿°è°ç¨ç¬¬ä¸ä¸ªã |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public static <E> E invokeMethodByName(final Object obj, final String methodName, final Object[] args) |
| | | { |
| | | Method method = getAccessibleMethodByName(obj, methodName, args.length); |
| | | if (method == null) |
| | | { |
| | | // å¦æä¸ºç©ºä¸æ¥éï¼ç´æ¥è¿å空ã |
| | | logger.debug("å¨ [" + obj.getClass() + "] ä¸ï¼æ²¡ææ¾å° [" + methodName + "] æ¹æ³ "); |
| | | return null; |
| | | } |
| | | try |
| | | { |
| | | // ç±»å转æ¢ï¼å°åæ°æ°æ®ç±»å转æ¢ä¸ºç®æ æ¹æ³åæ°ç±»åï¼ |
| | | Class<?>[] cs = method.getParameterTypes(); |
| | | for (int i = 0; i < cs.length; i++) |
| | | { |
| | | if (args[i] != null && !args[i].getClass().equals(cs[i])) |
| | | { |
| | | if (cs[i] == String.class) |
| | | { |
| | | args[i] = Convert.toStr(args[i]); |
| | | if (StringUtils.endsWith((String) args[i], ".0")) |
| | | { |
| | | args[i] = StringUtils.substringBefore((String) args[i], ".0"); |
| | | } |
| | | } |
| | | else if (cs[i] == Integer.class) |
| | | { |
| | | args[i] = Convert.toInt(args[i]); |
| | | } |
| | | else if (cs[i] == Long.class) |
| | | { |
| | | args[i] = Convert.toLong(args[i]); |
| | | } |
| | | else if (cs[i] == Double.class) |
| | | { |
| | | args[i] = Convert.toDouble(args[i]); |
| | | } |
| | | else if (cs[i] == Float.class) |
| | | { |
| | | args[i] = Convert.toFloat(args[i]); |
| | | } |
| | | else if (cs[i] == Date.class) |
| | | { |
| | | if (args[i] instanceof String) |
| | | { |
| | | args[i] = DateUtils.parseDate(args[i]); |
| | | } |
| | | else |
| | | { |
| | | args[i] = DateUtil.getJavaDate((Double) args[i]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return (E) method.invoke(obj, args); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | String msg = "method: " + method + ", obj: " + obj + ", args: " + args + ""; |
| | | throw convertReflectionExceptionToUnchecked(msg, e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 循ç¯åä¸è½¬å, è·å对象çDeclaredField, 并强å¶è®¾ç½®ä¸ºå¯è®¿é®. |
| | | * å¦åä¸è½¬åå°Object仿 æ³æ¾å°, è¿ånull. |
| | | */ |
| | | public static Field getAccessibleField(final Object obj, final String fieldName) |
| | | { |
| | | // ä¸ºç©ºä¸æ¥éãç´æ¥è¿å null |
| | | if (obj == null) |
| | | { |
| | | return null; |
| | | } |
| | | Validate.notBlank(fieldName, "fieldName can't be blank"); |
| | | for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) |
| | | { |
| | | try |
| | | { |
| | | Field field = superClass.getDeclaredField(fieldName); |
| | | makeAccessible(field); |
| | | return field; |
| | | } |
| | | catch (NoSuchFieldException e) |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 循ç¯åä¸è½¬å, è·å对象çDeclaredMethod,并强å¶è®¾ç½®ä¸ºå¯è®¿é®. |
| | | * å¦åä¸è½¬åå°Object仿 æ³æ¾å°, è¿ånull. |
| | | * å¹é
彿°å+åæ°ç±»åã |
| | | * ç¨äºæ¹æ³éè¦è¢«å¤æ¬¡è°ç¨çæ
åµ. å
ä½¿ç¨æ¬å½æ°å
åå¾Method,ç¶åè°ç¨Method.invoke(Object obj, Object... args) |
| | | */ |
| | | public static Method getAccessibleMethod(final Object obj, final String methodName, |
| | | final Class<?>... parameterTypes) |
| | | { |
| | | // ä¸ºç©ºä¸æ¥éãç´æ¥è¿å null |
| | | if (obj == null) |
| | | { |
| | | return null; |
| | | } |
| | | Validate.notBlank(methodName, "methodName can't be blank"); |
| | | for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) |
| | | { |
| | | try |
| | | { |
| | | Method method = searchType.getDeclaredMethod(methodName, parameterTypes); |
| | | makeAccessible(method); |
| | | return method; |
| | | } |
| | | catch (NoSuchMethodException e) |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 循ç¯åä¸è½¬å, è·å对象çDeclaredMethod,并强å¶è®¾ç½®ä¸ºå¯è®¿é®. |
| | | * å¦åä¸è½¬åå°Object仿 æ³æ¾å°, è¿ånull. |
| | | * åªå¹é
彿°åã |
| | | * ç¨äºæ¹æ³éè¦è¢«å¤æ¬¡è°ç¨çæ
åµ. å
ä½¿ç¨æ¬å½æ°å
åå¾Method,ç¶åè°ç¨Method.invoke(Object obj, Object... args) |
| | | */ |
| | | public static Method getAccessibleMethodByName(final Object obj, final String methodName, int argsNum) |
| | | { |
| | | // ä¸ºç©ºä¸æ¥éãç´æ¥è¿å null |
| | | if (obj == null) |
| | | { |
| | | return null; |
| | | } |
| | | Validate.notBlank(methodName, "methodName can't be blank"); |
| | | for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) |
| | | { |
| | | Method[] methods = searchType.getDeclaredMethods(); |
| | | for (Method method : methods) |
| | | { |
| | | if (method.getName().equals(methodName) && method.getParameterTypes().length == argsNum) |
| | | { |
| | | makeAccessible(method); |
| | | return method; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * æ¹åprivate/protectedçæ¹æ³ä¸ºpublicï¼å°½éä¸è°ç¨å®é
æ¹å¨çè¯å¥ï¼é¿å
JDKçSecurityManageræ±æ¨ã |
| | | */ |
| | | public static void makeAccessible(Method method) |
| | | { |
| | | if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) |
| | | && !method.isAccessible()) |
| | | { |
| | | method.setAccessible(true); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¹åprivate/protectedçæååé为publicï¼å°½éä¸è°ç¨å®é
æ¹å¨çè¯å¥ï¼é¿å
JDKçSecurityManageræ±æ¨ã |
| | | */ |
| | | public static void makeAccessible(Field field) |
| | | { |
| | | if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) |
| | | || Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) |
| | | { |
| | | field.setAccessible(true); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * éè¿åå°, è·å¾Classå®ä¹ä¸å£°æçæ³ååæ°çç±»å, æ³¨ææ³åå¿
é¡»å®ä¹å¨ç¶ç±»å¤ |
| | | * 妿 æ³æ¾å°, è¿åObject.class. |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public static <T> Class<T> getClassGenricType(final Class clazz) |
| | | { |
| | | return getClassGenricType(clazz, 0); |
| | | } |
| | | |
| | | /** |
| | | * éè¿åå°, è·å¾Classå®ä¹ä¸å£°æçç¶ç±»çæ³ååæ°çç±»å. |
| | | * 妿 æ³æ¾å°, è¿åObject.class. |
| | | */ |
| | | public static Class getClassGenricType(final Class clazz, final int index) |
| | | { |
| | | Type genType = clazz.getGenericSuperclass(); |
| | | |
| | | if (!(genType instanceof ParameterizedType)) |
| | | { |
| | | logger.debug(clazz.getSimpleName() + "'s superclass not ParameterizedType"); |
| | | return Object.class; |
| | | } |
| | | |
| | | Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); |
| | | |
| | | if (index >= params.length || index < 0) |
| | | { |
| | | logger.debug("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: " |
| | | + params.length); |
| | | return Object.class; |
| | | } |
| | | if (!(params[index] instanceof Class)) |
| | | { |
| | | logger.debug(clazz.getSimpleName() + " not set the actual class on superclass generic parameter"); |
| | | return Object.class; |
| | | } |
| | | |
| | | return (Class) params[index]; |
| | | } |
| | | |
| | | public static Class<?> getUserClass(Object instance) |
| | | { |
| | | if (instance == null) |
| | | { |
| | | throw new RuntimeException("Instance must not be null"); |
| | | } |
| | | Class clazz = instance.getClass(); |
| | | if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) |
| | | { |
| | | Class<?> superClass = clazz.getSuperclass(); |
| | | if (superClass != null && !Object.class.equals(superClass)) |
| | | { |
| | | return superClass; |
| | | } |
| | | } |
| | | return clazz; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * å°åå°æ¶çchecked exception转æ¢ä¸ºunchecked exception. |
| | | */ |
| | | public static RuntimeException convertReflectionExceptionToUnchecked(String msg, Exception e) |
| | | { |
| | | if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException |
| | | || e instanceof NoSuchMethodException) |
| | | { |
| | | return new IllegalArgumentException(msg, e); |
| | | } |
| | | else if (e instanceof InvocationTargetException) |
| | | { |
| | | return new RuntimeException(msg, ((InvocationTargetException) e).getTargetException()); |
| | | } |
| | | return new RuntimeException(msg, e); |
| | | } |
| | | } |
| | | package com.ruoyi.common.utils.reflect;
|
| | |
|
| | | import java.lang.reflect.Field;
|
| | | import java.lang.reflect.InvocationTargetException;
|
| | | import java.lang.reflect.Method;
|
| | | import java.lang.reflect.Modifier;
|
| | | import java.lang.reflect.ParameterizedType;
|
| | | import java.lang.reflect.Type;
|
| | | import java.util.Date;
|
| | | import org.apache.commons.lang3.StringUtils;
|
| | | import org.apache.commons.lang3.Validate;
|
| | | import org.apache.poi.ss.usermodel.DateUtil;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import com.ruoyi.common.core.text.Convert;
|
| | | import com.ruoyi.common.utils.DateUtils;
|
| | |
|
| | | /**
|
| | | * åå°å·¥å
·ç±». æä¾è°ç¨getter/setteræ¹æ³, 访é®ç§æåé, è°ç¨ç§ææ¹æ³, è·åæ³åç±»åClass, 被AOPè¿ççå®ç±»çå·¥å
·å½æ°.
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @SuppressWarnings("rawtypes")
|
| | | public class ReflectUtils
|
| | | {
|
| | | private static final String SETTER_PREFIX = "set";
|
| | |
|
| | | private static final String GETTER_PREFIX = "get";
|
| | |
|
| | | private static final String CGLIB_CLASS_SEPARATOR = "$$";
|
| | |
|
| | | private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class);
|
| | |
|
| | | /**
|
| | | * è°ç¨Getteræ¹æ³.
|
| | | * æ¯æå¤çº§ï¼å¦ï¼å¯¹è±¡å.对象å.æ¹æ³
|
| | | */
|
| | | @SuppressWarnings("unchecked")
|
| | | public static <E> E invokeGetter(Object obj, String propertyName)
|
| | | {
|
| | | Object object = obj;
|
| | | for (String name : StringUtils.split(propertyName, "."))
|
| | | {
|
| | | String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name);
|
| | | object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
|
| | | }
|
| | | return (E) object;
|
| | | }
|
| | |
|
| | | /**
|
| | | * è°ç¨Setteræ¹æ³, ä»
å¹é
æ¹æ³åã
|
| | | * æ¯æå¤çº§ï¼å¦ï¼å¯¹è±¡å.对象å.æ¹æ³
|
| | | */
|
| | | public static <E> void invokeSetter(Object obj, String propertyName, E value)
|
| | | {
|
| | | Object object = obj;
|
| | | String[] names = StringUtils.split(propertyName, ".");
|
| | | for (int i = 0; i < names.length; i++)
|
| | | {
|
| | | if (i < names.length - 1)
|
| | | {
|
| | | String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]);
|
| | | object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
|
| | | }
|
| | | else
|
| | | {
|
| | | String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]);
|
| | | invokeMethodByName(object, setterMethodName, new Object[] { value });
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * ç´æ¥è¯»åå¯¹è±¡å±æ§å¼, æ è§private/protected修饰符, ä¸ç»è¿getter彿°.
|
| | | */
|
| | | @SuppressWarnings("unchecked")
|
| | | public static <E> E getFieldValue(final Object obj, final String fieldName)
|
| | | {
|
| | | Field field = getAccessibleField(obj, fieldName);
|
| | | if (field == null)
|
| | | {
|
| | | logger.debug("å¨ [" + obj.getClass() + "] ä¸ï¼æ²¡ææ¾å° [" + fieldName + "] åæ®µ ");
|
| | | return null;
|
| | | }
|
| | | E result = null;
|
| | | try
|
| | | {
|
| | | result = (E) field.get(obj);
|
| | | }
|
| | | catch (IllegalAccessException e)
|
| | | {
|
| | | logger.error("ä¸å¯è½æåºçå¼å¸¸{}", e.getMessage());
|
| | | }
|
| | | return result;
|
| | | }
|
| | |
|
| | | /**
|
| | | * ç´æ¥è®¾ç½®å¯¹è±¡å±æ§å¼, æ è§private/protected修饰符, ä¸ç»è¿setter彿°.
|
| | | */
|
| | | public static <E> void setFieldValue(final Object obj, final String fieldName, final E value)
|
| | | {
|
| | | Field field = getAccessibleField(obj, fieldName);
|
| | | if (field == null)
|
| | | {
|
| | | // throw new IllegalArgumentException("å¨ [" + obj.getClass() + "] ä¸ï¼æ²¡ææ¾å° [" + fieldName + "] åæ®µ ");
|
| | | logger.debug("å¨ [" + obj.getClass() + "] ä¸ï¼æ²¡ææ¾å° [" + fieldName + "] åæ®µ ");
|
| | | return;
|
| | | }
|
| | | try
|
| | | {
|
| | | field.set(obj, value);
|
| | | }
|
| | | catch (IllegalAccessException e)
|
| | | {
|
| | | logger.error("ä¸å¯è½æåºçå¼å¸¸: {}", e.getMessage());
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * ç´æ¥è°ç¨å¯¹è±¡æ¹æ³, æ è§private/protected修饰符.
|
| | | * ç¨äºä¸æ¬¡æ§è°ç¨çæ
åµï¼å¦ååºä½¿ç¨getAccessibleMethod()彿°è·å¾Methodååå¤è°ç¨.
|
| | | * åæ¶å¹é
æ¹æ³å+åæ°ç±»åï¼
|
| | | */
|
| | | @SuppressWarnings("unchecked")
|
| | | public static <E> E invokeMethod(final Object obj, final String methodName, final Class<?>[] parameterTypes,
|
| | | final Object[] args)
|
| | | {
|
| | | if (obj == null || methodName == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | Method method = getAccessibleMethod(obj, methodName, parameterTypes);
|
| | | if (method == null)
|
| | | {
|
| | | logger.debug("å¨ [" + obj.getClass() + "] ä¸ï¼æ²¡ææ¾å° [" + methodName + "] æ¹æ³ ");
|
| | | return null;
|
| | | }
|
| | | try
|
| | | {
|
| | | return (E) method.invoke(obj, args);
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | String msg = "method: " + method + ", obj: " + obj + ", args: " + args + "";
|
| | | throw convertReflectionExceptionToUnchecked(msg, e);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * ç´æ¥è°ç¨å¯¹è±¡æ¹æ³, æ è§private/protected修饰符ï¼
|
| | | * ç¨äºä¸æ¬¡æ§è°ç¨çæ
åµï¼å¦ååºä½¿ç¨getAccessibleMethodByName()彿°è·å¾Methodååå¤è°ç¨.
|
| | | * åªå¹é
彿°åï¼å¦ææå¤ä¸ªåå彿°è°ç¨ç¬¬ä¸ä¸ªã
|
| | | */
|
| | | @SuppressWarnings("unchecked")
|
| | | public static <E> E invokeMethodByName(final Object obj, final String methodName, final Object[] args)
|
| | | {
|
| | | Method method = getAccessibleMethodByName(obj, methodName, args.length);
|
| | | if (method == null)
|
| | | {
|
| | | // å¦æä¸ºç©ºä¸æ¥éï¼ç´æ¥è¿å空ã
|
| | | logger.debug("å¨ [" + obj.getClass() + "] ä¸ï¼æ²¡ææ¾å° [" + methodName + "] æ¹æ³ ");
|
| | | return null;
|
| | | }
|
| | | try
|
| | | {
|
| | | // ç±»å转æ¢ï¼å°åæ°æ°æ®ç±»å转æ¢ä¸ºç®æ æ¹æ³åæ°ç±»åï¼
|
| | | Class<?>[] cs = method.getParameterTypes();
|
| | | for (int i = 0; i < cs.length; i++)
|
| | | {
|
| | | if (args[i] != null && !args[i].getClass().equals(cs[i]))
|
| | | {
|
| | | if (cs[i] == String.class)
|
| | | {
|
| | | args[i] = Convert.toStr(args[i]);
|
| | | if (StringUtils.endsWith((String) args[i], ".0"))
|
| | | {
|
| | | args[i] = StringUtils.substringBefore((String) args[i], ".0");
|
| | | }
|
| | | }
|
| | | else if (cs[i] == Integer.class)
|
| | | {
|
| | | args[i] = Convert.toInt(args[i]);
|
| | | }
|
| | | else if (cs[i] == Long.class)
|
| | | {
|
| | | args[i] = Convert.toLong(args[i]);
|
| | | }
|
| | | else if (cs[i] == Double.class)
|
| | | {
|
| | | args[i] = Convert.toDouble(args[i]);
|
| | | }
|
| | | else if (cs[i] == Float.class)
|
| | | {
|
| | | args[i] = Convert.toFloat(args[i]);
|
| | | }
|
| | | else if (cs[i] == Date.class)
|
| | | {
|
| | | if (args[i] instanceof String)
|
| | | {
|
| | | args[i] = DateUtils.parseDate(args[i]);
|
| | | }
|
| | | else
|
| | | {
|
| | | args[i] = DateUtil.getJavaDate((Double) args[i]);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | return (E) method.invoke(obj, args);
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | String msg = "method: " + method + ", obj: " + obj + ", args: " + args + "";
|
| | | throw convertReflectionExceptionToUnchecked(msg, e);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 循ç¯åä¸è½¬å, è·å对象çDeclaredField, 并强å¶è®¾ç½®ä¸ºå¯è®¿é®.
|
| | | * å¦åä¸è½¬åå°Object仿 æ³æ¾å°, è¿ånull.
|
| | | */
|
| | | public static Field getAccessibleField(final Object obj, final String fieldName)
|
| | | {
|
| | | // ä¸ºç©ºä¸æ¥éãç´æ¥è¿å null
|
| | | if (obj == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | Validate.notBlank(fieldName, "fieldName can't be blank");
|
| | | for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass())
|
| | | {
|
| | | try
|
| | | {
|
| | | Field field = superClass.getDeclaredField(fieldName);
|
| | | makeAccessible(field);
|
| | | return field;
|
| | | }
|
| | | catch (NoSuchFieldException e)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 循ç¯åä¸è½¬å, è·å对象çDeclaredMethod,并强å¶è®¾ç½®ä¸ºå¯è®¿é®.
|
| | | * å¦åä¸è½¬åå°Object仿 æ³æ¾å°, è¿ånull.
|
| | | * å¹é
彿°å+åæ°ç±»åã
|
| | | * ç¨äºæ¹æ³éè¦è¢«å¤æ¬¡è°ç¨çæ
åµ. å
ä½¿ç¨æ¬å½æ°å
åå¾Method,ç¶åè°ç¨Method.invoke(Object obj, Object... args)
|
| | | */
|
| | | public static Method getAccessibleMethod(final Object obj, final String methodName,
|
| | | final Class<?>... parameterTypes)
|
| | | {
|
| | | // ä¸ºç©ºä¸æ¥éãç´æ¥è¿å null
|
| | | if (obj == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | Validate.notBlank(methodName, "methodName can't be blank");
|
| | | for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass())
|
| | | {
|
| | | try
|
| | | {
|
| | | Method method = searchType.getDeclaredMethod(methodName, parameterTypes);
|
| | | makeAccessible(method);
|
| | | return method;
|
| | | }
|
| | | catch (NoSuchMethodException e)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 循ç¯åä¸è½¬å, è·å对象çDeclaredMethod,并强å¶è®¾ç½®ä¸ºå¯è®¿é®.
|
| | | * å¦åä¸è½¬åå°Object仿 æ³æ¾å°, è¿ånull.
|
| | | * åªå¹é
彿°åã
|
| | | * ç¨äºæ¹æ³éè¦è¢«å¤æ¬¡è°ç¨çæ
åµ. å
ä½¿ç¨æ¬å½æ°å
åå¾Method,ç¶åè°ç¨Method.invoke(Object obj, Object... args)
|
| | | */
|
| | | public static Method getAccessibleMethodByName(final Object obj, final String methodName, int argsNum)
|
| | | {
|
| | | // ä¸ºç©ºä¸æ¥éãç´æ¥è¿å null
|
| | | if (obj == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | Validate.notBlank(methodName, "methodName can't be blank");
|
| | | for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass())
|
| | | {
|
| | | Method[] methods = searchType.getDeclaredMethods();
|
| | | for (Method method : methods)
|
| | | {
|
| | | if (method.getName().equals(methodName) && method.getParameterTypes().length == argsNum)
|
| | | {
|
| | | makeAccessible(method);
|
| | | return method;
|
| | | }
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ¹åprivate/protectedçæ¹æ³ä¸ºpublicï¼å°½éä¸è°ç¨å®é
æ¹å¨çè¯å¥ï¼é¿å
JDKçSecurityManageræ±æ¨ã
|
| | | */
|
| | | public static void makeAccessible(Method method)
|
| | | {
|
| | | if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers()))
|
| | | && !method.isAccessible())
|
| | | {
|
| | | method.setAccessible(true);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ¹åprivate/protectedçæååé为publicï¼å°½éä¸è°ç¨å®é
æ¹å¨çè¯å¥ï¼é¿å
JDKçSecurityManageræ±æ¨ã
|
| | | */
|
| | | public static void makeAccessible(Field field)
|
| | | {
|
| | | if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())
|
| | | || Modifier.isFinal(field.getModifiers())) && !field.isAccessible())
|
| | | {
|
| | | field.setAccessible(true);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * éè¿åå°, è·å¾Classå®ä¹ä¸å£°æçæ³ååæ°çç±»å, æ³¨ææ³åå¿
é¡»å®ä¹å¨ç¶ç±»å¤
|
| | | * 妿 æ³æ¾å°, è¿åObject.class.
|
| | | */
|
| | | @SuppressWarnings("unchecked")
|
| | | public static <T> Class<T> getClassGenricType(final Class clazz)
|
| | | {
|
| | | return getClassGenricType(clazz, 0);
|
| | | }
|
| | |
|
| | | /**
|
| | | * éè¿åå°, è·å¾Classå®ä¹ä¸å£°æçç¶ç±»çæ³ååæ°çç±»å.
|
| | | * 妿 æ³æ¾å°, è¿åObject.class.
|
| | | */
|
| | | public static Class getClassGenricType(final Class clazz, final int index)
|
| | | {
|
| | | Type genType = clazz.getGenericSuperclass();
|
| | |
|
| | | if (!(genType instanceof ParameterizedType))
|
| | | {
|
| | | logger.debug(clazz.getSimpleName() + "'s superclass not ParameterizedType");
|
| | | return Object.class;
|
| | | }
|
| | |
|
| | | Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
|
| | |
|
| | | if (index >= params.length || index < 0)
|
| | | {
|
| | | logger.debug("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: "
|
| | | + params.length);
|
| | | return Object.class;
|
| | | }
|
| | | if (!(params[index] instanceof Class))
|
| | | {
|
| | | logger.debug(clazz.getSimpleName() + " not set the actual class on superclass generic parameter");
|
| | | return Object.class;
|
| | | }
|
| | |
|
| | | return (Class) params[index];
|
| | | }
|
| | |
|
| | | public static Class<?> getUserClass(Object instance)
|
| | | {
|
| | | if (instance == null)
|
| | | {
|
| | | throw new RuntimeException("Instance must not be null");
|
| | | }
|
| | | Class clazz = instance.getClass();
|
| | | if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR))
|
| | | {
|
| | | Class<?> superClass = clazz.getSuperclass();
|
| | | if (superClass != null && !Object.class.equals(superClass))
|
| | | {
|
| | | return superClass;
|
| | | }
|
| | | }
|
| | | return clazz;
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * å°åå°æ¶çchecked exception转æ¢ä¸ºunchecked exception.
|
| | | */
|
| | | public static RuntimeException convertReflectionExceptionToUnchecked(String msg, Exception e)
|
| | | {
|
| | | if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException
|
| | | || e instanceof NoSuchMethodException)
|
| | | {
|
| | | return new IllegalArgumentException(msg, e);
|
| | | }
|
| | | else if (e instanceof InvocationTargetException)
|
| | | {
|
| | | return new RuntimeException(msg, ((InvocationTargetException) e).getTargetException());
|
| | | }
|
| | | return new RuntimeException(msg, e);
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/IdUtils.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.utils;
|
| | | package com.ruoyi.common.utils.uuid;
|
| | |
|
| | | import com.ruoyi.common.core.lang.UUID;
|
| | | import com.ruoyi.common.utils.uuid.UUID;
|
| | |
|
| | | /**
|
| | | * IDçæå¨å·¥å
·ç±»
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/core/lang/UUID.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.core.lang;
|
| | | package com.ruoyi.common.utils.uuid;
|
| | |
|
| | | import java.security.MessageDigest;
|
| | | import java.security.NoSuchAlgorithmException;
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?>
|
| | | <project xmlns="http://maven.apache.org/POM/4.0.0"
|
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
| | | <parent>
|
| | | <artifactId>ruoyi</artifactId>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <version>3.0.0</version>
|
| | | </parent>
|
| | | <modelVersion>4.0.0</modelVersion>
|
| | |
|
| | | <artifactId>ruoyi-framework</artifactId>
|
| | |
|
| | | <description>
|
| | | frameworkæ¡æ¶æ ¸å¿
|
| | | </description>
|
| | |
|
| | | <dependencies>
|
| | |
|
| | | <!-- SpringBoot Webå®¹å¨ -->
|
| | | <dependency>
|
| | | <groupId>org.springframework.boot</groupId>
|
| | | <artifactId>spring-boot-starter-web</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- SpringBoot æ¦æªå¨ -->
|
| | | <dependency>
|
| | | <groupId>org.springframework.boot</groupId>
|
| | | <artifactId>spring-boot-starter-aop</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- é¿éæ°æ®åºè¿æ¥æ± -->
|
| | | <dependency>
|
| | | <groupId>com.alibaba</groupId>
|
| | | <artifactId>druid-spring-boot-starter</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- è·åç³»ç»ä¿¡æ¯ -->
|
| | | <dependency>
|
| | | <groupId>com.github.oshi</groupId>
|
| | | <artifactId>oshi-core</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <dependency>
|
| | | <groupId>net.java.dev.jna</groupId>
|
| | | <artifactId>jna</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <dependency>
|
| | | <groupId>net.java.dev.jna</groupId>
|
| | | <artifactId>jna-platform</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- ç³»ç»æ¨¡å-->
|
| | | <dependency>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi-system</artifactId>
|
| | | </dependency>
|
| | |
|
| | | </dependencies>
|
| | |
|
| | | </project> |
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java ÐÞ¸Ä |
| | |
| | | import org.aspectj.lang.annotation.Pointcut;
|
| | | import org.aspectj.lang.reflect.MethodSignature;
|
| | | import org.springframework.stereotype.Component;
|
| | | import com.ruoyi.common.annotation.DataScope;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | | import com.ruoyi.common.core.domain.entity.SysRole;
|
| | | import com.ruoyi.common.core.domain.entity.SysUser;
|
| | | import com.ruoyi.common.core.domain.model.LoginUser;
|
| | | import com.ruoyi.common.utils.ServletUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.spring.SpringUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | | import com.ruoyi.framework.security.service.TokenService;
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | | import com.ruoyi.project.system.domain.SysRole;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.framework.web.service.TokenService;
|
| | |
|
| | | /**
|
| | | * æ°æ®è¿æ»¤å¤ç
|
| | |
| | | public static final String DATA_SCOPE = "dataScope";
|
| | |
|
| | | // é
ç½®ç»å
¥ç¹
|
| | | @Pointcut("@annotation(com.ruoyi.framework.aspectj.lang.annotation.DataScope)")
|
| | | @Pointcut("@annotation(com.ruoyi.common.annotation.DataScope)")
|
| | | public void dataScopePointCut()
|
| | | {
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java ÐÞ¸Ä |
| | |
| | | import org.springframework.core.annotation.AnnotationUtils;
|
| | | import org.springframework.core.annotation.Order;
|
| | | import org.springframework.stereotype.Component;
|
| | | import com.ruoyi.common.annotation.DataSource;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
|
| | | import com.ruoyi.framework.datasource.DynamicDataSourceContextHolder;
|
| | |
|
| | | /**
|
| | |
| | | {
|
| | | protected Logger logger = LoggerFactory.getLogger(getClass());
|
| | |
|
| | | @Pointcut("@annotation(com.ruoyi.framework.aspectj.lang.annotation.DataSource)"
|
| | | + "|| @within(com.ruoyi.framework.aspectj.lang.annotation.DataSource)")
|
| | | @Pointcut("@annotation(com.ruoyi.common.annotation.DataSource)"
|
| | | + "|| @within(com.ruoyi.common.annotation.DataSource)")
|
| | | public void dsPointCut()
|
| | | {
|
| | |
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java ÐÞ¸Ä |
| | |
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.springframework.web.servlet.HandlerMapping;
|
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.core.domain.model.LoginUser;
|
| | | import com.ruoyi.common.enums.BusinessStatus;
|
| | | import com.ruoyi.common.enums.HttpMethod;
|
| | | import com.ruoyi.common.utils.ServletUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.ip.IpUtils;
|
| | | import com.ruoyi.common.utils.spring.SpringUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessStatus;
|
| | | import com.ruoyi.framework.manager.AsyncManager;
|
| | | import com.ruoyi.framework.manager.factory.AsyncFactory;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | | import com.ruoyi.framework.security.service.TokenService;
|
| | | import com.ruoyi.project.monitor.domain.SysOperLog;
|
| | | import com.ruoyi.framework.web.service.TokenService;
|
| | | import com.ruoyi.system.domain.SysOperLog;
|
| | |
|
| | | /**
|
| | | * æä½æ¥å¿è®°å½å¤ç
|
| | |
| | | private static final Logger log = LoggerFactory.getLogger(LogAspect.class);
|
| | |
|
| | | // é
ç½®ç»å
¥ç¹
|
| | | @Pointcut("@annotation(com.ruoyi.framework.aspectj.lang.annotation.Log)")
|
| | | @Pointcut("@annotation(com.ruoyi.common.annotation.Log)")
|
| | | public void logPointCut()
|
| | | {
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java ÐÞ¸Ä |
| | |
| | | // 表示éè¿aopæ¡æ¶æ´é²è¯¥ä»£ç对象,AopContextè½å¤è®¿é®
|
| | | @EnableAspectJAutoProxy(exposeProxy = true)
|
| | | // æå®è¦æ«æçMapperç±»çå
çè·¯å¾
|
| | | @MapperScan("com.ruoyi.project.**.mapper")
|
| | | @MapperScan("com.ruoyi.**.mapper")
|
| | | public class ApplicationConfig
|
| | | {
|
| | | /**
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/config/DruidConfig.java ÐÞ¸Ä |
| | |
| | | import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
|
| | | import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties;
|
| | | import com.alibaba.druid.util.Utils;
|
| | | import com.ruoyi.common.enums.DataSourceType;
|
| | | import com.ruoyi.common.utils.spring.SpringUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
|
| | | import com.ruoyi.framework.config.properties.DruidProperties;
|
| | | import com.ruoyi.framework.datasource.DynamicDataSource;
|
| | |
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java ÐÞ¸Ä |
| | |
| | | import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
| | | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
| | | import com.ruoyi.common.config.RuoYiConfig;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor;
|
| | |
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.interceptor; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.method.HandlerMethod; |
| | | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.framework.interceptor.annotation.RepeatSubmit; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | |
| | | /** |
| | | * 鲿¢éå¤æäº¤æ¦æªå¨ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter |
| | | { |
| | | @Override |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception |
| | | { |
| | | if (handler instanceof HandlerMethod) |
| | | { |
| | | HandlerMethod handlerMethod = (HandlerMethod) handler; |
| | | Method method = handlerMethod.getMethod(); |
| | | RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class); |
| | | if (annotation != null) |
| | | { |
| | | if (this.isRepeatSubmit(request)) |
| | | { |
| | | AjaxResult ajaxResult = AjaxResult.error("ä¸å
许éå¤æäº¤ï¼è¯·ç¨ååè¯"); |
| | | ServletUtils.renderString(response, JSONObject.toJSONString(ajaxResult)); |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return super.preHandle(request, response, handler); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * éªè¯æ¯å¦éå¤æäº¤ç±åç±»å®ç°å
·ä½çé²éå¤æäº¤çè§å |
| | | * |
| | | * @param httpServletRequest |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public abstract boolean isRepeatSubmit(HttpServletRequest request); |
| | | } |
| | | package com.ruoyi.framework.interceptor;
|
| | |
|
| | | import java.lang.reflect.Method;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.web.method.HandlerMethod;
|
| | | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.ruoyi.common.annotation.RepeatSubmit;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.utils.ServletUtils;
|
| | |
|
| | | /**
|
| | | * 鲿¢éå¤æäº¤æ¦æªå¨
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @Component
|
| | | public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter
|
| | | {
|
| | | @Override
|
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
|
| | | {
|
| | | if (handler instanceof HandlerMethod)
|
| | | {
|
| | | HandlerMethod handlerMethod = (HandlerMethod) handler;
|
| | | Method method = handlerMethod.getMethod();
|
| | | RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
|
| | | if (annotation != null)
|
| | | {
|
| | | if (this.isRepeatSubmit(request))
|
| | | {
|
| | | AjaxResult ajaxResult = AjaxResult.error("ä¸å
许éå¤æäº¤ï¼è¯·ç¨ååè¯");
|
| | | ServletUtils.renderString(response, JSONObject.toJSONString(ajaxResult));
|
| | | return false;
|
| | | }
|
| | | }
|
| | | return true;
|
| | | }
|
| | | else
|
| | | {
|
| | | return super.preHandle(request, response, handler);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * éªè¯æ¯å¦éå¤æäº¤ç±åç±»å®ç°å
·ä½çé²éå¤æäº¤çè§å
|
| | | * |
| | | * @param httpServletRequest
|
| | | * @return
|
| | | * @throws Exception
|
| | | */
|
| | | public abstract boolean isRepeatSubmit(HttpServletRequest request);
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.interceptor.impl; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.concurrent.TimeUnit; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.common.filter.RepeatedlyRequestWrapper; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.http.HttpHelper; |
| | | import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor; |
| | | import com.ruoyi.framework.redis.RedisCache; |
| | | |
| | | /** |
| | | * å¤æè¯·æ±urlåæ°æ®æ¯å¦åä¸ä¸æ¬¡ç¸åï¼ |
| | | * 妿å䏿¬¡ç¸åï¼åæ¯éå¤æäº¤è¡¨åã æææ¶é´ä¸º10ç§å
ã |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class SameUrlDataInterceptor extends RepeatSubmitInterceptor |
| | | { |
| | | public final String REPEAT_PARAMS = "repeatParams"; |
| | | |
| | | public final String REPEAT_TIME = "repeatTime"; |
| | | |
| | | public final String CACHE_REPEAT_KEY = "repeatData"; |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | /** |
| | | * é´éæ¶é´ï¼åä½:ç§ é»è®¤10ç§ |
| | | * |
| | | * 两次ç¸ååæ°ç请æ±ï¼å¦æé´éæ¶é´å¤§äºè¯¥åæ°ï¼ç³»ç»ä¸ä¼è®¤å®ä¸ºéå¤æäº¤çæ°æ® |
| | | */ |
| | | private int intervalTime = 10; |
| | | |
| | | public void setIntervalTime(int intervalTime) |
| | | { |
| | | this.intervalTime = intervalTime; |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | @Override |
| | | public boolean isRepeatSubmit(HttpServletRequest request) |
| | | { |
| | | RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper) request; |
| | | String nowParams = HttpHelper.getBodyString(repeatedlyRequest); |
| | | |
| | | // bodyåæ°ä¸ºç©ºï¼è·åParameterçæ°æ® |
| | | if (StringUtils.isEmpty(nowParams)) |
| | | { |
| | | nowParams = JSONObject.toJSONString(request.getParameterMap()); |
| | | } |
| | | Map<String, Object> nowDataMap = new HashMap<String, Object>(); |
| | | nowDataMap.put(REPEAT_PARAMS, nowParams); |
| | | nowDataMap.put(REPEAT_TIME, System.currentTimeMillis()); |
| | | |
| | | // 请æ±å°åï¼ä½ä¸ºåæ¾cacheçkeyå¼ï¼ |
| | | String url = request.getRequestURI(); |
| | | |
| | | Object sessionObj = redisCache.getCacheObject(CACHE_REPEAT_KEY); |
| | | if (sessionObj != null) |
| | | { |
| | | Map<String, Object> sessionMap = (Map<String, Object>) sessionObj; |
| | | if (sessionMap.containsKey(url)) |
| | | { |
| | | Map<String, Object> preDataMap = (Map<String, Object>) sessionMap.get(url); |
| | | if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | Map<String, Object> cacheMap = new HashMap<String, Object>(); |
| | | cacheMap.put(url, nowDataMap); |
| | | redisCache.setCacheObject(CACHE_REPEAT_KEY, cacheMap, intervalTime, TimeUnit.SECONDS); |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 夿忰æ¯å¦ç¸å |
| | | */ |
| | | private boolean compareParams(Map<String, Object> nowMap, Map<String, Object> preMap) |
| | | { |
| | | String nowParams = (String) nowMap.get(REPEAT_PARAMS); |
| | | String preParams = (String) preMap.get(REPEAT_PARAMS); |
| | | return nowParams.equals(preParams); |
| | | } |
| | | |
| | | /** |
| | | * å¤æä¸¤æ¬¡é´éæ¶é´ |
| | | */ |
| | | private boolean compareTime(Map<String, Object> nowMap, Map<String, Object> preMap) |
| | | { |
| | | long time1 = (Long) nowMap.get(REPEAT_TIME); |
| | | long time2 = (Long) preMap.get(REPEAT_TIME); |
| | | if ((time1 - time2) < (this.intervalTime * 1000)) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | | package com.ruoyi.framework.interceptor.impl;
|
| | |
|
| | | import java.util.HashMap;
|
| | | import java.util.Map;
|
| | | import java.util.concurrent.TimeUnit;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Component;
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.ruoyi.common.core.redis.RedisCache;
|
| | | import com.ruoyi.common.filter.RepeatedlyRequestWrapper;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.http.HttpHelper;
|
| | | import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor;
|
| | |
|
| | | /**
|
| | | * å¤æè¯·æ±urlåæ°æ®æ¯å¦åä¸ä¸æ¬¡ç¸åï¼
|
| | | * 妿å䏿¬¡ç¸åï¼åæ¯éå¤æäº¤è¡¨åã æææ¶é´ä¸º10ç§å
ã
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @Component
|
| | | public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
|
| | | {
|
| | | public final String REPEAT_PARAMS = "repeatParams";
|
| | |
|
| | | public final String REPEAT_TIME = "repeatTime";
|
| | |
|
| | | public final String CACHE_REPEAT_KEY = "repeatData";
|
| | |
|
| | | @Autowired
|
| | | private RedisCache redisCache;
|
| | |
|
| | | /**
|
| | | * é´éæ¶é´ï¼åä½:ç§ é»è®¤10ç§
|
| | | * |
| | | * 两次ç¸ååæ°ç请æ±ï¼å¦æé´éæ¶é´å¤§äºè¯¥åæ°ï¼ç³»ç»ä¸ä¼è®¤å®ä¸ºéå¤æäº¤çæ°æ®
|
| | | */
|
| | | private int intervalTime = 10;
|
| | |
|
| | | public void setIntervalTime(int intervalTime)
|
| | | {
|
| | | this.intervalTime = intervalTime;
|
| | | }
|
| | |
|
| | | @SuppressWarnings("unchecked")
|
| | | @Override
|
| | | public boolean isRepeatSubmit(HttpServletRequest request)
|
| | | {
|
| | | RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper) request;
|
| | | String nowParams = HttpHelper.getBodyString(repeatedlyRequest);
|
| | |
|
| | | // bodyåæ°ä¸ºç©ºï¼è·åParameterçæ°æ®
|
| | | if (StringUtils.isEmpty(nowParams))
|
| | | {
|
| | | nowParams = JSONObject.toJSONString(request.getParameterMap());
|
| | | }
|
| | | Map<String, Object> nowDataMap = new HashMap<String, Object>();
|
| | | nowDataMap.put(REPEAT_PARAMS, nowParams);
|
| | | nowDataMap.put(REPEAT_TIME, System.currentTimeMillis());
|
| | |
|
| | | // 请æ±å°åï¼ä½ä¸ºåæ¾cacheçkeyå¼ï¼
|
| | | String url = request.getRequestURI();
|
| | |
|
| | | Object sessionObj = redisCache.getCacheObject(CACHE_REPEAT_KEY);
|
| | | if (sessionObj != null)
|
| | | {
|
| | | Map<String, Object> sessionMap = (Map<String, Object>) sessionObj;
|
| | | if (sessionMap.containsKey(url))
|
| | | {
|
| | | Map<String, Object> preDataMap = (Map<String, Object>) sessionMap.get(url);
|
| | | if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap))
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | }
|
| | | Map<String, Object> cacheMap = new HashMap<String, Object>();
|
| | | cacheMap.put(url, nowDataMap);
|
| | | redisCache.setCacheObject(CACHE_REPEAT_KEY, cacheMap, intervalTime, TimeUnit.SECONDS);
|
| | | return false;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 夿忰æ¯å¦ç¸å
|
| | | */
|
| | | private boolean compareParams(Map<String, Object> nowMap, Map<String, Object> preMap)
|
| | | {
|
| | | String nowParams = (String) nowMap.get(REPEAT_PARAMS);
|
| | | String preParams = (String) preMap.get(REPEAT_PARAMS);
|
| | | return nowParams.equals(preParams);
|
| | | }
|
| | |
|
| | | /**
|
| | | * å¤æä¸¤æ¬¡é´éæ¶é´
|
| | | */
|
| | | private boolean compareTime(Map<String, Object> nowMap, Map<String, Object> preMap)
|
| | | {
|
| | | long time1 = (Long) nowMap.get(REPEAT_TIME);
|
| | | long time2 = (Long) preMap.get(REPEAT_TIME);
|
| | | if ((time1 - time2) < (this.intervalTime * 1000))
|
| | | {
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java ÐÞ¸Ä |
| | |
| | | import com.ruoyi.common.utils.ip.AddressUtils;
|
| | | import com.ruoyi.common.utils.ip.IpUtils;
|
| | | import com.ruoyi.common.utils.spring.SpringUtils;
|
| | | import com.ruoyi.project.monitor.domain.SysLogininfor;
|
| | | import com.ruoyi.project.monitor.domain.SysOperLog;
|
| | | import com.ruoyi.project.monitor.service.ISysLogininforService;
|
| | | import com.ruoyi.project.monitor.service.ISysOperLogService;
|
| | | import com.ruoyi.system.domain.SysLogininfor;
|
| | | import com.ruoyi.system.domain.SysOperLog;
|
| | | import com.ruoyi.system.service.ISysLogininforService;
|
| | | import com.ruoyi.system.service.ISysOperLogService;
|
| | | import eu.bitwalker.useragentutils.UserAgent;
|
| | |
|
| | | /**
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java ÐÞ¸Ä |
| | |
| | | import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.web.filter.OncePerRequestFilter;
|
| | | import com.ruoyi.common.core.domain.model.LoginUser;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | | import com.ruoyi.framework.security.service.TokenService;
|
| | | import com.ruoyi.framework.web.service.TokenService;
|
| | |
|
| | | /**
|
| | | * tokenè¿æ»¤å¨ éªè¯tokenæææ§
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java ÐÞ¸Ä |
| | |
| | | import org.springframework.stereotype.Component;
|
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.ruoyi.common.constant.HttpStatus;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.utils.ServletUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | |
|
| | | /**
|
| | | * 认è¯å¤±è´¥å¤çç±» è¿åæªææ
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java ÐÞ¸Ä |
| | |
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.constant.HttpStatus;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.domain.model.LoginUser;
|
| | | import com.ruoyi.common.utils.ServletUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.manager.AsyncManager;
|
| | | import com.ruoyi.framework.manager.factory.AsyncFactory;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | | import com.ruoyi.framework.security.service.TokenService;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.service.TokenService;
|
| | |
|
| | | /**
|
| | | * èªå®ä¹éåºå¤çç±» è¿åæå
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java ÐÞ¸Ä |
| | |
| | | import org.springframework.web.bind.annotation.RestControllerAdvice;
|
| | | import org.springframework.web.servlet.NoHandlerFoundException;
|
| | | import com.ruoyi.common.constant.HttpStatus;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.exception.BaseException;
|
| | | import com.ruoyi.common.exception.CustomException;
|
| | | import com.ruoyi.common.exception.DemoModeException;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | |
|
| | | /**
|
| | | * å
¨å±å¼å¸¸å¤çå¨
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/security/service/PermissionService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.security.service;
|
| | | package com.ruoyi.framework.web.service;
|
| | |
|
| | | import java.util.Set;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.util.CollectionUtils;
|
| | | import com.ruoyi.common.core.domain.entity.SysRole;
|
| | | import com.ruoyi.common.core.domain.model.LoginUser;
|
| | | import com.ruoyi.common.utils.ServletUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | | import com.ruoyi.project.system.domain.SysRole;
|
| | |
|
| | | /**
|
| | | * RuoYié¦å èªå®ä¹æéå®ç°ï¼ssåèªSpringSecurityé¦åæ¯
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/security/service/SysLoginService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.security.service;
|
| | | package com.ruoyi.framework.web.service;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | import org.springframework.security.core.Authentication;
|
| | | import org.springframework.stereotype.Component;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.core.domain.model.LoginUser;
|
| | | import com.ruoyi.common.core.redis.RedisCache;
|
| | | import com.ruoyi.common.exception.CustomException;
|
| | | import com.ruoyi.common.exception.user.CaptchaException;
|
| | | import com.ruoyi.common.exception.user.CaptchaExpireException;
|
| | |
| | | import com.ruoyi.common.utils.MessageUtils;
|
| | | import com.ruoyi.framework.manager.AsyncManager;
|
| | | import com.ruoyi.framework.manager.factory.AsyncFactory;
|
| | | import com.ruoyi.framework.redis.RedisCache;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | |
|
| | | /**
|
| | | * ç»å½æ ¡éªæ¹æ³
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/security/service/SysPermissionService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.security.service;
|
| | | package com.ruoyi.framework.web.service;
|
| | |
|
| | | import java.util.HashSet;
|
| | | import java.util.Set;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Component;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.project.system.service.ISysMenuService;
|
| | | import com.ruoyi.project.system.service.ISysRoleService;
|
| | | import com.ruoyi.common.core.domain.entity.SysUser;
|
| | | import com.ruoyi.system.service.ISysMenuService;
|
| | | import com.ruoyi.system.service.ISysRoleService;
|
| | |
|
| | | /**
|
| | | * ç¨æ·æéå¤ç
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/security/service/TokenService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.security.service;
|
| | | package com.ruoyi.framework.web.service;
|
| | |
|
| | | import java.util.HashMap;
|
| | | import java.util.Map;
|
| | |
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.stereotype.Component;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.utils.IdUtils;
|
| | | import com.ruoyi.common.core.domain.model.LoginUser;
|
| | | import com.ruoyi.common.core.redis.RedisCache;
|
| | | import com.ruoyi.common.utils.ServletUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.ip.AddressUtils;
|
| | | import com.ruoyi.common.utils.ip.IpUtils;
|
| | | import com.ruoyi.framework.redis.RedisCache;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | | import com.ruoyi.common.utils.uuid.IdUtils;
|
| | | import eu.bitwalker.useragentutils.UserAgent;
|
| | | import io.jsonwebtoken.Claims;
|
| | | import io.jsonwebtoken.Jwts;
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/security/service/UserDetailsServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.security.service;
|
| | | package com.ruoyi.framework.web.service;
|
| | |
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | |
| | | import org.springframework.security.core.userdetails.UserDetailsService;
|
| | | import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.common.core.domain.entity.SysUser;
|
| | | import com.ruoyi.common.core.domain.model.LoginUser;
|
| | | import com.ruoyi.common.enums.UserStatus;
|
| | | import com.ruoyi.common.exception.BaseException;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.project.system.service.ISysUserService;
|
| | | import com.ruoyi.system.service.ISysUserService;
|
| | |
|
| | | /**
|
| | | * ç¨æ·éªè¯å¤ç
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?>
|
| | | <project xmlns="http://maven.apache.org/POM/4.0.0"
|
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
| | | <parent>
|
| | | <artifactId>ruoyi</artifactId>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <version>3.0.0</version>
|
| | | </parent>
|
| | | <modelVersion>4.0.0</modelVersion>
|
| | |
|
| | | <artifactId>ruoyi-generator</artifactId>
|
| | |
|
| | | <description>
|
| | | generator代ç çæ
|
| | | </description>
|
| | |
|
| | | <dependencies>
|
| | |
|
| | | <!--velocity代ç çæä½¿ç¨æ¨¡æ¿ -->
|
| | | <dependency>
|
| | | <groupId>org.apache.velocity</groupId>
|
| | | <artifactId>velocity</artifactId>
|
| | | </dependency>
|
| | |
|
| | | <!-- éç¨å·¥å
·-->
|
| | | <dependency>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi-common</artifactId>
|
| | | </dependency>
|
| | |
|
| | | </dependencies>
|
| | |
|
| | | </project> |
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/config/GenConfig.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.config;
|
| | | package com.ruoyi.generator.config;
|
| | |
|
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.boot.context.properties.ConfigurationProperties;
|
| | | import org.springframework.context.annotation.PropertySource;
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | @Component
|
| | | @ConfigurationProperties(prefix = "gen")
|
| | | @PropertySource(value = { "classpath:generator.yml" })
|
| | | public class GenConfig
|
| | | {
|
| | | /** ä½è
*/
|
| | |
| | | /** çæå
è·¯å¾ */
|
| | | public static String packageName;
|
| | |
|
| | | /** èªå¨å»é¤è¡¨åç¼ï¼é»è®¤æ¯true */
|
| | | /** èªå¨å»é¤è¡¨åç¼ï¼é»è®¤æ¯false */
|
| | | public static boolean autoRemovePre;
|
| | |
|
| | | /** 表åç¼(ç±»åä¸ä¼å
å«è¡¨åç¼) */
|
| | |
| | | return author;
|
| | | }
|
| | |
|
| | | @Value("${author}")
|
| | | public void setAuthor(String author)
|
| | | {
|
| | | GenConfig.author = author;
|
| | |
| | | return packageName;
|
| | | }
|
| | |
|
| | | @Value("${packageName}")
|
| | | public void setPackageName(String packageName)
|
| | | {
|
| | | GenConfig.packageName = packageName;
|
| | |
| | | return autoRemovePre;
|
| | | }
|
| | |
|
| | | @Value("${autoRemovePre}")
|
| | | public void setAutoRemovePre(boolean autoRemovePre)
|
| | | {
|
| | | GenConfig.autoRemovePre = autoRemovePre;
|
| | |
| | | return tablePrefix;
|
| | | }
|
| | |
|
| | | @Value("${tablePrefix}")
|
| | | public void setTablePrefix(String tablePrefix)
|
| | | {
|
| | | GenConfig.tablePrefix = tablePrefix;
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.tool.gen.controller;
|
| | | package com.ruoyi.generator.controller;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.util.HashMap;
|
| | |
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.page.TableDataInfo;
|
| | | import com.ruoyi.common.core.text.Convert;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | import com.ruoyi.project.tool.gen.domain.GenTable;
|
| | | import com.ruoyi.project.tool.gen.domain.GenTableColumn;
|
| | | import com.ruoyi.project.tool.gen.service.IGenTableColumnService;
|
| | | import com.ruoyi.project.tool.gen.service.IGenTableService;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.generator.domain.GenTable;
|
| | | import com.ruoyi.generator.domain.GenTableColumn;
|
| | | import com.ruoyi.generator.service.IGenTableColumnService;
|
| | | import com.ruoyi.generator.service.IGenTableService;
|
| | |
|
| | | /**
|
| | | * 代ç çæ æä½å¤ç
|
| | |
| | | response.setContentType("application/octet-stream; charset=UTF-8");
|
| | | IOUtils.write(data, response.getOutputStream());
|
| | | }
|
| | | } |
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTable.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.tool.gen.domain;
|
| | | package com.ruoyi.generator.domain;
|
| | |
|
| | | import java.util.List;
|
| | | import javax.validation.Valid;
|
| | | import javax.validation.constraints.NotBlank;
|
| | | import org.apache.commons.lang3.ArrayUtils;
|
| | | import com.ruoyi.common.constant.GenConstants;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | |
|
| | | /**
|
| | | * ä¸å¡è¡¨ gen_table
|
| | |
| | | }
|
| | | return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY);
|
| | | }
|
| | | } |
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTableColumn.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.tool.gen.domain;
|
| | | package com.ruoyi.generator.domain;
|
| | |
|
| | | import javax.validation.constraints.NotBlank;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | |
|
| | | /**
|
| | | * 代ç çæä¸å¡å段表 gen_table_column
|
| | |
| | | return this.columnComment;
|
| | | }
|
| | | }
|
| | | } |
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableColumnMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.tool.gen.mapper;
|
| | | package com.ruoyi.generator.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.tool.gen.domain.GenTableColumn;
|
| | | import com.ruoyi.generator.domain.GenTableColumn;
|
| | |
|
| | | /**
|
| | | * ä¸å¡å段 æ°æ®å±
|
| | |
| | | * @return ç»æ
|
| | | */
|
| | | public int deleteGenTableColumnByIds(Long[] ids);
|
| | | } |
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.tool.gen.mapper;
|
| | | package com.ruoyi.generator.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.tool.gen.domain.GenTable;
|
| | | import com.ruoyi.generator.domain.GenTable;
|
| | |
|
| | | /**
|
| | | * ä¸å¡ æ°æ®å±
|
| | |
| | | * @return ç»æ
|
| | | */
|
| | | public int deleteGenTableByIds(Long[] ids);
|
| | | } |
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableColumnServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.tool.gen.service;
|
| | | package com.ruoyi.generator.service;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.common.core.text.Convert;
|
| | | import com.ruoyi.project.tool.gen.domain.GenTableColumn;
|
| | | import com.ruoyi.project.tool.gen.mapper.GenTableColumnMapper;
|
| | | import com.ruoyi.generator.domain.GenTableColumn;
|
| | | import com.ruoyi.generator.mapper.GenTableColumnMapper;
|
| | |
|
| | | /**
|
| | | * ä¸å¡å段 æå¡å±å®ç°
|
| | |
| | | {
|
| | | return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
|
| | | }
|
| | | } |
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.tool.gen.service;
|
| | | package com.ruoyi.generator.service;
|
| | |
|
| | | import java.io.ByteArrayOutputStream;
|
| | | import java.io.IOException;
|
| | |
| | | import com.ruoyi.common.exception.CustomException;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.project.tool.gen.domain.GenTable;
|
| | | import com.ruoyi.project.tool.gen.domain.GenTableColumn;
|
| | | import com.ruoyi.project.tool.gen.mapper.GenTableColumnMapper;
|
| | | import com.ruoyi.project.tool.gen.mapper.GenTableMapper;
|
| | | import com.ruoyi.project.tool.gen.util.GenUtils;
|
| | | import com.ruoyi.project.tool.gen.util.VelocityInitializer;
|
| | | import com.ruoyi.project.tool.gen.util.VelocityUtils;
|
| | | import com.ruoyi.generator.domain.GenTable;
|
| | | import com.ruoyi.generator.domain.GenTableColumn;
|
| | | import com.ruoyi.generator.mapper.GenTableColumnMapper;
|
| | | import com.ruoyi.generator.mapper.GenTableMapper;
|
| | | import com.ruoyi.generator.util.GenUtils;
|
| | | import com.ruoyi.generator.util.VelocityInitializer;
|
| | | import com.ruoyi.generator.util.VelocityUtils;
|
| | |
|
| | | /**
|
| | | * ä¸å¡ æå¡å±å®ç°
|
| | |
| | | genTable.setTreeName(treeName);
|
| | | }
|
| | | }
|
| | | } |
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableColumnService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.tool.gen.service;
|
| | | package com.ruoyi.generator.service;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.tool.gen.domain.GenTableColumn;
|
| | | import com.ruoyi.generator.domain.GenTableColumn;
|
| | |
|
| | | /**
|
| | | * ä¸å¡å段 æå¡å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.tool.gen.service;
|
| | | package com.ruoyi.generator.service;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import com.ruoyi.project.tool.gen.domain.GenTable;
|
| | | import com.ruoyi.generator.domain.GenTable;
|
| | |
|
| | | /**
|
| | | * ä¸å¡ æå¡å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.tool.gen.util;
|
| | | package com.ruoyi.generator.util;
|
| | |
|
| | | import java.util.Arrays;
|
| | | import org.apache.commons.lang3.RegExUtils;
|
| | | import com.ruoyi.common.constant.GenConstants;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.config.GenConfig;
|
| | | import com.ruoyi.project.tool.gen.domain.GenTable;
|
| | | import com.ruoyi.project.tool.gen.domain.GenTableColumn;
|
| | | import com.ruoyi.generator.config.GenConfig;
|
| | | import com.ruoyi.generator.domain.GenTable;
|
| | | import com.ruoyi.generator.domain.GenTableColumn;
|
| | |
|
| | | /**
|
| | | * 代ç çæå¨ å·¥å
·ç±»
|
| | |
| | | return 0;
|
| | | }
|
| | | }
|
| | | } |
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityInitializer.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.tool.gen.util;
|
| | | package com.ruoyi.generator.util;
|
| | |
|
| | | import java.util.Properties;
|
| | | import org.apache.velocity.app.Velocity;
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.tool.gen.util;
|
| | | package com.ruoyi.generator.util;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.HashSet;
|
| | |
| | | import com.ruoyi.common.constant.GenConstants;
|
| | | import com.ruoyi.common.utils.DateUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.project.tool.gen.domain.GenTable;
|
| | | import com.ruoyi.project.tool.gen.domain.GenTableColumn;
|
| | | import com.ruoyi.generator.domain.GenTable;
|
| | | import com.ruoyi.generator.domain.GenTableColumn;
|
| | |
|
| | | /**
|
| | | * 代ç çææ¨¡æ¿å¤ç
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class VelocityUtils
|
| | | {
|
| | | /** 项ç®ç©ºé´è·¯å¾ */
|
| | | private static final String PROJECT_PATH = "main/java";
|
| | |
|
| | | /** mybatis空é´è·¯å¾ */
|
| | | private static final String MYBATIS_PATH = "main/resources/mybatis";
|
| | | private static final String MYBATIS_PATH = "main/resources/mapper";
|
| | |
|
| | | /**
|
| | | * 设置模æ¿åéä¿¡æ¯
|
| | |
| | | }
|
| | | return num;
|
| | | }
|
| | | } |
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | # 代ç çæ
|
| | | gen: |
| | | # ä½è
|
| | | author: ruoyi
|
| | | # é»è®¤çæå
è·¯å¾ system éæ¹æèªå·±ç模ååç§° å¦ system monitor tool
|
| | | packageName: com.ruoyi.system
|
| | | # èªå¨å»é¤è¡¨åç¼ï¼é»è®¤æ¯false
|
| | | autoRemovePre: false
|
| | | # 表åç¼ï¼çæç±»åä¸ä¼å
å«è¡¨åç¼ï¼å¤ä¸ªç¨éå·åéï¼
|
| | | tablePrefix: sys_ |
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/tool/GenTableColumnMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.tool.gen.mapper.GenTableColumnMapper">
|
| | | <mapper namespace="com.ruoyi.generator.mapper.GenTableColumnMapper">
|
| | |
|
| | | <resultMap type="GenTableColumn" id="GenTableColumnResult">
|
| | | <id property="columnId" column="column_id" />
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/tool/GenTableMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.tool.gen.mapper.GenTableMapper">
|
| | | <mapper namespace="com.ruoyi.generator.mapper.GenTableMapper">
|
| | |
|
| | | <resultMap type="GenTable" id="GenTableResult">
|
| | | <id property="tableId" column="table_id" />
|
ÎļþÃû´Ó ruoyi/src/main/resources/vm/java/controller.java.vm ÐÞ¸Ä |
| | |
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import ${packageName}.domain.${ClassName};
|
| | | import ${packageName}.service.I${ClassName}Service;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.common.utils.poi.ExcelUtil;
|
| | | #if($table.crud)
|
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.core.page.TableDataInfo;
|
| | | #elseif($table.tree)
|
| | | #end
|
| | |
|
ÎļþÃû´Ó ruoyi/src/main/resources/vm/java/domain.java.vm ÐÞ¸Ä |
| | |
| | | #end
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
| | | import com.ruoyi.common.annotation.Excel;
|
| | | #if($table.crud)
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | | #elseif($table.tree)
|
| | | import com.ruoyi.framework.web.domain.TreeEntity;
|
| | | import com.ruoyi.common.core.domain.TreeEntity;
|
| | | #end
|
| | |
|
| | | /**
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?>
|
| | | <project xmlns="http://maven.apache.org/POM/4.0.0"
|
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
| | | <parent>
|
| | | <artifactId>ruoyi</artifactId>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <version>3.0.0</version>
|
| | | </parent>
|
| | | <modelVersion>4.0.0</modelVersion>
|
| | |
|
| | | <artifactId>ruoyi-quartz</artifactId>
|
| | |
|
| | | <description>
|
| | | quartz宿¶ä»»å¡
|
| | | </description>
|
| | |
|
| | | <dependencies>
|
| | |
|
| | | <!-- 宿¶ä»»å¡ -->
|
| | | <dependency>
|
| | | <groupId>org.quartz-scheduler</groupId>
|
| | | <artifactId>quartz</artifactId>
|
| | | <exclusions>
|
| | | <exclusion>
|
| | | <groupId>com.mchange</groupId>
|
| | | <artifactId>c3p0</artifactId>
|
| | | </exclusion>
|
| | | </exclusions>
|
| | | </dependency>
|
| | |
|
| | | <!-- éç¨å·¥å
·-->
|
| | | <dependency>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi-common</artifactId>
|
| | | </dependency>
|
| | |
|
| | | </dependencies>
|
| | |
|
| | | </project> |
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/config/ScheduleConfig.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.scheduling.quartz.SchedulerFactoryBean; |
| | | import javax.sql.DataSource; |
| | | import java.util.Properties; |
| | | |
| | | /** |
| | | * 宿¶ä»»å¡é
ç½® |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Configuration |
| | | public class ScheduleConfig |
| | | { |
| | | @Bean |
| | | public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) |
| | | { |
| | | SchedulerFactoryBean factory = new SchedulerFactoryBean(); |
| | | factory.setDataSource(dataSource); |
| | | |
| | | // quartzåæ° |
| | | Properties prop = new Properties(); |
| | | prop.put("org.quartz.scheduler.instanceName", "RuoyiScheduler"); |
| | | prop.put("org.quartz.scheduler.instanceId", "AUTO"); |
| | | // çº¿ç¨æ± é
ç½® |
| | | prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool"); |
| | | prop.put("org.quartz.threadPool.threadCount", "20"); |
| | | prop.put("org.quartz.threadPool.threadPriority", "5"); |
| | | // JobStoreé
ç½® |
| | | prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX"); |
| | | // é群é
ç½® |
| | | prop.put("org.quartz.jobStore.isClustered", "true"); |
| | | prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000"); |
| | | prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1"); |
| | | prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true"); |
| | | |
| | | // sqlserver å¯ç¨ |
| | | // prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?"); |
| | | prop.put("org.quartz.jobStore.misfireThreshold", "12000"); |
| | | prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); |
| | | factory.setQuartzProperties(prop); |
| | | |
| | | factory.setSchedulerName("RuoyiScheduler"); |
| | | // å»¶æ¶å¯å¨ |
| | | factory.setStartupDelay(1); |
| | | factory.setApplicationContextSchedulerContextKey("applicationContextKey"); |
| | | // å¯éï¼QuartzScheduler |
| | | // å¯å¨æ¶æ´æ°å·±åå¨çJobï¼è¿æ ·å°±ä¸ç¨æ¯æ¬¡ä¿®æ¹targetObjectåå é¤qrtz_job_details表对åºè®°å½äº |
| | | factory.setOverwriteExistingJobs(true); |
| | | // 设置èªå¨å¯å¨ï¼é»è®¤ä¸ºtrue |
| | | factory.setAutoStartup(true); |
| | | |
| | | return factory; |
| | | } |
| | | } |
| | | package com.ruoyi.quartz.config;
|
| | |
|
| | | import org.springframework.context.annotation.Bean;
|
| | | import org.springframework.context.annotation.Configuration;
|
| | | import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
| | | import javax.sql.DataSource;
|
| | | import java.util.Properties;
|
| | |
|
| | | /**
|
| | | * 宿¶ä»»å¡é
ç½®
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @Configuration
|
| | | public class ScheduleConfig
|
| | | {
|
| | | @Bean
|
| | | public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource)
|
| | | {
|
| | | SchedulerFactoryBean factory = new SchedulerFactoryBean();
|
| | | factory.setDataSource(dataSource);
|
| | |
|
| | | // quartzåæ°
|
| | | Properties prop = new Properties();
|
| | | prop.put("org.quartz.scheduler.instanceName", "RuoyiScheduler");
|
| | | prop.put("org.quartz.scheduler.instanceId", "AUTO");
|
| | | // çº¿ç¨æ± é
ç½®
|
| | | prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
|
| | | prop.put("org.quartz.threadPool.threadCount", "20");
|
| | | prop.put("org.quartz.threadPool.threadPriority", "5");
|
| | | // JobStoreé
ç½®
|
| | | prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
|
| | | // é群é
ç½®
|
| | | prop.put("org.quartz.jobStore.isClustered", "true");
|
| | | prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
|
| | | prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
|
| | | prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true");
|
| | |
|
| | | // sqlserver å¯ç¨
|
| | | // prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
|
| | | prop.put("org.quartz.jobStore.misfireThreshold", "12000");
|
| | | prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
|
| | | factory.setQuartzProperties(prop);
|
| | |
|
| | | factory.setSchedulerName("RuoyiScheduler");
|
| | | // å»¶æ¶å¯å¨
|
| | | factory.setStartupDelay(1);
|
| | | factory.setApplicationContextSchedulerContextKey("applicationContextKey");
|
| | | // å¯éï¼QuartzScheduler
|
| | | // å¯å¨æ¶æ´æ°å·±åå¨çJobï¼è¿æ ·å°±ä¸ç¨æ¯æ¬¡ä¿®æ¹targetObjectåå é¤qrtz_job_details表对åºè®°å½äº
|
| | | factory.setOverwriteExistingJobs(true);
|
| | | // 设置èªå¨å¯å¨ï¼é»è®¤ä¸ºtrue
|
| | | factory.setAutoStartup(true);
|
| | |
|
| | | return factory;
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysJobController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.controller; |
| | | |
| | | import java.util.List; |
| | | import org.quartz.SchedulerException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.exception.job.TaskException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.job.CronUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.page.TableDataInfo; |
| | | import com.ruoyi.project.monitor.domain.SysJob; |
| | | import com.ruoyi.project.monitor.service.ISysJobService; |
| | | |
| | | /** |
| | | * è°åº¦ä»»å¡ä¿¡æ¯æä½å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/monitor/job") |
| | | public class SysJobController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysJobService jobService; |
| | | |
| | | /** |
| | | * æ¥è¯¢å®æ¶ä»»å¡å表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysJob sysJob) |
| | | { |
| | | startPage(); |
| | | List<SysJob> list = jobService.selectJobList(sysJob); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 导åºå®æ¶ä»»å¡å表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:export')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.EXPORT) |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysJob sysJob) |
| | | { |
| | | List<SysJob> list = jobService.selectJobList(sysJob); |
| | | ExcelUtil<SysJob> util = new ExcelUtil<SysJob>(SysJob.class); |
| | | return util.exportExcel(list, "宿¶ä»»å¡"); |
| | | } |
| | | |
| | | /** |
| | | * è·å宿¶ä»»å¡è¯¦ç»ä¿¡æ¯ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:query')") |
| | | @GetMapping(value = "/{jobId}") |
| | | public AjaxResult getInfo(@PathVariable("jobId") Long jobId) |
| | | { |
| | | return AjaxResult.success(jobService.selectJobById(jobId)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢å®æ¶ä»»å¡ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:add')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException |
| | | { |
| | | if (!CronUtils.isValid(sysJob.getCronExpression())) |
| | | { |
| | | return AjaxResult.error("cron表达å¼ä¸æ£ç¡®"); |
| | | } |
| | | sysJob.setCreateBy(SecurityUtils.getUsername()); |
| | | return toAjax(jobService.insertJob(sysJob)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹å®æ¶ä»»å¡ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:edit')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException |
| | | { |
| | | if (!CronUtils.isValid(sysJob.getCronExpression())) |
| | | { |
| | | return AjaxResult.error("cron表达å¼ä¸æ£ç¡®"); |
| | | } |
| | | sysJob.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(jobService.updateJob(sysJob)); |
| | | } |
| | | |
| | | /** |
| | | * 宿¶ä»»å¡ç¶æä¿®æ¹ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException |
| | | { |
| | | SysJob newJob = jobService.selectJobById(job.getJobId()); |
| | | newJob.setStatus(job.getStatus()); |
| | | return toAjax(jobService.changeStatus(newJob)); |
| | | } |
| | | |
| | | /** |
| | | * 宿¶ä»»å¡ç«å³æ§è¡ä¸æ¬¡ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/run") |
| | | public AjaxResult run(@RequestBody SysJob job) throws SchedulerException |
| | | { |
| | | jobService.run(job); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * å é¤å®æ¶ä»»å¡ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:remove')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{jobIds}") |
| | | public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException |
| | | { |
| | | jobService.deleteJobByIds(jobIds); |
| | | return AjaxResult.success(); |
| | | } |
| | | } |
| | | package com.ruoyi.quartz.controller;
|
| | |
|
| | | import java.util.List;
|
| | | import org.quartz.SchedulerException;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | | import org.springframework.web.bind.annotation.PostMapping;
|
| | | import org.springframework.web.bind.annotation.PutMapping;
|
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.page.TableDataInfo;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.exception.job.TaskException;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.common.utils.poi.ExcelUtil;
|
| | | import com.ruoyi.quartz.domain.SysJob;
|
| | | import com.ruoyi.quartz.service.ISysJobService;
|
| | | import com.ruoyi.quartz.util.CronUtils;
|
| | |
|
| | | /**
|
| | | * è°åº¦ä»»å¡ä¿¡æ¯æä½å¤ç
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @RestController
|
| | | @RequestMapping("/monitor/job")
|
| | | public class SysJobController extends BaseController
|
| | | {
|
| | | @Autowired
|
| | | private ISysJobService jobService;
|
| | |
|
| | | /**
|
| | | * æ¥è¯¢å®æ¶ä»»å¡å表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:list')")
|
| | | @GetMapping("/list")
|
| | | public TableDataInfo list(SysJob sysJob)
|
| | | {
|
| | | startPage();
|
| | | List<SysJob> list = jobService.selectJobList(sysJob);
|
| | | return getDataTable(list);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 导åºå®æ¶ä»»å¡å表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:export')")
|
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.EXPORT)
|
| | | @GetMapping("/export")
|
| | | public AjaxResult export(SysJob sysJob)
|
| | | {
|
| | | List<SysJob> list = jobService.selectJobList(sysJob);
|
| | | ExcelUtil<SysJob> util = new ExcelUtil<SysJob>(SysJob.class);
|
| | | return util.exportExcel(list, "宿¶ä»»å¡");
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·å宿¶ä»»å¡è¯¦ç»ä¿¡æ¯
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:query')")
|
| | | @GetMapping(value = "/{jobId}")
|
| | | public AjaxResult getInfo(@PathVariable("jobId") Long jobId)
|
| | | {
|
| | | return AjaxResult.success(jobService.selectJobById(jobId));
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ°å¢å®æ¶ä»»å¡
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:add')")
|
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.INSERT)
|
| | | @PostMapping
|
| | | public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException
|
| | | {
|
| | | if (!CronUtils.isValid(sysJob.getCronExpression()))
|
| | | {
|
| | | return AjaxResult.error("cron表达å¼ä¸æ£ç¡®");
|
| | | }
|
| | | sysJob.setCreateBy(SecurityUtils.getUsername());
|
| | | return toAjax(jobService.insertJob(sysJob));
|
| | | }
|
| | |
|
| | | /**
|
| | | * ä¿®æ¹å®æ¶ä»»å¡
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:edit')")
|
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException
|
| | | {
|
| | | if (!CronUtils.isValid(sysJob.getCronExpression()))
|
| | | {
|
| | | return AjaxResult.error("cron表达å¼ä¸æ£ç¡®");
|
| | | }
|
| | | sysJob.setUpdateBy(SecurityUtils.getUsername());
|
| | | return toAjax(jobService.updateJob(sysJob));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 宿¶ä»»å¡ç¶æä¿®æ¹
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
|
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.UPDATE)
|
| | | @PutMapping("/changeStatus")
|
| | | public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException
|
| | | {
|
| | | SysJob newJob = jobService.selectJobById(job.getJobId());
|
| | | newJob.setStatus(job.getStatus());
|
| | | return toAjax(jobService.changeStatus(newJob));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 宿¶ä»»å¡ç«å³æ§è¡ä¸æ¬¡
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
|
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.UPDATE)
|
| | | @PutMapping("/run")
|
| | | public AjaxResult run(@RequestBody SysJob job) throws SchedulerException
|
| | | {
|
| | | jobService.run(job);
|
| | | return AjaxResult.success();
|
| | | }
|
| | |
|
| | | /**
|
| | | * å é¤å®æ¶ä»»å¡
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:remove')")
|
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{jobIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException
|
| | | {
|
| | | jobService.deleteJobByIds(jobIds);
|
| | | return AjaxResult.success();
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysJobLogController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.controller; |
| | | |
| | | import java.util.List; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.project.monitor.domain.SysJobLog; |
| | | import com.ruoyi.project.monitor.service.ISysJobLogService; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.page.TableDataInfo; |
| | | |
| | | /** |
| | | * è°åº¦æ¥å¿æä½å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/monitor/jobLog") |
| | | public class SysJobLogController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysJobLogService jobLogService; |
| | | |
| | | /** |
| | | * æ¥è¯¢å®æ¶ä»»å¡è°åº¦æ¥å¿å表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysJobLog sysJobLog) |
| | | { |
| | | startPage(); |
| | | List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 导åºå®æ¶ä»»å¡è°åº¦æ¥å¿å表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:export')") |
| | | @Log(title = "ä»»å¡è°åº¦æ¥å¿", businessType = BusinessType.EXPORT) |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysJobLog sysJobLog) |
| | | { |
| | | List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog); |
| | | ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class); |
| | | return util.exportExcel(list, "è°åº¦æ¥å¿"); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®è°åº¦ç¼å·è·å详ç»ä¿¡æ¯ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:query')") |
| | | @GetMapping(value = "/{configId}") |
| | | public AjaxResult getInfo(@PathVariable Long jobLogId) |
| | | { |
| | | return AjaxResult.success(jobLogService.selectJobLogById(jobLogId)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * å é¤å®æ¶ä»»å¡è°åº¦æ¥å¿ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:remove')") |
| | | @Log(title = "宿¶ä»»å¡è°åº¦æ¥å¿", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{jobLogIds}") |
| | | public AjaxResult remove(@PathVariable Long[] jobLogIds) |
| | | { |
| | | return toAjax(jobLogService.deleteJobLogByIds(jobLogIds)); |
| | | } |
| | | |
| | | /** |
| | | * æ¸
ç©ºå®æ¶ä»»å¡è°åº¦æ¥å¿ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:remove')") |
| | | @Log(title = "è°åº¦æ¥å¿", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/clean") |
| | | public AjaxResult clean() |
| | | { |
| | | jobLogService.cleanJobLog(); |
| | | return AjaxResult.success(); |
| | | } |
| | | } |
| | | package com.ruoyi.quartz.controller;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.page.TableDataInfo;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.utils.poi.ExcelUtil;
|
| | | import com.ruoyi.quartz.domain.SysJobLog;
|
| | | import com.ruoyi.quartz.service.ISysJobLogService;
|
| | |
|
| | | /**
|
| | | * è°åº¦æ¥å¿æä½å¤ç
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @RestController
|
| | | @RequestMapping("/monitor/jobLog")
|
| | | public class SysJobLogController extends BaseController
|
| | | {
|
| | | @Autowired
|
| | | private ISysJobLogService jobLogService;
|
| | |
|
| | | /**
|
| | | * æ¥è¯¢å®æ¶ä»»å¡è°åº¦æ¥å¿å表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:list')")
|
| | | @GetMapping("/list")
|
| | | public TableDataInfo list(SysJobLog sysJobLog)
|
| | | {
|
| | | startPage();
|
| | | List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
|
| | | return getDataTable(list);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 导åºå®æ¶ä»»å¡è°åº¦æ¥å¿å表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:export')")
|
| | | @Log(title = "ä»»å¡è°åº¦æ¥å¿", businessType = BusinessType.EXPORT)
|
| | | @GetMapping("/export")
|
| | | public AjaxResult export(SysJobLog sysJobLog)
|
| | | {
|
| | | List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
|
| | | ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class);
|
| | | return util.exportExcel(list, "è°åº¦æ¥å¿");
|
| | | }
|
| | | |
| | | /**
|
| | | * æ ¹æ®è°åº¦ç¼å·è·å详ç»ä¿¡æ¯
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:query')")
|
| | | @GetMapping(value = "/{configId}")
|
| | | public AjaxResult getInfo(@PathVariable Long jobLogId)
|
| | | {
|
| | | return AjaxResult.success(jobLogService.selectJobLogById(jobLogId));
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * å é¤å®æ¶ä»»å¡è°åº¦æ¥å¿
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:remove')")
|
| | | @Log(title = "宿¶ä»»å¡è°åº¦æ¥å¿", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{jobLogIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] jobLogIds)
|
| | | {
|
| | | return toAjax(jobLogService.deleteJobLogByIds(jobLogIds));
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ¸
ç©ºå®æ¶ä»»å¡è°åº¦æ¥å¿
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:remove')")
|
| | | @Log(title = "è°åº¦æ¥å¿", businessType = BusinessType.CLEAN)
|
| | | @DeleteMapping("/clean")
|
| | | public AjaxResult clean()
|
| | | {
|
| | | jobLogService.cleanJobLog();
|
| | | return AjaxResult.success();
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysJob.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.domain; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.Size; |
| | | import org.apache.commons.lang3.builder.ToStringBuilder; |
| | | import org.apache.commons.lang3.builder.ToStringStyle; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.constant.ScheduleConstants; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.job.CronUtils; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType; |
| | | import com.ruoyi.framework.web.domain.BaseEntity; |
| | | |
| | | /** |
| | | * 宿¶ä»»å¡è°åº¦è¡¨ sys_job |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysJob extends BaseEntity implements Serializable |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** ä»»å¡ID */ |
| | | @Excel(name = "ä»»å¡åºå·", cellType = ColumnType.NUMERIC) |
| | | private Long jobId; |
| | | |
| | | /** ä»»å¡åç§° */ |
| | | @Excel(name = "ä»»å¡åç§°") |
| | | private String jobName; |
| | | |
| | | /** ä»»å¡ç»å */ |
| | | @Excel(name = "ä»»å¡ç»å") |
| | | private String jobGroup; |
| | | |
| | | /** è°ç¨ç®æ å符串 */ |
| | | @Excel(name = "è°ç¨ç®æ å符串") |
| | | private String invokeTarget; |
| | | |
| | | /** cronæ§è¡è¡¨è¾¾å¼ */ |
| | | @Excel(name = "æ§è¡è¡¨è¾¾å¼ ") |
| | | private String cronExpression; |
| | | |
| | | /** cron计åçç¥ */ |
| | | @Excel(name = "计åçç¥ ", readConverterExp = "0=é»è®¤,1=ç«å³è§¦åæ§è¡,2=触å䏿¬¡æ§è¡,3=ä¸è§¦åç«å³æ§è¡") |
| | | private String misfirePolicy = ScheduleConstants.MISFIRE_DEFAULT; |
| | | |
| | | /** æ¯å¦å¹¶åæ§è¡ï¼0å
许 1ç¦æ¢ï¼ */ |
| | | @Excel(name = "å¹¶åæ§è¡", readConverterExp = "0=å
许,1=ç¦æ¢") |
| | | private String concurrent; |
| | | |
| | | /** ä»»å¡ç¶æï¼0æ£å¸¸ 1æåï¼ */ |
| | | @Excel(name = "ä»»å¡ç¶æ", readConverterExp = "0=æ£å¸¸,1=æå") |
| | | private String status; |
| | | |
| | | public Long getJobId() |
| | | { |
| | | return jobId; |
| | | } |
| | | |
| | | public void setJobId(Long jobId) |
| | | { |
| | | this.jobId = jobId; |
| | | } |
| | | |
| | | @NotBlank(message = "ä»»å¡åç§°ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 64, message = "ä»»å¡åç§°ä¸è½è¶
è¿64个å符") |
| | | public String getJobName() |
| | | { |
| | | return jobName; |
| | | } |
| | | |
| | | public void setJobName(String jobName) |
| | | { |
| | | this.jobName = jobName; |
| | | } |
| | | |
| | | public String getJobGroup() |
| | | { |
| | | return jobGroup; |
| | | } |
| | | |
| | | public void setJobGroup(String jobGroup) |
| | | { |
| | | this.jobGroup = jobGroup; |
| | | } |
| | | |
| | | @NotBlank(message = "è°ç¨ç®æ å符串ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 1000, message = "è°ç¨ç®æ å符串é¿åº¦ä¸è½è¶
è¿500个å符") |
| | | public String getInvokeTarget() |
| | | { |
| | | return invokeTarget; |
| | | } |
| | | |
| | | public void setInvokeTarget(String invokeTarget) |
| | | { |
| | | this.invokeTarget = invokeTarget; |
| | | } |
| | | |
| | | @NotBlank(message = "Cronæ§è¡è¡¨è¾¾å¼ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 255, message = "Cronæ§è¡è¡¨è¾¾å¼ä¸è½è¶
è¿255个å符") |
| | | public String getCronExpression() |
| | | { |
| | | return cronExpression; |
| | | } |
| | | |
| | | public void setCronExpression(String cronExpression) |
| | | { |
| | | this.cronExpression = cronExpression; |
| | | } |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | public Date getNextValidTime() |
| | | { |
| | | if (StringUtils.isNotEmpty(cronExpression)) |
| | | { |
| | | return CronUtils.getNextExecution(cronExpression); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getMisfirePolicy() |
| | | { |
| | | return misfirePolicy; |
| | | } |
| | | |
| | | public void setMisfirePolicy(String misfirePolicy) |
| | | { |
| | | this.misfirePolicy = misfirePolicy; |
| | | } |
| | | |
| | | public String getConcurrent() |
| | | { |
| | | return concurrent; |
| | | } |
| | | |
| | | public void setConcurrent(String concurrent) |
| | | { |
| | | this.concurrent = concurrent; |
| | | } |
| | | |
| | | public String getStatus() |
| | | { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(String status) |
| | | { |
| | | this.status = status; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | | .append("jobId", getJobId()) |
| | | .append("jobName", getJobName()) |
| | | .append("jobGroup", getJobGroup()) |
| | | .append("cronExpression", getCronExpression()) |
| | | .append("nextValidTime", getNextValidTime()) |
| | | .append("misfirePolicy", getMisfirePolicy()) |
| | | .append("concurrent", getConcurrent()) |
| | | .append("status", getStatus()) |
| | | .append("createBy", getCreateBy()) |
| | | .append("createTime", getCreateTime()) |
| | | .append("updateBy", getUpdateBy()) |
| | | .append("updateTime", getUpdateTime()) |
| | | .append("remark", getRemark()) |
| | | .toString(); |
| | | } |
| | | } |
| | | package com.ruoyi.quartz.domain;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.util.Date;
|
| | | import javax.validation.constraints.NotBlank;
|
| | | import javax.validation.constraints.Size;
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
| | | import com.fasterxml.jackson.annotation.JsonFormat;
|
| | | import com.ruoyi.common.annotation.Excel;
|
| | | import com.ruoyi.common.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.common.constant.ScheduleConstants;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.quartz.util.CronUtils;
|
| | |
|
| | | /**
|
| | | * 宿¶ä»»å¡è°åº¦è¡¨ sys_job
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class SysJob extends BaseEntity implements Serializable
|
| | | {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | /** ä»»å¡ID */
|
| | | @Excel(name = "ä»»å¡åºå·", cellType = ColumnType.NUMERIC)
|
| | | private Long jobId;
|
| | |
|
| | | /** ä»»å¡åç§° */
|
| | | @Excel(name = "ä»»å¡åç§°")
|
| | | private String jobName;
|
| | |
|
| | | /** ä»»å¡ç»å */
|
| | | @Excel(name = "ä»»å¡ç»å")
|
| | | private String jobGroup;
|
| | |
|
| | | /** è°ç¨ç®æ å符串 */
|
| | | @Excel(name = "è°ç¨ç®æ å符串")
|
| | | private String invokeTarget;
|
| | |
|
| | | /** cronæ§è¡è¡¨è¾¾å¼ */
|
| | | @Excel(name = "æ§è¡è¡¨è¾¾å¼ ")
|
| | | private String cronExpression;
|
| | |
|
| | | /** cron计åçç¥ */
|
| | | @Excel(name = "计åçç¥ ", readConverterExp = "0=é»è®¤,1=ç«å³è§¦åæ§è¡,2=触å䏿¬¡æ§è¡,3=ä¸è§¦åç«å³æ§è¡")
|
| | | private String misfirePolicy = ScheduleConstants.MISFIRE_DEFAULT;
|
| | |
|
| | | /** æ¯å¦å¹¶åæ§è¡ï¼0å
许 1ç¦æ¢ï¼ */
|
| | | @Excel(name = "å¹¶åæ§è¡", readConverterExp = "0=å
许,1=ç¦æ¢")
|
| | | private String concurrent;
|
| | |
|
| | | /** ä»»å¡ç¶æï¼0æ£å¸¸ 1æåï¼ */
|
| | | @Excel(name = "ä»»å¡ç¶æ", readConverterExp = "0=æ£å¸¸,1=æå")
|
| | | private String status;
|
| | |
|
| | | public Long getJobId()
|
| | | {
|
| | | return jobId;
|
| | | }
|
| | |
|
| | | public void setJobId(Long jobId)
|
| | | {
|
| | | this.jobId = jobId;
|
| | | }
|
| | |
|
| | | @NotBlank(message = "ä»»å¡åç§°ä¸è½ä¸ºç©º")
|
| | | @Size(min = 0, max = 64, message = "ä»»å¡åç§°ä¸è½è¶
è¿64个å符")
|
| | | public String getJobName()
|
| | | {
|
| | | return jobName;
|
| | | }
|
| | |
|
| | | public void setJobName(String jobName)
|
| | | {
|
| | | this.jobName = jobName;
|
| | | }
|
| | |
|
| | | public String getJobGroup()
|
| | | {
|
| | | return jobGroup;
|
| | | }
|
| | |
|
| | | public void setJobGroup(String jobGroup)
|
| | | {
|
| | | this.jobGroup = jobGroup;
|
| | | }
|
| | |
|
| | | @NotBlank(message = "è°ç¨ç®æ å符串ä¸è½ä¸ºç©º")
|
| | | @Size(min = 0, max = 1000, message = "è°ç¨ç®æ å符串é¿åº¦ä¸è½è¶
è¿500个å符")
|
| | | public String getInvokeTarget()
|
| | | {
|
| | | return invokeTarget;
|
| | | }
|
| | |
|
| | | public void setInvokeTarget(String invokeTarget)
|
| | | {
|
| | | this.invokeTarget = invokeTarget;
|
| | | }
|
| | |
|
| | | @NotBlank(message = "Cronæ§è¡è¡¨è¾¾å¼ä¸è½ä¸ºç©º")
|
| | | @Size(min = 0, max = 255, message = "Cronæ§è¡è¡¨è¾¾å¼ä¸è½è¶
è¿255个å符")
|
| | | public String getCronExpression()
|
| | | {
|
| | | return cronExpression;
|
| | | }
|
| | |
|
| | | public void setCronExpression(String cronExpression)
|
| | | {
|
| | | this.cronExpression = cronExpression;
|
| | | }
|
| | |
|
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
| | | public Date getNextValidTime()
|
| | | {
|
| | | if (StringUtils.isNotEmpty(cronExpression))
|
| | | {
|
| | | return CronUtils.getNextExecution(cronExpression);
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | public String getMisfirePolicy()
|
| | | {
|
| | | return misfirePolicy;
|
| | | }
|
| | |
|
| | | public void setMisfirePolicy(String misfirePolicy)
|
| | | {
|
| | | this.misfirePolicy = misfirePolicy;
|
| | | }
|
| | |
|
| | | public String getConcurrent()
|
| | | {
|
| | | return concurrent;
|
| | | }
|
| | |
|
| | | public void setConcurrent(String concurrent)
|
| | | {
|
| | | this.concurrent = concurrent;
|
| | | }
|
| | |
|
| | | public String getStatus()
|
| | | {
|
| | | return status;
|
| | | }
|
| | |
|
| | | public void setStatus(String status)
|
| | | {
|
| | | this.status = status;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
| | | .append("jobId", getJobId())
|
| | | .append("jobName", getJobName())
|
| | | .append("jobGroup", getJobGroup())
|
| | | .append("cronExpression", getCronExpression())
|
| | | .append("nextValidTime", getNextValidTime())
|
| | | .append("misfirePolicy", getMisfirePolicy())
|
| | | .append("concurrent", getConcurrent())
|
| | | .append("status", getStatus())
|
| | | .append("createBy", getCreateBy())
|
| | | .append("createTime", getCreateTime())
|
| | | .append("updateBy", getUpdateBy())
|
| | | .append("updateTime", getUpdateTime())
|
| | | .append("remark", getRemark())
|
| | | .toString();
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysJobLog.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.domain; |
| | | |
| | | import java.util.Date; |
| | | import org.apache.commons.lang3.builder.ToStringBuilder; |
| | | import org.apache.commons.lang3.builder.ToStringStyle; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import com.ruoyi.framework.web.domain.BaseEntity; |
| | | |
| | | /** |
| | | * 宿¶ä»»å¡è°åº¦æ¥å¿è¡¨ sys_job_log |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysJobLog extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** ID */ |
| | | @Excel(name = "æ¥å¿åºå·") |
| | | private Long jobLogId; |
| | | |
| | | /** ä»»å¡åç§° */ |
| | | @Excel(name = "ä»»å¡åç§°") |
| | | private String jobName; |
| | | |
| | | /** ä»»å¡ç»å */ |
| | | @Excel(name = "ä»»å¡ç»å") |
| | | private String jobGroup; |
| | | |
| | | /** è°ç¨ç®æ å符串 */ |
| | | @Excel(name = "è°ç¨ç®æ å符串") |
| | | private String invokeTarget; |
| | | |
| | | /** æ¥å¿ä¿¡æ¯ */ |
| | | @Excel(name = "æ¥å¿ä¿¡æ¯") |
| | | private String jobMessage; |
| | | |
| | | /** æ§è¡ç¶æï¼0æ£å¸¸ 1å¤±è´¥ï¼ */ |
| | | @Excel(name = "æ§è¡ç¶æ", readConverterExp = "0=æ£å¸¸,1=失败") |
| | | private String status; |
| | | |
| | | /** å¼å¸¸ä¿¡æ¯ */ |
| | | @Excel(name = "å¼å¸¸ä¿¡æ¯") |
| | | private String exceptionInfo; |
| | | |
| | | /** å¼å§æ¶é´ */ |
| | | private Date startTime; |
| | | |
| | | /** 忢æ¶é´ */ |
| | | private Date stopTime; |
| | | |
| | | public Long getJobLogId() |
| | | { |
| | | return jobLogId; |
| | | } |
| | | |
| | | public void setJobLogId(Long jobLogId) |
| | | { |
| | | this.jobLogId = jobLogId; |
| | | } |
| | | |
| | | public String getJobName() |
| | | { |
| | | return jobName; |
| | | } |
| | | |
| | | public void setJobName(String jobName) |
| | | { |
| | | this.jobName = jobName; |
| | | } |
| | | |
| | | public String getJobGroup() |
| | | { |
| | | return jobGroup; |
| | | } |
| | | |
| | | public void setJobGroup(String jobGroup) |
| | | { |
| | | this.jobGroup = jobGroup; |
| | | } |
| | | |
| | | public String getInvokeTarget() |
| | | { |
| | | return invokeTarget; |
| | | } |
| | | |
| | | public void setInvokeTarget(String invokeTarget) |
| | | { |
| | | this.invokeTarget = invokeTarget; |
| | | } |
| | | |
| | | public String getJobMessage() |
| | | { |
| | | return jobMessage; |
| | | } |
| | | |
| | | public void setJobMessage(String jobMessage) |
| | | { |
| | | this.jobMessage = jobMessage; |
| | | } |
| | | |
| | | public String getStatus() |
| | | { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(String status) |
| | | { |
| | | this.status = status; |
| | | } |
| | | |
| | | public String getExceptionInfo() |
| | | { |
| | | return exceptionInfo; |
| | | } |
| | | |
| | | public void setExceptionInfo(String exceptionInfo) |
| | | { |
| | | this.exceptionInfo = exceptionInfo; |
| | | } |
| | | |
| | | public Date getStartTime() |
| | | { |
| | | return startTime; |
| | | } |
| | | |
| | | public void setStartTime(Date startTime) |
| | | { |
| | | this.startTime = startTime; |
| | | } |
| | | |
| | | public Date getStopTime() |
| | | { |
| | | return stopTime; |
| | | } |
| | | |
| | | public void setStopTime(Date stopTime) |
| | | { |
| | | this.stopTime = stopTime; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | | .append("jobLogId", getJobLogId()) |
| | | .append("jobName", getJobName()) |
| | | .append("jobGroup", getJobGroup()) |
| | | .append("jobMessage", getJobMessage()) |
| | | .append("status", getStatus()) |
| | | .append("exceptionInfo", getExceptionInfo()) |
| | | .append("startTime", getStartTime()) |
| | | .append("stopTime", getStopTime()) |
| | | .toString(); |
| | | } |
| | | } |
| | | package com.ruoyi.quartz.domain;
|
| | |
|
| | | import java.util.Date;
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
| | | import com.ruoyi.common.annotation.Excel;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | |
|
| | | /**
|
| | | * 宿¶ä»»å¡è°åº¦æ¥å¿è¡¨ sys_job_log
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class SysJobLog extends BaseEntity
|
| | | {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | /** ID */
|
| | | @Excel(name = "æ¥å¿åºå·")
|
| | | private Long jobLogId;
|
| | |
|
| | | /** ä»»å¡åç§° */
|
| | | @Excel(name = "ä»»å¡åç§°")
|
| | | private String jobName;
|
| | |
|
| | | /** ä»»å¡ç»å */
|
| | | @Excel(name = "ä»»å¡ç»å")
|
| | | private String jobGroup;
|
| | |
|
| | | /** è°ç¨ç®æ å符串 */
|
| | | @Excel(name = "è°ç¨ç®æ å符串")
|
| | | private String invokeTarget;
|
| | |
|
| | | /** æ¥å¿ä¿¡æ¯ */
|
| | | @Excel(name = "æ¥å¿ä¿¡æ¯")
|
| | | private String jobMessage;
|
| | |
|
| | | /** æ§è¡ç¶æï¼0æ£å¸¸ 1å¤±è´¥ï¼ */
|
| | | @Excel(name = "æ§è¡ç¶æ", readConverterExp = "0=æ£å¸¸,1=失败")
|
| | | private String status;
|
| | |
|
| | | /** å¼å¸¸ä¿¡æ¯ */
|
| | | @Excel(name = "å¼å¸¸ä¿¡æ¯")
|
| | | private String exceptionInfo;
|
| | |
|
| | | /** å¼å§æ¶é´ */
|
| | | private Date startTime;
|
| | |
|
| | | /** 忢æ¶é´ */
|
| | | private Date stopTime;
|
| | |
|
| | | public Long getJobLogId()
|
| | | {
|
| | | return jobLogId;
|
| | | }
|
| | |
|
| | | public void setJobLogId(Long jobLogId)
|
| | | {
|
| | | this.jobLogId = jobLogId;
|
| | | }
|
| | |
|
| | | public String getJobName()
|
| | | {
|
| | | return jobName;
|
| | | }
|
| | |
|
| | | public void setJobName(String jobName)
|
| | | {
|
| | | this.jobName = jobName;
|
| | | }
|
| | |
|
| | | public String getJobGroup()
|
| | | {
|
| | | return jobGroup;
|
| | | }
|
| | |
|
| | | public void setJobGroup(String jobGroup)
|
| | | {
|
| | | this.jobGroup = jobGroup;
|
| | | }
|
| | |
|
| | | public String getInvokeTarget()
|
| | | {
|
| | | return invokeTarget;
|
| | | }
|
| | |
|
| | | public void setInvokeTarget(String invokeTarget)
|
| | | {
|
| | | this.invokeTarget = invokeTarget;
|
| | | }
|
| | |
|
| | | public String getJobMessage()
|
| | | {
|
| | | return jobMessage;
|
| | | }
|
| | |
|
| | | public void setJobMessage(String jobMessage)
|
| | | {
|
| | | this.jobMessage = jobMessage;
|
| | | }
|
| | |
|
| | | public String getStatus()
|
| | | {
|
| | | return status;
|
| | | }
|
| | |
|
| | | public void setStatus(String status)
|
| | | {
|
| | | this.status = status;
|
| | | }
|
| | |
|
| | | public String getExceptionInfo()
|
| | | {
|
| | | return exceptionInfo;
|
| | | }
|
| | |
|
| | | public void setExceptionInfo(String exceptionInfo)
|
| | | {
|
| | | this.exceptionInfo = exceptionInfo;
|
| | | }
|
| | |
|
| | | public Date getStartTime()
|
| | | {
|
| | | return startTime;
|
| | | }
|
| | |
|
| | | public void setStartTime(Date startTime)
|
| | | {
|
| | | this.startTime = startTime;
|
| | | }
|
| | | |
| | | public Date getStopTime()
|
| | | {
|
| | | return stopTime;
|
| | | }
|
| | |
|
| | | public void setStopTime(Date stopTime)
|
| | | {
|
| | | this.stopTime = stopTime;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
| | | .append("jobLogId", getJobLogId())
|
| | | .append("jobName", getJobName())
|
| | | .append("jobGroup", getJobGroup())
|
| | | .append("jobMessage", getJobMessage())
|
| | | .append("status", getStatus())
|
| | | .append("exceptionInfo", getExceptionInfo())
|
| | | .append("startTime", getStartTime())
|
| | | .append("stopTime", getStopTime())
|
| | | .toString();
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysJobLogMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.mapper; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.project.monitor.domain.SysJobLog; |
| | | |
| | | /** |
| | | * è°åº¦ä»»å¡æ¥å¿ä¿¡æ¯ æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysJobLogMapper |
| | | { |
| | | /** |
| | | * è·åquartzè°åº¦å¨æ¥å¿ç计åä»»å¡ |
| | | * |
| | | * @param jobLog è°åº¦æ¥å¿ä¿¡æ¯ |
| | | * @return è°åº¦ä»»å¡æ¥å¿éå |
| | | */ |
| | | public List<SysJobLog> selectJobLogList(SysJobLog jobLog); |
| | | |
| | | /** |
| | | * æ¥è¯¢ææè°åº¦ä»»å¡æ¥å¿ |
| | | * |
| | | * @return è°åº¦ä»»å¡æ¥å¿å表 |
| | | */ |
| | | public List<SysJobLog> selectJobLogAll(); |
| | | |
| | | /** |
| | | * éè¿è°åº¦ä»»å¡æ¥å¿IDæ¥è¯¢è°åº¦ä¿¡æ¯ |
| | | * |
| | | * @param jobLogId è°åº¦ä»»å¡æ¥å¿ID |
| | | * @return è°åº¦ä»»å¡æ¥å¿å¯¹è±¡ä¿¡æ¯ |
| | | */ |
| | | public SysJobLog selectJobLogById(Long jobLogId); |
| | | |
| | | /** |
| | | * æ°å¢ä»»å¡æ¥å¿ |
| | | * |
| | | * @param jobLog è°åº¦æ¥å¿ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertJobLog(SysJobLog jobLog); |
| | | |
| | | /** |
| | | * æ¹éå é¤è°åº¦æ¥å¿ä¿¡æ¯ |
| | | * |
| | | * @param logIds éè¦å é¤çæ°æ®ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteJobLogByIds(Long[] logIds); |
| | | |
| | | /** |
| | | * å é¤ä»»å¡æ¥å¿ |
| | | * |
| | | * @param jobId è°åº¦æ¥å¿ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteJobLogById(Long jobId); |
| | | |
| | | /** |
| | | * æ¸
ç©ºä»»å¡æ¥å¿ |
| | | */ |
| | | public void cleanJobLog(); |
| | | } |
| | | package com.ruoyi.quartz.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.quartz.domain.SysJobLog;
|
| | |
|
| | | /**
|
| | | * è°åº¦ä»»å¡æ¥å¿ä¿¡æ¯ æ°æ®å±
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public interface SysJobLogMapper
|
| | | {
|
| | | /**
|
| | | * è·åquartzè°åº¦å¨æ¥å¿ç计åä»»å¡
|
| | | * |
| | | * @param jobLog è°åº¦æ¥å¿ä¿¡æ¯
|
| | | * @return è°åº¦ä»»å¡æ¥å¿éå
|
| | | */
|
| | | public List<SysJobLog> selectJobLogList(SysJobLog jobLog);
|
| | |
|
| | | /**
|
| | | * æ¥è¯¢ææè°åº¦ä»»å¡æ¥å¿
|
| | | *
|
| | | * @return è°åº¦ä»»å¡æ¥å¿å表
|
| | | */
|
| | | public List<SysJobLog> selectJobLogAll();
|
| | |
|
| | | /**
|
| | | * éè¿è°åº¦ä»»å¡æ¥å¿IDæ¥è¯¢è°åº¦ä¿¡æ¯
|
| | | * |
| | | * @param jobLogId è°åº¦ä»»å¡æ¥å¿ID
|
| | | * @return è°åº¦ä»»å¡æ¥å¿å¯¹è±¡ä¿¡æ¯
|
| | | */
|
| | | public SysJobLog selectJobLogById(Long jobLogId);
|
| | |
|
| | | /**
|
| | | * æ°å¢ä»»å¡æ¥å¿
|
| | | * |
| | | * @param jobLog è°åº¦æ¥å¿ä¿¡æ¯
|
| | | * @return ç»æ
|
| | | */
|
| | | public int insertJobLog(SysJobLog jobLog);
|
| | |
|
| | | /**
|
| | | * æ¹éå é¤è°åº¦æ¥å¿ä¿¡æ¯
|
| | | * |
| | | * @param logIds éè¦å é¤çæ°æ®ID
|
| | | * @return ç»æ
|
| | | */
|
| | | public int deleteJobLogByIds(Long[] logIds);
|
| | |
|
| | | /**
|
| | | * å é¤ä»»å¡æ¥å¿
|
| | | * |
| | | * @param jobId è°åº¦æ¥å¿ID
|
| | | * @return ç»æ
|
| | | */
|
| | | public int deleteJobLogById(Long jobId);
|
| | |
|
| | | /**
|
| | | * æ¸
ç©ºä»»å¡æ¥å¿
|
| | | */
|
| | | public void cleanJobLog();
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysJobMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.mapper; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.project.monitor.domain.SysJob; |
| | | |
| | | /** |
| | | * è°åº¦ä»»å¡ä¿¡æ¯ æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysJobMapper |
| | | { |
| | | /** |
| | | * æ¥è¯¢è°åº¦ä»»å¡æ¥å¿éå |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ |
| | | * @return æä½æ¥å¿éå |
| | | */ |
| | | public List<SysJob> selectJobList(SysJob job); |
| | | |
| | | /** |
| | | * æ¥è¯¢ææè°åº¦ä»»å¡ |
| | | * |
| | | * @return è°åº¦ä»»å¡å表 |
| | | */ |
| | | public List<SysJob> selectJobAll(); |
| | | |
| | | /** |
| | | * éè¿è°åº¦IDæ¥è¯¢è°åº¦ä»»å¡ä¿¡æ¯ |
| | | * |
| | | * @param jobId è°åº¦ID |
| | | * @return è§è²å¯¹è±¡ä¿¡æ¯ |
| | | */ |
| | | public SysJob selectJobById(Long jobId); |
| | | |
| | | /** |
| | | * éè¿è°åº¦IDå é¤è°åº¦ä»»å¡ä¿¡æ¯ |
| | | * |
| | | * @param jobId è°åº¦ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteJobById(Long jobId); |
| | | |
| | | /** |
| | | * æ¹éå é¤è°åº¦ä»»å¡ä¿¡æ¯ |
| | | * |
| | | * @param ids éè¦å é¤çæ°æ®ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteJobByIds(Long[] ids); |
| | | |
| | | /** |
| | | * ä¿®æ¹è°åº¦ä»»å¡ä¿¡æ¯ |
| | | * |
| | | * @param job è°åº¦ä»»å¡ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateJob(SysJob job); |
| | | |
| | | /** |
| | | * æ°å¢è°åº¦ä»»å¡ä¿¡æ¯ |
| | | * |
| | | * @param job è°åº¦ä»»å¡ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertJob(SysJob job); |
| | | } |
| | | package com.ruoyi.quartz.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.quartz.domain.SysJob;
|
| | |
|
| | | /**
|
| | | * è°åº¦ä»»å¡ä¿¡æ¯ æ°æ®å±
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public interface SysJobMapper
|
| | | {
|
| | | /**
|
| | | * æ¥è¯¢è°åº¦ä»»å¡æ¥å¿éå
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯
|
| | | * @return æä½æ¥å¿éå
|
| | | */
|
| | | public List<SysJob> selectJobList(SysJob job);
|
| | |
|
| | | /**
|
| | | * æ¥è¯¢ææè°åº¦ä»»å¡
|
| | | * |
| | | * @return è°åº¦ä»»å¡å表
|
| | | */
|
| | | public List<SysJob> selectJobAll();
|
| | |
|
| | | /**
|
| | | * éè¿è°åº¦IDæ¥è¯¢è°åº¦ä»»å¡ä¿¡æ¯
|
| | | * |
| | | * @param jobId è°åº¦ID
|
| | | * @return è§è²å¯¹è±¡ä¿¡æ¯
|
| | | */
|
| | | public SysJob selectJobById(Long jobId);
|
| | |
|
| | | /**
|
| | | * éè¿è°åº¦IDå é¤è°åº¦ä»»å¡ä¿¡æ¯
|
| | | * |
| | | * @param jobId è°åº¦ID
|
| | | * @return ç»æ
|
| | | */
|
| | | public int deleteJobById(Long jobId);
|
| | |
|
| | | /**
|
| | | * æ¹éå é¤è°åº¦ä»»å¡ä¿¡æ¯
|
| | | * |
| | | * @param ids éè¦å é¤çæ°æ®ID
|
| | | * @return ç»æ
|
| | | */
|
| | | public int deleteJobByIds(Long[] ids);
|
| | |
|
| | | /**
|
| | | * ä¿®æ¹è°åº¦ä»»å¡ä¿¡æ¯
|
| | | * |
| | | * @param job è°åº¦ä»»å¡ä¿¡æ¯
|
| | | * @return ç»æ
|
| | | */
|
| | | public int updateJob(SysJob job);
|
| | |
|
| | | /**
|
| | | * æ°å¢è°åº¦ä»»å¡ä¿¡æ¯
|
| | | * |
| | | * @param job è°åº¦ä»»å¡ä¿¡æ¯
|
| | | * @return ç»æ
|
| | | */
|
| | | public int insertJob(SysJob job);
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysJobLogService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.service; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.project.monitor.domain.SysJobLog; |
| | | |
| | | /** |
| | | * 宿¶ä»»å¡è°åº¦æ¥å¿ä¿¡æ¯ä¿¡æ¯ æå¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysJobLogService |
| | | { |
| | | /** |
| | | * è·åquartzè°åº¦å¨æ¥å¿ç计åä»»å¡ |
| | | * |
| | | * @param jobLog è°åº¦æ¥å¿ä¿¡æ¯ |
| | | * @return è°åº¦ä»»å¡æ¥å¿éå |
| | | */ |
| | | public List<SysJobLog> selectJobLogList(SysJobLog jobLog); |
| | | |
| | | /** |
| | | * éè¿è°åº¦ä»»å¡æ¥å¿IDæ¥è¯¢è°åº¦ä¿¡æ¯ |
| | | * |
| | | * @param jobLogId è°åº¦ä»»å¡æ¥å¿ID |
| | | * @return è°åº¦ä»»å¡æ¥å¿å¯¹è±¡ä¿¡æ¯ |
| | | */ |
| | | public SysJobLog selectJobLogById(Long jobLogId); |
| | | |
| | | /** |
| | | * æ°å¢ä»»å¡æ¥å¿ |
| | | * |
| | | * @param jobLog è°åº¦æ¥å¿ä¿¡æ¯ |
| | | */ |
| | | public void addJobLog(SysJobLog jobLog); |
| | | |
| | | /** |
| | | * æ¹éå é¤è°åº¦æ¥å¿ä¿¡æ¯ |
| | | * |
| | | * @param logIds éè¦å é¤çæ¥å¿ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteJobLogByIds(Long[] logIds); |
| | | |
| | | /** |
| | | * å é¤ä»»å¡æ¥å¿ |
| | | * |
| | | * @param jobId è°åº¦æ¥å¿ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteJobLogById(Long jobId); |
| | | |
| | | /** |
| | | * æ¸
ç©ºä»»å¡æ¥å¿ |
| | | */ |
| | | public void cleanJobLog(); |
| | | } |
| | | package com.ruoyi.quartz.service;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.quartz.domain.SysJobLog;
|
| | |
|
| | | /**
|
| | | * 宿¶ä»»å¡è°åº¦æ¥å¿ä¿¡æ¯ä¿¡æ¯ æå¡å±
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public interface ISysJobLogService
|
| | | {
|
| | | /**
|
| | | * è·åquartzè°åº¦å¨æ¥å¿ç计åä»»å¡
|
| | | * |
| | | * @param jobLog è°åº¦æ¥å¿ä¿¡æ¯
|
| | | * @return è°åº¦ä»»å¡æ¥å¿éå
|
| | | */
|
| | | public List<SysJobLog> selectJobLogList(SysJobLog jobLog);
|
| | |
|
| | | /**
|
| | | * éè¿è°åº¦ä»»å¡æ¥å¿IDæ¥è¯¢è°åº¦ä¿¡æ¯
|
| | | * |
| | | * @param jobLogId è°åº¦ä»»å¡æ¥å¿ID
|
| | | * @return è°åº¦ä»»å¡æ¥å¿å¯¹è±¡ä¿¡æ¯
|
| | | */
|
| | | public SysJobLog selectJobLogById(Long jobLogId);
|
| | |
|
| | | /**
|
| | | * æ°å¢ä»»å¡æ¥å¿
|
| | | * |
| | | * @param jobLog è°åº¦æ¥å¿ä¿¡æ¯
|
| | | */
|
| | | public void addJobLog(SysJobLog jobLog);
|
| | |
|
| | | /**
|
| | | * æ¹éå é¤è°åº¦æ¥å¿ä¿¡æ¯
|
| | | * |
| | | * @param logIds éè¦å é¤çæ¥å¿ID
|
| | | * @return ç»æ
|
| | | */
|
| | | public int deleteJobLogByIds(Long[] logIds);
|
| | |
|
| | | /**
|
| | | * å é¤ä»»å¡æ¥å¿
|
| | | * |
| | | * @param jobId è°åº¦æ¥å¿ID
|
| | | * @return ç»æ
|
| | | */
|
| | | public int deleteJobLogById(Long jobId);
|
| | |
|
| | | /**
|
| | | * æ¸
ç©ºä»»å¡æ¥å¿
|
| | | */
|
| | | public void cleanJobLog();
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysJobService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.service; |
| | | |
| | | import java.util.List; |
| | | import org.quartz.SchedulerException; |
| | | import com.ruoyi.common.exception.job.TaskException; |
| | | import com.ruoyi.project.monitor.domain.SysJob; |
| | | |
| | | /** |
| | | * 宿¶ä»»å¡è°åº¦ä¿¡æ¯ä¿¡æ¯ æå¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysJobService |
| | | { |
| | | /** |
| | | * è·åquartzè°åº¦å¨ç计åä»»å¡ |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ |
| | | * @return è°åº¦ä»»å¡éå |
| | | */ |
| | | public List<SysJob> selectJobList(SysJob job); |
| | | |
| | | /** |
| | | * éè¿è°åº¦ä»»å¡IDæ¥è¯¢è°åº¦ä¿¡æ¯ |
| | | * |
| | | * @param jobId è°åº¦ä»»å¡ID |
| | | * @return è°åº¦ä»»å¡å¯¹è±¡ä¿¡æ¯ |
| | | */ |
| | | public SysJob selectJobById(Long jobId); |
| | | |
| | | /** |
| | | * æåä»»å¡ |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int pauseJob(SysJob job) throws SchedulerException; |
| | | |
| | | /** |
| | | * æ¢å¤ä»»å¡ |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int resumeJob(SysJob job) throws SchedulerException; |
| | | |
| | | /** |
| | | * å é¤ä»»å¡åï¼æå¯¹åºçtriggerä¹å°è¢«å é¤ |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteJob(SysJob job) throws SchedulerException; |
| | | |
| | | /** |
| | | * æ¹éå é¤è°åº¦ä¿¡æ¯ |
| | | * |
| | | * @param jobIds éè¦å é¤çä»»å¡ID |
| | | * @return ç»æ |
| | | */ |
| | | public void deleteJobByIds(Long[] jobIds) throws SchedulerException; |
| | | |
| | | /** |
| | | * ä»»å¡è°åº¦ç¶æä¿®æ¹ |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int changeStatus(SysJob job) throws SchedulerException; |
| | | |
| | | /** |
| | | * ç«å³è¿è¡ä»»å¡ |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public void run(SysJob job) throws SchedulerException; |
| | | |
| | | /** |
| | | * æ°å¢ä»»å¡ |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertJob(SysJob job) throws SchedulerException, TaskException; |
| | | |
| | | /** |
| | | * æ´æ°ä»»å¡ |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateJob(SysJob job) throws SchedulerException, TaskException; |
| | | |
| | | /** |
| | | * æ ¡éªcronè¡¨è¾¾å¼æ¯å¦ææ |
| | | * |
| | | * @param cronExpression è¡¨è¾¾å¼ |
| | | * @return ç»æ |
| | | */ |
| | | public boolean checkCronExpressionIsValid(String cronExpression); |
| | | } |
| | | package com.ruoyi.quartz.service;
|
| | |
|
| | | import java.util.List;
|
| | | import org.quartz.SchedulerException;
|
| | | import com.ruoyi.common.exception.job.TaskException;
|
| | | import com.ruoyi.quartz.domain.SysJob;
|
| | |
|
| | | /**
|
| | | * 宿¶ä»»å¡è°åº¦ä¿¡æ¯ä¿¡æ¯ æå¡å±
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public interface ISysJobService
|
| | | {
|
| | | /**
|
| | | * è·åquartzè°åº¦å¨ç计åä»»å¡
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯
|
| | | * @return è°åº¦ä»»å¡éå
|
| | | */
|
| | | public List<SysJob> selectJobList(SysJob job);
|
| | |
|
| | | /**
|
| | | * éè¿è°åº¦ä»»å¡IDæ¥è¯¢è°åº¦ä¿¡æ¯
|
| | | * |
| | | * @param jobId è°åº¦ä»»å¡ID
|
| | | * @return è°åº¦ä»»å¡å¯¹è±¡ä¿¡æ¯
|
| | | */
|
| | | public SysJob selectJobById(Long jobId);
|
| | |
|
| | | /**
|
| | | * æåä»»å¡
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯
|
| | | * @return ç»æ
|
| | | */
|
| | | public int pauseJob(SysJob job) throws SchedulerException;
|
| | |
|
| | | /**
|
| | | * æ¢å¤ä»»å¡
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯
|
| | | * @return ç»æ
|
| | | */
|
| | | public int resumeJob(SysJob job) throws SchedulerException;
|
| | |
|
| | | /**
|
| | | * å é¤ä»»å¡åï¼æå¯¹åºçtriggerä¹å°è¢«å é¤
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯
|
| | | * @return ç»æ
|
| | | */
|
| | | public int deleteJob(SysJob job) throws SchedulerException;
|
| | |
|
| | | /**
|
| | | * æ¹éå é¤è°åº¦ä¿¡æ¯
|
| | | * |
| | | * @param jobIds éè¦å é¤çä»»å¡ID
|
| | | * @return ç»æ
|
| | | */
|
| | | public void deleteJobByIds(Long[] jobIds) throws SchedulerException;
|
| | |
|
| | | /**
|
| | | * ä»»å¡è°åº¦ç¶æä¿®æ¹
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯
|
| | | * @return ç»æ
|
| | | */
|
| | | public int changeStatus(SysJob job) throws SchedulerException;
|
| | |
|
| | | /**
|
| | | * ç«å³è¿è¡ä»»å¡
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯
|
| | | * @return ç»æ
|
| | | */
|
| | | public void run(SysJob job) throws SchedulerException;
|
| | |
|
| | | /**
|
| | | * æ°å¢ä»»å¡
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯
|
| | | * @return ç»æ
|
| | | */
|
| | | public int insertJob(SysJob job) throws SchedulerException, TaskException;
|
| | |
|
| | | /**
|
| | | * æ´æ°ä»»å¡
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯
|
| | | * @return ç»æ
|
| | | */
|
| | | public int updateJob(SysJob job) throws SchedulerException, TaskException;
|
| | |
|
| | | /**
|
| | | * æ ¡éªcronè¡¨è¾¾å¼æ¯å¦ææ
|
| | | * |
| | | * @param cronExpression 表达å¼
|
| | | * @return ç»æ
|
| | | */
|
| | | public boolean checkCronExpressionIsValid(String cronExpression);
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysJobLogServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.service.impl; |
| | | |
| | | import java.util.List; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.project.monitor.domain.SysJobLog; |
| | | import com.ruoyi.project.monitor.mapper.SysJobLogMapper; |
| | | import com.ruoyi.project.monitor.service.ISysJobLogService; |
| | | |
| | | /** |
| | | * 宿¶ä»»å¡è°åº¦æ¥å¿ä¿¡æ¯ æå¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysJobLogServiceImpl implements ISysJobLogService |
| | | { |
| | | @Autowired |
| | | private SysJobLogMapper jobLogMapper; |
| | | |
| | | /** |
| | | * è·åquartzè°åº¦å¨æ¥å¿ç计åä»»å¡ |
| | | * |
| | | * @param jobLog è°åº¦æ¥å¿ä¿¡æ¯ |
| | | * @return è°åº¦ä»»å¡æ¥å¿éå |
| | | */ |
| | | @Override |
| | | public List<SysJobLog> selectJobLogList(SysJobLog jobLog) |
| | | { |
| | | return jobLogMapper.selectJobLogList(jobLog); |
| | | } |
| | | |
| | | /** |
| | | * éè¿è°åº¦ä»»å¡æ¥å¿IDæ¥è¯¢è°åº¦ä¿¡æ¯ |
| | | * |
| | | * @param jobLogId è°åº¦ä»»å¡æ¥å¿ID |
| | | * @return è°åº¦ä»»å¡æ¥å¿å¯¹è±¡ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public SysJobLog selectJobLogById(Long jobLogId) |
| | | { |
| | | return jobLogMapper.selectJobLogById(jobLogId); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢ä»»å¡æ¥å¿ |
| | | * |
| | | * @param jobLog è°åº¦æ¥å¿ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public void addJobLog(SysJobLog jobLog) |
| | | { |
| | | jobLogMapper.insertJobLog(jobLog); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå é¤è°åº¦æ¥å¿ä¿¡æ¯ |
| | | * |
| | | * @param logIds éè¦å é¤çæ°æ®ID |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int deleteJobLogByIds(Long[] logIds) |
| | | { |
| | | return jobLogMapper.deleteJobLogByIds(logIds); |
| | | } |
| | | |
| | | /** |
| | | * å é¤ä»»å¡æ¥å¿ |
| | | * |
| | | * @param jobId è°åº¦æ¥å¿ID |
| | | */ |
| | | @Override |
| | | public int deleteJobLogById(Long jobId) |
| | | { |
| | | return jobLogMapper.deleteJobLogById(jobId); |
| | | } |
| | | |
| | | /** |
| | | * æ¸
ç©ºä»»å¡æ¥å¿ |
| | | */ |
| | | @Override |
| | | public void cleanJobLog() |
| | | { |
| | | jobLogMapper.cleanJobLog(); |
| | | } |
| | | } |
| | | package com.ruoyi.quartz.service.impl;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.quartz.domain.SysJobLog;
|
| | | import com.ruoyi.quartz.mapper.SysJobLogMapper;
|
| | | import com.ruoyi.quartz.service.ISysJobLogService;
|
| | |
|
| | | /**
|
| | | * 宿¶ä»»å¡è°åº¦æ¥å¿ä¿¡æ¯ æå¡å±
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @Service
|
| | | public class SysJobLogServiceImpl implements ISysJobLogService
|
| | | {
|
| | | @Autowired
|
| | | private SysJobLogMapper jobLogMapper;
|
| | |
|
| | | /**
|
| | | * è·åquartzè°åº¦å¨æ¥å¿ç计åä»»å¡
|
| | | * |
| | | * @param jobLog è°åº¦æ¥å¿ä¿¡æ¯
|
| | | * @return è°åº¦ä»»å¡æ¥å¿éå
|
| | | */
|
| | | @Override
|
| | | public List<SysJobLog> selectJobLogList(SysJobLog jobLog)
|
| | | {
|
| | | return jobLogMapper.selectJobLogList(jobLog);
|
| | | }
|
| | |
|
| | | /**
|
| | | * éè¿è°åº¦ä»»å¡æ¥å¿IDæ¥è¯¢è°åº¦ä¿¡æ¯
|
| | | * |
| | | * @param jobLogId è°åº¦ä»»å¡æ¥å¿ID
|
| | | * @return è°åº¦ä»»å¡æ¥å¿å¯¹è±¡ä¿¡æ¯
|
| | | */
|
| | | @Override
|
| | | public SysJobLog selectJobLogById(Long jobLogId)
|
| | | {
|
| | | return jobLogMapper.selectJobLogById(jobLogId);
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ°å¢ä»»å¡æ¥å¿
|
| | | * |
| | | * @param jobLog è°åº¦æ¥å¿ä¿¡æ¯
|
| | | */
|
| | | @Override
|
| | | public void addJobLog(SysJobLog jobLog)
|
| | | {
|
| | | jobLogMapper.insertJobLog(jobLog);
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ¹éå é¤è°åº¦æ¥å¿ä¿¡æ¯
|
| | | * |
| | | * @param logIds éè¦å é¤çæ°æ®ID
|
| | | * @return ç»æ
|
| | | */
|
| | | @Override
|
| | | public int deleteJobLogByIds(Long[] logIds)
|
| | | {
|
| | | return jobLogMapper.deleteJobLogByIds(logIds);
|
| | | }
|
| | |
|
| | | /**
|
| | | * å é¤ä»»å¡æ¥å¿
|
| | | * |
| | | * @param jobId è°åº¦æ¥å¿ID
|
| | | */
|
| | | @Override
|
| | | public int deleteJobLogById(Long jobId)
|
| | | {
|
| | | return jobLogMapper.deleteJobLogById(jobId);
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ¸
ç©ºä»»å¡æ¥å¿
|
| | | */
|
| | | @Override
|
| | | public void cleanJobLog()
|
| | | {
|
| | | jobLogMapper.cleanJobLog();
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysJobServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.service.impl; |
| | | |
| | | import java.util.List; |
| | | import javax.annotation.PostConstruct; |
| | | import org.quartz.JobDataMap; |
| | | import org.quartz.JobKey; |
| | | import org.quartz.Scheduler; |
| | | import org.quartz.SchedulerException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import com.ruoyi.common.constant.ScheduleConstants; |
| | | import com.ruoyi.common.exception.job.TaskException; |
| | | import com.ruoyi.common.utils.job.CronUtils; |
| | | import com.ruoyi.common.utils.job.ScheduleUtils; |
| | | import com.ruoyi.project.monitor.domain.SysJob; |
| | | import com.ruoyi.project.monitor.mapper.SysJobMapper; |
| | | import com.ruoyi.project.monitor.service.ISysJobService; |
| | | |
| | | /** |
| | | * 宿¶ä»»å¡è°åº¦ä¿¡æ¯ æå¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysJobServiceImpl implements ISysJobService |
| | | { |
| | | @Autowired |
| | | private Scheduler scheduler; |
| | | |
| | | @Autowired |
| | | private SysJobMapper jobMapper; |
| | | |
| | | /** |
| | | * 项ç®å¯å¨æ¶ï¼åå§å宿¶å¨ ä¸»è¦æ¯é²æ¢æå¨ä¿®æ¹æ°æ®åºå¯¼è´æªåæ¥å°å®æ¶ä»»å¡å¤çï¼æ³¨ï¼ä¸è½æå¨ä¿®æ¹æ°æ®åºIDåä»»å¡ç»åï¼å¦åä¼å¯¼è´èæ°æ®ï¼ |
| | | */ |
| | | @PostConstruct |
| | | public void init() throws SchedulerException, TaskException |
| | | { |
| | | scheduler.clear(); |
| | | List<SysJob> jobList = jobMapper.selectJobAll(); |
| | | for (SysJob job : jobList) |
| | | { |
| | | ScheduleUtils.createScheduleJob(scheduler, job); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åquartzè°åº¦å¨ç计åä»»å¡å表 |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<SysJob> selectJobList(SysJob job) |
| | | { |
| | | return jobMapper.selectJobList(job); |
| | | } |
| | | |
| | | /** |
| | | * éè¿è°åº¦ä»»å¡IDæ¥è¯¢è°åº¦ä¿¡æ¯ |
| | | * |
| | | * @param jobId è°åº¦ä»»å¡ID |
| | | * @return è°åº¦ä»»å¡å¯¹è±¡ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public SysJob selectJobById(Long jobId) |
| | | { |
| | | return jobMapper.selectJobById(jobId); |
| | | } |
| | | |
| | | /** |
| | | * æåä»»å¡ |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public int pauseJob(SysJob job) throws SchedulerException |
| | | { |
| | | Long jobId = job.getJobId(); |
| | | String jobGroup = job.getJobGroup(); |
| | | job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); |
| | | int rows = jobMapper.updateJob(job); |
| | | if (rows > 0) |
| | | { |
| | | scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); |
| | | } |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | | * æ¢å¤ä»»å¡ |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public int resumeJob(SysJob job) throws SchedulerException |
| | | { |
| | | Long jobId = job.getJobId(); |
| | | String jobGroup = job.getJobGroup(); |
| | | job.setStatus(ScheduleConstants.Status.NORMAL.getValue()); |
| | | int rows = jobMapper.updateJob(job); |
| | | if (rows > 0) |
| | | { |
| | | scheduler.resumeJob(ScheduleUtils.getJobKey(jobId, jobGroup)); |
| | | } |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | | * å é¤ä»»å¡åï¼æå¯¹åºçtriggerä¹å°è¢«å é¤ |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public int deleteJob(SysJob job) throws SchedulerException |
| | | { |
| | | Long jobId = job.getJobId(); |
| | | String jobGroup = job.getJobGroup(); |
| | | int rows = jobMapper.deleteJobById(jobId); |
| | | if (rows > 0) |
| | | { |
| | | scheduler.deleteJob(ScheduleUtils.getJobKey(jobId, jobGroup)); |
| | | } |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå é¤è°åº¦ä¿¡æ¯ |
| | | * |
| | | * @param jobIds éè¦å é¤çä»»å¡ID |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void deleteJobByIds(Long[] jobIds) throws SchedulerException |
| | | { |
| | | for (Long jobId : jobIds) |
| | | { |
| | | SysJob job = jobMapper.selectJobById(jobId); |
| | | deleteJob(job); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ä»»å¡è°åº¦ç¶æä¿®æ¹ |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public int changeStatus(SysJob job) throws SchedulerException |
| | | { |
| | | int rows = 0; |
| | | String status = job.getStatus(); |
| | | if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) |
| | | { |
| | | rows = resumeJob(job); |
| | | } |
| | | else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) |
| | | { |
| | | rows = pauseJob(job); |
| | | } |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | | * ç«å³è¿è¡ä»»å¡ |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void run(SysJob job) throws SchedulerException |
| | | { |
| | | Long jobId = job.getJobId(); |
| | | String jobGroup = job.getJobGroup(); |
| | | SysJob properties = selectJobById(job.getJobId()); |
| | | // åæ° |
| | | JobDataMap dataMap = new JobDataMap(); |
| | | dataMap.put(ScheduleConstants.TASK_PROPERTIES, properties); |
| | | scheduler.triggerJob(ScheduleUtils.getJobKey(jobId, jobGroup), dataMap); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢ä»»å¡ |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ è°åº¦ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public int insertJob(SysJob job) throws SchedulerException, TaskException |
| | | { |
| | | job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); |
| | | int rows = jobMapper.insertJob(job); |
| | | if (rows > 0) |
| | | { |
| | | ScheduleUtils.createScheduleJob(scheduler, job); |
| | | } |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | | * æ´æ°ä»»å¡çæ¶é´è¡¨è¾¾å¼ |
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public int updateJob(SysJob job) throws SchedulerException, TaskException |
| | | { |
| | | SysJob properties = selectJobById(job.getJobId()); |
| | | int rows = jobMapper.updateJob(job); |
| | | if (rows > 0) |
| | | { |
| | | updateSchedulerJob(job, properties.getJobGroup()); |
| | | } |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | | * æ´æ°ä»»å¡ |
| | | * |
| | | * @param job ä»»å¡å¯¹è±¡ |
| | | * @param jobGroup ä»»å¡ç»å |
| | | */ |
| | | public void updateSchedulerJob(SysJob job, String jobGroup) throws SchedulerException, TaskException |
| | | { |
| | | Long jobId = job.getJobId(); |
| | | // 夿æ¯å¦åå¨ |
| | | JobKey jobKey = ScheduleUtils.getJobKey(jobId, jobGroup); |
| | | if (scheduler.checkExists(jobKey)) |
| | | { |
| | | // 鲿¢å建æ¶å卿°æ®é®é¢ å
ç§»é¤ï¼ç¶å卿§è¡å建æä½ |
| | | scheduler.deleteJob(jobKey); |
| | | } |
| | | ScheduleUtils.createScheduleJob(scheduler, job); |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªcronè¡¨è¾¾å¼æ¯å¦ææ |
| | | * |
| | | * @param cronExpression è¡¨è¾¾å¼ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public boolean checkCronExpressionIsValid(String cronExpression) |
| | | { |
| | | return CronUtils.isValid(cronExpression); |
| | | } |
| | | } |
| | | package com.ruoyi.quartz.service.impl;
|
| | |
|
| | | import java.util.List;
|
| | | import javax.annotation.PostConstruct;
|
| | | import org.quartz.JobDataMap;
|
| | | import org.quartz.JobKey;
|
| | | import org.quartz.Scheduler;
|
| | | import org.quartz.SchedulerException;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import com.ruoyi.common.constant.ScheduleConstants;
|
| | | import com.ruoyi.common.exception.job.TaskException;
|
| | | import com.ruoyi.quartz.domain.SysJob;
|
| | | import com.ruoyi.quartz.mapper.SysJobMapper;
|
| | | import com.ruoyi.quartz.service.ISysJobService;
|
| | | import com.ruoyi.quartz.util.CronUtils;
|
| | | import com.ruoyi.quartz.util.ScheduleUtils;
|
| | |
|
| | | /**
|
| | | * 宿¶ä»»å¡è°åº¦ä¿¡æ¯ æå¡å±
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @Service
|
| | | public class SysJobServiceImpl implements ISysJobService
|
| | | {
|
| | | @Autowired
|
| | | private Scheduler scheduler;
|
| | |
|
| | | @Autowired
|
| | | private SysJobMapper jobMapper;
|
| | |
|
| | | /**
|
| | | * 项ç®å¯å¨æ¶ï¼åå§å宿¶å¨ ä¸»è¦æ¯é²æ¢æå¨ä¿®æ¹æ°æ®åºå¯¼è´æªåæ¥å°å®æ¶ä»»å¡å¤çï¼æ³¨ï¼ä¸è½æå¨ä¿®æ¹æ°æ®åºIDåä»»å¡ç»åï¼å¦åä¼å¯¼è´èæ°æ®ï¼
|
| | | */
|
| | | @PostConstruct
|
| | | public void init() throws SchedulerException, TaskException
|
| | | {
|
| | | scheduler.clear();
|
| | | List<SysJob> jobList = jobMapper.selectJobAll();
|
| | | for (SysJob job : jobList)
|
| | | {
|
| | | ScheduleUtils.createScheduleJob(scheduler, job);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·åquartzè°åº¦å¨ç计åä»»å¡å表
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public List<SysJob> selectJobList(SysJob job)
|
| | | {
|
| | | return jobMapper.selectJobList(job);
|
| | | }
|
| | |
|
| | | /**
|
| | | * éè¿è°åº¦ä»»å¡IDæ¥è¯¢è°åº¦ä¿¡æ¯
|
| | | * |
| | | * @param jobId è°åº¦ä»»å¡ID
|
| | | * @return è°åº¦ä»»å¡å¯¹è±¡ä¿¡æ¯
|
| | | */
|
| | | @Override
|
| | | public SysJob selectJobById(Long jobId)
|
| | | {
|
| | | return jobMapper.selectJobById(jobId);
|
| | | }
|
| | |
|
| | | /**
|
| | | * æåä»»å¡
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯
|
| | | */
|
| | | @Override
|
| | | @Transactional
|
| | | public int pauseJob(SysJob job) throws SchedulerException
|
| | | {
|
| | | Long jobId = job.getJobId();
|
| | | String jobGroup = job.getJobGroup();
|
| | | job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
|
| | | int rows = jobMapper.updateJob(job);
|
| | | if (rows > 0)
|
| | | {
|
| | | scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup));
|
| | | }
|
| | | return rows;
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ¢å¤ä»»å¡
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯
|
| | | */
|
| | | @Override
|
| | | @Transactional
|
| | | public int resumeJob(SysJob job) throws SchedulerException
|
| | | {
|
| | | Long jobId = job.getJobId();
|
| | | String jobGroup = job.getJobGroup();
|
| | | job.setStatus(ScheduleConstants.Status.NORMAL.getValue());
|
| | | int rows = jobMapper.updateJob(job);
|
| | | if (rows > 0)
|
| | | {
|
| | | scheduler.resumeJob(ScheduleUtils.getJobKey(jobId, jobGroup));
|
| | | }
|
| | | return rows;
|
| | | }
|
| | |
|
| | | /**
|
| | | * å é¤ä»»å¡åï¼æå¯¹åºçtriggerä¹å°è¢«å é¤
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯
|
| | | */
|
| | | @Override
|
| | | @Transactional
|
| | | public int deleteJob(SysJob job) throws SchedulerException
|
| | | {
|
| | | Long jobId = job.getJobId();
|
| | | String jobGroup = job.getJobGroup();
|
| | | int rows = jobMapper.deleteJobById(jobId);
|
| | | if (rows > 0)
|
| | | {
|
| | | scheduler.deleteJob(ScheduleUtils.getJobKey(jobId, jobGroup));
|
| | | }
|
| | | return rows;
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ¹éå é¤è°åº¦ä¿¡æ¯
|
| | | * |
| | | * @param jobIds éè¦å é¤çä»»å¡ID
|
| | | * @return ç»æ
|
| | | */
|
| | | @Override
|
| | | @Transactional
|
| | | public void deleteJobByIds(Long[] jobIds) throws SchedulerException
|
| | | {
|
| | | for (Long jobId : jobIds)
|
| | | {
|
| | | SysJob job = jobMapper.selectJobById(jobId);
|
| | | deleteJob(job);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * ä»»å¡è°åº¦ç¶æä¿®æ¹
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯
|
| | | */
|
| | | @Override
|
| | | @Transactional
|
| | | public int changeStatus(SysJob job) throws SchedulerException
|
| | | {
|
| | | int rows = 0;
|
| | | String status = job.getStatus();
|
| | | if (ScheduleConstants.Status.NORMAL.getValue().equals(status))
|
| | | {
|
| | | rows = resumeJob(job);
|
| | | }
|
| | | else if (ScheduleConstants.Status.PAUSE.getValue().equals(status))
|
| | | {
|
| | | rows = pauseJob(job);
|
| | | }
|
| | | return rows;
|
| | | }
|
| | |
|
| | | /**
|
| | | * ç«å³è¿è¡ä»»å¡
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯
|
| | | */
|
| | | @Override
|
| | | @Transactional
|
| | | public void run(SysJob job) throws SchedulerException
|
| | | {
|
| | | Long jobId = job.getJobId();
|
| | | String jobGroup = job.getJobGroup();
|
| | | SysJob properties = selectJobById(job.getJobId());
|
| | | // åæ°
|
| | | JobDataMap dataMap = new JobDataMap();
|
| | | dataMap.put(ScheduleConstants.TASK_PROPERTIES, properties);
|
| | | scheduler.triggerJob(ScheduleUtils.getJobKey(jobId, jobGroup), dataMap);
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ°å¢ä»»å¡
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯ è°åº¦ä¿¡æ¯
|
| | | */
|
| | | @Override
|
| | | @Transactional
|
| | | public int insertJob(SysJob job) throws SchedulerException, TaskException
|
| | | {
|
| | | job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
|
| | | int rows = jobMapper.insertJob(job);
|
| | | if (rows > 0)
|
| | | {
|
| | | ScheduleUtils.createScheduleJob(scheduler, job);
|
| | | }
|
| | | return rows;
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ´æ°ä»»å¡çæ¶é´è¡¨è¾¾å¼
|
| | | * |
| | | * @param job è°åº¦ä¿¡æ¯
|
| | | */
|
| | | @Override
|
| | | @Transactional
|
| | | public int updateJob(SysJob job) throws SchedulerException, TaskException
|
| | | {
|
| | | SysJob properties = selectJobById(job.getJobId());
|
| | | int rows = jobMapper.updateJob(job);
|
| | | if (rows > 0)
|
| | | {
|
| | | updateSchedulerJob(job, properties.getJobGroup());
|
| | | }
|
| | | return rows;
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ´æ°ä»»å¡
|
| | | * |
| | | * @param job ä»»å¡å¯¹è±¡
|
| | | * @param jobGroup ä»»å¡ç»å
|
| | | */
|
| | | public void updateSchedulerJob(SysJob job, String jobGroup) throws SchedulerException, TaskException
|
| | | {
|
| | | Long jobId = job.getJobId();
|
| | | // 夿æ¯å¦åå¨
|
| | | JobKey jobKey = ScheduleUtils.getJobKey(jobId, jobGroup);
|
| | | if (scheduler.checkExists(jobKey))
|
| | | {
|
| | | // 鲿¢å建æ¶å卿°æ®é®é¢ å
ç§»é¤ï¼ç¶å卿§è¡å建æä½
|
| | | scheduler.deleteJob(jobKey);
|
| | | }
|
| | | ScheduleUtils.createScheduleJob(scheduler, job);
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ ¡éªcronè¡¨è¾¾å¼æ¯å¦ææ
|
| | | * |
| | | * @param cronExpression 表达å¼
|
| | | * @return ç»æ
|
| | | */
|
| | | @Override
|
| | | public boolean checkCronExpressionIsValid(String cronExpression)
|
| | | {
|
| | | return CronUtils.isValid(cronExpression);
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/framework/task/RyTask.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.task; |
| | | |
| | | import org.springframework.stereotype.Component; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | /** |
| | | * 宿¶ä»»å¡è°åº¦æµè¯ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component("ryTask") |
| | | public class RyTask |
| | | { |
| | | public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) |
| | | { |
| | | System.out.println(StringUtils.format("æ§è¡å¤åæ¹æ³ï¼ å符串类å{}ï¼å¸å°ç±»å{}ï¼é¿æ´å{}ï¼æµ®ç¹å{}ï¼æ´å½¢{}", s, b, l, d, i)); |
| | | } |
| | | |
| | | public void ryParams(String params) |
| | | { |
| | | System.out.println("æ§è¡æåæ¹æ³ï¼" + params); |
| | | } |
| | | |
| | | public void ryNoParams() |
| | | { |
| | | System.out.println("æ§è¡æ åæ¹æ³"); |
| | | } |
| | | } |
| | | package com.ruoyi.quartz.task;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | |
|
| | | /**
|
| | | * 宿¶ä»»å¡è°åº¦æµè¯
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @Component("ryTask")
|
| | | public class RyTask
|
| | | {
|
| | | public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
|
| | | {
|
| | | System.out.println(StringUtils.format("æ§è¡å¤åæ¹æ³ï¼ å符串类å{}ï¼å¸å°ç±»å{}ï¼é¿æ´å{}ï¼æµ®ç¹å{}ï¼æ´å½¢{}", s, b, l, d, i));
|
| | | }
|
| | |
|
| | | public void ryParams(String params)
|
| | | {
|
| | | System.out.println("æ§è¡æåæ¹æ³ï¼" + params);
|
| | | }
|
| | |
|
| | | public void ryNoParams()
|
| | | {
|
| | | System.out.println("æ§è¡æ åæ¹æ³");
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/job/AbstractQuartzJob.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.utils.job; |
| | | |
| | | import java.util.Date; |
| | | import org.quartz.Job; |
| | | import org.quartz.JobExecutionContext; |
| | | import org.quartz.JobExecutionException; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.ScheduleConstants; |
| | | import com.ruoyi.common.utils.ExceptionUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.project.monitor.domain.SysJob; |
| | | import com.ruoyi.project.monitor.domain.SysJobLog; |
| | | import com.ruoyi.project.monitor.service.ISysJobLogService; |
| | | |
| | | /** |
| | | * æ½è±¡quartzè°ç¨ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public abstract class AbstractQuartzJob implements Job |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(AbstractQuartzJob.class); |
| | | |
| | | /** |
| | | * çº¿ç¨æ¬å°åé |
| | | */ |
| | | private static ThreadLocal<Date> threadLocal = new ThreadLocal<>(); |
| | | |
| | | @Override |
| | | public void execute(JobExecutionContext context) throws JobExecutionException |
| | | { |
| | | SysJob sysJob = new SysJob(); |
| | | BeanUtils.copyBeanProp(sysJob, context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES)); |
| | | try |
| | | { |
| | | before(context, sysJob); |
| | | if (sysJob != null) |
| | | { |
| | | doExecute(context, sysJob); |
| | | } |
| | | after(context, sysJob, null); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | log.error("任塿§è¡å¼å¸¸ - ï¼", e); |
| | | after(context, sysJob, e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ§è¡å |
| | | * |
| | | * @param context 工使§è¡ä¸ä¸æå¯¹è±¡ |
| | | * @param sysJob ç³»ç»è®¡åä»»å¡ |
| | | */ |
| | | protected void before(JobExecutionContext context, SysJob sysJob) |
| | | { |
| | | threadLocal.set(new Date()); |
| | | } |
| | | |
| | | /** |
| | | * æ§è¡å |
| | | * |
| | | * @param context 工使§è¡ä¸ä¸æå¯¹è±¡ |
| | | * @param sysScheduleJob ç³»ç»è®¡åä»»å¡ |
| | | */ |
| | | protected void after(JobExecutionContext context, SysJob sysJob, Exception e) |
| | | { |
| | | Date startTime = threadLocal.get(); |
| | | threadLocal.remove(); |
| | | |
| | | final SysJobLog sysJobLog = new SysJobLog(); |
| | | sysJobLog.setJobName(sysJob.getJobName()); |
| | | sysJobLog.setJobGroup(sysJob.getJobGroup()); |
| | | sysJobLog.setInvokeTarget(sysJob.getInvokeTarget()); |
| | | sysJobLog.setStartTime(startTime); |
| | | sysJobLog.setStopTime(new Date()); |
| | | long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime(); |
| | | sysJobLog.setJobMessage(sysJobLog.getJobName() + " æ»å
±èæ¶ï¼" + runMs + "毫ç§"); |
| | | if (e != null) |
| | | { |
| | | sysJobLog.setStatus(Constants.FAIL); |
| | | String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(e), 0, 2000); |
| | | sysJobLog.setExceptionInfo(errorMsg); |
| | | } |
| | | else |
| | | { |
| | | sysJobLog.setStatus(Constants.SUCCESS); |
| | | } |
| | | |
| | | // åå
¥æ°æ®åºå½ä¸ |
| | | SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog); |
| | | } |
| | | |
| | | /** |
| | | * æ§è¡æ¹æ³ï¼ç±åç±»éè½½ |
| | | * |
| | | * @param context 工使§è¡ä¸ä¸æå¯¹è±¡ |
| | | * @param sysJob ç³»ç»è®¡åä»»å¡ |
| | | * @throws Exception æ§è¡è¿ç¨ä¸çå¼å¸¸ |
| | | */ |
| | | protected abstract void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception; |
| | | } |
| | | package com.ruoyi.quartz.util;
|
| | |
|
| | | import java.util.Date;
|
| | | import org.quartz.Job;
|
| | | import org.quartz.JobExecutionContext;
|
| | | import org.quartz.JobExecutionException;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.constant.ScheduleConstants;
|
| | | import com.ruoyi.common.utils.ExceptionUtil;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.bean.BeanUtils;
|
| | | import com.ruoyi.common.utils.spring.SpringUtils;
|
| | | import com.ruoyi.quartz.domain.SysJob;
|
| | | import com.ruoyi.quartz.domain.SysJobLog;
|
| | | import com.ruoyi.quartz.service.ISysJobLogService;
|
| | |
|
| | | /**
|
| | | * æ½è±¡quartzè°ç¨
|
| | | *
|
| | | * @author ruoyi
|
| | | */
|
| | | public abstract class AbstractQuartzJob implements Job
|
| | | {
|
| | | private static final Logger log = LoggerFactory.getLogger(AbstractQuartzJob.class);
|
| | |
|
| | | /**
|
| | | * çº¿ç¨æ¬å°åé
|
| | | */
|
| | | private static ThreadLocal<Date> threadLocal = new ThreadLocal<>();
|
| | |
|
| | | @Override
|
| | | public void execute(JobExecutionContext context) throws JobExecutionException
|
| | | {
|
| | | SysJob sysJob = new SysJob();
|
| | | BeanUtils.copyBeanProp(sysJob, context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES));
|
| | | try
|
| | | {
|
| | | before(context, sysJob);
|
| | | if (sysJob != null)
|
| | | {
|
| | | doExecute(context, sysJob);
|
| | | }
|
| | | after(context, sysJob, null);
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | log.error("任塿§è¡å¼å¸¸ - ï¼", e);
|
| | | after(context, sysJob, e);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ§è¡å
|
| | | *
|
| | | * @param context 工使§è¡ä¸ä¸æå¯¹è±¡
|
| | | * @param sysJob ç³»ç»è®¡åä»»å¡
|
| | | */
|
| | | protected void before(JobExecutionContext context, SysJob sysJob)
|
| | | {
|
| | | threadLocal.set(new Date());
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ§è¡å
|
| | | *
|
| | | * @param context 工使§è¡ä¸ä¸æå¯¹è±¡
|
| | | * @param sysScheduleJob ç³»ç»è®¡åä»»å¡
|
| | | */
|
| | | protected void after(JobExecutionContext context, SysJob sysJob, Exception e)
|
| | | {
|
| | | Date startTime = threadLocal.get();
|
| | | threadLocal.remove();
|
| | |
|
| | | final SysJobLog sysJobLog = new SysJobLog();
|
| | | sysJobLog.setJobName(sysJob.getJobName());
|
| | | sysJobLog.setJobGroup(sysJob.getJobGroup());
|
| | | sysJobLog.setInvokeTarget(sysJob.getInvokeTarget());
|
| | | sysJobLog.setStartTime(startTime);
|
| | | sysJobLog.setStopTime(new Date());
|
| | | long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime();
|
| | | sysJobLog.setJobMessage(sysJobLog.getJobName() + " æ»å
±èæ¶ï¼" + runMs + "毫ç§");
|
| | | if (e != null)
|
| | | {
|
| | | sysJobLog.setStatus(Constants.FAIL);
|
| | | String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(e), 0, 2000);
|
| | | sysJobLog.setExceptionInfo(errorMsg);
|
| | | }
|
| | | else
|
| | | {
|
| | | sysJobLog.setStatus(Constants.SUCCESS);
|
| | | }
|
| | |
|
| | | // åå
¥æ°æ®åºå½ä¸
|
| | | SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog);
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ§è¡æ¹æ³ï¼ç±åç±»éè½½
|
| | | *
|
| | | * @param context 工使§è¡ä¸ä¸æå¯¹è±¡
|
| | | * @param sysJob ç³»ç»è®¡åä»»å¡
|
| | | * @throws Exception æ§è¡è¿ç¨ä¸çå¼å¸¸
|
| | | */
|
| | | protected abstract void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception;
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/job/CronUtils.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.utils.job; |
| | | |
| | | import java.text.ParseException; |
| | | import java.util.Date; |
| | | import org.quartz.CronExpression; |
| | | |
| | | /** |
| | | * cron表达å¼å·¥å
·ç±» |
| | | * |
| | | * @author ruoyi |
| | | * |
| | | */ |
| | | public class CronUtils |
| | | { |
| | | /** |
| | | * è¿åä¸ä¸ªå¸å°å¼ä»£è¡¨ä¸ä¸ªç»å®çCron表达å¼çæææ§ |
| | | * |
| | | * @param cronExpression Cronè¡¨è¾¾å¼ |
| | | * @return boolean è¡¨è¾¾å¼æ¯å¦ææ |
| | | */ |
| | | public static boolean isValid(String cronExpression) |
| | | { |
| | | return CronExpression.isValidExpression(cronExpression); |
| | | } |
| | | |
| | | /** |
| | | * è¿åä¸ä¸ªå符串å¼,è¡¨ç¤ºè¯¥æ¶æ¯æ æCron表达å¼ç»åºæææ§ |
| | | * |
| | | * @param cronExpression Cronè¡¨è¾¾å¼ |
| | | * @return String æ ææ¶è¿å表达å¼é误æè¿°,妿ææè¿ånull |
| | | */ |
| | | public static String getInvalidMessage(String cronExpression) |
| | | { |
| | | try |
| | | { |
| | | new CronExpression(cronExpression); |
| | | return null; |
| | | } |
| | | catch (ParseException pe) |
| | | { |
| | | return pe.getMessage(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è¿åä¸ä¸ä¸ªæ§è¡æ¶é´æ ¹æ®ç»å®çCronè¡¨è¾¾å¼ |
| | | * |
| | | * @param cronExpression Cronè¡¨è¾¾å¼ |
| | | * @return Date 䏿¬¡Cronè¡¨è¾¾å¼æ§è¡æ¶é´ |
| | | */ |
| | | public static Date getNextExecution(String cronExpression) |
| | | { |
| | | try |
| | | { |
| | | CronExpression cron = new CronExpression(cronExpression); |
| | | return cron.getNextValidTimeAfter(new Date(System.currentTimeMillis())); |
| | | } |
| | | catch (ParseException e) |
| | | { |
| | | throw new IllegalArgumentException(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | package com.ruoyi.quartz.util;
|
| | |
|
| | | import java.text.ParseException;
|
| | | import java.util.Date;
|
| | | import org.quartz.CronExpression;
|
| | |
|
| | | /**
|
| | | * cron表达å¼å·¥å
·ç±»
|
| | | * |
| | | * @author ruoyi
|
| | | *
|
| | | */
|
| | | public class CronUtils
|
| | | {
|
| | | /**
|
| | | * è¿åä¸ä¸ªå¸å°å¼ä»£è¡¨ä¸ä¸ªç»å®çCron表达å¼çæææ§
|
| | | *
|
| | | * @param cronExpression Cron表达å¼
|
| | | * @return boolean è¡¨è¾¾å¼æ¯å¦ææ
|
| | | */
|
| | | public static boolean isValid(String cronExpression)
|
| | | {
|
| | | return CronExpression.isValidExpression(cronExpression);
|
| | | }
|
| | |
|
| | | /**
|
| | | * è¿åä¸ä¸ªå符串å¼,è¡¨ç¤ºè¯¥æ¶æ¯æ æCron表达å¼ç»åºæææ§
|
| | | *
|
| | | * @param cronExpression Cron表达å¼
|
| | | * @return String æ ææ¶è¿å表达å¼é误æè¿°,妿ææè¿ånull
|
| | | */
|
| | | public static String getInvalidMessage(String cronExpression)
|
| | | {
|
| | | try
|
| | | {
|
| | | new CronExpression(cronExpression);
|
| | | return null;
|
| | | }
|
| | | catch (ParseException pe)
|
| | | {
|
| | | return pe.getMessage();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * è¿åä¸ä¸ä¸ªæ§è¡æ¶é´æ ¹æ®ç»å®çCron表达å¼
|
| | | *
|
| | | * @param cronExpression Cron表达å¼
|
| | | * @return Date 䏿¬¡Cronè¡¨è¾¾å¼æ§è¡æ¶é´
|
| | | */
|
| | | public static Date getNextExecution(String cronExpression)
|
| | | {
|
| | | try
|
| | | {
|
| | | CronExpression cron = new CronExpression(cronExpression);
|
| | | return cron.getNextValidTimeAfter(new Date(System.currentTimeMillis()));
|
| | | }
|
| | | catch (ParseException e)
|
| | | {
|
| | | throw new IllegalArgumentException(e.getMessage());
|
| | | }
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/job/JobInvokeUtil.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.utils.job; |
| | | |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.lang.reflect.Method; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.project.monitor.domain.SysJob; |
| | | |
| | | /** |
| | | * 任塿§è¡å·¥å
· |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class JobInvokeUtil |
| | | { |
| | | /** |
| | | * æ§è¡æ¹æ³ |
| | | * |
| | | * @param sysJob ç³»ç»ä»»å¡ |
| | | */ |
| | | public static void invokeMethod(SysJob sysJob) throws Exception |
| | | { |
| | | String invokeTarget = sysJob.getInvokeTarget(); |
| | | String beanName = getBeanName(invokeTarget); |
| | | String methodName = getMethodName(invokeTarget); |
| | | List<Object[]> methodParams = getMethodParams(invokeTarget); |
| | | |
| | | if (!isValidClassName(beanName)) |
| | | { |
| | | Object bean = SpringUtils.getBean(beanName); |
| | | invokeMethod(bean, methodName, methodParams); |
| | | } |
| | | else |
| | | { |
| | | Object bean = Class.forName(beanName).newInstance(); |
| | | invokeMethod(bean, methodName, methodParams); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è°ç¨ä»»å¡æ¹æ³ |
| | | * |
| | | * @param bean ç®æ 对象 |
| | | * @param methodName æ¹æ³åç§° |
| | | * @param methodParams æ¹æ³åæ° |
| | | */ |
| | | private static void invokeMethod(Object bean, String methodName, List<Object[]> methodParams) |
| | | throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, |
| | | InvocationTargetException |
| | | { |
| | | if (StringUtils.isNotNull(methodParams) && methodParams.size() > 0) |
| | | { |
| | | Method method = bean.getClass().getDeclaredMethod(methodName, getMethodParamsType(methodParams)); |
| | | method.invoke(bean, getMethodParamsValue(methodParams)); |
| | | } |
| | | else |
| | | { |
| | | Method method = bean.getClass().getDeclaredMethod(methodName); |
| | | method.invoke(bean); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªæ¯å¦ä¸ºä¸ºclasså
å |
| | | * |
| | | * @param str åç§° |
| | | * @return trueæ¯ falseå¦ |
| | | */ |
| | | public static boolean isValidClassName(String invokeTarget) |
| | | { |
| | | return StringUtils.countMatches(invokeTarget, ".") > 1; |
| | | } |
| | | |
| | | /** |
| | | * è·åbeanåç§° |
| | | * |
| | | * @param invokeTarget ç®æ å符串 |
| | | * @return beanåç§° |
| | | */ |
| | | public static String getBeanName(String invokeTarget) |
| | | { |
| | | String beanName = StringUtils.substringBefore(invokeTarget, "("); |
| | | return StringUtils.substringBeforeLast(beanName, "."); |
| | | } |
| | | |
| | | /** |
| | | * è·åbeanæ¹æ³ |
| | | * |
| | | * @param invokeTarget ç®æ å符串 |
| | | * @return methodæ¹æ³ |
| | | */ |
| | | public static String getMethodName(String invokeTarget) |
| | | { |
| | | String methodName = StringUtils.substringBefore(invokeTarget, "("); |
| | | return StringUtils.substringAfterLast(methodName, "."); |
| | | } |
| | | |
| | | /** |
| | | * è·åmethodæ¹æ³åæ°ç¸å
³å表 |
| | | * |
| | | * @param invokeTarget ç®æ å符串 |
| | | * @return methodæ¹æ³ç¸å
³åæ°å表 |
| | | */ |
| | | public static List<Object[]> getMethodParams(String invokeTarget) |
| | | { |
| | | String methodStr = StringUtils.substringBetween(invokeTarget, "(", ")"); |
| | | if (StringUtils.isEmpty(methodStr)) |
| | | { |
| | | return null; |
| | | } |
| | | String[] methodParams = methodStr.split(","); |
| | | List<Object[]> classs = new LinkedList<>(); |
| | | for (int i = 0; i < methodParams.length; i++) |
| | | { |
| | | String str = StringUtils.trimToEmpty(methodParams[i]); |
| | | // Stringå符串类åï¼å
å«' |
| | | if (StringUtils.contains(str, "'")) |
| | | { |
| | | classs.add(new Object[] { StringUtils.replace(str, "'", ""), String.class }); |
| | | } |
| | | // booleanå¸å°ç±»åï¼çäºtrueæè
false |
| | | else if (StringUtils.equals(str, "true") || StringUtils.equalsIgnoreCase(str, "false")) |
| | | { |
| | | classs.add(new Object[] { Boolean.valueOf(str), Boolean.class }); |
| | | } |
| | | // longé¿æ´å½¢ï¼å
å«L |
| | | else if (StringUtils.containsIgnoreCase(str, "L")) |
| | | { |
| | | classs.add(new Object[] { Long.valueOf(StringUtils.replaceIgnoreCase(str, "L", "")), Long.class }); |
| | | } |
| | | // doubleæµ®ç¹ç±»åï¼å
å«D |
| | | else if (StringUtils.containsIgnoreCase(str, "D")) |
| | | { |
| | | classs.add(new Object[] { Double.valueOf(StringUtils.replaceIgnoreCase(str, "D", "")), Double.class }); |
| | | } |
| | | // å
¶ä»ç±»åå½ç±»ä¸ºæ´å½¢ |
| | | else |
| | | { |
| | | classs.add(new Object[] { Integer.valueOf(str), Integer.class }); |
| | | } |
| | | } |
| | | return classs; |
| | | } |
| | | |
| | | /** |
| | | * è·ååæ°ç±»å |
| | | * |
| | | * @param methodParams åæ°ç¸å
³å表 |
| | | * @return åæ°ç±»åå表 |
| | | */ |
| | | public static Class<?>[] getMethodParamsType(List<Object[]> methodParams) |
| | | { |
| | | Class<?>[] classs = new Class<?>[methodParams.size()]; |
| | | int index = 0; |
| | | for (Object[] os : methodParams) |
| | | { |
| | | classs[index] = (Class<?>) os[1]; |
| | | index++; |
| | | } |
| | | return classs; |
| | | } |
| | | |
| | | /** |
| | | * è·ååæ°å¼ |
| | | * |
| | | * @param methodParams åæ°ç¸å
³å表 |
| | | * @return åæ°å¼å表 |
| | | */ |
| | | public static Object[] getMethodParamsValue(List<Object[]> methodParams) |
| | | { |
| | | Object[] classs = new Object[methodParams.size()]; |
| | | int index = 0; |
| | | for (Object[] os : methodParams) |
| | | { |
| | | classs[index] = (Object) os[0]; |
| | | index++; |
| | | } |
| | | return classs; |
| | | } |
| | | } |
| | | package com.ruoyi.quartz.util;
|
| | |
|
| | | import java.lang.reflect.InvocationTargetException;
|
| | | import java.lang.reflect.Method;
|
| | | import java.util.LinkedList;
|
| | | import java.util.List;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.spring.SpringUtils;
|
| | | import com.ruoyi.quartz.domain.SysJob;
|
| | |
|
| | | /**
|
| | | * 任塿§è¡å·¥å
·
|
| | | *
|
| | | * @author ruoyi
|
| | | */
|
| | | public class JobInvokeUtil
|
| | | {
|
| | | /**
|
| | | * æ§è¡æ¹æ³
|
| | | *
|
| | | * @param sysJob ç³»ç»ä»»å¡
|
| | | */
|
| | | public static void invokeMethod(SysJob sysJob) throws Exception
|
| | | {
|
| | | String invokeTarget = sysJob.getInvokeTarget();
|
| | | String beanName = getBeanName(invokeTarget);
|
| | | String methodName = getMethodName(invokeTarget);
|
| | | List<Object[]> methodParams = getMethodParams(invokeTarget);
|
| | |
|
| | | if (!isValidClassName(beanName))
|
| | | {
|
| | | Object bean = SpringUtils.getBean(beanName);
|
| | | invokeMethod(bean, methodName, methodParams);
|
| | | }
|
| | | else
|
| | | {
|
| | | Object bean = Class.forName(beanName).newInstance();
|
| | | invokeMethod(bean, methodName, methodParams);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * è°ç¨ä»»å¡æ¹æ³
|
| | | *
|
| | | * @param bean ç®æ 对象
|
| | | * @param methodName æ¹æ³åç§°
|
| | | * @param methodParams æ¹æ³åæ°
|
| | | */
|
| | | private static void invokeMethod(Object bean, String methodName, List<Object[]> methodParams)
|
| | | throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException,
|
| | | InvocationTargetException
|
| | | {
|
| | | if (StringUtils.isNotNull(methodParams) && methodParams.size() > 0)
|
| | | {
|
| | | Method method = bean.getClass().getDeclaredMethod(methodName, getMethodParamsType(methodParams));
|
| | | method.invoke(bean, getMethodParamsValue(methodParams));
|
| | | }
|
| | | else
|
| | | {
|
| | | Method method = bean.getClass().getDeclaredMethod(methodName);
|
| | | method.invoke(bean);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ ¡éªæ¯å¦ä¸ºä¸ºclasså
å
|
| | | * |
| | | * @param str åç§°
|
| | | * @return trueæ¯ falseå¦
|
| | | */
|
| | | public static boolean isValidClassName(String invokeTarget)
|
| | | {
|
| | | return StringUtils.countMatches(invokeTarget, ".") > 1;
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·åbeanåç§°
|
| | | * |
| | | * @param invokeTarget ç®æ å符串
|
| | | * @return beanåç§°
|
| | | */
|
| | | public static String getBeanName(String invokeTarget)
|
| | | {
|
| | | String beanName = StringUtils.substringBefore(invokeTarget, "(");
|
| | | return StringUtils.substringBeforeLast(beanName, ".");
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·åbeanæ¹æ³
|
| | | * |
| | | * @param invokeTarget ç®æ å符串
|
| | | * @return methodæ¹æ³
|
| | | */
|
| | | public static String getMethodName(String invokeTarget)
|
| | | {
|
| | | String methodName = StringUtils.substringBefore(invokeTarget, "(");
|
| | | return StringUtils.substringAfterLast(methodName, ".");
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·åmethodæ¹æ³åæ°ç¸å
³å表
|
| | | * |
| | | * @param invokeTarget ç®æ å符串
|
| | | * @return methodæ¹æ³ç¸å
³åæ°å表
|
| | | */
|
| | | public static List<Object[]> getMethodParams(String invokeTarget)
|
| | | {
|
| | | String methodStr = StringUtils.substringBetween(invokeTarget, "(", ")");
|
| | | if (StringUtils.isEmpty(methodStr))
|
| | | {
|
| | | return null;
|
| | | }
|
| | | String[] methodParams = methodStr.split(",");
|
| | | List<Object[]> classs = new LinkedList<>();
|
| | | for (int i = 0; i < methodParams.length; i++)
|
| | | {
|
| | | String str = StringUtils.trimToEmpty(methodParams[i]);
|
| | | // Stringå符串类åï¼å
å«'
|
| | | if (StringUtils.contains(str, "'"))
|
| | | {
|
| | | classs.add(new Object[] { StringUtils.replace(str, "'", ""), String.class });
|
| | | }
|
| | | // booleanå¸å°ç±»åï¼çäºtrueæè
false
|
| | | else if (StringUtils.equals(str, "true") || StringUtils.equalsIgnoreCase(str, "false"))
|
| | | {
|
| | | classs.add(new Object[] { Boolean.valueOf(str), Boolean.class });
|
| | | }
|
| | | // longé¿æ´å½¢ï¼å
å«L
|
| | | else if (StringUtils.containsIgnoreCase(str, "L"))
|
| | | {
|
| | | classs.add(new Object[] { Long.valueOf(StringUtils.replaceIgnoreCase(str, "L", "")), Long.class });
|
| | | }
|
| | | // doubleæµ®ç¹ç±»åï¼å
å«D
|
| | | else if (StringUtils.containsIgnoreCase(str, "D"))
|
| | | {
|
| | | classs.add(new Object[] { Double.valueOf(StringUtils.replaceIgnoreCase(str, "D", "")), Double.class });
|
| | | }
|
| | | // å
¶ä»ç±»åå½ç±»ä¸ºæ´å½¢
|
| | | else
|
| | | {
|
| | | classs.add(new Object[] { Integer.valueOf(str), Integer.class });
|
| | | }
|
| | | }
|
| | | return classs;
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·ååæ°ç±»å
|
| | | * |
| | | * @param methodParams åæ°ç¸å
³å表
|
| | | * @return åæ°ç±»åå表
|
| | | */
|
| | | public static Class<?>[] getMethodParamsType(List<Object[]> methodParams)
|
| | | {
|
| | | Class<?>[] classs = new Class<?>[methodParams.size()];
|
| | | int index = 0;
|
| | | for (Object[] os : methodParams)
|
| | | {
|
| | | classs[index] = (Class<?>) os[1];
|
| | | index++;
|
| | | }
|
| | | return classs;
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·ååæ°å¼
|
| | | * |
| | | * @param methodParams åæ°ç¸å
³å表
|
| | | * @return åæ°å¼å表
|
| | | */
|
| | | public static Object[] getMethodParamsValue(List<Object[]> methodParams)
|
| | | {
|
| | | Object[] classs = new Object[methodParams.size()];
|
| | | int index = 0;
|
| | | for (Object[] os : methodParams)
|
| | | {
|
| | | classs[index] = (Object) os[0];
|
| | | index++;
|
| | | }
|
| | | return classs;
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/job/QuartzDisallowConcurrentExecution.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.utils.job; |
| | | |
| | | import org.quartz.DisallowConcurrentExecution; |
| | | import org.quartz.JobExecutionContext; |
| | | import com.ruoyi.project.monitor.domain.SysJob; |
| | | |
| | | /** |
| | | * 宿¶ä»»å¡å¤çï¼ç¦æ¢å¹¶åæ§è¡ï¼ |
| | | * |
| | | * @author ruoyi |
| | | * |
| | | */ |
| | | @DisallowConcurrentExecution |
| | | public class QuartzDisallowConcurrentExecution extends AbstractQuartzJob |
| | | { |
| | | @Override |
| | | protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception |
| | | { |
| | | JobInvokeUtil.invokeMethod(sysJob); |
| | | } |
| | | } |
| | | package com.ruoyi.quartz.util;
|
| | |
|
| | | import org.quartz.DisallowConcurrentExecution;
|
| | | import org.quartz.JobExecutionContext;
|
| | | import com.ruoyi.quartz.domain.SysJob;
|
| | |
|
| | | /**
|
| | | * 宿¶ä»»å¡å¤çï¼ç¦æ¢å¹¶åæ§è¡ï¼
|
| | | * |
| | | * @author ruoyi
|
| | | *
|
| | | */
|
| | | @DisallowConcurrentExecution
|
| | | public class QuartzDisallowConcurrentExecution extends AbstractQuartzJob
|
| | | {
|
| | | @Override
|
| | | protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception
|
| | | {
|
| | | JobInvokeUtil.invokeMethod(sysJob);
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/job/QuartzJobExecution.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.utils.job; |
| | | |
| | | import org.quartz.JobExecutionContext; |
| | | import com.ruoyi.project.monitor.domain.SysJob; |
| | | |
| | | /** |
| | | * 宿¶ä»»å¡å¤çï¼å
è®¸å¹¶åæ§è¡ï¼ |
| | | * |
| | | * @author ruoyi |
| | | * |
| | | */ |
| | | public class QuartzJobExecution extends AbstractQuartzJob |
| | | { |
| | | @Override |
| | | protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception |
| | | { |
| | | JobInvokeUtil.invokeMethod(sysJob); |
| | | } |
| | | } |
| | | package com.ruoyi.quartz.util;
|
| | |
|
| | | import org.quartz.JobExecutionContext;
|
| | | import com.ruoyi.quartz.domain.SysJob;
|
| | |
|
| | | /**
|
| | | * 宿¶ä»»å¡å¤çï¼å
è®¸å¹¶åæ§è¡ï¼
|
| | | * |
| | | * @author ruoyi
|
| | | *
|
| | | */
|
| | | public class QuartzJobExecution extends AbstractQuartzJob
|
| | | {
|
| | | @Override
|
| | | protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception
|
| | | {
|
| | | JobInvokeUtil.invokeMethod(sysJob);
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/common/utils/job/ScheduleUtils.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.utils.job; |
| | | |
| | | import org.quartz.CronScheduleBuilder; |
| | | import org.quartz.CronTrigger; |
| | | import org.quartz.Job; |
| | | import org.quartz.JobBuilder; |
| | | import org.quartz.JobDetail; |
| | | import org.quartz.JobKey; |
| | | import org.quartz.Scheduler; |
| | | import org.quartz.SchedulerException; |
| | | import org.quartz.TriggerBuilder; |
| | | import org.quartz.TriggerKey; |
| | | import com.ruoyi.common.constant.ScheduleConstants; |
| | | import com.ruoyi.common.exception.job.TaskException; |
| | | import com.ruoyi.common.exception.job.TaskException.Code; |
| | | import com.ruoyi.project.monitor.domain.SysJob; |
| | | |
| | | /** |
| | | * 宿¶ä»»å¡å·¥å
·ç±» |
| | | * |
| | | * @author ruoyi |
| | | * |
| | | */ |
| | | public class ScheduleUtils |
| | | { |
| | | /** |
| | | * å¾å°quartzä»»å¡ç±» |
| | | * |
| | | * @param sysJob æ§è¡è®¡å |
| | | * @return å
·ä½æ§è¡ä»»å¡ç±» |
| | | */ |
| | | private static Class<? extends Job> getQuartzJobClass(SysJob sysJob) |
| | | { |
| | | boolean isConcurrent = "0".equals(sysJob.getConcurrent()); |
| | | return isConcurrent ? QuartzJobExecution.class : QuartzDisallowConcurrentExecution.class; |
| | | } |
| | | |
| | | /** |
| | | * æå»ºä»»å¡è§¦å对象 |
| | | */ |
| | | public static TriggerKey getTriggerKey(Long jobId, String jobGroup) |
| | | { |
| | | return TriggerKey.triggerKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup); |
| | | } |
| | | |
| | | /** |
| | | * æå»ºä»»å¡é®å¯¹è±¡ |
| | | */ |
| | | public static JobKey getJobKey(Long jobId, String jobGroup) |
| | | { |
| | | return JobKey.jobKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup); |
| | | } |
| | | |
| | | /** |
| | | * åå»ºå®æ¶ä»»å¡ |
| | | */ |
| | | public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException |
| | | { |
| | | Class<? extends Job> jobClass = getQuartzJobClass(job); |
| | | // æå»ºjobä¿¡æ¯ |
| | | Long jobId = job.getJobId(); |
| | | String jobGroup = job.getJobGroup(); |
| | | JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build(); |
| | | |
| | | // 表达å¼è°åº¦æå»ºå¨ |
| | | CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression()); |
| | | cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder); |
| | | |
| | | // ææ°çcronExpressionè¡¨è¾¾å¼æå»ºä¸ä¸ªæ°çtrigger |
| | | CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(jobId, jobGroup)) |
| | | .withSchedule(cronScheduleBuilder).build(); |
| | | |
| | | // æ¾å
¥åæ°ï¼è¿è¡æ¶çæ¹æ³å¯ä»¥è·å |
| | | jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job); |
| | | |
| | | // 夿æ¯å¦åå¨ |
| | | if (scheduler.checkExists(getJobKey(jobId, jobGroup))) |
| | | { |
| | | // 鲿¢å建æ¶å卿°æ®é®é¢ å
ç§»é¤ï¼ç¶å卿§è¡å建æä½ |
| | | scheduler.deleteJob(getJobKey(jobId, jobGroup)); |
| | | } |
| | | |
| | | scheduler.scheduleJob(jobDetail, trigger); |
| | | |
| | | // æåä»»å¡ |
| | | if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue())) |
| | | { |
| | | scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è®¾ç½®å®æ¶ä»»å¡çç¥ |
| | | */ |
| | | public static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb) |
| | | throws TaskException |
| | | { |
| | | switch (job.getMisfirePolicy()) |
| | | { |
| | | case ScheduleConstants.MISFIRE_DEFAULT: |
| | | return cb; |
| | | case ScheduleConstants.MISFIRE_IGNORE_MISFIRES: |
| | | return cb.withMisfireHandlingInstructionIgnoreMisfires(); |
| | | case ScheduleConstants.MISFIRE_FIRE_AND_PROCEED: |
| | | return cb.withMisfireHandlingInstructionFireAndProceed(); |
| | | case ScheduleConstants.MISFIRE_DO_NOTHING: |
| | | return cb.withMisfireHandlingInstructionDoNothing(); |
| | | default: |
| | | throw new TaskException("The task misfire policy '" + job.getMisfirePolicy() |
| | | + "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR); |
| | | } |
| | | } |
| | | } |
| | | package com.ruoyi.quartz.util;
|
| | |
|
| | | import org.quartz.CronScheduleBuilder;
|
| | | import org.quartz.CronTrigger;
|
| | | import org.quartz.Job;
|
| | | import org.quartz.JobBuilder;
|
| | | import org.quartz.JobDetail;
|
| | | import org.quartz.JobKey;
|
| | | import org.quartz.Scheduler;
|
| | | import org.quartz.SchedulerException;
|
| | | import org.quartz.TriggerBuilder;
|
| | | import org.quartz.TriggerKey;
|
| | | import com.ruoyi.common.constant.ScheduleConstants;
|
| | | import com.ruoyi.common.exception.job.TaskException;
|
| | | import com.ruoyi.common.exception.job.TaskException.Code;
|
| | | import com.ruoyi.quartz.domain.SysJob;
|
| | |
|
| | | /**
|
| | | * 宿¶ä»»å¡å·¥å
·ç±»
|
| | | * |
| | | * @author ruoyi
|
| | | *
|
| | | */
|
| | | public class ScheduleUtils
|
| | | {
|
| | | /**
|
| | | * å¾å°quartzä»»å¡ç±»
|
| | | *
|
| | | * @param sysJob æ§è¡è®¡å
|
| | | * @return å
·ä½æ§è¡ä»»å¡ç±»
|
| | | */
|
| | | private static Class<? extends Job> getQuartzJobClass(SysJob sysJob)
|
| | | {
|
| | | boolean isConcurrent = "0".equals(sysJob.getConcurrent());
|
| | | return isConcurrent ? QuartzJobExecution.class : QuartzDisallowConcurrentExecution.class;
|
| | | }
|
| | |
|
| | | /**
|
| | | * æå»ºä»»å¡è§¦å对象
|
| | | */
|
| | | public static TriggerKey getTriggerKey(Long jobId, String jobGroup)
|
| | | {
|
| | | return TriggerKey.triggerKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup);
|
| | | }
|
| | |
|
| | | /**
|
| | | * æå»ºä»»å¡é®å¯¹è±¡
|
| | | */
|
| | | public static JobKey getJobKey(Long jobId, String jobGroup)
|
| | | {
|
| | | return JobKey.jobKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup);
|
| | | }
|
| | |
|
| | | /**
|
| | | * åå»ºå®æ¶ä»»å¡
|
| | | */
|
| | | public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException
|
| | | {
|
| | | Class<? extends Job> jobClass = getQuartzJobClass(job);
|
| | | // æå»ºjobä¿¡æ¯
|
| | | Long jobId = job.getJobId();
|
| | | String jobGroup = job.getJobGroup();
|
| | | JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build();
|
| | |
|
| | | // 表达å¼è°åº¦æå»ºå¨
|
| | | CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
|
| | | cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder);
|
| | |
|
| | | // ææ°çcronExpressionè¡¨è¾¾å¼æå»ºä¸ä¸ªæ°çtrigger
|
| | | CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(jobId, jobGroup))
|
| | | .withSchedule(cronScheduleBuilder).build();
|
| | |
|
| | | // æ¾å
¥åæ°ï¼è¿è¡æ¶çæ¹æ³å¯ä»¥è·å
|
| | | jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job);
|
| | |
|
| | | // 夿æ¯å¦åå¨
|
| | | if (scheduler.checkExists(getJobKey(jobId, jobGroup)))
|
| | | {
|
| | | // 鲿¢å建æ¶å卿°æ®é®é¢ å
ç§»é¤ï¼ç¶å卿§è¡å建æä½
|
| | | scheduler.deleteJob(getJobKey(jobId, jobGroup));
|
| | | }
|
| | |
|
| | | scheduler.scheduleJob(jobDetail, trigger);
|
| | |
|
| | | // æåä»»å¡
|
| | | if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue()))
|
| | | {
|
| | | scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * è®¾ç½®å®æ¶ä»»å¡çç¥
|
| | | */
|
| | | public static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb)
|
| | | throws TaskException
|
| | | {
|
| | | switch (job.getMisfirePolicy())
|
| | | {
|
| | | case ScheduleConstants.MISFIRE_DEFAULT:
|
| | | return cb;
|
| | | case ScheduleConstants.MISFIRE_IGNORE_MISFIRES:
|
| | | return cb.withMisfireHandlingInstructionIgnoreMisfires();
|
| | | case ScheduleConstants.MISFIRE_FIRE_AND_PROCEED:
|
| | | return cb.withMisfireHandlingInstructionFireAndProceed();
|
| | | case ScheduleConstants.MISFIRE_DO_NOTHING:
|
| | | return cb.withMisfireHandlingInstructionDoNothing();
|
| | | default:
|
| | | throw new TaskException("The task misfire policy '" + job.getMisfirePolicy()
|
| | | + "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR);
|
| | | }
|
| | | }
|
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/system/SysJobLogMapper.xml ÐÞ¸Ä |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.project.monitor.mapper.SysJobLogMapper"> |
| | | |
| | | <resultMap type="SysJobLog" id="SysJobLogResult"> |
| | | <id property="jobLogId" column="job_log_id" /> |
| | | <result property="jobName" column="job_name" /> |
| | | <result property="jobGroup" column="job_group" /> |
| | | <result property="invokeTarget" column="invoke_target" /> |
| | | <result property="jobMessage" column="job_message" /> |
| | | <result property="status" column="status" /> |
| | | <result property="exceptionInfo" column="exception_info" /> |
| | | <result property="createTime" column="create_time" /> |
| | | </resultMap> |
| | | |
| | | <sql id="selectJobLogVo"> |
| | | select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time |
| | | from sys_job_log |
| | | </sql> |
| | | |
| | | <select id="selectJobLogList" parameterType="SysJobLog" resultMap="SysJobLogResult"> |
| | | <include refid="selectJobLogVo"/> |
| | | <where> |
| | | <if test="jobName != null and jobName != ''"> |
| | | AND job_name like concat('%', #{jobName}, '%') |
| | | </if> |
| | | <if test="jobGroup != null and jobGroup != ''"> |
| | | AND job_group = #{jobGroup} |
| | | </if> |
| | | <if test="status != null and status != ''"> |
| | | AND status = #{status} |
| | | </if> |
| | | <if test="invokeTarget != null and invokeTarget != ''"> |
| | | AND invoke_target like concat('%', #{invokeTarget}, '%') |
| | | </if> |
| | | <if test="beginTime != null and beginTime != ''"><!-- å¼å§æ¶é´æ£ç´¢ --> |
| | | and date_format(create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d') |
| | | </if> |
| | | <if test="endTime != null and endTime != ''"><!-- ç»ææ¶é´æ£ç´¢ --> |
| | | and date_format(create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d') |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="selectJobLogAll" resultMap="SysJobLogResult"> |
| | | <include refid="selectJobLogVo"/> |
| | | </select> |
| | | |
| | | <select id="selectJobLogById" parameterType="Long" resultMap="SysJobLogResult"> |
| | | <include refid="selectJobLogVo"/> |
| | | where job_log_id = #{jobLogId} |
| | | </select> |
| | | |
| | | <delete id="deleteJobLogById" parameterType="Long"> |
| | | delete from sys_job_log where job_log_id = #{jobLogId} |
| | | </delete> |
| | | |
| | | <delete id="deleteJobLogByIds" parameterType="Long"> |
| | | delete from sys_job_log where job_log_id in |
| | | <foreach collection="array" item="jobLogId" open="(" separator="," close=")"> |
| | | #{jobLogId} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <update id="cleanJobLog"> |
| | | truncate table sys_job_log |
| | | </update> |
| | | |
| | | <insert id="insertJobLog" parameterType="SysJobLog"> |
| | | insert into sys_job_log( |
| | | <if test="jobLogId != null and jobLogId != 0">job_log_id,</if> |
| | | <if test="jobName != null and jobName != ''">job_name,</if> |
| | | <if test="jobGroup != null and jobGroup != ''">job_group,</if> |
| | | <if test="invokeTarget != null and invokeTarget != ''">invoke_target,</if> |
| | | <if test="jobMessage != null and jobMessage != ''">job_message,</if> |
| | | <if test="status != null and status != ''">status,</if> |
| | | <if test="exceptionInfo != null and exceptionInfo != ''">exception_info,</if> |
| | | create_time |
| | | )values( |
| | | <if test="jobLogId != null and jobLogId != 0">#{jobLogId},</if> |
| | | <if test="jobName != null and jobName != ''">#{jobName},</if> |
| | | <if test="jobGroup != null and jobGroup != ''">#{jobGroup},</if> |
| | | <if test="invokeTarget != null and invokeTarget != ''">#{invokeTarget},</if> |
| | | <if test="jobMessage != null and jobMessage != ''">#{jobMessage},</if> |
| | | <if test="status != null and status != ''">#{status},</if> |
| | | <if test="exceptionInfo != null and exceptionInfo != ''">#{exceptionInfo},</if> |
| | | sysdate() |
| | | ) |
| | | </insert> |
| | | |
| | | <?xml version="1.0" encoding="UTF-8" ?>
|
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.quartz.mapper.SysJobLogMapper">
|
| | |
|
| | | <resultMap type="SysJobLog" id="SysJobLogResult">
|
| | | <id property="jobLogId" column="job_log_id" />
|
| | | <result property="jobName" column="job_name" />
|
| | | <result property="jobGroup" column="job_group" />
|
| | | <result property="invokeTarget" column="invoke_target" />
|
| | | <result property="jobMessage" column="job_message" />
|
| | | <result property="status" column="status" />
|
| | | <result property="exceptionInfo" column="exception_info" />
|
| | | <result property="createTime" column="create_time" />
|
| | | </resultMap>
|
| | | |
| | | <sql id="selectJobLogVo">
|
| | | select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time |
| | | from sys_job_log
|
| | | </sql>
|
| | | |
| | | <select id="selectJobLogList" parameterType="SysJobLog" resultMap="SysJobLogResult">
|
| | | <include refid="selectJobLogVo"/>
|
| | | <where>
|
| | | <if test="jobName != null and jobName != ''">
|
| | | AND job_name like concat('%', #{jobName}, '%')
|
| | | </if>
|
| | | <if test="jobGroup != null and jobGroup != ''">
|
| | | AND job_group = #{jobGroup}
|
| | | </if>
|
| | | <if test="status != null and status != ''">
|
| | | AND status = #{status}
|
| | | </if>
|
| | | <if test="invokeTarget != null and invokeTarget != ''">
|
| | | AND invoke_target like concat('%', #{invokeTarget}, '%')
|
| | | </if>
|
| | | <if test="beginTime != null and beginTime != ''"><!-- å¼å§æ¶é´æ£ç´¢ -->
|
| | | and date_format(create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
| | | </if>
|
| | | <if test="endTime != null and endTime != ''"><!-- ç»ææ¶é´æ£ç´¢ -->
|
| | | and date_format(create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
| | | </if>
|
| | | </where>
|
| | | </select>
|
| | | |
| | | <select id="selectJobLogAll" resultMap="SysJobLogResult">
|
| | | <include refid="selectJobLogVo"/>
|
| | | </select>
|
| | | |
| | | <select id="selectJobLogById" parameterType="Long" resultMap="SysJobLogResult">
|
| | | <include refid="selectJobLogVo"/>
|
| | | where job_log_id = #{jobLogId}
|
| | | </select>
|
| | | |
| | | <delete id="deleteJobLogById" parameterType="Long">
|
| | | delete from sys_job_log where job_log_id = #{jobLogId}
|
| | | </delete>
|
| | | |
| | | <delete id="deleteJobLogByIds" parameterType="Long">
|
| | | delete from sys_job_log where job_log_id in
|
| | | <foreach collection="array" item="jobLogId" open="(" separator="," close=")">
|
| | | #{jobLogId}
|
| | | </foreach> |
| | | </delete>
|
| | | |
| | | <update id="cleanJobLog">
|
| | | truncate table sys_job_log
|
| | | </update>
|
| | | |
| | | <insert id="insertJobLog" parameterType="SysJobLog">
|
| | | insert into sys_job_log(
|
| | | <if test="jobLogId != null and jobLogId != 0">job_log_id,</if>
|
| | | <if test="jobName != null and jobName != ''">job_name,</if>
|
| | | <if test="jobGroup != null and jobGroup != ''">job_group,</if>
|
| | | <if test="invokeTarget != null and invokeTarget != ''">invoke_target,</if>
|
| | | <if test="jobMessage != null and jobMessage != ''">job_message,</if>
|
| | | <if test="status != null and status != ''">status,</if>
|
| | | <if test="exceptionInfo != null and exceptionInfo != ''">exception_info,</if>
|
| | | create_time
|
| | | )values(
|
| | | <if test="jobLogId != null and jobLogId != 0">#{jobLogId},</if>
|
| | | <if test="jobName != null and jobName != ''">#{jobName},</if>
|
| | | <if test="jobGroup != null and jobGroup != ''">#{jobGroup},</if>
|
| | | <if test="invokeTarget != null and invokeTarget != ''">#{invokeTarget},</if>
|
| | | <if test="jobMessage != null and jobMessage != ''">#{jobMessage},</if>
|
| | | <if test="status != null and status != ''">#{status},</if>
|
| | | <if test="exceptionInfo != null and exceptionInfo != ''">#{exceptionInfo},</if>
|
| | | sysdate()
|
| | | )
|
| | | </insert>
|
| | |
|
| | | </mapper> |
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/system/SysJobMapper.xml ÐÞ¸Ä |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.project.monitor.mapper.SysJobMapper"> |
| | | |
| | | <resultMap type="SysJob" id="SysJobResult"> |
| | | <id property="jobId" column="job_id" /> |
| | | <result property="jobName" column="job_name" /> |
| | | <result property="jobGroup" column="job_group" /> |
| | | <result property="invokeTarget" column="invoke_target" /> |
| | | <result property="cronExpression" column="cron_expression" /> |
| | | <result property="misfirePolicy" column="misfire_policy" /> |
| | | <result property="concurrent" column="concurrent" /> |
| | | <result property="status" column="status" /> |
| | | <result property="createBy" column="create_by" /> |
| | | <result property="createTime" column="create_time" /> |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | <result property="remark" column="remark" /> |
| | | </resultMap> |
| | | |
| | | <sql id="selectJobVo"> |
| | | select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark |
| | | from sys_job |
| | | </sql> |
| | | |
| | | <select id="selectJobList" parameterType="SysJob" resultMap="SysJobResult"> |
| | | <include refid="selectJobVo"/> |
| | | <where> |
| | | <if test="jobName != null and jobName != ''"> |
| | | AND job_name like concat('%', #{jobName}, '%') |
| | | </if> |
| | | <if test="jobGroup != null and jobGroup != ''"> |
| | | AND job_group = #{jobGroup} |
| | | </if> |
| | | <if test="status != null and status != ''"> |
| | | AND status = #{status} |
| | | </if> |
| | | <if test="invokeTarget != null and invokeTarget != ''"> |
| | | AND invoke_target like concat('%', #{invokeTarget}, '%') |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="selectJobAll" resultMap="SysJobResult"> |
| | | <include refid="selectJobVo"/> |
| | | </select> |
| | | |
| | | <select id="selectJobById" parameterType="Long" resultMap="SysJobResult"> |
| | | <include refid="selectJobVo"/> |
| | | where job_id = #{jobId} |
| | | </select> |
| | | |
| | | <delete id="deleteJobById" parameterType="Long"> |
| | | delete from sys_job where job_id = #{jobId} |
| | | </delete> |
| | | |
| | | <delete id="deleteJobByIds" parameterType="Long"> |
| | | delete from sys_job where job_id in |
| | | <foreach collection="array" item="jobId" open="(" separator="," close=")"> |
| | | #{jobId} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <update id="updateJob" parameterType="SysJob"> |
| | | update sys_job |
| | | <set> |
| | | <if test="jobName != null and jobName != ''">job_name = #{jobName},</if> |
| | | <if test="jobGroup != null and jobGroup != ''">job_group = #{jobGroup},</if> |
| | | <if test="invokeTarget != null and invokeTarget != ''">invoke_target = #{invokeTarget},</if> |
| | | <if test="cronExpression != null and cronExpression != ''">cron_expression = #{cronExpression},</if> |
| | | <if test="misfirePolicy != null and misfirePolicy != ''">misfire_policy = #{misfirePolicy},</if> |
| | | <if test="concurrent != null and concurrent != ''">concurrent = #{concurrent},</if> |
| | | <if test="status !=null">status = #{status},</if> |
| | | <if test="remark != null and remark != ''">remark = #{remark},</if> |
| | | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
| | | update_time = sysdate() |
| | | </set> |
| | | where job_id = #{jobId} |
| | | </update> |
| | | |
| | | <insert id="insertJob" parameterType="SysJob" useGeneratedKeys="true" keyProperty="jobId"> |
| | | insert into sys_job( |
| | | <if test="jobId != null and jobId != 0">job_id,</if> |
| | | <if test="jobName != null and jobName != ''">job_name,</if> |
| | | <if test="jobGroup != null and jobGroup != ''">job_group,</if> |
| | | <if test="invokeTarget != null and invokeTarget != ''">invoke_target,</if> |
| | | <if test="cronExpression != null and cronExpression != ''">cron_expression,</if> |
| | | <if test="misfirePolicy != null and misfirePolicy != ''">misfire_policy,</if> |
| | | <if test="concurrent != null and concurrent != ''">concurrent,</if> |
| | | <if test="status != null and status != ''">status,</if> |
| | | <if test="remark != null and remark != ''">remark,</if> |
| | | <if test="createBy != null and createBy != ''">create_by,</if> |
| | | create_time |
| | | )values( |
| | | <if test="jobId != null and jobId != 0">#{jobId},</if> |
| | | <if test="jobName != null and jobName != ''">#{jobName},</if> |
| | | <if test="jobGroup != null and jobGroup != ''">#{jobGroup},</if> |
| | | <if test="invokeTarget != null and invokeTarget != ''">#{invokeTarget},</if> |
| | | <if test="cronExpression != null and cronExpression != ''">#{cronExpression},</if> |
| | | <if test="misfirePolicy != null and misfirePolicy != ''">#{misfirePolicy},</if> |
| | | <if test="concurrent != null and concurrent != ''">#{concurrent},</if> |
| | | <if test="status != null and status != ''">#{status},</if> |
| | | <if test="remark != null and remark != ''">#{remark},</if> |
| | | <if test="createBy != null and createBy != ''">#{createBy},</if> |
| | | sysdate() |
| | | ) |
| | | </insert> |
| | | |
| | | <?xml version="1.0" encoding="UTF-8" ?>
|
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.quartz.mapper.SysJobMapper">
|
| | |
|
| | | <resultMap type="SysJob" id="SysJobResult">
|
| | | <id property="jobId" column="job_id" />
|
| | | <result property="jobName" column="job_name" />
|
| | | <result property="jobGroup" column="job_group" />
|
| | | <result property="invokeTarget" column="invoke_target" />
|
| | | <result property="cronExpression" column="cron_expression" />
|
| | | <result property="misfirePolicy" column="misfire_policy" />
|
| | | <result property="concurrent" column="concurrent" />
|
| | | <result property="status" column="status" />
|
| | | <result property="createBy" column="create_by" />
|
| | | <result property="createTime" column="create_time" />
|
| | | <result property="updateBy" column="update_by" />
|
| | | <result property="updateTime" column="update_time" />
|
| | | <result property="remark" column="remark" />
|
| | | </resultMap>
|
| | | |
| | | <sql id="selectJobVo">
|
| | | select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark |
| | | from sys_job
|
| | | </sql>
|
| | | |
| | | <select id="selectJobList" parameterType="SysJob" resultMap="SysJobResult">
|
| | | <include refid="selectJobVo"/>
|
| | | <where>
|
| | | <if test="jobName != null and jobName != ''">
|
| | | AND job_name like concat('%', #{jobName}, '%')
|
| | | </if>
|
| | | <if test="jobGroup != null and jobGroup != ''">
|
| | | AND job_group = #{jobGroup}
|
| | | </if>
|
| | | <if test="status != null and status != ''">
|
| | | AND status = #{status}
|
| | | </if>
|
| | | <if test="invokeTarget != null and invokeTarget != ''">
|
| | | AND invoke_target like concat('%', #{invokeTarget}, '%')
|
| | | </if>
|
| | | </where>
|
| | | </select>
|
| | | |
| | | <select id="selectJobAll" resultMap="SysJobResult">
|
| | | <include refid="selectJobVo"/>
|
| | | </select>
|
| | | |
| | | <select id="selectJobById" parameterType="Long" resultMap="SysJobResult">
|
| | | <include refid="selectJobVo"/>
|
| | | where job_id = #{jobId}
|
| | | </select>
|
| | | |
| | | <delete id="deleteJobById" parameterType="Long">
|
| | | delete from sys_job where job_id = #{jobId}
|
| | | </delete>
|
| | | |
| | | <delete id="deleteJobByIds" parameterType="Long">
|
| | | delete from sys_job where job_id in
|
| | | <foreach collection="array" item="jobId" open="(" separator="," close=")">
|
| | | #{jobId}
|
| | | </foreach> |
| | | </delete>
|
| | | |
| | | <update id="updateJob" parameterType="SysJob">
|
| | | update sys_job
|
| | | <set>
|
| | | <if test="jobName != null and jobName != ''">job_name = #{jobName},</if>
|
| | | <if test="jobGroup != null and jobGroup != ''">job_group = #{jobGroup},</if>
|
| | | <if test="invokeTarget != null and invokeTarget != ''">invoke_target = #{invokeTarget},</if>
|
| | | <if test="cronExpression != null and cronExpression != ''">cron_expression = #{cronExpression},</if>
|
| | | <if test="misfirePolicy != null and misfirePolicy != ''">misfire_policy = #{misfirePolicy},</if>
|
| | | <if test="concurrent != null and concurrent != ''">concurrent = #{concurrent},</if>
|
| | | <if test="status !=null">status = #{status},</if>
|
| | | <if test="remark != null and remark != ''">remark = #{remark},</if>
|
| | | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
| | | update_time = sysdate()
|
| | | </set>
|
| | | where job_id = #{jobId}
|
| | | </update>
|
| | | |
| | | <insert id="insertJob" parameterType="SysJob" useGeneratedKeys="true" keyProperty="jobId">
|
| | | insert into sys_job(
|
| | | <if test="jobId != null and jobId != 0">job_id,</if>
|
| | | <if test="jobName != null and jobName != ''">job_name,</if>
|
| | | <if test="jobGroup != null and jobGroup != ''">job_group,</if>
|
| | | <if test="invokeTarget != null and invokeTarget != ''">invoke_target,</if>
|
| | | <if test="cronExpression != null and cronExpression != ''">cron_expression,</if>
|
| | | <if test="misfirePolicy != null and misfirePolicy != ''">misfire_policy,</if>
|
| | | <if test="concurrent != null and concurrent != ''">concurrent,</if>
|
| | | <if test="status != null and status != ''">status,</if>
|
| | | <if test="remark != null and remark != ''">remark,</if>
|
| | | <if test="createBy != null and createBy != ''">create_by,</if>
|
| | | create_time
|
| | | )values(
|
| | | <if test="jobId != null and jobId != 0">#{jobId},</if>
|
| | | <if test="jobName != null and jobName != ''">#{jobName},</if>
|
| | | <if test="jobGroup != null and jobGroup != ''">#{jobGroup},</if>
|
| | | <if test="invokeTarget != null and invokeTarget != ''">#{invokeTarget},</if>
|
| | | <if test="cronExpression != null and cronExpression != ''">#{cronExpression},</if>
|
| | | <if test="misfirePolicy != null and misfirePolicy != ''">#{misfirePolicy},</if>
|
| | | <if test="concurrent != null and concurrent != ''">#{concurrent},</if>
|
| | | <if test="status != null and status != ''">#{status},</if>
|
| | | <if test="remark != null and remark != ''">#{remark},</if>
|
| | | <if test="createBy != null and createBy != ''">#{createBy},</if>
|
| | | sysdate()
|
| | | )
|
| | | </insert>
|
| | |
|
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?>
|
| | | <project xmlns="http://maven.apache.org/POM/4.0.0"
|
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
| | | <parent>
|
| | | <artifactId>ruoyi</artifactId>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <version>3.0.0</version>
|
| | | </parent>
|
| | | <modelVersion>4.0.0</modelVersion>
|
| | |
|
| | | <artifactId>ruoyi-system</artifactId>
|
| | |
|
| | | <description>
|
| | | systemç³»ç»æ¨¡å
|
| | | </description>
|
| | |
|
| | | <dependencies>
|
| | |
|
| | | <!-- éç¨å·¥å
·-->
|
| | | <dependency>
|
| | | <groupId>com.ruoyi</groupId>
|
| | | <artifactId>ruoyi-common</artifactId>
|
| | | </dependency>
|
| | |
|
| | | </dependencies>
|
| | |
|
| | | </project> |
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/domain/SysConfig.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.domain;
|
| | | package com.ruoyi.system.domain;
|
| | |
|
| | | import javax.validation.constraints.NotBlank;
|
| | | import javax.validation.constraints.Size;
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | | import com.ruoyi.common.annotation.Excel;
|
| | | import com.ruoyi.common.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | |
|
| | | /**
|
| | | * åæ°é
置表 sys_config
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysLogininfor.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.domain;
|
| | | package com.ruoyi.system.domain;
|
| | |
|
| | | import java.util.Date;
|
| | | import com.fasterxml.jackson.annotation.JsonFormat;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | | import com.ruoyi.common.annotation.Excel;
|
| | | import com.ruoyi.common.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | |
|
| | | /**
|
| | | * ç³»ç»è®¿é®è®°å½è¡¨ sys_logininfor
|
| | |
| | | {
|
| | | this.loginTime = loginTime;
|
| | | }
|
| | | } |
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/domain/SysNotice.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.domain;
|
| | | package com.ruoyi.system.domain;
|
| | |
|
| | | import javax.validation.constraints.NotBlank;
|
| | | import javax.validation.constraints.Size;
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | |
|
| | | /**
|
| | | * éç¥å
¬å表 sys_notice
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysOperLog.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.domain;
|
| | | package com.ruoyi.system.domain;
|
| | |
|
| | | import java.util.Date;
|
| | | import com.fasterxml.jackson.annotation.JsonFormat;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | | import com.ruoyi.common.annotation.Excel;
|
| | | import com.ruoyi.common.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | |
|
| | | /**
|
| | | * æä½æ¥å¿è®°å½è¡¨ oper_log
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/domain/SysPost.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.domain;
|
| | | package com.ruoyi.system.domain;
|
| | |
|
| | | import javax.validation.constraints.NotBlank;
|
| | | import javax.validation.constraints.Size;
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.framework.web.domain.BaseEntity;
|
| | | import com.ruoyi.common.annotation.Excel;
|
| | | import com.ruoyi.common.annotation.Excel.ColumnType;
|
| | | import com.ruoyi.common.core.domain.BaseEntity;
|
| | |
|
| | | /**
|
| | | * å²ä½è¡¨ sys_post
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/domain/SysRoleDept.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.domain;
|
| | | package com.ruoyi.system.domain;
|
| | |
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/domain/SysRoleMenu.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.domain;
|
| | | package com.ruoyi.system.domain;
|
| | |
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysUserOnline.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.domain;
|
| | | package com.ruoyi.system.domain;
|
| | |
|
| | | /**
|
| | | * å½åå¨çº¿ä¼è¯
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/domain/SysUserPost.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.domain;
|
| | | package com.ruoyi.system.domain;
|
| | |
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/domain/SysUserRole.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.domain;
|
| | | package com.ruoyi.system.domain;
|
| | |
|
| | | import org.apache.commons.lang3.builder.ToStringBuilder;
|
| | | import org.apache.commons.lang3.builder.ToStringStyle;
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/domain/vo/MetaVo.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.domain.vo;
|
| | | package com.ruoyi.system.domain.vo;
|
| | |
|
| | | /**
|
| | | * è·¯ç±æ¾ç¤ºä¿¡æ¯
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/domain/vo/RouterVo.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.domain.vo;
|
| | | package com.ruoyi.system.domain.vo;
|
| | |
|
| | | import com.fasterxml.jackson.annotation.JsonInclude;
|
| | | import java.util.List;
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysConfigMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.mapper;
|
| | | package com.ruoyi.system.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.system.domain.SysConfig;
|
| | | import com.ruoyi.system.domain.SysConfig;
|
| | |
|
| | | /**
|
| | | * åæ°é
ç½® æ°æ®å±
|
| | |
| | | * @return ç»æ
|
| | | */
|
| | | public int deleteConfigByIds(Long[] configIds);
|
| | | } |
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysDeptMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.mapper;
|
| | | package com.ruoyi.system.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import org.apache.ibatis.annotations.Param;
|
| | | import com.ruoyi.project.system.domain.SysDept;
|
| | | import com.ruoyi.common.core.domain.entity.SysDept;
|
| | |
|
| | | /**
|
| | | * é¨é¨ç®¡ç æ°æ®å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysDictDataMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.mapper;
|
| | | package com.ruoyi.system.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import org.apache.ibatis.annotations.Param;
|
| | | import com.ruoyi.project.system.domain.SysDictData;
|
| | | import com.ruoyi.common.core.domain.entity.SysDictData;
|
| | |
|
| | | /**
|
| | | * åå
¸è¡¨ æ°æ®å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysDictTypeMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.mapper;
|
| | | package com.ruoyi.system.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import org.apache.ibatis.annotations.Mapper;
|
| | | import com.ruoyi.project.system.domain.SysDictType;
|
| | | import com.ruoyi.common.core.domain.entity.SysDictType;
|
| | |
|
| | | /**
|
| | | * åå
¸è¡¨ æ°æ®å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysLogininforMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.mapper;
|
| | | package com.ruoyi.system.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.monitor.domain.SysLogininfor;
|
| | | import com.ruoyi.system.domain.SysLogininfor;
|
| | |
|
| | | /**
|
| | | * ç³»ç»è®¿é®æ¥å¿æ
åµä¿¡æ¯ æ°æ®å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysMenuMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.mapper;
|
| | | package com.ruoyi.system.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import org.apache.ibatis.annotations.Param;
|
| | | import com.ruoyi.project.system.domain.SysMenu;
|
| | | import com.ruoyi.common.core.domain.entity.SysMenu;
|
| | |
|
| | | /**
|
| | | * èå表 æ°æ®å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.mapper;
|
| | | package com.ruoyi.system.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.system.domain.SysNotice;
|
| | | import com.ruoyi.system.domain.SysNotice;
|
| | |
|
| | | /**
|
| | | * éç¥å
¬å表 æ°æ®å±
|
| | |
| | | * @return ç»æ
|
| | | */
|
| | | public int deleteNoticeByIds(Long[] noticeIds);
|
| | | } |
| | | }
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysOperLogMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.mapper;
|
| | | package com.ruoyi.system.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.monitor.domain.SysOperLog;
|
| | | import com.ruoyi.system.domain.SysOperLog;
|
| | |
|
| | | /**
|
| | | * æä½æ¥å¿ æ°æ®å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysPostMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.mapper;
|
| | | package com.ruoyi.system.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.system.domain.SysPost;
|
| | | import com.ruoyi.system.domain.SysPost;
|
| | |
|
| | | /**
|
| | | * å²ä½ä¿¡æ¯ æ°æ®å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysRoleDeptMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.mapper;
|
| | | package com.ruoyi.system.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.system.domain.SysRoleDept;
|
| | | import com.ruoyi.system.domain.SysRoleDept;
|
| | |
|
| | | /**
|
| | | * è§è²ä¸é¨é¨å
³è表 æ°æ®å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysRoleMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.mapper;
|
| | | package com.ruoyi.system.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.system.domain.SysRole;
|
| | | import com.ruoyi.common.core.domain.entity.SysRole;
|
| | |
|
| | | /**
|
| | | * è§è²è¡¨ æ°æ®å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysRoleMenuMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.mapper;
|
| | | package com.ruoyi.system.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.system.domain.SysRoleMenu;
|
| | | import com.ruoyi.system.domain.SysRoleMenu;
|
| | |
|
| | | /**
|
| | | * è§è²ä¸èåå
³è表 æ°æ®å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.mapper;
|
| | | package com.ruoyi.system.mapper;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import org.apache.ibatis.annotations.Param;
|
| | |
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.common.core.domain.entity.SysUser;
|
| | |
|
| | | /**
|
| | | * ç¨æ·è¡¨ æ°æ®å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysUserPostMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.mapper;
|
| | | package com.ruoyi.system.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.system.domain.SysUserPost;
|
| | | import com.ruoyi.system.domain.SysUserPost;
|
| | |
|
| | | /**
|
| | | * ç¨æ·ä¸å²ä½å
³è表 æ°æ®å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysUserRoleMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.mapper;
|
| | | package com.ruoyi.system.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import org.apache.ibatis.annotations.Param;
|
| | | import com.ruoyi.project.system.domain.SysUserRole;
|
| | | import com.ruoyi.system.domain.SysUserRole;
|
| | |
|
| | | /**
|
| | | * ç¨æ·ä¸è§è²å
³è表 æ°æ®å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/ISysConfigService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service;
|
| | | package com.ruoyi.system.service;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.system.domain.SysConfig;
|
| | | import com.ruoyi.system.domain.SysConfig;
|
| | |
|
| | | /**
|
| | | * åæ°é
ç½® æå¡å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDeptService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service;
|
| | | package com.ruoyi.system.service;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.framework.web.domain.TreeSelect;
|
| | | import com.ruoyi.project.system.domain.SysDept;
|
| | | import com.ruoyi.common.core.domain.TreeSelect;
|
| | | import com.ruoyi.common.core.domain.entity.SysDept;
|
| | |
|
| | | /**
|
| | | * é¨é¨ç®¡ç æå¡å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictDataService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service;
|
| | | package com.ruoyi.system.service;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.system.domain.SysDictData;
|
| | | import com.ruoyi.common.core.domain.entity.SysDictData;
|
| | |
|
| | | /**
|
| | | * åå
¸ ä¸å¡å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictTypeService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service;
|
| | | package com.ruoyi.system.service;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.system.domain.SysDictData;
|
| | | import com.ruoyi.project.system.domain.SysDictType;
|
| | | import com.ruoyi.common.core.domain.entity.SysDictData;
|
| | | import com.ruoyi.common.core.domain.entity.SysDictType;
|
| | |
|
| | | /**
|
| | | * åå
¸ ä¸å¡å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysLogininforService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.service;
|
| | | package com.ruoyi.system.service;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.monitor.domain.SysLogininfor;
|
| | | import com.ruoyi.system.domain.SysLogininfor;
|
| | |
|
| | | /**
|
| | | * ç³»ç»è®¿é®æ¥å¿æ
åµä¿¡æ¯ æå¡å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/ISysMenuService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service;
|
| | | package com.ruoyi.system.service;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | | import com.ruoyi.framework.web.domain.TreeSelect;
|
| | | import com.ruoyi.project.system.domain.SysMenu;
|
| | | import com.ruoyi.project.system.domain.vo.RouterVo;
|
| | | import com.ruoyi.common.core.domain.TreeSelect;
|
| | | import com.ruoyi.common.core.domain.entity.SysMenu;
|
| | | import com.ruoyi.system.domain.vo.RouterVo;
|
| | |
|
| | | /**
|
| | | * èå ä¸å¡å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service;
|
| | | package com.ruoyi.system.service;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.system.domain.SysNotice;
|
| | | import com.ruoyi.system.domain.SysNotice;
|
| | |
|
| | | /**
|
| | | * å
¬å æå¡å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysOperLogService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.service;
|
| | | package com.ruoyi.system.service;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.monitor.domain.SysOperLog;
|
| | | import com.ruoyi.system.domain.SysOperLog;
|
| | |
|
| | | /**
|
| | | * æä½æ¥å¿ æå¡å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/ISysPostService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service;
|
| | | package com.ruoyi.system.service;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.system.domain.SysPost;
|
| | | import com.ruoyi.system.domain.SysPost;
|
| | |
|
| | | /**
|
| | | * å²ä½ä¿¡æ¯ æå¡å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/ISysRoleService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service;
|
| | | package com.ruoyi.system.service;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | | import com.ruoyi.project.system.domain.SysRole;
|
| | | import com.ruoyi.common.core.domain.entity.SysRole;
|
| | |
|
| | | /**
|
| | | * è§è²ä¸å¡å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/ISysUserOnlineService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service;
|
| | | package com.ruoyi.system.service;
|
| | |
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | | import com.ruoyi.project.monitor.domain.SysUserOnline;
|
| | | import com.ruoyi.common.core.domain.model.LoginUser;
|
| | | import com.ruoyi.system.domain.SysUserOnline;
|
| | |
|
| | | /**
|
| | | * å¨çº¿ç¨æ· æå¡å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/ISysUserService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service;
|
| | | package com.ruoyi.system.service;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.common.core.domain.entity.SysUser;
|
| | |
|
| | | /**
|
| | | * ç¨æ· ä¸å¡å±
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysConfigServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service.impl;
|
| | | package com.ruoyi.system.service.impl;
|
| | |
|
| | | import java.util.Collection;
|
| | | import java.util.List;
|
| | | import javax.annotation.PostConstruct;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.common.annotation.DataSource;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.core.redis.RedisCache;
|
| | | import com.ruoyi.common.core.text.Convert;
|
| | | import com.ruoyi.common.enums.DataSourceType;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.redis.RedisCache;
|
| | | import com.ruoyi.project.system.domain.SysConfig;
|
| | | import com.ruoyi.project.system.mapper.SysConfigMapper;
|
| | | import com.ruoyi.project.system.service.ISysConfigService;
|
| | | import com.ruoyi.system.domain.SysConfig;
|
| | | import com.ruoyi.system.mapper.SysConfigMapper;
|
| | | import com.ruoyi.system.service.ISysConfigService;
|
| | |
|
| | | /**
|
| | | * åæ°é
ç½® æå¡å±å®ç°
|
| | |
| | | * @return åæ°é
置信æ¯
|
| | | */
|
| | | @Override
|
| | | @DataSource(DataSourceType.MASTER)
|
| | | public SysConfig selectConfigById(Long configId)
|
| | | {
|
| | | SysConfig config = new SysConfig();
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service.impl;
|
| | | package com.ruoyi.system.service.impl;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Iterator;
|
| | |
| | | import java.util.stream.Collectors;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.common.annotation.DataScope;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.core.domain.TreeSelect;
|
| | | import com.ruoyi.common.core.domain.entity.SysDept;
|
| | | import com.ruoyi.common.exception.CustomException;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
|
| | | import com.ruoyi.framework.web.domain.TreeSelect;
|
| | | import com.ruoyi.project.system.domain.SysDept;
|
| | | import com.ruoyi.project.system.mapper.SysDeptMapper;
|
| | | import com.ruoyi.project.system.service.ISysDeptService;
|
| | | import com.ruoyi.system.mapper.SysDeptMapper;
|
| | | import com.ruoyi.system.service.ISysDeptService;
|
| | |
|
| | | /**
|
| | | * é¨é¨ç®¡ç æå¡å®ç°
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictDataServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service.impl;
|
| | | package com.ruoyi.system.service.impl;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.common.core.domain.entity.SysDictData;
|
| | | import com.ruoyi.common.utils.DictUtils;
|
| | | import com.ruoyi.project.system.domain.SysDictData;
|
| | | import com.ruoyi.project.system.mapper.SysDictDataMapper;
|
| | | import com.ruoyi.project.system.service.ISysDictDataService;
|
| | | import com.ruoyi.system.mapper.SysDictDataMapper;
|
| | | import com.ruoyi.system.service.ISysDictDataService;
|
| | |
|
| | | /**
|
| | | * åå
¸ ä¸å¡å±å¤ç
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictTypeServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service.impl;
|
| | | package com.ruoyi.system.service.impl;
|
| | |
|
| | | import java.util.List;
|
| | | import javax.annotation.PostConstruct;
|
| | |
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.core.domain.entity.SysDictData;
|
| | | import com.ruoyi.common.core.domain.entity.SysDictType;
|
| | | import com.ruoyi.common.exception.CustomException;
|
| | | import com.ruoyi.common.utils.DictUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.project.system.domain.SysDictData;
|
| | | import com.ruoyi.project.system.domain.SysDictType;
|
| | | import com.ruoyi.project.system.mapper.SysDictDataMapper;
|
| | | import com.ruoyi.project.system.mapper.SysDictTypeMapper;
|
| | | import com.ruoyi.project.system.service.ISysDictTypeService;
|
| | | import com.ruoyi.system.mapper.SysDictDataMapper;
|
| | | import com.ruoyi.system.mapper.SysDictTypeMapper;
|
| | | import com.ruoyi.system.service.ISysDictTypeService;
|
| | |
|
| | | /**
|
| | | * åå
¸ ä¸å¡å±å¤ç
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysLogininforServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.service.impl;
|
| | | package com.ruoyi.system.service.impl;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.project.monitor.domain.SysLogininfor;
|
| | | import com.ruoyi.project.monitor.mapper.SysLogininforMapper;
|
| | | import com.ruoyi.project.monitor.service.ISysLogininforService;
|
| | | import com.ruoyi.system.domain.SysLogininfor;
|
| | | import com.ruoyi.system.mapper.SysLogininforMapper;
|
| | | import com.ruoyi.system.service.ISysLogininforService;
|
| | |
|
| | | /**
|
| | | * ç³»ç»è®¿é®æ¥å¿æ
åµä¿¡æ¯ æå¡å±å¤ç
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysMenuServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service.impl;
|
| | | package com.ruoyi.system.service.impl;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | |
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.core.domain.TreeSelect;
|
| | | import com.ruoyi.common.core.domain.entity.SysMenu;
|
| | | import com.ruoyi.common.core.domain.entity.SysUser;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.web.domain.TreeSelect;
|
| | | import com.ruoyi.project.system.domain.SysMenu;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.project.system.domain.vo.MetaVo;
|
| | | import com.ruoyi.project.system.domain.vo.RouterVo;
|
| | | import com.ruoyi.project.system.mapper.SysMenuMapper;
|
| | | import com.ruoyi.project.system.mapper.SysRoleMenuMapper;
|
| | | import com.ruoyi.project.system.service.ISysMenuService;
|
| | | import com.ruoyi.system.domain.vo.MetaVo;
|
| | | import com.ruoyi.system.domain.vo.RouterVo;
|
| | | import com.ruoyi.system.mapper.SysMenuMapper;
|
| | | import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
| | | import com.ruoyi.system.service.ISysMenuService;
|
| | |
|
| | | /**
|
| | | * èå ä¸å¡å±å¤ç
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service.impl;
|
| | | package com.ruoyi.system.service.impl;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.project.system.domain.SysNotice;
|
| | | import com.ruoyi.project.system.mapper.SysNoticeMapper;
|
| | | import com.ruoyi.project.system.service.ISysNoticeService;
|
| | | import com.ruoyi.system.domain.SysNotice;
|
| | | import com.ruoyi.system.mapper.SysNoticeMapper;
|
| | | import com.ruoyi.system.service.ISysNoticeService;
|
| | |
|
| | | /**
|
| | | * å
¬å æå¡å±å®ç°
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysOperLogServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.monitor.service.impl;
|
| | | package com.ruoyi.system.service.impl;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.project.monitor.domain.SysOperLog;
|
| | | import com.ruoyi.project.monitor.mapper.SysOperLogMapper;
|
| | | import com.ruoyi.project.monitor.service.ISysOperLogService;
|
| | | import com.ruoyi.system.domain.SysOperLog;
|
| | | import com.ruoyi.system.mapper.SysOperLogMapper;
|
| | | import com.ruoyi.system.service.ISysOperLogService;
|
| | |
|
| | | /**
|
| | | * æä½æ¥å¿ æå¡å±å¤ç
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysPostServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service.impl;
|
| | | package com.ruoyi.system.service.impl;
|
| | |
|
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.exception.CustomException;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.project.system.domain.SysPost;
|
| | | import com.ruoyi.project.system.mapper.SysPostMapper;
|
| | | import com.ruoyi.project.system.mapper.SysUserPostMapper;
|
| | | import com.ruoyi.project.system.service.ISysPostService;
|
| | | import com.ruoyi.system.domain.SysPost;
|
| | | import com.ruoyi.system.mapper.SysPostMapper;
|
| | | import com.ruoyi.system.mapper.SysUserPostMapper;
|
| | | import com.ruoyi.system.service.ISysPostService;
|
| | |
|
| | | /**
|
| | | * å²ä½ä¿¡æ¯ æå¡å±å¤ç
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysRoleServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service.impl;
|
| | | package com.ruoyi.system.service.impl;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | |
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import com.ruoyi.common.annotation.DataScope;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.core.domain.entity.SysRole;
|
| | | import com.ruoyi.common.exception.CustomException;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.spring.SpringUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
|
| | | import com.ruoyi.project.system.domain.SysRole;
|
| | | import com.ruoyi.project.system.domain.SysRoleDept;
|
| | | import com.ruoyi.project.system.domain.SysRoleMenu;
|
| | | import com.ruoyi.project.system.mapper.SysRoleDeptMapper;
|
| | | import com.ruoyi.project.system.mapper.SysRoleMapper;
|
| | | import com.ruoyi.project.system.mapper.SysRoleMenuMapper;
|
| | | import com.ruoyi.project.system.mapper.SysUserRoleMapper;
|
| | | import com.ruoyi.project.system.service.ISysRoleService;
|
| | | import com.ruoyi.system.domain.SysRoleDept;
|
| | | import com.ruoyi.system.domain.SysRoleMenu;
|
| | | import com.ruoyi.system.mapper.SysRoleDeptMapper;
|
| | | import com.ruoyi.system.mapper.SysRoleMapper;
|
| | | import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
| | | import com.ruoyi.system.mapper.SysUserRoleMapper;
|
| | | import com.ruoyi.system.service.ISysRoleService;
|
| | |
|
| | | /**
|
| | | * è§è² ä¸å¡å±å¤ç
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysUserOnlineServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service.impl;
|
| | | package com.ruoyi.system.service.impl;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.common.core.domain.model.LoginUser;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.security.LoginUser;
|
| | | import com.ruoyi.project.monitor.domain.SysUserOnline;
|
| | | import com.ruoyi.project.system.service.ISysUserOnlineService;
|
| | | import com.ruoyi.system.domain.SysUserOnline;
|
| | | import com.ruoyi.system.service.ISysUserOnlineService;
|
| | |
|
| | | /**
|
| | | * å¨çº¿ç¨æ· æå¡å±å¤ç
|
ÎļþÃû´Ó ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysUserServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.project.system.service.impl;
|
| | | package com.ruoyi.system.service.impl;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import com.ruoyi.common.annotation.DataScope;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.core.domain.entity.SysRole;
|
| | | import com.ruoyi.common.core.domain.entity.SysUser;
|
| | | import com.ruoyi.common.exception.CustomException;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
|
| | | import com.ruoyi.project.system.domain.SysPost;
|
| | | import com.ruoyi.project.system.domain.SysRole;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.project.system.domain.SysUserPost;
|
| | | import com.ruoyi.project.system.domain.SysUserRole;
|
| | | import com.ruoyi.project.system.mapper.SysPostMapper;
|
| | | import com.ruoyi.project.system.mapper.SysRoleMapper;
|
| | | import com.ruoyi.project.system.mapper.SysUserMapper;
|
| | | import com.ruoyi.project.system.mapper.SysUserPostMapper;
|
| | | import com.ruoyi.project.system.mapper.SysUserRoleMapper;
|
| | | import com.ruoyi.project.system.service.ISysConfigService;
|
| | | import com.ruoyi.project.system.service.ISysUserService;
|
| | | import com.ruoyi.system.domain.SysPost;
|
| | | import com.ruoyi.system.domain.SysUserPost;
|
| | | import com.ruoyi.system.domain.SysUserRole;
|
| | | import com.ruoyi.system.mapper.SysPostMapper;
|
| | | import com.ruoyi.system.mapper.SysRoleMapper;
|
| | | import com.ruoyi.system.mapper.SysUserMapper;
|
| | | import com.ruoyi.system.mapper.SysUserPostMapper;
|
| | | import com.ruoyi.system.mapper.SysUserRoleMapper;
|
| | | import com.ruoyi.system.service.ISysConfigService;
|
| | | import com.ruoyi.system.service.ISysUserService;
|
| | |
|
| | | /**
|
| | | * ç¨æ· ä¸å¡å±å¤ç
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/system/SysConfigMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.system.mapper.SysConfigMapper">
|
| | | <mapper namespace="com.ruoyi.system.mapper.SysConfigMapper">
|
| | |
|
| | | <resultMap type="SysConfig" id="SysConfigResult">
|
| | | <id property="configId" column="config_id" />
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/system/SysDeptMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.system.mapper.SysDeptMapper">
|
| | | <mapper namespace="com.ruoyi.system.mapper.SysDeptMapper">
|
| | |
|
| | | <resultMap type="SysDept" id="SysDeptResult">
|
| | | <id property="deptId" column="dept_id" />
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/system/SysDictDataMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.system.mapper.SysDictDataMapper">
|
| | | <mapper namespace="com.ruoyi.system.mapper.SysDictDataMapper">
|
| | |
|
| | | <resultMap type="SysDictData" id="SysDictDataResult">
|
| | | <id property="dictCode" column="dict_code" />
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/system/SysDictTypeMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.system.mapper.SysDictTypeMapper">
|
| | | <mapper namespace="com.ruoyi.system.mapper.SysDictTypeMapper">
|
| | |
|
| | | <resultMap type="SysDictType" id="SysDictTypeResult">
|
| | | <id property="dictId" column="dict_id" />
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/monitor/SysLogininforMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.monitor.mapper.SysLogininforMapper">
|
| | | <mapper namespace="com.ruoyi.system.mapper.SysLogininforMapper">
|
| | |
|
| | | <resultMap type="SysLogininfor" id="SysLogininforResult">
|
| | | <id property="infoId" column="info_id" />
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/system/SysMenuMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.system.mapper.SysMenuMapper">
|
| | | <mapper namespace="com.ruoyi.system.mapper.SysMenuMapper">
|
| | |
|
| | | <resultMap type="SysMenu" id="SysMenuResult">
|
| | | <id property="menuId" column="menu_id" />
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/system/SysNoticeMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.system.mapper.SysNoticeMapper">
|
| | | <mapper namespace="com.ruoyi.system.mapper.SysNoticeMapper">
|
| | |
|
| | | <resultMap type="SysNotice" id="SysNoticeResult">
|
| | | <result property="noticeId" column="notice_id" />
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/monitor/SysOperLogMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.monitor.mapper.SysOperLogMapper">
|
| | | <mapper namespace="com.ruoyi.system.mapper.SysOperLogMapper">
|
| | |
|
| | | <resultMap type="SysOperLog" id="SysOperLogResult">
|
| | | <id property="operId" column="oper_id" />
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/system/SysPostMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.system.mapper.SysPostMapper">
|
| | | <mapper namespace="com.ruoyi.system.mapper.SysPostMapper">
|
| | |
|
| | | <resultMap type="SysPost" id="SysPostResult">
|
| | | <id property="postId" column="post_id" />
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/system/SysRoleDeptMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.system.mapper.SysRoleDeptMapper">
|
| | | <mapper namespace="com.ruoyi.system.mapper.SysRoleDeptMapper">
|
| | |
|
| | | <resultMap type="SysRoleDept" id="SysRoleDeptResult">
|
| | | <result property="roleId" column="role_id" />
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/system/SysRoleMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.system.mapper.SysRoleMapper">
|
| | | <mapper namespace="com.ruoyi.system.mapper.SysRoleMapper">
|
| | |
|
| | | <resultMap type="SysRole" id="SysRoleResult">
|
| | | <id property="roleId" column="role_id" />
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/system/SysRoleMenuMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.system.mapper.SysRoleMenuMapper">
|
| | | <mapper namespace="com.ruoyi.system.mapper.SysRoleMenuMapper">
|
| | |
|
| | | <resultMap type="SysRoleMenu" id="SysRoleMenuResult">
|
| | | <result property="roleId" column="role_id" />
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/system/SysUserMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.system.mapper.SysUserMapper">
|
| | | <mapper namespace="com.ruoyi.system.mapper.SysUserMapper">
|
| | |
|
| | | <resultMap type="SysUser" id="SysUserResult">
|
| | | <id property="userId" column="user_id" />
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/system/SysUserPostMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.system.mapper.SysUserPostMapper">
|
| | | <mapper namespace="com.ruoyi.system.mapper.SysUserPostMapper">
|
| | |
|
| | | <resultMap type="SysUserPost" id="SysUserPostResult">
|
| | | <result property="userId" column="user_id" />
|
ÎļþÃû´Ó ruoyi/src/main/resources/mybatis/system/SysUserRoleMapper.xml ÐÞ¸Ä |
| | |
| | | <!DOCTYPE mapper
|
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
| | | <mapper namespace="com.ruoyi.project.system.mapper.SysUserRoleMapper">
|
| | | <mapper namespace="com.ruoyi.system.mapper.SysUserRoleMapper">
|
| | |
|
| | | <resultMap type="SysUserRole" id="SysUserRoleResult">
|
| | | <result property="userId" column="user_id" />
|
| | |
| | | {
|
| | | "name": "ruoyi",
|
| | | "version": "2.3.0",
|
| | | "version": "3.0.0",
|
| | | "description": "è¥ä¾ç®¡çç³»ç»",
|
| | | "author": "è¥ä¾",
|
| | | "license": "MIT",
|
ÎļþÃû´Ó ruoyi/ry.sh ÐÞ¸Ä |
| | |
| | | #!/bin/bash
|
| | |
|
| | | AppName=ruoyi.jar
|
| | | AppName=ruoyi-admin.jar
|
| | |
|
| | | #JVMåæ°
|
| | | JVM_OPTS="-Dname=$AppName -Duser.timezone=Asia/Shanghai -Xms512M -Xmx512M -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC"
|
ÎļþÃû´Ó ruoyi/sql/quartz.sql ÐÞ¸Ä |
| | |
| | | -- ---------------------------- |
| | | -- 1ãå卿¯ä¸ä¸ªå·²é
ç½®ç jobDetail ç详ç»ä¿¡æ¯ |
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_JOB_DETAILS; |
| | | create table QRTZ_JOB_DETAILS ( |
| | | sched_name varchar(120) not null, |
| | | job_name varchar(200) not null, |
| | | job_group varchar(200) not null, |
| | | description varchar(250) null, |
| | | job_class_name varchar(250) not null, |
| | | is_durable varchar(1) not null, |
| | | is_nonconcurrent varchar(1) not null, |
| | | is_update_data varchar(1) not null, |
| | | requests_recovery varchar(1) not null, |
| | | job_data blob null, |
| | | primary key (sched_name,job_name,job_group) |
| | | ) engine=innodb; |
| | | |
| | | -- ---------------------------- |
| | | -- 2ã åå¨å·²é
ç½®ç Trigger çä¿¡æ¯ |
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_TRIGGERS; |
| | | create table QRTZ_TRIGGERS ( |
| | | sched_name varchar(120) not null, |
| | | trigger_name varchar(200) not null, |
| | | trigger_group varchar(200) not null, |
| | | job_name varchar(200) not null, |
| | | job_group varchar(200) not null, |
| | | description varchar(250) null, |
| | | next_fire_time bigint(13) null, |
| | | prev_fire_time bigint(13) null, |
| | | priority integer null, |
| | | trigger_state varchar(16) not null, |
| | | trigger_type varchar(8) not null, |
| | | start_time bigint(13) not null, |
| | | end_time bigint(13) null, |
| | | calendar_name varchar(200) null, |
| | | misfire_instr smallint(2) null, |
| | | job_data blob null, |
| | | primary key (sched_name,trigger_name,trigger_group), |
| | | foreign key (sched_name,job_name,job_group) references QRTZ_JOB_DETAILS(sched_name,job_name,job_group) |
| | | ) engine=innodb; |
| | | |
| | | -- ---------------------------- |
| | | -- 3ã åå¨ç®åç Triggerï¼å
æ¬é夿¬¡æ°ï¼é´éï¼ä»¥å已触åçæ¬¡æ° |
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_SIMPLE_TRIGGERS; |
| | | create table QRTZ_SIMPLE_TRIGGERS ( |
| | | sched_name varchar(120) not null, |
| | | trigger_name varchar(200) not null, |
| | | trigger_group varchar(200) not null, |
| | | repeat_count bigint(7) not null, |
| | | repeat_interval bigint(12) not null, |
| | | times_triggered bigint(10) not null, |
| | | primary key (sched_name,trigger_name,trigger_group), |
| | | foreign key (sched_name,trigger_name,trigger_group) references QRTZ_TRIGGERS(sched_name,trigger_name,trigger_group) |
| | | ) engine=innodb; |
| | | |
| | | -- ---------------------------- |
| | | -- 4ã åå¨ Cron Triggerï¼å
æ¬ Cron 表达å¼åæ¶åºä¿¡æ¯ |
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_CRON_TRIGGERS; |
| | | create table QRTZ_CRON_TRIGGERS ( |
| | | sched_name varchar(120) not null, |
| | | trigger_name varchar(200) not null, |
| | | trigger_group varchar(200) not null, |
| | | cron_expression varchar(200) not null, |
| | | time_zone_id varchar(80), |
| | | primary key (sched_name,trigger_name,trigger_group), |
| | | foreign key (sched_name,trigger_name,trigger_group) references QRTZ_TRIGGERS(sched_name,trigger_name,trigger_group) |
| | | ) engine=innodb; |
| | | |
| | | -- ---------------------------- |
| | | -- 5ã Trigger ä½ä¸º Blob ç±»ååå¨(ç¨äº Quartz ç¨æ·ç¨ JDBC å建ä»ä»¬èªå·±å®å¶ç Trigger ç±»åï¼JobStore å¹¶ä¸ç¥éå¦ä½åå¨å®ä¾çæ¶å) |
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_BLOB_TRIGGERS; |
| | | create table QRTZ_BLOB_TRIGGERS ( |
| | | sched_name varchar(120) not null, |
| | | trigger_name varchar(200) not null, |
| | | trigger_group varchar(200) not null, |
| | | blob_data blob null, |
| | | primary key (sched_name,trigger_name,trigger_group), |
| | | foreign key (sched_name,trigger_name,trigger_group) references QRTZ_TRIGGERS(sched_name,trigger_name,trigger_group) |
| | | ) engine=innodb; |
| | | |
| | | -- ---------------------------- |
| | | -- 6ã 以 Blob ç±»ååå¨åæ¾æ¥åä¿¡æ¯ï¼ quartzå¯é
ç½®ä¸ä¸ªæ¥åæ¥æå®ä¸ä¸ªæ¶é´èå´ |
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_CALENDARS; |
| | | create table QRTZ_CALENDARS ( |
| | | sched_name varchar(120) not null, |
| | | calendar_name varchar(200) not null, |
| | | calendar blob not null, |
| | | primary key (sched_name,calendar_name) |
| | | ) engine=innodb; |
| | | |
| | | -- ---------------------------- |
| | | -- 7ã åå¨å·²æåç Trigger ç»çä¿¡æ¯ |
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_PAUSED_TRIGGER_GRPS; |
| | | create table QRTZ_PAUSED_TRIGGER_GRPS ( |
| | | sched_name varchar(120) not null, |
| | | trigger_group varchar(200) not null, |
| | | primary key (sched_name,trigger_group) |
| | | ) engine=innodb; |
| | | |
| | | -- ---------------------------- |
| | | -- 8ã åå¨ä¸å·²è§¦åç Trigger ç¸å
³çç¶æä¿¡æ¯ï¼ä»¥åç¸è Job çæ§è¡ä¿¡æ¯ |
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_FIRED_TRIGGERS; |
| | | create table QRTZ_FIRED_TRIGGERS ( |
| | | sched_name varchar(120) not null, |
| | | entry_id varchar(95) not null, |
| | | trigger_name varchar(200) not null, |
| | | trigger_group varchar(200) not null, |
| | | instance_name varchar(200) not null, |
| | | fired_time bigint(13) not null, |
| | | sched_time bigint(13) not null, |
| | | priority integer not null, |
| | | state varchar(16) not null, |
| | | job_name varchar(200) null, |
| | | job_group varchar(200) null, |
| | | is_nonconcurrent varchar(1) null, |
| | | requests_recovery varchar(1) null, |
| | | primary key (sched_name,entry_id) |
| | | ) engine=innodb; |
| | | |
| | | -- ---------------------------- |
| | | -- 9ã åå¨å°éçæå
³ Scheduler çç¶æä¿¡æ¯ï¼å妿¯ç¨äºé群ä¸ï¼å¯ä»¥çå°å
¶ä»ç Scheduler å®ä¾ |
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_SCHEDULER_STATE; |
| | | create table QRTZ_SCHEDULER_STATE ( |
| | | sched_name varchar(120) not null, |
| | | instance_name varchar(200) not null, |
| | | last_checkin_time bigint(13) not null, |
| | | checkin_interval bigint(13) not null, |
| | | primary key (sched_name,instance_name) |
| | | ) engine=innodb; |
| | | |
| | | -- ---------------------------- |
| | | -- 10ã åå¨ç¨åºçæ²è§éçä¿¡æ¯(åå¦ä½¿ç¨äºæ²è§é) |
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_LOCKS; |
| | | create table QRTZ_LOCKS ( |
| | | sched_name varchar(120) not null, |
| | | lock_name varchar(40) not null, |
| | | primary key (sched_name,lock_name) |
| | | ) engine=innodb; |
| | | |
| | | drop table if exists QRTZ_SIMPROP_TRIGGERS; |
| | | create table QRTZ_SIMPROP_TRIGGERS ( |
| | | sched_name varchar(120) not null, |
| | | trigger_name varchar(200) not null, |
| | | trigger_group varchar(200) not null, |
| | | str_prop_1 varchar(512) null, |
| | | str_prop_2 varchar(512) null, |
| | | str_prop_3 varchar(512) null, |
| | | int_prop_1 int null, |
| | | int_prop_2 int null, |
| | | long_prop_1 bigint null, |
| | | long_prop_2 bigint null, |
| | | dec_prop_1 numeric(13,4) null, |
| | | dec_prop_2 numeric(13,4) null, |
| | | bool_prop_1 varchar(1) null, |
| | | bool_prop_2 varchar(1) null, |
| | | primary key (sched_name,trigger_name,trigger_group), |
| | | foreign key (sched_name,trigger_name,trigger_group) references QRTZ_TRIGGERS(sched_name,trigger_name,trigger_group) |
| | | ) engine=innodb; |
| | | |
| | | -- ----------------------------
|
| | | -- 1ãå卿¯ä¸ä¸ªå·²é
ç½®ç jobDetail ç详ç»ä¿¡æ¯
|
| | | -- ----------------------------
|
| | | drop table if exists QRTZ_JOB_DETAILS;
|
| | | create table QRTZ_JOB_DETAILS (
|
| | | sched_name varchar(120) not null,
|
| | | job_name varchar(200) not null,
|
| | | job_group varchar(200) not null,
|
| | | description varchar(250) null,
|
| | | job_class_name varchar(250) not null,
|
| | | is_durable varchar(1) not null,
|
| | | is_nonconcurrent varchar(1) not null,
|
| | | is_update_data varchar(1) not null,
|
| | | requests_recovery varchar(1) not null,
|
| | | job_data blob null,
|
| | | primary key (sched_name,job_name,job_group)
|
| | | ) engine=innodb;
|
| | |
|
| | | -- ----------------------------
|
| | | -- 2ã åå¨å·²é
ç½®ç Trigger çä¿¡æ¯
|
| | | -- ----------------------------
|
| | | drop table if exists QRTZ_TRIGGERS;
|
| | | create table QRTZ_TRIGGERS (
|
| | | sched_name varchar(120) not null,
|
| | | trigger_name varchar(200) not null,
|
| | | trigger_group varchar(200) not null,
|
| | | job_name varchar(200) not null,
|
| | | job_group varchar(200) not null,
|
| | | description varchar(250) null,
|
| | | next_fire_time bigint(13) null,
|
| | | prev_fire_time bigint(13) null,
|
| | | priority integer null,
|
| | | trigger_state varchar(16) not null,
|
| | | trigger_type varchar(8) not null,
|
| | | start_time bigint(13) not null,
|
| | | end_time bigint(13) null,
|
| | | calendar_name varchar(200) null,
|
| | | misfire_instr smallint(2) null,
|
| | | job_data blob null,
|
| | | primary key (sched_name,trigger_name,trigger_group),
|
| | | foreign key (sched_name,job_name,job_group) references QRTZ_JOB_DETAILS(sched_name,job_name,job_group)
|
| | | ) engine=innodb;
|
| | |
|
| | | -- ----------------------------
|
| | | -- 3ã åå¨ç®åç Triggerï¼å
æ¬é夿¬¡æ°ï¼é´éï¼ä»¥å已触åçæ¬¡æ°
|
| | | -- ----------------------------
|
| | | drop table if exists QRTZ_SIMPLE_TRIGGERS;
|
| | | create table QRTZ_SIMPLE_TRIGGERS (
|
| | | sched_name varchar(120) not null,
|
| | | trigger_name varchar(200) not null,
|
| | | trigger_group varchar(200) not null,
|
| | | repeat_count bigint(7) not null,
|
| | | repeat_interval bigint(12) not null,
|
| | | times_triggered bigint(10) not null,
|
| | | primary key (sched_name,trigger_name,trigger_group),
|
| | | foreign key (sched_name,trigger_name,trigger_group) references QRTZ_TRIGGERS(sched_name,trigger_name,trigger_group)
|
| | | ) engine=innodb;
|
| | |
|
| | | -- ----------------------------
|
| | | -- 4ã åå¨ Cron Triggerï¼å
æ¬ Cron 表达å¼åæ¶åºä¿¡æ¯
|
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_CRON_TRIGGERS;
|
| | | create table QRTZ_CRON_TRIGGERS (
|
| | | sched_name varchar(120) not null,
|
| | | trigger_name varchar(200) not null,
|
| | | trigger_group varchar(200) not null,
|
| | | cron_expression varchar(200) not null,
|
| | | time_zone_id varchar(80),
|
| | | primary key (sched_name,trigger_name,trigger_group),
|
| | | foreign key (sched_name,trigger_name,trigger_group) references QRTZ_TRIGGERS(sched_name,trigger_name,trigger_group)
|
| | | ) engine=innodb;
|
| | |
|
| | | -- ----------------------------
|
| | | -- 5ã Trigger ä½ä¸º Blob ç±»ååå¨(ç¨äº Quartz ç¨æ·ç¨ JDBC å建ä»ä»¬èªå·±å®å¶ç Trigger ç±»åï¼JobStore å¹¶ä¸ç¥éå¦ä½åå¨å®ä¾çæ¶å)
|
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_BLOB_TRIGGERS;
|
| | | create table QRTZ_BLOB_TRIGGERS (
|
| | | sched_name varchar(120) not null,
|
| | | trigger_name varchar(200) not null,
|
| | | trigger_group varchar(200) not null,
|
| | | blob_data blob null,
|
| | | primary key (sched_name,trigger_name,trigger_group),
|
| | | foreign key (sched_name,trigger_name,trigger_group) references QRTZ_TRIGGERS(sched_name,trigger_name,trigger_group)
|
| | | ) engine=innodb;
|
| | |
|
| | | -- ----------------------------
|
| | | -- 6ã 以 Blob ç±»ååå¨åæ¾æ¥åä¿¡æ¯ï¼ quartzå¯é
ç½®ä¸ä¸ªæ¥åæ¥æå®ä¸ä¸ªæ¶é´èå´
|
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_CALENDARS;
|
| | | create table QRTZ_CALENDARS (
|
| | | sched_name varchar(120) not null,
|
| | | calendar_name varchar(200) not null,
|
| | | calendar blob not null,
|
| | | primary key (sched_name,calendar_name)
|
| | | ) engine=innodb;
|
| | |
|
| | | -- ----------------------------
|
| | | -- 7ã åå¨å·²æåç Trigger ç»çä¿¡æ¯
|
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_PAUSED_TRIGGER_GRPS;
|
| | | create table QRTZ_PAUSED_TRIGGER_GRPS (
|
| | | sched_name varchar(120) not null,
|
| | | trigger_group varchar(200) not null,
|
| | | primary key (sched_name,trigger_group)
|
| | | ) engine=innodb;
|
| | |
|
| | | -- ----------------------------
|
| | | -- 8ã åå¨ä¸å·²è§¦åç Trigger ç¸å
³çç¶æä¿¡æ¯ï¼ä»¥åç¸è Job çæ§è¡ä¿¡æ¯
|
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_FIRED_TRIGGERS;
|
| | | create table QRTZ_FIRED_TRIGGERS (
|
| | | sched_name varchar(120) not null,
|
| | | entry_id varchar(95) not null,
|
| | | trigger_name varchar(200) not null,
|
| | | trigger_group varchar(200) not null,
|
| | | instance_name varchar(200) not null,
|
| | | fired_time bigint(13) not null,
|
| | | sched_time bigint(13) not null,
|
| | | priority integer not null,
|
| | | state varchar(16) not null,
|
| | | job_name varchar(200) null,
|
| | | job_group varchar(200) null,
|
| | | is_nonconcurrent varchar(1) null,
|
| | | requests_recovery varchar(1) null,
|
| | | primary key (sched_name,entry_id)
|
| | | ) engine=innodb;
|
| | |
|
| | | -- ----------------------------
|
| | | -- 9ã åå¨å°éçæå
³ Scheduler çç¶æä¿¡æ¯ï¼å妿¯ç¨äºé群ä¸ï¼å¯ä»¥çå°å
¶ä»ç Scheduler å®ä¾
|
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_SCHEDULER_STATE; |
| | | create table QRTZ_SCHEDULER_STATE (
|
| | | sched_name varchar(120) not null,
|
| | | instance_name varchar(200) not null,
|
| | | last_checkin_time bigint(13) not null,
|
| | | checkin_interval bigint(13) not null,
|
| | | primary key (sched_name,instance_name)
|
| | | ) engine=innodb;
|
| | |
|
| | | -- ----------------------------
|
| | | -- 10ã åå¨ç¨åºçæ²è§éçä¿¡æ¯(åå¦ä½¿ç¨äºæ²è§é)
|
| | | -- ---------------------------- |
| | | drop table if exists QRTZ_LOCKS;
|
| | | create table QRTZ_LOCKS (
|
| | | sched_name varchar(120) not null,
|
| | | lock_name varchar(40) not null,
|
| | | primary key (sched_name,lock_name)
|
| | | ) engine=innodb;
|
| | |
|
| | | drop table if exists QRTZ_SIMPROP_TRIGGERS;
|
| | | create table QRTZ_SIMPROP_TRIGGERS (
|
| | | sched_name varchar(120) not null,
|
| | | trigger_name varchar(200) not null,
|
| | | trigger_group varchar(200) not null,
|
| | | str_prop_1 varchar(512) null,
|
| | | str_prop_2 varchar(512) null,
|
| | | str_prop_3 varchar(512) null,
|
| | | int_prop_1 int null,
|
| | | int_prop_2 int null,
|
| | | long_prop_1 bigint null,
|
| | | long_prop_2 bigint null,
|
| | | dec_prop_1 numeric(13,4) null,
|
| | | dec_prop_2 numeric(13,4) null,
|
| | | bool_prop_1 varchar(1) null,
|
| | | bool_prop_2 varchar(1) null,
|
| | | primary key (sched_name,trigger_name,trigger_group),
|
| | | foreign key (sched_name,trigger_name,trigger_group) references QRTZ_TRIGGERS(sched_name,trigger_name,trigger_group)
|
| | | ) engine=innodb;
|
| | |
|
| | | commit; |