已添加202个文件
已复制1个文件
已重命名78个文件
已删除190个文件
已修改3个文件
¶Ô±ÈÐÂÎļþ |
| | |
| | | @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>
|
| | | <mybatis-plus.version>3.3.0</mybatis-plus.version>
|
| | | <hutool.version>5.1.0</hutool.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>
|
| | | <exclusions>
|
| | | <exclusion>
|
| | | <groupId>org.mybatis</groupId>
|
| | | <artifactId>mybatis</artifactId>
|
| | | </exclusion>
|
| | | </exclusions>
|
| | | </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.baomidou</groupId>
|
| | | <artifactId>mybatis-plus-boot-starter</artifactId>
|
| | | <version>${mybatis-plus.version}</version>
|
| | | </dependency>
|
| | | <dependency>
|
| | | <groupId>com.baomidou</groupId>
|
| | | <artifactId>mybatis-plus-extension</artifactId>
|
| | | <version>${mybatis-plus.version}</version>
|
| | | </dependency>
|
| | | <dependency>
|
| | | <groupId>cn.hutool</groupId>
|
| | | <artifactId>hutool-all</artifactId>
|
| | | <version>${hutool.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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.common; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.util.concurrent.TimeUnit; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | 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.redis.RedisCache; |
| | | import com.ruoyi.common.utils.VerifyCodeUtils; |
| | | import com.ruoyi.common.utils.sign.Base64; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | |
| | | /** |
| | | * éªè¯ç æä½å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | public class CaptchaController |
| | | { |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | /** |
| | | * çæéªè¯ç |
| | | */ |
| | | @GetMapping("/captchaImage") |
| | | public AjaxResult getCode(HttpServletResponse response) throws IOException |
| | | { |
| | | // çæéæºå串 |
| | | String verifyCode = VerifyCodeUtils.generateVerifyCode(4); |
| | | // å¯ä¸æ è¯ |
| | | String uuid = IdUtils.simpleUUID(); |
| | | String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; |
| | | |
| | | redisCache.setCacheObject(verifyKey, verifyCode, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES); |
| | | // çæå¾ç |
| | | int w = 111, h = 36; |
| | | ByteArrayOutputStream stream = new ByteArrayOutputStream(); |
| | | VerifyCodeUtils.outputImage(w, h, stream, verifyCode); |
| | | try |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("uuid", uuid); |
| | | ajax.put("img", Base64.encode(stream.toByteArray())); |
| | | return ajax; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | e.printStackTrace(); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | finally |
| | | { |
| | | stream.close(); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.common; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | 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.ServerConfig; |
| | | |
| | | /** |
| | | * éç¨è¯·æ±å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | public class CommonController |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(CommonController.class); |
| | | |
| | | @Autowired |
| | | private ServerConfig serverConfig; |
| | | |
| | | /** |
| | | * éç¨ä¸è½½è¯·æ± |
| | | * |
| | | * @param fileName æä»¶åç§° |
| | | * @param delete æ¯å¦å é¤ |
| | | */ |
| | | @GetMapping("common/download") |
| | | public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) |
| | | { |
| | | try |
| | | { |
| | | if (!FileUtils.isValidFilename(fileName)) |
| | | { |
| | | throw new Exception(StringUtils.format("æä»¶åç§°({})éæ³ï¼ä¸å
许ä¸è½½ã ", fileName)); |
| | | } |
| | | String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); |
| | | String filePath = RuoYiConfig.getDownloadPath() + fileName; |
| | | |
| | | response.setCharacterEncoding("utf-8"); |
| | | response.setContentType("multipart/form-data"); |
| | | response.setHeader("Content-Disposition", |
| | | "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName)); |
| | | FileUtils.writeBytes(filePath, response.getOutputStream()); |
| | | if (delete) |
| | | { |
| | | FileUtils.deleteFile(filePath); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | log.error("ä¸è½½æä»¶å¤±è´¥", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * éç¨ä¸ä¼ è¯·æ± |
| | | */ |
| | | @PostMapping("/common/upload") |
| | | public AjaxResult uploadFile(MultipartFile file) throws Exception |
| | | { |
| | | try |
| | | { |
| | | // ä¸ä¼ æä»¶è·¯å¾ |
| | | String filePath = RuoYiConfig.getUploadPath(); |
| | | // ä¸ä¼ å¹¶è¿åæ°æä»¶åç§° |
| | | String fileName = FileUploadUtils.upload(filePath, file); |
| | | String url = serverConfig.getUrl() + fileName; |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("fileName", fileName); |
| | | ajax.put("url", url); |
| | | return ajax; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¬å°èµæºéç¨ä¸è½½ |
| | | */ |
| | | @GetMapping("/common/download/resource") |
| | | public void resourceDownload(String name, HttpServletRequest request, HttpServletResponse response) throws Exception |
| | | { |
| | | // æ¬å°èµæºè·¯å¾ |
| | | String localPath = RuoYiConfig.getProfile(); |
| | | // æ°æ®åºèµæºå°å |
| | | String downloadPath = localPath + StringUtils.substringAfter(name, Constants.RESOURCE_PREFIX); |
| | | // ä¸è½½åç§° |
| | | String downloadName = StringUtils.substringAfterLast(downloadPath, "/"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | response.setContentType("multipart/form-data"); |
| | | response.setHeader("Content-Disposition", |
| | | "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName)); |
| | | FileUtils.writeBytes(downloadPath, response.getOutputStream()); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.domain.Server; |
| | | |
| | | /** |
| | | * æå¡å¨çæ§ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/monitor/server") |
| | | public class ServerController extends BaseController |
| | | { |
| | | @PreAuthorize("@ss.hasPermi('monitor:server:list')") |
| | | @GetMapping() |
| | | public AjaxResult getInfo() throws Exception |
| | | { |
| | | Server server = new Server(); |
| | | server.copyTo(); |
| | | return AjaxResult.success(server); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.monitor; |
| | | |
| | | 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.system.domain.SysLogininfor; |
| | | import com.ruoyi.system.service.ISysLogininforService; |
| | | |
| | | /** |
| | | * ç³»ç»è®¿é®è®°å½ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/monitor/logininfor") |
| | | public class SysLogininforController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysLogininforService logininforService; |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:logininfor:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysLogininfor logininfor) |
| | | { |
| | | startPage(); |
| | | List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | @Log(title = "ç»éæ¥å¿", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('monitor:logininfor:export')") |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysLogininfor logininfor) |
| | | { |
| | | List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); |
| | | ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class); |
| | | return util.exportExcel(list, "ç»éæ¥å¿"); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')") |
| | | @Log(title = "ç»éæ¥å¿", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{infoIds}") |
| | | public AjaxResult remove(@PathVariable Long[] infoIds) |
| | | { |
| | | return toAjax(logininforService.deleteLogininforByIds(infoIds)); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')") |
| | | @Log(title = "ç»éæ¥å¿", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/clean") |
| | | public AjaxResult clean() |
| | | { |
| | | logininforService.cleanLogininfor(); |
| | | return AjaxResult.success(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.monitor; |
| | | |
| | | 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.system.domain.SysOperLog; |
| | | import com.ruoyi.system.service.ISysOperLogService; |
| | | |
| | | /** |
| | | * æä½æ¥å¿è®°å½ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/monitor/operlog") |
| | | public class SysOperlogController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysOperLogService operLogService; |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:operlog:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysOperLog operLog) |
| | | { |
| | | startPage(); |
| | | List<SysOperLog> list = operLogService.selectOperLogList(operLog); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | @Log(title = "æä½æ¥å¿", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('monitor:operlog:export')") |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysOperLog operLog) |
| | | { |
| | | List<SysOperLog> list = operLogService.selectOperLogList(operLog); |
| | | ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class); |
| | | return util.exportExcel(list, "æä½æ¥å¿"); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:operlog:remove')") |
| | | @DeleteMapping("/{operIds}") |
| | | public AjaxResult remove(@PathVariable Long[] operIds) |
| | | { |
| | | return toAjax(operLogService.deleteOperLogByIds(operIds)); |
| | | } |
| | | |
| | | @Log(title = "æä½æ¥å¿", businessType = BusinessType.CLEAN) |
| | | @PreAuthorize("@ss.hasPermi('monitor:operlog:remove')") |
| | | @DeleteMapping("/clean") |
| | | public AjaxResult clean() |
| | | { |
| | | operLogService.cleanOperLog(); |
| | | return AjaxResult.success(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.monitor; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | 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.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.system.domain.SysUserOnline; |
| | | import com.ruoyi.system.service.ISysUserOnlineService; |
| | | |
| | | /** |
| | | * å¨çº¿ç¨æ·çæ§ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/monitor/online") |
| | | public class SysUserOnlineController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysUserOnlineService userOnlineService; |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:online:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(String ipaddr, String userName) |
| | | { |
| | | Collection<String> keys = redisCache.keys(Constants.LOGIN_TOKEN_KEY + "*"); |
| | | List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>(); |
| | | for (String key : keys) |
| | | { |
| | | LoginUser user = redisCache.getCacheObject(key); |
| | | if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) |
| | | { |
| | | if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) |
| | | { |
| | | userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user)); |
| | | } |
| | | } |
| | | else if (StringUtils.isNotEmpty(ipaddr)) |
| | | { |
| | | if (StringUtils.equals(ipaddr, user.getIpaddr())) |
| | | { |
| | | userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user)); |
| | | } |
| | | } |
| | | else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) |
| | | { |
| | | if (StringUtils.equals(userName, user.getUsername())) |
| | | { |
| | | userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user)); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | userOnlineList.add(userOnlineService.loginUserToUserOnline(user)); |
| | | } |
| | | } |
| | | Collections.reverse(userOnlineList); |
| | | userOnlineList.removeAll(Collections.singleton(null)); |
| | | return getDataTable(userOnlineList); |
| | | } |
| | | |
| | | /** |
| | | * 强éç¨æ· |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')") |
| | | @Log(title = "å¨çº¿ç¨æ·", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{tokenId}") |
| | | public AjaxResult forceLogout(@PathVariable String tokenId) |
| | | { |
| | | redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId); |
| | | return AjaxResult.success(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | 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.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.system.domain.SysConfig; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | |
| | | /** |
| | | * åæ°é
ç½® ä¿¡æ¯æä½å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/config") |
| | | public class SysConfigController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | |
| | | /** |
| | | * è·ååæ°é
ç½®å表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:config:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysConfig config) |
| | | { |
| | | startPage(); |
| | | List<SysConfig> list = configService.selectConfigList(config); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:config:export')") |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysConfig config) |
| | | { |
| | | List<SysConfig> list = configService.selectConfigList(config); |
| | | ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class); |
| | | return util.exportExcel(list, "åæ°æ°æ®"); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®åæ°ç¼å·è·å详ç»ä¿¡æ¯ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:config:query')") |
| | | @GetMapping(value = "/{configId}") |
| | | public AjaxResult getInfo(@PathVariable Long configId) |
| | | { |
| | | return AjaxResult.success(configService.selectConfigById(configId)); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®åæ°é®åæ¥è¯¢åæ°å¼ |
| | | */ |
| | | @GetMapping(value = "/configKey/{configKey}") |
| | | public AjaxResult getConfigKey(@PathVariable String configKey) |
| | | { |
| | | return AjaxResult.success(configService.selectConfigByKey(configKey)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢åæ°é
ç½® |
| | | */ |
| | | @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))) |
| | | { |
| | | return AjaxResult.error("æ°å¢åæ°'" + config.getConfigName() + "'失败ï¼åæ°é®åå·²åå¨"); |
| | | } |
| | | config.setCreateBy(SecurityUtils.getUsername()); |
| | | return toAjax(configService.insertConfig(config)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹åæ°é
ç½® |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:config:edit')") |
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysConfig config) |
| | | { |
| | | if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹åæ°'" + config.getConfigName() + "'失败ï¼åæ°é®åå·²åå¨"); |
| | | } |
| | | config.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(configService.updateConfig(config)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤åæ°é
ç½® |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:config:remove')") |
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{configIds}") |
| | | public AjaxResult remove(@PathVariable Long[] configIds) |
| | | { |
| | | return toAjax(configService.deleteConfigByIds(configIds)); |
| | | } |
| | | |
| | | /** |
| | | * æ¸
空ç¼å |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:config:remove')") |
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/clearCache") |
| | | public AjaxResult clearCache() |
| | | { |
| | | configService.clearCache(); |
| | | return AjaxResult.success(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | 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.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.system.service.ISysDeptService; |
| | | |
| | | /** |
| | | * é¨é¨ä¿¡æ¯ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/dept") |
| | | public class SysDeptController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysDeptService deptService; |
| | | |
| | | /** |
| | | * è·åé¨é¨å表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:list')") |
| | | @GetMapping("/list") |
| | | public AjaxResult list(SysDept dept) |
| | | { |
| | | List<SysDept> depts = deptService.selectDeptList(dept); |
| | | return AjaxResult.success(depts); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢é¨é¨åè¡¨ï¼æé¤èç¹ï¼ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:list')") |
| | | @GetMapping("/list/exclude/{deptId}") |
| | | public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) |
| | | { |
| | | List<SysDept> depts = deptService.selectDeptList(new SysDept()); |
| | | Iterator<SysDept> it = depts.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | SysDept d = (SysDept) it.next(); |
| | | if (d.getDeptId().intValue() == deptId |
| | | || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")) |
| | | { |
| | | it.remove(); |
| | | } |
| | | } |
| | | return AjaxResult.success(depts); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®é¨é¨ç¼å·è·å详ç»ä¿¡æ¯ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:query')") |
| | | @GetMapping(value = "/{deptId}") |
| | | public AjaxResult getInfo(@PathVariable Long deptId) |
| | | { |
| | | return AjaxResult.success(deptService.selectDeptById(deptId)); |
| | | } |
| | | |
| | | /** |
| | | * è·åé¨é¨ä¸ææ å表 |
| | | */ |
| | | @GetMapping("/treeselect") |
| | | public AjaxResult treeselect(SysDept dept) |
| | | { |
| | | List<SysDept> depts = deptService.selectDeptList(dept); |
| | | return AjaxResult.success(deptService.buildDeptTreeSelect(depts)); |
| | | } |
| | | |
| | | /** |
| | | * å 载对åºè§è²é¨é¨å表æ |
| | | */ |
| | | @GetMapping(value = "/roleDeptTreeselect/{roleId}") |
| | | public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId) |
| | | { |
| | | List<SysDept> depts = deptService.selectDeptList(new SysDept()); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); |
| | | ajax.put("depts", deptService.buildDeptTreeSelect(depts)); |
| | | return ajax; |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢é¨é¨ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:add')") |
| | | @Log(title = "é¨é¨ç®¡ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysDept dept) |
| | | { |
| | | if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) |
| | | { |
| | | return AjaxResult.error("æ°å¢é¨é¨'" + dept.getDeptName() + "'失败ï¼é¨é¨åç§°å·²åå¨"); |
| | | } |
| | | dept.setCreateBy(SecurityUtils.getUsername()); |
| | | return toAjax(deptService.insertDept(dept)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹é¨é¨ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:edit')") |
| | | @Log(title = "é¨é¨ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysDept dept) |
| | | { |
| | | if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹é¨é¨'" + dept.getDeptName() + "'失败ï¼é¨é¨åç§°å·²åå¨"); |
| | | } |
| | | else if (dept.getParentId().equals(dept.getDeptId())) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹é¨é¨'" + dept.getDeptName() + "'失败ï¼ä¸çº§é¨é¨ä¸è½æ¯èªå·±"); |
| | | } |
| | | else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) |
| | | && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) |
| | | { |
| | | return AjaxResult.error("该é¨é¨å
嫿ªåç¨çåé¨é¨ï¼"); |
| | | } |
| | | dept.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(deptService.updateDept(dept)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤é¨é¨ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:remove')") |
| | | @Log(title = "é¨é¨ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{deptId}") |
| | | public AjaxResult remove(@PathVariable Long deptId) |
| | | { |
| | | if (deptService.hasChildByDeptId(deptId)) |
| | | { |
| | | return AjaxResult.error("åå¨ä¸çº§é¨é¨,ä¸å
许å é¤"); |
| | | } |
| | | if (deptService.checkDeptExistUser(deptId)) |
| | | { |
| | | return AjaxResult.error("é¨é¨åå¨ç¨æ·,ä¸å
许å é¤"); |
| | | } |
| | | return toAjax(deptService.deleteDeptById(deptId)); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | 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.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.system.service.ISysDictDataService; |
| | | import com.ruoyi.system.service.ISysDictTypeService; |
| | | |
| | | /** |
| | | * æ°æ®åå
¸ä¿¡æ¯ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/dict/data") |
| | | public class SysDictDataController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysDictDataService dictDataService; |
| | | |
| | | @Autowired |
| | | private ISysDictTypeService dictTypeService; |
| | | |
| | | @PreAuthorize("@ss.hasPermi('system:dict:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysDictData dictData) |
| | | { |
| | | startPage(); |
| | | List<SysDictData> list = dictDataService.selectDictDataList(dictData); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | @Log(title = "åå
¸æ°æ®", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:dict:export')") |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysDictData dictData) |
| | | { |
| | | List<SysDictData> list = dictDataService.selectDictDataList(dictData); |
| | | ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class); |
| | | return util.exportExcel(list, "åå
¸æ°æ®"); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢åå
¸æ°æ®è¯¦ç» |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:query')") |
| | | @GetMapping(value = "/{dictCode}") |
| | | public AjaxResult getInfo(@PathVariable Long dictCode) |
| | | { |
| | | return AjaxResult.success(dictDataService.selectDictDataById(dictCode)); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸ç±»åæ¥è¯¢åå
¸æ°æ®ä¿¡æ¯ |
| | | */ |
| | | @GetMapping(value = "/type/{dictType}") |
| | | public AjaxResult dictType(@PathVariable String dictType) |
| | | { |
| | | return AjaxResult.success(dictTypeService.selectDictDataByType(dictType)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢åå
¸ç±»å |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:add')") |
| | | @Log(title = "åå
¸æ°æ®", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysDictData dict) |
| | | { |
| | | dict.setCreateBy(SecurityUtils.getUsername()); |
| | | return toAjax(dictDataService.insertDictData(dict)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¿ååå
¸ç±»å |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:edit')") |
| | | @Log(title = "åå
¸æ°æ®", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysDictData dict) |
| | | { |
| | | dict.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(dictDataService.updateDictData(dict)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤åå
¸ç±»å |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:remove')") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictCodes}") |
| | | public AjaxResult remove(@PathVariable Long[] dictCodes) |
| | | { |
| | | return toAjax(dictDataService.deleteDictDataByIds(dictCodes)); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | 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.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.system.service.ISysDictTypeService; |
| | | |
| | | /** |
| | | * æ°æ®åå
¸ä¿¡æ¯ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/dict/type") |
| | | public class SysDictTypeController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysDictTypeService dictTypeService; |
| | | |
| | | @PreAuthorize("@ss.hasPermi('system:dict:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysDictType dictType) |
| | | { |
| | | startPage(); |
| | | List<SysDictType> list = dictTypeService.selectDictTypeList(dictType); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:dict:export')") |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysDictType dictType) |
| | | { |
| | | List<SysDictType> list = dictTypeService.selectDictTypeList(dictType); |
| | | ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class); |
| | | return util.exportExcel(list, "åå
¸ç±»å"); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢åå
¸ç±»åè¯¦ç» |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:query')") |
| | | @GetMapping(value = "/{dictId}") |
| | | public AjaxResult getInfo(@PathVariable Long dictId) |
| | | { |
| | | return AjaxResult.success(dictTypeService.selectDictTypeById(dictId)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢åå
¸ç±»å |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:add')") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysDictType dict) |
| | | { |
| | | if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) |
| | | { |
| | | return AjaxResult.error("æ°å¢åå
¸'" + dict.getDictName() + "'失败ï¼åå
¸ç±»åå·²åå¨"); |
| | | } |
| | | dict.setCreateBy(SecurityUtils.getUsername()); |
| | | return toAjax(dictTypeService.insertDictType(dict)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹åå
¸ç±»å |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:edit')") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysDictType dict) |
| | | { |
| | | if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹åå
¸'" + dict.getDictName() + "'失败ï¼åå
¸ç±»åå·²åå¨"); |
| | | } |
| | | dict.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(dictTypeService.updateDictType(dict)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤åå
¸ç±»å |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:remove')") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictIds}") |
| | | public AjaxResult remove(@PathVariable Long[] dictIds) |
| | | { |
| | | return toAjax(dictTypeService.deleteDictTypeByIds(dictIds)); |
| | | } |
| | | |
| | | /** |
| | | * æ¸
空ç¼å |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:remove')") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/clearCache") |
| | | public AjaxResult clearCache() |
| | | { |
| | | dictTypeService.clearCache(); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * è·ååå
¸éæ©æ¡å表 |
| | | */ |
| | | @GetMapping("/optionselect") |
| | | public AjaxResult optionselect() |
| | | { |
| | | List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll(); |
| | | return AjaxResult.success(dictTypes); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | 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.web.service.SysLoginService; |
| | | import com.ruoyi.framework.web.service.SysPermissionService; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | |
| | | /** |
| | | * ç»å½éªè¯ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | public class SysLoginController |
| | | { |
| | | @Autowired |
| | | private SysLoginService loginService; |
| | | |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | | @Autowired |
| | | private SysPermissionService permissionService; |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | /** |
| | | * ç»å½æ¹æ³ |
| | | * |
| | | * @param loginBody ç»å½ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | @PostMapping("/login") |
| | | public AjaxResult login(@RequestBody LoginBody loginBody) |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | // çæä»¤ç |
| | | String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), |
| | | loginBody.getUuid()); |
| | | ajax.put(Constants.TOKEN, token); |
| | | return ajax; |
| | | } |
| | | |
| | | /** |
| | | * è·åç¨æ·ä¿¡æ¯ |
| | | * |
| | | * @return ç¨æ·ä¿¡æ¯ |
| | | */ |
| | | @GetMapping("getInfo") |
| | | public AjaxResult getInfo() |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | SysUser user = loginUser.getUser(); |
| | | // è§è²éå |
| | | Set<String> roles = permissionService.getRolePermission(user); |
| | | // æééå |
| | | Set<String> permissions = permissionService.getMenuPermission(user); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("user", user); |
| | | ajax.put("roles", roles); |
| | | ajax.put("permissions", permissions); |
| | | return ajax; |
| | | } |
| | | |
| | | /** |
| | | * è·åè·¯ç±ä¿¡æ¯ |
| | | * |
| | | * @return è·¯ç±ä¿¡æ¯ |
| | | */ |
| | | @GetMapping("getRouters") |
| | | public AjaxResult getRouters() |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | // ç¨æ·ä¿¡æ¯ |
| | | SysUser user = loginUser.getUser(); |
| | | List<SysMenu> menus = menuService.selectMenuTreeByUserId(user.getUserId()); |
| | | return AjaxResult.success(menuService.buildMenus(menus)); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | 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.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.web.service.TokenService; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | |
| | | /** |
| | | * èåä¿¡æ¯ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/menu") |
| | | public class SysMenuController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | /** |
| | | * è·åèåå表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:menu:list')") |
| | | @GetMapping("/list") |
| | | public AjaxResult list(SysMenu menu) |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | Long userId = loginUser.getUser().getUserId(); |
| | | List<SysMenu> menus = menuService.selectMenuList(menu, userId); |
| | | return AjaxResult.success(menus); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®èåç¼å·è·å详ç»ä¿¡æ¯ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:menu:query')") |
| | | @GetMapping(value = "/{menuId}") |
| | | public AjaxResult getInfo(@PathVariable Long menuId) |
| | | { |
| | | return AjaxResult.success(menuService.selectMenuById(menuId)); |
| | | } |
| | | |
| | | /** |
| | | * è·åèå䏿æ å表 |
| | | */ |
| | | @GetMapping("/treeselect") |
| | | public AjaxResult treeselect(SysMenu menu) |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | Long userId = loginUser.getUser().getUserId(); |
| | | List<SysMenu> menus = menuService.selectMenuList(menu, userId); |
| | | return AjaxResult.success(menuService.buildMenuTreeSelect(menus)); |
| | | } |
| | | |
| | | /** |
| | | * å 载对åºè§è²èåå表æ |
| | | */ |
| | | @GetMapping(value = "/roleMenuTreeselect/{roleId}") |
| | | public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId()); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); |
| | | ajax.put("menus", menuService.buildMenuTreeSelect(menus)); |
| | | return ajax; |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢èå |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:menu:add')") |
| | | @Log(title = "èå管ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysMenu menu) |
| | | { |
| | | if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) |
| | | { |
| | | return AjaxResult.error("æ°å¢èå'" + menu.getMenuName() + "'失败ï¼èååç§°å·²åå¨"); |
| | | } |
| | | else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) |
| | | && !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) |
| | | { |
| | | return AjaxResult.error("æ°å¢èå'" + menu.getMenuName() + "'失败ï¼å°åå¿
须以http(s)://å¼å¤´"); |
| | | } |
| | | menu.setCreateBy(SecurityUtils.getUsername()); |
| | | return toAjax(menuService.insertMenu(menu)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹èå |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:menu:edit')") |
| | | @Log(title = "èå管ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysMenu menu) |
| | | { |
| | | if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹èå'" + menu.getMenuName() + "'失败ï¼èååç§°å·²åå¨"); |
| | | } |
| | | else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) |
| | | && !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) |
| | | { |
| | | return AjaxResult.error("æ°å¢èå'" + menu.getMenuName() + "'失败ï¼å°åå¿
须以http(s)://å¼å¤´"); |
| | | } |
| | | menu.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(menuService.updateMenu(menu)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤èå |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:menu:remove')") |
| | | @Log(title = "èå管ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{menuId}") |
| | | public AjaxResult remove(@PathVariable("menuId") Long menuId) |
| | | { |
| | | if (menuService.hasChildByMenuId(menuId)) |
| | | { |
| | | return AjaxResult.error("åå¨åèå,ä¸å
许å é¤"); |
| | | } |
| | | if (menuService.checkMenuExistRole(menuId)) |
| | | { |
| | | return AjaxResult.error("èåå·²åé
,ä¸å
许å é¤"); |
| | | } |
| | | return toAjax(menuService.deleteMenuById(menuId)); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | 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.utils.SecurityUtils; |
| | | import com.ruoyi.system.domain.SysNotice; |
| | | import com.ruoyi.system.service.ISysNoticeService; |
| | | |
| | | /** |
| | | * å
¬å ä¿¡æ¯æä½å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/notice") |
| | | public class SysNoticeController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysNoticeService noticeService; |
| | | |
| | | /** |
| | | * è·åéç¥å
¬åå表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:notice:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysNotice notice) |
| | | { |
| | | startPage(); |
| | | List<SysNotice> list = noticeService.selectNoticeList(notice); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®éç¥å
¬åç¼å·è·å详ç»ä¿¡æ¯ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:notice:query')") |
| | | @GetMapping(value = "/{noticeId}") |
| | | public AjaxResult getInfo(@PathVariable Long noticeId) |
| | | { |
| | | return AjaxResult.success(noticeService.selectNoticeById(noticeId)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢éç¥å
Œ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:notice:add')") |
| | | @Log(title = "éç¥å
Œ", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysNotice notice) |
| | | { |
| | | notice.setCreateBy(SecurityUtils.getUsername()); |
| | | return toAjax(noticeService.insertNotice(notice)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹éç¥å
Œ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:notice:edit')") |
| | | @Log(title = "éç¥å
Œ", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysNotice notice) |
| | | { |
| | | notice.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(noticeService.updateNotice(notice)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤éç¥å
Œ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:notice:remove')") |
| | | @Log(title = "éç¥å
Œ", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{noticeIds}") |
| | | public AjaxResult remove(@PathVariable Long[] noticeIds) |
| | | { |
| | | return toAjax(noticeService.deleteNoticeByIds(noticeIds)); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | 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.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.system.domain.SysPost; |
| | | import com.ruoyi.system.service.ISysPostService; |
| | | |
| | | /** |
| | | * å²ä½ä¿¡æ¯æä½å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/post") |
| | | public class SysPostController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysPostService postService; |
| | | |
| | | /** |
| | | * è·åå²ä½å表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:post:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysPost post) |
| | | { |
| | | startPage(); |
| | | List<SysPost> list = postService.selectPostList(post); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | @Log(title = "å²ä½ç®¡ç", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:post:export')") |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysPost post) |
| | | { |
| | | List<SysPost> list = postService.selectPostList(post); |
| | | ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class); |
| | | return util.exportExcel(list, "å²ä½æ°æ®"); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®å²ä½ç¼å·è·å详ç»ä¿¡æ¯ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:post:query')") |
| | | @GetMapping(value = "/{postId}") |
| | | public AjaxResult getInfo(@PathVariable Long postId) |
| | | { |
| | | return AjaxResult.success(postService.selectPostById(postId)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢å²ä½ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:post:add')") |
| | | @Log(title = "å²ä½ç®¡ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysPost post) |
| | | { |
| | | if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) |
| | | { |
| | | return AjaxResult.error("æ°å¢å²ä½'" + post.getPostName() + "'失败ï¼å²ä½åç§°å·²åå¨"); |
| | | } |
| | | else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) |
| | | { |
| | | return AjaxResult.error("æ°å¢å²ä½'" + post.getPostName() + "'失败ï¼å²ä½ç¼ç å·²åå¨"); |
| | | } |
| | | post.setCreateBy(SecurityUtils.getUsername()); |
| | | return toAjax(postService.insertPost(post)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹å²ä½ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:post:edit')") |
| | | @Log(title = "å²ä½ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysPost post) |
| | | { |
| | | if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹å²ä½'" + post.getPostName() + "'失败ï¼å²ä½åç§°å·²åå¨"); |
| | | } |
| | | else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹å²ä½'" + post.getPostName() + "'失败ï¼å²ä½ç¼ç å·²åå¨"); |
| | | } |
| | | post.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(postService.updatePost(post)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤å²ä½ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:post:remove')") |
| | | @Log(title = "å²ä½ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{postIds}") |
| | | public AjaxResult remove(@PathVariable Long[] postIds) |
| | | { |
| | | return toAjax(postService.deletePostByIds(postIds)); |
| | | } |
| | | |
| | | /** |
| | | * è·åå²ä½éæ©æ¡å表 |
| | | */ |
| | | @GetMapping("/optionselect") |
| | | public AjaxResult optionselect() |
| | | { |
| | | List<SysPost> posts = postService.selectPostAll(); |
| | | return AjaxResult.success(posts); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.io.IOException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | 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.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.web.service.TokenService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | |
| | | /** |
| | | * ä¸ªäººä¿¡æ¯ ä¸å¡å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/user/profile") |
| | | public class SysProfileController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | /** |
| | | * ä¸ªäººä¿¡æ¯ |
| | | */ |
| | | @GetMapping |
| | | public AjaxResult profile() |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | SysUser user = loginUser.getUser(); |
| | | AjaxResult ajax = AjaxResult.success(user); |
| | | ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername())); |
| | | ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername())); |
| | | return ajax; |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ç¨æ· |
| | | */ |
| | | @Log(title = "个人信æ¯", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult updateProfile(@RequestBody SysUser user) |
| | | { |
| | | if (userService.updateUserProfile(user) > 0) |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | // æ´æ°ç¼åç¨æ·ä¿¡æ¯ |
| | | loginUser.getUser().setNickName(user.getNickName()); |
| | | loginUser.getUser().setPhonenumber(user.getPhonenumber()); |
| | | loginUser.getUser().setEmail(user.getEmail()); |
| | | loginUser.getUser().setSex(user.getSex()); |
| | | tokenService.setLoginUser(loginUser); |
| | | return AjaxResult.success(); |
| | | } |
| | | return AjaxResult.error("ä¿®æ¹ä¸ªäººä¿¡æ¯å¼å¸¸ï¼è¯·è系管çå"); |
| | | } |
| | | |
| | | /** |
| | | * éç½®å¯ç |
| | | */ |
| | | @Log(title = "个人信æ¯", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/updatePwd") |
| | | public AjaxResult updatePwd(String oldPassword, String newPassword) |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | String userName = loginUser.getUsername(); |
| | | String password = loginUser.getPassword(); |
| | | if (!SecurityUtils.matchesPassword(oldPassword, password)) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹å¯ç å¤±è´¥ï¼æ§å¯ç é误"); |
| | | } |
| | | if (SecurityUtils.matchesPassword(newPassword, password)) |
| | | { |
| | | return AjaxResult.error("æ°å¯ç ä¸è½ä¸æ§å¯ç ç¸å"); |
| | | } |
| | | if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) |
| | | { |
| | | // æ´æ°ç¼åç¨æ·å¯ç |
| | | loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword)); |
| | | tokenService.setLoginUser(loginUser); |
| | | return AjaxResult.success(); |
| | | } |
| | | return AjaxResult.error("ä¿®æ¹å¯ç å¼å¸¸ï¼è¯·è系管çå"); |
| | | } |
| | | |
| | | /** |
| | | * 头åä¸ä¼ |
| | | */ |
| | | @Log(title = "ç¨æ·å¤´å", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/avatar") |
| | | public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException |
| | | { |
| | | if (!file.isEmpty()) |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file); |
| | | if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("imgUrl", avatar); |
| | | // æ´æ°ç¼åç¨æ·å¤´å |
| | | loginUser.getUser().setAvatar(avatar); |
| | | tokenService.setLoginUser(loginUser); |
| | | return ajax; |
| | | } |
| | | } |
| | | return AjaxResult.error("ä¸ä¼ å¾çå¼å¸¸ï¼è¯·è系管çå"); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | 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.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.system.service.ISysRoleService; |
| | | |
| | | /** |
| | | * è§è²ä¿¡æ¯ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/role") |
| | | public class SysRoleController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | |
| | | @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysRole role) |
| | | { |
| | | startPage(); |
| | | List<SysRole> list = roleService.selectRoleList(role); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:role:export')") |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysRole role) |
| | | { |
| | | List<SysRole> list = roleService.selectRoleList(role); |
| | | ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); |
| | | return util.exportExcel(list, "è§è²æ°æ®"); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®è§è²ç¼å·è·å详ç»ä¿¡æ¯ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | @GetMapping(value = "/{roleId}") |
| | | public AjaxResult getInfo(@PathVariable Long roleId) |
| | | { |
| | | return AjaxResult.success(roleService.selectRoleById(roleId)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢è§è² |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:add')") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysRole role) |
| | | { |
| | | if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) |
| | | { |
| | | return AjaxResult.error("æ°å¢è§è²'" + role.getRoleName() + "'失败ï¼è§è²åç§°å·²åå¨"); |
| | | } |
| | | else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) |
| | | { |
| | | return AjaxResult.error("æ°å¢è§è²'" + role.getRoleName() + "'失败ï¼è§è²æéå·²åå¨"); |
| | | } |
| | | role.setCreateBy(SecurityUtils.getUsername()); |
| | | return toAjax(roleService.insertRole(role)); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¿åè§è² |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysRole role) |
| | | { |
| | | roleService.checkRoleAllowed(role); |
| | | if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹è§è²'" + role.getRoleName() + "'失败ï¼è§è²åç§°å·²åå¨"); |
| | | } |
| | | else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹è§è²'" + role.getRoleName() + "'失败ï¼è§è²æéå·²åå¨"); |
| | | } |
| | | role.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(roleService.updateRole(role)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¿åæ°æ®æé |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/dataScope") |
| | | public AjaxResult dataScope(@RequestBody SysRole role) |
| | | { |
| | | roleService.checkRoleAllowed(role); |
| | | return toAjax(roleService.authDataScope(role)); |
| | | } |
| | | |
| | | /** |
| | | * ç¶æä¿®æ¹ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysRole role) |
| | | { |
| | | roleService.checkRoleAllowed(role); |
| | | role.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(roleService.updateRoleStatus(role)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤è§è² |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:remove')") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{roleIds}") |
| | | public AjaxResult remove(@PathVariable Long[] roleIds) |
| | | { |
| | | return toAjax(roleService.deleteRoleByIds(roleIds)); |
| | | } |
| | | |
| | | /** |
| | | * è·åè§è²éæ©æ¡å表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | @GetMapping("/optionselect") |
| | | public AjaxResult optionselect() |
| | | { |
| | | return AjaxResult.success(roleService.selectRoleAll()); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | 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 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.web.service.TokenService; |
| | | import com.ruoyi.system.service.ISysPostService; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | |
| | | /** |
| | | * ç¨æ·ä¿¡æ¯ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/user") |
| | | public class SysUserController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | |
| | | @Autowired |
| | | private ISysPostService postService; |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | /** |
| | | * è·åç¨æ·å表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysUser user) |
| | | { |
| | | startPage(); |
| | | List<SysUser> list = userService.selectUserList(user); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:user:export')") |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysUser user) |
| | | { |
| | | List<SysUser> list = userService.selectUserList(user); |
| | | ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); |
| | | return util.exportExcel(list, "ç¨æ·æ°æ®"); |
| | | } |
| | | |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.IMPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:user:import')") |
| | | @PostMapping("/importData") |
| | | public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception |
| | | { |
| | | ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); |
| | | List<SysUser> userList = util.importExcel(file.getInputStream()); |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | String operName = loginUser.getUsername(); |
| | | String message = userService.importUser(userList, updateSupport, operName); |
| | | return AjaxResult.success(message); |
| | | } |
| | | |
| | | @GetMapping("/importTemplate") |
| | | public AjaxResult importTemplate() |
| | | { |
| | | ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); |
| | | return util.importTemplateExcel("ç¨æ·æ°æ®"); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·ç¼å·è·å详ç»ä¿¡æ¯ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:query')") |
| | | @GetMapping(value = { "/", "/{userId}" }) |
| | | public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | List<SysRole> roles = roleService.selectRoleAll(); |
| | | ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); |
| | | ajax.put("posts", postService.selectPostAll()); |
| | | if (StringUtils.isNotNull(userId)) |
| | | { |
| | | ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId)); |
| | | ajax.put("postIds", postService.selectPostListByUserId(userId)); |
| | | ajax.put("roleIds", roleService.selectRoleListByUserId(userId)); |
| | | } |
| | | return ajax; |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢ç¨æ· |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:add')") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysUser user) |
| | | { |
| | | if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) |
| | | { |
| | | return AjaxResult.error("æ°å¢ç¨æ·'" + user.getUserName() + "'失败ï¼ç»å½è´¦å·å·²åå¨"); |
| | | } |
| | | else if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) |
| | | { |
| | | return AjaxResult.error("æ°å¢ç¨æ·'" + user.getUserName() + "'å¤±è´¥ï¼ææºå·ç å·²åå¨"); |
| | | } |
| | | else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) |
| | | { |
| | | return AjaxResult.error("æ°å¢ç¨æ·'" + user.getUserName() + "'失败ï¼é®ç®±è´¦å·å·²åå¨"); |
| | | } |
| | | user.setCreateBy(SecurityUtils.getUsername()); |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | return toAjax(userService.insertUser(user)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ç¨æ· |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysUser user) |
| | | { |
| | | userService.checkUserAllowed(user); |
| | | if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'å¤±è´¥ï¼ææºå·ç å·²åå¨"); |
| | | } |
| | | else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'失败ï¼é®ç®±è´¦å·å·²åå¨"); |
| | | } |
| | | user.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(userService.updateUser(user)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤ç¨æ· |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:remove')") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{userIds}") |
| | | public AjaxResult remove(@PathVariable Long[] userIds) |
| | | { |
| | | return toAjax(userService.deleteUserByIds(userIds)); |
| | | } |
| | | |
| | | /** |
| | | * éç½®å¯ç |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/resetPwd") |
| | | public AjaxResult resetPwd(@RequestBody SysUser user) |
| | | { |
| | | userService.checkUserAllowed(user); |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | user.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(userService.resetPwd(user)); |
| | | } |
| | | |
| | | /** |
| | | * ç¶æä¿®æ¹ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysUser user) |
| | | { |
| | | userService.checkUserAllowed(user); |
| | | 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");
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.tool; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | 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.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 io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | | /** |
| | | * swagger ç¨æ·æµè¯æ¹æ³ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Api("ç¨æ·ä¿¡æ¯ç®¡ç") |
| | | @RestController |
| | | @RequestMapping("/test/user") |
| | | public class TestController extends BaseController |
| | | { |
| | | private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>(); |
| | | { |
| | | users.put(1, new UserEntity(1, "admin", "admin123", "15888888888")); |
| | | users.put(2, new UserEntity(2, "ry", "admin123", "15666666666")); |
| | | } |
| | | |
| | | @ApiOperation("è·åç¨æ·å表") |
| | | @GetMapping("/list") |
| | | public AjaxResult userList() |
| | | { |
| | | List<UserEntity> userList = new ArrayList<UserEntity>(users.values()); |
| | | return AjaxResult.success(userList); |
| | | } |
| | | |
| | | @ApiOperation("è·åç¨æ·è¯¦ç»") |
| | | @ApiImplicitParam(name = "userId", value = "ç¨æ·ID", required = true, dataType = "int", paramType = "path") |
| | | @GetMapping("/{userId}") |
| | | public AjaxResult getUser(@PathVariable Integer userId) |
| | | { |
| | | if (!users.isEmpty() && users.containsKey(userId)) |
| | | { |
| | | return AjaxResult.success(users.get(userId)); |
| | | } |
| | | else |
| | | { |
| | | return AjaxResult.error("ç¨æ·ä¸åå¨"); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation("æ°å¢ç¨æ·") |
| | | @ApiImplicitParam(name = "userEntity", value = "æ°å¢ç¨æ·ä¿¡æ¯", dataType = "UserEntity") |
| | | @PostMapping("/save") |
| | | public AjaxResult save(UserEntity user) |
| | | { |
| | | if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) |
| | | { |
| | | return AjaxResult.error("ç¨æ·IDä¸è½ä¸ºç©º"); |
| | | } |
| | | return AjaxResult.success(users.put(user.getUserId(), user)); |
| | | } |
| | | |
| | | @ApiOperation("æ´æ°ç¨æ·") |
| | | @ApiImplicitParam(name = "userEntity", value = "æ°å¢ç¨æ·ä¿¡æ¯", dataType = "UserEntity") |
| | | @PutMapping("/update") |
| | | public AjaxResult update(UserEntity user) |
| | | { |
| | | if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) |
| | | { |
| | | return AjaxResult.error("ç¨æ·IDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (users.isEmpty() || !users.containsKey(user.getUserId())) |
| | | { |
| | | return AjaxResult.error("ç¨æ·ä¸åå¨"); |
| | | } |
| | | users.remove(user.getUserId()); |
| | | return AjaxResult.success(users.put(user.getUserId(), user)); |
| | | } |
| | | |
| | | @ApiOperation("å é¤ç¨æ·ä¿¡æ¯") |
| | | @ApiImplicitParam(name = "userId", value = "ç¨æ·ID", required = true, dataType = "int", paramType = "path") |
| | | @DeleteMapping("/{userId}") |
| | | public AjaxResult delete(@PathVariable Integer userId) |
| | | { |
| | | if (!users.isEmpty() && users.containsKey(userId)) |
| | | { |
| | | users.remove(userId); |
| | | return AjaxResult.success(); |
| | | } |
| | | else |
| | | { |
| | | return AjaxResult.error("ç¨æ·ä¸åå¨"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @ApiModel("ç¨æ·å®ä½") |
| | | class UserEntity |
| | | { |
| | | @ApiModelProperty("ç¨æ·ID") |
| | | private Integer userId; |
| | | |
| | | @ApiModelProperty("ç¨æ·åç§°") |
| | | private String username; |
| | | |
| | | @ApiModelProperty("ç¨æ·å¯ç ") |
| | | private String password; |
| | | |
| | | @ApiModelProperty("ç¨æ·ææº") |
| | | private String mobile; |
| | | |
| | | public UserEntity() |
| | | { |
| | | |
| | | } |
| | | |
| | | public UserEntity(Integer userId, String username, String password, String mobile) |
| | | { |
| | | this.userId = userId; |
| | | this.username = username; |
| | | this.password = password; |
| | | this.mobile = mobile; |
| | | } |
| | | |
| | | public Integer getUserId() |
| | | { |
| | | return userId; |
| | | } |
| | | |
| | | public void setUserId(Integer userId) |
| | | { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public String getUsername() |
| | | { |
| | | return username; |
| | | } |
| | | |
| | | public void setUsername(String username) |
| | | { |
| | | this.username = username; |
| | | } |
| | | |
| | | public String getPassword() |
| | | { |
| | | return password; |
| | | } |
| | | |
| | | public void setPassword(String password) |
| | | { |
| | | this.password = password; |
| | | } |
| | | |
| | | public String getMobile() |
| | | { |
| | | return mobile; |
| | | } |
| | | |
| | | public void setMobile(String mobile) |
| | | { |
| | | this.mobile = mobile; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.core.config; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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; |
| | | import springfox.documentation.builders.RequestHandlerSelectors; |
| | | import springfox.documentation.service.ApiInfo; |
| | | import springfox.documentation.service.ApiKey; |
| | | import springfox.documentation.service.AuthorizationScope; |
| | | import springfox.documentation.service.Contact; |
| | | import springfox.documentation.service.SecurityReference; |
| | | import springfox.documentation.spi.DocumentationType; |
| | | import springfox.documentation.spi.service.contexts.SecurityContext; |
| | | import springfox.documentation.spring.web.plugins.Docket; |
| | | import springfox.documentation.swagger2.annotations.EnableSwagger2; |
| | | |
| | | /** |
| | | * Swagger2çæ¥å£é
ç½® |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Configuration |
| | | @EnableSwagger2 |
| | | public class SwaggerConfig |
| | | { |
| | | /** ç³»ç»åºç¡é
ç½® */ |
| | | @Autowired |
| | | private RuoYiConfig ruoyiConfig; |
| | | |
| | | /** æ¯å¦å¼å¯swagger */ |
| | | @Value("${swagger.enabled}") |
| | | private boolean enabled; |
| | | |
| | | /** 设置请æ±çç»ä¸åç¼ */ |
| | | @Value("${swagger.pathMapping}") |
| | | private String pathMapping; |
| | | |
| | | /** |
| | | * å建API |
| | | */ |
| | | @Bean |
| | | public Docket createRestApi() |
| | | { |
| | | return new Docket(DocumentationType.SWAGGER_2) |
| | | // æ¯å¦å¯ç¨Swagger |
| | | .enable(enabled) |
| | | // ç¨æ¥å建该APIçåºæ¬ä¿¡æ¯ï¼å±ç¤ºå¨ææ¡£ç页é¢ä¸ï¼èªå®ä¹å±ç¤ºçä¿¡æ¯ï¼ |
| | | .apiInfo(apiInfo()) |
| | | // 设置åªäºæ¥å£æ´é²ç»Swaggerå±ç¤º |
| | | .select() |
| | | // æ«æææææ³¨è§£çapiï¼ç¨è¿ç§æ¹å¼æ´çµæ´» |
| | | .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
| | | // æ«ææå®å
ä¸çswagger注解 |
| | | // .apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger")) |
| | | // æ«æææ .apis(RequestHandlerSelectors.any()) |
| | | .paths(PathSelectors.any()) |
| | | .build() |
| | | /* 设置å®å
¨æ¨¡å¼ï¼swaggerå¯ä»¥è®¾ç½®è®¿é®token */ |
| | | .securitySchemes(securitySchemes()) |
| | | .securityContexts(securityContexts()) |
| | | .pathMapping(pathMapping); |
| | | } |
| | | |
| | | /** |
| | | * å®å
¨æ¨¡å¼ï¼è¿éæå®tokenéè¿Authorization头请æ±å¤´ä¼ é |
| | | */ |
| | | private List<ApiKey> securitySchemes() |
| | | { |
| | | List<ApiKey> apiKeyList = new ArrayList<ApiKey>(); |
| | | apiKeyList.add(new ApiKey("Authorization", "Authorization", "header")); |
| | | return apiKeyList; |
| | | } |
| | | |
| | | /** |
| | | * å®å
¨ä¸ä¸æ |
| | | */ |
| | | private List<SecurityContext> securityContexts() |
| | | { |
| | | List<SecurityContext> securityContexts = new ArrayList<>(); |
| | | securityContexts.add( |
| | | SecurityContext.builder() |
| | | .securityReferences(defaultAuth()) |
| | | .forPaths(PathSelectors.regex("^(?!auth).*$")) |
| | | .build()); |
| | | return securityContexts; |
| | | } |
| | | |
| | | /** |
| | | * é»è®¤çå®å
¨ä¸å¼ç¨ |
| | | */ |
| | | private List<SecurityReference> defaultAuth() |
| | | { |
| | | AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); |
| | | AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; |
| | | authorizationScopes[0] = authorizationScope; |
| | | List<SecurityReference> securityReferences = new ArrayList<>(); |
| | | securityReferences.add(new SecurityReference("Authorization", authorizationScopes)); |
| | | return securityReferences; |
| | | } |
| | | |
| | | /** |
| | | * æ·»å æè¦ä¿¡æ¯ |
| | | */ |
| | | private ApiInfo apiInfo() |
| | | { |
| | | // ç¨ApiInfoBuilderè¿è¡å®å¶ |
| | | return new ApiInfoBuilder() |
| | | // 设置æ é¢ |
| | | .title("æ é¢ï¼è¥ä¾ç®¡çç³»ç»_æ¥å£ææ¡£") |
| | | // æè¿° |
| | | .description("æè¿°ï¼ç¨äºç®¡çé墿ä¸å
¬å¸ç人åä¿¡æ¯,å
·ä½å
æ¬XXX,XXX模å...") |
| | | // ä½è
ä¿¡æ¯ |
| | | .contact(new Contact(ruoyiConfig.getName(), null, null)) |
| | | // çæ¬ |
| | | .version("çæ¬å·:" + ruoyiConfig.getVersion()) |
| | | .build(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | # æ°æ®æºé
ç½® |
| | | spring: |
| | | datasource: |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | driverClassName: com.mysql.cj.jdbc.Driver |
| | | druid: |
| | | # ä¸»åºæ°æ®æº |
| | | master: |
| | | url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true |
| | | username: root |
| | | password: root |
| | | # ä»åºæ°æ®æº |
| | | slave: |
| | | # 仿°æ®æºå¼å
³/é»è®¤å
³é |
| | | enabled: false |
| | | url: |
| | | username: |
| | | password: |
| | | # åå§è¿æ¥æ° |
| | | initialSize: 5 |
| | | # æå°è¿æ¥æ± æ°é |
| | | minIdle: 10 |
| | | # æå¤§è¿æ¥æ± æ°é |
| | | maxActive: 20 |
| | | # é
ç½®è·åè¿æ¥çå¾
è¶
æ¶çæ¶é´ |
| | | maxWait: 60000 |
| | | # é
ç½®é´éå¤ä¹
æè¿è¡ä¸æ¬¡æ£æµï¼æ£æµéè¦å
³éç空é²è¿æ¥ï¼å使¯æ¯«ç§ |
| | | timeBetweenEvictionRunsMillis: 60000 |
| | | # é
ç½®ä¸ä¸ªè¿æ¥å¨æ± 䏿å°çåçæ¶é´ï¼å使¯æ¯«ç§ |
| | | minEvictableIdleTimeMillis: 300000 |
| | | # é
ç½®ä¸ä¸ªè¿æ¥å¨æ± 䏿大çåçæ¶é´ï¼å使¯æ¯«ç§ |
| | | maxEvictableIdleTimeMillis: 900000 |
| | | # é
ç½®æ£æµè¿æ¥æ¯å¦ææ |
| | | validationQuery: SELECT 1 FROM DUAL |
| | | testWhileIdle: true |
| | | testOnBorrow: false |
| | | testOnReturn: false |
| | | webStatFilter: |
| | | enabled: true |
| | | statViewServlet: |
| | | enabled: true |
| | | # 设置ç½ååï¼ä¸å¡«åå
许ææè®¿é® |
| | | allow: |
| | | url-pattern: /druid/* |
| | | # æ§å¶å°ç®¡çç¨æ·ååå¯ç |
| | | login-username: |
| | | login-password: |
| | | filter: |
| | | stat: |
| | | enabled: true |
| | | # æ
¢SQLè®°å½ |
| | | log-slow-sql: true |
| | | slow-sql-millis: 1000 |
| | | merge-sql: true |
| | | wall: |
| | | config: |
| | | multi-statement-allow: true |
| | | # redis é
ç½® |
| | | redis: |
| | | # å°å |
| | | host: 192.168.0.222 |
| | | # 端å£ï¼é»è®¤ä¸º6379 |
| | | port: 6379 |
| | | # å¯ç |
| | | password: |
| | | # è¿æ¥è¶
æ¶æ¶é´ |
| | | timeout: 10s |
| | | lettuce: |
| | | pool: |
| | | # è¿æ¥æ± ä¸çæå°ç©ºé²è¿æ¥ |
| | | min-idle: 0 |
| | | # è¿æ¥æ± ä¸çæå¤§ç©ºé²è¿æ¥ |
| | | max-idle: 8 |
| | | # è¿æ¥æ± çæå¤§æ°æ®åºè¿æ¥æ° |
| | | max-active: 8 |
| | | # #è¿æ¥æ± æå¤§é»å¡çå¾
æ¶é´ï¼ä½¿ç¨è´å¼è¡¨ç¤ºæ²¡æéå¶ï¼ |
| | | max-wait: -1ms |
¶Ô±ÈÐÂÎļþ |
| | |
| | | # 项ç®ç¸å
³é
ç½® |
| | | ruoyi: |
| | | # åç§° |
| | | name: RuoYi |
| | | # çæ¬ |
| | | version: 3.0.0 |
| | | # çæå¹´ä»½ |
| | | copyrightYear: 2019 |
| | | # å®ä¾æ¼ç¤ºå¼å
³ |
| | | demoEnabled: true |
| | | # æä»¶è·¯å¾ 示ä¾ï¼ Windowsé
ç½®D:/ruoyi/uploadPathï¼Linuxé
ç½® /home/ruoyi/uploadPathï¼ |
| | | profile: D:/ruoyi/uploadPath |
| | | # è·åipå°åå¼å
³ |
| | | addressEnabled: false |
| | | |
| | | # å¼åç¯å¢é
ç½® |
| | | server: |
| | | # æå¡å¨çHTTP端å£ï¼é»è®¤ä¸º8080 |
| | | port: 8081 |
| | | servlet: |
| | | # åºç¨ç访é®è·¯å¾ |
| | | context-path: / |
| | | undertow: |
| | | # 设置IOçº¿ç¨æ°, å®ä¸»è¦æ§è¡éé»å¡çä»»å¡,å®ä»¬ä¼è´è´£å¤ä¸ªè¿æ¥, é»è®¤è®¾ç½®æ¯ä¸ªCPUæ ¸å¿ä¸ä¸ªçº¿ç¨ |
| | | io-threads: 8 |
| | | # é»å¡ä»»å¡çº¿ç¨æ± , 彿§è¡ç±»ä¼¼servlet请æ±é»å¡æä½, undertowä¼ä»è¿ä¸ªçº¿ç¨æ± ä¸åå¾çº¿ç¨,å®çå¼è®¾ç½®åå³äºç³»ç»çè´è½½ |
| | | worker-threads: 256 |
| | | # 以ä¸çé
ç½®ä¼å½±åbuffer,è¿äºbufferä¼ç¨äºæå¡å¨è¿æ¥çIOæä½,æç¹ç±»ä¼¼nettyçæ± åå
å管ç |
| | | # æ¯åbufferç空é´å¤§å°,è¶å°ç空é´è¢«å©ç¨è¶å
å |
| | | buffer-size: 512 |
| | | # æ¯å¦åé
çç´æ¥å
å |
| | | direct-buffers: true |
| | | |
| | | |
| | | # æ¥å¿é
ç½® |
| | | logging: |
| | | level: |
| | | com.ruoyi: debug |
| | | org.springframework: warn |
| | | |
| | | # Springé
ç½® |
| | | spring: |
| | | # èµæºä¿¡æ¯ |
| | | messages: |
| | | # å½é
åèµæºæä»¶è·¯å¾ |
| | | basename: i18n/messages |
| | | profiles: |
| | | active: dev |
| | | # æä»¶ä¸ä¼ |
| | | servlet: |
| | | multipart: |
| | | # å个æä»¶å¤§å° |
| | | max-file-size: 10MB |
| | | # 设置æ»ä¸ä¼ çæä»¶å¤§å° |
| | | max-request-size: 20MB |
| | | # æå¡æ¨¡å |
| | | devtools: |
| | | restart: |
| | | # çé¨ç½²å¼å
³ |
| | | enabled: true |
| | | |
| | | # tokené
ç½® |
| | | token: |
| | | # 令çèªå®ä¹æ è¯ |
| | | header: Authorization |
| | | # 令çå¯é¥ |
| | | secret: abcdefghijklmnopqrstuvwxyz |
| | | # ä»¤çæææï¼é»è®¤30åéï¼ |
| | | expireTime: 30 |
| | | |
| | | # MyBatisé
ç½® |
| | | mybatis-plus: |
| | | mapper-locations: classpath*:mapper/**/*Mapper.xml |
| | | #å®ä½æ«æï¼å¤ä¸ªpackageç¨éå·æè
åå·åé |
| | | typeAliasesPackage: com.ruoyi.**.domain |
| | | configuration: |
| | | map-underscore-to-camel-case: true |
| | | cache-enabled: true |
| | | global-config: |
| | | banner: false |
| | | #å·æ°mapper è°è¯ç¥å¨ |
| | | refresh: true |
| | | db-config: |
| | | #主é®ç±»å 0:"æ°æ®åºIDèªå¢", 1:"ç¨æ·è¾å
¥ID",2:"å
¨å±å¯ä¸ID (æ°åç±»åå¯ä¸ID)", 3:"å
¨å±å¯ä¸ID UUID"; |
| | | id-type: auto |
| | | #åæ®µçç¥ 0:"忽ç¥å¤æ",1:"é NULL 夿"),2:"éç©ºå¤æ" |
| | | field-strategy: not_empty |
| | | #驼峰ä¸åçº¿è½¬æ¢ |
| | | db-column-underline: true |
| | | #æ°æ®åºå¤§åä¸åçº¿è½¬æ¢ |
| | | #capital-mode: true |
| | | #åºåæ¥å£å®ç°ç±»é
ç½® |
| | | #key-generator: com.baomidou.springboot.xxx |
| | | #é»è¾å é¤é
ç½® |
| | | logic-delete-value: 1 |
| | | logic-not-delete-value: 0 |
| | | #æ°æ®åºç±»å |
| | | db-type: mysql |
| | | #èªå®ä¹SQL注å
¥å¨ |
| | | #sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector |
| | | #èªå®ä¹å¡«å
çç¥æ¥å£å®ç° |
| | | #meta-object-handler: com.baomidou.springboot.xxx |
| | | |
| | | # PageHelperå页æä»¶ |
| | | pagehelper: |
| | | helperDialect: mysql |
| | | reasonable: true |
| | | supportMethodsArguments: true |
| | | params: count=countSql |
| | | |
| | | # Swaggeré
ç½® |
| | | swagger: |
| | | # æ¯å¦å¼å¯swagger |
| | | enabled: true |
| | | # 请æ±åç¼ |
| | | pathMapping: /dev-api |
| | | |
| | | # 鲿¢XSSæ»å» |
| | | xss: |
| | | # è¿æ»¤å¼å
³ |
| | | enabled: true |
| | | # æé¤é¾æ¥ï¼å¤ä¸ªç¨éå·åéï¼ |
| | | excludes: /system/notice/* |
| | | # å¹é
龿¥ |
| | | urlPatterns: /system/*,/monitor/*,/tool/* |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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>
|
| | |
|
| | | <dependency>
|
| | | <groupId>com.baomidou</groupId>
|
| | | <artifactId>mybatis-plus-boot-starter</artifactId>
|
| | | </dependency>
|
| | | <dependency>
|
| | | <groupId>com.baomidou</groupId>
|
| | | <artifactId>mybatis-plus-extension</artifactId>
|
| | | </dependency>
|
| | | <dependency>
|
| | | <groupId>cn.hutool</groupId>
|
| | | <artifactId>hutool-all</artifactId>
|
| | | </dependency>
|
| | | <dependency>
|
| | | <groupId>org.projectlombok</groupId>
|
| | | <artifactId>lombok</artifactId>
|
| | | </dependency>
|
| | |
|
| | | </dependencies>
|
| | |
|
| | | </project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | |
| | | /** |
| | | * æ°æ®æéè¿æ»¤æ³¨è§£ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Target(ElementType.METHOD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | public @interface DataScope |
| | | { |
| | | /** |
| | | * é¨é¨è¡¨çå«å |
| | | */ |
| | | public String deptAlias() default ""; |
| | | |
| | | /** |
| | | * ç¨æ·è¡¨çå«å |
| | | */ |
| | | public String userAlias() default ""; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | import com.ruoyi.common.enums.DataSourceType; |
| | | |
| | | /** |
| | | * èªå®ä¹å¤æ°æ®æºåæ¢æ³¨è§£ |
| | | * |
| | | * ä¼å
级ï¼å
æ¹æ³ï¼åç±»ï¼å¦ææ¹æ³è¦çäºç±»ä¸çæ°æ®æºç±»åï¼ä»¥æ¹æ³ç为åï¼å¦å以类ä¸ç为å |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Target({ ElementType.METHOD, ElementType.TYPE }) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | @Inherited |
| | | public @interface DataSource |
| | | { |
| | | /** |
| | | * åæ¢æ°æ®æºåç§° |
| | | */ |
| | | public DataSourceType value() default DataSourceType.MASTER; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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;
|
| | | }
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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();
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.common.enums.BusinessType; |
| | | import com.ruoyi.common.enums.OperatorType; |
| | | |
| | | /** |
| | | * èªå®ä¹æä½æ¥å¿è®°å½æ³¨è§£ |
| | | * |
| | | * @author ruoyi |
| | | * |
| | | */ |
| | | @Target({ ElementType.PARAMETER, ElementType.METHOD }) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | public @interface Log |
| | | { |
| | | /** |
| | | * 模å |
| | | */ |
| | | public String title() default ""; |
| | | |
| | | /** |
| | | * åè½ |
| | | */ |
| | | public BusinessType businessType() default BusinessType.OTHER; |
| | | |
| | | /** |
| | | * æä½äººç±»å« |
| | | */ |
| | | public OperatorType operatorType() default OperatorType.MANAGE; |
| | | |
| | | /** |
| | | * æ¯å¦ä¿å请æ±çåæ° |
| | | */ |
| | | public boolean isSaveRequestData() default true; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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
|
| | | {
|
| | |
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.config; |
| | | |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 读å项ç®ç¸å
³é
ç½® |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | @ConfigurationProperties(prefix = "ruoyi") |
| | | public class RuoYiConfig |
| | | { |
| | | /** 项ç®åç§° */ |
| | | private String name; |
| | | |
| | | /** çæ¬ */ |
| | | private String version; |
| | | |
| | | /** çæå¹´ä»½ */ |
| | | private String copyrightYear; |
| | | |
| | | /** å®ä¾æ¼ç¤ºå¼å
³ */ |
| | | private boolean demoEnabled; |
| | | |
| | | /** ä¸ä¼ è·¯å¾ */ |
| | | private static String profile; |
| | | |
| | | /** è·åå°åå¼å
³ */ |
| | | private static boolean addressEnabled; |
| | | |
| | | public String getName() |
| | | { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) |
| | | { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getVersion() |
| | | { |
| | | return version; |
| | | } |
| | | |
| | | public void setVersion(String version) |
| | | { |
| | | this.version = version; |
| | | } |
| | | |
| | | public String getCopyrightYear() |
| | | { |
| | | return copyrightYear; |
| | | } |
| | | |
| | | public void setCopyrightYear(String copyrightYear) |
| | | { |
| | | this.copyrightYear = copyrightYear; |
| | | } |
| | | |
| | | public boolean isDemoEnabled() |
| | | { |
| | | return demoEnabled; |
| | | } |
| | | |
| | | public void setDemoEnabled(boolean demoEnabled) |
| | | { |
| | | this.demoEnabled = demoEnabled; |
| | | } |
| | | |
| | | public static String getProfile() |
| | | { |
| | | return profile; |
| | | } |
| | | |
| | | public void setProfile(String profile) |
| | | { |
| | | RuoYiConfig.profile = profile; |
| | | } |
| | | |
| | | public static boolean isAddressEnabled() |
| | | { |
| | | return addressEnabled; |
| | | } |
| | | |
| | | public void setAddressEnabled(boolean addressEnabled) |
| | | { |
| | | RuoYiConfig.addressEnabled = addressEnabled; |
| | | } |
| | | |
| | | /** |
| | | * è·å头åä¸ä¼ è·¯å¾ |
| | | */ |
| | | public static String getAvatarPath() |
| | | { |
| | | return getProfile() + "/avatar"; |
| | | } |
| | | |
| | | /** |
| | | * è·åä¸è½½è·¯å¾ |
| | | */ |
| | | public static String getDownloadPath() |
| | | { |
| | | return getProfile() + "/download/"; |
| | | } |
| | | |
| | | /** |
| | | * è·åä¸ä¼ è·¯å¾ |
| | | */ |
| | | public static String getUploadPath() |
| | | { |
| | | return getProfile() + "/upload"; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.constant; |
| | | |
| | | /** |
| | | * éç¨å¸¸éä¿¡æ¯ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class Constants |
| | | { |
| | | /** |
| | | * UTF-8 å符é |
| | | */ |
| | | public static final String UTF8 = "UTF-8"; |
| | | |
| | | /** |
| | | * GBK å符é |
| | | */ |
| | | public static final String GBK = "GBK"; |
| | | |
| | | /** |
| | | * httpè¯·æ± |
| | | */ |
| | | public static final String HTTP = "http://"; |
| | | |
| | | /** |
| | | * httpsè¯·æ± |
| | | */ |
| | | public static final String HTTPS = "https://"; |
| | | |
| | | /** |
| | | * éç¨æåæ è¯ |
| | | */ |
| | | public static final String SUCCESS = "0"; |
| | | |
| | | /** |
| | | * éç¨å¤±è´¥æ è¯ |
| | | */ |
| | | public static final String FAIL = "1"; |
| | | |
| | | /** |
| | | * ç»å½æå |
| | | */ |
| | | public static final String LOGIN_SUCCESS = "Success"; |
| | | |
| | | /** |
| | | * 注é |
| | | */ |
| | | public static final String LOGOUT = "Logout"; |
| | | |
| | | /** |
| | | * ç»å½å¤±è´¥ |
| | | */ |
| | | public static final String LOGIN_FAIL = "Error"; |
| | | |
| | | /** |
| | | * éªè¯ç redis key |
| | | */ |
| | | public static final String CAPTCHA_CODE_KEY = "captcha_codes:"; |
| | | |
| | | /** |
| | | * ç»å½ç¨æ· redis key |
| | | */ |
| | | public static final String LOGIN_TOKEN_KEY = "login_tokens:"; |
| | | |
| | | /** |
| | | * éªè¯ç æææï¼åéï¼ |
| | | */ |
| | | public static final Integer CAPTCHA_EXPIRATION = 2; |
| | | |
| | | /** |
| | | * 令ç |
| | | */ |
| | | public static final String TOKEN = "token"; |
| | | |
| | | /** |
| | | * 令çåç¼ |
| | | */ |
| | | public static final String TOKEN_PREFIX = "Bearer "; |
| | | |
| | | /** |
| | | * 令çåç¼ |
| | | */ |
| | | public static final String LOGIN_USER_KEY = "login_user_key"; |
| | | |
| | | /** |
| | | * ç¨æ·ID |
| | | */ |
| | | public static final String JWT_USERID = "userid"; |
| | | |
| | | /** |
| | | * ç¨æ·åç§° |
| | | */ |
| | | public static final String JWT_USERNAME = "sub"; |
| | | |
| | | /** |
| | | * ç¨æ·å¤´å |
| | | */ |
| | | public static final String JWT_AVATAR = "avatar"; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | public static final String JWT_CREATED = "created"; |
| | | |
| | | /** |
| | | * ç¨æ·æé |
| | | */ |
| | | public static final String JWT_AUTHORITIES = "authorities"; |
| | | |
| | | /** |
| | | * åæ°ç®¡ç cache key |
| | | */ |
| | | public static final String SYS_CONFIG_KEY = "sys_config:"; |
| | | |
| | | /** |
| | | * åå
¸ç®¡ç cache key |
| | | */ |
| | | public static final String SYS_DICT_KEY = "sys_dict:"; |
| | | |
| | | /** |
| | | * èµæºæ å°è·¯å¾ åç¼ |
| | | */ |
| | | public static final String RESOURCE_PREFIX = "/profile"; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.core.controller; |
| | | |
| | | import java.beans.PropertyEditorSupport; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.web.bind.WebDataBinder; |
| | | import org.springframework.web.bind.annotation.InitBinder; |
| | | 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; |
| | | |
| | | /** |
| | | * webå±éç¨æ°æ®å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class BaseController |
| | | { |
| | | protected final Logger logger = LoggerFactory.getLogger(BaseController.class); |
| | | |
| | | /** |
| | | * å°åå°ä¼ éè¿æ¥çæ¥ææ ¼å¼çå符串ï¼èªå¨è½¬å为Dateç±»å |
| | | */ |
| | | @InitBinder |
| | | public void initBinder(WebDataBinder binder) |
| | | { |
| | | // Date ç±»åè½¬æ¢ |
| | | binder.registerCustomEditor(Date.class, new PropertyEditorSupport() |
| | | { |
| | | @Override |
| | | public void setAsText(String text) |
| | | { |
| | | setValue(DateUtils.parseDate(text)); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 设置请æ±åé¡µæ°æ® |
| | | */ |
| | | protected void startPage() |
| | | { |
| | | PageDomain pageDomain = TableSupport.buildPageRequest(); |
| | | Integer pageNum = pageDomain.getPageNum(); |
| | | Integer pageSize = pageDomain.getPageSize(); |
| | | if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) |
| | | { |
| | | String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); |
| | | PageHelper.startPage(pageNum, pageSize, orderBy); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ååºè¯·æ±åé¡µæ°æ® |
| | | */ |
| | | @SuppressWarnings({ "rawtypes", "unchecked" }) |
| | | protected TableDataInfo getDataTable(List<?> list) |
| | | { |
| | | TableDataInfo rspData = new TableDataInfo(); |
| | | rspData.setCode(HttpStatus.SUCCESS); |
| | | rspData.setMsg("æ¥è¯¢æå"); |
| | | rspData.setRows(list); |
| | | rspData.setTotal(new PageInfo(list).getTotal()); |
| | | return rspData; |
| | | } |
| | | |
| | | /** |
| | | * ååºè¿åç»æ |
| | | * |
| | | * @param rows å½±åè¡æ° |
| | | * @return æä½ç»æ |
| | | */ |
| | | protected AjaxResult toAjax(int rows) |
| | | { |
| | | return rows > 0 ? AjaxResult.success() : AjaxResult.error(); |
| | | } |
| | | |
| | | /** |
| | | * 页é¢è·³è½¬ |
| | | */ |
| | | public String redirect(String url) |
| | | { |
| | | return StringUtils.format("redirect:{}", url); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.domain; |
| | | |
| | | import java.util.HashMap; |
| | | import com.ruoyi.common.constant.HttpStatus; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | /** |
| | | * æä½æ¶æ¯æé |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class AjaxResult extends HashMap<String, Object> |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** ç¶æç */ |
| | | public static final String CODE_TAG = "code"; |
| | | |
| | | /** è¿åå
容 */ |
| | | public static final String MSG_TAG = "msg"; |
| | | |
| | | /** æ°æ®å¯¹è±¡ */ |
| | | public static final String DATA_TAG = "data"; |
| | | |
| | | /** |
| | | * åå§åä¸ä¸ªæ°å建ç AjaxResult 对象ï¼ä½¿å
¶è¡¨ç¤ºä¸ä¸ªç©ºæ¶æ¯ã |
| | | */ |
| | | public AjaxResult() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * åå§åä¸ä¸ªæ°å建ç AjaxResult 对象 |
| | | * |
| | | * @param code ç¶æç |
| | | * @param msg è¿åå
容 |
| | | */ |
| | | public AjaxResult(int code, String msg) |
| | | { |
| | | super.put(CODE_TAG, code); |
| | | super.put(MSG_TAG, msg); |
| | | } |
| | | |
| | | /** |
| | | * åå§åä¸ä¸ªæ°å建ç AjaxResult 对象 |
| | | * |
| | | * @param code ç¶æç |
| | | * @param msg è¿åå
容 |
| | | * @param data æ°æ®å¯¹è±¡ |
| | | */ |
| | | public AjaxResult(int code, String msg, Object data) |
| | | { |
| | | super.put(CODE_TAG, code); |
| | | super.put(MSG_TAG, msg); |
| | | if (StringUtils.isNotNull(data)) |
| | | { |
| | | super.put(DATA_TAG, data); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è¿åæåæ¶æ¯ |
| | | * |
| | | * @return æåæ¶æ¯ |
| | | */ |
| | | public static AjaxResult success() |
| | | { |
| | | return AjaxResult.success("æä½æå"); |
| | | } |
| | | |
| | | /** |
| | | * è¿åæåæ°æ® |
| | | * |
| | | * @return æåæ¶æ¯ |
| | | */ |
| | | public static AjaxResult success(Object data) |
| | | { |
| | | return AjaxResult.success("æä½æå", data); |
| | | } |
| | | |
| | | /** |
| | | * è¿åæåæ¶æ¯ |
| | | * |
| | | * @param msg è¿åå
容 |
| | | * @return æåæ¶æ¯ |
| | | */ |
| | | public static AjaxResult success(String msg) |
| | | { |
| | | return AjaxResult.success(msg, null); |
| | | } |
| | | |
| | | /** |
| | | * è¿åæåæ¶æ¯ |
| | | * |
| | | * @param msg è¿åå
容 |
| | | * @param data æ°æ®å¯¹è±¡ |
| | | * @return æåæ¶æ¯ |
| | | */ |
| | | public static AjaxResult success(String msg, Object data) |
| | | { |
| | | return new AjaxResult(HttpStatus.SUCCESS, msg, data); |
| | | } |
| | | |
| | | /** |
| | | * è¿åéè¯¯æ¶æ¯ |
| | | * |
| | | * @return |
| | | */ |
| | | public static AjaxResult error() |
| | | { |
| | | return AjaxResult.error("æä½å¤±è´¥"); |
| | | } |
| | | |
| | | /** |
| | | * è¿åéè¯¯æ¶æ¯ |
| | | * |
| | | * @param msg è¿åå
容 |
| | | * @return è¦åæ¶æ¯ |
| | | */ |
| | | public static AjaxResult error(String msg) |
| | | { |
| | | return AjaxResult.error(msg, null); |
| | | } |
| | | |
| | | /** |
| | | * è¿åéè¯¯æ¶æ¯ |
| | | * |
| | | * @param msg è¿åå
容 |
| | | * @param data æ°æ®å¯¹è±¡ |
| | | * @return è¦åæ¶æ¯ |
| | | */ |
| | | public static AjaxResult error(String msg, Object data) |
| | | { |
| | | return new AjaxResult(HttpStatus.ERROR, msg, data); |
| | | } |
| | | |
| | | /** |
| | | * è¿åéè¯¯æ¶æ¯ |
| | | * |
| | | * @param code ç¶æç |
| | | * @param msg è¿åå
容 |
| | | * @return è¦åæ¶æ¯ |
| | | */ |
| | | public static AjaxResult error(int code, String msg) |
| | | { |
| | | return new AjaxResult(code, msg, null); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.domain; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | |
| | | /** |
| | | * Entityåºç±» |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class BaseEntity implements Serializable |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** æç´¢å¼ */ |
| | | private String searchValue; |
| | | |
| | | /** å建è
*/ |
| | | private String createBy; |
| | | |
| | | /** å建æ¶é´ */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** æ´æ°è
*/ |
| | | private String updateBy; |
| | | |
| | | /** æ´æ°æ¶é´ */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | /** 夿³¨ */ |
| | | private String remark; |
| | | |
| | | /** å¼å§æ¶é´ */ |
| | | @JsonIgnore |
| | | private String beginTime; |
| | | |
| | | /** ç»ææ¶é´ */ |
| | | @JsonIgnore |
| | | private String endTime; |
| | | |
| | | /** 请æ±åæ° */ |
| | | private Map<String, Object> params; |
| | | |
| | | public String getSearchValue() |
| | | { |
| | | return searchValue; |
| | | } |
| | | |
| | | public void setSearchValue(String searchValue) |
| | | { |
| | | this.searchValue = searchValue; |
| | | } |
| | | |
| | | public String getCreateBy() |
| | | { |
| | | return createBy; |
| | | } |
| | | |
| | | public void setCreateBy(String createBy) |
| | | { |
| | | this.createBy = createBy; |
| | | } |
| | | |
| | | public Date getCreateTime() |
| | | { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Date createTime) |
| | | { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public String getUpdateBy() |
| | | { |
| | | return updateBy; |
| | | } |
| | | |
| | | public void setUpdateBy(String updateBy) |
| | | { |
| | | this.updateBy = updateBy; |
| | | } |
| | | |
| | | public Date getUpdateTime() |
| | | { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(Date updateTime) |
| | | { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public String getRemark() |
| | | { |
| | | return remark; |
| | | } |
| | | |
| | | public void setRemark(String remark) |
| | | { |
| | | this.remark = remark; |
| | | } |
| | | |
| | | public String getBeginTime() |
| | | { |
| | | return beginTime; |
| | | } |
| | | |
| | | public void setBeginTime(String beginTime) |
| | | { |
| | | this.beginTime = beginTime; |
| | | } |
| | | |
| | | public String getEndTime() |
| | | { |
| | | return endTime; |
| | | } |
| | | |
| | | public void setEndTime(String endTime) |
| | | { |
| | | this.endTime = endTime; |
| | | } |
| | | |
| | | public Map<String, Object> getParams() |
| | | { |
| | | if (params == null) |
| | | { |
| | | params = new HashMap<>(); |
| | | } |
| | | return params; |
| | | } |
| | | |
| | | public void setParams(Map<String, Object> params) |
| | | { |
| | | this.params = params; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.domain;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | /**
|
| | | * Treeåºç±»
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class TreeEntity extends BaseEntity
|
| | | {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | /** ç¶èååç§° */
|
| | | private String parentName;
|
| | |
|
| | | /** ç¶èåID */
|
| | | private Long parentId;
|
| | |
|
| | | /** æ¾ç¤ºé¡ºåº */
|
| | | private Integer orderNum;
|
| | |
|
| | | /** ç¥çº§å表 */
|
| | | private String ancestors;
|
| | |
|
| | | /** åé¨é¨ */
|
| | | private List<?> children = new ArrayList<>();
|
| | |
|
| | | public String getParentName()
|
| | | {
|
| | | return parentName;
|
| | | }
|
| | |
|
| | | public void setParentName(String parentName)
|
| | | {
|
| | | this.parentName = parentName;
|
| | | }
|
| | |
|
| | | public Long getParentId()
|
| | | {
|
| | | return parentId;
|
| | | }
|
| | |
|
| | | public void setParentId(Long parentId)
|
| | | {
|
| | | this.parentId = parentId;
|
| | | }
|
| | |
|
| | | public Integer getOrderNum()
|
| | | {
|
| | | return orderNum;
|
| | | }
|
| | |
|
| | | public void setOrderNum(Integer orderNum)
|
| | | {
|
| | | this.orderNum = orderNum;
|
| | | }
|
| | |
|
| | | public String getAncestors()
|
| | | {
|
| | | return ancestors;
|
| | | }
|
| | |
|
| | | public void setAncestors(String ancestors)
|
| | | {
|
| | | this.ancestors = ancestors;
|
| | | }
|
| | |
|
| | | public List<?> getChildren()
|
| | | {
|
| | | return children;
|
| | | }
|
| | |
|
| | | public void setChildren(List<?> children)
|
| | | {
|
| | | this.children = children;
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | |
| | | /** |
| | | * Treeselectæ ç»æå®ä½ç±» |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class TreeSelect implements Serializable |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** èç¹ID */ |
| | | private Long id; |
| | | |
| | | /** èç¹åç§° */ |
| | | private String label; |
| | | |
| | | /** åèç¹ */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | private List<TreeSelect> children; |
| | | |
| | | public TreeSelect() |
| | | { |
| | | |
| | | } |
| | | |
| | | public TreeSelect(SysDept dept) |
| | | { |
| | | this.id = dept.getDeptId(); |
| | | this.label = dept.getDeptName(); |
| | | this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); |
| | | } |
| | | |
| | | public TreeSelect(SysMenu menu) |
| | | { |
| | | this.id = menu.getMenuId(); |
| | | this.label = menu.getMenuName(); |
| | | this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); |
| | | } |
| | | |
| | | public Long getId() |
| | | { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Long id) |
| | | { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getLabel() |
| | | { |
| | | return label; |
| | | } |
| | | |
| | | public void setLabel(String label) |
| | | { |
| | | this.label = label; |
| | | } |
| | | |
| | | public List<TreeSelect> getChildren() |
| | | { |
| | | return children; |
| | | } |
| | | |
| | | public void setChildren(List<TreeSelect> children) |
| | | { |
| | | this.children = children; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.domain.entity; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import javax.validation.constraints.Email; |
| | | 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.core.domain.BaseEntity; |
| | | |
| | | /** |
| | | * é¨é¨è¡¨ sys_dept |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysDept extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** é¨é¨ID */ |
| | | private Long deptId; |
| | | |
| | | /** ç¶é¨é¨ID */ |
| | | private Long parentId; |
| | | |
| | | /** ç¥çº§å表 */ |
| | | private String ancestors; |
| | | |
| | | /** é¨é¨åç§° */ |
| | | private String deptName; |
| | | |
| | | /** æ¾ç¤ºé¡ºåº */ |
| | | private String orderNum; |
| | | |
| | | /** è´è´£äºº */ |
| | | private String leader; |
| | | |
| | | /** èç³»çµè¯ */ |
| | | private String phone; |
| | | |
| | | /** é®ç®± */ |
| | | private String email; |
| | | |
| | | /** é¨é¨ç¶æ:0æ£å¸¸,1åç¨ */ |
| | | private String status; |
| | | |
| | | /** å 餿 å¿ï¼0代表åå¨ 2代表å é¤ï¼ */ |
| | | private String delFlag; |
| | | |
| | | /** ç¶é¨é¨åç§° */ |
| | | private String parentName; |
| | | |
| | | /** åé¨é¨ */ |
| | | private List<SysDept> children = new ArrayList<SysDept>(); |
| | | |
| | | public Long getDeptId() |
| | | { |
| | | return deptId; |
| | | } |
| | | |
| | | public void setDeptId(Long deptId) |
| | | { |
| | | this.deptId = deptId; |
| | | } |
| | | |
| | | public Long getParentId() |
| | | { |
| | | return parentId; |
| | | } |
| | | |
| | | public void setParentId(Long parentId) |
| | | { |
| | | this.parentId = parentId; |
| | | } |
| | | |
| | | public String getAncestors() |
| | | { |
| | | return ancestors; |
| | | } |
| | | |
| | | public void setAncestors(String ancestors) |
| | | { |
| | | this.ancestors = ancestors; |
| | | } |
| | | |
| | | @NotBlank(message = "é¨é¨åç§°ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 30, message = "é¨é¨åç§°é¿åº¦ä¸è½è¶
è¿30个å符") |
| | | public String getDeptName() |
| | | { |
| | | return deptName; |
| | | } |
| | | |
| | | public void setDeptName(String deptName) |
| | | { |
| | | this.deptName = deptName; |
| | | } |
| | | |
| | | @NotBlank(message = "æ¾ç¤ºé¡ºåºä¸è½ä¸ºç©º") |
| | | public String getOrderNum() |
| | | { |
| | | return orderNum; |
| | | } |
| | | |
| | | public void setOrderNum(String orderNum) |
| | | { |
| | | this.orderNum = orderNum; |
| | | } |
| | | |
| | | public String getLeader() |
| | | { |
| | | return leader; |
| | | } |
| | | |
| | | public void setLeader(String leader) |
| | | { |
| | | this.leader = leader; |
| | | } |
| | | |
| | | @Size(min = 0, max = 11, message = "èç³»çµè¯é¿åº¦ä¸è½è¶
è¿11个å符") |
| | | public String getPhone() |
| | | { |
| | | return phone; |
| | | } |
| | | |
| | | public void setPhone(String phone) |
| | | { |
| | | this.phone = phone; |
| | | } |
| | | |
| | | @Email(message = "é®ç®±æ ¼å¼ä¸æ£ç¡®") |
| | | @Size(min = 0, max = 50, message = "é®ç®±é¿åº¦ä¸è½è¶
è¿50个å符") |
| | | public String getEmail() |
| | | { |
| | | return email; |
| | | } |
| | | |
| | | public void setEmail(String email) |
| | | { |
| | | this.email = email; |
| | | } |
| | | |
| | | public String getStatus() |
| | | { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(String status) |
| | | { |
| | | this.status = status; |
| | | } |
| | | |
| | | public String getDelFlag() |
| | | { |
| | | return delFlag; |
| | | } |
| | | |
| | | public void setDelFlag(String delFlag) |
| | | { |
| | | this.delFlag = delFlag; |
| | | } |
| | | |
| | | public String getParentName() |
| | | { |
| | | return parentName; |
| | | } |
| | | |
| | | public void setParentName(String parentName) |
| | | { |
| | | this.parentName = parentName; |
| | | } |
| | | |
| | | public List<SysDept> getChildren() |
| | | { |
| | | return children; |
| | | } |
| | | |
| | | public void setChildren(List<SysDept> children) |
| | | { |
| | | this.children = children; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | | .append("deptId", getDeptId()) |
| | | .append("parentId", getParentId()) |
| | | .append("ancestors", getAncestors()) |
| | | .append("deptName", getDeptName()) |
| | | .append("orderNum", getOrderNum()) |
| | | .append("leader", getLeader()) |
| | | .append("phone", getPhone()) |
| | | .append("email", getEmail()) |
| | | .append("status", getStatus()) |
| | | .append("delFlag", getDelFlag()) |
| | | .append("createBy", getCreateBy()) |
| | | .append("createTime", getCreateTime()) |
| | | .append("updateBy", getUpdateBy()) |
| | | .append("updateTime", getUpdateTime()) |
| | | .toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.common.core.domain.BaseEntity; |
| | | |
| | | /** |
| | | * åå
¸æ°æ®è¡¨ sys_dict_data |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysDictData extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** åå
¸ç¼ç */ |
| | | @Excel(name = "åå
¸ç¼ç ", cellType = ColumnType.NUMERIC) |
| | | private Long dictCode; |
| | | |
| | | /** åå
¸æåº */ |
| | | @Excel(name = "åå
¸æåº", cellType = ColumnType.NUMERIC) |
| | | private Long dictSort; |
| | | |
| | | /** åå
¸æ ç¾ */ |
| | | @Excel(name = "åå
¸æ ç¾") |
| | | private String dictLabel; |
| | | |
| | | /** åå
¸é®å¼ */ |
| | | @Excel(name = "åå
¸é®å¼") |
| | | private String dictValue; |
| | | |
| | | /** åå
¸ç±»å */ |
| | | @Excel(name = "åå
¸ç±»å") |
| | | private String dictType; |
| | | |
| | | /** æ ·å¼å±æ§ï¼å
¶ä»æ ·å¼æ©å±ï¼ */ |
| | | private String cssClass; |
| | | |
| | | /** è¡¨æ ¼åå
¸æ ·å¼ */ |
| | | private String listClass; |
| | | |
| | | /** æ¯å¦é»è®¤ï¼Yæ¯ Nå¦ï¼ */ |
| | | @Excel(name = "æ¯å¦é»è®¤", readConverterExp = "Y=æ¯,N=å¦") |
| | | private String isDefault; |
| | | |
| | | /** ç¶æï¼0æ£å¸¸ 1åç¨ï¼ */ |
| | | @Excel(name = "ç¶æ", readConverterExp = "0=æ£å¸¸,1=åç¨") |
| | | private String status; |
| | | |
| | | public Long getDictCode() |
| | | { |
| | | return dictCode; |
| | | } |
| | | |
| | | public void setDictCode(Long dictCode) |
| | | { |
| | | this.dictCode = dictCode; |
| | | } |
| | | |
| | | public Long getDictSort() |
| | | { |
| | | return dictSort; |
| | | } |
| | | |
| | | public void setDictSort(Long dictSort) |
| | | { |
| | | this.dictSort = dictSort; |
| | | } |
| | | |
| | | @NotBlank(message = "åå
¸æ ç¾ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 100, message = "åå
¸æ ç¾é¿åº¦ä¸è½è¶
è¿100个å符") |
| | | public String getDictLabel() |
| | | { |
| | | return dictLabel; |
| | | } |
| | | |
| | | public void setDictLabel(String dictLabel) |
| | | { |
| | | this.dictLabel = dictLabel; |
| | | } |
| | | |
| | | @NotBlank(message = "åå
¸é®å¼ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 100, message = "åå
¸é®å¼é¿åº¦ä¸è½è¶
è¿100个å符") |
| | | public String getDictValue() |
| | | { |
| | | return dictValue; |
| | | } |
| | | |
| | | public void setDictValue(String dictValue) |
| | | { |
| | | this.dictValue = dictValue; |
| | | } |
| | | |
| | | @NotBlank(message = "åå
¸ç±»åä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 100, message = "åå
¸ç±»åé¿åº¦ä¸è½è¶
è¿100个å符") |
| | | public String getDictType() |
| | | { |
| | | return dictType; |
| | | } |
| | | |
| | | public void setDictType(String dictType) |
| | | { |
| | | this.dictType = dictType; |
| | | } |
| | | |
| | | @Size(min = 0, max = 100, message = "æ ·å¼å±æ§é¿åº¦ä¸è½è¶
è¿100个å符") |
| | | public String getCssClass() |
| | | { |
| | | return cssClass; |
| | | } |
| | | |
| | | public void setCssClass(String cssClass) |
| | | { |
| | | this.cssClass = cssClass; |
| | | } |
| | | |
| | | public String getListClass() |
| | | { |
| | | return listClass; |
| | | } |
| | | |
| | | public void setListClass(String listClass) |
| | | { |
| | | this.listClass = listClass; |
| | | } |
| | | |
| | | public boolean getDefault() |
| | | { |
| | | return UserConstants.YES.equals(this.isDefault) ? true : false; |
| | | } |
| | | |
| | | public String getIsDefault() |
| | | { |
| | | return isDefault; |
| | | } |
| | | |
| | | public void setIsDefault(String isDefault) |
| | | { |
| | | this.isDefault = isDefault; |
| | | } |
| | | |
| | | 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("dictCode", getDictCode()) |
| | | .append("dictSort", getDictSort()) |
| | | .append("dictLabel", getDictLabel()) |
| | | .append("dictValue", getDictValue()) |
| | | .append("dictType", getDictType()) |
| | | .append("cssClass", getCssClass()) |
| | | .append("listClass", getListClass()) |
| | | .append("isDefault", getIsDefault()) |
| | | .append("status", getStatus()) |
| | | .append("createBy", getCreateBy()) |
| | | .append("createTime", getCreateTime()) |
| | | .append("updateBy", getUpdateBy()) |
| | | .append("updateTime", getUpdateTime()) |
| | | .append("remark", getRemark()) |
| | | .toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.core.domain.BaseEntity; |
| | | |
| | | /** |
| | | * åå
¸ç±»å表 sys_dict_type |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysDictType extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** åå
¸ä¸»é® */ |
| | | @Excel(name = "åå
¸ä¸»é®", cellType = ColumnType.NUMERIC) |
| | | private Long dictId; |
| | | |
| | | /** åå
¸åç§° */ |
| | | @Excel(name = "åå
¸åç§°") |
| | | private String dictName; |
| | | |
| | | /** åå
¸ç±»å */ |
| | | @Excel(name = "åå
¸ç±»å") |
| | | private String dictType; |
| | | |
| | | /** ç¶æï¼0æ£å¸¸ 1åç¨ï¼ */ |
| | | @Excel(name = "ç¶æ", readConverterExp = "0=æ£å¸¸,1=åç¨") |
| | | private String status; |
| | | |
| | | public Long getDictId() |
| | | { |
| | | return dictId; |
| | | } |
| | | |
| | | public void setDictId(Long dictId) |
| | | { |
| | | this.dictId = dictId; |
| | | } |
| | | |
| | | @NotBlank(message = "åå
¸åç§°ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 100, message = "åå
¸ç±»ååç§°é¿åº¦ä¸è½è¶
è¿100个å符") |
| | | public String getDictName() |
| | | { |
| | | return dictName; |
| | | } |
| | | |
| | | public void setDictName(String dictName) |
| | | { |
| | | this.dictName = dictName; |
| | | } |
| | | |
| | | @NotBlank(message = "åå
¸ç±»åä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 100, message = "åå
¸ç±»åç±»åé¿åº¦ä¸è½è¶
è¿100个å符") |
| | | public String getDictType() |
| | | { |
| | | return dictType; |
| | | } |
| | | |
| | | public void setDictType(String dictType) |
| | | { |
| | | this.dictType = dictType; |
| | | } |
| | | |
| | | 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("dictId", getDictId()) |
| | | .append("dictName", getDictName()) |
| | | .append("dictType", getDictType()) |
| | | .append("status", getStatus()) |
| | | .append("createBy", getCreateBy()) |
| | | .append("createTime", getCreateTime()) |
| | | .append("updateBy", getUpdateBy()) |
| | | .append("updateTime", getUpdateTime()) |
| | | .append("remark", getRemark()) |
| | | .toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.domain.entity; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | 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.core.domain.BaseEntity; |
| | | |
| | | /** |
| | | * èåæé表 sys_menu |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysMenu extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** èåID */ |
| | | private Long menuId; |
| | | |
| | | /** èååç§° */ |
| | | private String menuName; |
| | | |
| | | /** ç¶èååç§° */ |
| | | private String parentName; |
| | | |
| | | /** ç¶èåID */ |
| | | private Long parentId; |
| | | |
| | | /** æ¾ç¤ºé¡ºåº */ |
| | | private String orderNum; |
| | | |
| | | /** è·¯ç±å°å */ |
| | | private String path; |
| | | |
| | | /** ç»ä»¶è·¯å¾ */ |
| | | private String component; |
| | | |
| | | /** æ¯å¦ä¸ºå¤é¾ï¼0æ¯ 1å¦ï¼ */ |
| | | private String isFrame; |
| | | |
| | | /** ç±»åï¼Mç®å½ Cèå Fæé®ï¼ */ |
| | | private String menuType; |
| | | |
| | | /** æ¾ç¤ºç¶æï¼0æ¾ç¤º 1éèï¼ */ |
| | | private String visible; |
| | | |
| | | /** èåç¶æï¼0æ¾ç¤º 1éèï¼ */ |
| | | private String status; |
| | | |
| | | /** æéå符串 */ |
| | | private String perms; |
| | | |
| | | /** èå徿 */ |
| | | private String icon; |
| | | |
| | | /** åèå */ |
| | | private List<SysMenu> children = new ArrayList<SysMenu>(); |
| | | |
| | | public Long getMenuId() |
| | | { |
| | | return menuId; |
| | | } |
| | | |
| | | public void setMenuId(Long menuId) |
| | | { |
| | | this.menuId = menuId; |
| | | } |
| | | |
| | | @NotBlank(message = "èååç§°ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 50, message = "èååç§°é¿åº¦ä¸è½è¶
è¿50个å符") |
| | | public String getMenuName() |
| | | { |
| | | return menuName; |
| | | } |
| | | |
| | | public void setMenuName(String menuName) |
| | | { |
| | | this.menuName = menuName; |
| | | } |
| | | |
| | | public String getParentName() |
| | | { |
| | | return parentName; |
| | | } |
| | | |
| | | public void setParentName(String parentName) |
| | | { |
| | | this.parentName = parentName; |
| | | } |
| | | |
| | | public Long getParentId() |
| | | { |
| | | return parentId; |
| | | } |
| | | |
| | | public void setParentId(Long parentId) |
| | | { |
| | | this.parentId = parentId; |
| | | } |
| | | |
| | | @NotBlank(message = "æ¾ç¤ºé¡ºåºä¸è½ä¸ºç©º") |
| | | public String getOrderNum() |
| | | { |
| | | return orderNum; |
| | | } |
| | | |
| | | public void setOrderNum(String orderNum) |
| | | { |
| | | this.orderNum = orderNum; |
| | | } |
| | | |
| | | @Size(min = 0, max = 200, message = "è·¯ç±å°åä¸è½è¶
è¿200个å符") |
| | | public String getPath() |
| | | { |
| | | return path; |
| | | } |
| | | |
| | | public void setPath(String path) |
| | | { |
| | | this.path = path; |
| | | } |
| | | |
| | | @Size(min = 0, max = 200, message = "ç»ä»¶è·¯å¾ä¸è½è¶
è¿255个å符") |
| | | public String getComponent() |
| | | { |
| | | return component; |
| | | } |
| | | |
| | | public void setComponent(String component) |
| | | { |
| | | this.component = component; |
| | | } |
| | | |
| | | public String getIsFrame() |
| | | { |
| | | return isFrame; |
| | | } |
| | | |
| | | public void setIsFrame(String isFrame) |
| | | { |
| | | this.isFrame = isFrame; |
| | | } |
| | | |
| | | @NotBlank(message = "èåç±»åä¸è½ä¸ºç©º") |
| | | public String getMenuType() |
| | | { |
| | | return menuType; |
| | | } |
| | | |
| | | public void setMenuType(String menuType) |
| | | { |
| | | this.menuType = menuType; |
| | | } |
| | | |
| | | public String getVisible() |
| | | { |
| | | return visible; |
| | | } |
| | | |
| | | public void setVisible(String visible) |
| | | { |
| | | this.visible = visible; |
| | | } |
| | | |
| | | public String getStatus() |
| | | { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(String status) |
| | | { |
| | | this.status = status; |
| | | } |
| | | |
| | | @Size(min = 0, max = 100, message = "æéæ è¯é¿åº¦ä¸è½è¶
è¿100个å符") |
| | | public String getPerms() |
| | | { |
| | | return perms; |
| | | } |
| | | |
| | | public void setPerms(String perms) |
| | | { |
| | | this.perms = perms; |
| | | } |
| | | |
| | | public String getIcon() |
| | | { |
| | | return icon; |
| | | } |
| | | |
| | | public void setIcon(String icon) |
| | | { |
| | | this.icon = icon; |
| | | } |
| | | |
| | | public List<SysMenu> getChildren() |
| | | { |
| | | return children; |
| | | } |
| | | |
| | | public void setChildren(List<SysMenu> children) |
| | | { |
| | | this.children = children; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | | .append("menuId", getMenuId()) |
| | | .append("menuName", getMenuName()) |
| | | .append("parentId", getParentId()) |
| | | .append("orderNum", getOrderNum()) |
| | | .append("path", getPath()) |
| | | .append("component", getComponent()) |
| | | .append("isFrame", getIsFrame()) |
| | | .append("menuType", getMenuType()) |
| | | .append("visible", getVisible()) |
| | | .append("status ", getStatus()) |
| | | .append("perms", getPerms()) |
| | | .append("icon", getIcon()) |
| | | .append("createBy", getCreateBy()) |
| | | .append("createTime", getCreateTime()) |
| | | .append("updateBy", getUpdateBy()) |
| | | .append("updateTime", getUpdateTime()) |
| | | .append("remark", getRemark()) |
| | | .toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.core.domain.BaseEntity; |
| | | |
| | | /** |
| | | * è§è²è¡¨ sys_role |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysRole extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** è§è²ID */ |
| | | @Excel(name = "è§è²åºå·", cellType = ColumnType.NUMERIC) |
| | | private Long roleId; |
| | | |
| | | /** è§è²åç§° */ |
| | | @Excel(name = "è§è²åç§°") |
| | | private String roleName; |
| | | |
| | | /** è§è²æé */ |
| | | @Excel(name = "è§è²æé") |
| | | private String roleKey; |
| | | |
| | | /** è§è²æåº */ |
| | | @Excel(name = "è§è²æåº") |
| | | private String roleSort; |
| | | |
| | | /** æ°æ®èå´ï¼1ï¼æææ°æ®æéï¼2ï¼èªå®ä¹æ°æ®æéï¼3ï¼æ¬é¨é¨æ°æ®æéï¼4ï¼æ¬é¨é¨å以䏿°æ®æéï¼ */ |
| | | @Excel(name = "æ°æ®èå´", readConverterExp = "1=æææ°æ®æé,2=èªå®ä¹æ°æ®æé,3=æ¬é¨é¨æ°æ®æé,4=æ¬é¨é¨å以䏿°æ®æé") |
| | | private String dataScope; |
| | | |
| | | /** è§è²ç¶æï¼0æ£å¸¸ 1åç¨ï¼ */ |
| | | @Excel(name = "è§è²ç¶æ", readConverterExp = "0=æ£å¸¸,1=åç¨") |
| | | private String status; |
| | | |
| | | /** å 餿 å¿ï¼0代表åå¨ 2代表å é¤ï¼ */ |
| | | private String delFlag; |
| | | |
| | | /** ç¨æ·æ¯å¦å卿¤è§è²æ è¯ é»è®¤ä¸åå¨ */ |
| | | private boolean flag = false; |
| | | |
| | | /** èåç» */ |
| | | private Long[] menuIds; |
| | | |
| | | /** é¨é¨ç»ï¼æ°æ®æéï¼ */ |
| | | private Long[] deptIds; |
| | | |
| | | public SysRole() |
| | | { |
| | | |
| | | } |
| | | |
| | | public SysRole(Long roleId) |
| | | { |
| | | this.roleId = roleId; |
| | | } |
| | | |
| | | public Long getRoleId() |
| | | { |
| | | return roleId; |
| | | } |
| | | |
| | | public void setRoleId(Long roleId) |
| | | { |
| | | this.roleId = roleId; |
| | | } |
| | | |
| | | public boolean isAdmin() |
| | | { |
| | | return isAdmin(this.roleId); |
| | | } |
| | | |
| | | public static boolean isAdmin(Long roleId) |
| | | { |
| | | return roleId != null && 1L == roleId; |
| | | } |
| | | |
| | | @NotBlank(message = "è§è²åç§°ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 30, message = "è§è²åç§°é¿åº¦ä¸è½è¶
è¿30个å符") |
| | | public String getRoleName() |
| | | { |
| | | return roleName; |
| | | } |
| | | |
| | | public void setRoleName(String roleName) |
| | | { |
| | | this.roleName = roleName; |
| | | } |
| | | |
| | | @NotBlank(message = "æéå符ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 100, message = "æéå符é¿åº¦ä¸è½è¶
è¿100个å符") |
| | | public String getRoleKey() |
| | | { |
| | | return roleKey; |
| | | } |
| | | |
| | | public void setRoleKey(String roleKey) |
| | | { |
| | | this.roleKey = roleKey; |
| | | } |
| | | |
| | | @NotBlank(message = "æ¾ç¤ºé¡ºåºä¸è½ä¸ºç©º") |
| | | public String getRoleSort() |
| | | { |
| | | return roleSort; |
| | | } |
| | | |
| | | public void setRoleSort(String roleSort) |
| | | { |
| | | this.roleSort = roleSort; |
| | | } |
| | | |
| | | public String getDataScope() |
| | | { |
| | | return dataScope; |
| | | } |
| | | |
| | | public void setDataScope(String dataScope) |
| | | { |
| | | this.dataScope = dataScope; |
| | | } |
| | | |
| | | public String getStatus() |
| | | { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(String status) |
| | | { |
| | | this.status = status; |
| | | } |
| | | |
| | | public String getDelFlag() |
| | | { |
| | | return delFlag; |
| | | } |
| | | |
| | | public void setDelFlag(String delFlag) |
| | | { |
| | | this.delFlag = delFlag; |
| | | } |
| | | |
| | | public boolean isFlag() |
| | | { |
| | | return flag; |
| | | } |
| | | |
| | | public void setFlag(boolean flag) |
| | | { |
| | | this.flag = flag; |
| | | } |
| | | |
| | | public Long[] getMenuIds() |
| | | { |
| | | return menuIds; |
| | | } |
| | | |
| | | public void setMenuIds(Long[] menuIds) |
| | | { |
| | | this.menuIds = menuIds; |
| | | } |
| | | |
| | | public Long[] getDeptIds() |
| | | { |
| | | return deptIds; |
| | | } |
| | | |
| | | public void setDeptIds(Long[] deptIds) |
| | | { |
| | | this.deptIds = deptIds; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | | .append("roleId", getRoleId()) |
| | | .append("roleName", getRoleName()) |
| | | .append("roleKey", getRoleKey()) |
| | | .append("roleSort", getRoleSort()) |
| | | .append("dataScope", getDataScope()) |
| | | .append("status", getStatus()) |
| | | .append("delFlag", getDelFlag()) |
| | | .append("createBy", getCreateBy()) |
| | | .append("createTime", getCreateTime()) |
| | | .append("updateBy", getUpdateBy()) |
| | | .append("updateTime", getUpdateTime()) |
| | | .append("remark", getRemark()) |
| | | .toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.domain.entity; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import javax.validation.constraints.Email; |
| | | 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.JsonIgnore; |
| | | import com.fasterxml.jackson.annotation.JsonProperty; |
| | | 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 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysUser extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** ç¨æ·ID */ |
| | | @Excel(name = "ç¨æ·åºå·", cellType = ColumnType.NUMERIC, prompt = "ç¨æ·ç¼å·") |
| | | private Long userId; |
| | | |
| | | /** é¨é¨ID */ |
| | | @Excel(name = "é¨é¨ç¼å·", type = Type.IMPORT) |
| | | private Long deptId; |
| | | |
| | | /** ç¨æ·è´¦å· */ |
| | | @Excel(name = "ç»å½åç§°") |
| | | private String userName; |
| | | |
| | | /** ç¨æ·æµç§° */ |
| | | @Excel(name = "ç¨æ·åç§°") |
| | | private String nickName; |
| | | |
| | | /** ç¨æ·é®ç®± */ |
| | | @Excel(name = "ç¨æ·é®ç®±") |
| | | private String email; |
| | | |
| | | /** ææºå·ç */ |
| | | @Excel(name = "ææºå·ç ") |
| | | private String phonenumber; |
| | | |
| | | /** ç¨æ·æ§å« */ |
| | | @Excel(name = "ç¨æ·æ§å«", readConverterExp = "0=ç·,1=女,2=æªç¥") |
| | | private String sex; |
| | | |
| | | /** ç¨æ·å¤´å */ |
| | | private String avatar; |
| | | |
| | | /** å¯ç */ |
| | | private String password; |
| | | |
| | | /** çå å¯ */ |
| | | private String salt; |
| | | |
| | | /** å¸å·ç¶æï¼0æ£å¸¸ 1åç¨ï¼ */ |
| | | @Excel(name = "å¸å·ç¶æ", readConverterExp = "0=æ£å¸¸,1=åç¨") |
| | | private String status; |
| | | |
| | | /** å 餿 å¿ï¼0代表åå¨ 2代表å é¤ï¼ */ |
| | | private String delFlag; |
| | | |
| | | /** æåç»éIP */ |
| | | @Excel(name = "æåç»éIP", type = Type.EXPORT) |
| | | private String loginIp; |
| | | |
| | | /** æåç»éæ¶é´ */ |
| | | @Excel(name = "æåç»éæ¶é´", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) |
| | | private Date loginDate; |
| | | |
| | | /** é¨é¨å¯¹è±¡ */ |
| | | @Excels({ |
| | | @Excel(name = "é¨é¨åç§°", targetAttr = "deptName", type = Type.EXPORT), |
| | | @Excel(name = "é¨é¨è´è´£äºº", targetAttr = "leader", type = Type.EXPORT) |
| | | }) |
| | | private SysDept dept; |
| | | |
| | | /** è§è²å¯¹è±¡ */ |
| | | private List<SysRole> roles; |
| | | |
| | | /** è§è²ç» */ |
| | | private Long[] roleIds; |
| | | |
| | | /** å²ä½ç» */ |
| | | private Long[] postIds; |
| | | |
| | | public SysUser() |
| | | { |
| | | |
| | | } |
| | | |
| | | public SysUser(Long userId) |
| | | { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public Long getUserId() |
| | | { |
| | | return userId; |
| | | } |
| | | |
| | | public void setUserId(Long userId) |
| | | { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public boolean isAdmin() |
| | | { |
| | | return isAdmin(this.userId); |
| | | } |
| | | |
| | | public static boolean isAdmin(Long userId) |
| | | { |
| | | return userId != null && 1L == userId; |
| | | } |
| | | |
| | | public Long getDeptId() |
| | | { |
| | | return deptId; |
| | | } |
| | | |
| | | public void setDeptId(Long deptId) |
| | | { |
| | | this.deptId = deptId; |
| | | } |
| | | |
| | | @Size(min = 0, max = 30, message = "ç¨æ·æµç§°é¿åº¦ä¸è½è¶
è¿30个å符") |
| | | public String getNickName() |
| | | { |
| | | return nickName; |
| | | } |
| | | |
| | | public void setNickName(String nickName) |
| | | { |
| | | this.nickName = nickName; |
| | | } |
| | | |
| | | @NotBlank(message = "ç¨æ·è´¦å·ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 30, message = "ç¨æ·è´¦å·é¿åº¦ä¸è½è¶
è¿30个å符") |
| | | public String getUserName() |
| | | { |
| | | return userName; |
| | | } |
| | | |
| | | public void setUserName(String userName) |
| | | { |
| | | this.userName = userName; |
| | | } |
| | | |
| | | @Email(message = "é®ç®±æ ¼å¼ä¸æ£ç¡®") |
| | | @Size(min = 0, max = 50, message = "é®ç®±é¿åº¦ä¸è½è¶
è¿50个å符") |
| | | public String getEmail() |
| | | { |
| | | return email; |
| | | } |
| | | |
| | | public void setEmail(String email) |
| | | { |
| | | this.email = email; |
| | | } |
| | | |
| | | @Size(min = 0, max = 11, message = "ææºå·ç é¿åº¦ä¸è½è¶
è¿11个å符") |
| | | public String getPhonenumber() |
| | | { |
| | | return phonenumber; |
| | | } |
| | | |
| | | public void setPhonenumber(String phonenumber) |
| | | { |
| | | this.phonenumber = phonenumber; |
| | | } |
| | | |
| | | public String getSex() |
| | | { |
| | | return sex; |
| | | } |
| | | |
| | | public void setSex(String sex) |
| | | { |
| | | this.sex = sex; |
| | | } |
| | | |
| | | public String getAvatar() |
| | | { |
| | | return avatar; |
| | | } |
| | | |
| | | public void setAvatar(String avatar) |
| | | { |
| | | this.avatar = avatar; |
| | | } |
| | | |
| | | @JsonIgnore |
| | | @JsonProperty |
| | | public String getPassword() |
| | | { |
| | | return password; |
| | | } |
| | | |
| | | public void setPassword(String password) |
| | | { |
| | | this.password = password; |
| | | } |
| | | |
| | | public String getSalt() |
| | | { |
| | | return salt; |
| | | } |
| | | |
| | | public void setSalt(String salt) |
| | | { |
| | | this.salt = salt; |
| | | } |
| | | |
| | | public String getStatus() |
| | | { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(String status) |
| | | { |
| | | this.status = status; |
| | | } |
| | | |
| | | public String getDelFlag() |
| | | { |
| | | return delFlag; |
| | | } |
| | | |
| | | public void setDelFlag(String delFlag) |
| | | { |
| | | this.delFlag = delFlag; |
| | | } |
| | | |
| | | public String getLoginIp() |
| | | { |
| | | return loginIp; |
| | | } |
| | | |
| | | public void setLoginIp(String loginIp) |
| | | { |
| | | this.loginIp = loginIp; |
| | | } |
| | | |
| | | public Date getLoginDate() |
| | | { |
| | | return loginDate; |
| | | } |
| | | |
| | | public void setLoginDate(Date loginDate) |
| | | { |
| | | this.loginDate = loginDate; |
| | | } |
| | | |
| | | public SysDept getDept() |
| | | { |
| | | return dept; |
| | | } |
| | | |
| | | public void setDept(SysDept dept) |
| | | { |
| | | this.dept = dept; |
| | | } |
| | | |
| | | public List<SysRole> getRoles() |
| | | { |
| | | return roles; |
| | | } |
| | | |
| | | public void setRoles(List<SysRole> roles) |
| | | { |
| | | this.roles = roles; |
| | | } |
| | | |
| | | public Long[] getRoleIds() |
| | | { |
| | | return roleIds; |
| | | } |
| | | |
| | | public void setRoleIds(Long[] roleIds) |
| | | { |
| | | this.roleIds = roleIds; |
| | | } |
| | | |
| | | public Long[] getPostIds() |
| | | { |
| | | return postIds; |
| | | } |
| | | |
| | | public void setPostIds(Long[] postIds) |
| | | { |
| | | this.postIds = postIds; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | | .append("userId", getUserId()) |
| | | .append("deptId", getDeptId()) |
| | | .append("userName", getUserName()) |
| | | .append("nickName", getNickName()) |
| | | .append("email", getEmail()) |
| | | .append("phonenumber", getPhonenumber()) |
| | | .append("sex", getSex()) |
| | | .append("avatar", getAvatar()) |
| | | .append("password", getPassword()) |
| | | .append("salt", getSalt()) |
| | | .append("status", getStatus()) |
| | | .append("delFlag", getDelFlag()) |
| | | .append("loginIp", getLoginIp()) |
| | | .append("loginDate", getLoginDate()) |
| | | .append("createBy", getCreateBy()) |
| | | .append("createTime", getCreateTime()) |
| | | .append("updateBy", getUpdateBy()) |
| | | .append("updateTime", getUpdateTime()) |
| | | .append("remark", getRemark()) |
| | | .append("dept", getDept()) |
| | | .toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.domain.model;
|
| | |
|
| | | /**
|
| | | * ç¨æ·ç»å½å¯¹è±¡
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class LoginBody
|
| | | {
|
| | | /**
|
| | | * ç¨æ·å
|
| | | */
|
| | | private String username;
|
| | |
|
| | | /**
|
| | | * ç¨æ·å¯ç
|
| | | */
|
| | | private String password;
|
| | |
|
| | | /**
|
| | | * éªè¯ç
|
| | | */
|
| | | private String code;
|
| | |
|
| | | /**
|
| | | * å¯ä¸æ è¯
|
| | | */
|
| | | private String uuid = "";
|
| | |
|
| | | public String getUsername()
|
| | | {
|
| | | return username;
|
| | | }
|
| | |
|
| | | public void setUsername(String username)
|
| | | {
|
| | | this.username = username;
|
| | | }
|
| | |
|
| | | public String getPassword()
|
| | | {
|
| | | return password;
|
| | | }
|
| | |
|
| | | public void setPassword(String password)
|
| | | {
|
| | | this.password = password;
|
| | | }
|
| | |
|
| | | public String getCode()
|
| | | {
|
| | | return code;
|
| | | }
|
| | |
|
| | | public void setCode(String code)
|
| | | {
|
| | | this.code = code;
|
| | | }
|
| | |
|
| | | public String getUuid()
|
| | | {
|
| | | return uuid;
|
| | | }
|
| | |
|
| | | public void setUuid(String uuid)
|
| | | {
|
| | | this.uuid = uuid;
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.common.core.domain.entity.SysUser; |
| | | |
| | | /** |
| | | * ç»å½ç¨æ·èº«ä»½æé |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class LoginUser implements UserDetails |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ç¨æ·å¯ä¸æ è¯ |
| | | */ |
| | | private String token; |
| | | |
| | | /** |
| | | * ç»éæ¶é´ |
| | | */ |
| | | private Long loginTime; |
| | | |
| | | /** |
| | | * è¿ææ¶é´ |
| | | */ |
| | | private Long expireTime; |
| | | |
| | | /** |
| | | * ç»å½IPå°å |
| | | */ |
| | | private String ipaddr; |
| | | |
| | | /** |
| | | * ç»å½å°ç¹ |
| | | */ |
| | | private String loginLocation; |
| | | |
| | | /** |
| | | * æµè§å¨ç±»å |
| | | */ |
| | | private String browser; |
| | | |
| | | /** |
| | | * æä½ç³»ç» |
| | | */ |
| | | private String os; |
| | | |
| | | /** |
| | | * æéå表 |
| | | */ |
| | | private Set<String> permissions; |
| | | |
| | | /** |
| | | * ç¨æ·ä¿¡æ¯ |
| | | */ |
| | | private SysUser user; |
| | | |
| | | public String getToken() |
| | | { |
| | | return token; |
| | | } |
| | | |
| | | public void setToken(String token) |
| | | { |
| | | this.token = token; |
| | | } |
| | | |
| | | public LoginUser() |
| | | { |
| | | } |
| | | |
| | | public LoginUser(SysUser user, Set<String> permissions) |
| | | { |
| | | this.user = user; |
| | | this.permissions = permissions; |
| | | } |
| | | |
| | | @JsonIgnore |
| | | @Override |
| | | public String getPassword() |
| | | { |
| | | return user.getPassword(); |
| | | } |
| | | |
| | | @Override |
| | | public String getUsername() |
| | | { |
| | | return user.getUserName(); |
| | | } |
| | | |
| | | /** |
| | | * è´¦æ·æ¯å¦æªè¿æ,è¿ææ æ³éªè¯ |
| | | */ |
| | | @JsonIgnore |
| | | @Override |
| | | public boolean isAccountNonExpired() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * æå®ç¨æ·æ¯å¦è§£é,éå®çç¨æ·æ æ³è¿è¡èº«ä»½éªè¯ |
| | | * |
| | | * @return |
| | | */ |
| | | @JsonIgnore |
| | | @Override |
| | | public boolean isAccountNonLocked() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * æç¤ºæ¯å¦å·²è¿æçç¨æ·çåæ®(å¯ç ),è¿æç忮鲿¢è®¤è¯ |
| | | * |
| | | * @return |
| | | */ |
| | | @JsonIgnore |
| | | @Override |
| | | public boolean isCredentialsNonExpired() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦å¯ç¨ ,ç¦ç¨çç¨æ·ä¸è½èº«ä»½éªè¯ |
| | | * |
| | | * @return |
| | | */ |
| | | @JsonIgnore |
| | | @Override |
| | | public boolean isEnabled() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | public Long getLoginTime() |
| | | { |
| | | return loginTime; |
| | | } |
| | | |
| | | public void setLoginTime(Long loginTime) |
| | | { |
| | | this.loginTime = loginTime; |
| | | } |
| | | |
| | | public String getIpaddr() |
| | | { |
| | | return ipaddr; |
| | | } |
| | | |
| | | public void setIpaddr(String ipaddr) |
| | | { |
| | | this.ipaddr = ipaddr; |
| | | } |
| | | |
| | | public String getLoginLocation() |
| | | { |
| | | return loginLocation; |
| | | } |
| | | |
| | | public void setLoginLocation(String loginLocation) |
| | | { |
| | | this.loginLocation = loginLocation; |
| | | } |
| | | |
| | | public String getBrowser() |
| | | { |
| | | return browser; |
| | | } |
| | | |
| | | public void setBrowser(String browser) |
| | | { |
| | | this.browser = browser; |
| | | } |
| | | |
| | | public String getOs() |
| | | { |
| | | return os; |
| | | } |
| | | |
| | | public void setOs(String os) |
| | | { |
| | | this.os = os; |
| | | } |
| | | |
| | | public Long getExpireTime() |
| | | { |
| | | return expireTime; |
| | | } |
| | | |
| | | public void setExpireTime(Long expireTime) |
| | | { |
| | | this.expireTime = expireTime; |
| | | } |
| | | |
| | | public Set<String> getPermissions() |
| | | { |
| | | return permissions; |
| | | } |
| | | |
| | | public void setPermissions(Set<String> permissions) |
| | | { |
| | | this.permissions = permissions; |
| | | } |
| | | |
| | | public SysUser getUser() |
| | | { |
| | | return user; |
| | | } |
| | | |
| | | public void setUser(SysUser user) |
| | | { |
| | | this.user = user; |
| | | } |
| | | |
| | | @Override |
| | | public Collection<? extends GrantedAuthority> getAuthorities() |
| | | { |
| | | return null; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.page; |
| | | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | /** |
| | | * åé¡µæ°æ® |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class PageDomain |
| | | { |
| | | /** å½åè®°å½èµ·å§ç´¢å¼ */ |
| | | private Integer pageNum; |
| | | |
| | | /** æ¯é¡µæ¾ç¤ºè®°å½æ° */ |
| | | private Integer pageSize; |
| | | |
| | | /** æåºå */ |
| | | private String orderByColumn; |
| | | |
| | | /** æåºçæ¹å "desc" æè
"asc". */ |
| | | private String isAsc; |
| | | |
| | | public String getOrderBy() |
| | | { |
| | | if (StringUtils.isEmpty(orderByColumn)) |
| | | { |
| | | return ""; |
| | | } |
| | | return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc; |
| | | } |
| | | |
| | | public Integer getPageNum() |
| | | { |
| | | return pageNum; |
| | | } |
| | | |
| | | public void setPageNum(Integer pageNum) |
| | | { |
| | | this.pageNum = pageNum; |
| | | } |
| | | |
| | | public Integer getPageSize() |
| | | { |
| | | return pageSize; |
| | | } |
| | | |
| | | public void setPageSize(Integer pageSize) |
| | | { |
| | | this.pageSize = pageSize; |
| | | } |
| | | |
| | | public String getOrderByColumn() |
| | | { |
| | | return orderByColumn; |
| | | } |
| | | |
| | | public void setOrderByColumn(String orderByColumn) |
| | | { |
| | | this.orderByColumn = orderByColumn; |
| | | } |
| | | |
| | | public String getIsAsc() |
| | | { |
| | | return isAsc; |
| | | } |
| | | |
| | | public void setIsAsc(String isAsc) |
| | | { |
| | | this.isAsc = isAsc; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.page; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * è¡¨æ ¼åé¡µæ°æ®å¯¹è±¡ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class TableDataInfo implements Serializable |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** æ»è®°å½æ° */ |
| | | private long total; |
| | | |
| | | /** åè¡¨æ°æ® */ |
| | | private List<?> rows; |
| | | |
| | | /** æ¶æ¯ç¶æç */ |
| | | private int code; |
| | | |
| | | /** æ¶æ¯å
容 */ |
| | | private String msg; |
| | | |
| | | /** |
| | | * è¡¨æ ¼æ°æ®å¯¹è±¡ |
| | | */ |
| | | public TableDataInfo() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * å页 |
| | | * |
| | | * @param list åè¡¨æ°æ® |
| | | * @param total æ»è®°å½æ° |
| | | */ |
| | | public TableDataInfo(List<?> list, int total) |
| | | { |
| | | this.rows = list; |
| | | this.total = total; |
| | | } |
| | | |
| | | public long getTotal() |
| | | { |
| | | return total; |
| | | } |
| | | |
| | | public void setTotal(long total) |
| | | { |
| | | this.total = total; |
| | | } |
| | | |
| | | public List<?> getRows() |
| | | { |
| | | return rows; |
| | | } |
| | | |
| | | public void setRows(List<?> rows) |
| | | { |
| | | this.rows = rows; |
| | | } |
| | | |
| | | public int getCode() |
| | | { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(int code) |
| | | { |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getMsg() |
| | | { |
| | | return msg; |
| | | } |
| | | |
| | | public void setMsg(String msg) |
| | | { |
| | | this.msg = msg; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.page; |
| | | |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | |
| | | /** |
| | | * è¡¨æ ¼æ°æ®å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class TableSupport |
| | | { |
| | | /** |
| | | * å½åè®°å½èµ·å§ç´¢å¼ |
| | | */ |
| | | public static final String PAGE_NUM = "pageNum"; |
| | | |
| | | /** |
| | | * æ¯é¡µæ¾ç¤ºè®°å½æ° |
| | | */ |
| | | public static final String PAGE_SIZE = "pageSize"; |
| | | |
| | | /** |
| | | * æåºå |
| | | */ |
| | | public static final String ORDER_BY_COLUMN = "orderByColumn"; |
| | | |
| | | /** |
| | | * æåºçæ¹å "desc" æè
"asc". |
| | | */ |
| | | public static final String IS_ASC = "isAsc"; |
| | | |
| | | /** |
| | | * å°è£
å页对象 |
| | | */ |
| | | public static PageDomain getPageDomain() |
| | | { |
| | | PageDomain pageDomain = new PageDomain(); |
| | | pageDomain.setPageNum(ServletUtils.getParameterToInt(PAGE_NUM)); |
| | | pageDomain.setPageSize(ServletUtils.getParameterToInt(PAGE_SIZE)); |
| | | pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN)); |
| | | pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC)); |
| | | return pageDomain; |
| | | } |
| | | |
| | | public static PageDomain buildPageRequest() |
| | | { |
| | | return getPageDomain(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.redis; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.concurrent.TimeUnit; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.HashOperations; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.core.ValueOperations; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * spring redis å·¥å
·ç±» |
| | | * |
| | | * @author ruoyi |
| | | **/ |
| | | @SuppressWarnings(value = { "unchecked", "rawtypes" }) |
| | | @Component |
| | | public class RedisCache |
| | | { |
| | | @Autowired |
| | | public RedisTemplate redisTemplate; |
| | | |
| | | /** |
| | | * ç¼ååºæ¬ç对象ï¼IntegerãStringãå®ä½ç±»ç |
| | | * |
| | | * @param key ç¼åçé®å¼ |
| | | * @param value ç¼åçå¼ |
| | | */ |
| | | public <T> void setCacheObject(final String key, final T value) |
| | | { |
| | | redisTemplate.opsForValue().set(key, value); |
| | | } |
| | | |
| | | /** |
| | | * ç¼ååºæ¬ç对象ï¼IntegerãStringãå®ä½ç±»ç |
| | | * |
| | | * @param key ç¼åçé®å¼ |
| | | * @param value ç¼åçå¼ |
| | | * @param timeout æ¶é´ |
| | | * @param timeUnit æ¶é´é¢ç²åº¦ |
| | | */ |
| | | public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) |
| | | { |
| | | redisTemplate.opsForValue().set(key, value, timeout, timeUnit); |
| | | } |
| | | |
| | | /** |
| | | * è®¾ç½®æææ¶é´ |
| | | * |
| | | * @param key Redisé® |
| | | * @param timeout è¶
æ¶æ¶é´ |
| | | * @return true=设置æåï¼false=设置失败 |
| | | */ |
| | | public boolean expire(final String key, final long timeout) |
| | | { |
| | | return expire(key, timeout, TimeUnit.SECONDS); |
| | | } |
| | | |
| | | /** |
| | | * è®¾ç½®æææ¶é´ |
| | | * |
| | | * @param key Redisé® |
| | | * @param timeout è¶
æ¶æ¶é´ |
| | | * @param unit æ¶é´åä½ |
| | | * @return true=设置æåï¼false=设置失败 |
| | | */ |
| | | public boolean expire(final String key, final long timeout, final TimeUnit unit) |
| | | { |
| | | return redisTemplate.expire(key, timeout, unit); |
| | | } |
| | | |
| | | /** |
| | | * è·å¾ç¼åçåºæ¬å¯¹è±¡ã |
| | | * |
| | | * @param key ç¼åé®å¼ |
| | | * @return ç¼åé®å¼å¯¹åºçæ°æ® |
| | | */ |
| | | public <T> T getCacheObject(final String key) |
| | | { |
| | | ValueOperations<String, T> operation = redisTemplate.opsForValue(); |
| | | return operation.get(key); |
| | | } |
| | | |
| | | /** |
| | | * å é¤å个对象 |
| | | * |
| | | * @param key |
| | | */ |
| | | public boolean deleteObject(final String key) |
| | | { |
| | | return redisTemplate.delete(key); |
| | | } |
| | | |
| | | /** |
| | | * å é¤éå对象 |
| | | * |
| | | * @param collection å¤ä¸ªå¯¹è±¡ |
| | | * @return |
| | | */ |
| | | public long deleteObject(final Collection collection) |
| | | { |
| | | return redisTemplate.delete(collection); |
| | | } |
| | | |
| | | /** |
| | | * ç¼åListæ°æ® |
| | | * |
| | | * @param key ç¼åçé®å¼ |
| | | * @param values å¾
ç¼åçListæ°æ® |
| | | * @return ç¼åç对象 |
| | | */ |
| | | public <T> long setCacheList(final String key, final List<T> dataList) |
| | | { |
| | | Long count = redisTemplate.opsForList().rightPushAll(key, dataList); |
| | | return count == null ? 0 : count; |
| | | } |
| | | |
| | | /** |
| | | * è·å¾ç¼åçlist对象 |
| | | * |
| | | * @param key ç¼åçé®å¼ |
| | | * @return ç¼åé®å¼å¯¹åºçæ°æ® |
| | | */ |
| | | public <T> List<T> getCacheList(final String key) |
| | | { |
| | | return redisTemplate.opsForList().range(key, 0, -1); |
| | | } |
| | | |
| | | /** |
| | | * ç¼åSet |
| | | * |
| | | * @param key ç¼åé®å¼ |
| | | * @param dataSet ç¼åçæ°æ® |
| | | * @return ç¼åæ°æ®ç对象 |
| | | */ |
| | | public <T> long setCacheSet(final String key, final Set<T> dataSet) |
| | | { |
| | | Long count = redisTemplate.opsForSet().add(key, dataSet); |
| | | return count == null ? 0 : count; |
| | | } |
| | | |
| | | /** |
| | | * è·å¾ç¼åçset |
| | | * |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public <T> Set<T> getCacheSet(final String key) |
| | | { |
| | | return redisTemplate.opsForSet().members(key); |
| | | } |
| | | |
| | | /** |
| | | * ç¼åMap |
| | | * |
| | | * @param key |
| | | * @param dataMap |
| | | */ |
| | | public <T> void setCacheMap(final String key, final Map<String, T> dataMap) |
| | | { |
| | | if (dataMap != null) { |
| | | redisTemplate.opsForHash().putAll(key, dataMap); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·å¾ç¼åçMap |
| | | * |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public <T> Map<String, T> getCacheMap(final String key) |
| | | { |
| | | return redisTemplate.opsForHash().entries(key); |
| | | } |
| | | |
| | | /** |
| | | * å¾Hashä¸åå
¥æ°æ® |
| | | * |
| | | * @param key Redisé® |
| | | * @param hKey Hashé® |
| | | * @param value å¼ |
| | | */ |
| | | public <T> void setCacheMapValue(final String key, final String hKey, final T value) |
| | | { |
| | | redisTemplate.opsForHash().put(key, hKey, value); |
| | | } |
| | | |
| | | /** |
| | | * è·åHashä¸çæ°æ® |
| | | * |
| | | * @param key Redisé® |
| | | * @param hKey Hashé® |
| | | * @return Hashä¸ç对象 |
| | | */ |
| | | public <T> T getCacheMapValue(final String key, final String hKey) |
| | | { |
| | | HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash(); |
| | | return opsForHash.get(key, hKey); |
| | | } |
| | | |
| | | /** |
| | | * è·åå¤ä¸ªHashä¸çæ°æ® |
| | | * |
| | | * @param key Redisé® |
| | | * @param hKeys Hashé®éå |
| | | * @return Hash对象éå |
| | | */ |
| | | public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) |
| | | { |
| | | return redisTemplate.opsForHash().multiGet(key, hKeys); |
| | | } |
| | | |
| | | /** |
| | | * è·å¾ç¼åçåºæ¬å¯¹è±¡å表 |
| | | * |
| | | * @param pattern å符串åç¼ |
| | | * @return 对象å表 |
| | | */ |
| | | public Collection<String> keys(final String pattern) |
| | | { |
| | | return redisTemplate.keys(pattern); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | /** |
| | | * æä½ç¶æ |
| | | * |
| | | * @author ruoyi |
| | | * |
| | | */ |
| | | public enum BusinessStatus |
| | | { |
| | | /** |
| | | * æå |
| | | */ |
| | | SUCCESS, |
| | | |
| | | /** |
| | | * 失败 |
| | | */ |
| | | FAIL, |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | /** |
| | | * ä¸å¡æä½ç±»å |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public enum BusinessType |
| | | { |
| | | /** |
| | | * å
¶å® |
| | | */ |
| | | OTHER, |
| | | |
| | | /** |
| | | * æ°å¢ |
| | | */ |
| | | INSERT, |
| | | |
| | | /** |
| | | * ä¿®æ¹ |
| | | */ |
| | | UPDATE, |
| | | |
| | | /** |
| | | * å é¤ |
| | | */ |
| | | DELETE, |
| | | |
| | | /** |
| | | * ææ |
| | | */ |
| | | GRANT, |
| | | |
| | | /** |
| | | * å¯¼åº |
| | | */ |
| | | EXPORT, |
| | | |
| | | /** |
| | | * 导å
¥ |
| | | */ |
| | | IMPORT, |
| | | |
| | | /** |
| | | * 强é |
| | | */ |
| | | FORCE, |
| | | |
| | | /** |
| | | * çæä»£ç |
| | | */ |
| | | GENCODE, |
| | | |
| | | /** |
| | | * æ¸
ç©ºæ°æ® |
| | | */ |
| | | CLEAN, |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | /** |
| | | * æ°æ®æº |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public enum DataSourceType |
| | | { |
| | | /** |
| | | * ä¸»åº |
| | | */ |
| | | MASTER, |
| | | |
| | | /** |
| | | * ä»åº |
| | | */ |
| | | SLAVE |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | /** |
| | | * æä½äººç±»å« |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public enum OperatorType |
| | | { |
| | | /** |
| | | * å
¶å® |
| | | */ |
| | | OTHER, |
| | | |
| | | /** |
| | | * åå°ç¨æ· |
| | | */ |
| | | MANAGE, |
| | | |
| | | /** |
| | | * ææºç«¯ç¨æ· |
| | | */ |
| | | MOBILE |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.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.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.utils;
|
| | |
|
| | | 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;
|
| | |
|
| | | /**
|
| | | * åå
¸å·¥å
·ç±»
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class DictUtils
|
| | | {
|
| | | /**
|
| | | * 设置åå
¸ç¼å
|
| | | * |
| | | * @param key åæ°é®
|
| | | * @param dictDatas åå
¸æ°æ®å表
|
| | | */
|
| | | public static void setDictCache(String key, List<SysDictData> dictDatas)
|
| | | {
|
| | | SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas);
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·ååå
¸ç¼å
|
| | | * |
| | | * @param key åæ°é®
|
| | | * @return dictDatas åå
¸æ°æ®å表
|
| | | */
|
| | | public static List<SysDictData> getDictCache(String key)
|
| | | {
|
| | | Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
|
| | | if (StringUtils.isNotNull(cacheObj))
|
| | | {
|
| | | List<SysDictData> DictDatas = StringUtils.cast(cacheObj);
|
| | | return DictDatas;
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ¸
空åå
¸ç¼å
|
| | | */
|
| | | public static void clearDictCache()
|
| | | {
|
| | | Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(Constants.SYS_DICT_KEY + "*");
|
| | | SpringUtils.getBean(RedisCache.class).deleteObject(keys);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 设置cache key
|
| | | * |
| | | * @param configKey åæ°é®
|
| | | * @return ç¼åé®key
|
| | | */
|
| | | public static String getCacheKey(String configKey)
|
| | | {
|
| | | return Constants.SYS_DICT_KEY + configKey;
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 org.springframework.security.core.Authentication; |
| | | 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; |
| | | |
| | | /** |
| | | * å®å
¨æå¡å·¥å
·ç±» |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SecurityUtils |
| | | { |
| | | /** |
| | | * è·åç¨æ·è´¦æ· |
| | | **/ |
| | | public static String getUsername() |
| | | { |
| | | try |
| | | { |
| | | return getLoginUser().getUsername(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new CustomException("è·åç¨æ·è´¦æ·å¼å¸¸", HttpStatus.UNAUTHORIZED); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åç¨æ· |
| | | **/ |
| | | public static LoginUser getLoginUser() |
| | | { |
| | | try |
| | | { |
| | | return (LoginUser) getAuthentication().getPrincipal(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new CustomException("è·åç¨æ·ä¿¡æ¯å¼å¸¸", HttpStatus.UNAUTHORIZED); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åAuthentication |
| | | */ |
| | | public static Authentication getAuthentication() |
| | | { |
| | | return SecurityContextHolder.getContext().getAuthentication(); |
| | | } |
| | | |
| | | /** |
| | | * çæBCryptPasswordEncoderå¯ç |
| | | * |
| | | * @param password å¯ç |
| | | * @return å å¯å符串 |
| | | */ |
| | | public static String encryptPassword(String password) |
| | | { |
| | | BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
| | | return passwordEncoder.encode(password); |
| | | } |
| | | |
| | | /** |
| | | * 夿å¯ç æ¯å¦ç¸å |
| | | * |
| | | * @param rawPassword çå®å¯ç |
| | | * @param encodedPassword å å¯åå符 |
| | | * @return ç»æ |
| | | */ |
| | | public static boolean matchesPassword(String rawPassword, String encodedPassword) |
| | | { |
| | | BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
| | | return passwordEncoder.matches(rawPassword, encodedPassword); |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦ä¸ºç®¡çå |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return ç»æ |
| | | */ |
| | | public static boolean isAdmin(Long userId) |
| | | { |
| | | return userId != null && 1L == userId; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.file; |
| | | |
| | | import java.io.File; |
| | | 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.StringUtils; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | |
| | | /** |
| | | * æä»¶ä¸ä¼ å·¥å
·ç±» |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class FileUploadUtils |
| | | { |
| | | /** |
| | | * é»è®¤å¤§å° 50M |
| | | */ |
| | | public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024; |
| | | |
| | | /** |
| | | * é»è®¤çæä»¶åæå¤§é¿åº¦ 100 |
| | | */ |
| | | public static final int DEFAULT_FILE_NAME_LENGTH = 100; |
| | | |
| | | /** |
| | | * é»è®¤ä¸ä¼ çå°å |
| | | */ |
| | | private static String defaultBaseDir = RuoYiConfig.getProfile(); |
| | | |
| | | public static void setDefaultBaseDir(String defaultBaseDir) |
| | | { |
| | | FileUploadUtils.defaultBaseDir = defaultBaseDir; |
| | | } |
| | | |
| | | public static String getDefaultBaseDir() |
| | | { |
| | | return defaultBaseDir; |
| | | } |
| | | |
| | | /** |
| | | * 以é»è®¤é
ç½®è¿è¡æä»¶ä¸ä¼ |
| | | * |
| | | * @param file ä¸ä¼ çæä»¶ |
| | | * @return æä»¶åç§° |
| | | * @throws Exception |
| | | */ |
| | | public static final String upload(MultipartFile file) throws IOException |
| | | { |
| | | try |
| | | { |
| | | return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new IOException(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®æä»¶è·¯å¾ä¸ä¼ |
| | | * |
| | | * @param baseDir ç¸å¯¹åºç¨çåºç®å½ |
| | | * @param file ä¸ä¼ çæä»¶ |
| | | * @return æä»¶åç§° |
| | | * @throws IOException |
| | | */ |
| | | public static final String upload(String baseDir, MultipartFile file) throws IOException |
| | | { |
| | | try |
| | | { |
| | | return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new IOException(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æä»¶ä¸ä¼ |
| | | * |
| | | * @param baseDir ç¸å¯¹åºç¨çåºç®å½ |
| | | * @param file ä¸ä¼ çæä»¶ |
| | | * @param extension ä¸ä¼ æä»¶ç±»å |
| | | * @return è¿åä¸ä¼ æåçæä»¶å |
| | | * @throws FileSizeLimitExceededException 妿è¶
åºæå¤§å¤§å° |
| | | * @throws FileNameLengthLimitExceededException æä»¶åå¤ªé¿ |
| | | * @throws IOException æ¯å¦è¯»åæä»¶åºéæ¶ |
| | | * @throws InvalidExtensionException æä»¶æ ¡éªå¼å¸¸ |
| | | */ |
| | | public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension) |
| | | throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, |
| | | InvalidExtensionException |
| | | { |
| | | int fileNamelength = file.getOriginalFilename().length(); |
| | | if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) |
| | | { |
| | | throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); |
| | | } |
| | | |
| | | assertAllowed(file, allowedExtension); |
| | | |
| | | String fileName = extractFilename(file); |
| | | |
| | | File desc = getAbsoluteFile(baseDir, fileName); |
| | | file.transferTo(desc); |
| | | String pathFileName = getPathFileName(baseDir, fileName); |
| | | return pathFileName; |
| | | } |
| | | |
| | | /** |
| | | * ç¼ç æä»¶å |
| | | */ |
| | | public static final String extractFilename(MultipartFile file) |
| | | { |
| | | String fileName = file.getOriginalFilename(); |
| | | String extension = getExtension(file); |
| | | fileName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension; |
| | | return fileName; |
| | | } |
| | | |
| | | private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException |
| | | { |
| | | File desc = new File(uploadDir + File.separator + fileName); |
| | | |
| | | if (!desc.getParentFile().exists()) |
| | | { |
| | | desc.getParentFile().mkdirs(); |
| | | } |
| | | // è§£å³undertowæä»¶ä¸ä¼ bug,å åºå±å®ç°ä¸å,æ éåå»ºæ°æä»¶ |
| | | // if (!desc.exists()) |
| | | // { |
| | | // desc.createNewFile(); |
| | | // } |
| | | return desc; |
| | | } |
| | | |
| | | private static final String getPathFileName(String uploadDir, String fileName) throws IOException |
| | | { |
| | | int dirLastIndex = RuoYiConfig.getProfile().length() + 1; |
| | | String currentDir = StringUtils.substring(uploadDir, dirLastIndex); |
| | | String pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName; |
| | | return pathFileName; |
| | | } |
| | | |
| | | /** |
| | | * æä»¶å¤§å°æ ¡éª |
| | | * |
| | | * @param file ä¸ä¼ çæä»¶ |
| | | * @return |
| | | * @throws FileSizeLimitExceededException 妿è¶
åºæå¤§å¤§å° |
| | | * @throws InvalidExtensionException |
| | | */ |
| | | public static final void assertAllowed(MultipartFile file, String[] allowedExtension) |
| | | throws FileSizeLimitExceededException, InvalidExtensionException |
| | | { |
| | | long size = file.getSize(); |
| | | if (DEFAULT_MAX_SIZE != -1 && size > DEFAULT_MAX_SIZE) |
| | | { |
| | | throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024); |
| | | } |
| | | |
| | | String fileName = file.getOriginalFilename(); |
| | | String extension = getExtension(file); |
| | | if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) |
| | | { |
| | | if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) |
| | | { |
| | | throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, |
| | | fileName); |
| | | } |
| | | else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) |
| | | { |
| | | throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension, |
| | | fileName); |
| | | } |
| | | else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) |
| | | { |
| | | throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension, |
| | | fileName); |
| | | } |
| | | else |
| | | { |
| | | throw new InvalidExtensionException(allowedExtension, extension, fileName); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 夿MIMEç±»åæ¯å¦æ¯å
许çMIMEç±»å |
| | | * |
| | | * @param extension |
| | | * @param allowedExtension |
| | | * @return |
| | | */ |
| | | public static final boolean isAllowedExtension(String extension, String[] allowedExtension) |
| | | { |
| | | for (String str : allowedExtension) |
| | | { |
| | | if (str.equalsIgnoreCase(extension)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * è·åæä»¶åçåç¼ |
| | | * |
| | | * @param file 表åæä»¶ |
| | | * @return åç¼å |
| | | */ |
| | | public static final String getExtension(MultipartFile file) |
| | | { |
| | | String extension = FilenameUtils.getExtension(file.getOriginalFilename()); |
| | | if (StringUtils.isEmpty(extension)) |
| | | { |
| | | extension = MimeTypeUtils.getExtension(file.getContentType()); |
| | | } |
| | | return extension; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.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();
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.utils.ip; |
| | | |
| | | 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; |
| | | |
| | | /** |
| | | * è·åå°åç±» |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class AddressUtils |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(AddressUtils.class); |
| | | |
| | | // IPå°åæ¥è¯¢ |
| | | public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp"; |
| | | |
| | | // æªç¥å°å |
| | | public static final String UNKNOWN = "XX XX"; |
| | | |
| | | public static String getRealAddressByIP(String ip) |
| | | { |
| | | String address = UNKNOWN; |
| | | // å
ç½ä¸æ¥è¯¢ |
| | | if (IpUtils.internalIp(ip)) |
| | | { |
| | | return "å
ç½IP"; |
| | | } |
| | | if (RuoYiConfig.isAddressEnabled()) |
| | | { |
| | | try |
| | | { |
| | | String rspStr = HttpUtils.sendGet(IP_URL, "ip=" + ip + "&json=true", Constants.GBK); |
| | | if (StringUtils.isEmpty(rspStr)) |
| | | { |
| | | log.error("è·åå°çä½ç½®å¼å¸¸ {}", ip); |
| | | return UNKNOWN; |
| | | } |
| | | JSONObject obj = JSONObject.parseObject(rspStr); |
| | | String region = obj.getString("pro"); |
| | | String city = obj.getString("city"); |
| | | return String.format("%s %s", region, city); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | log.error("è·åå°çä½ç½®å¼å¸¸ {}", ip); |
| | | } |
| | | } |
| | | return address; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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;
|
| | | }
|
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.uuid; |
| | | |
| | | import com.ruoyi.common.utils.uuid.UUID; |
| | | |
| | | /** |
| | | * IDçæå¨å·¥å
·ç±» |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class IdUtils |
| | | { |
| | | /** |
| | | * è·åéæºUUID |
| | | * |
| | | * @return éæºUUID |
| | | */ |
| | | public static String randomUUID() |
| | | { |
| | | return UUID.randomUUID().toString(); |
| | | } |
| | | |
| | | /** |
| | | * ç®åçUUIDï¼å»æäºæ¨ªçº¿ |
| | | * |
| | | * @return ç®åçUUIDï¼å»æäºæ¨ªçº¿ |
| | | */ |
| | | public static String simpleUUID() |
| | | { |
| | | return UUID.randomUUID().toString(true); |
| | | } |
| | | |
| | | /** |
| | | * è·åéæºUUIDï¼ä½¿ç¨æ§è½æ´å¥½çThreadLocalRandomçæUUID |
| | | * |
| | | * @return éæºUUID |
| | | */ |
| | | public static String fastUUID() |
| | | { |
| | | return UUID.fastUUID().toString(); |
| | | } |
| | | |
| | | /** |
| | | * ç®åçUUIDï¼å»æäºæ¨ªçº¿ï¼ä½¿ç¨æ§è½æ´å¥½çThreadLocalRandomçæUUID |
| | | * |
| | | * @return ç®åçUUIDï¼å»æäºæ¨ªçº¿ |
| | | */ |
| | | public static String fastSimpleUUID() |
| | | { |
| | | return UUID.fastUUID().toString(true); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.utils.uuid; |
| | | |
| | | import java.security.MessageDigest; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.security.SecureRandom; |
| | | import java.util.Random; |
| | | import java.util.concurrent.ThreadLocalRandom; |
| | | import com.ruoyi.common.exception.UtilException; |
| | | |
| | | /** |
| | | * æä¾éç¨å¯ä¸è¯å«ç ï¼universally unique identifierï¼ï¼UUIDï¼å®ç° |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public final class UUID implements java.io.Serializable, Comparable<UUID> |
| | | { |
| | | private static final long serialVersionUID = -1185015143654744140L; |
| | | |
| | | /** |
| | | * SecureRandom çåä¾ |
| | | * |
| | | */ |
| | | private static class Holder |
| | | { |
| | | static final SecureRandom numberGenerator = getSecureRandom(); |
| | | } |
| | | |
| | | /** æ¤UUIDçæé«64ææä½ */ |
| | | private final long mostSigBits; |
| | | |
| | | /** æ¤UUIDçæä½64ææä½ */ |
| | | private final long leastSigBits; |
| | | |
| | | /** |
| | | * ç§ææé |
| | | * |
| | | * @param data æ°æ® |
| | | */ |
| | | private UUID(byte[] data) |
| | | { |
| | | long msb = 0; |
| | | long lsb = 0; |
| | | assert data.length == 16 : "data must be 16 bytes in length"; |
| | | for (int i = 0; i < 8; i++) |
| | | { |
| | | msb = (msb << 8) | (data[i] & 0xff); |
| | | } |
| | | for (int i = 8; i < 16; i++) |
| | | { |
| | | lsb = (lsb << 8) | (data[i] & 0xff); |
| | | } |
| | | this.mostSigBits = msb; |
| | | this.leastSigBits = lsb; |
| | | } |
| | | |
| | | /** |
| | | * ä½¿ç¨æå®çæ°æ®æé æ°ç UUIDã |
| | | * |
| | | * @param mostSigBits ç¨äº {@code UUID} çæé«ææ 64 ä½ |
| | | * @param leastSigBits ç¨äº {@code UUID} çæä½ææ 64 ä½ |
| | | */ |
| | | public UUID(long mostSigBits, long leastSigBits) |
| | | { |
| | | this.mostSigBits = mostSigBits; |
| | | this.leastSigBits = leastSigBits; |
| | | } |
| | | |
| | | /** |
| | | * è·åç±»å 4ï¼ä¼ªéæºçæçï¼UUID çéæå·¥åã 使ç¨å å¯çæ¬å°çº¿ç¨ä¼ªéæºæ°çæå¨çæè¯¥ UUIDã |
| | | * |
| | | * @return éæºçæç {@code UUID} |
| | | */ |
| | | public static UUID fastUUID() |
| | | { |
| | | return randomUUID(false); |
| | | } |
| | | |
| | | /** |
| | | * è·åç±»å 4ï¼ä¼ªéæºçæçï¼UUID çéæå·¥åã 使ç¨å å¯çå¼ºä¼ªéæºæ°çæå¨çæè¯¥ UUIDã |
| | | * |
| | | * @return éæºçæç {@code UUID} |
| | | */ |
| | | public static UUID randomUUID() |
| | | { |
| | | return randomUUID(true); |
| | | } |
| | | |
| | | /** |
| | | * è·åç±»å 4ï¼ä¼ªéæºçæçï¼UUID çéæå·¥åã 使ç¨å å¯çå¼ºä¼ªéæºæ°çæå¨çæè¯¥ UUIDã |
| | | * |
| | | * @param isSecure æ¯å¦ä½¿ç¨{@link SecureRandom}妿æ¯å¯ä»¥è·å¾æ´å®å
¨çéæºç ï¼å¦åå¯ä»¥å¾å°æ´å¥½çæ§è½ |
| | | * @return éæºçæç {@code UUID} |
| | | */ |
| | | public static UUID randomUUID(boolean isSecure) |
| | | { |
| | | final Random ng = isSecure ? Holder.numberGenerator : getRandom(); |
| | | |
| | | byte[] randomBytes = new byte[16]; |
| | | ng.nextBytes(randomBytes); |
| | | randomBytes[6] &= 0x0f; /* clear version */ |
| | | randomBytes[6] |= 0x40; /* set to version 4 */ |
| | | randomBytes[8] &= 0x3f; /* clear variant */ |
| | | randomBytes[8] |= 0x80; /* set to IETF variant */ |
| | | return new UUID(randomBytes); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®æå®çåèæ°ç»è·åç±»å 3ï¼åºäºåç§°çï¼UUID çéæå·¥åã |
| | | * |
| | | * @param name ç¨äºæé UUID çåèæ°ç»ã |
| | | * |
| | | * @return æ ¹æ®æå®æ°ç»çæç {@code UUID} |
| | | */ |
| | | public static UUID nameUUIDFromBytes(byte[] name) |
| | | { |
| | | MessageDigest md; |
| | | try |
| | | { |
| | | md = MessageDigest.getInstance("MD5"); |
| | | } |
| | | catch (NoSuchAlgorithmException nsae) |
| | | { |
| | | throw new InternalError("MD5 not supported"); |
| | | } |
| | | byte[] md5Bytes = md.digest(name); |
| | | md5Bytes[6] &= 0x0f; /* clear version */ |
| | | md5Bytes[6] |= 0x30; /* set to version 3 */ |
| | | md5Bytes[8] &= 0x3f; /* clear variant */ |
| | | md5Bytes[8] |= 0x80; /* set to IETF variant */ |
| | | return new UUID(md5Bytes); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ® {@link #toString()} æ¹æ³ä¸æè¿°çå符串æ å表示形å¼å建{@code UUID}ã |
| | | * |
| | | * @param name æå® {@code UUID} å符串 |
| | | * @return å
·ææå®å¼ç {@code UUID} |
| | | * @throws IllegalArgumentException 妿 name ä¸ {@link #toString} ä¸æè¿°çå符串表示形å¼ä¸ç¬¦æåºæ¤å¼å¸¸ |
| | | * |
| | | */ |
| | | public static UUID fromString(String name) |
| | | { |
| | | String[] components = name.split("-"); |
| | | if (components.length != 5) |
| | | { |
| | | throw new IllegalArgumentException("Invalid UUID string: " + name); |
| | | } |
| | | for (int i = 0; i < 5; i++) |
| | | { |
| | | components[i] = "0x" + components[i]; |
| | | } |
| | | |
| | | long mostSigBits = Long.decode(components[0]).longValue(); |
| | | mostSigBits <<= 16; |
| | | mostSigBits |= Long.decode(components[1]).longValue(); |
| | | mostSigBits <<= 16; |
| | | mostSigBits |= Long.decode(components[2]).longValue(); |
| | | |
| | | long leastSigBits = Long.decode(components[3]).longValue(); |
| | | leastSigBits <<= 48; |
| | | leastSigBits |= Long.decode(components[4]).longValue(); |
| | | |
| | | return new UUID(mostSigBits, leastSigBits); |
| | | } |
| | | |
| | | /** |
| | | * è¿åæ¤ UUID ç 128 ä½å¼ä¸çæä½ææ 64 ä½ã |
| | | * |
| | | * @return æ¤ UUID ç 128 ä½å¼ä¸çæä½ææ 64 ä½ã |
| | | */ |
| | | public long getLeastSignificantBits() |
| | | { |
| | | return leastSigBits; |
| | | } |
| | | |
| | | /** |
| | | * è¿åæ¤ UUID ç 128 ä½å¼ä¸çæé«ææ 64 ä½ã |
| | | * |
| | | * @return æ¤ UUID ç 128 ä½å¼ä¸æé«ææ 64 ä½ã |
| | | */ |
| | | public long getMostSignificantBits() |
| | | { |
| | | return mostSigBits; |
| | | } |
| | | |
| | | /** |
| | | * 䏿¤ {@code UUID} ç¸å
³èççæ¬å·. çæ¬å·æè¿°æ¤ {@code UUID} æ¯å¦ä½çæçã |
| | | * <p> |
| | | * çæ¬å·å
·æä»¥ä¸å«æ: |
| | | * <ul> |
| | | * <li>1 åºäºæ¶é´ç UUID |
| | | * <li>2 DCE å®å
¨ UUID |
| | | * <li>3 åºäºåç§°ç UUID |
| | | * <li>4 éæºçæç UUID |
| | | * </ul> |
| | | * |
| | | * @return æ¤ {@code UUID} ççæ¬å· |
| | | */ |
| | | public int version() |
| | | { |
| | | // Version is bits masked by 0x000000000000F000 in MS long |
| | | return (int) ((mostSigBits >> 12) & 0x0f); |
| | | } |
| | | |
| | | /** |
| | | * 䏿¤ {@code UUID} ç¸å
³èçåä½å·ãåä½å·æè¿° {@code UUID} çå¸å±ã |
| | | * <p> |
| | | * åä½å·å
·æä»¥ä¸å«æï¼ |
| | | * <ul> |
| | | * <li>0 为 NCS ååå
¼å®¹ä¿ç |
| | | * <li>2 <a href="http://www.ietf.org/rfc/rfc4122.txt">IETF RFC 4122</a>(Leach-Salz), ç¨äºæ¤ç±» |
| | | * <li>6 ä¿çï¼å¾®è½¯ååå
¼å®¹ |
| | | * <li>7 ä¿çä¾ä»¥åå®ä¹ä½¿ç¨ |
| | | * </ul> |
| | | * |
| | | * @return æ¤ {@code UUID} ç¸å
³èçåä½å· |
| | | */ |
| | | public int variant() |
| | | { |
| | | // This field is composed of a varying number of bits. |
| | | // 0 - - Reserved for NCS backward compatibility |
| | | // 1 0 - The IETF aka Leach-Salz variant (used by this class) |
| | | // 1 1 0 Reserved, Microsoft backward compatibility |
| | | // 1 1 1 Reserved for future definition. |
| | | return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62))) & (leastSigBits >> 63)); |
| | | } |
| | | |
| | | /** |
| | | * 䏿¤ UUID ç¸å
³èçæ¶é´æ³å¼ã |
| | | * |
| | | * <p> |
| | | * 60 ä½çæ¶é´æ³å¼æ ¹æ®æ¤ {@code UUID} ç time_lowãtime_mid å time_hi åæ®µæé ã<br> |
| | | * æå¾å°çæ¶é´æ³ä»¥ 100 毫微ç§ä¸ºåä½ï¼ä» UTCï¼éç¨åè°æ¶é´ï¼ 1582 å¹´ 10 æ 15 æ¥é¶æ¶å¼å§ã |
| | | * |
| | | * <p> |
| | | * æ¶é´æ³å¼ä»
å¨å¨åºäºæ¶é´ç UUIDï¼å
¶ version ç±»å为 1ï¼ä¸æææä¹ã<br> |
| | | * å¦ææ¤ {@code UUID} 䏿¯åºäºæ¶é´ç UUIDï¼åæ¤æ¹æ³æåº UnsupportedOperationExceptionã |
| | | * |
| | | * @throws UnsupportedOperationException å¦ææ¤ {@code UUID} 䏿¯ version 为 1 ç UUIDã |
| | | */ |
| | | public long timestamp() throws UnsupportedOperationException |
| | | { |
| | | checkTimeBase(); |
| | | return (mostSigBits & 0x0FFFL) << 48// |
| | | | ((mostSigBits >> 16) & 0x0FFFFL) << 32// |
| | | | mostSigBits >>> 32; |
| | | } |
| | | |
| | | /** |
| | | * 䏿¤ UUID ç¸å
³èçæ¶éåºåå¼ã |
| | | * |
| | | * <p> |
| | | * 14 ä½çæ¶éåºå弿 ¹æ®æ¤ UUID ç clock_seq åæ®µæé ãclock_seq åæ®µç¨äºä¿è¯å¨åºäºæ¶é´ç UUID ä¸çæ¶é´å¯ä¸æ§ã |
| | | * <p> |
| | | * {@code clockSequence} å¼ä»
å¨åºäºæ¶é´ç UUIDï¼å
¶ version ç±»å为 1ï¼ä¸æææä¹ã å¦ææ¤ UUID 䏿¯åºäºæ¶é´ç UUIDï¼åæ¤æ¹æ³æåº |
| | | * UnsupportedOperationExceptionã |
| | | * |
| | | * @return æ¤ {@code UUID} çæ¶éåºå |
| | | * |
| | | * @throws UnsupportedOperationException å¦ææ¤ UUID ç version ä¸ä¸º 1 |
| | | */ |
| | | public int clockSequence() throws UnsupportedOperationException |
| | | { |
| | | checkTimeBase(); |
| | | return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48); |
| | | } |
| | | |
| | | /** |
| | | * 䏿¤ UUID ç¸å
³çèç¹å¼ã |
| | | * |
| | | * <p> |
| | | * 48 ä½çèç¹å¼æ ¹æ®æ¤ UUID ç node åæ®µæé ãæ¤åæ®µæ¨å¨ç¨äºä¿åæºå¨ç IEEE 802 å°åï¼è¯¥å°åç¨äºçææ¤ UUID 以ä¿è¯ç©ºé´å¯ä¸æ§ã |
| | | * <p> |
| | | * èç¹å¼ä»
å¨åºäºæ¶é´ç UUIDï¼å
¶ version ç±»å为 1ï¼ä¸æææä¹ã<br> |
| | | * å¦ææ¤ UUID 䏿¯åºäºæ¶é´ç UUIDï¼åæ¤æ¹æ³æåº UnsupportedOperationExceptionã |
| | | * |
| | | * @return æ¤ {@code UUID} çèç¹å¼ |
| | | * |
| | | * @throws UnsupportedOperationException å¦ææ¤ UUID ç version ä¸ä¸º 1 |
| | | */ |
| | | public long node() throws UnsupportedOperationException |
| | | { |
| | | checkTimeBase(); |
| | | return leastSigBits & 0x0000FFFFFFFFFFFFL; |
| | | } |
| | | |
| | | /** |
| | | * è¿åæ¤{@code UUID} çå符串表ç°å½¢å¼ã |
| | | * |
| | | * <p> |
| | | * UUID çå符串表示形å¼ç±æ¤ BNF æè¿°ï¼ |
| | | * |
| | | * <pre> |
| | | * {@code |
| | | * UUID = <time_low>-<time_mid>-<time_high_and_version>-<variant_and_sequence>-<node> |
| | | * time_low = 4*<hexOctet> |
| | | * time_mid = 2*<hexOctet> |
| | | * time_high_and_version = 2*<hexOctet> |
| | | * variant_and_sequence = 2*<hexOctet> |
| | | * node = 6*<hexOctet> |
| | | * hexOctet = <hexDigit><hexDigit> |
| | | * hexDigit = [0-9a-fA-F] |
| | | * } |
| | | * </pre> |
| | | * |
| | | * </blockquote> |
| | | * |
| | | * @return æ¤{@code UUID} çå符串表ç°å½¢å¼ |
| | | * @see #toString(boolean) |
| | | */ |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return toString(false); |
| | | } |
| | | |
| | | /** |
| | | * è¿åæ¤{@code UUID} çå符串表ç°å½¢å¼ã |
| | | * |
| | | * <p> |
| | | * UUID çå符串表示形å¼ç±æ¤ BNF æè¿°ï¼ |
| | | * |
| | | * <pre> |
| | | * {@code |
| | | * UUID = <time_low>-<time_mid>-<time_high_and_version>-<variant_and_sequence>-<node> |
| | | * time_low = 4*<hexOctet> |
| | | * time_mid = 2*<hexOctet> |
| | | * time_high_and_version = 2*<hexOctet> |
| | | * variant_and_sequence = 2*<hexOctet> |
| | | * node = 6*<hexOctet> |
| | | * hexOctet = <hexDigit><hexDigit> |
| | | * hexDigit = [0-9a-fA-F] |
| | | * } |
| | | * </pre> |
| | | * |
| | | * </blockquote> |
| | | * |
| | | * @param isSimple æ¯å¦ç®å模å¼ï¼ç®å模å¼ä¸ºä¸å¸¦'-'çUUIDå符串 |
| | | * @return æ¤{@code UUID} çå符串表ç°å½¢å¼ |
| | | */ |
| | | public String toString(boolean isSimple) |
| | | { |
| | | final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36); |
| | | // time_low |
| | | builder.append(digits(mostSigBits >> 32, 8)); |
| | | if (false == isSimple) |
| | | { |
| | | builder.append('-'); |
| | | } |
| | | // time_mid |
| | | builder.append(digits(mostSigBits >> 16, 4)); |
| | | if (false == isSimple) |
| | | { |
| | | builder.append('-'); |
| | | } |
| | | // time_high_and_version |
| | | builder.append(digits(mostSigBits, 4)); |
| | | if (false == isSimple) |
| | | { |
| | | builder.append('-'); |
| | | } |
| | | // variant_and_sequence |
| | | builder.append(digits(leastSigBits >> 48, 4)); |
| | | if (false == isSimple) |
| | | { |
| | | builder.append('-'); |
| | | } |
| | | // node |
| | | builder.append(digits(leastSigBits, 12)); |
| | | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | /** |
| | | * è¿åæ¤ UUID çåå¸ç ã |
| | | * |
| | | * @return UUID çåå¸ç å¼ã |
| | | */ |
| | | @Override |
| | | public int hashCode() |
| | | { |
| | | long hilo = mostSigBits ^ leastSigBits; |
| | | return ((int) (hilo >> 32)) ^ (int) hilo; |
| | | } |
| | | |
| | | /** |
| | | * å°æ¤å¯¹è±¡ä¸æå®å¯¹è±¡æ¯è¾ã |
| | | * <p> |
| | | * å½ä¸ä»
å½åæ°ä¸ä¸º {@code null}ãèæ¯ä¸ä¸ª UUID 对象ãå
·æä¸æ¤ UUID ç¸åç varriantãå
å«ç¸åçå¼ï¼æ¯ä¸ä½åç¸åï¼æ¶ï¼ç»ææä¸º {@code true}ã |
| | | * |
| | | * @param obj è¦ä¸ä¹æ¯è¾ç对象 |
| | | * |
| | | * @return å¦æå¯¹è±¡ç¸åï¼åè¿å {@code true}ï¼å¦åè¿å {@code false} |
| | | */ |
| | | @Override |
| | | public boolean equals(Object obj) |
| | | { |
| | | if ((null == obj) || (obj.getClass() != UUID.class)) |
| | | { |
| | | return false; |
| | | } |
| | | UUID id = (UUID) obj; |
| | | return (mostSigBits == id.mostSigBits && leastSigBits == id.leastSigBits); |
| | | } |
| | | |
| | | // Comparison Operations |
| | | |
| | | /** |
| | | * å°æ¤ UUID 䏿å®ç UUID æ¯è¾ã |
| | | * |
| | | * <p> |
| | | * å¦æä¸¤ä¸ª UUID ä¸åï¼ä¸ç¬¬ä¸ä¸ª UUID çæé«ææå段大äºç¬¬äºä¸ª UUID ç对åºå段ï¼å第ä¸ä¸ª UUID 大äºç¬¬äºä¸ª UUIDã |
| | | * |
| | | * @param val 䏿¤ UUID æ¯è¾ç UUID |
| | | * |
| | | * @return 卿¤ UUID å°äºãçäºæå¤§äº val æ¶ï¼åå«è¿å -1ã0 æ 1ã |
| | | * |
| | | */ |
| | | @Override |
| | | public int compareTo(UUID val) |
| | | { |
| | | // The ordering is intentionally set up so that the UUIDs |
| | | // can simply be numerically compared as two numbers |
| | | return (this.mostSigBits < val.mostSigBits ? -1 : // |
| | | (this.mostSigBits > val.mostSigBits ? 1 : // |
| | | (this.leastSigBits < val.leastSigBits ? -1 : // |
| | | (this.leastSigBits > val.leastSigBits ? 1 : // |
| | | 0)))); |
| | | } |
| | | |
| | | // ------------------------------------------------------------------------------------------------------------------- |
| | | // Private method start |
| | | /** |
| | | * è¿åæå®æ°å对åºçhexå¼ |
| | | * |
| | | * @param val å¼ |
| | | * @param digits ä½ |
| | | * @return å¼ |
| | | */ |
| | | private static String digits(long val, int digits) |
| | | { |
| | | long hi = 1L << (digits * 4); |
| | | return Long.toHexString(hi | (val & (hi - 1))).substring(1); |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥æ¯å¦ä¸ºtime-basedçæ¬UUID |
| | | */ |
| | | private void checkTimeBase() |
| | | { |
| | | if (version() != 1) |
| | | { |
| | | throw new UnsupportedOperationException("Not a time-based UUID"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·å{@link SecureRandom}ï¼ç±»æä¾å å¯çå¼ºéæºæ°çæå¨ (RNG) |
| | | * |
| | | * @return {@link SecureRandom} |
| | | */ |
| | | public static SecureRandom getSecureRandom() |
| | | { |
| | | try |
| | | { |
| | | return SecureRandom.getInstance("SHA1PRNG"); |
| | | } |
| | | catch (NoSuchAlgorithmException e) |
| | | { |
| | | throw new UtilException(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åéæºæ°çæå¨å¯¹è±¡<br> |
| | | * ThreadLocalRandomæ¯JDK 7ä¹åæä¾å¹¶å产çéæºæ°ï¼è½å¤è§£å³å¤ä¸ªçº¿ç¨åççç«äºäºå¤ºã |
| | | * |
| | | * @return {@link ThreadLocalRandom} |
| | | */ |
| | | public static ThreadLocalRandom getRandom() |
| | | { |
| | | return ThreadLocalRandom.current(); |
| | | } |
| | | } |
copy from ruoyi/src/main/resources/application-dev.yml
copy to ruoyi-common/src/main/resources/application-dev.yml
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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>
|
| | | <exclusions>
|
| | | <exclusion>
|
| | | <artifactId>spring-boot-starter-tomcat</artifactId>
|
| | | <groupId>org.springframework.boot</groupId>
|
| | | </exclusion>
|
| | | </exclusions>
|
| | | </dependency>
|
| | |
|
| | | <!-- web 容å¨ä½¿ç¨ undertow æ§è½æ´å¼º -->
|
| | | <dependency>
|
| | | <groupId>org.springframework.boot</groupId>
|
| | | <artifactId>spring-boot-starter-undertow</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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.aspectj; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.aspectj.lang.Signature; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.annotation.Before; |
| | | 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.web.service.TokenService; |
| | | |
| | | /** |
| | | * æ°æ®è¿æ»¤å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Aspect |
| | | @Component |
| | | public class DataScopeAspect |
| | | { |
| | | /** |
| | | * å
¨é¨æ°æ®æé |
| | | */ |
| | | public static final String DATA_SCOPE_ALL = "1"; |
| | | |
| | | /** |
| | | * èªå®æ°æ®æé |
| | | */ |
| | | public static final String DATA_SCOPE_CUSTOM = "2"; |
| | | |
| | | /** |
| | | * é¨é¨æ°æ®æé |
| | | */ |
| | | public static final String DATA_SCOPE_DEPT = "3"; |
| | | |
| | | /** |
| | | * é¨é¨å以䏿°æ®æé |
| | | */ |
| | | public static final String DATA_SCOPE_DEPT_AND_CHILD = "4"; |
| | | |
| | | /** |
| | | * ä»
æ¬äººæ°æ®æé |
| | | */ |
| | | public static final String DATA_SCOPE_SELF = "5"; |
| | | |
| | | /** |
| | | * æ°æ®æéè¿æ»¤å
³é®å |
| | | */ |
| | | public static final String DATA_SCOPE = "dataScope"; |
| | | |
| | | // é
ç½®ç»å
¥ç¹ |
| | | @Pointcut("@annotation(com.ruoyi.common.annotation.DataScope)") |
| | | public void dataScopePointCut() |
| | | { |
| | | } |
| | | |
| | | @Before("dataScopePointCut()") |
| | | public void doBefore(JoinPoint point) throws Throwable |
| | | { |
| | | handleDataScope(point); |
| | | } |
| | | |
| | | protected void handleDataScope(final JoinPoint joinPoint) |
| | | { |
| | | // è·å¾æ³¨è§£ |
| | | DataScope controllerDataScope = getAnnotationLog(joinPoint); |
| | | if (controllerDataScope == null) |
| | | { |
| | | return; |
| | | } |
| | | // è·åå½åçç¨æ· |
| | | LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest()); |
| | | SysUser currentUser = loginUser.getUser(); |
| | | if (currentUser != null) |
| | | { |
| | | // 妿æ¯è¶
级管çåï¼åä¸è¿æ»¤æ°æ® |
| | | if (!currentUser.isAdmin()) |
| | | { |
| | | dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), |
| | | controllerDataScope.userAlias()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ°æ®èå´è¿æ»¤ |
| | | * |
| | | * @param joinPoint åç¹ |
| | | * @param user ç¨æ· |
| | | * @param alias å«å |
| | | */ |
| | | public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias) |
| | | { |
| | | StringBuilder sqlString = new StringBuilder(); |
| | | |
| | | for (SysRole role : user.getRoles()) |
| | | { |
| | | String dataScope = role.getDataScope(); |
| | | if (DATA_SCOPE_ALL.equals(dataScope)) |
| | | { |
| | | sqlString = new StringBuilder(); |
| | | break; |
| | | } |
| | | else if (DATA_SCOPE_CUSTOM.equals(dataScope)) |
| | | { |
| | | sqlString.append(StringUtils.format( |
| | | " OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias, |
| | | role.getRoleId())); |
| | | } |
| | | else if (DATA_SCOPE_DEPT.equals(dataScope)) |
| | | { |
| | | sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId())); |
| | | } |
| | | else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) |
| | | { |
| | | sqlString.append(StringUtils.format( |
| | | " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", |
| | | deptAlias, user.getDeptId(), user.getDeptId())); |
| | | } |
| | | else if (DATA_SCOPE_SELF.equals(dataScope)) |
| | | { |
| | | if (StringUtils.isNotBlank(userAlias)) |
| | | { |
| | | sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId())); |
| | | } |
| | | else |
| | | { |
| | | // æ°æ®æé为ä»
æ¬äººä¸æ²¡æuserAliaså«å䏿¥è¯¢ä»»ä½æ°æ® |
| | | sqlString.append(" OR 1=0 "); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(sqlString.toString())) |
| | | { |
| | | BaseEntity baseEntity = (BaseEntity) joinPoint.getArgs()[0]; |
| | | baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦å卿³¨è§£ï¼å¦æåå¨å°±è·å |
| | | */ |
| | | private DataScope getAnnotationLog(JoinPoint joinPoint) |
| | | { |
| | | Signature signature = joinPoint.getSignature(); |
| | | MethodSignature methodSignature = (MethodSignature) signature; |
| | | Method method = methodSignature.getMethod(); |
| | | |
| | | if (method != null) |
| | | { |
| | | return method.getAnnotation(DataScope.class); |
| | | } |
| | | return null; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.aspectj; |
| | | |
| | | import java.util.Objects; |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.annotation.Around; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.annotation.Pointcut; |
| | | import org.aspectj.lang.reflect.MethodSignature; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | 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.datasource.DynamicDataSourceContextHolder; |
| | | |
| | | /** |
| | | * 夿°æ®æºå¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Aspect |
| | | @Order(1) |
| | | @Component |
| | | public class DataSourceAspect |
| | | { |
| | | protected Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | @Pointcut("@annotation(com.ruoyi.common.annotation.DataSource)" |
| | | + "|| @within(com.ruoyi.common.annotation.DataSource)") |
| | | public void dsPointCut() |
| | | { |
| | | |
| | | } |
| | | |
| | | @Around("dsPointCut()") |
| | | public Object around(ProceedingJoinPoint point) throws Throwable |
| | | { |
| | | DataSource dataSource = getDataSource(point); |
| | | |
| | | if (StringUtils.isNotNull(dataSource)) |
| | | { |
| | | DynamicDataSourceContextHolder.setDataSourceType(dataSource.value().name()); |
| | | } |
| | | |
| | | try |
| | | { |
| | | return point.proceed(); |
| | | } |
| | | finally |
| | | { |
| | | // éæ¯æ°æ®æº 卿§è¡æ¹æ³ä¹å |
| | | DynamicDataSourceContextHolder.clearDataSourceType(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åéè¦åæ¢çæ°æ®æº |
| | | */ |
| | | public DataSource getDataSource(ProceedingJoinPoint point) |
| | | { |
| | | MethodSignature signature = (MethodSignature) point.getSignature(); |
| | | DataSource dataSource = AnnotationUtils.findAnnotation(signature.getMethod(), DataSource.class); |
| | | if (Objects.nonNull(dataSource)) |
| | | { |
| | | return dataSource; |
| | | } |
| | | |
| | | return AnnotationUtils.findAnnotation(signature.getDeclaringType(), DataSource.class); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.aspectj; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.Map; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.aspectj.lang.Signature; |
| | | import org.aspectj.lang.annotation.AfterReturning; |
| | | import org.aspectj.lang.annotation.AfterThrowing; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.annotation.Pointcut; |
| | | import org.aspectj.lang.reflect.MethodSignature; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Component; |
| | | 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.manager.AsyncManager; |
| | | import com.ruoyi.framework.manager.factory.AsyncFactory; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.domain.SysOperLog; |
| | | |
| | | /** |
| | | * æä½æ¥å¿è®°å½å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Aspect |
| | | @Component |
| | | public class LogAspect |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(LogAspect.class); |
| | | |
| | | // é
ç½®ç»å
¥ç¹ |
| | | @Pointcut("@annotation(com.ruoyi.common.annotation.Log)") |
| | | public void logPointCut() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * å¤çå®è¯·æ±åæ§è¡ |
| | | * |
| | | * @param joinPoint åç¹ |
| | | */ |
| | | @AfterReturning(pointcut = "logPointCut()", returning = "jsonResult") |
| | | public void doAfterReturning(JoinPoint joinPoint, Object jsonResult) |
| | | { |
| | | handleLog(joinPoint, null, jsonResult); |
| | | } |
| | | |
| | | /** |
| | | * æ¦æªå¼å¸¸æä½ |
| | | * |
| | | * @param joinPoint åç¹ |
| | | * @param e å¼å¸¸ |
| | | */ |
| | | @AfterThrowing(value = "logPointCut()", throwing = "e") |
| | | public void doAfterThrowing(JoinPoint joinPoint, Exception e) |
| | | { |
| | | handleLog(joinPoint, e, null); |
| | | } |
| | | |
| | | protected void handleLog(final JoinPoint joinPoint, final Exception e, Object jsonResult) |
| | | { |
| | | try |
| | | { |
| | | // è·å¾æ³¨è§£ |
| | | Log controllerLog = getAnnotationLog(joinPoint); |
| | | if (controllerLog == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | // è·åå½åçç¨æ· |
| | | LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest()); |
| | | |
| | | // *========æ°æ®åºæ¥å¿=========*// |
| | | SysOperLog operLog = new SysOperLog(); |
| | | operLog.setStatus(BusinessStatus.SUCCESS.ordinal()); |
| | | // 请æ±çå°å |
| | | String ip = IpUtils.getIpAddr(ServletUtils.getRequest()); |
| | | operLog.setOperIp(ip); |
| | | // è¿ååæ° |
| | | operLog.setJsonResult(JSON.toJSONString(jsonResult)); |
| | | |
| | | operLog.setOperUrl(ServletUtils.getRequest().getRequestURI()); |
| | | if (loginUser != null) |
| | | { |
| | | operLog.setOperName(loginUser.getUsername()); |
| | | } |
| | | |
| | | if (e != null) |
| | | { |
| | | operLog.setStatus(BusinessStatus.FAIL.ordinal()); |
| | | operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000)); |
| | | } |
| | | // è®¾ç½®æ¹æ³åç§° |
| | | String className = joinPoint.getTarget().getClass().getName(); |
| | | String methodName = joinPoint.getSignature().getName(); |
| | | operLog.setMethod(className + "." + methodName + "()"); |
| | | // è®¾ç½®è¯·æ±æ¹å¼ |
| | | operLog.setRequestMethod(ServletUtils.getRequest().getMethod()); |
| | | // å¤ç设置注解ä¸çåæ° |
| | | getControllerMethodDescription(joinPoint, controllerLog, operLog); |
| | | // ä¿åæ°æ®åº |
| | | AsyncManager.me().execute(AsyncFactory.recordOper(operLog)); |
| | | } |
| | | catch (Exception exp) |
| | | { |
| | | // è®°å½æ¬å°å¼å¸¸æ¥å¿ |
| | | log.error("==åç½®éç¥å¼å¸¸=="); |
| | | log.error("å¼å¸¸ä¿¡æ¯:{}", exp.getMessage()); |
| | | exp.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·å注解ä¸å¯¹æ¹æ³çæè¿°ä¿¡æ¯ ç¨äºController屿³¨è§£ |
| | | * |
| | | * @param log æ¥å¿ |
| | | * @param operLog æä½æ¥å¿ |
| | | * @throws Exception |
| | | */ |
| | | public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog) throws Exception |
| | | { |
| | | // 设置actionå¨ä½ |
| | | operLog.setBusinessType(log.businessType().ordinal()); |
| | | // 设置æ é¢ |
| | | operLog.setTitle(log.title()); |
| | | // 设置æä½äººç±»å« |
| | | operLog.setOperatorType(log.operatorType().ordinal()); |
| | | // æ¯å¦éè¦ä¿årequestï¼åæ°åå¼ |
| | | if (log.isSaveRequestData()) |
| | | { |
| | | // è·ååæ°çä¿¡æ¯ï¼ä¼ å
¥å°æ°æ®åºä¸ã |
| | | setRequestValue(joinPoint, operLog); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·å请æ±çåæ°ï¼æ¾å°logä¸ |
| | | * |
| | | * @param operLog æä½æ¥å¿ |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | private void setRequestValue(JoinPoint joinPoint, SysOperLog operLog) throws Exception |
| | | { |
| | | String requestMethod = operLog.getRequestMethod(); |
| | | if (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)) |
| | | { |
| | | String params = argsArrayToString(joinPoint.getArgs()); |
| | | operLog.setOperParam(StringUtils.substring(params, 0, 2000)); |
| | | } |
| | | else |
| | | { |
| | | Map<?, ?> paramsMap = (Map<?, ?>) ServletUtils.getRequest().getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE); |
| | | operLog.setOperParam(StringUtils.substring(paramsMap.toString(), 0, 2000)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦å卿³¨è§£ï¼å¦æåå¨å°±è·å |
| | | */ |
| | | private Log getAnnotationLog(JoinPoint joinPoint) throws Exception |
| | | { |
| | | Signature signature = joinPoint.getSignature(); |
| | | MethodSignature methodSignature = (MethodSignature) signature; |
| | | Method method = methodSignature.getMethod(); |
| | | |
| | | if (method != null) |
| | | { |
| | | return method.getAnnotation(Log.class); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * åæ°æ¼è£
|
| | | */ |
| | | private String argsArrayToString(Object[] paramsArray) |
| | | { |
| | | String params = ""; |
| | | if (paramsArray != null && paramsArray.length > 0) |
| | | { |
| | | for (int i = 0; i < paramsArray.length; i++) |
| | | { |
| | | if (!isFilterObject(paramsArray[i])) |
| | | { |
| | | Object jsonObj = JSON.toJSON(paramsArray[i]); |
| | | params += jsonObj.toString() + " "; |
| | | } |
| | | } |
| | | } |
| | | return params.trim(); |
| | | } |
| | | |
| | | /** |
| | | * 夿æ¯å¦éè¦è¿æ»¤ç对象ã |
| | | * |
| | | * @param o 对象信æ¯ã |
| | | * @return 妿æ¯éè¦è¿æ»¤ç对象ï¼åè¿åtrueï¼å¦åè¿åfalseã |
| | | */ |
| | | public boolean isFilterObject(final Object o) |
| | | { |
| | | return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import java.util.TimeZone; |
| | | import org.mybatis.spring.annotation.MapperScan; |
| | | import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.context.annotation.EnableAspectJAutoProxy; |
| | | |
| | | /** |
| | | * ç¨åºæ³¨è§£é
ç½® |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Configuration |
| | | // 表示éè¿aopæ¡æ¶æ´é²è¯¥ä»£ç对象,AopContextè½å¤è®¿é® |
| | | @EnableAspectJAutoProxy(exposeProxy = true) |
| | | // æå®è¦æ«æçMapperç±»çå
çè·¯å¾ |
| | | @MapperScan("com.ruoyi.**.mapper") |
| | | public class ApplicationConfig |
| | | { |
| | | /** |
| | | * æ¶åºé
ç½® |
| | | */ |
| | | @Bean |
| | | public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() |
| | | { |
| | | return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault()); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import javax.servlet.Filter; |
| | | import javax.servlet.FilterChain; |
| | | import javax.servlet.ServletException; |
| | | import javax.servlet.ServletRequest; |
| | | import javax.servlet.ServletResponse; |
| | | import javax.sql.DataSource; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.boot.web.servlet.FilterRegistrationBean; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.context.annotation.Primary; |
| | | import com.alibaba.druid.pool.DruidDataSource; |
| | | 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.config.properties.DruidProperties; |
| | | import com.ruoyi.framework.datasource.DynamicDataSource; |
| | | |
| | | /** |
| | | * druid é
ç½®å¤æ°æ®æº |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Configuration |
| | | public class DruidConfig |
| | | { |
| | | @Bean |
| | | @ConfigurationProperties("spring.datasource.druid.master") |
| | | public DataSource masterDataSource(DruidProperties druidProperties) |
| | | { |
| | | DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); |
| | | return druidProperties.dataSource(dataSource); |
| | | } |
| | | |
| | | @Bean |
| | | @ConfigurationProperties("spring.datasource.druid.slave") |
| | | @ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true") |
| | | public DataSource slaveDataSource(DruidProperties druidProperties) |
| | | { |
| | | DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); |
| | | return druidProperties.dataSource(dataSource); |
| | | } |
| | | |
| | | @Bean(name = "dynamicDataSource") |
| | | @Primary |
| | | public DynamicDataSource dataSource(DataSource masterDataSource) |
| | | { |
| | | Map<Object, Object> targetDataSources = new HashMap<>(); |
| | | targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource); |
| | | setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource"); |
| | | return new DynamicDataSource(masterDataSource, targetDataSources); |
| | | } |
| | | |
| | | /** |
| | | * è®¾ç½®æ°æ®æº |
| | | * |
| | | * @param targetDataSources å¤éæ°æ®æºéå |
| | | * @param sourceName æ°æ®æºåç§° |
| | | * @param beanName beanåç§° |
| | | */ |
| | | public void setDataSource(Map<Object, Object> targetDataSources, String sourceName, String beanName) |
| | | { |
| | | try |
| | | { |
| | | DataSource dataSource = SpringUtils.getBean(beanName); |
| | | targetDataSources.put(sourceName, dataSource); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å»é¤çæ§é¡µé¢åºé¨ç广å |
| | | */ |
| | | @SuppressWarnings({ "rawtypes", "unchecked" }) |
| | | @Bean |
| | | @ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true") |
| | | public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) |
| | | { |
| | | // è·åwebçæ§é¡µé¢çåæ° |
| | | DruidStatProperties.StatViewServlet config = properties.getStatViewServlet(); |
| | | // æåcommon.jsçé
ç½®è·¯å¾ |
| | | String pattern = config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*"; |
| | | String commonJsPattern = pattern.replaceAll("\\*", "js/common.js"); |
| | | final String filePath = "support/http/resources/js/common.js"; |
| | | // å建filterè¿è¡è¿æ»¤ |
| | | Filter filter = new Filter() |
| | | { |
| | | @Override |
| | | public void init(javax.servlet.FilterConfig filterConfig) throws ServletException |
| | | { |
| | | } |
| | | @Override |
| | | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) |
| | | throws IOException, ServletException |
| | | { |
| | | chain.doFilter(request, response); |
| | | // éç½®ç¼å²åºï¼ååºå¤´ä¸ä¼è¢«éç½® |
| | | response.resetBuffer(); |
| | | // è·åcommon.js |
| | | String text = Utils.readFromResource(filePath); |
| | | // æ£åæ¿æ¢banner, é¤å»åºé¨ç广åä¿¡æ¯ |
| | | text = text.replaceAll("<a.*?banner\"></a><br/>", ""); |
| | | text = text.replaceAll("powered.*?shrek.wang</a>", ""); |
| | | response.getWriter().write(text); |
| | | } |
| | | @Override |
| | | public void destroy() |
| | | { |
| | | } |
| | | }; |
| | | FilterRegistrationBean registrationBean = new FilterRegistrationBean(); |
| | | registrationBean.setFilter(filter); |
| | | registrationBean.addUrlPatterns(commonJsPattern); |
| | | return registrationBean; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Configuration; |
| | | 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; |
| | | |
| | | /** |
| | | * éç¨é
ç½® |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Configuration |
| | | public class ResourcesConfig implements WebMvcConfigurer |
| | | { |
| | | @Autowired |
| | | private RepeatSubmitInterceptor repeatSubmitInterceptor; |
| | | |
| | | @Override |
| | | public void addResourceHandlers(ResourceHandlerRegistry registry) |
| | | { |
| | | /** æ¬å°æä»¶ä¸ä¼ è·¯å¾ */ |
| | | registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + RuoYiConfig.getProfile() + "/"); |
| | | |
| | | /** swaggeré
ç½® */ |
| | | registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); |
| | | registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); |
| | | } |
| | | |
| | | /** |
| | | * èªå®ä¹æ¦æªè§å |
| | | */ |
| | | @Override |
| | | public void addInterceptors(InterceptorRegistry registry) |
| | | { |
| | | registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**"); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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);
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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;
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.manager.factory; |
| | | |
| | | import java.util.TimerTask; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.utils.LogUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.ip.AddressUtils; |
| | | import com.ruoyi.common.utils.ip.IpUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | 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; |
| | | |
| | | /** |
| | | * 弿¥å·¥åï¼äº§çä»»å¡ç¨ï¼ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class AsyncFactory |
| | | { |
| | | private static final Logger sys_user_logger = LoggerFactory.getLogger("sys-user"); |
| | | |
| | | /** |
| | | * è®°å½ç»éä¿¡æ¯ |
| | | * |
| | | * @param username ç¨æ·å |
| | | * @param status ç¶æ |
| | | * @param message æ¶æ¯ |
| | | * @param args å表 |
| | | * @return ä»»å¡task |
| | | */ |
| | | public static TimerTask recordLogininfor(final String username, final String status, final String message, |
| | | final Object... args) |
| | | { |
| | | final UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent")); |
| | | final String ip = IpUtils.getIpAddr(ServletUtils.getRequest()); |
| | | return new TimerTask() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | String address = AddressUtils.getRealAddressByIP(ip); |
| | | StringBuilder s = new StringBuilder(); |
| | | s.append(LogUtils.getBlock(ip)); |
| | | s.append(address); |
| | | s.append(LogUtils.getBlock(username)); |
| | | s.append(LogUtils.getBlock(status)); |
| | | s.append(LogUtils.getBlock(message)); |
| | | // æå°ä¿¡æ¯å°æ¥å¿ |
| | | sys_user_logger.info(s.toString(), args); |
| | | // è·å客æ·ç«¯æä½ç³»ç» |
| | | String os = userAgent.getOperatingSystem().getName(); |
| | | // è·å客æ·ç«¯æµè§å¨ |
| | | String browser = userAgent.getBrowser().getName(); |
| | | // å°è£
对象 |
| | | SysLogininfor logininfor = new SysLogininfor(); |
| | | logininfor.setUserName(username); |
| | | logininfor.setIpaddr(ip); |
| | | logininfor.setLoginLocation(address); |
| | | logininfor.setBrowser(browser); |
| | | logininfor.setOs(os); |
| | | logininfor.setMsg(message); |
| | | // æ¥å¿ç¶æ |
| | | if (Constants.LOGIN_SUCCESS.equals(status) || Constants.LOGOUT.equals(status)) |
| | | { |
| | | logininfor.setStatus(Constants.SUCCESS); |
| | | } |
| | | else if (Constants.LOGIN_FAIL.equals(status)) |
| | | { |
| | | logininfor.setStatus(Constants.FAIL); |
| | | } |
| | | // æå
¥æ°æ® |
| | | SpringUtils.getBean(ISysLogininforService.class).insertLogininfor(logininfor); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * æä½æ¥å¿è®°å½ |
| | | * |
| | | * @param operLog æä½æ¥å¿ä¿¡æ¯ |
| | | * @return ä»»å¡task |
| | | */ |
| | | public static TimerTask recordOper(final SysOperLog operLog) |
| | | { |
| | | return new TimerTask() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | // è¿ç¨æ¥è¯¢æä½å°ç¹ |
| | | operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp())); |
| | | SpringUtils.getBean(ISysOperLogService.class).insertOperlog(operLog); |
| | | } |
| | | }; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.security.filter; |
| | | |
| | | import java.io.IOException; |
| | | import javax.servlet.FilterChain; |
| | | import javax.servlet.ServletException; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | 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.web.service.TokenService; |
| | | |
| | | /** |
| | | * tokenè¿æ»¤å¨ éªè¯tokenæææ§ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class JwtAuthenticationTokenFilter extends OncePerRequestFilter |
| | | { |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @Override |
| | | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) |
| | | throws ServletException, IOException |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(request); |
| | | if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication())) |
| | | { |
| | | tokenService.verifyToken(loginUser); |
| | | UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities()); |
| | | authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); |
| | | SecurityContextHolder.getContext().setAuthentication(authenticationToken); |
| | | } |
| | | chain.doFilter(request, response); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.security.handle; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.Serializable; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.springframework.security.core.AuthenticationException; |
| | | import org.springframework.security.web.AuthenticationEntryPoint; |
| | | 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; |
| | | |
| | | /** |
| | | * 认è¯å¤±è´¥å¤çç±» è¿åæªææ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint, Serializable |
| | | { |
| | | private static final long serialVersionUID = -8970718410437077606L; |
| | | |
| | | @Override |
| | | public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) |
| | | throws IOException |
| | | { |
| | | int code = HttpStatus.UNAUTHORIZED; |
| | | String msg = StringUtils.format("请æ±è®¿é®ï¼{}ï¼è®¤è¯å¤±è´¥ï¼æ æ³è®¿é®ç³»ç»èµæº", request.getRequestURI()); |
| | | ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(code, msg))); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.security.handle; |
| | | |
| | | import java.io.IOException; |
| | | import javax.servlet.ServletException; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; |
| | | 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.web.service.TokenService; |
| | | |
| | | /** |
| | | * èªå®ä¹éåºå¤çç±» è¿åæå |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Configuration |
| | | public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler |
| | | { |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | /** |
| | | * éåºå¤ç |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) |
| | | throws IOException, ServletException |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(request); |
| | | if (StringUtils.isNotNull(loginUser)) |
| | | { |
| | | String userName = loginUser.getUsername(); |
| | | // å é¤ç¨æ·ç¼åè®°å½ |
| | | tokenService.delLoginUser(loginUser.getToken()); |
| | | // è®°å½ç¨æ·éåºæ¥å¿ |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(userName, Constants.LOGOUT, "éåºæå")); |
| | | } |
| | | ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(HttpStatus.SUCCESS, "éåºæå"))); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.web.exception; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.security.access.AccessDeniedException; |
| | | import org.springframework.security.authentication.AccountExpiredException; |
| | | import org.springframework.security.core.userdetails.UsernameNotFoundException; |
| | | import org.springframework.validation.BindException; |
| | | import org.springframework.web.bind.MethodArgumentNotValidException; |
| | | import org.springframework.web.bind.annotation.ExceptionHandler; |
| | | 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; |
| | | |
| | | /** |
| | | * å
¨å±å¼å¸¸å¤çå¨ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestControllerAdvice |
| | | public class GlobalExceptionHandler |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class); |
| | | |
| | | /** |
| | | * åºç¡å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(BaseException.class) |
| | | public AjaxResult baseException(BaseException e) |
| | | { |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * ä¸å¡å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(CustomException.class) |
| | | public AjaxResult businessException(CustomException e) |
| | | { |
| | | if (StringUtils.isNull(e.getCode())) |
| | | { |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | return AjaxResult.error(e.getCode(), e.getMessage()); |
| | | } |
| | | |
| | | @ExceptionHandler(NoHandlerFoundException.class) |
| | | public AjaxResult handlerNoFoundException(Exception e) |
| | | { |
| | | log.error(e.getMessage(), e); |
| | | return AjaxResult.error(HttpStatus.NOT_FOUND, "è·¯å¾ä¸åå¨ï¼è¯·æ£æ¥è·¯å¾æ¯å¦æ£ç¡®"); |
| | | } |
| | | |
| | | @ExceptionHandler(AccessDeniedException.class) |
| | | public AjaxResult handleAuthorizationException(AccessDeniedException e) |
| | | { |
| | | log.error(e.getMessage()); |
| | | return AjaxResult.error(HttpStatus.FORBIDDEN, "没ææéï¼è¯·è系管çåææ"); |
| | | } |
| | | |
| | | @ExceptionHandler(AccountExpiredException.class) |
| | | public AjaxResult handleAccountExpiredException(AccountExpiredException e) |
| | | { |
| | | log.error(e.getMessage(), e); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | @ExceptionHandler(UsernameNotFoundException.class) |
| | | public AjaxResult handleUsernameNotFoundException(UsernameNotFoundException e) |
| | | { |
| | | log.error(e.getMessage(), e); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | @ExceptionHandler(Exception.class) |
| | | public AjaxResult handleException(Exception e) |
| | | { |
| | | log.error(e.getMessage(), e); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * èªå®ä¹éªè¯å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(BindException.class) |
| | | public AjaxResult validatedBindException(BindException e) |
| | | { |
| | | log.error(e.getMessage(), e); |
| | | String message = e.getAllErrors().get(0).getDefaultMessage(); |
| | | return AjaxResult.error(message); |
| | | } |
| | | |
| | | /** |
| | | * èªå®ä¹éªè¯å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(MethodArgumentNotValidException.class) |
| | | public Object validExceptionHandler(MethodArgumentNotValidException e) |
| | | { |
| | | log.error(e.getMessage(), e); |
| | | String message = e.getBindingResult().getFieldError().getDefaultMessage(); |
| | | return AjaxResult.error(message); |
| | | } |
| | | |
| | | /** |
| | | * æ¼ç¤ºæ¨¡å¼å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(DemoModeException.class) |
| | | public AjaxResult demoModeException(DemoModeException e) |
| | | { |
| | | return AjaxResult.error("æ¼ç¤ºæ¨¡å¼ï¼ä¸å
许æä½"); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | |
| | | /** |
| | | * RuoYié¦å èªå®ä¹æéå®ç°ï¼ssåèªSpringSecurityé¦åæ¯ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Service("ss") |
| | | public class PermissionService |
| | | { |
| | | /** æææéæ è¯ */ |
| | | private static final String ALL_PERMISSION = "*:*:*"; |
| | | |
| | | /** 管çåè§è²æéæ è¯ */ |
| | | private static final String SUPER_ADMIN = "admin"; |
| | | |
| | | private static final String ROLE_DELIMETER = ","; |
| | | |
| | | private static final String PERMISSION_DELIMETER = ","; |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | /** |
| | | * éªè¯ç¨æ·æ¯å¦å
·å¤ææé |
| | | * |
| | | * @param permission æéå符串 |
| | | * @return ç¨æ·æ¯å¦å
·å¤ææé |
| | | */ |
| | | public boolean hasPermi(String permission) |
| | | { |
| | | if (StringUtils.isEmpty(permission)) |
| | | { |
| | | return false; |
| | | } |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) |
| | | { |
| | | return false; |
| | | } |
| | | return hasPermissions(loginUser.getPermissions(), permission); |
| | | } |
| | | |
| | | /** |
| | | * éªè¯ç¨æ·æ¯å¦ä¸å
·å¤ææéï¼ä¸ hasPermié»è¾ç¸å |
| | | * |
| | | * @param permission æéå符串 |
| | | * @return ç¨æ·æ¯å¦ä¸å
·å¤ææé |
| | | */ |
| | | public boolean lacksPermi(String permission) |
| | | { |
| | | return hasPermi(permission) != true; |
| | | } |
| | | |
| | | /** |
| | | * éªè¯ç¨æ·æ¯å¦å
·æä»¥ä¸ä»»æä¸ä¸ªæé |
| | | * |
| | | * @param permissions 以 PERMISSION_NAMES_DELIMETER 为åé符çæéå表 |
| | | * @return ç¨æ·æ¯å¦å
·æä»¥ä¸ä»»æä¸ä¸ªæé |
| | | */ |
| | | public boolean hasAnyPermi(String permissions) |
| | | { |
| | | if (StringUtils.isEmpty(permissions)) |
| | | { |
| | | return false; |
| | | } |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) |
| | | { |
| | | return false; |
| | | } |
| | | Set<String> authorities = loginUser.getPermissions(); |
| | | for (String permission : permissions.split(PERMISSION_DELIMETER)) |
| | | { |
| | | if (permission != null && hasPermissions(authorities, permission)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * å¤æç¨æ·æ¯å¦æ¥ææä¸ªè§è² |
| | | * |
| | | * @param role è§è²å符串 |
| | | * @return ç¨æ·æ¯å¦å
·å¤æè§è² |
| | | */ |
| | | public boolean hasRole(String role) |
| | | { |
| | | if (StringUtils.isEmpty(role)) |
| | | { |
| | | return false; |
| | | } |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles())) |
| | | { |
| | | return false; |
| | | } |
| | | for (SysRole sysRole : loginUser.getUser().getRoles()) |
| | | { |
| | | String roleKey = sysRole.getRoleKey(); |
| | | if (SUPER_ADMIN.contains(roleKey) || roleKey.contains(StringUtils.trim(role))) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * éªè¯ç¨æ·æ¯å¦ä¸å
·å¤æè§è²ï¼ä¸ isRoleé»è¾ç¸åã |
| | | * |
| | | * @param role è§è²åç§° |
| | | * @return ç¨æ·æ¯å¦ä¸å
·å¤æè§è² |
| | | */ |
| | | public boolean lacksRole(String role) |
| | | { |
| | | return hasRole(role) != true; |
| | | } |
| | | |
| | | /** |
| | | * éªè¯ç¨æ·æ¯å¦å
·æä»¥ä¸ä»»æä¸ä¸ªè§è² |
| | | * |
| | | * @param roles 以 ROLE_NAMES_DELIMETER 为åé符çè§è²å表 |
| | | * @return ç¨æ·æ¯å¦å
·æä»¥ä¸ä»»æä¸ä¸ªè§è² |
| | | */ |
| | | public boolean hasAnyRoles(String roles) |
| | | { |
| | | if (StringUtils.isEmpty(roles)) |
| | | { |
| | | return false; |
| | | } |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles())) |
| | | { |
| | | return false; |
| | | } |
| | | for (String role : roles.split(ROLE_DELIMETER)) |
| | | { |
| | | if (hasRole(role)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 夿æ¯å¦å
嫿é |
| | | * |
| | | * @param permissions æéå表 |
| | | * @param permission æéå符串 |
| | | * @return ç¨æ·æ¯å¦å
·å¤ææé |
| | | */ |
| | | private boolean hasPermissions(Set<String> permissions, String permission) |
| | | { |
| | | return permissions.contains(ALL_PERMISSION) || permissions.contains(StringUtils.trim(permission)); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.web.service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | | import org.springframework.security.authentication.BadCredentialsException; |
| | | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| | | 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.exception.user.UserPasswordNotMatchException; |
| | | import com.ruoyi.common.utils.MessageUtils; |
| | | import com.ruoyi.framework.manager.AsyncManager; |
| | | import com.ruoyi.framework.manager.factory.AsyncFactory; |
| | | |
| | | /** |
| | | * ç»å½æ ¡éªæ¹æ³ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class SysLoginService |
| | | { |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @Resource |
| | | private AuthenticationManager authenticationManager; |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | /** |
| | | * ç»å½éªè¯ |
| | | * |
| | | * @param username ç¨æ·å |
| | | * @param password å¯ç |
| | | * @param code éªè¯ç |
| | | * @param uuid å¯ä¸æ è¯ |
| | | * @return ç»æ |
| | | */ |
| | | public String login(String username, String password, String code, String uuid) |
| | | { |
| | | String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; |
| | | String captcha = redisCache.getCacheObject(verifyKey); |
| | | redisCache.deleteObject(verifyKey); |
| | | if (captcha == null) |
| | | { |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"))); |
| | | throw new CaptchaExpireException(); |
| | | } |
| | | if (!code.equalsIgnoreCase(captcha)) |
| | | { |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"))); |
| | | throw new CaptchaException(); |
| | | } |
| | | // ç¨æ·éªè¯ |
| | | Authentication authentication = null; |
| | | try |
| | | { |
| | | // è¯¥æ¹æ³ä¼å»è°ç¨UserDetailsServiceImpl.loadUserByUsername |
| | | authentication = authenticationManager |
| | | .authenticate(new UsernamePasswordAuthenticationToken(username, password)); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (e instanceof BadCredentialsException) |
| | | { |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"))); |
| | | throw new UserPasswordNotMatchException(); |
| | | } |
| | | else |
| | | { |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage())); |
| | | throw new CustomException(e.getMessage()); |
| | | } |
| | | } |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); |
| | | LoginUser loginUser = (LoginUser) authentication.getPrincipal(); |
| | | // çætoken |
| | | return tokenService.createToken(loginUser); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | |
| | | /** |
| | | * ç¨æ·æéå¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class SysPermissionService |
| | | { |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | | /** |
| | | * è·åè§è²æ°æ®æé |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return è§è²æéä¿¡æ¯ |
| | | */ |
| | | public Set<String> getRolePermission(SysUser user) |
| | | { |
| | | Set<String> roles = new HashSet<String>(); |
| | | // 管çåæ¥ææææé |
| | | if (user.isAdmin()) |
| | | { |
| | | roles.add("admin"); |
| | | } |
| | | else |
| | | { |
| | | roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId())); |
| | | } |
| | | return roles; |
| | | } |
| | | |
| | | /** |
| | | * è·åèåæ°æ®æé |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return èåæéä¿¡æ¯ |
| | | */ |
| | | public Set<String> getMenuPermission(SysUser user) |
| | | { |
| | | Set<String> perms = new HashSet<String>(); |
| | | // 管çåæ¥ææææé |
| | | if (user.isAdmin()) |
| | | { |
| | | perms.add("*:*:*"); |
| | | } |
| | | else |
| | | { |
| | | perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId())); |
| | | } |
| | | return perms; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.web.service; |
| | | |
| | | 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.beans.factory.annotation.Value; |
| | | 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.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.common.utils.uuid.IdUtils; |
| | | import eu.bitwalker.useragentutils.UserAgent; |
| | | import io.jsonwebtoken.Claims; |
| | | import io.jsonwebtoken.Jwts; |
| | | import io.jsonwebtoken.SignatureAlgorithm; |
| | | |
| | | /** |
| | | * tokenéªè¯å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class TokenService |
| | | { |
| | | // 令çèªå®ä¹æ è¯ |
| | | @Value("${token.header}") |
| | | private String header; |
| | | |
| | | // 令çç§é¥ |
| | | @Value("${token.secret}") |
| | | private String secret; |
| | | |
| | | // ä»¤çæææï¼é»è®¤30åéï¼ |
| | | @Value("${token.expireTime}") |
| | | private int expireTime; |
| | | |
| | | protected static final long MILLIS_SECOND = 1000; |
| | | |
| | | protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND; |
| | | |
| | | private static final Long MILLIS_MINUTE_TEN = 20 * 60 * 1000L; |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | /** |
| | | * è·åç¨æ·èº«ä»½ä¿¡æ¯ |
| | | * |
| | | * @return ç¨æ·ä¿¡æ¯ |
| | | */ |
| | | public LoginUser getLoginUser(HttpServletRequest request) |
| | | { |
| | | // è·åè¯·æ±æºå¸¦ç令ç |
| | | String token = getToken(request); |
| | | if (StringUtils.isNotEmpty(token)) |
| | | { |
| | | Claims claims = parseToken(token); |
| | | // è§£æå¯¹åºçæé以åç¨æ·ä¿¡æ¯ |
| | | String uuid = (String) claims.get(Constants.LOGIN_USER_KEY); |
| | | String userKey = getTokenKey(uuid); |
| | | LoginUser user = redisCache.getCacheObject(userKey); |
| | | return user; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * è®¾ç½®ç¨æ·èº«ä»½ä¿¡æ¯ |
| | | */ |
| | | public void setLoginUser(LoginUser loginUser) |
| | | { |
| | | if (StringUtils.isNotNull(loginUser) && StringUtils.isNotEmpty(loginUser.getToken())) |
| | | { |
| | | refreshToken(loginUser); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å é¤ç¨æ·èº«ä»½ä¿¡æ¯ |
| | | */ |
| | | public void delLoginUser(String token) |
| | | { |
| | | if (StringUtils.isNotEmpty(token)) |
| | | { |
| | | String userKey = getTokenKey(token); |
| | | redisCache.deleteObject(userKey); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å建令ç |
| | | * |
| | | * @param loginUser ç¨æ·ä¿¡æ¯ |
| | | * @return 令ç |
| | | */ |
| | | public String createToken(LoginUser loginUser) |
| | | { |
| | | String token = IdUtils.fastUUID(); |
| | | loginUser.setToken(token); |
| | | setUserAgent(loginUser); |
| | | refreshToken(loginUser); |
| | | |
| | | Map<String, Object> claims = new HashMap<>(); |
| | | claims.put(Constants.LOGIN_USER_KEY, token); |
| | | return createToken(claims); |
| | | } |
| | | |
| | | /** |
| | | * éªè¯ä»¤çæææï¼ç¸å·®ä¸è¶³20åéï¼èªå¨å·æ°ç¼å |
| | | * |
| | | * @param token 令ç |
| | | * @return 令ç |
| | | */ |
| | | public void verifyToken(LoginUser loginUser) |
| | | { |
| | | long expireTime = loginUser.getExpireTime(); |
| | | long currentTime = System.currentTimeMillis(); |
| | | if (expireTime - currentTime <= MILLIS_MINUTE_TEN) |
| | | { |
| | | refreshToken(loginUser); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å·æ°ä»¤çæææ |
| | | * |
| | | * @param loginUser ç»å½ä¿¡æ¯ |
| | | */ |
| | | public void refreshToken(LoginUser loginUser) |
| | | { |
| | | loginUser.setLoginTime(System.currentTimeMillis()); |
| | | loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE); |
| | | // æ ¹æ®uuidå°loginUserç¼å |
| | | String userKey = getTokenKey(loginUser.getToken()); |
| | | redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES); |
| | | } |
| | | |
| | | /** |
| | | * è®¾ç½®ç¨æ·ä»£çä¿¡æ¯ |
| | | * |
| | | * @param loginUser ç»å½ä¿¡æ¯ |
| | | */ |
| | | public void setUserAgent(LoginUser loginUser) |
| | | { |
| | | UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent")); |
| | | String ip = IpUtils.getIpAddr(ServletUtils.getRequest()); |
| | | loginUser.setIpaddr(ip); |
| | | loginUser.setLoginLocation(AddressUtils.getRealAddressByIP(ip)); |
| | | loginUser.setBrowser(userAgent.getBrowser().getName()); |
| | | loginUser.setOs(userAgent.getOperatingSystem().getName()); |
| | | } |
| | | |
| | | /** |
| | | * 仿°æ®å£°æçæä»¤ç |
| | | * |
| | | * @param claims æ°æ®å£°æ |
| | | * @return 令ç |
| | | */ |
| | | private String createToken(Map<String, Object> claims) |
| | | { |
| | | String token = Jwts.builder() |
| | | .setClaims(claims) |
| | | .signWith(SignatureAlgorithm.HS512, secret).compact(); |
| | | return token; |
| | | } |
| | | |
| | | /** |
| | | * ä»ä»¤çä¸è·åæ°æ®å£°æ |
| | | * |
| | | * @param token 令ç |
| | | * @return æ°æ®å£°æ |
| | | */ |
| | | private Claims parseToken(String token) |
| | | { |
| | | return Jwts.parser() |
| | | .setSigningKey(secret) |
| | | .parseClaimsJws(token) |
| | | .getBody(); |
| | | } |
| | | |
| | | /** |
| | | * ä»ä»¤çä¸è·åç¨æ·å |
| | | * |
| | | * @param token 令ç |
| | | * @return ç¨æ·å |
| | | */ |
| | | public String getUsernameFromToken(String token) |
| | | { |
| | | Claims claims = parseToken(token); |
| | | return claims.getSubject(); |
| | | } |
| | | |
| | | /** |
| | | * è·å请æ±token |
| | | * |
| | | * @param request |
| | | * @return token |
| | | */ |
| | | private String getToken(HttpServletRequest request) |
| | | { |
| | | String token = request.getHeader(header); |
| | | if (StringUtils.isNotEmpty(token) && token.startsWith(Constants.TOKEN_PREFIX)) |
| | | { |
| | | token = token.replace(Constants.TOKEN_PREFIX, ""); |
| | | } |
| | | return token; |
| | | } |
| | | |
| | | private String getTokenKey(String uuid) |
| | | { |
| | | return Constants.LOGIN_TOKEN_KEY + uuid; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.web.service; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.core.userdetails.UserDetails; |
| | | 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.system.service.ISysUserService; |
| | | |
| | | /** |
| | | * ç¨æ·éªè¯å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class UserDetailsServiceImpl implements UserDetailsService |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(UserDetailsServiceImpl.class); |
| | | |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private SysPermissionService permissionService; |
| | | |
| | | @Override |
| | | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException |
| | | { |
| | | SysUser user = userService.selectUserByUserName(username); |
| | | if (StringUtils.isNull(user)) |
| | | { |
| | | log.info("ç»å½ç¨æ·ï¼{} ä¸åå¨.", username); |
| | | throw new UsernameNotFoundException("ç»å½ç¨æ·ï¼" + username + " ä¸åå¨"); |
| | | } |
| | | else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) |
| | | { |
| | | log.info("ç»å½ç¨æ·ï¼{} 已被å é¤.", username); |
| | | throw new BaseException("对ä¸èµ·ï¼æ¨çè´¦å·ï¼" + username + " 已被å é¤"); |
| | | } |
| | | else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) |
| | | { |
| | | log.info("ç»å½ç¨æ·ï¼{} 已被åç¨.", username); |
| | | throw new BaseException("对ä¸èµ·ï¼æ¨çè´¦å·ï¼" + username + " å·²åç¨"); |
| | | } |
| | | |
| | | return createLoginUser(user); |
| | | } |
| | | |
| | | public UserDetails createLoginUser(SysUser user) |
| | | { |
| | | return new LoginUser(user, permissionService.getMenuPermission(user)); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | |
| | | /** |
| | | * 读å代ç çæç¸å
³é
ç½® |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | @ConfigurationProperties(prefix = "gen") |
| | | @PropertySource(value = { "classpath:generator.yml" }) |
| | | public class GenConfig |
| | | { |
| | | /** ä½è
*/ |
| | | public static String author; |
| | | |
| | | /** çæå
è·¯å¾ */ |
| | | public static String packageName; |
| | | |
| | | /** èªå¨å»é¤è¡¨åç¼ï¼é»è®¤æ¯false */ |
| | | public static boolean autoRemovePre; |
| | | |
| | | /** 表åç¼(ç±»åä¸ä¼å
å«è¡¨åç¼) */ |
| | | public static String tablePrefix; |
| | | |
| | | public static String getAuthor() |
| | | { |
| | | return author; |
| | | } |
| | | |
| | | @Value("${author}") |
| | | public void setAuthor(String author) |
| | | { |
| | | GenConfig.author = author; |
| | | } |
| | | |
| | | public static String getPackageName() |
| | | { |
| | | return packageName; |
| | | } |
| | | |
| | | @Value("${packageName}") |
| | | public void setPackageName(String packageName) |
| | | { |
| | | GenConfig.packageName = packageName; |
| | | } |
| | | |
| | | public static boolean getAutoRemovePre() |
| | | { |
| | | return autoRemovePre; |
| | | } |
| | | |
| | | @Value("${autoRemovePre}") |
| | | public void setAutoRemovePre(boolean autoRemovePre) |
| | | { |
| | | GenConfig.autoRemovePre = autoRemovePre; |
| | | } |
| | | |
| | | public static String getTablePrefix() |
| | | { |
| | | return tablePrefix; |
| | | } |
| | | |
| | | @Value("${tablePrefix}") |
| | | public void setTablePrefix(String tablePrefix) |
| | | { |
| | | GenConfig.tablePrefix = tablePrefix; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.generator.controller; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | 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.core.text.Convert; |
| | | 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; |
| | | |
| | | /** |
| | | * 代ç çæ æä½å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/tool/gen") |
| | | public class GenController extends BaseController |
| | | { |
| | | @Autowired |
| | | private IGenTableService genTableService; |
| | | |
| | | @Autowired |
| | | private IGenTableColumnService genTableColumnService; |
| | | |
| | | /** |
| | | * æ¥è¯¢ä»£ç çæå表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo genList(GenTable genTable) |
| | | { |
| | | startPage(); |
| | | List<GenTable> list = genTableService.selectGenTableList(genTable); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ä»£ç çæä¸å¡ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:query')") |
| | | @GetMapping(value = "/{talbleId}") |
| | | public AjaxResult getInfo(@PathVariable Long talbleId) |
| | | { |
| | | GenTable table = genTableService.selectGenTableById(talbleId); |
| | | List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId); |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | map.put("info", table); |
| | | map.put("rows", list); |
| | | return AjaxResult.success(map); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢æ°æ®åºå表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:list')") |
| | | @GetMapping("/db/list") |
| | | public TableDataInfo dataList(GenTable genTable) |
| | | { |
| | | startPage(); |
| | | List<GenTable> list = genTableService.selectDbTableList(genTable); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢æ°æ®è¡¨å段å表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:list')") |
| | | @GetMapping(value = "/column/{talbleId}") |
| | | public TableDataInfo columnList(Long tableId) |
| | | { |
| | | TableDataInfo dataInfo = new TableDataInfo(); |
| | | List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId); |
| | | dataInfo.setRows(list); |
| | | dataInfo.setTotal(list.size()); |
| | | return dataInfo; |
| | | } |
| | | |
| | | /** |
| | | * 导å
¥è¡¨ç»æï¼ä¿åï¼ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:list')") |
| | | @Log(title = "代ç çæ", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/importTable") |
| | | public AjaxResult importTableSave(String tables) |
| | | { |
| | | String[] tableNames = Convert.toStrArray(tables); |
| | | // æ¥è¯¢è¡¨ä¿¡æ¯ |
| | | List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames); |
| | | genTableService.importGenTable(tableList); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¿å代ç çæä¸å¡ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:edit')") |
| | | @Log(title = "代ç çæ", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult editSave(@Validated @RequestBody GenTable genTable) |
| | | { |
| | | genTableService.validateEdit(genTable); |
| | | genTableService.updateGenTable(genTable); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * å é¤ä»£ç çæ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:remove')") |
| | | @Log(title = "代ç çæ", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{tableIds}") |
| | | public AjaxResult remove(@PathVariable Long[] tableIds) |
| | | { |
| | | genTableService.deleteGenTableByIds(tableIds); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * é¢è§ä»£ç |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:preview')") |
| | | @GetMapping("/preview/{tableId}") |
| | | public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException |
| | | { |
| | | Map<String, String> dataMap = genTableService.previewCode(tableId); |
| | | return AjaxResult.success(dataMap); |
| | | } |
| | | |
| | | /** |
| | | * çæä»£ç |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:code')") |
| | | @Log(title = "代ç çæ", businessType = BusinessType.GENCODE) |
| | | @GetMapping("/genCode/{tableName}") |
| | | public void genCode(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException |
| | | { |
| | | byte[] data = genTableService.generatorCode(tableName); |
| | | genCode(response, data); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éçæä»£ç |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:code')") |
| | | @Log(title = "代ç çæ", businessType = BusinessType.GENCODE) |
| | | @GetMapping("/batchGenCode") |
| | | public void batchGenCode(HttpServletResponse response, String tables) throws IOException |
| | | { |
| | | String[] tableNames = Convert.toStrArray(tables); |
| | | byte[] data = genTableService.generatorCode(tableNames); |
| | | genCode(response, data); |
| | | } |
| | | |
| | | /** |
| | | * çæzipæä»¶ |
| | | */ |
| | | private void genCode(HttpServletResponse response, byte[] data) throws IOException |
| | | { |
| | | response.reset(); |
| | | response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\""); |
| | | response.addHeader("Content-Length", "" + data.length); |
| | | response.setContentType("application/octet-stream; charset=UTF-8"); |
| | | IOUtils.write(data, response.getOutputStream()); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | |
| | | /** |
| | | * ä¸å¡è¡¨ gen_table |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class GenTable extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** ç¼å· */ |
| | | private Long tableId; |
| | | |
| | | /** 表åç§° */ |
| | | @NotBlank(message = "表åç§°ä¸è½ä¸ºç©º") |
| | | private String tableName; |
| | | |
| | | /** 表æè¿° */ |
| | | @NotBlank(message = "表æè¿°ä¸è½ä¸ºç©º") |
| | | private String tableComment; |
| | | |
| | | /** å®ä½ç±»åç§°(é¦åæ¯å¤§å) */ |
| | | @NotBlank(message = "å®ä½ç±»åç§°ä¸è½ä¸ºç©º") |
| | | private String className; |
| | | |
| | | /** 使ç¨ç模æ¿ï¼crudå表æä½ treeæ 表æä½ï¼ */ |
| | | private String tplCategory; |
| | | |
| | | /** çæå
è·¯å¾ */ |
| | | @NotBlank(message = "çæå
è·¯å¾ä¸è½ä¸ºç©º") |
| | | private String packageName; |
| | | |
| | | /** çææ¨¡åå */ |
| | | @NotBlank(message = "çææ¨¡ååä¸è½ä¸ºç©º") |
| | | private String moduleName; |
| | | |
| | | /** çæä¸å¡å */ |
| | | @NotBlank(message = "çæä¸å¡åä¸è½ä¸ºç©º") |
| | | private String businessName; |
| | | |
| | | /** çæåè½å */ |
| | | @NotBlank(message = "çæåè½åä¸è½ä¸ºç©º") |
| | | private String functionName; |
| | | |
| | | /** çæä½è
*/ |
| | | @NotBlank(message = "ä½è
ä¸è½ä¸ºç©º") |
| | | private String functionAuthor; |
| | | |
| | | /** 主é®ä¿¡æ¯ */ |
| | | private GenTableColumn pkColumn; |
| | | |
| | | /** 表åä¿¡æ¯ */ |
| | | @Valid |
| | | private List<GenTableColumn> columns; |
| | | |
| | | /** å
¶å®çæé项 */ |
| | | private String options; |
| | | |
| | | /** æ ç¼ç åæ®µ */ |
| | | private String treeCode; |
| | | |
| | | /** æ ç¶ç¼ç åæ®µ */ |
| | | private String treeParentCode; |
| | | |
| | | /** æ åç§°åæ®µ */ |
| | | private String treeName; |
| | | |
| | | public Long getTableId() |
| | | { |
| | | return tableId; |
| | | } |
| | | |
| | | public void setTableId(Long tableId) |
| | | { |
| | | this.tableId = tableId; |
| | | } |
| | | |
| | | public String getTableName() |
| | | { |
| | | return tableName; |
| | | } |
| | | |
| | | public void setTableName(String tableName) |
| | | { |
| | | this.tableName = tableName; |
| | | } |
| | | |
| | | public String getTableComment() |
| | | { |
| | | return tableComment; |
| | | } |
| | | |
| | | public void setTableComment(String tableComment) |
| | | { |
| | | this.tableComment = tableComment; |
| | | } |
| | | |
| | | public String getClassName() |
| | | { |
| | | return className; |
| | | } |
| | | |
| | | public void setClassName(String className) |
| | | { |
| | | this.className = className; |
| | | } |
| | | |
| | | public String getTplCategory() |
| | | { |
| | | return tplCategory; |
| | | } |
| | | |
| | | public void setTplCategory(String tplCategory) |
| | | { |
| | | this.tplCategory = tplCategory; |
| | | } |
| | | |
| | | public String getPackageName() |
| | | { |
| | | return packageName; |
| | | } |
| | | |
| | | public void setPackageName(String packageName) |
| | | { |
| | | this.packageName = packageName; |
| | | } |
| | | |
| | | public String getModuleName() |
| | | { |
| | | return moduleName; |
| | | } |
| | | |
| | | public void setModuleName(String moduleName) |
| | | { |
| | | this.moduleName = moduleName; |
| | | } |
| | | |
| | | public String getBusinessName() |
| | | { |
| | | return businessName; |
| | | } |
| | | |
| | | public void setBusinessName(String businessName) |
| | | { |
| | | this.businessName = businessName; |
| | | } |
| | | |
| | | public String getFunctionName() |
| | | { |
| | | return functionName; |
| | | } |
| | | |
| | | public void setFunctionName(String functionName) |
| | | { |
| | | this.functionName = functionName; |
| | | } |
| | | |
| | | public String getFunctionAuthor() |
| | | { |
| | | return functionAuthor; |
| | | } |
| | | |
| | | public void setFunctionAuthor(String functionAuthor) |
| | | { |
| | | this.functionAuthor = functionAuthor; |
| | | } |
| | | |
| | | public GenTableColumn getPkColumn() |
| | | { |
| | | return pkColumn; |
| | | } |
| | | |
| | | public void setPkColumn(GenTableColumn pkColumn) |
| | | { |
| | | this.pkColumn = pkColumn; |
| | | } |
| | | |
| | | public List<GenTableColumn> getColumns() |
| | | { |
| | | return columns; |
| | | } |
| | | |
| | | public void setColumns(List<GenTableColumn> columns) |
| | | { |
| | | this.columns = columns; |
| | | } |
| | | |
| | | public String getOptions() |
| | | { |
| | | return options; |
| | | } |
| | | |
| | | public void setOptions(String options) |
| | | { |
| | | this.options = options; |
| | | } |
| | | |
| | | public String getTreeCode() |
| | | { |
| | | return treeCode; |
| | | } |
| | | |
| | | public void setTreeCode(String treeCode) |
| | | { |
| | | this.treeCode = treeCode; |
| | | } |
| | | |
| | | public String getTreeParentCode() |
| | | { |
| | | return treeParentCode; |
| | | } |
| | | |
| | | public void setTreeParentCode(String treeParentCode) |
| | | { |
| | | this.treeParentCode = treeParentCode; |
| | | } |
| | | |
| | | public String getTreeName() |
| | | { |
| | | return treeName; |
| | | } |
| | | |
| | | public void setTreeName(String treeName) |
| | | { |
| | | this.treeName = treeName; |
| | | } |
| | | |
| | | public boolean isTree() |
| | | { |
| | | return isTree(this.tplCategory); |
| | | } |
| | | |
| | | public static boolean isTree(String tplCategory) |
| | | { |
| | | return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory); |
| | | } |
| | | |
| | | public boolean isCrud() |
| | | { |
| | | return isCrud(this.tplCategory); |
| | | } |
| | | |
| | | public static boolean isCrud(String tplCategory) |
| | | { |
| | | return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory); |
| | | } |
| | | |
| | | public boolean isSuperColumn(String javaField) |
| | | { |
| | | return isSuperColumn(this.tplCategory, javaField); |
| | | } |
| | | |
| | | public static boolean isSuperColumn(String tplCategory, String javaField) |
| | | { |
| | | if (isTree(tplCategory)) |
| | | { |
| | | return StringUtils.equalsAnyIgnoreCase(javaField, |
| | | ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY)); |
| | | } |
| | | return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.generator.domain; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | /** |
| | | * 代ç çæä¸å¡å段表 gen_table_column |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class GenTableColumn extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** ç¼å· */ |
| | | private Long columnId; |
| | | |
| | | /** å½å±è¡¨ç¼å· */ |
| | | private Long tableId; |
| | | |
| | | /** ååç§° */ |
| | | private String columnName; |
| | | |
| | | /** åæè¿° */ |
| | | private String columnComment; |
| | | |
| | | /** åç±»å */ |
| | | private String columnType; |
| | | |
| | | /** JAVAç±»å */ |
| | | private String javaType; |
| | | |
| | | /** JAVAåæ®µå */ |
| | | @NotBlank(message = "Java屿§ä¸è½ä¸ºç©º") |
| | | private String javaField; |
| | | |
| | | /** æ¯å¦ä¸»é®ï¼1æ¯ï¼ */ |
| | | private String isPk; |
| | | |
| | | /** æ¯å¦èªå¢ï¼1æ¯ï¼ */ |
| | | private String isIncrement; |
| | | |
| | | /** æ¯å¦å¿
å¡«ï¼1æ¯ï¼ */ |
| | | private String isRequired; |
| | | |
| | | /** æ¯å¦ä¸ºæå
¥å段ï¼1æ¯ï¼ */ |
| | | private String isInsert; |
| | | |
| | | /** æ¯å¦ç¼è¾å段ï¼1æ¯ï¼ */ |
| | | private String isEdit; |
| | | |
| | | /** æ¯å¦åè¡¨åæ®µï¼1æ¯ï¼ */ |
| | | private String isList; |
| | | |
| | | /** æ¯å¦æ¥è¯¢å段ï¼1æ¯ï¼ */ |
| | | private String isQuery; |
| | | |
| | | /** æ¥è¯¢æ¹å¼ï¼EQçäºãNEä¸çäºãGT大äºãLTå°äºãLIKE模ç³ãBETWEENèå´ï¼ */ |
| | | private String queryType; |
| | | |
| | | /** æ¾ç¤ºç±»åï¼inputææ¬æ¡ãtextareaææ¬åãselect䏿æ¡ãcheckboxå¤éæ¡ãradioåéæ¡ãdatetimeæ¥ææ§ä»¶ï¼ */ |
| | | private String htmlType; |
| | | |
| | | /** åå
¸ç±»å */ |
| | | private String dictType; |
| | | |
| | | /** æåº */ |
| | | private Integer sort; |
| | | |
| | | public void setColumnId(Long columnId) |
| | | { |
| | | this.columnId = columnId; |
| | | } |
| | | |
| | | public Long getColumnId() |
| | | { |
| | | return columnId; |
| | | } |
| | | |
| | | public void setTableId(Long tableId) |
| | | { |
| | | this.tableId = tableId; |
| | | } |
| | | |
| | | public Long getTableId() |
| | | { |
| | | return tableId; |
| | | } |
| | | |
| | | public void setColumnName(String columnName) |
| | | { |
| | | this.columnName = columnName; |
| | | } |
| | | |
| | | public String getColumnName() |
| | | { |
| | | return columnName; |
| | | } |
| | | |
| | | public void setColumnComment(String columnComment) |
| | | { |
| | | this.columnComment = columnComment; |
| | | } |
| | | |
| | | public String getColumnComment() |
| | | { |
| | | return columnComment; |
| | | } |
| | | |
| | | public void setColumnType(String columnType) |
| | | { |
| | | this.columnType = columnType; |
| | | } |
| | | |
| | | public String getColumnType() |
| | | { |
| | | return columnType; |
| | | } |
| | | |
| | | public void setJavaType(String javaType) |
| | | { |
| | | this.javaType = javaType; |
| | | } |
| | | |
| | | public String getJavaType() |
| | | { |
| | | return javaType; |
| | | } |
| | | |
| | | public void setJavaField(String javaField) |
| | | { |
| | | this.javaField = javaField; |
| | | } |
| | | |
| | | public String getJavaField() |
| | | { |
| | | return javaField; |
| | | } |
| | | |
| | | public void setIsPk(String isPk) |
| | | { |
| | | this.isPk = isPk; |
| | | } |
| | | |
| | | public String getIsPk() |
| | | { |
| | | return isPk; |
| | | } |
| | | |
| | | public boolean isPk() |
| | | { |
| | | return isPk(this.isPk); |
| | | } |
| | | |
| | | public boolean isPk(String isPk) |
| | | { |
| | | return isPk != null && StringUtils.equals("1", isPk); |
| | | } |
| | | |
| | | public String getIsIncrement() |
| | | { |
| | | return isIncrement; |
| | | } |
| | | |
| | | public void setIsIncrement(String isIncrement) |
| | | { |
| | | this.isIncrement = isIncrement; |
| | | } |
| | | |
| | | public boolean isIncrement() |
| | | { |
| | | return isIncrement(this.isIncrement); |
| | | } |
| | | |
| | | public boolean isIncrement(String isIncrement) |
| | | { |
| | | return isIncrement != null && StringUtils.equals("1", isIncrement); |
| | | } |
| | | |
| | | public void setIsRequired(String isRequired) |
| | | { |
| | | this.isRequired = isRequired; |
| | | } |
| | | |
| | | public String getIsRequired() |
| | | { |
| | | return isRequired; |
| | | } |
| | | |
| | | public boolean isRequired() |
| | | { |
| | | return isRequired(this.isRequired); |
| | | } |
| | | |
| | | public boolean isRequired(String isRequired) |
| | | { |
| | | return isRequired != null && StringUtils.equals("1", isRequired); |
| | | } |
| | | |
| | | public void setIsInsert(String isInsert) |
| | | { |
| | | this.isInsert = isInsert; |
| | | } |
| | | |
| | | public String getIsInsert() |
| | | { |
| | | return isInsert; |
| | | } |
| | | |
| | | public boolean isInsert() |
| | | { |
| | | return isInsert(this.isInsert); |
| | | } |
| | | |
| | | public boolean isInsert(String isInsert) |
| | | { |
| | | return isInsert != null && StringUtils.equals("1", isInsert); |
| | | } |
| | | |
| | | public void setIsEdit(String isEdit) |
| | | { |
| | | this.isEdit = isEdit; |
| | | } |
| | | |
| | | public String getIsEdit() |
| | | { |
| | | return isEdit; |
| | | } |
| | | |
| | | public boolean isEdit() |
| | | { |
| | | return isInsert(this.isEdit); |
| | | } |
| | | |
| | | public boolean isEdit(String isEdit) |
| | | { |
| | | return isEdit != null && StringUtils.equals("1", isEdit); |
| | | } |
| | | |
| | | public void setIsList(String isList) |
| | | { |
| | | this.isList = isList; |
| | | } |
| | | |
| | | public String getIsList() |
| | | { |
| | | return isList; |
| | | } |
| | | |
| | | public boolean isList() |
| | | { |
| | | return isList(this.isList); |
| | | } |
| | | |
| | | public boolean isList(String isList) |
| | | { |
| | | return isList != null && StringUtils.equals("1", isList); |
| | | } |
| | | |
| | | public void setIsQuery(String isQuery) |
| | | { |
| | | this.isQuery = isQuery; |
| | | } |
| | | |
| | | public String getIsQuery() |
| | | { |
| | | return isQuery; |
| | | } |
| | | |
| | | public boolean isQuery() |
| | | { |
| | | return isQuery(this.isQuery); |
| | | } |
| | | |
| | | public boolean isQuery(String isQuery) |
| | | { |
| | | return isQuery != null && StringUtils.equals("1", isQuery); |
| | | } |
| | | |
| | | public void setQueryType(String queryType) |
| | | { |
| | | this.queryType = queryType; |
| | | } |
| | | |
| | | public String getQueryType() |
| | | { |
| | | return queryType; |
| | | } |
| | | |
| | | public String getHtmlType() |
| | | { |
| | | return htmlType; |
| | | } |
| | | |
| | | public void setHtmlType(String htmlType) |
| | | { |
| | | this.htmlType = htmlType; |
| | | } |
| | | |
| | | public void setDictType(String dictType) |
| | | { |
| | | this.dictType = dictType; |
| | | } |
| | | |
| | | public String getDictType() |
| | | { |
| | | return dictType; |
| | | } |
| | | |
| | | public void setSort(Integer sort) |
| | | { |
| | | this.sort = sort; |
| | | } |
| | | |
| | | public Integer getSort() |
| | | { |
| | | return sort; |
| | | } |
| | | |
| | | public boolean isSuperColumn() |
| | | { |
| | | return isSuperColumn(this.javaField); |
| | | } |
| | | |
| | | public static boolean isSuperColumn(String javaField) |
| | | { |
| | | return StringUtils.equalsAnyIgnoreCase(javaField, |
| | | // BaseEntity |
| | | "createBy", "createTime", "updateBy", "updateTime", "remark", |
| | | // TreeEntity |
| | | "parentName", "parentId", "orderNum", "ancestors"); |
| | | } |
| | | |
| | | public boolean isUsableColumn() |
| | | { |
| | | return isUsableColumn(javaField); |
| | | } |
| | | |
| | | public static boolean isUsableColumn(String javaField) |
| | | { |
| | | // isSuperColumn()ä¸çååç¨äºé¿å
çæå¤ä½Domain屿§ï¼è¥æäºå±æ§å¨çæé¡µé¢æ¶éè¦ç¨å°ä¸è½å¿½ç¥ï¼åæ¾å¨æ¤å¤ç½åå |
| | | return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum"); |
| | | } |
| | | |
| | | public String readConverterExp() |
| | | { |
| | | String remarks = StringUtils.substringBetween(this.columnComment, "ï¼", "ï¼"); |
| | | StringBuffer sb = new StringBuffer(); |
| | | if (StringUtils.isNotEmpty(remarks)) |
| | | { |
| | | for (String value : remarks.split(" ")) |
| | | { |
| | | if (StringUtils.isNotEmpty(value)) |
| | | { |
| | | Object startStr = value.subSequence(0, 1); |
| | | String endStr = value.substring(1); |
| | | sb.append("").append(startStr).append("=").append(endStr).append(","); |
| | | } |
| | | } |
| | | return sb.deleteCharAt(sb.length() - 1).toString(); |
| | | } |
| | | else |
| | | { |
| | | return this.columnComment; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.generator.mapper; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.generator.domain.GenTableColumn; |
| | | |
| | | /** |
| | | * ä¸å¡å段 æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface GenTableColumnMapper |
| | | { |
| | | /** |
| | | * æ ¹æ®è¡¨åç§°æ¥è¯¢åä¿¡æ¯ |
| | | * |
| | | * @param tableName 表åç§° |
| | | * @return åä¿¡æ¯ |
| | | */ |
| | | public List<GenTableColumn> selectDbTableColumnsByName(String tableName); |
| | | |
| | | /** |
| | | * æ¥è¯¢ä¸å¡å段å表 |
| | | * |
| | | * @param tableId ä¸å¡å段ç¼å· |
| | | * @return ä¸å¡å段éå |
| | | */ |
| | | public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId); |
| | | |
| | | /** |
| | | * æ°å¢ä¸å¡å段 |
| | | * |
| | | * @param genTableColumn ä¸å¡åæ®µä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertGenTableColumn(GenTableColumn genTableColumn); |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¸å¡å段 |
| | | * |
| | | * @param genTableColumn ä¸å¡åæ®µä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateGenTableColumn(GenTableColumn genTableColumn); |
| | | |
| | | /** |
| | | * æ¹éå é¤ä¸å¡å段 |
| | | * |
| | | * @param ids éè¦å é¤çæ°æ®ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteGenTableColumnByIds(Long[] ids); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.generator.mapper; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.generator.domain.GenTable; |
| | | |
| | | /** |
| | | * ä¸å¡ æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface GenTableMapper |
| | | { |
| | | /** |
| | | * æ¥è¯¢ä¸å¡å表 |
| | | * |
| | | * @param genTable ä¸å¡ä¿¡æ¯ |
| | | * @return ä¸å¡éå |
| | | */ |
| | | public List<GenTable> selectGenTableList(GenTable genTable); |
| | | |
| | | /** |
| | | * æ¥è¯¢æ®åºå表 |
| | | * |
| | | * @param genTable ä¸å¡ä¿¡æ¯ |
| | | * @return æ°æ®åºè¡¨éå |
| | | */ |
| | | public List<GenTable> selectDbTableList(GenTable genTable); |
| | | |
| | | /** |
| | | * æ¥è¯¢æ®åºå表 |
| | | * |
| | | * @param tableNames 表åç§°ç» |
| | | * @return æ°æ®åºè¡¨éå |
| | | */ |
| | | public List<GenTable> selectDbTableListByNames(String[] tableNames); |
| | | |
| | | /** |
| | | * æ¥è¯¢è¡¨IDä¸å¡ä¿¡æ¯ |
| | | * |
| | | * @param id ä¸å¡ID |
| | | * @return ä¸å¡ä¿¡æ¯ |
| | | */ |
| | | public GenTable selectGenTableById(Long id); |
| | | |
| | | /** |
| | | * æ¥è¯¢è¡¨åç§°ä¸å¡ä¿¡æ¯ |
| | | * |
| | | * @param tableName 表åç§° |
| | | * @return ä¸å¡ä¿¡æ¯ |
| | | */ |
| | | public GenTable selectGenTableByName(String tableName); |
| | | |
| | | /** |
| | | * æ°å¢ä¸å¡ |
| | | * |
| | | * @param genTable ä¸å¡ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertGenTable(GenTable genTable); |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¸å¡ |
| | | * |
| | | * @param genTable ä¸å¡ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateGenTable(GenTable genTable); |
| | | |
| | | /** |
| | | * æ¹éå é¤ä¸å¡ |
| | | * |
| | | * @param ids éè¦å é¤çæ°æ®ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteGenTableByIds(Long[] ids); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.generator.domain.GenTableColumn; |
| | | import com.ruoyi.generator.mapper.GenTableColumnMapper; |
| | | |
| | | /** |
| | | * ä¸å¡å段 æå¡å±å®ç° |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class GenTableColumnServiceImpl implements IGenTableColumnService |
| | | { |
| | | @Autowired |
| | | private GenTableColumnMapper genTableColumnMapper; |
| | | |
| | | /** |
| | | * æ¥è¯¢ä¸å¡å段å表 |
| | | * |
| | | * @param tableId ä¸å¡å段ç¼å· |
| | | * @return ä¸å¡å段éå |
| | | */ |
| | | @Override |
| | | public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) |
| | | { |
| | | return genTableColumnMapper.selectGenTableColumnListByTableId(tableId); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢ä¸å¡å段 |
| | | * |
| | | * @param genTableColumn ä¸å¡åæ®µä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int insertGenTableColumn(GenTableColumn genTableColumn) |
| | | { |
| | | return genTableColumnMapper.insertGenTableColumn(genTableColumn); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¸å¡å段 |
| | | * |
| | | * @param genTableColumn ä¸å¡åæ®µä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int updateGenTableColumn(GenTableColumn genTableColumn) |
| | | { |
| | | return genTableColumnMapper.updateGenTableColumn(genTableColumn); |
| | | } |
| | | |
| | | /** |
| | | * å é¤ä¸å¡å段对象 |
| | | * |
| | | * @param ids éè¦å é¤çæ°æ®ID |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int deleteGenTableColumnByIds(String ids) |
| | | { |
| | | return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids)); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.generator.service; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.StringWriter; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.zip.ZipEntry; |
| | | import java.util.zip.ZipOutputStream; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.velocity.Template; |
| | | import org.apache.velocity.VelocityContext; |
| | | import org.apache.velocity.app.Velocity; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.GenConstants; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | 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; |
| | | |
| | | /** |
| | | * ä¸å¡ æå¡å±å®ç° |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class GenTableServiceImpl implements IGenTableService |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class); |
| | | |
| | | @Autowired |
| | | private GenTableMapper genTableMapper; |
| | | |
| | | @Autowired |
| | | private GenTableColumnMapper genTableColumnMapper; |
| | | |
| | | /** |
| | | * æ¥è¯¢ä¸å¡ä¿¡æ¯ |
| | | * |
| | | * @param id ä¸å¡ID |
| | | * @return ä¸å¡ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public GenTable selectGenTableById(Long id) |
| | | { |
| | | GenTable genTable = genTableMapper.selectGenTableById(id); |
| | | setTableFromOptions(genTable); |
| | | return genTable; |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ä¸å¡å表 |
| | | * |
| | | * @param genTable ä¸å¡ä¿¡æ¯ |
| | | * @return ä¸å¡éå |
| | | */ |
| | | @Override |
| | | public List<GenTable> selectGenTableList(GenTable genTable) |
| | | { |
| | | return genTableMapper.selectGenTableList(genTable); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢æ®åºå表 |
| | | * |
| | | * @param genTable ä¸å¡ä¿¡æ¯ |
| | | * @return æ°æ®åºè¡¨éå |
| | | */ |
| | | @Override |
| | | public List<GenTable> selectDbTableList(GenTable genTable) |
| | | { |
| | | return genTableMapper.selectDbTableList(genTable); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢æ®åºå表 |
| | | * |
| | | * @param tableNames 表åç§°ç» |
| | | * @return æ°æ®åºè¡¨éå |
| | | */ |
| | | @Override |
| | | public List<GenTable> selectDbTableListByNames(String[] tableNames) |
| | | { |
| | | return genTableMapper.selectDbTableListByNames(tableNames); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¸å¡ |
| | | * |
| | | * @param genTable ä¸å¡ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void updateGenTable(GenTable genTable) |
| | | { |
| | | String options = JSON.toJSONString(genTable.getParams()); |
| | | genTable.setOptions(options); |
| | | int row = genTableMapper.updateGenTable(genTable); |
| | | if (row > 0) |
| | | { |
| | | for (GenTableColumn cenTableColumn : genTable.getColumns()) |
| | | { |
| | | genTableColumnMapper.updateGenTableColumn(cenTableColumn); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å é¤ä¸å¡å¯¹è±¡ |
| | | * |
| | | * @param tableIds éè¦å é¤çæ°æ®ID |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void deleteGenTableByIds(Long[] tableIds) |
| | | { |
| | | genTableMapper.deleteGenTableByIds(tableIds); |
| | | genTableColumnMapper.deleteGenTableColumnByIds(tableIds); |
| | | } |
| | | |
| | | /** |
| | | * 导å
¥è¡¨ç»æ |
| | | * |
| | | * @param tableList 导å
¥è¡¨å表 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void importGenTable(List<GenTable> tableList) |
| | | { |
| | | String operName = SecurityUtils.getUsername(); |
| | | try |
| | | { |
| | | for (GenTable table : tableList) |
| | | { |
| | | String tableName = table.getTableName(); |
| | | GenUtils.initTable(table, operName); |
| | | int row = genTableMapper.insertGenTable(table); |
| | | if (row > 0) |
| | | { |
| | | // ä¿ååä¿¡æ¯ |
| | | List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); |
| | | for (GenTableColumn column : genTableColumns) |
| | | { |
| | | GenUtils.initColumnField(column, table); |
| | | genTableColumnMapper.insertGenTableColumn(column); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new CustomException("导å
¥å¤±è´¥ï¼" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * é¢è§ä»£ç |
| | | * |
| | | * @param tableId 表ç¼å· |
| | | * @return é¢è§æ°æ®å表 |
| | | */ |
| | | @Override |
| | | public Map<String, String> previewCode(Long tableId) |
| | | { |
| | | Map<String, String> dataMap = new LinkedHashMap<>(); |
| | | // æ¥è¯¢è¡¨ä¿¡æ¯ |
| | | GenTable table = genTableMapper.selectGenTableById(tableId); |
| | | // æ¥è¯¢åä¿¡æ¯ |
| | | List<GenTableColumn> columns = table.getColumns(); |
| | | setPkColumn(table, columns); |
| | | VelocityInitializer.initVelocity(); |
| | | |
| | | VelocityContext context = VelocityUtils.prepareContext(table); |
| | | |
| | | // è·å模æ¿å表 |
| | | List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); |
| | | for (String template : templates) |
| | | { |
| | | // æ¸²ææ¨¡æ¿ |
| | | StringWriter sw = new StringWriter(); |
| | | Template tpl = Velocity.getTemplate(template, Constants.UTF8); |
| | | tpl.merge(context, sw); |
| | | dataMap.put(template, sw.toString()); |
| | | } |
| | | return dataMap; |
| | | } |
| | | |
| | | /** |
| | | * çæä»£ç |
| | | * |
| | | * @param tableName 表åç§° |
| | | * @return æ°æ® |
| | | */ |
| | | @Override |
| | | public byte[] generatorCode(String tableName) |
| | | { |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | ZipOutputStream zip = new ZipOutputStream(outputStream); |
| | | generatorCode(tableName, zip); |
| | | IOUtils.closeQuietly(zip); |
| | | return outputStream.toByteArray(); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éçæä»£ç |
| | | * |
| | | * @param tableNames 表æ°ç» |
| | | * @return æ°æ® |
| | | */ |
| | | @Override |
| | | public byte[] generatorCode(String[] tableNames) |
| | | { |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | ZipOutputStream zip = new ZipOutputStream(outputStream); |
| | | for (String tableName : tableNames) |
| | | { |
| | | generatorCode(tableName, zip); |
| | | } |
| | | IOUtils.closeQuietly(zip); |
| | | return outputStream.toByteArray(); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢è¡¨ä¿¡æ¯å¹¶çæä»£ç |
| | | */ |
| | | private void generatorCode(String tableName, ZipOutputStream zip) |
| | | { |
| | | // æ¥è¯¢è¡¨ä¿¡æ¯ |
| | | GenTable table = genTableMapper.selectGenTableByName(tableName); |
| | | // æ¥è¯¢åä¿¡æ¯ |
| | | List<GenTableColumn> columns = table.getColumns(); |
| | | setPkColumn(table, columns); |
| | | |
| | | VelocityInitializer.initVelocity(); |
| | | |
| | | VelocityContext context = VelocityUtils.prepareContext(table); |
| | | |
| | | // è·å模æ¿å表 |
| | | List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); |
| | | for (String template : templates) |
| | | { |
| | | // æ¸²ææ¨¡æ¿ |
| | | StringWriter sw = new StringWriter(); |
| | | Template tpl = Velocity.getTemplate(template, Constants.UTF8); |
| | | tpl.merge(context, sw); |
| | | try |
| | | { |
| | | // æ·»å å°zip |
| | | zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table))); |
| | | IOUtils.write(sw.toString(), zip, Constants.UTF8); |
| | | IOUtils.closeQuietly(sw); |
| | | zip.flush(); |
| | | zip.closeEntry(); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | log.error("æ¸²ææ¨¡æ¿å¤±è´¥ï¼è¡¨åï¼" + table.getTableName(), e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¿ååæ°æ ¡éª |
| | | * |
| | | * @param genTable ä¸å¡ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public void validateEdit(GenTable genTable) |
| | | { |
| | | if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) |
| | | { |
| | | String options = JSON.toJSONString(genTable.getParams()); |
| | | JSONObject paramsObj = JSONObject.parseObject(options); |
| | | if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) |
| | | { |
| | | throw new CustomException("æ ç¼ç åæ®µä¸è½ä¸ºç©º"); |
| | | } |
| | | else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) |
| | | { |
| | | throw new CustomException("æ ç¶ç¼ç åæ®µä¸è½ä¸ºç©º"); |
| | | } |
| | | else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) |
| | | { |
| | | throw new CustomException("æ åç§°åæ®µä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置主é®åä¿¡æ¯ |
| | | * |
| | | * @param table ä¸å¡è¡¨ä¿¡æ¯ |
| | | * @param columns ä¸å¡å段å表 |
| | | */ |
| | | public void setPkColumn(GenTable table, List<GenTableColumn> columns) |
| | | { |
| | | for (GenTableColumn column : columns) |
| | | { |
| | | if (column.isPk()) |
| | | { |
| | | table.setPkColumn(column); |
| | | break; |
| | | } |
| | | } |
| | | if (StringUtils.isNull(table.getPkColumn())) |
| | | { |
| | | table.setPkColumn(columns.get(0)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置代ç çæå
¶ä»éé¡¹å¼ |
| | | * |
| | | * @param genTable 设置åççæå¯¹è±¡ |
| | | */ |
| | | public void setTableFromOptions(GenTable genTable) |
| | | { |
| | | JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions()); |
| | | if (StringUtils.isNotNull(paramsObj)) |
| | | { |
| | | String treeCode = paramsObj.getString(GenConstants.TREE_CODE); |
| | | String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE); |
| | | String treeName = paramsObj.getString(GenConstants.TREE_NAME); |
| | | genTable.setTreeCode(treeCode); |
| | | genTable.setTreeParentCode(treeParentCode); |
| | | genTable.setTreeName(treeName); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.generator.service; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.generator.domain.GenTableColumn; |
| | | |
| | | /** |
| | | * ä¸å¡å段 æå¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface IGenTableColumnService |
| | | { |
| | | /** |
| | | * æ¥è¯¢ä¸å¡å段å表 |
| | | * |
| | | * @param tableId ä¸å¡å段ç¼å· |
| | | * @return ä¸å¡å段éå |
| | | */ |
| | | public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId); |
| | | |
| | | /** |
| | | * æ°å¢ä¸å¡å段 |
| | | * |
| | | * @param genTableColumn ä¸å¡åæ®µä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertGenTableColumn(GenTableColumn genTableColumn); |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¸å¡å段 |
| | | * |
| | | * @param genTableColumn ä¸å¡åæ®µä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateGenTableColumn(GenTableColumn genTableColumn); |
| | | |
| | | /** |
| | | * å é¤ä¸å¡åæ®µä¿¡æ¯ |
| | | * |
| | | * @param ids éè¦å é¤çæ°æ®ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteGenTableColumnByIds(String ids); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.generator.service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import com.ruoyi.generator.domain.GenTable; |
| | | |
| | | /** |
| | | * ä¸å¡ æå¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface IGenTableService |
| | | { |
| | | /** |
| | | * æ¥è¯¢ä¸å¡å表 |
| | | * |
| | | * @param genTable ä¸å¡ä¿¡æ¯ |
| | | * @return ä¸å¡éå |
| | | */ |
| | | public List<GenTable> selectGenTableList(GenTable genTable); |
| | | |
| | | /** |
| | | * æ¥è¯¢æ®åºå表 |
| | | * |
| | | * @param genTable ä¸å¡ä¿¡æ¯ |
| | | * @return æ°æ®åºè¡¨éå |
| | | */ |
| | | public List<GenTable> selectDbTableList(GenTable genTable); |
| | | |
| | | /** |
| | | * æ¥è¯¢æ®åºå表 |
| | | * |
| | | * @param tableNames 表åç§°ç» |
| | | * @return æ°æ®åºè¡¨éå |
| | | */ |
| | | public List<GenTable> selectDbTableListByNames(String[] tableNames); |
| | | |
| | | /** |
| | | * æ¥è¯¢ä¸å¡ä¿¡æ¯ |
| | | * |
| | | * @param id ä¸å¡ID |
| | | * @return ä¸å¡ä¿¡æ¯ |
| | | */ |
| | | public GenTable selectGenTableById(Long id); |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¸å¡ |
| | | * |
| | | * @param genTable ä¸å¡ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public void updateGenTable(GenTable genTable); |
| | | |
| | | /** |
| | | * å é¤ä¸å¡ä¿¡æ¯ |
| | | * |
| | | * @param tableIds éè¦å é¤çè¡¨æ°æ®ID |
| | | * @return ç»æ |
| | | */ |
| | | public void deleteGenTableByIds(Long[] tableIds); |
| | | |
| | | /** |
| | | * 导å
¥è¡¨ç»æ |
| | | * |
| | | * @param tableList 导å
¥è¡¨å表 |
| | | */ |
| | | public void importGenTable(List<GenTable> tableList); |
| | | |
| | | /** |
| | | * é¢è§ä»£ç |
| | | * |
| | | * @param tableId 表ç¼å· |
| | | * @return é¢è§æ°æ®å表 |
| | | */ |
| | | public Map<String, String> previewCode(Long tableId); |
| | | |
| | | /** |
| | | * çæä»£ç |
| | | * |
| | | * @param tableName 表åç§° |
| | | * @return æ°æ® |
| | | */ |
| | | public byte[] generatorCode(String tableName); |
| | | |
| | | /** |
| | | * æ¹éçæä»£ç |
| | | * |
| | | * @param tableNames 表æ°ç» |
| | | * @return æ°æ® |
| | | */ |
| | | public byte[] generatorCode(String[] tableNames); |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¿ååæ°æ ¡éª |
| | | * |
| | | * @param genTable ä¸å¡ä¿¡æ¯ |
| | | */ |
| | | public void validateEdit(GenTable genTable); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.generator.config.GenConfig; |
| | | import com.ruoyi.generator.domain.GenTable; |
| | | import com.ruoyi.generator.domain.GenTableColumn; |
| | | |
| | | /** |
| | | * 代ç çæå¨ å·¥å
·ç±» |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class GenUtils |
| | | { |
| | | /** |
| | | * åå§åè¡¨ä¿¡æ¯ |
| | | */ |
| | | public static void initTable(GenTable genTable, String operName) |
| | | { |
| | | genTable.setClassName(convertClassName(genTable.getTableName())); |
| | | genTable.setPackageName(GenConfig.getPackageName()); |
| | | genTable.setModuleName(getModuleName(GenConfig.getPackageName())); |
| | | genTable.setBusinessName(getBusinessName(genTable.getTableName())); |
| | | genTable.setFunctionName(replaceText(genTable.getTableComment())); |
| | | genTable.setFunctionAuthor(GenConfig.getAuthor()); |
| | | genTable.setCreateBy(operName); |
| | | } |
| | | |
| | | /** |
| | | * åå§åå屿§å段 |
| | | */ |
| | | public static void initColumnField(GenTableColumn column, GenTable table) |
| | | { |
| | | String dataType = getDbType(column.getColumnType()); |
| | | String columnName = column.getColumnName(); |
| | | column.setTableId(table.getTableId()); |
| | | column.setCreateBy(table.getCreateBy()); |
| | | // 设置javaåæ®µå |
| | | column.setJavaField(StringUtils.toCamelCase(columnName)); |
| | | |
| | | if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType)) |
| | | { |
| | | column.setJavaType(GenConstants.TYPE_STRING); |
| | | // å符串é¿åº¦è¶
è¿500è®¾ç½®ä¸ºææ¬å |
| | | Integer columnLength = getColumnLength(column.getColumnType()); |
| | | String htmlType = columnLength >= 500 ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT; |
| | | column.setHtmlType(htmlType); |
| | | } |
| | | else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) |
| | | { |
| | | column.setJavaType(GenConstants.TYPE_DATE); |
| | | column.setHtmlType(GenConstants.HTML_DATETIME); |
| | | } |
| | | else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) |
| | | { |
| | | column.setHtmlType(GenConstants.HTML_INPUT); |
| | | |
| | | // å¦ææ¯æµ®ç¹å ç»ä¸ç¨BigDecimal |
| | | String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ","); |
| | | if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) |
| | | { |
| | | column.setJavaType(GenConstants.TYPE_BIGDECIMAL); |
| | | } |
| | | // å¦ææ¯æ´å½¢ |
| | | else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) |
| | | { |
| | | column.setJavaType(GenConstants.TYPE_INTEGER); |
| | | } |
| | | // é¿æ´å½¢ |
| | | else |
| | | { |
| | | column.setJavaType(GenConstants.TYPE_LONG); |
| | | } |
| | | } |
| | | |
| | | // æå
¥å段ï¼é»è®¤ææå段é½éè¦æå
¥ï¼ |
| | | column.setIsInsert(GenConstants.REQUIRE); |
| | | |
| | | // ç¼è¾å段 |
| | | if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk()) |
| | | { |
| | | column.setIsEdit(GenConstants.REQUIRE); |
| | | } |
| | | // åè¡¨åæ®µ |
| | | if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk()) |
| | | { |
| | | column.setIsList(GenConstants.REQUIRE); |
| | | } |
| | | // æ¥è¯¢å段 |
| | | if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk()) |
| | | { |
| | | column.setIsQuery(GenConstants.REQUIRE); |
| | | } |
| | | |
| | | // æ¥è¯¢å段类å |
| | | if (StringUtils.endsWithIgnoreCase(columnName, "name")) |
| | | { |
| | | column.setQueryType(GenConstants.QUERY_LIKE); |
| | | } |
| | | // ç¶æåæ®µè®¾ç½®åéæ¡ |
| | | if (StringUtils.endsWithIgnoreCase(columnName, "status")) |
| | | { |
| | | column.setHtmlType(GenConstants.HTML_RADIO); |
| | | } |
| | | // ç±»å&æ§å«åæ®µè®¾ç½®ä¸ææ¡ |
| | | else if (StringUtils.endsWithIgnoreCase(columnName, "type") |
| | | || StringUtils.endsWithIgnoreCase(columnName, "sex")) |
| | | { |
| | | column.setHtmlType(GenConstants.HTML_SELECT); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªæ°ç»æ¯å¦å
嫿å®å¼ |
| | | * |
| | | * @param arr æ°ç» |
| | | * @param targetValue å¼ |
| | | * @return æ¯å¦å
å« |
| | | */ |
| | | public static boolean arraysContains(String[] arr, String targetValue) |
| | | { |
| | | return Arrays.asList(arr).contains(targetValue); |
| | | } |
| | | |
| | | /** |
| | | * è·å模åå |
| | | * |
| | | * @param packageName å
å |
| | | * @return 模åå |
| | | */ |
| | | public static String getModuleName(String packageName) |
| | | { |
| | | int lastIndex = packageName.lastIndexOf("."); |
| | | int nameLength = packageName.length(); |
| | | String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength); |
| | | return moduleName; |
| | | } |
| | | |
| | | /** |
| | | * è·åä¸å¡å |
| | | * |
| | | * @param tableName 表å |
| | | * @return ä¸å¡å |
| | | */ |
| | | public static String getBusinessName(String tableName) |
| | | { |
| | | int lastIndex = tableName.indexOf("_"); |
| | | int nameLength = tableName.length(); |
| | | String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength); |
| | | return StringUtils.toCamelCase(businessName); |
| | | } |
| | | |
| | | /** |
| | | * 表åè½¬æ¢æJavaç±»å |
| | | * |
| | | * @param tableName 表åç§° |
| | | * @return ç±»å |
| | | */ |
| | | public static String convertClassName(String tableName) |
| | | { |
| | | boolean autoRemovePre = GenConfig.getAutoRemovePre(); |
| | | String tablePrefix = GenConfig.getTablePrefix(); |
| | | if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) |
| | | { |
| | | String[] searchList = StringUtils.split(tablePrefix, ","); |
| | | tableName = replaceFirst(tableName, searchList); |
| | | } |
| | | return StringUtils.convertToCamelCase(tableName); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éæ¿æ¢åç¼ |
| | | * |
| | | * @param replacementm æ¿æ¢å¼ |
| | | * @param searchList æ¿æ¢å表 |
| | | * @return |
| | | */ |
| | | public static String replaceFirst(String replacementm, String[] searchList) |
| | | { |
| | | String text = replacementm; |
| | | for (String searchString : searchList) |
| | | { |
| | | if (replacementm.startsWith(searchString)) |
| | | { |
| | | text = replacementm.replaceFirst(searchString, ""); |
| | | break; |
| | | } |
| | | } |
| | | return text; |
| | | } |
| | | |
| | | /** |
| | | * å
³é®åæ¿æ¢ |
| | | * |
| | | * @param name éè¦è¢«æ¿æ¢çåå |
| | | * @return æ¿æ¢åçåå |
| | | */ |
| | | public static String replaceText(String text) |
| | | { |
| | | return RegExUtils.replaceAll(text, "(?:表|è¥ä¾)", ""); |
| | | } |
| | | |
| | | /** |
| | | * è·åæ°æ®åºç±»ååæ®µ |
| | | * |
| | | * @param columnType åç±»å |
| | | * @return æªååçåç±»å |
| | | */ |
| | | public static String getDbType(String columnType) |
| | | { |
| | | if (StringUtils.indexOf(columnType, "(") > 0) |
| | | { |
| | | return StringUtils.substringBefore(columnType, "("); |
| | | } |
| | | else |
| | | { |
| | | return columnType; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·ååæ®µé¿åº¦ |
| | | * |
| | | * @param columnType åç±»å |
| | | * @return æªååçåç±»å |
| | | */ |
| | | public static Integer getColumnLength(String columnType) |
| | | { |
| | | if (StringUtils.indexOf(columnType, "(") > 0) |
| | | { |
| | | String length = StringUtils.substringBetween(columnType, "(", ")"); |
| | | return Integer.valueOf(length); |
| | | } |
| | | else |
| | | { |
| | | return 0; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.generator.util; |
| | | |
| | | import java.util.Properties; |
| | | import org.apache.velocity.app.Velocity; |
| | | import com.ruoyi.common.constant.Constants; |
| | | |
| | | /** |
| | | * VelocityEngineå·¥å |
| | | * |
| | | * @author RuoYi |
| | | */ |
| | | public class VelocityInitializer |
| | | { |
| | | /** |
| | | * åå§åvmæ¹æ³ |
| | | */ |
| | | public static void initVelocity() |
| | | { |
| | | Properties p = new Properties(); |
| | | try |
| | | { |
| | | // å è½½classpathç®å½ä¸çvmæä»¶ |
| | | p.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); |
| | | // å®ä¹å符é |
| | | p.setProperty(Velocity.ENCODING_DEFAULT, Constants.UTF8); |
| | | p.setProperty(Velocity.OUTPUT_ENCODING, Constants.UTF8); |
| | | // åå§åVelocityå¼æï¼æå®é
ç½®Properties |
| | | Velocity.init(p); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.generator.util; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import org.apache.velocity.VelocityContext; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.common.constant.GenConstants; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | 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/mapper"; |
| | | |
| | | /** |
| | | * 设置模æ¿åéä¿¡æ¯ |
| | | * |
| | | * @return 模æ¿å表 |
| | | */ |
| | | public static VelocityContext prepareContext(GenTable genTable) |
| | | { |
| | | String moduleName = genTable.getModuleName(); |
| | | String businessName = genTable.getBusinessName(); |
| | | String packageName = genTable.getPackageName(); |
| | | String tplCategory = genTable.getTplCategory(); |
| | | String functionName = genTable.getFunctionName(); |
| | | |
| | | VelocityContext velocityContext = new VelocityContext(); |
| | | velocityContext.put("tplCategory", genTable.getTplCategory()); |
| | | velocityContext.put("tableName", genTable.getTableName()); |
| | | velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "ã请填ååè½åç§°ã"); |
| | | velocityContext.put("ClassName", genTable.getClassName()); |
| | | velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName())); |
| | | velocityContext.put("moduleName", genTable.getModuleName()); |
| | | velocityContext.put("BusinessName", StringUtils.capitalize(genTable.getBusinessName())); |
| | | velocityContext.put("businessName", genTable.getBusinessName()); |
| | | velocityContext.put("basePackage", getPackagePrefix(packageName)); |
| | | velocityContext.put("packageName", packageName); |
| | | velocityContext.put("author", genTable.getFunctionAuthor()); |
| | | velocityContext.put("datetime", DateUtils.getDate()); |
| | | velocityContext.put("pkColumn", genTable.getPkColumn()); |
| | | velocityContext.put("importList", getImportList(genTable.getColumns())); |
| | | velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName)); |
| | | velocityContext.put("columns", genTable.getColumns()); |
| | | velocityContext.put("table", genTable); |
| | | if (GenConstants.TPL_TREE.equals(tplCategory)) |
| | | { |
| | | setTreeVelocityContext(velocityContext, genTable); |
| | | } |
| | | return velocityContext; |
| | | } |
| | | |
| | | public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) |
| | | { |
| | | String options = genTable.getOptions(); |
| | | JSONObject paramsObj = JSONObject.parseObject(options); |
| | | String treeCode = getTreecode(paramsObj); |
| | | String treeParentCode = getTreeParentCode(paramsObj); |
| | | String treeName = getTreeName(paramsObj); |
| | | |
| | | context.put("treeCode", treeCode); |
| | | context.put("treeParentCode", treeParentCode); |
| | | context.put("treeName", treeName); |
| | | context.put("expandColumn", getExpandColumn(genTable)); |
| | | if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) |
| | | { |
| | | context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE)); |
| | | } |
| | | if (paramsObj.containsKey(GenConstants.TREE_NAME)) |
| | | { |
| | | context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·å模æ¿ä¿¡æ¯ |
| | | * |
| | | * @return 模æ¿å表 |
| | | */ |
| | | public static List<String> getTemplateList(String tplCategory) |
| | | { |
| | | List<String> templates = new ArrayList<String>(); |
| | | templates.add("vm/java/domain.java.vm"); |
| | | templates.add("vm/java/mapper.java.vm"); |
| | | templates.add("vm/java/service.java.vm"); |
| | | templates.add("vm/java/serviceImpl.java.vm"); |
| | | templates.add("vm/java/controller.java.vm"); |
| | | templates.add("vm/xml/mapper.xml.vm"); |
| | | templates.add("vm/sql/sql.vm"); |
| | | templates.add("vm/js/api.js.vm"); |
| | | if (GenConstants.TPL_CRUD.equals(tplCategory)) |
| | | { |
| | | templates.add("vm/vue/index.vue.vm"); |
| | | } |
| | | else if (GenConstants.TPL_TREE.equals(tplCategory)) |
| | | { |
| | | templates.add("vm/vue/index-tree.vue.vm"); |
| | | } |
| | | return templates; |
| | | } |
| | | |
| | | /** |
| | | * è·åæä»¶å |
| | | */ |
| | | public static String getFileName(String template, GenTable genTable) |
| | | { |
| | | // æä»¶åç§° |
| | | String fileName = ""; |
| | | // å
è·¯å¾ |
| | | String packageName = genTable.getPackageName(); |
| | | // 模åå |
| | | String moduleName = genTable.getModuleName(); |
| | | // 大åç±»å |
| | | String className = genTable.getClassName(); |
| | | // ä¸å¡åç§° |
| | | String businessName = genTable.getBusinessName(); |
| | | |
| | | String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/"); |
| | | String mybatisPath = MYBATIS_PATH + "/" + moduleName; |
| | | String vuePath = "vue"; |
| | | |
| | | if (template.contains("domain.java.vm")) |
| | | { |
| | | fileName = StringUtils.format("{}/domain/{}.java", javaPath, className); |
| | | } |
| | | else if (template.contains("mapper.java.vm")) |
| | | { |
| | | fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className); |
| | | } |
| | | else if (template.contains("service.java.vm")) |
| | | { |
| | | fileName = StringUtils.format("{}/service/I{}Service.java", javaPath, className); |
| | | } |
| | | else if (template.contains("serviceImpl.java.vm")) |
| | | { |
| | | fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className); |
| | | } |
| | | else if (template.contains("controller.java.vm")) |
| | | { |
| | | fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className); |
| | | } |
| | | else if (template.contains("mapper.xml.vm")) |
| | | { |
| | | fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className); |
| | | } |
| | | else if (template.contains("sql.vm")) |
| | | { |
| | | fileName = businessName + "Menu.sql"; |
| | | } |
| | | else if (template.contains("api.js.vm")) |
| | | { |
| | | fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName); |
| | | } |
| | | else if (template.contains("index.vue.vm")) |
| | | { |
| | | fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); |
| | | } |
| | | else if (template.contains("index-tree.vue.vm")) |
| | | { |
| | | fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); |
| | | } |
| | | return fileName; |
| | | } |
| | | |
| | | /** |
| | | * è·åå
åç¼ |
| | | * |
| | | * @param packageName å
åç§° |
| | | * @return å
åç¼åç§° |
| | | */ |
| | | public static String getPackagePrefix(String packageName) |
| | | { |
| | | int lastIndex = packageName.lastIndexOf("."); |
| | | String basePackage = StringUtils.substring(packageName, 0, lastIndex); |
| | | return basePackage; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®åç±»åè·å导å
¥å
|
| | | * |
| | | * @param column åéå |
| | | * @return è¿åéè¦å¯¼å
¥çå
å表 |
| | | */ |
| | | public static HashSet<String> getImportList(List<GenTableColumn> columns) |
| | | { |
| | | HashSet<String> importList = new HashSet<String>(); |
| | | for (GenTableColumn column : columns) |
| | | { |
| | | if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType())) |
| | | { |
| | | importList.add("java.util.Date"); |
| | | importList.add("com.fasterxml.jackson.annotation.JsonFormat"); |
| | | } |
| | | else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType())) |
| | | { |
| | | importList.add("java.math.BigDecimal"); |
| | | } |
| | | } |
| | | return importList; |
| | | } |
| | | |
| | | /** |
| | | * è·åæéåç¼ |
| | | * |
| | | * @param moduleName 模ååç§° |
| | | * @param businessName ä¸å¡åç§° |
| | | * @return è¿åæéåç¼ |
| | | */ |
| | | public static String getPermissionPrefix(String moduleName, String businessName) |
| | | { |
| | | return StringUtils.format("{}:{}", moduleName, businessName); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * è·åæ ç¼ç |
| | | * |
| | | * @param options çæå
¶ä»é项 |
| | | * @return æ ç¼ç |
| | | */ |
| | | public static String getTreecode(JSONObject paramsObj) |
| | | { |
| | | if (paramsObj.containsKey(GenConstants.TREE_CODE)) |
| | | { |
| | | return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE)); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * è·åæ ç¶ç¼ç |
| | | * |
| | | * @param options çæå
¶ä»é项 |
| | | * @return æ ç¶ç¼ç |
| | | */ |
| | | public static String getTreeParentCode(JSONObject paramsObj) |
| | | { |
| | | if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) |
| | | { |
| | | return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE)); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * è·åæ åç§° |
| | | * |
| | | * @param options çæå
¶ä»é项 |
| | | * @return æ åç§° |
| | | */ |
| | | public static String getTreeName(JSONObject paramsObj) |
| | | { |
| | | if (paramsObj.containsKey(GenConstants.TREE_NAME)) |
| | | { |
| | | return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME)); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * è·åéè¦å¨åªä¸åä¸é¢æ¾ç¤ºå±å¼æé® |
| | | * |
| | | * @param genTable ä¸å¡è¡¨å¯¹è±¡ |
| | | * @return å±å¼æé®ååºå· |
| | | */ |
| | | public static int getExpandColumn(GenTable genTable) |
| | | { |
| | | String options = genTable.getOptions(); |
| | | JSONObject paramsObj = JSONObject.parseObject(options); |
| | | String treeName = paramsObj.getString(GenConstants.TREE_NAME); |
| | | int num = 0; |
| | | for (GenTableColumn column : genTable.getColumns()) |
| | | { |
| | | if (column.isList()) |
| | | { |
| | | num++; |
| | | String columnName = column.getColumnName(); |
| | | if (columnName.equals(treeName)) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return num; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | # 代ç çæ
|
| | | gen: |
| | | # ä½è
|
| | | author: ruoyi
|
| | | # é»è®¤çæå
è·¯å¾ system éæ¹æèªå·±ç模ååç§° å¦ system monitor tool
|
| | | packageName: com.ruoyi.system
|
| | | # èªå¨å»é¤è¡¨åç¼ï¼é»è®¤æ¯false
|
| | | autoRemovePre: false
|
| | | # 表åç¼ï¼çæç±»åä¸ä¼å
å«è¡¨åç¼ï¼å¤ä¸ªç¨éå·åéï¼
|
| | | tablePrefix: sys_ |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.generator.mapper.GenTableColumnMapper"> |
| | | |
| | | <resultMap type="GenTableColumn" id="GenTableColumnResult"> |
| | | <id property="columnId" column="column_id" /> |
| | | <result property="tableId" column="table_id" /> |
| | | <result property="columnName" column="column_name" /> |
| | | <result property="columnComment" column="column_comment" /> |
| | | <result property="columnType" column="column_type" /> |
| | | <result property="javaType" column="java_type" /> |
| | | <result property="javaField" column="java_field" /> |
| | | <result property="isPk" column="is_pk" /> |
| | | <result property="isIncrement" column="is_increment" /> |
| | | <result property="isRequired" column="is_required" /> |
| | | <result property="isInsert" column="is_insert" /> |
| | | <result property="isEdit" column="is_edit" /> |
| | | <result property="isList" column="is_list" /> |
| | | <result property="isQuery" column="is_query" /> |
| | | <result property="queryType" column="query_type" /> |
| | | <result property="htmlType" column="html_type" /> |
| | | <result property="dictType" column="dict_type" /> |
| | | <result property="sort" column="sort" /> |
| | | <result property="createBy" column="create_by" /> |
| | | <result property="createTime" column="create_time" /> |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | </resultMap> |
| | | |
| | | <sql id="selectGenTableColumnVo"> |
| | | select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column |
| | | </sql> |
| | | |
| | | <select id="selectGenTableColumnListByTableId" parameterType="Long" resultMap="GenTableColumnResult"> |
| | | <include refid="selectGenTableColumnVo"/> |
| | | where table_id = #{tableId} |
| | | order by sort |
| | | </select> |
| | | |
| | | <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult"> |
| | | select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type |
| | | from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName}) |
| | | order by ordinal_position |
| | | </select> |
| | | |
| | | <insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId"> |
| | | insert into gen_table_column ( |
| | | <if test="tableId != null and tableId != ''">table_id,</if> |
| | | <if test="columnName != null and columnName != ''">column_name,</if> |
| | | <if test="columnComment != null and columnComment != ''">column_comment,</if> |
| | | <if test="columnType != null and columnType != ''">column_type,</if> |
| | | <if test="javaType != null and javaType != ''">java_type,</if> |
| | | <if test="javaField != null and javaField != ''">java_field,</if> |
| | | <if test="isPk != null and isPk != ''">is_pk,</if> |
| | | <if test="isIncrement != null and isIncrement != ''">is_increment,</if> |
| | | <if test="isRequired != null and isRequired != ''">is_required,</if> |
| | | <if test="isInsert != null and isInsert != ''">is_insert,</if> |
| | | <if test="isEdit != null and isEdit != ''">is_edit,</if> |
| | | <if test="isList != null and isList != ''">is_list,</if> |
| | | <if test="isQuery != null and isQuery != ''">is_query,</if> |
| | | <if test="queryType != null and queryType != ''">query_type,</if> |
| | | <if test="htmlType != null and htmlType != ''">html_type,</if> |
| | | <if test="dictType != null and dictType != ''">dict_type,</if> |
| | | <if test="sort != null">sort,</if> |
| | | <if test="createBy != null and createBy != ''">create_by,</if> |
| | | create_time |
| | | )values( |
| | | <if test="tableId != null and tableId != ''">#{tableId},</if> |
| | | <if test="columnName != null and columnName != ''">#{columnName},</if> |
| | | <if test="columnComment != null and columnComment != ''">#{columnComment},</if> |
| | | <if test="columnType != null and columnType != ''">#{columnType},</if> |
| | | <if test="javaType != null and javaType != ''">#{javaType},</if> |
| | | <if test="javaField != null and javaField != ''">#{javaField},</if> |
| | | <if test="isPk != null and isPk != ''">#{isPk},</if> |
| | | <if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if> |
| | | <if test="isRequired != null and isRequired != ''">#{isRequired},</if> |
| | | <if test="isInsert != null and isInsert != ''">#{isInsert},</if> |
| | | <if test="isEdit != null and isEdit != ''">#{isEdit},</if> |
| | | <if test="isList != null and isList != ''">#{isList},</if> |
| | | <if test="isQuery != null and isQuery != ''">#{isQuery},</if> |
| | | <if test="queryType != null and queryType != ''">#{queryType},</if> |
| | | <if test="htmlType != null and htmlType != ''">#{htmlType},</if> |
| | | <if test="dictType != null and dictType != ''">#{dictType},</if> |
| | | <if test="sort != null">#{sort},</if> |
| | | <if test="createBy != null and createBy != ''">#{createBy},</if> |
| | | sysdate() |
| | | ) |
| | | </insert> |
| | | |
| | | <update id="updateGenTableColumn" parameterType="GenTableColumn"> |
| | | update gen_table_column |
| | | <set> |
| | | column_comment = #{columnComment}, |
| | | java_type = #{javaType}, |
| | | java_field = #{javaField}, |
| | | is_insert = #{isInsert}, |
| | | is_edit = #{isEdit}, |
| | | is_list = #{isList}, |
| | | is_query = #{isQuery}, |
| | | is_required = #{isRequired}, |
| | | query_type = #{queryType}, |
| | | html_type = #{htmlType}, |
| | | dict_type = #{dictType}, |
| | | sort = #{sort}, |
| | | update_by = #{updateBy}, |
| | | update_time = sysdate() |
| | | </set> |
| | | where column_id = #{columnId} |
| | | </update> |
| | | |
| | | <delete id="deleteGenTableColumnByIds" parameterType="Long"> |
| | | delete from gen_table_column where table_id in |
| | | <foreach collection="array" item="tableId" open="(" separator="," close=")"> |
| | | #{tableId} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.generator.mapper.GenTableMapper"> |
| | | |
| | | <resultMap type="GenTable" id="GenTableResult"> |
| | | <id property="tableId" column="table_id" /> |
| | | <result property="tableName" column="table_name" /> |
| | | <result property="tableComment" column="table_comment" /> |
| | | <result property="className" column="class_name" /> |
| | | <result property="tplCategory" column="tpl_category" /> |
| | | <result property="packageName" column="package_name" /> |
| | | <result property="moduleName" column="module_name" /> |
| | | <result property="businessName" column="business_name" /> |
| | | <result property="functionName" column="function_name" /> |
| | | <result property="functionAuthor" column="function_author" /> |
| | | <result property="options" column="options" /> |
| | | <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" /> |
| | | <collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" /> |
| | | </resultMap> |
| | | |
| | | <resultMap type="GenTableColumn" id="GenTableColumnResult"> |
| | | <id property="columnId" column="column_id" /> |
| | | <result property="tableId" column="table_id" /> |
| | | <result property="columnName" column="column_name" /> |
| | | <result property="columnComment" column="column_comment" /> |
| | | <result property="columnType" column="column_type" /> |
| | | <result property="javaType" column="java_type" /> |
| | | <result property="javaField" column="java_field" /> |
| | | <result property="isPk" column="is_pk" /> |
| | | <result property="isIncrement" column="is_increment" /> |
| | | <result property="isRequired" column="is_required" /> |
| | | <result property="isInsert" column="is_insert" /> |
| | | <result property="isEdit" column="is_edit" /> |
| | | <result property="isList" column="is_list" /> |
| | | <result property="isQuery" column="is_query" /> |
| | | <result property="queryType" column="query_type" /> |
| | | <result property="htmlType" column="html_type" /> |
| | | <result property="dictType" column="dict_type" /> |
| | | <result property="sort" column="sort" /> |
| | | <result property="createBy" column="create_by" /> |
| | | <result property="createTime" column="create_time" /> |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | </resultMap> |
| | | |
| | | <sql id="selectGenTableVo"> |
| | | select table_id, table_name, table_comment, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, options, create_by, create_time, update_by, update_time, remark from gen_table |
| | | </sql> |
| | | |
| | | <select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult"> |
| | | <include refid="selectGenTableVo"/> |
| | | <where> |
| | | <if test="tableName != null and tableName != ''"> |
| | | AND lower(table_name) like lower(concat('%', #{tableName}, '%')) |
| | | </if> |
| | | <if test="tableComment != null and tableComment != ''"> |
| | | AND lower(table_comment) like lower(concat('%', #{tableComment}, '%')) |
| | | </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="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult"> |
| | | select table_name, table_comment, create_time, update_time from information_schema.tables |
| | | where table_schema = (select database()) |
| | | AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%' |
| | | AND table_name NOT IN (select table_name from gen_table) |
| | | <if test="tableName != null and tableName != ''"> |
| | | AND lower(table_name) like lower(concat('%', #{tableName}, '%')) |
| | | </if> |
| | | <if test="tableComment != null and tableComment != ''"> |
| | | AND lower(table_comment) like lower(concat('%', #{tableComment}, '%')) |
| | | </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> |
| | | </select> |
| | | |
| | | <select id="selectDbTableListByNames" resultMap="GenTableResult"> |
| | | select table_name, table_comment, create_time, update_time from information_schema.tables |
| | | where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database()) |
| | | and table_name in |
| | | <foreach collection="array" item="name" open="(" separator="," close=")"> |
| | | #{name} |
| | | </foreach> |
| | | </select> |
| | | |
| | | <select id="selectTableByName" parameterType="String" resultMap="GenTableResult"> |
| | | select table_name, table_comment, create_time, update_time from information_schema.tables |
| | | where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database()) |
| | | and table_name = #{tableName} |
| | | </select> |
| | | |
| | | <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult"> |
| | | SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark, |
| | | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort |
| | | FROM gen_table t |
| | | LEFT JOIN gen_table_column c ON t.table_id = c.table_id |
| | | where t.table_id = #{tableId} order by c.sort |
| | | </select> |
| | | |
| | | <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult"> |
| | | SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark, |
| | | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort |
| | | FROM gen_table t |
| | | LEFT JOIN gen_table_column c ON t.table_id = c.table_id |
| | | where t.table_name = #{tableName} order by c.sort |
| | | </select> |
| | | |
| | | <insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId"> |
| | | insert into gen_table ( |
| | | <if test="tableName != null">table_name,</if> |
| | | <if test="tableComment != null and tableComment != ''">table_comment,</if> |
| | | <if test="className != null and className != ''">class_name,</if> |
| | | <if test="tplCategory != null and tplCategory != ''">tpl_category,</if> |
| | | <if test="packageName != null and packageName != ''">package_name,</if> |
| | | <if test="moduleName != null and moduleName != ''">module_name,</if> |
| | | <if test="businessName != null and businessName != ''">business_name,</if> |
| | | <if test="functionName != null and functionName != ''">function_name,</if> |
| | | <if test="functionAuthor != null and functionAuthor != ''">function_author,</if> |
| | | <if test="remark != null and remark != ''">remark,</if> |
| | | <if test="createBy != null and createBy != ''">create_by,</if> |
| | | create_time |
| | | )values( |
| | | <if test="tableName != null">#{tableName},</if> |
| | | <if test="tableComment != null and tableComment != ''">#{tableComment},</if> |
| | | <if test="className != null and className != ''">#{className},</if> |
| | | <if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if> |
| | | <if test="packageName != null and packageName != ''">#{packageName},</if> |
| | | <if test="moduleName != null and moduleName != ''">#{moduleName},</if> |
| | | <if test="businessName != null and businessName != ''">#{businessName},</if> |
| | | <if test="functionName != null and functionName != ''">#{functionName},</if> |
| | | <if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if> |
| | | <if test="remark != null and remark != ''">#{remark},</if> |
| | | <if test="createBy != null and createBy != ''">#{createBy},</if> |
| | | sysdate() |
| | | ) |
| | | </insert> |
| | | |
| | | <update id="updateGenTable" parameterType="GenTable"> |
| | | update gen_table |
| | | <set> |
| | | <if test="tableName != null">table_name = #{tableName},</if> |
| | | <if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if> |
| | | <if test="className != null and className != ''">class_name = #{className},</if> |
| | | <if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if> |
| | | <if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if> |
| | | <if test="packageName != null and packageName != ''">package_name = #{packageName},</if> |
| | | <if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if> |
| | | <if test="businessName != null and businessName != ''">business_name = #{businessName},</if> |
| | | <if test="functionName != null and functionName != ''">function_name = #{functionName},</if> |
| | | <if test="options != null and options != ''">options = #{options},</if> |
| | | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
| | | <if test="remark != null">remark = #{remark},</if> |
| | | update_time = sysdate() |
| | | </set> |
| | | where table_id = #{tableId} |
| | | </update> |
| | | |
| | | <delete id="deleteGenTableByIds" parameterType="Long"> |
| | | delete from gen_table where table_id in |
| | | <foreach collection="array" item="tableId" open="(" separator="," close=")"> |
| | | #{tableId} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package ${packageName}.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Arrays; |
| | | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.AllArgsConstructor; |
| | | 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.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | 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.enums.BusinessType; |
| | | import ${packageName}.domain.${ClassName}; |
| | | import ${packageName}.service.I${ClassName}Service; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | #if($table.crud) |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | #elseif($table.tree) |
| | | #end |
| | | |
| | | /** |
| | | * ${functionName}Controller |
| | | * |
| | | * @author ${author} |
| | | * @date ${datetime} |
| | | */ |
| | | @AllArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/${moduleName}/${businessName}" ) |
| | | public class ${ClassName}Controller extends BaseController { |
| | | |
| | | private final I${ClassName}Service i${ClassName}Service; |
| | | |
| | | /** |
| | | * æ¥è¯¢${functionName}å表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") |
| | | @GetMapping("/list") |
| | | #if($table.crud) |
| | | public TableDataInfo list(${ClassName} ${className}) |
| | | { |
| | | startPage(); |
| | | LambdaQueryWrapper<${ClassName}> lqw = new LambdaQueryWrapper<${ClassName}>(); |
| | | #foreach($column in $columns) |
| | | #set($queryType=$column.queryType) |
| | | #set($javaField=$column.javaField) |
| | | #set($javaType=$column.javaType) |
| | | #set($columnName=$column.columnName) |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | #if($column.query) |
| | | #if($column.queryType == "EQ") |
| | | #if($javaType == 'String') |
| | | if (StringUtils.isNotBlank(${className}.get$AttrName())){ |
| | | lqw.eq(${ClassName}::get$AttrName ,${className}.get$AttrName()); |
| | | } |
| | | #else |
| | | if (${className}.get$AttrName() != null){ |
| | | lqw.eq(${ClassName}::get$AttrName ,${className}.get$AttrName()); |
| | | } |
| | | #end |
| | | #elseif($queryType == "NE") |
| | | #if($javaType == 'String') |
| | | if (StringUtils.isNotBlank(${className}.get$AttrName())){ |
| | | lqw.ne(${ClassName}::get$AttrName ,${className}.get$AttrName()); |
| | | } |
| | | #else |
| | | if (${className}.get$AttrName() != null){ |
| | | lqw.ne(${ClassName}::get$AttrName ,${className}.get$AttrName()); |
| | | } |
| | | #end |
| | | #elseif($queryType == "GT") |
| | | #if($javaType == 'String') |
| | | if (StringUtils.isNotBlank(${className}.get$AttrName())){ |
| | | lqw.gt(${ClassName}::get$AttrName ,${className}.get$AttrName()); |
| | | } |
| | | #else |
| | | if (${className}.get$AttrName() != null){ |
| | | lqw.gt(${ClassName}::get$AttrName ,${className}.get$AttrName()); |
| | | } |
| | | #end |
| | | #elseif($queryType == "GTE") |
| | | #if($javaType == 'String') |
| | | if (StringUtils.isNotBlank(${className}.get$AttrName())){ |
| | | lqw.ge(${ClassName}::get$AttrName ,${className}.get$AttrName()); |
| | | } |
| | | #else |
| | | if (${className}.get$AttrName() != null){ |
| | | lqw.ge(${ClassName}::get$AttrName ,${className}.get$AttrName()); |
| | | } |
| | | #end |
| | | #elseif($queryType == "LT") |
| | | #if($javaType == 'String') |
| | | if (StringUtils.isNotBlank(${className}.get$AttrName())){ |
| | | lqw.lt(${ClassName}::get$AttrName ,${className}.get$AttrName()); |
| | | } |
| | | #else |
| | | if (${className}.get$AttrName() != null){ |
| | | lqw.lt(${ClassName}::get$AttrName ,${className}.get$AttrName()); |
| | | } |
| | | #end |
| | | #elseif($queryType == "LTE") |
| | | #if($javaType == 'String') |
| | | if (StringUtils.isNotBlank(${className}.get$AttrName())){ |
| | | lqw.le(${ClassName}::get$AttrName ,${className}.get$AttrName()); |
| | | } |
| | | #else |
| | | if (${className}.get$AttrName() != null){ |
| | | lqw.le(${ClassName}::get$AttrName ,${className}.get$AttrName()); |
| | | } |
| | | #end |
| | | #elseif($queryType == "LIKE") |
| | | #if($javaType == 'String') |
| | | if (StringUtils.isNotBlank(${className}.get$AttrName())){ |
| | | lqw.like(${ClassName}::get$AttrName ,${className}.get$AttrName()); |
| | | } |
| | | #else |
| | | if (${className}.get$AttrName() != null){ |
| | | lqw.like(${ClassName}::get$AttrName ,${className}.get$AttrName()); |
| | | } |
| | | #end |
| | | #elseif($queryType == "BETWEEN") |
| | | #end |
| | | #end |
| | | #end |
| | | List<${ClassName}> list = i${ClassName}Service.list(lqw); |
| | | return getDataTable(list); |
| | | } |
| | | #elseif($table.tree) |
| | | public AjaxResult list(${ClassName} ${className}) { |
| | | List<${ClassName}> list = i${ClassName}Service.list(lqw); |
| | | return AjaxResult.success(list); |
| | | } |
| | | #end |
| | | |
| | | /** |
| | | * 导åº${functionName}å表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')" ) |
| | | @Log(title = "${functionName}" , businessType = BusinessType.EXPORT) |
| | | @GetMapping("/export" ) |
| | | public AjaxResult export(${ClassName} ${className}) { |
| | | LambdaQueryWrapper<${ClassName}> lqw = new LambdaQueryWrapper<${ClassName}>(${className}); |
| | | List<${ClassName}> list = i${ClassName}Service.list(lqw); |
| | | ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}. class); |
| | | return util.exportExcel(list, "${businessName}" ); |
| | | } |
| | | |
| | | /** |
| | | * è·å${functionName}详ç»ä¿¡æ¯ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')" ) |
| | | @GetMapping(value = "/{${pkColumn.javaField}}" ) |
| | | public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}" ) ${pkColumn.javaType} ${pkColumn.javaField}) { |
| | | return AjaxResult.success(i${ClassName}Service.getById(${pkColumn.javaField})); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢${functionName} |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')" ) |
| | | @Log(title = "${functionName}" , businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ${ClassName} ${className}) { |
| | | return toAjax(i${ClassName}Service.save(${className}) ? 1 : 0); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹${functionName} |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')" ) |
| | | @Log(title = "${functionName}" , businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ${ClassName} ${className}) { |
| | | return toAjax(i${ClassName}Service.updateById(${className}) ? 1 : 0); |
| | | } |
| | | |
| | | /** |
| | | * å é¤${functionName} |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')" ) |
| | | @Log(title = "${functionName}" , businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{${pkColumn.javaField}s}" ) |
| | | public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) { |
| | | return toAjax(i${ClassName}Service.removeByIds(Arrays.asList(${pkColumn.javaField}s)) ? 1 : 0); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package ${packageName}.domain; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.ToString; |
| | | import lombok.experimental.Accessors; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.math.BigDecimal; |
| | | #if($table.crud) |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | #elseif($table.tree) |
| | | import com.ruoyi.common.core.domain.TreeEntity; |
| | | #end |
| | | |
| | | /** |
| | | * ${functionName}对象 ${tableName} |
| | | * |
| | | * @author ${author} |
| | | * @date ${datetime} |
| | | */ |
| | | #if($table.crud) |
| | | #set($Entity="BaseEntity") |
| | | #elseif($table.tree) |
| | | #set($Entity="TreeEntity") |
| | | #end |
| | | @Data |
| | | @ToString |
| | | @EqualsAndHashCode |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | @TableName("${tableName}") |
| | | public class ${ClassName} implements Serializable { |
| | | |
| | | private static final long serialVersionUID=1L; |
| | | |
| | | #foreach ($column in $columns) |
| | | |
| | | /** $column.columnComment */ |
| | | #if($column.list) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("ï¼")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | #if($parentheseIndex != -1) |
| | | @Excel(name = "${comment}" , readConverterExp = "$column.readConverterExp()") |
| | | #elseif($column.javaType == 'Date') |
| | | @Excel(name = "${comment}" , width = 30, dateFormat = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | #else |
| | | @Excel(name = "${comment}") |
| | | #end |
| | | #end |
| | | #if($column.isPk==1) |
| | | @TableId(value = "$column.columnName", type = IdType.AUTO) |
| | | private $column.javaType $column.javaField; |
| | | #else |
| | | private $column.javaType $column.javaField; |
| | | #end |
| | | #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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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;
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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();
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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();
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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();
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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();
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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();
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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);
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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();
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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);
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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();
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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);
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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("æ§è¡æ åæ¹æ³");
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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;
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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());
|
| | | }
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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;
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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);
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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);
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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);
|
| | | }
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.common.annotation.Excel; |
| | | import com.ruoyi.common.annotation.Excel.ColumnType; |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | |
| | | /** |
| | | * åæ°é
置表 sys_config |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysConfig extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** åæ°ä¸»é® */ |
| | | @Excel(name = "忰䏻é®", cellType = ColumnType.NUMERIC) |
| | | private Long configId; |
| | | |
| | | /** åæ°åç§° */ |
| | | @Excel(name = "åæ°åç§°") |
| | | private String configName; |
| | | |
| | | /** åæ°é®å */ |
| | | @Excel(name = "åæ°é®å") |
| | | private String configKey; |
| | | |
| | | /** åæ°é®å¼ */ |
| | | @Excel(name = "åæ°é®å¼") |
| | | private String configValue; |
| | | |
| | | /** ç³»ç»å
ç½®ï¼Yæ¯ Nå¦ï¼ */ |
| | | @Excel(name = "ç³»ç»å
ç½®", readConverterExp = "Y=æ¯,N=å¦") |
| | | private String configType; |
| | | |
| | | public Long getConfigId() |
| | | { |
| | | return configId; |
| | | } |
| | | |
| | | public void setConfigId(Long configId) |
| | | { |
| | | this.configId = configId; |
| | | } |
| | | |
| | | @NotBlank(message = "åæ°åç§°ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 100, message = "åæ°åç§°ä¸è½è¶
è¿100个å符") |
| | | public String getConfigName() |
| | | { |
| | | return configName; |
| | | } |
| | | |
| | | public void setConfigName(String configName) |
| | | { |
| | | this.configName = configName; |
| | | } |
| | | |
| | | @NotBlank(message = "åæ°é®åé¿åº¦ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 100, message = "åæ°é®åé¿åº¦ä¸è½è¶
è¿100个å符") |
| | | public String getConfigKey() |
| | | { |
| | | return configKey; |
| | | } |
| | | |
| | | public void setConfigKey(String configKey) |
| | | { |
| | | this.configKey = configKey; |
| | | } |
| | | |
| | | @NotBlank(message = "åæ°é®å¼ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 500, message = "åæ°é®å¼é¿åº¦ä¸è½è¶
è¿500个å符") |
| | | public String getConfigValue() |
| | | { |
| | | return configValue; |
| | | } |
| | | |
| | | public void setConfigValue(String configValue) |
| | | { |
| | | this.configValue = configValue; |
| | | } |
| | | |
| | | public String getConfigType() |
| | | { |
| | | return configType; |
| | | } |
| | | |
| | | public void setConfigType(String configType) |
| | | { |
| | | this.configType = configType; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | | .append("configId", getConfigId()) |
| | | .append("configName", getConfigName()) |
| | | .append("configKey", getConfigKey()) |
| | | .append("configValue", getConfigValue()) |
| | | .append("configType", getConfigType()) |
| | | .append("createBy", getCreateBy()) |
| | | .append("createTime", getCreateTime()) |
| | | .append("updateBy", getUpdateBy()) |
| | | .append("updateTime", getUpdateTime()) |
| | | .append("remark", getRemark()) |
| | | .toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.domain; |
| | | |
| | | import java.util.Date; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.ruoyi.common.annotation.Excel.ColumnType; |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | |
| | | /** |
| | | * ç³»ç»è®¿é®è®°å½è¡¨ sys_logininfor |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysLogininfor extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** ID */ |
| | | @Excel(name = "åºå·", cellType = ColumnType.NUMERIC) |
| | | private Long infoId; |
| | | |
| | | /** ç¨æ·è´¦å· */ |
| | | @Excel(name = "ç¨æ·è´¦å·") |
| | | private String userName; |
| | | |
| | | /** ç»å½ç¶æ 0æå 1失败 */ |
| | | @Excel(name = "ç»å½ç¶æ", readConverterExp = "0=æå,1=失败") |
| | | private String status; |
| | | |
| | | /** ç»å½IPå°å */ |
| | | @Excel(name = "ç»å½å°å") |
| | | private String ipaddr; |
| | | |
| | | /** ç»å½å°ç¹ */ |
| | | @Excel(name = "ç»å½å°ç¹") |
| | | private String loginLocation; |
| | | |
| | | /** æµè§å¨ç±»å */ |
| | | @Excel(name = "æµè§å¨") |
| | | private String browser; |
| | | |
| | | /** æä½ç³»ç» */ |
| | | @Excel(name = "æä½ç³»ç»") |
| | | private String os; |
| | | |
| | | /** æç¤ºæ¶æ¯ */ |
| | | @Excel(name = "æç¤ºæ¶æ¯") |
| | | private String msg; |
| | | |
| | | /** è®¿é®æ¶é´ */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Excel(name = "è®¿é®æ¶é´", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | private Date loginTime; |
| | | |
| | | public Long getInfoId() |
| | | { |
| | | return infoId; |
| | | } |
| | | |
| | | public void setInfoId(Long infoId) |
| | | { |
| | | this.infoId = infoId; |
| | | } |
| | | |
| | | public String getUserName() |
| | | { |
| | | return userName; |
| | | } |
| | | |
| | | public void setUserName(String userName) |
| | | { |
| | | this.userName = userName; |
| | | } |
| | | |
| | | public String getStatus() |
| | | { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(String status) |
| | | { |
| | | this.status = status; |
| | | } |
| | | |
| | | public String getIpaddr() |
| | | { |
| | | return ipaddr; |
| | | } |
| | | |
| | | public void setIpaddr(String ipaddr) |
| | | { |
| | | this.ipaddr = ipaddr; |
| | | } |
| | | |
| | | public String getLoginLocation() |
| | | { |
| | | return loginLocation; |
| | | } |
| | | |
| | | public void setLoginLocation(String loginLocation) |
| | | { |
| | | this.loginLocation = loginLocation; |
| | | } |
| | | |
| | | public String getBrowser() |
| | | { |
| | | return browser; |
| | | } |
| | | |
| | | public void setBrowser(String browser) |
| | | { |
| | | this.browser = browser; |
| | | } |
| | | |
| | | public String getOs() |
| | | { |
| | | return os; |
| | | } |
| | | |
| | | public void setOs(String os) |
| | | { |
| | | this.os = os; |
| | | } |
| | | |
| | | public String getMsg() |
| | | { |
| | | return msg; |
| | | } |
| | | |
| | | public void setMsg(String msg) |
| | | { |
| | | this.msg = msg; |
| | | } |
| | | |
| | | public Date getLoginTime() |
| | | { |
| | | return loginTime; |
| | | } |
| | | |
| | | public void setLoginTime(Date loginTime) |
| | | { |
| | | this.loginTime = loginTime; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.common.core.domain.BaseEntity; |
| | | |
| | | /** |
| | | * éç¥å
¬å表 sys_notice |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysNotice extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** å
ŒID */ |
| | | private Long noticeId; |
| | | |
| | | /** å
¬åæ é¢ */ |
| | | private String noticeTitle; |
| | | |
| | | /** å
¬åç±»åï¼1éç¥ 2å
¬åï¼ */ |
| | | private String noticeType; |
| | | |
| | | /** å
¬åå
容 */ |
| | | private String noticeContent; |
| | | |
| | | /** å
¬åç¶æï¼0æ£å¸¸ 1å
³éï¼ */ |
| | | private String status; |
| | | |
| | | public Long getNoticeId() |
| | | { |
| | | return noticeId; |
| | | } |
| | | |
| | | public void setNoticeId(Long noticeId) |
| | | { |
| | | this.noticeId = noticeId; |
| | | } |
| | | |
| | | public void setNoticeTitle(String noticeTitle) |
| | | { |
| | | this.noticeTitle = noticeTitle; |
| | | } |
| | | |
| | | @NotBlank(message = "å
¬åæ é¢ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 50, message = "å
¬åæ é¢ä¸è½è¶
è¿50个å符") |
| | | public String getNoticeTitle() |
| | | { |
| | | return noticeTitle; |
| | | } |
| | | |
| | | public void setNoticeType(String noticeType) |
| | | { |
| | | this.noticeType = noticeType; |
| | | } |
| | | |
| | | public String getNoticeType() |
| | | { |
| | | return noticeType; |
| | | } |
| | | |
| | | public void setNoticeContent(String noticeContent) |
| | | { |
| | | this.noticeContent = noticeContent; |
| | | } |
| | | |
| | | public String getNoticeContent() |
| | | { |
| | | return noticeContent; |
| | | } |
| | | |
| | | public void setStatus(String status) |
| | | { |
| | | this.status = status; |
| | | } |
| | | |
| | | public String getStatus() |
| | | { |
| | | return status; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | | .append("noticeId", getNoticeId()) |
| | | .append("noticeTitle", getNoticeTitle()) |
| | | .append("noticeType", getNoticeType()) |
| | | .append("noticeContent", getNoticeContent()) |
| | | .append("status", getStatus()) |
| | | .append("createBy", getCreateBy()) |
| | | .append("createTime", getCreateTime()) |
| | | .append("updateBy", getUpdateBy()) |
| | | .append("updateTime", getUpdateTime()) |
| | | .append("remark", getRemark()) |
| | | .toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.domain; |
| | | |
| | | import java.util.Date; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.ruoyi.common.annotation.Excel.ColumnType; |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | |
| | | /** |
| | | * æä½æ¥å¿è®°å½è¡¨ oper_log |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysOperLog extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** æ¥å¿ä¸»é® */ |
| | | @Excel(name = "æä½åºå·", cellType = ColumnType.NUMERIC) |
| | | private Long operId; |
| | | |
| | | /** æä½æ¨¡å */ |
| | | @Excel(name = "æä½æ¨¡å") |
| | | private String title; |
| | | |
| | | /** ä¸å¡ç±»åï¼0å
¶å® 1æ°å¢ 2ä¿®æ¹ 3å é¤ï¼ */ |
| | | @Excel(name = "ä¸å¡ç±»å", readConverterExp = "0=å
¶å®,1=æ°å¢,2=ä¿®æ¹,3=å é¤,4=ææ,5=导åº,6=导å
¥,7=强é,8=çæä»£ç ,9=æ¸
ç©ºæ°æ®") |
| | | private Integer businessType; |
| | | |
| | | /** ä¸å¡ç±»åæ°ç» */ |
| | | private Integer[] businessTypes; |
| | | |
| | | /** è¯·æ±æ¹æ³ */ |
| | | @Excel(name = "è¯·æ±æ¹æ³") |
| | | private String method; |
| | | |
| | | /** è¯·æ±æ¹å¼ */ |
| | | @Excel(name = "è¯·æ±æ¹å¼") |
| | | private String requestMethod; |
| | | |
| | | /** æä½ç±»å«ï¼0å
¶å® 1åå°ç¨æ· 2ææºç«¯ç¨æ·ï¼ */ |
| | | @Excel(name = "æä½ç±»å«", readConverterExp = "0=å
¶å®,1=åå°ç¨æ·,2=ææºç«¯ç¨æ·") |
| | | private Integer operatorType; |
| | | |
| | | /** æä½äººå */ |
| | | @Excel(name = "æä½äººå") |
| | | private String operName; |
| | | |
| | | /** é¨é¨åç§° */ |
| | | @Excel(name = "é¨é¨åç§°") |
| | | private String deptName; |
| | | |
| | | /** 请æ±url */ |
| | | @Excel(name = "请æ±å°å") |
| | | private String operUrl; |
| | | |
| | | /** æä½å°å */ |
| | | @Excel(name = "æä½å°å") |
| | | private String operIp; |
| | | |
| | | /** æä½å°ç¹ */ |
| | | @Excel(name = "æä½å°ç¹") |
| | | private String operLocation; |
| | | |
| | | /** 请æ±åæ° */ |
| | | @Excel(name = "请æ±åæ°") |
| | | private String operParam; |
| | | |
| | | /** è¿ååæ° */ |
| | | @Excel(name = "è¿ååæ°") |
| | | private String jsonResult; |
| | | |
| | | /** æä½ç¶æï¼0æ£å¸¸ 1å¼å¸¸ï¼ */ |
| | | @Excel(name = "ç¶æ", readConverterExp = "0=æ£å¸¸,1=å¼å¸¸") |
| | | private Integer status; |
| | | |
| | | /** éè¯¯æ¶æ¯ */ |
| | | @Excel(name = "éè¯¯æ¶æ¯") |
| | | private String errorMsg; |
| | | |
| | | /** æä½æ¶é´ */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Excel(name = "æä½æ¶é´", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | private Date operTime; |
| | | |
| | | public Long getOperId() |
| | | { |
| | | return operId; |
| | | } |
| | | |
| | | public void setOperId(Long operId) |
| | | { |
| | | this.operId = operId; |
| | | } |
| | | |
| | | public String getTitle() |
| | | { |
| | | return title; |
| | | } |
| | | |
| | | public void setTitle(String title) |
| | | { |
| | | this.title = title; |
| | | } |
| | | |
| | | public Integer getBusinessType() |
| | | { |
| | | return businessType; |
| | | } |
| | | |
| | | public void setBusinessType(Integer businessType) |
| | | { |
| | | this.businessType = businessType; |
| | | } |
| | | |
| | | public Integer[] getBusinessTypes() |
| | | { |
| | | return businessTypes; |
| | | } |
| | | |
| | | public void setBusinessTypes(Integer[] businessTypes) |
| | | { |
| | | this.businessTypes = businessTypes; |
| | | } |
| | | |
| | | public String getMethod() |
| | | { |
| | | return method; |
| | | } |
| | | |
| | | public void setMethod(String method) |
| | | { |
| | | this.method = method; |
| | | } |
| | | |
| | | public String getRequestMethod() |
| | | { |
| | | return requestMethod; |
| | | } |
| | | |
| | | public void setRequestMethod(String requestMethod) |
| | | { |
| | | this.requestMethod = requestMethod; |
| | | } |
| | | |
| | | public Integer getOperatorType() |
| | | { |
| | | return operatorType; |
| | | } |
| | | |
| | | public void setOperatorType(Integer operatorType) |
| | | { |
| | | this.operatorType = operatorType; |
| | | } |
| | | |
| | | public String getOperName() |
| | | { |
| | | return operName; |
| | | } |
| | | |
| | | public void setOperName(String operName) |
| | | { |
| | | this.operName = operName; |
| | | } |
| | | |
| | | public String getDeptName() |
| | | { |
| | | return deptName; |
| | | } |
| | | |
| | | public void setDeptName(String deptName) |
| | | { |
| | | this.deptName = deptName; |
| | | } |
| | | |
| | | public String getOperUrl() |
| | | { |
| | | return operUrl; |
| | | } |
| | | |
| | | public void setOperUrl(String operUrl) |
| | | { |
| | | this.operUrl = operUrl; |
| | | } |
| | | |
| | | public String getOperIp() |
| | | { |
| | | return operIp; |
| | | } |
| | | |
| | | public void setOperIp(String operIp) |
| | | { |
| | | this.operIp = operIp; |
| | | } |
| | | |
| | | public String getOperLocation() |
| | | { |
| | | return operLocation; |
| | | } |
| | | |
| | | public void setOperLocation(String operLocation) |
| | | { |
| | | this.operLocation = operLocation; |
| | | } |
| | | |
| | | public String getOperParam() |
| | | { |
| | | return operParam; |
| | | } |
| | | |
| | | public void setOperParam(String operParam) |
| | | { |
| | | this.operParam = operParam; |
| | | } |
| | | |
| | | public String getJsonResult() |
| | | { |
| | | return jsonResult; |
| | | } |
| | | |
| | | public void setJsonResult(String jsonResult) |
| | | { |
| | | this.jsonResult = jsonResult; |
| | | } |
| | | |
| | | public Integer getStatus() |
| | | { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(Integer status) |
| | | { |
| | | this.status = status; |
| | | } |
| | | |
| | | public String getErrorMsg() |
| | | { |
| | | return errorMsg; |
| | | } |
| | | |
| | | public void setErrorMsg(String errorMsg) |
| | | { |
| | | this.errorMsg = errorMsg; |
| | | } |
| | | |
| | | public Date getOperTime() |
| | | { |
| | | return operTime; |
| | | } |
| | | |
| | | public void setOperTime(Date operTime) |
| | | { |
| | | this.operTime = operTime; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.common.annotation.Excel; |
| | | import com.ruoyi.common.annotation.Excel.ColumnType; |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | |
| | | /** |
| | | * å²ä½è¡¨ sys_post |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysPost extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** å²ä½åºå· */ |
| | | @Excel(name = "å²ä½åºå·", cellType = ColumnType.NUMERIC) |
| | | private Long postId; |
| | | |
| | | /** å²ä½ç¼ç */ |
| | | @Excel(name = "å²ä½ç¼ç ") |
| | | private String postCode; |
| | | |
| | | /** å²ä½åç§° */ |
| | | @Excel(name = "å²ä½åç§°") |
| | | private String postName; |
| | | |
| | | /** å²ä½æåº */ |
| | | @Excel(name = "å²ä½æåº") |
| | | private String postSort; |
| | | |
| | | /** ç¶æï¼0æ£å¸¸ 1åç¨ï¼ */ |
| | | @Excel(name = "ç¶æ", readConverterExp = "0=æ£å¸¸,1=åç¨") |
| | | private String status; |
| | | |
| | | /** ç¨æ·æ¯å¦å卿¤å²ä½æ è¯ é»è®¤ä¸åå¨ */ |
| | | private boolean flag = false; |
| | | |
| | | public Long getPostId() |
| | | { |
| | | return postId; |
| | | } |
| | | |
| | | public void setPostId(Long postId) |
| | | { |
| | | this.postId = postId; |
| | | } |
| | | |
| | | @NotBlank(message = "å²ä½ç¼ç ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 64, message = "å²ä½ç¼ç é¿åº¦ä¸è½è¶
è¿64个å符") |
| | | public String getPostCode() |
| | | { |
| | | return postCode; |
| | | } |
| | | |
| | | public void setPostCode(String postCode) |
| | | { |
| | | this.postCode = postCode; |
| | | } |
| | | |
| | | @NotBlank(message = "å²ä½åç§°ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 50, message = "å²ä½åç§°é¿åº¦ä¸è½è¶
è¿50个å符") |
| | | public String getPostName() |
| | | { |
| | | return postName; |
| | | } |
| | | |
| | | public void setPostName(String postName) |
| | | { |
| | | this.postName = postName; |
| | | } |
| | | |
| | | @NotBlank(message = "æ¾ç¤ºé¡ºåºä¸è½ä¸ºç©º") |
| | | public String getPostSort() |
| | | { |
| | | return postSort; |
| | | } |
| | | |
| | | public void setPostSort(String postSort) |
| | | { |
| | | this.postSort = postSort; |
| | | } |
| | | |
| | | public String getStatus() |
| | | { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(String status) |
| | | { |
| | | this.status = status; |
| | | } |
| | | |
| | | public boolean isFlag() |
| | | { |
| | | return flag; |
| | | } |
| | | |
| | | public void setFlag(boolean flag) |
| | | { |
| | | this.flag = flag; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | | .append("postId", getPostId()) |
| | | .append("postCode", getPostCode()) |
| | | .append("postName", getPostName()) |
| | | .append("postSort", getPostSort()) |
| | | .append("status", getStatus()) |
| | | .append("createBy", getCreateBy()) |
| | | .append("createTime", getCreateTime()) |
| | | .append("updateBy", getUpdateBy()) |
| | | .append("updateTime", getUpdateTime()) |
| | | .append("remark", getRemark()) |
| | | .toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.domain; |
| | | |
| | | import org.apache.commons.lang3.builder.ToStringBuilder; |
| | | import org.apache.commons.lang3.builder.ToStringStyle; |
| | | |
| | | /** |
| | | * è§è²åé¨é¨å
³è sys_role_dept |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysRoleDept |
| | | { |
| | | /** è§è²ID */ |
| | | private Long roleId; |
| | | |
| | | /** é¨é¨ID */ |
| | | private Long deptId; |
| | | |
| | | public Long getRoleId() |
| | | { |
| | | return roleId; |
| | | } |
| | | |
| | | public void setRoleId(Long roleId) |
| | | { |
| | | this.roleId = roleId; |
| | | } |
| | | |
| | | public Long getDeptId() |
| | | { |
| | | return deptId; |
| | | } |
| | | |
| | | public void setDeptId(Long deptId) |
| | | { |
| | | this.deptId = deptId; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | | .append("roleId", getRoleId()) |
| | | .append("deptId", getDeptId()) |
| | | .toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.domain; |
| | | |
| | | import org.apache.commons.lang3.builder.ToStringBuilder; |
| | | import org.apache.commons.lang3.builder.ToStringStyle; |
| | | |
| | | /** |
| | | * è§è²åèåå
³è sys_role_menu |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysRoleMenu |
| | | { |
| | | /** è§è²ID */ |
| | | private Long roleId; |
| | | |
| | | /** èåID */ |
| | | private Long menuId; |
| | | |
| | | public Long getRoleId() |
| | | { |
| | | return roleId; |
| | | } |
| | | |
| | | public void setRoleId(Long roleId) |
| | | { |
| | | this.roleId = roleId; |
| | | } |
| | | |
| | | public Long getMenuId() |
| | | { |
| | | return menuId; |
| | | } |
| | | |
| | | public void setMenuId(Long menuId) |
| | | { |
| | | this.menuId = menuId; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | | .append("roleId", getRoleId()) |
| | | .append("menuId", getMenuId()) |
| | | .toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.domain; |
| | | |
| | | /** |
| | | * å½åå¨çº¿ä¼è¯ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysUserOnline |
| | | { |
| | | /** ä¼è¯ç¼å· */ |
| | | private String tokenId; |
| | | |
| | | /** é¨é¨åç§° */ |
| | | private String deptName; |
| | | |
| | | /** ç¨æ·åç§° */ |
| | | private String userName; |
| | | |
| | | /** ç»å½IPå°å */ |
| | | private String ipaddr; |
| | | |
| | | /** ç»å½å°å */ |
| | | private String loginLocation; |
| | | |
| | | /** æµè§å¨ç±»å */ |
| | | private String browser; |
| | | |
| | | /** æä½ç³»ç» */ |
| | | private String os; |
| | | |
| | | /** ç»å½æ¶é´ */ |
| | | private Long loginTime; |
| | | |
| | | public String getTokenId() |
| | | { |
| | | return tokenId; |
| | | } |
| | | |
| | | public void setTokenId(String tokenId) |
| | | { |
| | | this.tokenId = tokenId; |
| | | } |
| | | |
| | | public String getDeptName() |
| | | { |
| | | return deptName; |
| | | } |
| | | |
| | | public void setDeptName(String deptName) |
| | | { |
| | | this.deptName = deptName; |
| | | } |
| | | |
| | | public String getUserName() |
| | | { |
| | | return userName; |
| | | } |
| | | |
| | | public void setUserName(String userName) |
| | | { |
| | | this.userName = userName; |
| | | } |
| | | |
| | | public String getIpaddr() |
| | | { |
| | | return ipaddr; |
| | | } |
| | | |
| | | public void setIpaddr(String ipaddr) |
| | | { |
| | | this.ipaddr = ipaddr; |
| | | } |
| | | |
| | | public String getLoginLocation() |
| | | { |
| | | return loginLocation; |
| | | } |
| | | |
| | | public void setLoginLocation(String loginLocation) |
| | | { |
| | | this.loginLocation = loginLocation; |
| | | } |
| | | |
| | | public String getBrowser() |
| | | { |
| | | return browser; |
| | | } |
| | | |
| | | public void setBrowser(String browser) |
| | | { |
| | | this.browser = browser; |
| | | } |
| | | |
| | | public String getOs() |
| | | { |
| | | return os; |
| | | } |
| | | |
| | | public void setOs(String os) |
| | | { |
| | | this.os = os; |
| | | } |
| | | |
| | | public Long getLoginTime() |
| | | { |
| | | return loginTime; |
| | | } |
| | | |
| | | public void setLoginTime(Long loginTime) |
| | | { |
| | | this.loginTime = loginTime; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.domain; |
| | | |
| | | import org.apache.commons.lang3.builder.ToStringBuilder; |
| | | import org.apache.commons.lang3.builder.ToStringStyle; |
| | | |
| | | /** |
| | | * ç¨æ·åå²ä½å
³è sys_user_post |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysUserPost |
| | | { |
| | | /** ç¨æ·ID */ |
| | | private Long userId; |
| | | |
| | | /** å²ä½ID */ |
| | | private Long postId; |
| | | |
| | | public Long getUserId() |
| | | { |
| | | return userId; |
| | | } |
| | | |
| | | public void setUserId(Long userId) |
| | | { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public Long getPostId() |
| | | { |
| | | return postId; |
| | | } |
| | | |
| | | public void setPostId(Long postId) |
| | | { |
| | | this.postId = postId; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | | .append("userId", getUserId()) |
| | | .append("postId", getPostId()) |
| | | .toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.domain; |
| | | |
| | | import org.apache.commons.lang3.builder.ToStringBuilder; |
| | | import org.apache.commons.lang3.builder.ToStringStyle; |
| | | |
| | | /** |
| | | * ç¨æ·åè§è²å
³è sys_user_role |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SysUserRole |
| | | { |
| | | /** ç¨æ·ID */ |
| | | private Long userId; |
| | | |
| | | /** è§è²ID */ |
| | | private Long roleId; |
| | | |
| | | public Long getUserId() |
| | | { |
| | | return userId; |
| | | } |
| | | |
| | | public void setUserId(Long userId) |
| | | { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public Long getRoleId() |
| | | { |
| | | return roleId; |
| | | } |
| | | |
| | | public void setRoleId(Long roleId) |
| | | { |
| | | this.roleId = roleId; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | | .append("userId", getUserId()) |
| | | .append("roleId", getRoleId()) |
| | | .toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.domain.vo; |
| | | |
| | | /** |
| | | * è·¯ç±æ¾ç¤ºä¿¡æ¯ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class MetaVo |
| | | { |
| | | /** |
| | | * 设置该路ç±å¨ä¾§è¾¹æ åé¢å
å±ä¸å±ç¤ºçåå |
| | | */ |
| | | private String title; |
| | | |
| | | /** |
| | | * 设置该路ç±ç徿 ï¼å¯¹åºè·¯å¾src/icons/svg |
| | | */ |
| | | private String icon; |
| | | |
| | | public MetaVo() |
| | | { |
| | | } |
| | | |
| | | public MetaVo(String title, String icon) |
| | | { |
| | | this.title = title; |
| | | this.icon = icon; |
| | | } |
| | | |
| | | public String getTitle() |
| | | { |
| | | return title; |
| | | } |
| | | |
| | | public void setTitle(String title) |
| | | { |
| | | this.title = title; |
| | | } |
| | | |
| | | public String getIcon() |
| | | { |
| | | return icon; |
| | | } |
| | | |
| | | public void setIcon(String icon) |
| | | { |
| | | this.icon = icon; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.domain.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * è·¯ç±é
ç½®ä¿¡æ¯ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | public class RouterVo |
| | | { |
| | | /** |
| | | * è·¯ç±åå |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * è·¯ç±å°å |
| | | */ |
| | | private String path; |
| | | |
| | | /** |
| | | * æ¯å¦éèè·¯ç±ï¼å½è®¾ç½® true çæ¶å该路ç±ä¸ä¼åä¾§è¾¹æ åºç° |
| | | */ |
| | | private boolean hidden; |
| | | |
| | | /** |
| | | * éå®åå°åï¼å½è®¾ç½® noRedirect çæ¶å该路ç±å¨é¢å
å±å¯¼èªä¸ä¸å¯è¢«ç¹å» |
| | | */ |
| | | private String redirect; |
| | | |
| | | /** |
| | | * ç»ä»¶å°å |
| | | */ |
| | | private String component; |
| | | |
| | | /** |
| | | * å½ä½ ä¸ä¸ªè·¯ç±ä¸é¢ç children 声æçè·¯ç±å¤§äº1个æ¶ï¼èªå¨ä¼åæåµå¥ç模å¼--å¦ç»ä»¶é¡µé¢ |
| | | */ |
| | | private Boolean alwaysShow; |
| | | |
| | | /** |
| | | * å
¶ä»å
ç´ |
| | | */ |
| | | private MetaVo meta; |
| | | |
| | | /** |
| | | * åè·¯ç± |
| | | */ |
| | | private List<RouterVo> children; |
| | | |
| | | public String getName() |
| | | { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) |
| | | { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getPath() |
| | | { |
| | | return path; |
| | | } |
| | | |
| | | public void setPath(String path) |
| | | { |
| | | this.path = path; |
| | | } |
| | | |
| | | public boolean getHidden() |
| | | { |
| | | return hidden; |
| | | } |
| | | |
| | | public void setHidden(boolean hidden) |
| | | { |
| | | this.hidden = hidden; |
| | | } |
| | | |
| | | public String getRedirect() |
| | | { |
| | | return redirect; |
| | | } |
| | | |
| | | public void setRedirect(String redirect) |
| | | { |
| | | this.redirect = redirect; |
| | | } |
| | | |
| | | public String getComponent() |
| | | { |
| | | return component; |
| | | } |
| | | |
| | | public void setComponent(String component) |
| | | { |
| | | this.component = component; |
| | | } |
| | | |
| | | public Boolean getAlwaysShow() |
| | | { |
| | | return alwaysShow; |
| | | } |
| | | |
| | | public void setAlwaysShow(Boolean alwaysShow) |
| | | { |
| | | this.alwaysShow = alwaysShow; |
| | | } |
| | | |
| | | public MetaVo getMeta() |
| | | { |
| | | return meta; |
| | | } |
| | | |
| | | public void setMeta(MetaVo meta) |
| | | { |
| | | this.meta = meta; |
| | | } |
| | | |
| | | public List<RouterVo> getChildren() |
| | | { |
| | | return children; |
| | | } |
| | | |
| | | public void setChildren(List<RouterVo> children) |
| | | { |
| | | this.children = children; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | |
| | | /** |
| | | * åæ°é
ç½® æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysConfigMapper |
| | | { |
| | | /** |
| | | * æ¥è¯¢åæ°é
ç½®ä¿¡æ¯ |
| | | * |
| | | * @param config åæ°é
ç½®ä¿¡æ¯ |
| | | * @return åæ°é
ç½®ä¿¡æ¯ |
| | | */ |
| | | public SysConfig selectConfig(SysConfig config); |
| | | |
| | | /** |
| | | * æ¥è¯¢åæ°é
ç½®å表 |
| | | * |
| | | * @param config åæ°é
ç½®ä¿¡æ¯ |
| | | * @return åæ°é
ç½®éå |
| | | */ |
| | | public List<SysConfig> selectConfigList(SysConfig config); |
| | | |
| | | /** |
| | | * æ ¹æ®é®åæ¥è¯¢åæ°é
ç½®ä¿¡æ¯ |
| | | * |
| | | * @param configKey åæ°é®å |
| | | * @return åæ°é
ç½®ä¿¡æ¯ |
| | | */ |
| | | public SysConfig checkConfigKeyUnique(String configKey); |
| | | |
| | | /** |
| | | * æ°å¢åæ°é
ç½® |
| | | * |
| | | * @param config åæ°é
ç½®ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertConfig(SysConfig config); |
| | | |
| | | /** |
| | | * ä¿®æ¹åæ°é
ç½® |
| | | * |
| | | * @param config åæ°é
ç½®ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateConfig(SysConfig config); |
| | | |
| | | /** |
| | | * å é¤åæ°é
ç½® |
| | | * |
| | | * @param configId åæ°ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteConfigById(Long configId); |
| | | |
| | | /** |
| | | * æ¹éå é¤åæ°ä¿¡æ¯ |
| | | * |
| | | * @param configIds éè¦å é¤çåæ°ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteConfigByIds(Long[] configIds); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | |
| | | /** |
| | | * é¨é¨ç®¡ç æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysDeptMapper |
| | | { |
| | | /** |
| | | * æ¥è¯¢é¨é¨ç®¡çæ°æ® |
| | | * |
| | | * @param dept é¨é¨ä¿¡æ¯ |
| | | * @return é¨é¨ä¿¡æ¯éå |
| | | */ |
| | | public List<SysDept> selectDeptList(SysDept dept); |
| | | |
| | | /** |
| | | * æ ¹æ®è§è²IDæ¥è¯¢é¨é¨æ ä¿¡æ¯ |
| | | * |
| | | * @param roleId è§è²ID |
| | | * @return éä¸é¨é¨å表 |
| | | */ |
| | | public List<Integer> selectDeptListByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * æ ¹æ®é¨é¨IDæ¥è¯¢ä¿¡æ¯ |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return é¨é¨ä¿¡æ¯ |
| | | */ |
| | | public SysDept selectDeptById(Long deptId); |
| | | |
| | | /** |
| | | * æ ¹æ®IDæ¥è¯¢ææåé¨é¨ |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return é¨é¨å表 |
| | | */ |
| | | public List<SysDept> selectChildrenDeptById(Long deptId); |
| | | |
| | | /** |
| | | * æ ¹æ®IDæ¥è¯¢ææåé¨é¨ï¼æ£å¸¸ç¶æï¼ |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return åé¨é¨æ° |
| | | */ |
| | | public int selectNormalChildrenDeptById(Long deptId); |
| | | |
| | | /** |
| | | * æ¯å¦åå¨åèç¹ |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return ç»æ |
| | | */ |
| | | public int hasChildByDeptId(Long deptId); |
| | | |
| | | /** |
| | | * æ¥è¯¢é¨é¨æ¯å¦åå¨ç¨æ· |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return ç»æ |
| | | */ |
| | | public int checkDeptExistUser(Long deptId); |
| | | |
| | | /** |
| | | * æ ¡éªé¨é¨åç§°æ¯å¦å¯ä¸ |
| | | * |
| | | * @param deptName é¨é¨åç§° |
| | | * @param parentId ç¶é¨é¨ID |
| | | * @return ç»æ |
| | | */ |
| | | public SysDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId); |
| | | |
| | | /** |
| | | * æ°å¢é¨é¨ä¿¡æ¯ |
| | | * |
| | | * @param dept é¨é¨ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertDept(SysDept dept); |
| | | |
| | | /** |
| | | * ä¿®æ¹é¨é¨ä¿¡æ¯ |
| | | * |
| | | * @param dept é¨é¨ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateDept(SysDept dept); |
| | | |
| | | /** |
| | | * ä¿®æ¹æå¨é¨é¨çç¶çº§é¨é¨ç¶æ |
| | | * |
| | | * @param dept é¨é¨ |
| | | */ |
| | | public void updateDeptStatus(SysDept dept); |
| | | |
| | | /** |
| | | * ä¿®æ¹åå
ç´ å
³ç³» |
| | | * |
| | | * @param depts åå
ç´ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateDeptChildren(@Param("depts") List<SysDept> depts); |
| | | |
| | | /** |
| | | * å é¤é¨é¨ç®¡çä¿¡æ¯ |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteDeptById(Long deptId); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | |
| | | /** |
| | | * åå
¸è¡¨ æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysDictDataMapper |
| | | { |
| | | /** |
| | | * æ ¹æ®æ¡ä»¶å页æ¥è¯¢åå
¸æ°æ® |
| | | * |
| | | * @param dictData åå
¸æ°æ®ä¿¡æ¯ |
| | | * @return åå
¸æ°æ®éåä¿¡æ¯ |
| | | */ |
| | | public List<SysDictData> selectDictDataList(SysDictData dictData); |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸ç±»åæ¥è¯¢åå
¸æ°æ® |
| | | * |
| | | * @param dictType åå
¸ç±»å |
| | | * @return åå
¸æ°æ®éåä¿¡æ¯ |
| | | */ |
| | | public List<SysDictData> selectDictDataByType(String dictType); |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸ç±»åååå
¸é®å¼æ¥è¯¢åå
¸æ°æ®ä¿¡æ¯ |
| | | * |
| | | * @param dictType åå
¸ç±»å |
| | | * @param dictValue åå
¸é®å¼ |
| | | * @return åå
¸æ ç¾ |
| | | */ |
| | | public String selectDictLabel(@Param("dictType") String dictType, @Param("dictValue") String dictValue); |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸æ°æ®IDæ¥è¯¢ä¿¡æ¯ |
| | | * |
| | | * @param dictCode åå
¸æ°æ®ID |
| | | * @return åå
¸æ°æ® |
| | | */ |
| | | public SysDictData selectDictDataById(Long dictCode); |
| | | |
| | | /** |
| | | * æ¥è¯¢åå
¸æ°æ® |
| | | * |
| | | * @param dictType åå
¸ç±»å |
| | | * @return åå
¸æ°æ® |
| | | */ |
| | | public int countDictDataByType(String dictType); |
| | | |
| | | /** |
| | | * éè¿åå
¸IDå é¤åå
¸æ°æ®ä¿¡æ¯ |
| | | * |
| | | * @param dictCode åå
¸æ°æ®ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteDictDataById(Long dictCode); |
| | | |
| | | /** |
| | | * æ¹éå é¤åå
¸æ°æ®ä¿¡æ¯ |
| | | * |
| | | * @param dictCodes éè¦å é¤çåå
¸æ°æ®ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteDictDataByIds(Long[] dictCodes); |
| | | |
| | | /** |
| | | * æ°å¢åå
¸æ°æ®ä¿¡æ¯ |
| | | * |
| | | * @param dictData åå
¸æ°æ®ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertDictData(SysDictData dictData); |
| | | |
| | | /** |
| | | * ä¿®æ¹åå
¸æ°æ®ä¿¡æ¯ |
| | | * |
| | | * @param dictData åå
¸æ°æ®ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateDictData(SysDictData dictData); |
| | | |
| | | /** |
| | | * åæ¥ä¿®æ¹åå
¸ç±»å |
| | | * |
| | | * @param oldDictType æ§åå
¸ç±»å |
| | | * @param newDictType æ°æ§åå
¸ç±»å |
| | | * @return ç»æ |
| | | */ |
| | | public int updateDictDataType(@Param("oldDictType") String oldDictType, @Param("newDictType") String newDictType); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import com.ruoyi.common.core.domain.entity.SysDictType; |
| | | |
| | | /** |
| | | * åå
¸è¡¨ æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Mapper |
| | | public interface SysDictTypeMapper |
| | | { |
| | | /** |
| | | * æ ¹æ®æ¡ä»¶å页æ¥è¯¢åå
¸ç±»å |
| | | * |
| | | * @param dictType åå
¸ç±»åä¿¡æ¯ |
| | | * @return åå
¸ç±»åéåä¿¡æ¯ |
| | | */ |
| | | public List<SysDictType> selectDictTypeList(SysDictType dictType); |
| | | |
| | | /** |
| | | * æ ¹æ®ææåå
¸ç±»å |
| | | * |
| | | * @return åå
¸ç±»åéåä¿¡æ¯ |
| | | */ |
| | | public List<SysDictType> selectDictTypeAll(); |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸ç±»åIDæ¥è¯¢ä¿¡æ¯ |
| | | * |
| | | * @param dictId åå
¸ç±»åID |
| | | * @return åå
¸ç±»å |
| | | */ |
| | | public SysDictType selectDictTypeById(Long dictId); |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸ç±»åæ¥è¯¢ä¿¡æ¯ |
| | | * |
| | | * @param dictType åå
¸ç±»å |
| | | * @return åå
¸ç±»å |
| | | */ |
| | | public SysDictType selectDictTypeByType(String dictType); |
| | | |
| | | /** |
| | | * éè¿åå
¸IDå é¤åå
¸ä¿¡æ¯ |
| | | * |
| | | * @param dictId åå
¸ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteDictTypeById(Long dictId); |
| | | |
| | | /** |
| | | * æ¹éå é¤åå
¸ç±»åä¿¡æ¯ |
| | | * |
| | | * @param dictIds éè¦å é¤çåå
¸ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteDictTypeByIds(Long[] dictIds); |
| | | |
| | | /** |
| | | * æ°å¢åå
¸ç±»åä¿¡æ¯ |
| | | * |
| | | * @param dictType åå
¸ç±»åä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertDictType(SysDictType dictType); |
| | | |
| | | /** |
| | | * ä¿®æ¹åå
¸ç±»åä¿¡æ¯ |
| | | * |
| | | * @param dictType åå
¸ç±»åä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateDictType(SysDictType dictType); |
| | | |
| | | /** |
| | | * æ ¡éªåå
¸ç±»åç§°æ¯å¦å¯ä¸ |
| | | * |
| | | * @param dictType åå
¸ç±»å |
| | | * @return ç»æ |
| | | */ |
| | | public SysDictType checkDictTypeUnique(String dictType); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.domain.SysLogininfor; |
| | | |
| | | /** |
| | | * ç³»ç»è®¿é®æ¥å¿æ
åµä¿¡æ¯ æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysLogininforMapper |
| | | { |
| | | /** |
| | | * æ°å¢ç³»ç»ç»å½æ¥å¿ |
| | | * |
| | | * @param logininfor è®¿é®æ¥å¿å¯¹è±¡ |
| | | */ |
| | | public void insertLogininfor(SysLogininfor logininfor); |
| | | |
| | | /** |
| | | * æ¥è¯¢ç³»ç»ç»å½æ¥å¿éå |
| | | * |
| | | * @param logininfor è®¿é®æ¥å¿å¯¹è±¡ |
| | | * @return ç»å½è®°å½éå |
| | | */ |
| | | public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor); |
| | | |
| | | /** |
| | | * æ¹éå é¤ç³»ç»ç»å½æ¥å¿ |
| | | * |
| | | * @param infoIds éè¦å é¤çç»å½æ¥å¿ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteLogininforByIds(Long[] infoIds); |
| | | |
| | | /** |
| | | * æ¸
空系ç»ç»å½æ¥å¿ |
| | | * |
| | | * @return ç»æ |
| | | */ |
| | | public int cleanLogininfor(); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | |
| | | /** |
| | | * èå表 æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysMenuMapper |
| | | { |
| | | /** |
| | | * æ¥è¯¢ç³»ç»èåå表 |
| | | * |
| | | * @param menu èåä¿¡æ¯ |
| | | * @return èåå表 |
| | | */ |
| | | public List<SysMenu> selectMenuList(SysMenu menu); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·æææé |
| | | * |
| | | * @return æéå表 |
| | | */ |
| | | public List<String> selectMenuPerms(); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·æ¥è¯¢ç³»ç»èåå表 |
| | | * |
| | | * @param menu èåä¿¡æ¯ |
| | | * @return èåå表 |
| | | */ |
| | | public List<SysMenu> selectMenuListByUserId(SysMenu menu); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·IDæ¥è¯¢æé |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return æéå表 |
| | | */ |
| | | public List<String> selectMenuPermsByUserId(Long userId); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·IDæ¥è¯¢èå |
| | | * |
| | | * @return èåå表 |
| | | */ |
| | | public List<SysMenu> selectMenuTreeAll(); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·IDæ¥è¯¢èå |
| | | * |
| | | * @param username ç¨æ·ID |
| | | * @return èåå表 |
| | | */ |
| | | public List<SysMenu> selectMenuTreeByUserId(Long userId); |
| | | |
| | | /** |
| | | * æ ¹æ®è§è²IDæ¥è¯¢èåæ ä¿¡æ¯ |
| | | * |
| | | * @param roleId è§è²ID |
| | | * @return éä¸èåå表 |
| | | */ |
| | | public List<Integer> selectMenuListByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * æ ¹æ®èåIDæ¥è¯¢ä¿¡æ¯ |
| | | * |
| | | * @param menuId èåID |
| | | * @return èåä¿¡æ¯ |
| | | */ |
| | | public SysMenu selectMenuById(Long menuId); |
| | | |
| | | /** |
| | | * æ¯å¦åå¨èååèç¹ |
| | | * |
| | | * @param menuId èåID |
| | | * @return ç»æ |
| | | */ |
| | | public int hasChildByMenuId(Long menuId); |
| | | |
| | | /** |
| | | * æ°å¢èåä¿¡æ¯ |
| | | * |
| | | * @param menu èåä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertMenu(SysMenu menu); |
| | | |
| | | /** |
| | | * ä¿®æ¹èåä¿¡æ¯ |
| | | * |
| | | * @param menu èåä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateMenu(SysMenu menu); |
| | | |
| | | /** |
| | | * å é¤èå管çä¿¡æ¯ |
| | | * |
| | | * @param menuId èåID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteMenuById(Long menuId); |
| | | |
| | | /** |
| | | * æ ¡éªèååç§°æ¯å¦å¯ä¸ |
| | | * |
| | | * @param menuName èååç§° |
| | | * @param parentId ç¶èåID |
| | | * @return ç»æ |
| | | */ |
| | | public SysMenu checkMenuNameUnique(@Param("menuName") String menuName, @Param("parentId") Long parentId); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.domain.SysNotice; |
| | | |
| | | /** |
| | | * éç¥å
¬å表 æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysNoticeMapper |
| | | { |
| | | /** |
| | | * æ¥è¯¢å
¬åä¿¡æ¯ |
| | | * |
| | | * @param noticeId å
ŒID |
| | | * @return å
¬åä¿¡æ¯ |
| | | */ |
| | | public SysNotice selectNoticeById(Long noticeId); |
| | | |
| | | /** |
| | | * æ¥è¯¢å
¬åå表 |
| | | * |
| | | * @param notice å
¬åä¿¡æ¯ |
| | | * @return å
¬åéå |
| | | */ |
| | | public List<SysNotice> selectNoticeList(SysNotice notice); |
| | | |
| | | /** |
| | | * æ°å¢å
Œ |
| | | * |
| | | * @param notice å
¬åä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertNotice(SysNotice notice); |
| | | |
| | | /** |
| | | * ä¿®æ¹å
Œ |
| | | * |
| | | * @param notice å
¬åä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateNotice(SysNotice notice); |
| | | |
| | | /** |
| | | * æ¹éå é¤å
Œ |
| | | * |
| | | * @param noticeId å
ŒID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteNoticeById(Long noticeId); |
| | | |
| | | /** |
| | | * æ¹éå é¤å
¬åä¿¡æ¯ |
| | | * |
| | | * @param noticeIds éè¦å é¤çå
ŒID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteNoticeByIds(Long[] noticeIds); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.domain.SysOperLog; |
| | | |
| | | /** |
| | | * æä½æ¥å¿ æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysOperLogMapper |
| | | { |
| | | /** |
| | | * æ°å¢æä½æ¥å¿ |
| | | * |
| | | * @param operLog æä½æ¥å¿å¯¹è±¡ |
| | | */ |
| | | public void insertOperlog(SysOperLog operLog); |
| | | |
| | | /** |
| | | * æ¥è¯¢ç³»ç»æä½æ¥å¿éå |
| | | * |
| | | * @param operLog æä½æ¥å¿å¯¹è±¡ |
| | | * @return æä½æ¥å¿éå |
| | | */ |
| | | public List<SysOperLog> selectOperLogList(SysOperLog operLog); |
| | | |
| | | /** |
| | | * æ¹éå é¤ç³»ç»æä½æ¥å¿ |
| | | * |
| | | * @param operIds éè¦å é¤çæä½æ¥å¿ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteOperLogByIds(Long[] operIds); |
| | | |
| | | /** |
| | | * æ¥è¯¢æä½æ¥å¿è¯¦ç» |
| | | * |
| | | * @param operId æä½ID |
| | | * @return æä½æ¥å¿å¯¹è±¡ |
| | | */ |
| | | public SysOperLog selectOperLogById(Long operId); |
| | | |
| | | /** |
| | | * æ¸
空æä½æ¥å¿ |
| | | */ |
| | | public void cleanOperLog(); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.domain.SysPost; |
| | | |
| | | /** |
| | | * å²ä½ä¿¡æ¯ æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysPostMapper |
| | | { |
| | | /** |
| | | * æ¥è¯¢å²ä½æ°æ®éå |
| | | * |
| | | * @param post å²ä½ä¿¡æ¯ |
| | | * @return å²ä½æ°æ®éå |
| | | */ |
| | | public List<SysPost> selectPostList(SysPost post); |
| | | |
| | | /** |
| | | * æ¥è¯¢ææå²ä½ |
| | | * |
| | | * @return å²ä½å表 |
| | | */ |
| | | public List<SysPost> selectPostAll(); |
| | | |
| | | /** |
| | | * éè¿å²ä½IDæ¥è¯¢å²ä½ä¿¡æ¯ |
| | | * |
| | | * @param postId å²ä½ID |
| | | * @return è§è²å¯¹è±¡ä¿¡æ¯ |
| | | */ |
| | | public SysPost selectPostById(Long postId); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·IDè·åå²ä½éæ©æ¡å表 |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return éä¸å²ä½IDå表 |
| | | */ |
| | | public List<Integer> selectPostListByUserId(Long userId); |
| | | |
| | | /** |
| | | * æ¥è¯¢ç¨æ·æå±å²ä½ç» |
| | | * |
| | | * @param userName ç¨æ·å |
| | | * @return ç»æ |
| | | */ |
| | | public List<SysPost> selectPostsByUserName(String userName); |
| | | |
| | | /** |
| | | * å é¤å²ä½ä¿¡æ¯ |
| | | * |
| | | * @param postId å²ä½ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deletePostById(Long postId); |
| | | |
| | | /** |
| | | * æ¹éå é¤å²ä½ä¿¡æ¯ |
| | | * |
| | | * @param postIds éè¦å é¤çå²ä½ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deletePostByIds(Long[] postIds); |
| | | |
| | | /** |
| | | * ä¿®æ¹å²ä½ä¿¡æ¯ |
| | | * |
| | | * @param post å²ä½ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updatePost(SysPost post); |
| | | |
| | | /** |
| | | * æ°å¢å²ä½ä¿¡æ¯ |
| | | * |
| | | * @param post å²ä½ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertPost(SysPost post); |
| | | |
| | | /** |
| | | * æ ¡éªå²ä½åç§° |
| | | * |
| | | * @param postName å²ä½åç§° |
| | | * @return ç»æ |
| | | */ |
| | | public SysPost checkPostNameUnique(String postName); |
| | | |
| | | /** |
| | | * æ ¡éªå²ä½ç¼ç |
| | | * |
| | | * @param postCode å²ä½ç¼ç |
| | | * @return ç»æ |
| | | */ |
| | | public SysPost checkPostCodeUnique(String postCode); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.domain.SysRoleDept; |
| | | |
| | | /** |
| | | * è§è²ä¸é¨é¨å
³è表 æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysRoleDeptMapper |
| | | { |
| | | /** |
| | | * éè¿è§è²IDå é¤è§è²åé¨é¨å
³è |
| | | * |
| | | * @param roleId è§è²ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteRoleDeptByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * æ¹éå é¤è§è²é¨é¨å
³èä¿¡æ¯ |
| | | * |
| | | * @param ids éè¦å é¤çæ°æ®ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteRoleDept(Long[] ids); |
| | | |
| | | /** |
| | | * æ¥è¯¢é¨é¨ä½¿ç¨æ°é |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return ç»æ |
| | | */ |
| | | public int selectCountRoleDeptByDeptId(Long deptId); |
| | | |
| | | /** |
| | | * æ¹éæ°å¢è§è²é¨é¨ä¿¡æ¯ |
| | | * |
| | | * @param roleDeptList è§è²é¨é¨å表 |
| | | * @return ç»æ |
| | | */ |
| | | public int batchRoleDept(List<SysRoleDept> roleDeptList); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | |
| | | /** |
| | | * è§è²è¡¨ æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysRoleMapper |
| | | { |
| | | /** |
| | | * æ ¹æ®æ¡ä»¶å页æ¥è¯¢è§è²æ°æ® |
| | | * |
| | | * @param role è§è²ä¿¡æ¯ |
| | | * @return è§è²æ°æ®éåä¿¡æ¯ |
| | | */ |
| | | public List<SysRole> selectRoleList(SysRole role); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·IDæ¥è¯¢è§è² |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return è§è²å表 |
| | | */ |
| | | public List<SysRole> selectRolePermissionByUserId(Long userId); |
| | | |
| | | /** |
| | | * æ¥è¯¢ææè§è² |
| | | * |
| | | * @return è§è²å表 |
| | | */ |
| | | public List<SysRole> selectRoleAll(); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·IDè·åè§è²éæ©æ¡å表 |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return éä¸è§è²IDå表 |
| | | */ |
| | | public List<Integer> selectRoleListByUserId(Long userId); |
| | | |
| | | /** |
| | | * éè¿è§è²IDæ¥è¯¢è§è² |
| | | * |
| | | * @param roleId è§è²ID |
| | | * @return è§è²å¯¹è±¡ä¿¡æ¯ |
| | | */ |
| | | public SysRole selectRoleById(Long roleId); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·IDæ¥è¯¢è§è² |
| | | * |
| | | * @param userName ç¨æ·å |
| | | * @return è§è²å表 |
| | | */ |
| | | public List<SysRole> selectRolesByUserName(String userName); |
| | | |
| | | /** |
| | | * æ ¡éªè§è²åç§°æ¯å¦å¯ä¸ |
| | | * |
| | | * @param roleName è§è²åç§° |
| | | * @return è§è²ä¿¡æ¯ |
| | | */ |
| | | public SysRole checkRoleNameUnique(String roleName); |
| | | |
| | | /** |
| | | * æ ¡éªè§è²æéæ¯å¦å¯ä¸ |
| | | * |
| | | * @param roleKey è§è²æé |
| | | * @return è§è²ä¿¡æ¯ |
| | | */ |
| | | public SysRole checkRoleKeyUnique(String roleKey); |
| | | |
| | | /** |
| | | * ä¿®æ¹è§è²ä¿¡æ¯ |
| | | * |
| | | * @param role è§è²ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateRole(SysRole role); |
| | | |
| | | /** |
| | | * æ°å¢è§è²ä¿¡æ¯ |
| | | * |
| | | * @param role è§è²ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertRole(SysRole role); |
| | | |
| | | /** |
| | | * éè¿è§è²IDå é¤è§è² |
| | | * |
| | | * @param roleId è§è²ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteRoleById(Long roleId); |
| | | |
| | | /** |
| | | * æ¹éå é¤è§è²ä¿¡æ¯ |
| | | * |
| | | * @param roleIds éè¦å é¤çè§è²ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteRoleByIds(Long[] roleIds); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.domain.SysRoleMenu; |
| | | |
| | | /** |
| | | * è§è²ä¸èåå
³è表 æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysRoleMenuMapper |
| | | { |
| | | /** |
| | | * æ¥è¯¢èåä½¿ç¨æ°é |
| | | * |
| | | * @param menuId èåID |
| | | * @return ç»æ |
| | | */ |
| | | public int checkMenuExistRole(Long menuId); |
| | | |
| | | /** |
| | | * éè¿è§è²IDå é¤è§è²åèåå
³è |
| | | * |
| | | * @param roleId è§è²ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteRoleMenuByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * æ¹éæ°å¢è§è²èåä¿¡æ¯ |
| | | * |
| | | * @param roleMenuList è§è²èåå表 |
| | | * @return ç»æ |
| | | */ |
| | | public int batchRoleMenu(List<SysRoleMenu> roleMenuList); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | |
| | | /** |
| | | * ç¨æ·è¡¨ æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysUserMapper |
| | | { |
| | | /** |
| | | * æ ¹æ®æ¡ä»¶å页æ¥è¯¢ç¨æ·å表 |
| | | * |
| | | * @param sysUser ç¨æ·ä¿¡æ¯ |
| | | * @return ç¨æ·ä¿¡æ¯éåä¿¡æ¯ |
| | | */ |
| | | public List<SysUser> selectUserList(SysUser sysUser); |
| | | |
| | | /** |
| | | * éè¿ç¨æ·åæ¥è¯¢ç¨æ· |
| | | * |
| | | * @param userName ç¨æ·å |
| | | * @return ç¨æ·å¯¹è±¡ä¿¡æ¯ |
| | | */ |
| | | public SysUser selectUserByUserName(String userName); |
| | | |
| | | /** |
| | | * éè¿ç¨æ·IDæ¥è¯¢ç¨æ· |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return ç¨æ·å¯¹è±¡ä¿¡æ¯ |
| | | */ |
| | | public SysUser selectUserById(Long userId); |
| | | |
| | | /** |
| | | * æ°å¢ç¨æ·ä¿¡æ¯ |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertUser(SysUser user); |
| | | |
| | | /** |
| | | * ä¿®æ¹ç¨æ·ä¿¡æ¯ |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateUser(SysUser user); |
| | | |
| | | /** |
| | | * ä¿®æ¹ç¨æ·å¤´å |
| | | * |
| | | * @param userName ç¨æ·å |
| | | * @param avatar 头åå°å |
| | | * @return ç»æ |
| | | */ |
| | | public int updateUserAvatar(@Param("userName") String userName, @Param("avatar") String avatar); |
| | | |
| | | /** |
| | | * éç½®ç¨æ·å¯ç |
| | | * |
| | | * @param userName ç¨æ·å |
| | | * @param password å¯ç |
| | | * @return ç»æ |
| | | */ |
| | | public int resetUserPwd(@Param("userName") String userName, @Param("password") String password); |
| | | |
| | | /** |
| | | * éè¿ç¨æ·IDå é¤ç¨æ· |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteUserById(Long userId); |
| | | |
| | | /** |
| | | * æ¹éå é¤ç¨æ·ä¿¡æ¯ |
| | | * |
| | | * @param userIds éè¦å é¤çç¨æ·ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteUserByIds(Long[] userIds); |
| | | |
| | | /** |
| | | * æ ¡éªç¨æ·åç§°æ¯å¦å¯ä¸ |
| | | * |
| | | * @param userName ç¨æ·åç§° |
| | | * @return ç»æ |
| | | */ |
| | | public int checkUserNameUnique(String userName); |
| | | |
| | | /** |
| | | * æ ¡éªææºå·ç æ¯å¦å¯ä¸ |
| | | * |
| | | * @param phonenumber ææºå·ç |
| | | * @return ç»æ |
| | | */ |
| | | public SysUser checkPhoneUnique(String phonenumber); |
| | | |
| | | /** |
| | | * æ ¡éªemailæ¯å¦å¯ä¸ |
| | | * |
| | | * @param email ç¨æ·é®ç®± |
| | | * @return ç»æ |
| | | */ |
| | | public SysUser checkEmailUnique(String email); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.domain.SysUserPost; |
| | | |
| | | /** |
| | | * ç¨æ·ä¸å²ä½å
³è表 æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysUserPostMapper |
| | | { |
| | | /** |
| | | * éè¿ç¨æ·IDå é¤ç¨æ·åå²ä½å
³è |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteUserPostByUserId(Long userId); |
| | | |
| | | /** |
| | | * éè¿å²ä½IDæ¥è¯¢å²ä½ä½¿ç¨æ°é |
| | | * |
| | | * @param postId å²ä½ID |
| | | * @return ç»æ |
| | | */ |
| | | public int countUserPostById(Long postId); |
| | | |
| | | /** |
| | | * æ¹éå é¤ç¨æ·åå²ä½å
³è |
| | | * |
| | | * @param ids éè¦å é¤çæ°æ®ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteUserPost(Long[] ids); |
| | | |
| | | /** |
| | | * æ¹éæ°å¢ç¨æ·å²ä½ä¿¡æ¯ |
| | | * |
| | | * @param userPostList ç¨æ·è§è²å表 |
| | | * @return ç»æ |
| | | */ |
| | | public int batchUserPost(List<SysUserPost> userPostList); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | |
| | | /** |
| | | * ç¨æ·ä¸è§è²å
³è表 æ°æ®å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysUserRoleMapper |
| | | { |
| | | /** |
| | | * éè¿ç¨æ·IDå é¤ç¨æ·åè§è²å
³è |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteUserRoleByUserId(Long userId); |
| | | |
| | | /** |
| | | * æ¹éå é¤ç¨æ·åè§è²å
³è |
| | | * |
| | | * @param ids éè¦å é¤çæ°æ®ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteUserRole(Long[] ids); |
| | | |
| | | /** |
| | | * éè¿è§è²IDæ¥è¯¢è§è²ä½¿ç¨æ°é |
| | | * |
| | | * @param roleId è§è²ID |
| | | * @return ç»æ |
| | | */ |
| | | public int countUserRoleByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * æ¹éæ°å¢ç¨æ·è§è²ä¿¡æ¯ |
| | | * |
| | | * @param userRoleList ç¨æ·è§è²å表 |
| | | * @return ç»æ |
| | | */ |
| | | public int batchUserRole(List<SysUserRole> userRoleList); |
| | | |
| | | /** |
| | | * å é¤ç¨æ·åè§è²å
³èä¿¡æ¯ |
| | | * |
| | | * @param userRole ç¨æ·åè§è²å
³èä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteUserRoleInfo(SysUserRole userRole); |
| | | |
| | | /** |
| | | * æ¹éåæ¶ææç¨æ·è§è² |
| | | * |
| | | * @param roleId è§è²ID |
| | | * @param userIds éè¦å é¤çç¨æ·æ°æ®ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteUserRoleInfos(@Param("roleId") Long roleId, @Param("userIds") Long[] userIds); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | |
| | | /** |
| | | * åæ°é
ç½® æå¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysConfigService |
| | | { |
| | | /** |
| | | * æ¥è¯¢åæ°é
ç½®ä¿¡æ¯ |
| | | * |
| | | * @param configId åæ°é
ç½®ID |
| | | * @return åæ°é
ç½®ä¿¡æ¯ |
| | | */ |
| | | public SysConfig selectConfigById(Long configId); |
| | | |
| | | /** |
| | | * æ ¹æ®é®åæ¥è¯¢åæ°é
ç½®ä¿¡æ¯ |
| | | * |
| | | * @param configKey åæ°é®å |
| | | * @return åæ°é®å¼ |
| | | */ |
| | | public String selectConfigByKey(String configKey); |
| | | |
| | | /** |
| | | * æ¥è¯¢åæ°é
ç½®å表 |
| | | * |
| | | * @param config åæ°é
ç½®ä¿¡æ¯ |
| | | * @return åæ°é
ç½®éå |
| | | */ |
| | | public List<SysConfig> selectConfigList(SysConfig config); |
| | | |
| | | /** |
| | | * æ°å¢åæ°é
ç½® |
| | | * |
| | | * @param config åæ°é
ç½®ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertConfig(SysConfig config); |
| | | |
| | | /** |
| | | * ä¿®æ¹åæ°é
ç½® |
| | | * |
| | | * @param config åæ°é
ç½®ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateConfig(SysConfig config); |
| | | |
| | | /** |
| | | * æ¹éå é¤åæ°ä¿¡æ¯ |
| | | * |
| | | * @param configIds éè¦å é¤çåæ°ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteConfigByIds(Long[] configIds); |
| | | |
| | | /** |
| | | * æ¸
空ç¼åæ°æ® |
| | | */ |
| | | public void clearCache(); |
| | | |
| | | /** |
| | | * æ ¡éªåæ°é®åæ¯å¦å¯ä¸ |
| | | * |
| | | * @param config åæ°ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public String checkConfigKeyUnique(SysConfig config); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.common.core.domain.TreeSelect; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | |
| | | /** |
| | | * é¨é¨ç®¡ç æå¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysDeptService |
| | | { |
| | | /** |
| | | * æ¥è¯¢é¨é¨ç®¡çæ°æ® |
| | | * |
| | | * @param dept é¨é¨ä¿¡æ¯ |
| | | * @return é¨é¨ä¿¡æ¯éå |
| | | */ |
| | | public List<SysDept> selectDeptList(SysDept dept); |
| | | |
| | | /** |
| | | * æå»ºå端æéè¦æ ç»æ |
| | | * |
| | | * @param depts é¨é¨å表 |
| | | * @return æ ç»æå表 |
| | | */ |
| | | public List<SysDept> buildDeptTree(List<SysDept> depts); |
| | | |
| | | /** |
| | | * æå»ºå端æéè¦ä¸ææ ç»æ |
| | | * |
| | | * @param depts é¨é¨å表 |
| | | * @return 䏿æ ç»æå表 |
| | | */ |
| | | public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts); |
| | | |
| | | /** |
| | | * æ ¹æ®è§è²IDæ¥è¯¢é¨é¨æ ä¿¡æ¯ |
| | | * |
| | | * @param roleId è§è²ID |
| | | * @return éä¸é¨é¨å表 |
| | | */ |
| | | public List<Integer> selectDeptListByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * æ ¹æ®é¨é¨IDæ¥è¯¢ä¿¡æ¯ |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return é¨é¨ä¿¡æ¯ |
| | | */ |
| | | public SysDept selectDeptById(Long deptId); |
| | | |
| | | /** |
| | | * æ ¹æ®IDæ¥è¯¢ææåé¨é¨ï¼æ£å¸¸ç¶æï¼ |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return åé¨é¨æ° |
| | | */ |
| | | public int selectNormalChildrenDeptById(Long deptId); |
| | | |
| | | /** |
| | | * æ¯å¦åå¨é¨é¨åèç¹ |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return ç»æ |
| | | */ |
| | | public boolean hasChildByDeptId(Long deptId); |
| | | |
| | | /** |
| | | * æ¥è¯¢é¨é¨æ¯å¦åå¨ç¨æ· |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return ç»æ true åå¨ false ä¸åå¨ |
| | | */ |
| | | public boolean checkDeptExistUser(Long deptId); |
| | | |
| | | /** |
| | | * æ ¡éªé¨é¨åç§°æ¯å¦å¯ä¸ |
| | | * |
| | | * @param dept é¨é¨ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public String checkDeptNameUnique(SysDept dept); |
| | | |
| | | /** |
| | | * æ°å¢ä¿åé¨é¨ä¿¡æ¯ |
| | | * |
| | | * @param dept é¨é¨ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertDept(SysDept dept); |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¿åé¨é¨ä¿¡æ¯ |
| | | * |
| | | * @param dept é¨é¨ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateDept(SysDept dept); |
| | | |
| | | /** |
| | | * å é¤é¨é¨ç®¡çä¿¡æ¯ |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteDeptById(Long deptId); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | |
| | | /** |
| | | * åå
¸ ä¸å¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysDictDataService |
| | | { |
| | | /** |
| | | * æ ¹æ®æ¡ä»¶å页æ¥è¯¢åå
¸æ°æ® |
| | | * |
| | | * @param dictData åå
¸æ°æ®ä¿¡æ¯ |
| | | * @return åå
¸æ°æ®éåä¿¡æ¯ |
| | | */ |
| | | public List<SysDictData> selectDictDataList(SysDictData dictData); |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸ç±»åååå
¸é®å¼æ¥è¯¢åå
¸æ°æ®ä¿¡æ¯ |
| | | * |
| | | * @param dictType åå
¸ç±»å |
| | | * @param dictValue åå
¸é®å¼ |
| | | * @return åå
¸æ ç¾ |
| | | */ |
| | | public String selectDictLabel(String dictType, String dictValue); |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸æ°æ®IDæ¥è¯¢ä¿¡æ¯ |
| | | * |
| | | * @param dictCode åå
¸æ°æ®ID |
| | | * @return åå
¸æ°æ® |
| | | */ |
| | | public SysDictData selectDictDataById(Long dictCode); |
| | | |
| | | /** |
| | | * æ¹éå é¤åå
¸æ°æ®ä¿¡æ¯ |
| | | * |
| | | * @param dictCodes éè¦å é¤çåå
¸æ°æ®ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteDictDataByIds(Long[] dictCodes); |
| | | |
| | | /** |
| | | * æ°å¢ä¿ååå
¸æ°æ®ä¿¡æ¯ |
| | | * |
| | | * @param dictData åå
¸æ°æ®ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertDictData(SysDictData dictData); |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¿ååå
¸æ°æ®ä¿¡æ¯ |
| | | * |
| | | * @param dictData åå
¸æ°æ®ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateDictData(SysDictData dictData); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.domain.entity.SysDictType; |
| | | |
| | | /** |
| | | * åå
¸ ä¸å¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysDictTypeService |
| | | { |
| | | /** |
| | | * æ ¹æ®æ¡ä»¶å页æ¥è¯¢åå
¸ç±»å |
| | | * |
| | | * @param dictType åå
¸ç±»åä¿¡æ¯ |
| | | * @return åå
¸ç±»åéåä¿¡æ¯ |
| | | */ |
| | | public List<SysDictType> selectDictTypeList(SysDictType dictType); |
| | | |
| | | /** |
| | | * æ ¹æ®ææåå
¸ç±»å |
| | | * |
| | | * @return åå
¸ç±»åéåä¿¡æ¯ |
| | | */ |
| | | public List<SysDictType> selectDictTypeAll(); |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸ç±»åæ¥è¯¢åå
¸æ°æ® |
| | | * |
| | | * @param dictType åå
¸ç±»å |
| | | * @return åå
¸æ°æ®éåä¿¡æ¯ |
| | | */ |
| | | public List<SysDictData> selectDictDataByType(String dictType); |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸ç±»åIDæ¥è¯¢ä¿¡æ¯ |
| | | * |
| | | * @param dictId åå
¸ç±»åID |
| | | * @return åå
¸ç±»å |
| | | */ |
| | | public SysDictType selectDictTypeById(Long dictId); |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸ç±»åæ¥è¯¢ä¿¡æ¯ |
| | | * |
| | | * @param dictType åå
¸ç±»å |
| | | * @return åå
¸ç±»å |
| | | */ |
| | | public SysDictType selectDictTypeByType(String dictType); |
| | | |
| | | /** |
| | | * æ¹éå é¤åå
¸ä¿¡æ¯ |
| | | * |
| | | * @param dictIds éè¦å é¤çåå
¸ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteDictTypeByIds(Long[] dictIds); |
| | | |
| | | /** |
| | | * æ¸
空ç¼åæ°æ® |
| | | */ |
| | | public void clearCache(); |
| | | |
| | | /** |
| | | * æ°å¢ä¿ååå
¸ç±»åä¿¡æ¯ |
| | | * |
| | | * @param dictType åå
¸ç±»åä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertDictType(SysDictType dictType); |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¿ååå
¸ç±»åä¿¡æ¯ |
| | | * |
| | | * @param dictType åå
¸ç±»åä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateDictType(SysDictType dictType); |
| | | |
| | | /** |
| | | * æ ¡éªåå
¸ç±»åç§°æ¯å¦å¯ä¸ |
| | | * |
| | | * @param dictType åå
¸ç±»å |
| | | * @return ç»æ |
| | | */ |
| | | public String checkDictTypeUnique(SysDictType dictType); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.domain.SysLogininfor; |
| | | |
| | | /** |
| | | * ç³»ç»è®¿é®æ¥å¿æ
åµä¿¡æ¯ æå¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysLogininforService |
| | | { |
| | | /** |
| | | * æ°å¢ç³»ç»ç»å½æ¥å¿ |
| | | * |
| | | * @param logininfor è®¿é®æ¥å¿å¯¹è±¡ |
| | | */ |
| | | public void insertLogininfor(SysLogininfor logininfor); |
| | | |
| | | /** |
| | | * æ¥è¯¢ç³»ç»ç»å½æ¥å¿éå |
| | | * |
| | | * @param logininfor è®¿é®æ¥å¿å¯¹è±¡ |
| | | * @return ç»å½è®°å½éå |
| | | */ |
| | | public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor); |
| | | |
| | | /** |
| | | * æ¹éå é¤ç³»ç»ç»å½æ¥å¿ |
| | | * |
| | | * @param infoIds éè¦å é¤çç»å½æ¥å¿ID |
| | | * @return |
| | | */ |
| | | public int deleteLogininforByIds(Long[] infoIds); |
| | | |
| | | /** |
| | | * æ¸
空系ç»ç»å½æ¥å¿ |
| | | */ |
| | | public void cleanLogininfor(); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import com.ruoyi.common.core.domain.TreeSelect; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | import com.ruoyi.system.domain.vo.RouterVo; |
| | | |
| | | /** |
| | | * èå ä¸å¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysMenuService |
| | | { |
| | | /** |
| | | * æ ¹æ®ç¨æ·æ¥è¯¢ç³»ç»èåå表 |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return èåå表 |
| | | */ |
| | | public List<SysMenu> selectMenuList(Long userId); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·æ¥è¯¢ç³»ç»èåå表 |
| | | * |
| | | * @param menu èåä¿¡æ¯ |
| | | * @param userId ç¨æ·ID |
| | | * @return èåå表 |
| | | */ |
| | | public List<SysMenu> selectMenuList(SysMenu menu, Long userId); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·IDæ¥è¯¢æé |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return æéå表 |
| | | */ |
| | | public Set<String> selectMenuPermsByUserId(Long userId); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·IDæ¥è¯¢èåæ ä¿¡æ¯ |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return èåå表 |
| | | */ |
| | | public List<SysMenu> selectMenuTreeByUserId(Long userId); |
| | | |
| | | /** |
| | | * æ ¹æ®è§è²IDæ¥è¯¢èåæ ä¿¡æ¯ |
| | | * |
| | | * @param roleId è§è²ID |
| | | * @return éä¸èåå表 |
| | | */ |
| | | public List<Integer> selectMenuListByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * æå»ºåç«¯è·¯ç±æéè¦çèå |
| | | * |
| | | * @param menus èåå表 |
| | | * @return è·¯ç±å表 |
| | | */ |
| | | public List<RouterVo> buildMenus(List<SysMenu> menus); |
| | | |
| | | /** |
| | | * æå»ºå端æéè¦æ ç»æ |
| | | * |
| | | * @param menus èåå表 |
| | | * @return æ ç»æå表 |
| | | */ |
| | | public List<SysMenu> buildMenuTree(List<SysMenu> menus); |
| | | |
| | | /** |
| | | * æå»ºå端æéè¦ä¸ææ ç»æ |
| | | * |
| | | * @param menus èåå表 |
| | | * @return 䏿æ ç»æå表 |
| | | */ |
| | | public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus); |
| | | |
| | | /** |
| | | * æ ¹æ®èåIDæ¥è¯¢ä¿¡æ¯ |
| | | * |
| | | * @param menuId èåID |
| | | * @return èåä¿¡æ¯ |
| | | */ |
| | | public SysMenu selectMenuById(Long menuId); |
| | | |
| | | /** |
| | | * æ¯å¦åå¨èååèç¹ |
| | | * |
| | | * @param menuId èåID |
| | | * @return ç»æ true åå¨ false ä¸åå¨ |
| | | */ |
| | | public boolean hasChildByMenuId(Long menuId); |
| | | |
| | | /** |
| | | * æ¥è¯¢è忝å¦åå¨è§è² |
| | | * |
| | | * @param menuId èåID |
| | | * @return ç»æ true åå¨ false ä¸åå¨ |
| | | */ |
| | | public boolean checkMenuExistRole(Long menuId); |
| | | |
| | | /** |
| | | * æ°å¢ä¿åèåä¿¡æ¯ |
| | | * |
| | | * @param menu èåä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertMenu(SysMenu menu); |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¿åèåä¿¡æ¯ |
| | | * |
| | | * @param menu èåä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateMenu(SysMenu menu); |
| | | |
| | | /** |
| | | * å é¤èå管çä¿¡æ¯ |
| | | * |
| | | * @param menuId èåID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteMenuById(Long menuId); |
| | | |
| | | /** |
| | | * æ ¡éªèååç§°æ¯å¦å¯ä¸ |
| | | * |
| | | * @param menu èåä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public String checkMenuNameUnique(SysMenu menu); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.domain.SysNotice; |
| | | |
| | | /** |
| | | * å
¬å æå¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysNoticeService |
| | | { |
| | | /** |
| | | * æ¥è¯¢å
¬åä¿¡æ¯ |
| | | * |
| | | * @param noticeId å
ŒID |
| | | * @return å
¬åä¿¡æ¯ |
| | | */ |
| | | public SysNotice selectNoticeById(Long noticeId); |
| | | |
| | | /** |
| | | * æ¥è¯¢å
¬åå表 |
| | | * |
| | | * @param notice å
¬åä¿¡æ¯ |
| | | * @return å
¬åéå |
| | | */ |
| | | public List<SysNotice> selectNoticeList(SysNotice notice); |
| | | |
| | | /** |
| | | * æ°å¢å
Œ |
| | | * |
| | | * @param notice å
¬åä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertNotice(SysNotice notice); |
| | | |
| | | /** |
| | | * ä¿®æ¹å
Œ |
| | | * |
| | | * @param notice å
¬åä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateNotice(SysNotice notice); |
| | | |
| | | /** |
| | | * å é¤å
¬åä¿¡æ¯ |
| | | * |
| | | * @param noticeId å
ŒID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteNoticeById(Long noticeId); |
| | | |
| | | /** |
| | | * æ¹éå é¤å
¬åä¿¡æ¯ |
| | | * |
| | | * @param noticeIds éè¦å é¤çå
ŒID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteNoticeByIds(Long[] noticeIds); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.domain.SysOperLog; |
| | | |
| | | /** |
| | | * æä½æ¥å¿ æå¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysOperLogService |
| | | { |
| | | /** |
| | | * æ°å¢æä½æ¥å¿ |
| | | * |
| | | * @param operLog æä½æ¥å¿å¯¹è±¡ |
| | | */ |
| | | public void insertOperlog(SysOperLog operLog); |
| | | |
| | | /** |
| | | * æ¥è¯¢ç³»ç»æä½æ¥å¿éå |
| | | * |
| | | * @param operLog æä½æ¥å¿å¯¹è±¡ |
| | | * @return æä½æ¥å¿éå |
| | | */ |
| | | public List<SysOperLog> selectOperLogList(SysOperLog operLog); |
| | | |
| | | /** |
| | | * æ¹éå é¤ç³»ç»æä½æ¥å¿ |
| | | * |
| | | * @param operIds éè¦å é¤çæä½æ¥å¿ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteOperLogByIds(Long[] operIds); |
| | | |
| | | /** |
| | | * æ¥è¯¢æä½æ¥å¿è¯¦ç» |
| | | * |
| | | * @param operId æä½ID |
| | | * @return æä½æ¥å¿å¯¹è±¡ |
| | | */ |
| | | public SysOperLog selectOperLogById(Long operId); |
| | | |
| | | /** |
| | | * æ¸
空æä½æ¥å¿ |
| | | */ |
| | | public void cleanOperLog(); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.domain.SysPost; |
| | | |
| | | /** |
| | | * å²ä½ä¿¡æ¯ æå¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysPostService |
| | | { |
| | | /** |
| | | * æ¥è¯¢å²ä½ä¿¡æ¯éå |
| | | * |
| | | * @param post å²ä½ä¿¡æ¯ |
| | | * @return å²ä½å表 |
| | | */ |
| | | public List<SysPost> selectPostList(SysPost post); |
| | | |
| | | /** |
| | | * æ¥è¯¢ææå²ä½ |
| | | * |
| | | * @return å²ä½å表 |
| | | */ |
| | | public List<SysPost> selectPostAll(); |
| | | |
| | | /** |
| | | * éè¿å²ä½IDæ¥è¯¢å²ä½ä¿¡æ¯ |
| | | * |
| | | * @param postId å²ä½ID |
| | | * @return è§è²å¯¹è±¡ä¿¡æ¯ |
| | | */ |
| | | public SysPost selectPostById(Long postId); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·IDè·åå²ä½éæ©æ¡å表 |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return éä¸å²ä½IDå表 |
| | | */ |
| | | public List<Integer> selectPostListByUserId(Long userId); |
| | | |
| | | /** |
| | | * æ ¡éªå²ä½åç§° |
| | | * |
| | | * @param post å²ä½ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public String checkPostNameUnique(SysPost post); |
| | | |
| | | /** |
| | | * æ ¡éªå²ä½ç¼ç |
| | | * |
| | | * @param post å²ä½ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public String checkPostCodeUnique(SysPost post); |
| | | |
| | | /** |
| | | * éè¿å²ä½IDæ¥è¯¢å²ä½ä½¿ç¨æ°é |
| | | * |
| | | * @param postId å²ä½ID |
| | | * @return ç»æ |
| | | */ |
| | | public int countUserPostById(Long postId); |
| | | |
| | | /** |
| | | * å é¤å²ä½ä¿¡æ¯ |
| | | * |
| | | * @param postId å²ä½ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deletePostById(Long postId); |
| | | |
| | | /** |
| | | * æ¹éå é¤å²ä½ä¿¡æ¯ |
| | | * |
| | | * @param postIds éè¦å é¤çå²ä½ID |
| | | * @return ç»æ |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public int deletePostByIds(Long[] postIds); |
| | | |
| | | /** |
| | | * æ°å¢ä¿åå²ä½ä¿¡æ¯ |
| | | * |
| | | * @param post å²ä½ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertPost(SysPost post); |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¿åå²ä½ä¿¡æ¯ |
| | | * |
| | | * @param post å²ä½ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updatePost(SysPost post); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | |
| | | /** |
| | | * è§è²ä¸å¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysRoleService |
| | | { |
| | | /** |
| | | * æ ¹æ®æ¡ä»¶å页æ¥è¯¢è§è²æ°æ® |
| | | * |
| | | * @param role è§è²ä¿¡æ¯ |
| | | * @return è§è²æ°æ®éåä¿¡æ¯ |
| | | */ |
| | | public List<SysRole> selectRoleList(SysRole role); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·IDæ¥è¯¢è§è² |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return æéå表 |
| | | */ |
| | | public Set<String> selectRolePermissionByUserId(Long userId); |
| | | |
| | | /** |
| | | * æ¥è¯¢ææè§è² |
| | | * |
| | | * @return è§è²å表 |
| | | */ |
| | | public List<SysRole> selectRoleAll(); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·IDè·åè§è²éæ©æ¡å表 |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return éä¸è§è²IDå表 |
| | | */ |
| | | public List<Integer> selectRoleListByUserId(Long userId); |
| | | |
| | | /** |
| | | * éè¿è§è²IDæ¥è¯¢è§è² |
| | | * |
| | | * @param roleId è§è²ID |
| | | * @return è§è²å¯¹è±¡ä¿¡æ¯ |
| | | */ |
| | | public SysRole selectRoleById(Long roleId); |
| | | |
| | | /** |
| | | * æ ¡éªè§è²åç§°æ¯å¦å¯ä¸ |
| | | * |
| | | * @param role è§è²ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public String checkRoleNameUnique(SysRole role); |
| | | |
| | | /** |
| | | * æ ¡éªè§è²æéæ¯å¦å¯ä¸ |
| | | * |
| | | * @param role è§è²ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public String checkRoleKeyUnique(SysRole role); |
| | | |
| | | /** |
| | | * æ ¡éªè§è²æ¯å¦å
许æä½ |
| | | * |
| | | * @param role è§è²ä¿¡æ¯ |
| | | */ |
| | | public void checkRoleAllowed(SysRole role); |
| | | |
| | | /** |
| | | * éè¿è§è²IDæ¥è¯¢è§è²ä½¿ç¨æ°é |
| | | * |
| | | * @param roleId è§è²ID |
| | | * @return ç»æ |
| | | */ |
| | | public int countUserRoleByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * æ°å¢ä¿åè§è²ä¿¡æ¯ |
| | | * |
| | | * @param role è§è²ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertRole(SysRole role); |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¿åè§è²ä¿¡æ¯ |
| | | * |
| | | * @param role è§è²ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateRole(SysRole role); |
| | | |
| | | /** |
| | | * ä¿®æ¹è§è²ç¶æ |
| | | * |
| | | * @param role è§è²ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateRoleStatus(SysRole role); |
| | | |
| | | /** |
| | | * ä¿®æ¹æ°æ®æéä¿¡æ¯ |
| | | * |
| | | * @param role è§è²ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int authDataScope(SysRole role); |
| | | |
| | | /** |
| | | * éè¿è§è²IDå é¤è§è² |
| | | * |
| | | * @param roleId è§è²ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteRoleById(Long roleId); |
| | | |
| | | /** |
| | | * æ¹éå é¤è§è²ä¿¡æ¯ |
| | | * |
| | | * @param roleIds éè¦å é¤çè§è²ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteRoleByIds(Long[] roleIds); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.system.domain.SysUserOnline; |
| | | |
| | | /** |
| | | * å¨çº¿ç¨æ· æå¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysUserOnlineService |
| | | { |
| | | /** |
| | | * éè¿ç»å½å°åæ¥è¯¢ä¿¡æ¯ |
| | | * |
| | | * @param ipaddr ç»å½å°å |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return å¨çº¿ç¨æ·ä¿¡æ¯ |
| | | */ |
| | | public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user); |
| | | |
| | | /** |
| | | * éè¿ç¨æ·åç§°æ¥è¯¢ä¿¡æ¯ |
| | | * |
| | | * @param userName ç¨æ·åç§° |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return å¨çº¿ç¨æ·ä¿¡æ¯ |
| | | */ |
| | | public SysUserOnline selectOnlineByUserName(String userName, LoginUser user); |
| | | |
| | | /** |
| | | * éè¿ç»å½å°å/ç¨æ·åç§°æ¥è¯¢ä¿¡æ¯ |
| | | * |
| | | * @param ipaddr ç»å½å°å |
| | | * @param userName ç¨æ·åç§° |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return å¨çº¿ç¨æ·ä¿¡æ¯ |
| | | */ |
| | | public SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user); |
| | | |
| | | /** |
| | | * 设置å¨çº¿ç¨æ·ä¿¡æ¯ |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return å¨çº¿ç¨æ· |
| | | */ |
| | | public SysUserOnline loginUserToUserOnline(LoginUser user); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | |
| | | /** |
| | | * ç¨æ· ä¸å¡å± |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysUserService |
| | | { |
| | | /** |
| | | * æ ¹æ®æ¡ä»¶å页æ¥è¯¢ç¨æ·å表 |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return ç¨æ·ä¿¡æ¯éåä¿¡æ¯ |
| | | */ |
| | | public List<SysUser> selectUserList(SysUser user); |
| | | |
| | | /** |
| | | * éè¿ç¨æ·åæ¥è¯¢ç¨æ· |
| | | * |
| | | * @param userName ç¨æ·å |
| | | * @return ç¨æ·å¯¹è±¡ä¿¡æ¯ |
| | | */ |
| | | public SysUser selectUserByUserName(String userName); |
| | | |
| | | /** |
| | | * éè¿ç¨æ·IDæ¥è¯¢ç¨æ· |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return ç¨æ·å¯¹è±¡ä¿¡æ¯ |
| | | */ |
| | | public SysUser selectUserById(Long userId); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·IDæ¥è¯¢ç¨æ·æå±è§è²ç» |
| | | * |
| | | * @param userName ç¨æ·å |
| | | * @return ç»æ |
| | | */ |
| | | public String selectUserRoleGroup(String userName); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·IDæ¥è¯¢ç¨æ·æå±å²ä½ç» |
| | | * |
| | | * @param userName ç¨æ·å |
| | | * @return ç»æ |
| | | */ |
| | | public String selectUserPostGroup(String userName); |
| | | |
| | | /** |
| | | * æ ¡éªç¨æ·åç§°æ¯å¦å¯ä¸ |
| | | * |
| | | * @param userName ç¨æ·åç§° |
| | | * @return ç»æ |
| | | */ |
| | | public String checkUserNameUnique(String userName); |
| | | |
| | | /** |
| | | * æ ¡éªææºå·ç æ¯å¦å¯ä¸ |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public String checkPhoneUnique(SysUser user); |
| | | |
| | | /** |
| | | * æ ¡éªemailæ¯å¦å¯ä¸ |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public String checkEmailUnique(SysUser user); |
| | | |
| | | /** |
| | | * æ ¡éªç¨æ·æ¯å¦å
许æä½ |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | */ |
| | | public void checkUserAllowed(SysUser user); |
| | | |
| | | /** |
| | | * æ°å¢ç¨æ·ä¿¡æ¯ |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertUser(SysUser user); |
| | | |
| | | /** |
| | | * ä¿®æ¹ç¨æ·ä¿¡æ¯ |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateUser(SysUser user); |
| | | |
| | | /** |
| | | * ä¿®æ¹ç¨æ·ç¶æ |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateUserStatus(SysUser user); |
| | | |
| | | /** |
| | | * ä¿®æ¹ç¨æ·åºæ¬ä¿¡æ¯ |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateUserProfile(SysUser user); |
| | | |
| | | /** |
| | | * ä¿®æ¹ç¨æ·å¤´å |
| | | * |
| | | * @param userName ç¨æ·å |
| | | * @param avatar 头åå°å |
| | | * @return ç»æ |
| | | */ |
| | | public boolean updateUserAvatar(String userName, String avatar); |
| | | |
| | | /** |
| | | * éç½®ç¨æ·å¯ç |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public int resetPwd(SysUser user); |
| | | |
| | | /** |
| | | * éç½®ç¨æ·å¯ç |
| | | * |
| | | * @param userName ç¨æ·å |
| | | * @param password å¯ç |
| | | * @return ç»æ |
| | | */ |
| | | public int resetUserPwd(String userName, String password); |
| | | |
| | | /** |
| | | * éè¿ç¨æ·IDå é¤ç¨æ· |
| | | * |
| | | * @param userId ç¨æ·ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteUserById(Long userId); |
| | | |
| | | /** |
| | | * æ¹éå é¤ç¨æ·ä¿¡æ¯ |
| | | * |
| | | * @param userIds éè¦å é¤çç¨æ·ID |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteUserByIds(Long[] userIds); |
| | | |
| | | /** |
| | | * 导å
¥ç¨æ·æ°æ® |
| | | * |
| | | * @param userList ç¨æ·æ°æ®å表 |
| | | * @param isUpdateSupport æ¯å¦æ´æ°æ¯æï¼å¦æå·²åå¨ï¼åè¿è¡æ´æ°æ°æ® |
| | | * @param operName æä½ç¨æ· |
| | | * @return ç»æ |
| | | */ |
| | | public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.system.domain.SysConfig; |
| | | import com.ruoyi.system.mapper.SysConfigMapper; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | |
| | | /** |
| | | * åæ°é
ç½® æå¡å±å®ç° |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysConfigServiceImpl implements ISysConfigService |
| | | { |
| | | @Autowired |
| | | private SysConfigMapper configMapper; |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | /** |
| | | * 项ç®å¯å¨æ¶ï¼åå§ååæ°å°ç¼å |
| | | */ |
| | | @PostConstruct |
| | | public void init() |
| | | { |
| | | List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig()); |
| | | for (SysConfig config : configsList) |
| | | { |
| | | redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢åæ°é
ç½®ä¿¡æ¯ |
| | | * |
| | | * @param configId åæ°é
ç½®ID |
| | | * @return åæ°é
ç½®ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | @DataSource(DataSourceType.MASTER) |
| | | public SysConfig selectConfigById(Long configId) |
| | | { |
| | | SysConfig config = new SysConfig(); |
| | | config.setConfigId(configId); |
| | | return configMapper.selectConfig(config); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®é®åæ¥è¯¢åæ°é
ç½®ä¿¡æ¯ |
| | | * |
| | | * @param configKey åæ°key |
| | | * @return åæ°é®å¼ |
| | | */ |
| | | @Override |
| | | public String selectConfigByKey(String configKey) |
| | | { |
| | | String configValue = Convert.toStr(redisCache.getCacheObject(getCacheKey(configKey))); |
| | | if (StringUtils.isNotEmpty(configValue)) |
| | | { |
| | | return configValue; |
| | | } |
| | | SysConfig config = new SysConfig(); |
| | | config.setConfigKey(configKey); |
| | | SysConfig retConfig = configMapper.selectConfig(config); |
| | | if (StringUtils.isNotNull(retConfig)) |
| | | { |
| | | redisCache.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue()); |
| | | return retConfig.getConfigValue(); |
| | | } |
| | | return StringUtils.EMPTY; |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢åæ°é
ç½®å表 |
| | | * |
| | | * @param config åæ°é
ç½®ä¿¡æ¯ |
| | | * @return åæ°é
ç½®éå |
| | | */ |
| | | @Override |
| | | public List<SysConfig> selectConfigList(SysConfig config) |
| | | { |
| | | return configMapper.selectConfigList(config); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢åæ°é
ç½® |
| | | * |
| | | * @param config åæ°é
ç½®ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int insertConfig(SysConfig config) |
| | | { |
| | | int row = configMapper.insertConfig(config); |
| | | if (row > 0) |
| | | { |
| | | redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); |
| | | } |
| | | return row; |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹åæ°é
ç½® |
| | | * |
| | | * @param config åæ°é
ç½®ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int updateConfig(SysConfig config) |
| | | { |
| | | int row = configMapper.updateConfig(config); |
| | | if (row > 0) |
| | | { |
| | | redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); |
| | | } |
| | | return row; |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå é¤åæ°ä¿¡æ¯ |
| | | * |
| | | * @param configIds éè¦å é¤çåæ°ID |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int deleteConfigByIds(Long[] configIds) |
| | | { |
| | | int count = configMapper.deleteConfigByIds(configIds); |
| | | if (count > 0) |
| | | { |
| | | Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*"); |
| | | redisCache.deleteObject(keys); |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | /** |
| | | * æ¸
空ç¼åæ°æ® |
| | | */ |
| | | @Override |
| | | public void clearCache() |
| | | { |
| | | Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*"); |
| | | redisCache.deleteObject(keys); |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªåæ°é®åæ¯å¦å¯ä¸ |
| | | * |
| | | * @param config åæ°é
ç½®ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public String checkConfigKeyUnique(SysConfig config) |
| | | { |
| | | Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId(); |
| | | SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey()); |
| | | if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) |
| | | { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | | } |
| | | |
| | | /** |
| | | * 设置cache key |
| | | * |
| | | * @param configKey åæ°é® |
| | | * @return ç¼åé®key |
| | | */ |
| | | private String getCacheKey(String configKey) |
| | | { |
| | | return Constants.SYS_CONFIG_KEY + configKey; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | 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.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.system.service.ISysDeptService; |
| | | |
| | | /** |
| | | * é¨é¨ç®¡ç æå¡å®ç° |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysDeptServiceImpl implements ISysDeptService |
| | | { |
| | | @Autowired |
| | | private SysDeptMapper deptMapper; |
| | | |
| | | /** |
| | | * æ¥è¯¢é¨é¨ç®¡çæ°æ® |
| | | * |
| | | * @param dept é¨é¨ä¿¡æ¯ |
| | | * @return é¨é¨ä¿¡æ¯éå |
| | | */ |
| | | @Override |
| | | @DataScope(deptAlias = "d") |
| | | public List<SysDept> selectDeptList(SysDept dept) |
| | | { |
| | | return deptMapper.selectDeptList(dept); |
| | | } |
| | | |
| | | /** |
| | | * æå»ºå端æéè¦æ ç»æ |
| | | * |
| | | * @param depts é¨é¨å表 |
| | | * @return æ ç»æå表 |
| | | */ |
| | | @Override |
| | | public List<SysDept> buildDeptTree(List<SysDept> depts) |
| | | { |
| | | List<SysDept> returnList = new ArrayList<SysDept>(); |
| | | List<Long> tempList = new ArrayList<Long>(); |
| | | for (SysDept dept : depts) |
| | | { |
| | | tempList.add(dept.getDeptId()); |
| | | } |
| | | for (Iterator<SysDept> iterator = depts.iterator(); iterator.hasNext();) |
| | | { |
| | | SysDept dept = (SysDept) iterator.next(); |
| | | // 妿æ¯é¡¶çº§èç¹, éå该ç¶èç¹çææåèç¹ |
| | | if (!tempList.contains(dept.getParentId())) |
| | | { |
| | | recursionFn(depts, dept); |
| | | returnList.add(dept); |
| | | } |
| | | } |
| | | if (returnList.isEmpty()) |
| | | { |
| | | returnList = depts; |
| | | } |
| | | return returnList; |
| | | } |
| | | |
| | | /** |
| | | * æå»ºå端æéè¦ä¸ææ ç»æ |
| | | * |
| | | * @param depts é¨é¨å表 |
| | | * @return 䏿æ ç»æå表 |
| | | */ |
| | | @Override |
| | | public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts) |
| | | { |
| | | List<SysDept> deptTrees = buildDeptTree(depts); |
| | | return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®è§è²IDæ¥è¯¢é¨é¨æ ä¿¡æ¯ |
| | | * |
| | | * @param roleId è§è²ID |
| | | * @return éä¸é¨é¨å表 |
| | | */ |
| | | @Override |
| | | public List<Integer> selectDeptListByRoleId(Long roleId) |
| | | { |
| | | return deptMapper.selectDeptListByRoleId(roleId); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®é¨é¨IDæ¥è¯¢ä¿¡æ¯ |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return é¨é¨ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public SysDept selectDeptById(Long deptId) |
| | | { |
| | | return deptMapper.selectDeptById(deptId); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®IDæ¥è¯¢ææåé¨é¨ï¼æ£å¸¸ç¶æï¼ |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return åé¨é¨æ° |
| | | */ |
| | | @Override |
| | | public int selectNormalChildrenDeptById(Long deptId) |
| | | { |
| | | return deptMapper.selectNormalChildrenDeptById(deptId); |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦åå¨åèç¹ |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public boolean hasChildByDeptId(Long deptId) |
| | | { |
| | | int result = deptMapper.hasChildByDeptId(deptId); |
| | | return result > 0 ? true : false; |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢é¨é¨æ¯å¦åå¨ç¨æ· |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return ç»æ true åå¨ false ä¸åå¨ |
| | | */ |
| | | @Override |
| | | public boolean checkDeptExistUser(Long deptId) |
| | | { |
| | | int result = deptMapper.checkDeptExistUser(deptId); |
| | | return result > 0 ? true : false; |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªé¨é¨åç§°æ¯å¦å¯ä¸ |
| | | * |
| | | * @param dept é¨é¨ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public String checkDeptNameUnique(SysDept dept) |
| | | { |
| | | Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); |
| | | SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); |
| | | if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) |
| | | { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢ä¿åé¨é¨ä¿¡æ¯ |
| | | * |
| | | * @param dept é¨é¨ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int insertDept(SysDept dept) |
| | | { |
| | | SysDept info = deptMapper.selectDeptById(dept.getParentId()); |
| | | // 妿ç¶èç¹ä¸ä¸ºæ£å¸¸ç¶æ,åä¸å
许æ°å¢åèç¹ |
| | | if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) |
| | | { |
| | | throw new CustomException("é¨é¨åç¨ï¼ä¸å
许æ°å¢"); |
| | | } |
| | | dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); |
| | | return deptMapper.insertDept(dept); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¿åé¨é¨ä¿¡æ¯ |
| | | * |
| | | * @param dept é¨é¨ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int updateDept(SysDept dept) |
| | | { |
| | | SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); |
| | | SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId()); |
| | | if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) |
| | | { |
| | | String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); |
| | | String oldAncestors = oldDept.getAncestors(); |
| | | dept.setAncestors(newAncestors); |
| | | updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); |
| | | } |
| | | int result = deptMapper.updateDept(dept); |
| | | if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) |
| | | { |
| | | // å¦æè¯¥é¨é¨æ¯å¯ç¨ç¶æï¼åå¯ç¨è¯¥é¨é¨çææä¸çº§é¨é¨ |
| | | updateParentDeptStatus(dept); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹è¯¥é¨é¨çç¶çº§é¨é¨ç¶æ |
| | | * |
| | | * @param dept å½åé¨é¨ |
| | | */ |
| | | private void updateParentDeptStatus(SysDept dept) |
| | | { |
| | | String updateBy = dept.getUpdateBy(); |
| | | dept = deptMapper.selectDeptById(dept.getDeptId()); |
| | | dept.setUpdateBy(updateBy); |
| | | deptMapper.updateDeptStatus(dept); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹åå
ç´ å
³ç³» |
| | | * |
| | | * @param deptId 被修æ¹çé¨é¨ID |
| | | * @param newAncestors æ°çç¶IDéå |
| | | * @param oldAncestors æ§çç¶IDéå |
| | | */ |
| | | public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) |
| | | { |
| | | List<SysDept> children = deptMapper.selectChildrenDeptById(deptId); |
| | | for (SysDept child : children) |
| | | { |
| | | child.setAncestors(child.getAncestors().replace(oldAncestors, newAncestors)); |
| | | } |
| | | if (children.size() > 0) |
| | | { |
| | | deptMapper.updateDeptChildren(children); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å é¤é¨é¨ç®¡çä¿¡æ¯ |
| | | * |
| | | * @param deptId é¨é¨ID |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int deleteDeptById(Long deptId) |
| | | { |
| | | return deptMapper.deleteDeptById(deptId); |
| | | } |
| | | |
| | | /** |
| | | * éå½å表 |
| | | */ |
| | | private void recursionFn(List<SysDept> list, SysDept t) |
| | | { |
| | | // å¾å°åèç¹å表 |
| | | List<SysDept> childList = getChildList(list, t); |
| | | t.setChildren(childList); |
| | | for (SysDept tChild : childList) |
| | | { |
| | | if (hasChild(list, tChild)) |
| | | { |
| | | // 夿æ¯å¦æåèç¹ |
| | | Iterator<SysDept> it = childList.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | SysDept n = (SysDept) it.next(); |
| | | recursionFn(list, n); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å¾å°åèç¹å表 |
| | | */ |
| | | private List<SysDept> getChildList(List<SysDept> list, SysDept t) |
| | | { |
| | | List<SysDept> tlist = new ArrayList<SysDept>(); |
| | | Iterator<SysDept> it = list.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | SysDept n = (SysDept) it.next(); |
| | | if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) |
| | | { |
| | | tlist.add(n); |
| | | } |
| | | } |
| | | return tlist; |
| | | } |
| | | |
| | | /** |
| | | * 夿æ¯å¦æåèç¹ |
| | | */ |
| | | private boolean hasChild(List<SysDept> list, SysDept t) |
| | | { |
| | | return getChildList(list, t).size() > 0 ? true : false; |
| | | } |
| | | } |
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml
ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
ruoyi-system/src/main/resources/mapper/system/SysDictDataMapper.xml
ruoyi-system/src/main/resources/mapper/system/SysDictTypeMapper.xml
ruoyi-system/src/main/resources/mapper/system/SysLogininforMapper.xml
ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml
ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml
ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml
ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml
ruoyi-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml
ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml
ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
ruoyi-system/src/main/resources/mapper/system/SysUserPostMapper.xml
ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml
ruoyi-ui/package.json
ruoyi-ui/src/utils/index.js
ruoyi-ui/vue.config.js
ruoyi/bin/run-tomcat.bat (已删除)
ruoyi/pom.xml (已删除)
ruoyi/ry.sh (已删除)
ruoyi/sql/quartz.sql (已删除)
ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/core/lang/UUID.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/exception/job/TaskException.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/DictUtils.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/IdUtils.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/SecurityUtils.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/job/AbstractQuartzJob.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/job/CronUtils.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/job/JobInvokeUtil.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/job/QuartzDisallowConcurrentExecution.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/job/QuartzJobExecution.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/job/ScheduleUtils.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java (已删除)
ruoyi/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/DataScope.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/DataSource.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Excel.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Excels.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Log.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/BusinessStatus.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/BusinessType.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/DataSourceType.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/OperatorType.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/config/DruidConfig.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/config/GenConfig.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/config/RuoYiConfig.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/config/ScheduleConfig.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/interceptor/annotation/RepeatSubmit.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/redis/RedisCache.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/security/LoginBody.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/security/LoginUser.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/security/service/PermissionService.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/security/service/SysLoginService.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/security/service/SysPermissionService.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/security/service/TokenService.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/security/service/UserDetailsServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/task/RyTask.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/web/controller/BaseController.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/web/domain/AjaxResult.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/web/domain/BaseEntity.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/web/domain/TreeEntity.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/web/domain/TreeSelect.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/web/page/PageDomain.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/web/page/TableDataInfo.java (已删除)
ruoyi/src/main/java/com/ruoyi/framework/web/page/TableSupport.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/common/CaptchaController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/common/CommonController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/controller/ServerController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysJobController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysJobLogController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysLogininforController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysOperlogController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysUserOnlineController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysJob.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysJobLog.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysLogininfor.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysOperLog.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysUserOnline.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysJobLogMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysJobMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysLogininforMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysOperLogMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysJobLogService.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysJobService.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysLogininforService.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysOperLogService.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysJobLogServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysJobServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysLogininforServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysOperLogServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysConfigController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictDataController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictTypeController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysLoginController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysMenuController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysPostController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysRoleController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysUserController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/domain/SysConfig.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDept.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDictData.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDictType.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/domain/SysMenu.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/domain/SysNotice.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/domain/SysPost.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/domain/SysRole.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/domain/SysRoleDept.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/domain/SysRoleMenu.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/domain/SysUser.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/domain/SysUserPost.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/domain/SysUserRole.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/domain/vo/MetaVo.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/domain/vo/RouterVo.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysConfigMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysDeptMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysDictDataMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysDictTypeMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysMenuMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysPostMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysRoleDeptMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysRoleMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysRoleMenuMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysUserPostMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysUserRoleMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysConfigService.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDeptService.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictDataService.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictTypeService.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysMenuService.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysPostService.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysRoleService.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysUserOnlineService.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysUserService.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysConfigServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictDataServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictTypeServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysMenuServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysPostServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysRoleServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysUserOnlineServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysUserServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTable.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTableColumn.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableColumnMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableMapper.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableColumnServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableServiceImpl.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableColumnService.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableService.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityInitializer.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java (已删除)
ruoyi/src/main/java/com/ruoyi/project/tool/swagger/TestController.java (已删除)
ruoyi/src/main/resources/application.yml (已删除)
ruoyi/src/main/resources/mybatis/monitor/SysLogininforMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/monitor/SysOperLogMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/system/SysConfigMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/system/SysDeptMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/system/SysDictDataMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/system/SysDictTypeMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/system/SysJobLogMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/system/SysJobMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/system/SysMenuMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/system/SysNoticeMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/system/SysPostMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/system/SysRoleDeptMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/system/SysRoleMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/system/SysRoleMenuMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/system/SysUserMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/system/SysUserPostMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/system/SysUserRoleMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/tool/GenTableColumnMapper.xml (已删除)
ruoyi/src/main/resources/mybatis/tool/GenTableMapper.xml (已删除)
ruoyi/src/main/resources/vm/java/controller.java.vm (已删除)
ruoyi/src/main/resources/vm/java/domain.java.vm (已删除)
ry.sh
sql/quartz.sql
sql/ry_20200629.sql |