| | |
| | | *.class |
| | | ###################################################################### |
| | | # Build Tools |
| | | |
| | | # Mobile Tools for Java (J2ME) |
| | | .mtj.tmp/ |
| | | .gradle |
| | | /build/ |
| | | !gradle/wrapper/gradle-wrapper.jar |
| | | |
| | | # Package Files # |
| | | *.jar |
| | | *.war |
| | | *.ear |
| | | target/ |
| | | !.mvn/wrapper/maven-wrapper.jar |
| | | |
| | | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml |
| | | hs_err_pid* |
| | | ###################################################################### |
| | | # IDE |
| | | |
| | | ### STS ### |
| | | .apt_generated |
| | | .classpath |
| | | .factorypath |
| | | .project |
| | | .settings |
| | | .springBeans |
| | | |
| | | ### IntelliJ IDEA ### |
| | | .idea |
| | | *.iws |
| | | *.iml |
| | | *.ipr |
| | | |
| | | ### JRebel ### |
| | | rebel.xml |
| | | |
| | | ### NetBeans ### |
| | | nbproject/private/ |
| | | build/* |
| | | nbbuild/ |
| | | dist/ |
| | | nbdist/ |
| | | .nb-gradle/ |
| | | |
| | | ###################################################################### |
| | | # Others |
| | | *.log |
| | | *.xml.versionsBackup |
| | | *.swp |
| | | |
| | | !*/build/*.java |
| | | !*/build/*.html |
| | | !*/build/*.xml |
New file |
| | |
| | | The MIT License (MIT) |
| | | |
| | | Copyright (c) 2018 RuoYi |
| | | |
| | | Permission is hereby granted, free of charge, to any person obtaining a copy of |
| | | this software and associated documentation files (the "Software"), to deal in |
| | | the Software without restriction, including without limitation the rights to |
| | | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
| | | the Software, and to permit persons to whom the Software is furnished to do so, |
| | | subject to the following conditions: |
| | | |
| | | The above copyright notice and this permission notice shall be included in all |
| | | copies or substantial portions of the Software. |
| | | |
| | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
| | | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| | | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| | | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| | | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
New file |
| | |
| | | @echo off |
| | | echo. |
| | | echo [ÐÅÏ¢] ÇåÀí¹¤³ÌtargetÉú³É·¾¶¡£ |
| | | echo. |
| | | |
| | | %~d0 |
| | | cd %~dp0 |
| | | |
| | | cd .. |
| | | call mvn clean |
| | | |
| | | pause |
New file |
| | |
| | | @echo off |
| | | echo. |
| | | echo [ÐÅÏ¢] ´ò°üWeb¹¤³Ì£¬Éú³Éwar/jar°üÎļþ¡£ |
| | | echo. |
| | | |
| | | %~d0 |
| | | cd %~dp0 |
| | | |
| | | cd .. |
| | | call mvn clean package -Dmaven.test.skip=true |
| | | |
| | | pause |
New file |
| | |
| | | @echo off |
| | | echo. |
| | | echo [ÐÅÏ¢] ʹÓÃJarÃüÁîÔËÐÐ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 |
New file |
| | |
| | | <?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.8.6</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>generator</artifactId> |
| | | |
| | | <properties> |
| | | <maven.compiler.source>8</maven.compiler.source> |
| | | <maven.compiler.target>8</maven.compiler.target> |
| | | </properties> |
| | | <dependencies> |
| | | |
| | | <!-- https://mvnrepository.com/artifact/org.apache.velocity/velocity-engine-core --> |
| | | <dependency> |
| | | <groupId>org.apache.velocity</groupId> |
| | | <artifactId>velocity-engine-core</artifactId> |
| | | <version>2.3</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>junit</groupId> |
| | | <artifactId>junit</artifactId> |
| | | <version>4.13.2</version> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | <!-- jdbc 连接包 --> |
| | | <dependency> |
| | | <groupId>mysql</groupId> |
| | | <artifactId>mysql-connector-java</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.baomidou</groupId> |
| | | <artifactId>mybatis-plus-generator</artifactId> |
| | | <version>3.4.0</version> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-common</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
New file |
| | |
| | | package com.xizang; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.StringPool; |
| | | import com.baomidou.mybatisplus.generator.AutoGenerator; |
| | | import com.baomidou.mybatisplus.generator.InjectionConfig; |
| | | import com.baomidou.mybatisplus.generator.config.*; |
| | | import com.baomidou.mybatisplus.generator.config.po.LikeTable; |
| | | import com.baomidou.mybatisplus.generator.config.po.TableInfo; |
| | | import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; |
| | | import org.junit.Test; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 通过指定 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) 可达到加速的效果。 |
| | | * 这时测试类启动时就只会初始化 Spring 上下文,不再启动 Tomcat 容器 |
| | | */ |
| | | public class CodeGeneratorTests { |
| | | |
| | | private static final String DRIVER_NAME = "com.mysql.cj.jdbc.Driver"; |
| | | |
| | | private static final String JDBC_URL = "jdbc:mysql://xzgt.test.591taxi.cn:13306/xizang?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai"; |
| | | private static final String USER_NAME = "root"; |
| | | private static final String PASSWORD = "8f5z9g52gx4bg"; |
| | | |
| | | |
| | | // 防止误生成 |
| | | private static final String BASE_PACKAGE = "com.ruoyi.system"; |
| | | |
| | | @Test |
| | | public void contextLoads() { |
| | | // 代码生成器 |
| | | AutoGenerator mpg = new AutoGenerator(); |
| | | |
| | | // 全局配置 |
| | | GlobalConfig gc = new GlobalConfig(); |
| | | String projectPath = "D:\\workspaces\\Project\\company\\changyun\\xizang\\xizang\\generator"; |
| | | gc.setOutputDir(projectPath + "/src/main/java") |
| | | .setAuthor("yupeng") |
| | | .setMapperName("%sMapper") |
| | | .setXmlName("%sMapper") |
| | | .setServiceName("%sService") |
| | | .setServiceImplName("%sServiceImpl") |
| | | .setControllerName("%sController") |
| | | .setOpen(false)//当代码生成完成之后是否打开代码所在的文件夹 |
| | | .setSwagger2(true) //实体属性 Swagger2 注解 |
| | | .setFileOverride(true)//是否覆盖 |
| | | //.setActiveRecord(true) |
| | | .setEnableCache(false)// XML 二级缓存 |
| | | .setBaseResultMap(true)// XML ResultMap |
| | | .setBaseColumnList(true);// XML columList |
| | | mpg.setGlobalConfig(gc); |
| | | |
| | | // 数据源配置 |
| | | DataSourceConfig dsc = new DataSourceConfig(); |
| | | dsc.setUrl(JDBC_URL); |
| | | // dsc.setSchemaName("public"); |
| | | dsc.setDriverName(DRIVER_NAME); |
| | | dsc.setUsername(USER_NAME); |
| | | dsc.setPassword(PASSWORD); |
| | | mpg.setDataSource(dsc); |
| | | |
| | | // 包配置 |
| | | PackageConfig pc = new PackageConfig(); |
| | | // pc.setModuleName(scanner("模块名")); |
| | | // pc.setModuleName("sys"); |
| | | pc.setParent(BASE_PACKAGE);//controller entity service service.impl |
| | | pc.setController("controller"); |
| | | pc.setEntity("model"); |
| | | pc.setMapper("mapper"); |
| | | pc.setService("service"); |
| | | |
| | | |
| | | // 自定义mapping文件生成路径配置 |
| | | InjectionConfig cfg = new InjectionConfig() { |
| | | @Override |
| | | public void initMap() { |
| | | // to do nothing |
| | | } |
| | | }; |
| | | // 如果模板引擎是 velocity |
| | | String templatePath = "/templates/mapper.xml.vm"; |
| | | |
| | | // 自定义输出配置 |
| | | List<FileOutConfig> focList = new ArrayList<>(); |
| | | // 自定义配置会被优先输出 |
| | | focList.add(new FileOutConfig(templatePath) { |
| | | @Override |
| | | public String outputFile(TableInfo tableInfo) { |
| | | // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!! |
| | | return projectPath + "/src/main/resources/mapping/" |
| | | + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML; |
| | | } |
| | | }); |
| | | cfg.setFileOutConfigList(focList); |
| | | mpg.setCfg(cfg); |
| | | // 配置模板 |
| | | TemplateConfig templateConfig = new TemplateConfig(); |
| | | templateConfig.setXml(null); |
| | | mpg.setTemplate(templateConfig); |
| | | mpg.setPackageInfo(pc); |
| | | |
| | | // 配置模板 |
| | | // 不生成controller |
| | | //TemplateConfig templateConfig = new TemplateConfig(); |
| | | //templateConfig.setController(null); |
| | | //mpg.setTemplate(templateConfig); |
| | | |
| | | |
| | | // 策略配置 |
| | | StrategyConfig strategy = new StrategyConfig(); |
| | | //设置字段和表名的是否把下划线完成驼峰命名规则 |
| | | strategy.setNaming(NamingStrategy.underline_to_camel); |
| | | strategy.setEntitySerialVersionUID(true); |
| | | strategy.setEntityColumnConstant(false); |
| | | |
| | | |
| | | //设置生成的实体类继承的父类 |
| | | // strategy.setSuperEntityClass(BaseModel.class); |
| | | // 生成字段常量 |
| | | // strategy.setEntityColumnConstant(true); |
| | | // strategy.setSuperEntityColumns("create_by", "update_by", "disabled", "create_time", "last_time"); |
| | | strategy.setEntityLombokModel(true);//是否启动lombok |
| | | |
| | | strategy.setRestControllerStyle(true);//是否生成resetController |
| | | strategy.setLogicDeleteFieldName("isDelete"); |
| | | |
| | | // 字段自动操作策略 |
| | | /* List<TableFill> tableFillList = new ArrayList<>(); |
| | | tableFillList.add(new TableFill("create_time", FieldFill.INSERT)); |
| | | tableFillList.add(new TableFill("update_time", FieldFill.INSERT_UPDATE)); |
| | | // 表字段与属性映射关系 |
| | | strategy.setTableFillList(tableFillList);*/ |
| | | |
| | | // 公共父类 |
| | | // strategy.setSuperControllerClass("com.sxt.BaseController"); |
| | | // 写于父类中的公共字段 |
| | | // strategy.setSuperEntityColumns("person_id","person_name"); |
| | | //要设置生成哪些表 如果不设置就是生成所有的表 |
| | | // strategy.setInclude(scanner("表名,多个英文逗号分割").split(",")); |
| | | strategy.setControllerMappingHyphenStyle(true); |
| | | strategy.setEntityTableFieldAnnotationEnable(true); |
| | | // strategy.setTablePrefix(pc.getModuleName() + ""); |
| | | // strategy.setLikeTable(new LikeTable("room")); |
| | | //strategy.setLikeTable(new LikeTable("member")); |
| | | strategy.setLikeTable(new LikeTable("sys_file"));// 生成表名 |
| | | // strategy.setLikeTable(new LikeTable("t_hotel"));// 生成表名 |
| | | // strategy.setLikeTable(new LikeTable("t_scan_message"));// 生成表名 |
| | | // strategy.setNotLikeTable(new LikeTable("hotel_info"));// 不生成表名 |
| | | // strategy.setLikeTable(); |
| | | // strategy.setTablePrefix("sys_"); |
| | | mpg.setStrategy(strategy); |
| | | mpg.execute(); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | <?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.8.6</version> |
| | | |
| | | <name>ruoyi</name> |
| | | <url>http://www.ruoyi.vip</url> |
| | | <description>若依管理系统</description> |
| | | |
| | | <properties> |
| | | <ruoyi.version>3.8.6</ruoyi.version> |
| | | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| | | <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> |
| | | <java.version>1.8</java.version> |
| | | <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version> |
| | | <druid.version>1.2.16</druid.version> |
| | | <bitwalker.version>1.21</bitwalker.version> |
| | | <swagger.version>3.0.0</swagger.version> |
| | | <kaptcha.version>2.3.3</kaptcha.version> |
| | | <pagehelper.boot.version>1.4.6</pagehelper.boot.version> |
| | | <fastjson.version>2.0.39</fastjson.version> |
| | | <oshi.version>6.4.4</oshi.version> |
| | | <commons.io.version>2.13.0</commons.io.version> |
| | | <commons.collections.version>3.2.2</commons.collections.version> |
| | | <poi.version>4.1.2</poi.version> |
| | | <velocity.version>2.3</velocity.version> |
| | | <jwt.version>0.9.1</jwt.version> |
| | | </properties> |
| | | |
| | | <!-- 依赖声明 --> |
| | | <dependencyManagement> |
| | | <dependencies> |
| | | |
| | | <!-- SpringBoot的依赖配置--> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-dependencies</artifactId> |
| | | <version>2.5.15</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> |
| | | |
| | | <!-- 获取系统信息 --> |
| | | <dependency> |
| | | <groupId>com.github.oshi</groupId> |
| | | <artifactId>oshi-core</artifactId> |
| | | <version>${oshi.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- Swagger3依赖 --> |
| | | <dependency> |
| | | <groupId>io.springfox</groupId> |
| | | <artifactId>springfox-boot-starter</artifactId> |
| | | <version>${swagger.version}</version> |
| | | <!-- <exclusions>--> |
| | | <!-- <exclusion>--> |
| | | <!-- <groupId>io.swagger</groupId>--> |
| | | <!-- <artifactId>swagger-models</artifactId>--> |
| | | <!-- </exclusion>--> |
| | | <!-- </exclusions>--> |
| | | </dependency> |
| | | |
| | | <!-- io常用工具类 --> |
| | | <dependency> |
| | | <groupId>commons-io</groupId> |
| | | <artifactId>commons-io</artifactId> |
| | | <version>${commons.io.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- excel工具 --> |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi-ooxml</artifactId> |
| | | <version>${poi.version}</version> |
| | | </dependency> |
| | | |
| | | |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi</artifactId> |
| | | <version>${poi.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi-ooxml-schemas</artifactId> |
| | | <version>${poi.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- velocity代码生成使用模板 --> |
| | | <dependency> |
| | | <groupId>org.apache.velocity</groupId> |
| | | <artifactId>velocity-engine-core</artifactId> |
| | | <version>${velocity.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- collections工具类 --> |
| | | <dependency> |
| | | <groupId>commons-collections</groupId> |
| | | <artifactId>commons-collections</artifactId> |
| | | <version>${commons.collections.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- 阿里JSON解析器 --> |
| | | <dependency> |
| | | <groupId>com.alibaba.fastjson2</groupId> |
| | | <artifactId>fastjson2</artifactId> |
| | | <version>${fastjson.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- Token生成与解析--> |
| | | <dependency> |
| | | <groupId>io.jsonwebtoken</groupId> |
| | | <artifactId>jjwt</artifactId> |
| | | <version>${jwt.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- 验证码 --> |
| | | <dependency> |
| | | <groupId>pro.fessional</groupId> |
| | | <artifactId>kaptcha</artifactId> |
| | | <version>${kaptcha.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> |
| | | <module>ruoyi-applet</module> |
| | | </modules> |
| | | <packaging>pom</packaging> |
| | | |
| | | <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>https://maven.aliyun.com/repository/public</url> |
| | | <releases> |
| | | <enabled>true</enabled> |
| | | </releases> |
| | | </repository> |
| | | </repositories> |
| | | |
| | | <pluginRepositories> |
| | | <pluginRepository> |
| | | <id>public</id> |
| | | <name>aliyun nexus</name> |
| | | <url>https://maven.aliyun.com/repository/public</url> |
| | | <releases> |
| | | <enabled>true</enabled> |
| | | </releases> |
| | | <snapshots> |
| | | <enabled>false</enabled> |
| | | </snapshots> |
| | | </pluginRepository> |
| | | </pluginRepositories> |
| | | |
| | | </project> |
New file |
| | |
| | | <?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.8.6</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <packaging>jar</packaging> |
| | | <artifactId>ruoyi-admin</artifactId> |
| | | |
| | | <description> |
| | | web服务入口 |
| | | </description> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>com.aliyun.oss</groupId> |
| | | <artifactId>aliyun-sdk-oss</artifactId> |
| | | <version>3.8.0</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.google.guava</groupId> |
| | | <artifactId>guava</artifactId> |
| | | <version>31.1-jre</version> <!-- 请根据需要选择合适的版本 --> |
| | | </dependency> |
| | | <!-- spring-boot-devtools --> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-devtools</artifactId> |
| | | <optional>true</optional> <!-- 表示依赖不会传递 --> |
| | | </dependency> |
| | | |
| | | <!-- swagger3--> |
| | | <dependency> |
| | | <groupId>io.springfox</groupId> |
| | | <artifactId>springfox-boot-starter</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>com.github.xiaoymin</groupId>--> |
| | | <!-- <artifactId>swagger-bootstrap-ui</artifactId>--> |
| | | <!-- <version>1.9.6</version>--> |
| | | <!-- </dependency>--> |
| | | |
| | | |
| | | <!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 --> |
| | | <dependency> |
| | | <groupId>io.swagger</groupId> |
| | | <artifactId>swagger-models</artifactId> |
| | | <version>1.6.2</version> |
| | | </dependency> |
| | | |
| | | <!-- Mysql驱动包 --> |
| | | <dependency> |
| | | <groupId>mysql</groupId> |
| | | <artifactId>mysql-connector-java</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- 核心模块--> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-framework</artifactId> |
| | | <!-- <exclusions>--> |
| | | <!-- <exclusion>--> |
| | | <!-- <groupId>com.github.pagehelper</groupId>--> |
| | | <!-- <artifactId>pagehelper-spring-boot-starter</artifactId>--> |
| | | <!-- </exclusion>--> |
| | | <!-- </exclusions>--> |
| | | </dependency> |
| | | |
| | | <!-- 定时任务--> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-quartz</artifactId> |
| | | <!-- <exclusions>--> |
| | | <!-- <exclusion>--> |
| | | <!-- <groupId>com.github.pagehelper</groupId>--> |
| | | <!-- <artifactId>pagehelper-spring-boot-starter</artifactId>--> |
| | | <!-- </exclusion>--> |
| | | <!-- </exclusions>--> |
| | | </dependency> |
| | | |
| | | <!-- 代码生成--> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-generator</artifactId> |
| | | <!-- <exclusions>--> |
| | | <!-- <exclusion>--> |
| | | <!-- <groupId>com.github.pagehelper</groupId>--> |
| | | <!-- <artifactId>pagehelper-spring-boot-starter</artifactId>--> |
| | | <!-- </exclusion>--> |
| | | <!-- </exclusions>--> |
| | | </dependency> |
| | | |
| | | <!-- zxing生成二维码 --> |
| | | <dependency> |
| | | <groupId>com.google.zxing</groupId> |
| | | <artifactId>core</artifactId> |
| | | <version>3.3.3</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.google.zxing</groupId> |
| | | <artifactId>javase</artifactId> |
| | | <version>3.3.3</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.springframework</groupId> |
| | | <artifactId>spring-test</artifactId> |
| | | <version>5.1.3.RELEASE</version> |
| | | </dependency> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>org.apache.httpcomponents</groupId>--> |
| | | <!-- <artifactId>httpcore</artifactId>--> |
| | | <!-- <version>4.3.2</version>--> |
| | | <!-- </dependency>--> |
| | | |
| | | <dependency> |
| | | <groupId>com.squareup.okhttp3</groupId> |
| | | <artifactId>okhttp</artifactId> |
| | | <version>4.9.3</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>fastjson</artifactId> |
| | | <version>1.2.78</version> |
| | | </dependency> |
| | | |
| | | <!-- easypoi --> |
| | | <dependency> |
| | | <groupId>cn.afterturn</groupId> |
| | | <artifactId>easypoi-base</artifactId> |
| | | <version>4.3.0</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>cn.afterturn</groupId> |
| | | <artifactId>easypoi-web</artifactId> |
| | | <version>4.3.0</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>cn.afterturn</groupId> |
| | | <artifactId>easypoi-annotation</artifactId> |
| | | <version>4.3.0</version> |
| | | </dependency> |
| | | |
| | | <!-- 阿里云短信 --> |
| | | <dependency> |
| | | <groupId>com.aliyun</groupId> |
| | | <artifactId>dysmsapi20170525</artifactId> |
| | | <version>2.0.10</version> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | <version>2.5.15</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.1.0</version> |
| | | <configuration> |
| | | <failOnMissingWebXml>false</failOnMissingWebXml> |
| | | <warName>${project.artifactId}</warName> |
| | | </configuration> |
| | | </plugin> |
| | | </plugins> |
| | | <finalName>${project.artifactId}</finalName> |
| | | </build> |
| | | |
| | | </project> |
New file |
| | |
| | | package com.ruoyi; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
| | | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; |
| | | import org.springframework.cache.annotation.EnableCaching; |
| | | import org.springframework.context.ConfigurableApplicationContext; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.core.env.Environment; |
| | | import org.springframework.http.client.SimpleClientHttpRequestFactory; |
| | | import org.springframework.scheduling.annotation.EnableScheduling; |
| | | import org.springframework.web.client.RestTemplate; |
| | | import springfox.documentation.oas.annotations.EnableOpenApi; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.net.UnknownHostException; |
| | | |
| | | /** |
| | | * 启动程序 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Slf4j |
| | | @EnableOpenApi |
| | | @EnableCaching |
| | | @EnableScheduling//开启定时任务 |
| | | @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) |
| | | public class RuoYiApplication |
| | | { |
| | | public static void main(String[] args) { |
| | | |
| | | |
| | | ConfigurableApplicationContext application = SpringApplication.run(RuoYiApplication.class, args); |
| | | try { |
| | | |
| | | Environment env = application.getEnvironment(); |
| | | log.info("\n----------------------------------------------------------\n\t" + |
| | | "应用 '{}' 运行成功! 访问连接:\n\t" + |
| | | "Swagger文档: \t\thttp://{}:{}/doc.html\n" + |
| | | "----------------------------------------------------------", |
| | | env.getProperty("spring.application.name", "后台"), |
| | | InetAddress.getLocalHost().getHostAddress(), |
| | | env.getProperty("server.port", "8081")); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 当不存在此 wxRestTemplate 使用此方法的bean注入 |
| | | * |
| | | * @return |
| | | */ |
| | | @Bean |
| | | @ConditionalOnMissingBean(name = "restTemplate") |
| | | public RestTemplate wxRestTemplate() { |
| | | //复杂构造函数的使用 |
| | | SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); |
| | | // 设置超时 |
| | | requestFactory.setConnectTimeout(6000); |
| | | requestFactory.setReadTimeout(6000); |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | restTemplate.setRequestFactory(requestFactory); |
| | | return restTemplate; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi; |
| | | |
| | | import org.springframework.boot.builder.SpringApplicationBuilder; |
| | | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
| | | |
| | | /** |
| | | * web容器中进行部署 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class RuoYiServletInitializer extends SpringBootServletInitializer |
| | | { |
| | | @Override |
| | | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) |
| | | { |
| | | return application.sources(RuoYiApplication.class); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.aspect; |
| | | |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.annotation.Before; |
| | | import org.aspectj.lang.annotation.Pointcut; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | |
| | | @Aspect |
| | | @Component |
| | | |
| | | public class StateAspect { |
| | | |
| | | @Autowired |
| | | private ISysUserService sysUserService; |
| | | |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | @Pointcut("execution(* com.ruoyi.web.controller.manage.*.*(..)) && !execution( * com.ruoyi.web.controller.manage.LoginController.*.*(..))") |
| | | public void state(){} |
| | | |
| | | @Before("state()") |
| | | public void isfrozen(){ |
| | | System.err.println("进入切面"); |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | SysUser sysUser = sysUserService.selectUserById(loginUser.getUserId()); |
| | | if (sysUser.getStatus().equals("1")){ |
| | | throw new ServiceException("当前账号已停用"); |
| | | } |
| | | if (roleService.selectRoleByUserId(sysUser.getUserId()).getStatus()==1){ |
| | | throw new ServiceException("当前角色已停用"); |
| | | }; |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | @Api(tags = "测试接口") |
| | | @RestController |
| | | @RequestMapping("/api") |
| | | public class TestController { |
| | | |
| | | @ApiOperation(value = "处理加密后的数据") |
| | | @PostMapping("/data") |
| | | public R<PageInfo<SysUser>> processData(@RequestBody String encryptedRequest) { |
| | | try { |
| | | // 解密整个请求体 |
| | | System.out.println("过滤器解密后发送的请求体: " + encryptedRequest); |
| | | |
| | | return R.ok(new PageInfo<>(1, 10)); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("解密或处理消息失败", e); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.common; |
| | | |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.IOException; |
| | | import java.util.concurrent.TimeUnit; |
| | | import javax.annotation.Resource; |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.FastByteArrayOutputStream; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.google.code.kaptcha.Producer; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.constant.CacheConstants; |
| | | 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.sign.Base64; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | |
| | | /** |
| | | * 验证码操作处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | public class CaptchaController |
| | | { |
| | | @Resource(name = "captchaProducer") |
| | | private Producer captchaProducer; |
| | | |
| | | @Resource(name = "captchaProducerMath") |
| | | private Producer captchaProducerMath; |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | /** |
| | | * 生成验证码 |
| | | */ |
| | | @GetMapping("/captchaImage") |
| | | public AjaxResult getCode(HttpServletResponse response) throws IOException |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | boolean captchaEnabled = configService.selectCaptchaEnabled(); |
| | | ajax.put("captchaEnabled", captchaEnabled); |
| | | if (!captchaEnabled) |
| | | { |
| | | return ajax; |
| | | } |
| | | |
| | | // 保存验证码信息 |
| | | String uuid = IdUtils.simpleUUID(); |
| | | String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid; |
| | | |
| | | String capStr = null, code = null; |
| | | BufferedImage image = null; |
| | | |
| | | // 生成验证码 |
| | | String captchaType = RuoYiConfig.getCaptchaType(); |
| | | if ("math".equals(captchaType)) |
| | | { |
| | | String capText = captchaProducerMath.createText(); |
| | | capStr = capText.substring(0, capText.lastIndexOf("@")); |
| | | code = capText.substring(capText.lastIndexOf("@") + 1); |
| | | image = captchaProducerMath.createImage(capStr); |
| | | } |
| | | else if ("char".equals(captchaType)) |
| | | { |
| | | capStr = code = captchaProducer.createText(); |
| | | image = captchaProducer.createImage(capStr); |
| | | } |
| | | |
| | | redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES); |
| | | // 转换流信息写出 |
| | | FastByteArrayOutputStream os = new FastByteArrayOutputStream(); |
| | | try |
| | | { |
| | | ImageIO.write(image, "jpg", os); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | ajax.put("uuid", uuid); |
| | | ajax.put("img", Base64.encode(os.toByteArray())); |
| | | return ajax; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.common; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | 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.http.MediaType; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | 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 |
| | | @RequestMapping("/common") |
| | | public class CommonController |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(CommonController.class); |
| | | |
| | | @Autowired |
| | | private ServerConfig serverConfig; |
| | | |
| | | private static final String FILE_DELIMETER = ","; |
| | | |
| | | /** |
| | | * 通用下载请求 |
| | | * |
| | | * @param fileName 文件名称 |
| | | * @param delete 是否删除 |
| | | */ |
| | | @GetMapping("/download") |
| | | public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) |
| | | { |
| | | try |
| | | { |
| | | if (!FileUtils.checkAllowDownload(fileName)) |
| | | { |
| | | throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName)); |
| | | } |
| | | String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); |
| | | String filePath = RuoYiConfig.getDownloadPath() + fileName; |
| | | |
| | | response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
| | | FileUtils.setAttachmentResponseHeader(response, realFileName); |
| | | FileUtils.writeBytes(filePath, response.getOutputStream()); |
| | | if (delete) |
| | | { |
| | | FileUtils.deleteFile(filePath); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | log.error("下载文件失败", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 通用上传请求(单个) |
| | | */ |
| | | @PostMapping("/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("url", url); |
| | | ajax.put("fileName", fileName); |
| | | ajax.put("newFileName", FileUtils.getName(fileName)); |
| | | ajax.put("originalFilename", file.getOriginalFilename()); |
| | | return ajax; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 通用上传请求(多个) |
| | | */ |
| | | @PostMapping("/uploads") |
| | | public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception |
| | | { |
| | | try |
| | | { |
| | | // 上传文件路径 |
| | | String filePath = RuoYiConfig.getUploadPath(); |
| | | List<String> urls = new ArrayList<String>(); |
| | | List<String> fileNames = new ArrayList<String>(); |
| | | List<String> newFileNames = new ArrayList<String>(); |
| | | List<String> originalFilenames = new ArrayList<String>(); |
| | | for (MultipartFile file : files) |
| | | { |
| | | // 上传并返回新文件名称 |
| | | String fileName = FileUploadUtils.upload(filePath, file); |
| | | String url = serverConfig.getUrl() + fileName; |
| | | urls.add(url); |
| | | fileNames.add(fileName); |
| | | newFileNames.add(FileUtils.getName(fileName)); |
| | | originalFilenames.add(file.getOriginalFilename()); |
| | | } |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER)); |
| | | ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER)); |
| | | ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER)); |
| | | ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER)); |
| | | return ajax; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 本地资源通用下载 |
| | | */ |
| | | @GetMapping("/download/resource") |
| | | public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response) |
| | | throws Exception |
| | | { |
| | | try |
| | | { |
| | | if (!FileUtils.checkAllowDownload(resource)) |
| | | { |
| | | throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource)); |
| | | } |
| | | // 本地资源路径 |
| | | String localPath = RuoYiConfig.getProfile(); |
| | | // 数据库资源地址 |
| | | String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX); |
| | | // 下载名称 |
| | | String downloadName = StringUtils.substringAfterLast(downloadPath, "/"); |
| | | response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
| | | FileUtils.setAttachmentResponseHeader(response, downloadName); |
| | | FileUtils.writeBytes(downloadPath, response.getOutputStream()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | log.error("下载文件失败", e); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | //package com.ruoyi.web.controller.interceptor; |
| | | // |
| | | //import org.springframework.context.annotation.Bean; |
| | | //import org.springframework.context.annotation.Configuration; |
| | | // |
| | | //@Configuration |
| | | //public class MybatisConfiguration { |
| | | // |
| | | // /** |
| | | // * 注册拦截器 |
| | | // */ |
| | | // @Bean |
| | | // public MybatisInterceptor getMybatisInterceptor() { |
| | | // return new MybatisInterceptor(); |
| | | // } |
| | | // |
| | | //} |
New file |
| | |
| | | //package com.ruoyi.web.controller.interceptor; |
| | | // |
| | | //import com.ruoyi.framework.web.service.TokenService; |
| | | //import lombok.extern.slf4j.Slf4j; |
| | | //import org.apache.ibatis.executor.Executor; |
| | | //import org.apache.ibatis.mapping.MappedStatement; |
| | | //import org.apache.ibatis.mapping.SqlCommandType; |
| | | //import org.apache.ibatis.plugin.*; |
| | | //import org.springframework.beans.factory.annotation.Autowired; |
| | | //import org.springframework.stereotype.Component; |
| | | // |
| | | //import java.lang.reflect.Field; |
| | | //import java.time.LocalDateTime; |
| | | //import java.util.*; |
| | | // |
| | | //@Slf4j |
| | | //@Component |
| | | //@Intercepts({ @Signature(type = Executor.class, method = "update", args = { MappedStatement.class, Object.class }) }) |
| | | //public class MybatisInterceptor implements Interceptor { |
| | | // |
| | | // @Autowired |
| | | // private TokenService tokenService; |
| | | // |
| | | // @Override |
| | | // public Object intercept(Invocation invocation) throws Throwable { |
| | | // MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0]; |
| | | // if("com.ruoyi.system.mapper.SysLogininforMapper.insertLogininfor".equals(mappedStatement.getId())){ |
| | | // return invocation.proceed(); |
| | | // } |
| | | // // sql类型:insert、update、select、delete |
| | | // SqlCommandType sqlCommandType = mappedStatement.getSqlCommandType(); |
| | | // Object parameter = invocation.getArgs()[1]; |
| | | // |
| | | // if (parameter == null) { |
| | | // return invocation.proceed(); |
| | | // } |
| | | // |
| | | // // 当sql为新增或更新类型时,自动填充操作人相关信息 |
| | | // if (SqlCommandType.INSERT == sqlCommandType) { |
| | | // |
| | | // Field[] fields = getAllFields(parameter); |
| | | // for (Field field : fields) { |
| | | // try { |
| | | // // 注入创建人 |
| | | // if ("createBy".equals(field.getName())) { |
| | | // // 获取当前登录用户信息 |
| | | // if(Objects.nonNull(tokenService.getLoginUser())){ |
| | | // String userName = tokenService.getLoginUser().getUser().getUserName(); |
| | | // field.setAccessible(true); |
| | | // field.set(parameter, userName); |
| | | // field.setAccessible(false); |
| | | // } |
| | | // } |
| | | // //注入创建时间 |
| | | // if ("createTime".equals(field.getName())) { |
| | | // field.setAccessible(true); |
| | | //// field.set(parameter, LocalDateTime.now()); |
| | | // field.setAccessible(false); |
| | | // } |
| | | // } catch (Exception e) { |
| | | // log.error("failed to insert data, exception = ", e); |
| | | // } |
| | | // } |
| | | // } |
| | | // if (SqlCommandType.UPDATE == sqlCommandType) { |
| | | // Field[] fields = getAllFields(parameter); |
| | | // for (Field field : fields) { |
| | | // try { |
| | | // if ("updateBy".equals(field.getName())) { |
| | | // // 获取当前登录用户信息 |
| | | // if(Objects.nonNull(tokenService.getLoginUser())){ |
| | | // String userName = tokenService.getLoginUser().getUser().getUserName(); |
| | | // field.setAccessible(true); |
| | | // field.set(parameter, userName); |
| | | // field.setAccessible(false); |
| | | // } |
| | | // } |
| | | // if ("updateTime".equals(field.getName())) { |
| | | // field.setAccessible(true); |
| | | //// field.set(parameter, new Date()); |
| | | // field.setAccessible(false); |
| | | // } |
| | | // } catch (Exception e) { |
| | | // log.error("failed to update data, exception = ", e); |
| | | // } |
| | | // } |
| | | // } |
| | | // return invocation.proceed(); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public Object plugin(Object target) { |
| | | // return Plugin.wrap(target, this); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void setProperties(Properties properties) { |
| | | // // TODO Auto-generated method stub |
| | | // } |
| | | // |
| | | // /** |
| | | // * 获取类的所有属性,包括父类 |
| | | // * |
| | | // * @param object |
| | | // * @return |
| | | // */ |
| | | // private Field[] getAllFields(Object object) { |
| | | // Class<?> clazz = object.getClass(); |
| | | // List<Field> fieldList = new ArrayList<>(); |
| | | // while (clazz != null) { |
| | | // fieldList.addAll(new ArrayList<>(Arrays.asList(clazz.getDeclaredFields()))); |
| | | // clazz = clazz.getSuperclass(); |
| | | // } |
| | | // Field[] fields = new Field[fieldList.size()]; |
| | | // fieldList.toArray(fields); |
| | | // return fields; |
| | | // } |
| | | // |
| | | //} |
New file |
| | |
| | | package com.ruoyi.web.controller.monitor; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Properties; |
| | | import java.util.Set; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisCallback; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | 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.constant.CacheConstants; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.SysCache; |
| | | |
| | | /** |
| | | * 缓存监控 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/monitor/cache") |
| | | public class CacheController |
| | | { |
| | | @Autowired |
| | | private RedisTemplate<String, String> redisTemplate; |
| | | |
| | | private final static List<SysCache> caches = new ArrayList<SysCache>(); |
| | | { |
| | | caches.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "用户信息")); |
| | | caches.add(new SysCache(CacheConstants.SYS_CONFIG_KEY, "配置信息")); |
| | | caches.add(new SysCache(CacheConstants.SYS_DICT_KEY, "数据字典")); |
| | | caches.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "验证码")); |
| | | caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交")); |
| | | caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理")); |
| | | caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数")); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @GetMapping() |
| | | public AjaxResult getInfo() throws Exception |
| | | { |
| | | Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info()); |
| | | Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats")); |
| | | Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize()); |
| | | |
| | | Map<String, Object> result = new HashMap<>(3); |
| | | result.put("info", info); |
| | | result.put("dbSize", dbSize); |
| | | |
| | | List<Map<String, String>> pieList = new ArrayList<>(); |
| | | commandStats.stringPropertyNames().forEach(key -> { |
| | | Map<String, String> data = new HashMap<>(2); |
| | | String property = commandStats.getProperty(key); |
| | | data.put("name", StringUtils.removeStart(key, "cmdstat_")); |
| | | data.put("value", StringUtils.substringBetween(property, "calls=", ",usec")); |
| | | pieList.add(data); |
| | | }); |
| | | result.put("commandStats", pieList); |
| | | return AjaxResult.success(result); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @GetMapping("/getNames") |
| | | public AjaxResult cache() |
| | | { |
| | | return AjaxResult.success(caches); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @GetMapping("/getKeys/{cacheName}") |
| | | public AjaxResult getCacheKeys(@PathVariable String cacheName) |
| | | { |
| | | Set<String> cacheKeys = redisTemplate.keys(cacheName + "*"); |
| | | return AjaxResult.success(cacheKeys); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @GetMapping("/getValue/{cacheName}/{cacheKey}") |
| | | public AjaxResult getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey) |
| | | { |
| | | String cacheValue = redisTemplate.opsForValue().get(cacheKey); |
| | | SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue); |
| | | return AjaxResult.success(sysCache); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @DeleteMapping("/clearCacheName/{cacheName}") |
| | | public AjaxResult clearCacheName(@PathVariable String cacheName) |
| | | { |
| | | Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*"); |
| | | redisTemplate.delete(cacheKeys); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @DeleteMapping("/clearCacheKey/{cacheKey}") |
| | | public AjaxResult clearCacheKey(@PathVariable String cacheKey) |
| | | { |
| | | redisTemplate.delete(cacheKey); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @DeleteMapping("/clearCacheAll") |
| | | public AjaxResult clearCacheAll() |
| | | { |
| | | Collection<String> cacheKeys = redisTemplate.keys("*"); |
| | | redisTemplate.delete(cacheKeys); |
| | | return AjaxResult.success(); |
| | | } |
| | | } |
New file |
| | |
| | | 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.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.domain.Server; |
| | | |
| | | /** |
| | | * 服务器监控 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/monitor/server") |
| | | public class ServerController |
| | | { |
| | | @PreAuthorize("@ss.hasPermi('monitor:server:list')") |
| | | @GetMapping() |
| | | public AjaxResult getInfo() throws Exception |
| | | { |
| | | Server server = new Server(); |
| | | server.copyTo(); |
| | | return AjaxResult.success(server); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.monitor; |
| | | |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | 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.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.service.SysPasswordService; |
| | | 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; |
| | | |
| | | @Autowired |
| | | private SysPasswordService passwordService; |
| | | |
| | | @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')") |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, SysLogininfor logininfor) |
| | | // { |
| | | // List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); |
| | | // ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class); |
| | | // util.exportExcel(response, 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 success(); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:logininfor:unlock')") |
| | | @Log(title = "账户解锁", businessType = BusinessType.OTHER) |
| | | @GetMapping("/unlock/{userName}") |
| | | public AjaxResult unlock(@PathVariable("userName") String userName) |
| | | { |
| | | passwordService.clearLoginRecordCache(userName); |
| | | return success(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.monitor; |
| | | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.system.query.SysOperLogQuery; |
| | | import com.ruoyi.system.service.ISysOperLogService; |
| | | import com.ruoyi.system.vo.SysOperLogVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 操作日志记录 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Slf4j |
| | | @Api(tags = "操作日志记录") |
| | | @RestController |
| | | @RequestMapping("/monitor/operlog") |
| | | public class SysOperlogController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysOperLogService operLogService; |
| | | |
| | | @ApiOperation(value = "操作日志分页列表") |
| | | @PostMapping("/list") |
| | | public AjaxResult list(@RequestBody SysOperLogQuery query) |
| | | { |
| | | PageInfo<SysOperLogVO> list = operLogService.selectOperLogPageList(query); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @Log(title = "删除操作日志", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/deleteById/{operIds}") |
| | | public AjaxResult remove(@PathVariable String operIds) |
| | | { |
| | | String[] split = operIds.split(","); |
| | | List<Long> id = new ArrayList<>(); |
| | | for (String s : split) { |
| | | id.add(Long.valueOf(s)); |
| | | } |
| | | return AjaxResult.success(operLogService.deleteOperLogByIds(id)); |
| | | } |
| | | |
| | | @Log(title = "清除操作日志", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/clean") |
| | | public AjaxResult clean() |
| | | { |
| | | operLogService.cleanOperLog(); |
| | | return success(); |
| | | } |
| | | } |
New file |
| | |
| | | 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.CacheConstants; |
| | | 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(CacheConstants.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)) |
| | | { |
| | | userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user)); |
| | | } |
| | | else if (StringUtils.isNotEmpty(ipaddr)) |
| | | { |
| | | userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user)); |
| | | } |
| | | else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) |
| | | { |
| | | 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.FORCE) |
| | | @DeleteMapping("/{tokenId}") |
| | | public AjaxResult forceLogout(@PathVariable String tokenId) |
| | | { |
| | | redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId); |
| | | return success(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | 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.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; |
| | | |
| | | // @Log(title = "参数管理", businessType = BusinessType.EXPORT) |
| | | // @PreAuthorize("@ss.hasPermi('system:config:export')") |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, SysConfig config) |
| | | // { |
| | | // List<SysConfig> list = configService.selectConfigList(config); |
| | | // ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class); |
| | | // util.exportExcel(response, list, "参数数据"); |
| | | // } |
| | | |
| | | /** |
| | | * 根据参数编号获取详细信息 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:config:query')") |
| | | @GetMapping(value = "/{configId}") |
| | | public AjaxResult getInfo(@PathVariable Long configId) |
| | | { |
| | | return success(configService.selectConfigById(configId)); |
| | | } |
| | | |
| | | /** |
| | | * 根据参数键名查询参数值 |
| | | */ |
| | | @GetMapping(value = "/configKey/{configKey}") |
| | | public AjaxResult getConfigKey(@PathVariable String configKey) |
| | | { |
| | | return success(configService.selectConfigByKey(configKey)); |
| | | } |
| | | |
| | | /** |
| | | * 新增参数配置 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:config:add')") |
| | | @Log(title = "参数管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysConfig config) |
| | | { |
| | | if (!configService.checkConfigKeyUnique(config)) |
| | | { |
| | | return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); |
| | | } |
| | | config.setCreateBy(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 (!configService.checkConfigKeyUnique(config)) |
| | | { |
| | | return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); |
| | | } |
| | | config.setUpdateBy(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) |
| | | { |
| | | configService.deleteConfigByIds(configIds); |
| | | return success(); |
| | | } |
| | | |
| | | /** |
| | | * 刷新参数缓存 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:config:remove')") |
| | | @Log(title = "参数管理", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/refreshCache") |
| | | public AjaxResult refreshCache() |
| | | { |
| | | configService.resetConfigCache(); |
| | | return success(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | 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.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()); |
| | | depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); |
| | | return AjaxResult.success(depts); |
| | | } |
| | | |
| | | /** |
| | | * 根据部门编号获取详细信息 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:dept:query')") |
| | | @GetMapping(value = "/{deptId}") |
| | | public AjaxResult getInfo(@PathVariable Long deptId) |
| | | { |
| | | deptService.checkDeptDataScope(deptId); |
| | | return AjaxResult.success(deptService.selectDeptById(deptId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增部门 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:dept:add')") |
| | | @Log(title = "部门管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysDept dept) |
| | | { |
| | | if (!deptService.checkDeptNameUnique(dept)) |
| | | { |
| | | return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); |
| | | } |
| | | dept.setCreateBy(getUsername()); |
| | | return AjaxResult.success(deptService.insertDept(dept)); |
| | | } |
| | | |
| | | /** |
| | | * 修改部门 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:dept:edit')") |
| | | @Log(title = "部门管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysDept dept) |
| | | { |
| | | Long deptId = dept.getDeptId(); |
| | | deptService.checkDeptDataScope(deptId); |
| | | if (!deptService.checkDeptNameUnique(dept)) |
| | | { |
| | | return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); |
| | | } |
| | | else if (dept.getParentId().equals(deptId)) |
| | | { |
| | | return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); |
| | | } |
| | | else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) |
| | | { |
| | | return error("该部门包含未停用的子部门!"); |
| | | } |
| | | dept.setUpdateBy(getUsername()); |
| | | return AjaxResult.success(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 warn("存在下级部门,不允许删除"); |
| | | } |
| | | if (deptService.checkDeptExistUser(deptId)) |
| | | { |
| | | return warn("部门存在用户,不允许删除"); |
| | | } |
| | | deptService.checkDeptDataScope(deptId); |
| | | return AjaxResult.success(deptService.deleteDeptById(deptId)); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | 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.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.system.service.ISysDictDataService; |
| | | import com.ruoyi.system.service.ISysDictTypeService; |
| | | |
| | | /** |
| | | * 数据字典信息 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Api(tags = "数据字典信息") |
| | | @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')") |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, SysDictData dictData) |
| | | // { |
| | | // List<SysDictData> list = dictDataService.selectDictDataList(dictData); |
| | | // ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class); |
| | | // util.exportExcel(response, list, "字典数据"); |
| | | // } |
| | | |
| | | /** |
| | | * 查询字典数据详细 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:query')") |
| | | @GetMapping(value = "/{dictCode}") |
| | | public AjaxResult getInfo(@PathVariable Long dictCode) |
| | | { |
| | | return success(dictDataService.selectDictDataById(dictCode)); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型查询字典数据信息 |
| | | */ |
| | | @ApiOperation(value = "根据字典类型查询字典数据信息") |
| | | @GetMapping(value = "/type/{dictType}") |
| | | public AjaxResult dictType(@PathVariable String dictType) |
| | | { |
| | | List<SysDictData> data = dictTypeService.selectDictDataByType(dictType); |
| | | if (StringUtils.isNull(data)) |
| | | { |
| | | data = new ArrayList<SysDictData>(); |
| | | } |
| | | return success(data); |
| | | } |
| | | |
| | | /** |
| | | * 新增字典类型 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:add')") |
| | | @Log(title = "字典数据", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysDictData dict) |
| | | { |
| | | dict.setCreateBy(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(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) |
| | | { |
| | | dictDataService.deleteDictDataByIds(dictCodes); |
| | | return success(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | 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.SysDictType; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | 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')") |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, SysDictType dictType) |
| | | // { |
| | | // List<SysDictType> list = dictTypeService.selectDictTypeList(dictType); |
| | | // ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class); |
| | | // util.exportExcel(response, list, "字典类型"); |
| | | // } |
| | | |
| | | /** |
| | | * 查询字典类型详细 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:query')") |
| | | @GetMapping(value = "/{dictId}") |
| | | public AjaxResult getInfo(@PathVariable Long dictId) |
| | | { |
| | | return success(dictTypeService.selectDictTypeById(dictId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增字典类型 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:add')") |
| | | @Log(title = "字典类型", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysDictType dict) |
| | | { |
| | | if (!dictTypeService.checkDictTypeUnique(dict)) |
| | | { |
| | | return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); |
| | | } |
| | | dict.setCreateBy(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 (!dictTypeService.checkDictTypeUnique(dict)) |
| | | { |
| | | return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); |
| | | } |
| | | dict.setUpdateBy(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) |
| | | { |
| | | dictTypeService.deleteDictTypeByIds(dictIds); |
| | | return success(); |
| | | } |
| | | |
| | | /** |
| | | * 刷新字典缓存 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:remove')") |
| | | @Log(title = "字典类型", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/refreshCache") |
| | | public AjaxResult refreshCache() |
| | | { |
| | | dictTypeService.resetDictCache(); |
| | | return success(); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典选择框列表 |
| | | */ |
| | | @GetMapping("/optionselect") |
| | | public AjaxResult optionselect() |
| | | { |
| | | List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll(); |
| | | return success(dictTypes); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | /** |
| | | * 首页 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | public class SysIndexController |
| | | { |
| | | /** 系统基础配置 */ |
| | | @Autowired |
| | | private RuoYiConfig ruoyiConfig; |
| | | |
| | | /** |
| | | * 访问首页,提示语 |
| | | */ |
| | | @RequestMapping("/") |
| | | public String index() |
| | | { |
| | | return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion()); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.web.controller.tool.MsgUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | 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.utils.SecurityUtils; |
| | | import com.ruoyi.framework.web.service.SysLoginService; |
| | | import com.ruoyi.framework.web.service.SysPermissionService; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | |
| | | /** |
| | | * 登录验证 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Api(tags = "登录") |
| | | @RestController |
| | | public class SysLoginController |
| | | { |
| | | @Autowired |
| | | private SysLoginService loginService; |
| | | |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | | @Autowired |
| | | private SysPermissionService permissionService; |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | @Autowired |
| | | private MsgUtils msgUtils; |
| | | |
| | | /** |
| | | * 账号密码登录 |
| | | * |
| | | * @param loginBody 登录信息 |
| | | * @return 结果 |
| | | */ |
| | | @ApiOperation(value = "账号密码登录",notes = "账号密码登录") |
| | | @PostMapping("/login") |
| | | public AjaxResult login(@RequestBody LoginBody loginBody) |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | // 生成令牌 |
| | | LoginUser loginUser = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), |
| | | loginBody.getUuid()); |
| | | ajax.put(Constants.TOKEN, tokenService.createToken(loginUser)); |
| | | List<SysRole> roles = loginUser.getUser().getRoles(); |
| | | if(CollectionUtils.isEmpty(roles)){ |
| | | return AjaxResult.error("请关联角色!"); |
| | | } |
| | | if(roles.get(0).getStatus() == 1){ |
| | | return AjaxResult.error("该账号角色已被禁用!"); |
| | | } |
| | | |
| | | List<SysMenu> menus = roleService.roleInfoFromUserId(loginUser.getUserId()); |
| | | |
| | | ajax.put("menus",menus); |
| | | ajax.put("roleName",roles.get(0).getRoleName()); |
| | | ajax.put("userInfo",loginUser); |
| | | return ajax; |
| | | } |
| | | |
| | | /** |
| | | * 账号密码登录 |
| | | * |
| | | * @param loginBody 登录信息 |
| | | * @return 结果 |
| | | */ |
| | | @ApiOperation(value = "短信登录",notes = "短信登录") |
| | | @PostMapping("/loginCode") |
| | | public AjaxResult loginCode(@RequestBody LoginBody loginBody) |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | // 生成令牌 |
| | | LoginUser loginUser = loginService.loginCode(loginBody.getUsername(), loginBody.getCode()); |
| | | ajax.put(Constants.TOKEN, tokenService.createToken(loginUser)); |
| | | List<SysRole> roles = loginUser.getUser().getRoles(); |
| | | if(CollectionUtils.isEmpty(roles)){ |
| | | return AjaxResult.error("请关联角色!"); |
| | | } |
| | | List<SysMenu> menus = roleService.roleInfoFromUserId(loginUser.getUserId()); |
| | | |
| | | ajax.put("menus",menus); |
| | | ajax.put("roleName",roles.get(0).getRoleName()); |
| | | ajax.put("userInfo",loginUser); |
| | | return ajax; |
| | | } |
| | | |
| | | /** |
| | | * 获取验证码 |
| | | * |
| | | * @param phone 手机号 |
| | | * @return 结果 |
| | | */ |
| | | @ApiOperation(value = "获取验证码",notes = "获取验证码") |
| | | @GetMapping("/getCode") |
| | | public AjaxResult getCode(@RequestParam String phone) |
| | | { |
| | | // 发送验证码并存储到redis |
| | | if (StringUtils.hasLength(phone)) { |
| | | String code = String.valueOf((int) (Math.random() * 1000000)); |
| | | redisCache.setCacheObject(phone, code,5*60,TimeUnit.SECONDS); |
| | | try { |
| | | msgUtils.sendMsg(phone, code); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return AjaxResult.success("发送短信验证码成功!5分钟内有效"); |
| | | } |
| | | return AjaxResult.error(500, "发送短信验证码失败,请确认手机号码!"); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户信息 |
| | | * |
| | | * @return 用户信息 |
| | | */ |
| | | @GetMapping("getInfo") |
| | | public AjaxResult getInfo() |
| | | { |
| | | SysUser user = SecurityUtils.getLoginUser().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() |
| | | { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId); |
| | | return AjaxResult.success(menuService.buildMenus(menus)); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | 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.SysMenu; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | |
| | | /** |
| | | * 菜单信息 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Api(tags = "菜单信息") |
| | | @RestController |
| | | @RequestMapping("/system/menu") |
| | | public class SysMenuController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | | @ApiOperation("菜单权限(有层级)") |
| | | @GetMapping("/levelList") |
| | | public AjaxResult levelList() |
| | | { |
| | | // 获取当前角色的菜单列表 |
| | | List<SysMenu> menus = menuService.selectList(); |
| | | if(menus.size()==0){ |
| | | return AjaxResult.success(new ArrayList<>()); |
| | | } |
| | | // 第三级 |
| | | List<SysMenu> s3 = menus.stream().filter(e -> e.getMenuType().equals("F")).collect(Collectors.toList()); |
| | | // 第二级 |
| | | List<SysMenu> s2 = menus.stream().filter(e -> e.getMenuType().equals("C")).collect(Collectors.toList()); |
| | | // 第一级 |
| | | List<SysMenu> s1 = menus.stream().filter(e -> e.getMenuType().equals("M")).collect(Collectors.toList()); |
| | | |
| | | for (SysMenu menu : s2) { |
| | | List<SysMenu> collect = s3.stream().filter(e -> e.getParentId().equals(menu.getMenuId())).collect(Collectors.toList()); |
| | | menu.setChildren(collect); |
| | | } |
| | | for (SysMenu menu : s1) { |
| | | List<SysMenu> collect = s2.stream().filter(e -> e.getParentId().equals(menu.getMenuId())).collect(Collectors.toList()); |
| | | menu.setChildren(collect); |
| | | } |
| | | |
| | | return AjaxResult.success(s1); |
| | | } |
| | | |
| | | /** |
| | | * 获取菜单列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:menu:list')") |
| | | @GetMapping("/list") |
| | | public AjaxResult list(SysMenu menu) |
| | | { |
| | | List<SysMenu> menus = menuService.selectMenuList(menu, getUserId()); |
| | | 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) |
| | | { |
| | | List<SysMenu> menus = menuService.selectMenuList(menu, getUserId()); |
| | | return AjaxResult.success(menuService.buildMenuTreeSelect(menus)); |
| | | } |
| | | |
| | | /** |
| | | * 加载对应角色菜单列表树 |
| | | */ |
| | | @GetMapping(value = "/roleMenuTreeselect/{roleId}") |
| | | public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) |
| | | { |
| | | List<SysMenu> menus = menuService.selectMenuList(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 (!menuService.checkMenuNameUnique(menu)) |
| | | { |
| | | return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); |
| | | } |
| | | else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) |
| | | { |
| | | return error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); |
| | | } |
| | | menu.setCreateBy(getUsername()); |
| | | return AjaxResult.success(menuService.insertMenu(menu)); |
| | | } |
| | | |
| | | /** |
| | | * 修改菜单 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:menu:edit')") |
| | | @Log(title = "菜单管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysMenu menu) |
| | | { |
| | | if (!menuService.checkMenuNameUnique(menu)) |
| | | { |
| | | return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); |
| | | } |
| | | else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) |
| | | { |
| | | return error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); |
| | | } |
| | | else if (menu.getMenuId().equals(menu.getParentId())) |
| | | { |
| | | return error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己"); |
| | | } |
| | | menu.setUpdateBy(getUsername()); |
| | | return AjaxResult.success(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 warn("存在子菜单,不允许删除"); |
| | | } |
| | | if (menuService.checkMenuExistRole(menuId)) |
| | | { |
| | | return warn("菜单已分配,不允许删除"); |
| | | } |
| | | return AjaxResult.success(menuService.deleteMenuById(menuId)); |
| | | } |
| | | } |
New file |
| | |
| | | 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.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 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(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(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)); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | 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.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')") |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, SysPost post) |
| | | // { |
| | | // List<SysPost> list = postService.selectPostList(post); |
| | | // ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class); |
| | | // util.exportExcel(response, list, "岗位数据"); |
| | | // } |
| | | |
| | | /** |
| | | * 根据岗位编号获取详细信息 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:post:query')") |
| | | @GetMapping(value = "/{postId}") |
| | | public AjaxResult getInfo(@PathVariable Long postId) |
| | | { |
| | | return success(postService.selectPostById(postId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增岗位 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:post:add')") |
| | | @Log(title = "岗位管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysPost post) |
| | | { |
| | | if (!postService.checkPostNameUnique(post)) |
| | | { |
| | | return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); |
| | | } |
| | | else if (!postService.checkPostCodeUnique(post)) |
| | | { |
| | | return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); |
| | | } |
| | | post.setCreateBy(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 (!postService.checkPostNameUnique(post)) |
| | | { |
| | | return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); |
| | | } |
| | | else if (!postService.checkPostCodeUnique(post)) |
| | | { |
| | | return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); |
| | | } |
| | | post.setUpdateBy(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 success(posts); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | 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.StringUtils; |
| | | import com.ruoyi.common.utils.file.FileUploadUtils; |
| | | import com.ruoyi.common.utils.file.MimeTypeUtils; |
| | | 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 = getLoginUser(); |
| | | 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) |
| | | { |
| | | LoginUser loginUser = getLoginUser(); |
| | | SysUser currentUser = loginUser.getUser(); |
| | | currentUser.setNickName(user.getNickName()); |
| | | currentUser.setEmail(user.getEmail()); |
| | | currentUser.setPhonenumber(user.getPhonenumber()); |
| | | currentUser.setSex(user.getSex()); |
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | | if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(currentUser)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); |
| | | } |
| | | if (userService.updateUserProfile(currentUser) > 0) |
| | | { |
| | | // 更新缓存用户信息 |
| | | tokenService.setLoginUser(loginUser); |
| | | return success(); |
| | | } |
| | | return error("修改个人信息异常,请联系管理员"); |
| | | } |
| | | |
| | | /** |
| | | * 重置密码 |
| | | */ |
| | | @Log(title = "个人信息", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/updatePwd") |
| | | public AjaxResult updatePwd(String oldPassword, String newPassword) |
| | | { |
| | | LoginUser loginUser = getLoginUser(); |
| | | String userName = loginUser.getUsername(); |
| | | String password = loginUser.getPassword(); |
| | | if (!SecurityUtils.matchesPassword(oldPassword, password)) |
| | | { |
| | | return error("修改密码失败,旧密码错误"); |
| | | } |
| | | if (SecurityUtils.matchesPassword(newPassword, password)) |
| | | { |
| | | return error("新密码不能与旧密码相同"); |
| | | } |
| | | if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) |
| | | { |
| | | // 更新缓存用户密码 |
| | | loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword)); |
| | | tokenService.setLoginUser(loginUser); |
| | | return success(); |
| | | } |
| | | return error("修改密码异常,请联系管理员"); |
| | | } |
| | | |
| | | /** |
| | | * 头像上传 |
| | | */ |
| | | @Log(title = "用户头像", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/avatar") |
| | | public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception |
| | | { |
| | | if (!file.isEmpty()) |
| | | { |
| | | LoginUser loginUser = getLoginUser(); |
| | | String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION); |
| | | if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("imgUrl", avatar); |
| | | // 更新缓存用户头像 |
| | | loginUser.getUser().setAvatar(avatar); |
| | | tokenService.setLoginUser(loginUser); |
| | | return ajax; |
| | | } |
| | | } |
| | | return error("上传图片异常,请联系管理员"); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.model.RegisterBody; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.SysRegisterService; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | |
| | | /** |
| | | * 注册验证 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | public class SysRegisterController extends BaseController |
| | | { |
| | | @Autowired |
| | | private SysRegisterService registerService; |
| | | |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | |
| | | @PostMapping("/register") |
| | | public AjaxResult register(@RequestBody RegisterBody user) |
| | | { |
| | | if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) |
| | | { |
| | | return error("当前系统没有开启注册功能!"); |
| | | } |
| | | String msg = registerService.register(user); |
| | | return StringUtils.isEmpty(msg) ? success() : error(msg); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | import com.ruoyi.system.dto.SysRoleDTO; |
| | | import com.ruoyi.system.query.SysRoleQuery; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | import com.ruoyi.system.vo.RoleInfoVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | 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.*; |
| | | 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.SysDept; |
| | | 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.StringUtils; |
| | | import com.ruoyi.framework.web.service.SysPermissionService; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import com.ruoyi.system.service.ISysDeptService; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | |
| | | /** |
| | | * 角色信息 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Api(tags = "角色信息") |
| | | @RestController |
| | | @RequestMapping("/system/role") |
| | | public class SysRoleController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @Autowired |
| | | private SysPermissionService permissionService; |
| | | |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private ISysDeptService deptService; |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | | @PreAuthorize("@ss.hasPermi('system:role')") |
| | | @ApiOperation(value = "角色列表") |
| | | @PostMapping("/list") |
| | | public AjaxResult list(@RequestBody SysRoleQuery query) |
| | | { |
| | | PageInfo<SysRole> list = roleService.selectPageList(query); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('system:role')") |
| | | @ApiOperation(value = "角色列表不分页") |
| | | @PostMapping("/listNotPage") |
| | | public AjaxResult list() |
| | | { |
| | | List<SysRole> list = roleService.selectRoleList(new SysRole()); |
| | | return AjaxResult.success(list); |
| | | } |
| | | @PreAuthorize("@ss.hasPermi('system:role:count')") |
| | | @ApiOperation(value = "角色数量统计") |
| | | @PostMapping("/roleCount") |
| | | public AjaxResult roleCount() |
| | | { |
| | | int all = roleService.selectCount(null); |
| | | int normal = roleService.selectCount(0); |
| | | int stop = roleService.selectCount(1); |
| | | |
| | | Map<String,Integer> map = new HashMap<>(); |
| | | map.put("all",all); |
| | | map.put("normal",normal); |
| | | map.put("stop",stop); |
| | | return AjaxResult.success(map); |
| | | } |
| | | |
| | | // @Log(title = "角色管理", businessType = BusinessType.EXPORT) |
| | | // // @PreAuthorize("@ss.hasPermi('system:role:export')") |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, SysRole role) |
| | | // { |
| | | // List<SysRole> list = roleService.selectRoleList(role); |
| | | // ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); |
| | | // util.exportExcel(response, list, "角色数据"); |
| | | // } |
| | | |
| | | /** |
| | | * 根据角色编号获取详细信息 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | @GetMapping(value = "/{roleId}") |
| | | public AjaxResult getInfo(@PathVariable Long roleId) |
| | | { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return AjaxResult.success(roleService.selectRoleById(roleId)); |
| | | } |
| | | |
| | | // @PreAuthorize("@ss.hasPermi('system:role:detail')") |
| | | @ApiOperation("角色详情") |
| | | @GetMapping("/roleInfo") |
| | | public AjaxResult roleInfo(@RequestParam Long roleId) |
| | | { |
| | | SysRole role = roleService.selectRoleById(roleId); |
| | | RoleInfoVO roleInfoVo = new RoleInfoVO(); |
| | | roleInfoVo.setRoleId(role.getRoleId()); |
| | | roleInfoVo.setRoleName(role.getRoleName()); |
| | | |
| | | // 获取当前角色的菜单列表 |
| | | List<SysMenu> menus = menuService.selectListByRoleId(roleId); |
| | | if(menus.size()==0){ |
| | | return AjaxResult.success(new ArrayList<>()); |
| | | } |
| | | List<Long> menusId = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList()); |
| | | |
| | | // 获取当前的权限菜单(有层级) |
| | | List<SysMenu> levelMenus = roleService.getMenuLevelList(menusId); |
| | | |
| | | roleInfoVo.setMenus(menusId); |
| | | return AjaxResult.success(roleInfoVo); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("用户获取权限菜单") |
| | | @GetMapping("/roleInfoFromUserId") |
| | | public AjaxResult roleInfoFromUserId(@RequestParam Long userId) |
| | | { |
| | | return AjaxResult.success(roleService.roleInfoFromUserId(userId)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新增角色 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:add')") |
| | | @ApiOperation(value = "新增角色") |
| | | @Log(title = "角色信息-新增角色", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | | public AjaxResult add(@Validated @RequestBody SysRoleDTO dto) |
| | | { |
| | | Boolean flag= roleService.isExit(dto.getRoleId(),dto.getRoleName()); |
| | | if(flag){ |
| | | return error("新增角色'" + dto.getRoleName() + "'失败,角色名称已存在"); |
| | | } |
| | | roleService.saveRole(dto); |
| | | return AjaxResult.success(); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 修改保存角色 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @ApiOperation(value = "编辑角色") |
| | | @Log(title = "角色信息-编辑角色", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysRoleDTO dto) |
| | | { |
| | | Boolean flag= roleService.isExit(dto.getRoleId(),dto.getRoleName()); |
| | | if (flag){ |
| | | return error("修改角色'" + dto.getRoleName() + "'失败,角色名称已存在"); |
| | | } |
| | | if (roleService.editRole(dto) > 0) |
| | | { |
| | | // 更新缓存用户权限 |
| | | LoginUser loginUser = getLoginUser(); |
| | | if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) |
| | | { |
| | | loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser())); |
| | | loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName())); |
| | | tokenService.setLoginUser(loginUser); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | return error("修改角色'" + dto.getRoleName() + "'失败,请联系管理员"); |
| | | } |
| | | |
| | | /** |
| | | * 修改保存数据权限 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "角色管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/dataScope") |
| | | public AjaxResult dataScope(@RequestBody SysRole role) |
| | | { |
| | | roleService.checkRoleAllowed(role); |
| | | roleService.checkRoleDataScope(role.getRoleId()); |
| | | return AjaxResult.success(roleService.authDataScope(role)); |
| | | } |
| | | |
| | | /** |
| | | * 状态修改 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @ApiOperation(value = "状态修改") |
| | | @Log(title = "角色信息-角色状态修改", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysRole role) |
| | | { |
| | | role.setUpdateBy(getUsername()); |
| | | roleService.updateStatus(role); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 删除角色 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:role:remove')") |
| | | @ApiOperation(value = "删除角色") |
| | | @Log(title = "角色信息-角色删除角色", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/deleteById/{ids}") |
| | | public AjaxResult remove(@PathVariable String ids) |
| | | { |
| | | String[] split = ids.split(","); |
| | | List<Long> id = new ArrayList<>(); |
| | | for (String s : split) { |
| | | id.add(Long.valueOf(s)); |
| | | } |
| | | return AjaxResult.success(roleService.deleteRoleByIds(id)); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色选择框列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | @GetMapping("/optionselect") |
| | | public AjaxResult optionselect() |
| | | { |
| | | return AjaxResult.success(roleService.selectRoleAll()); |
| | | } |
| | | |
| | | /** |
| | | * 查询已分配用户角色列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | @GetMapping("/authUser/allocatedList") |
| | | public TableDataInfo allocatedList(SysUser user) |
| | | { |
| | | // startPage(); |
| | | List<SysUser> list = userService.selectAllocatedList(user); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 查询未分配用户角色列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | @GetMapping("/authUser/unallocatedList") |
| | | public TableDataInfo unallocatedList(SysUser user) |
| | | { |
| | | // startPage(); |
| | | List<SysUser> list = userService.selectUnallocatedList(user); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 取消授权用户 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/cancel") |
| | | public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole) |
| | | { |
| | | return AjaxResult.success(roleService.deleteAuthUser(userRole)); |
| | | } |
| | | |
| | | /** |
| | | * 批量取消授权用户 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/cancelAll") |
| | | public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) |
| | | { |
| | | return AjaxResult.success(roleService.deleteAuthUsers(roleId, userIds)); |
| | | } |
| | | |
| | | /** |
| | | * 批量选择用户授权 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/selectAll") |
| | | public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds) |
| | | { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return AjaxResult.success(roleService.insertAuthUsers(roleId, userIds)); |
| | | } |
| | | |
| | | /** |
| | | * 获取对应角色部门树列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | @GetMapping(value = "/deptTree/{roleId}") |
| | | public AjaxResult deptTree(@PathVariable("roleId") Long roleId) |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); |
| | | ajax.put("depts", deptService.selectDeptTreeList(new SysDept())); |
| | | return ajax; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | 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.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.SysUserUpdateStatusDTO; |
| | | import com.ruoyi.system.query.SysUserQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.SysUserVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | 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.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 用户信息 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Api(tags = "用户信息") |
| | | @RestController |
| | | @RequestMapping("/system/user") |
| | | public class SysUserController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | |
| | | @Autowired |
| | | private ISysDeptService deptService; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | /** |
| | | * 获取用户列表 |
| | | */ |
| | | @ApiOperation(value = "获取用户列表") |
| | | @PostMapping("/list") |
| | | @PreAuthorize("@ss.hasPermi('system:user')") |
| | | public AjaxResult list(@RequestBody SysUserQuery query) |
| | | { |
| | | PageInfo<SysUserVO> list = userService.pageList(query); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取用户列表-不分页") |
| | | @PostMapping("/listNotPage") |
| | | @PreAuthorize("@ss.hasPermi('system:user')") |
| | | |
| | | public AjaxResult listNotPage() |
| | | { |
| | | List<SysUser> list = userService.selectList(); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户黑名单列表 |
| | | */ |
| | | // @ApiOperation(value = "获取用户黑名单列表") |
| | | // @PostMapping("/blacklist") |
| | | // public AjaxResult blacklist(@RequestBody SysUserQuery query) |
| | | // { |
| | | // startPage(query.getPageNum(), query.getPageSize()); |
| | | // List<SysUserVO> list = userService.selectBlackPageList(query); |
| | | // return AjaxResult.success(getDataTable(list)); |
| | | // } |
| | | |
| | | /** |
| | | * 获取用户详情 |
| | | */ |
| | | @ApiOperation(value = "获取用户详情") |
| | | @GetMapping("/getDetail") |
| | | public AjaxResult getDetail(@RequestParam Long userId) |
| | | { |
| | | SysUser sysUser = userService.selectUserById(userId); |
| | | SysUserVO sysUserVO = new SysUserVO(); |
| | | BeanUtils.copyProperties(sysUser,sysUserVO); |
| | | |
| | | return AjaxResult.success(sysUser); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户详情 |
| | | */ |
| | | @ApiOperation(value = "获取用户详情") |
| | | @GetMapping("/queryDetail") |
| | | public AjaxResult queryDetail() |
| | | { |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | SysUser sysUser = userService.selectUserById(userId); |
| | | SysUserVO sysUserVO = new SysUserVO(); |
| | | BeanUtils.copyProperties(sysUser,sysUserVO); |
| | | |
| | | return AjaxResult.success(sysUser); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取用户数量统计 |
| | | */ |
| | | @ApiOperation(value = "获取用户数量统计") |
| | | @PostMapping("/getUserCount") |
| | | public AjaxResult getUserCount() |
| | | { |
| | | Map<String,Integer> map = new HashMap<>(); |
| | | |
| | | Integer userCountSum = userService.selectCount(null); |
| | | Integer normalCount = userService.selectCount(0);// 正常 |
| | | Integer stopCount = userService.selectCount(1);// 停用 |
| | | |
| | | map.put("all",userCountSum); |
| | | map.put("normal",normalCount); |
| | | map.put("stop",stopCount); |
| | | |
| | | return AjaxResult.success(map); |
| | | } |
| | | |
| | | /** |
| | | * 移除黑名单 |
| | | */ |
| | | @GetMapping("/removeBlackList") |
| | | public AjaxResult removeBlackList(@RequestParam String ids) |
| | | { |
| | | String[] split = ids.split(","); |
| | | List<Long> id = new ArrayList<>(); |
| | | for (String s : split) { |
| | | id.add(Long.valueOf(s)); |
| | | } |
| | | userService.updateUserIfBlack(id); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 新增用户 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:add')") |
| | | @ApiOperation(value = "新增用户管理") |
| | | @Log(title = "用户信息-新增用户", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | | public AjaxResult add(@Validated @RequestBody SysUser user) |
| | | { |
| | | user.setUserName(user.getUserName()); |
| | | if (!userService.checkUserNameUnique(user)) |
| | | { |
| | | return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } |
| | | else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) |
| | | { |
| | | return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | | user.setCreateBy(getUsername()); |
| | | user.setPassword(SecurityUtils.encryptPassword("123456")); |
| | | userService.insertUser(user); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 修改用户 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | @ApiOperation(value = "修改用户管理") |
| | | @Log(title = "用户信息-修改用户", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/edit") |
| | | public AjaxResult edit(@Validated @RequestBody SysUser user) |
| | | { |
| | | user.setUserName(user.getPhonenumber()); |
| | | // userService.checkUserAllowed(user); |
| | | // userService.checkUserDataScope(user.getUserId()); |
| | | if (!userService.checkUserNameUnique(user)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } |
| | | else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | | |
| | | user.setUpdateBy(getUsername()); |
| | | if(StringUtils.isNotEmpty(user.getPassword())){ |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | } |
| | | return AjaxResult.success(userService.updateUser(user)); |
| | | } |
| | | |
| | | /** |
| | | * 删除用户 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:remove')") |
| | | @ApiOperation(value = "批量删除用户") |
| | | @Log(title = "用户信息-批量删除用户", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/deleteById/{ids}") |
| | | public AjaxResult remove(@PathVariable String ids) |
| | | { |
| | | String[] split = ids.split(","); |
| | | List<Long> userIds = new ArrayList<>(); |
| | | for (String s : split) { |
| | | userIds.add(Long.valueOf(s)); |
| | | } |
| | | if (userIds.contains(getUserId())) |
| | | { |
| | | return error("当前用户不能删除"); |
| | | } |
| | | return AjaxResult.success(userService.deleteUserByIds(userIds)); |
| | | } |
| | | |
| | | /** |
| | | * 重置密码 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:resetPwd')") |
| | | @ApiOperation(value = "重置密码") |
| | | @Log(title = "用户信息-重置密码", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/resetPwd") |
| | | public AjaxResult resetPwd(@RequestBody SysUser user) |
| | | { |
| | | userService.checkUserAllowed(user); |
| | | // userService.checkUserDataScope(user.getUserId()); |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | user.setUpdateBy(getUsername()); |
| | | return AjaxResult.success(userService.resetPwd(user)); |
| | | } |
| | | |
| | | /** |
| | | * 状态修改 |
| | | */ |
| | | @ApiOperation(value = "状态修改") |
| | | @Log(title = "用户信息-状态修改", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysUserUpdateStatusDTO dto) |
| | | { |
| | | SysUser loginUser = tokenService.getLoginUser().getUser(); |
| | | SysUser user = new SysUser(); |
| | | user.setUserId(dto.getUserId()); |
| | | user.setStatus(String.valueOf(dto.getStatus())); |
| | | // user.setRemark(dto.getRemark()); |
| | | user.setUpdateBy(getUsername()); |
| | | user.setDisableRemark(dto.getRemark()); |
| | | user.setOperatingTime(LocalDateTime.now()); |
| | | user.setOperatingPerson(loginUser.getNickName()+"("+loginUser.getUserName()+")"); |
| | | return AjaxResult.success(userService.updateUserStatus(user)); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户编号获取授权角色 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:query')") |
| | | @GetMapping("/authRole/{userId}") |
| | | public AjaxResult authRole(@PathVariable("userId") Long userId) |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | SysUser user = userService.selectUserById(userId); |
| | | List<SysRole> roles = roleService.selectRolesByUserId(userId); |
| | | ajax.put("user", user); |
| | | ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); |
| | | return ajax; |
| | | } |
| | | |
| | | /** |
| | | * 用户授权角色 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | @Log(title = "用户管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authRole") |
| | | public AjaxResult insertAuthRole(Long userId, Long[] roleIds) |
| | | { |
| | | userService.checkUserDataScope(userId); |
| | | userService.insertUserAuth(userId, roleIds); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 获取部门树列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:list')") |
| | | @GetMapping("/deptTree") |
| | | public AjaxResult deptTree(SysDept dept) |
| | | { |
| | | return AjaxResult.success(deptService.selectDeptTreeList(dept)); |
| | | } |
| | | } |
New file |
| | |
| | | //package com.ruoyi.web.controller.task; |
| | | // |
| | | // |
| | | //import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | //import com.ruoyi.common.utils.SmsUtil; |
| | | //import com.ruoyi.system.mapper.TBillMapper; |
| | | //import com.ruoyi.system.model.TBill; |
| | | //import com.ruoyi.system.model.TContract; |
| | | //import com.ruoyi.system.model.TContractRentType; |
| | | //import com.ruoyi.system.service.TBillService; |
| | | //import com.ruoyi.system.service.TContractRentTypeService; |
| | | //import com.ruoyi.system.service.TContractService; |
| | | //import org.springframework.beans.factory.annotation.Autowired; |
| | | //import org.springframework.scheduling.annotation.Scheduled; |
| | | //import org.springframework.stereotype.Component; |
| | | // |
| | | //import javax.annotation.Resource; |
| | | //import java.math.BigDecimal; |
| | | //import java.time.LocalDate; |
| | | //import java.time.LocalDateTime; |
| | | //import java.time.LocalTime; |
| | | //import java.time.ZoneId; |
| | | //import java.time.temporal.ChronoUnit; |
| | | //import java.time.temporal.TemporalAdjusters; |
| | | //import java.util.ArrayList; |
| | | //import java.util.Date; |
| | | //import java.util.List; |
| | | //import java.util.Random; |
| | | //import java.util.stream.Collectors; |
| | | // |
| | | ///** |
| | | // * @author zhibing.pu |
| | | // * @date 2023/7/11 8:39 |
| | | // */ |
| | | //@Component |
| | | //public class TaskUtil { |
| | | // @Autowired |
| | | // private TContractService contractService; |
| | | // @Autowired |
| | | // private TBillMapper billMapper; |
| | | // // 用于更新违约金账单 |
| | | // // 每分钟执行一次的定时任务 |
| | | // |
| | | // @Scheduled(cron = "0 * * * * ?") |
| | | // public void dayOfProportionBill() { |
| | | // try { |
| | | // // 查询所有未缴费账单 |
| | | // List<TBill> list = billMapper.selectList(new LambdaQueryWrapper<TBill>().eq(TBill::getPayFeesStatus, 1) |
| | | // .le(TBill::getPayableFeesTime,LocalDate.now())); |
| | | // for (TBill tBill : list) { |
| | | // tBill.setPayFeesStatus("4"); |
| | | // TContract contract = contractService.getById(tBill.getContractId()); |
| | | // LocalDate payableFeesTime = tBill.getPayableFeesTime(); |
| | | // // 将LocalDate转化为LocalDateTime |
| | | // LocalDateTime payableFeesTime1 = LocalDateTime.of(payableFeesTime, LocalTime.of(0, 0, 0)); |
| | | // LocalDateTime now = LocalDateTime.now(); |
| | | // // 计算两个时间相差多少个小时 |
| | | // long hours = ChronoUnit.HOURS.between(payableFeesTime1, now); |
| | | // long l = hours / 24; |
| | | // if (l>=3){ |
| | | // // 违约金比例 |
| | | // BigDecimal proportion = contract.getProportion(); |
| | | // // 按每天 待缴费金额 * XX% 增加违约金费用 |
| | | // if (tBill.getOutstandingMoney().compareTo(new BigDecimal("0"))==0){ |
| | | // tBill.setPayFeesStatus("3"); |
| | | // billMapper.updateById(tBill); |
| | | // continue; |
| | | // } |
| | | // BigDecimal money = tBill.getOutstandingMoney().multiply(new BigDecimal(100).add(proportion)).divide(new BigDecimal(100),2, BigDecimal.ROUND_DOWN); |
| | | // tBill.setOverDays((int) l); |
| | | // tBill.setPayableFeesPenalty((tBill.getPayableFeesPenalty()!=null?tBill.getPayableFeesPenalty():BigDecimal.ZERO).add(money)); |
| | | // tBill.setOutstandingMoney(money); |
| | | // billMapper.updateById(tBill); |
| | | // |
| | | // } |
| | | // } |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // |
| | | // |
| | | //} |
New file |
| | |
| | | package com.ruoyi.web.controller.tool; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.InputStream; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | |
| | | /** |
| | | * @author zhy |
| | | * @title: HttpClientUtil |
| | | * @projectName car_park |
| | | * @description: http连接工具类 |
| | | * @date 2019/10/2219:23 |
| | | */ |
| | | public class HttpClientUtil { |
| | | |
| | | |
| | | /** |
| | | * @param strUrl |
| | | * @return byte[] |
| | | * @throws |
| | | * @description: 获取网络图片转成字节流 |
| | | * @author zhy |
| | | * @date 2019/10/23 8:59 |
| | | */ |
| | | public static byte[] getImageFromNetByUrl(String strUrl) { |
| | | if (!isURL(strUrl)){ |
| | | return null; |
| | | } |
| | | try { |
| | | URL url = new URL(strUrl); |
| | | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
| | | conn.setRequestMethod("GET"); |
| | | conn.setConnectTimeout(2 * 1000); |
| | | InputStream inStream = conn.getInputStream();// 通过输入流获取图片数据 |
| | | byte[] btImg = readInputStream(inStream);// 得到图片的二进制数据 |
| | | return btImg; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 从输入流中获取字节流数据 |
| | | * |
| | | * @param inStream 输入流 |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static byte[] readInputStream(InputStream inStream) throws Exception { |
| | | ByteArrayOutputStream outStream = new ByteArrayOutputStream(); |
| | | byte[] buffer = new byte[10240]; |
| | | int len = 0; |
| | | while ((len = inStream.read(buffer)) != -1) { |
| | | outStream.write(buffer, 0, len); |
| | | } |
| | | inStream.close(); |
| | | return outStream.toByteArray(); |
| | | } |
| | | |
| | | public static boolean isURL(String str) { |
| | | str = str.toLowerCase(); |
| | | String regex = "^((https|http|ftp|rtsp|mms)?://)" |
| | | + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" |
| | | + "(([0-9]{1,3}\\.){3}[0-9]{1,3}" |
| | | + "|" |
| | | + "([0-9a-z_!~*'()-]+\\.)*" |
| | | + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\\." |
| | | + "[a-z]{2,6})" |
| | | + "(:[0-9]{1,5})?" |
| | | + "((/?)|" |
| | | + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$"; |
| | | return str.matches(regex); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.ruoyi.web.controller.tool; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 导出返回信息 |
| | | */ |
| | | @Slf4j |
| | | public class ImportExcelUtil { |
| | | |
| | | /** |
| | | * @param errorLines 错误行数 |
| | | * @param successLines 成功行数 |
| | | * @param errorMessage 错误信息 |
| | | * @return |
| | | * @throws IOException |
| | | */ |
| | | public static R<String> importReturnMsg(int errorLines, int successLines, List<String> errorMessage) throws IOException { |
| | | if (errorLines == 0) { |
| | | return R.ok("共" + successLines + "行数据全部导入成功!"); |
| | | } else { |
| | | JSONObject result = new JSONObject(5); |
| | | int totalCount = successLines + errorLines; |
| | | result.put("totalCount", totalCount); |
| | | result.put("errorCount", errorLines); |
| | | result.put("errorMessage", errorMessage); |
| | | result.put("successCount", successLines); |
| | | result.put("msg", "总上传行数:" + totalCount + ",已导入行数:" + successLines + ",错误行数:" + errorLines); |
| | | return R.ok(JSON.toJSONString(result)); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.tool; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.system.code.SubmitTemplateReg; |
| | | import org.apache.commons.codec.binary.Base64; |
| | | import org.apache.commons.codec.binary.Hex; |
| | | |
| | | import java.io.Serializable; |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | | /** |
| | | * 短信工具类 |
| | | */ |
| | | public class MsgCodeUtil implements Serializable { |
| | | |
| | | /**接口账号用户名*/ |
| | | private static final String AP_ID = ""; |
| | | /**企业名称*/ |
| | | private static final String EC_NAME = ""; |
| | | /**签名*/ |
| | | private static final String SECRET_KEY = ""; |
| | | /**签名编码*/ |
| | | private static final String SIGN = ""; |
| | | /**模板ID*/ |
| | | private static final String TEMPLATE_ID = ""; |
| | | |
| | | |
| | | /** |
| | | * 实体封装 |
| | | * @param code |
| | | * @return |
| | | */ |
| | | public static SubmitTemplateReg getSubmitTemplateReg(String code,String mobiles) { |
| | | SubmitTemplateReg submitReg =new SubmitTemplateReg(); |
| | | String[] paramss = {code}; |
| | | submitReg.setApId(AP_ID); |
| | | submitReg.setEcName(EC_NAME); |
| | | submitReg.setSecretKey(SECRET_KEY); |
| | | submitReg.setParams(JSONObject.toJSONString(paramss)); |
| | | submitReg.setMobiles(mobiles); |
| | | submitReg.setAddSerial(""); |
| | | submitReg.setSign(SIGN); |
| | | submitReg.setTemplateId(TEMPLATE_ID); |
| | | submitReg.setMac(TEMPLATE_ID); |
| | | StringBuffer stringBuffer = new StringBuffer(); |
| | | stringBuffer.append(submitReg.getEcName( ));stringBuffer.append(submitReg.getApId()); |
| | | stringBuffer.append(submitReg.getSecretKey());stringBuffer.append(submitReg.getTemplateId());stringBuffer.append(submitReg.getMobiles()); |
| | | stringBuffer.append(submitReg.getParams());stringBuffer.append(submitReg.getSign());stringBuffer.append(submitReg.getAddSerial()); |
| | | submitReg.setMac(Hex.encodeHexString(stringBuffer.toString().getBytes(StandardCharsets.UTF_8))); |
| | | String regText = JSONObject.toJSONString(submitReg); |
| | | //加密 |
| | | String encode = Base64.encodeBase64String(regText.getBytes()); |
| | | System.err.println(encode); |
| | | return submitReg; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | getSubmitTemplateReg("123456","18398968484"); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.tool; |
| | | |
| | | import com.aliyun.dysmsapi20170525.models.SendSmsRequest; |
| | | import com.aliyun.dysmsapi20170525.models.SendSmsResponse; |
| | | import com.aliyun.tea.TeaException; |
| | | import com.aliyun.teaopenapi.models.Config; |
| | | import com.aliyun.teautil.models.RuntimeOptions; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Component |
| | | @Slf4j |
| | | public class MsgUtils { |
| | | |
| | | @Value("${code.config.accessKeyId}") |
| | | private String accessKeyId; |
| | | @Value("${code.config.accessKeySecret}") |
| | | private String accessKeySecret; |
| | | @Value("${code.config.signName}") |
| | | private String signName; |
| | | @Value("${code.config.templateCode}") |
| | | private String templateCode; |
| | | @Value("${code.config.signNameTest}") |
| | | private String signNameTest; |
| | | @Value("${code.config.templateCodeTest}") |
| | | private String templateCodeTest; |
| | | |
| | | /** |
| | | * 使用AK&SK初始化账号Client |
| | | * @param accessKeyId |
| | | * @param accessKeySecret |
| | | * @return Client |
| | | * @throws Exception |
| | | */ |
| | | public static com.aliyun.dysmsapi20170525.Client createClient(String accessKeyId, String accessKeySecret) throws Exception { |
| | | Config config = new Config() |
| | | // 您的 AccessKey ID |
| | | .setAccessKeyId(accessKeyId) |
| | | // 您的 AccessKey Secret |
| | | .setAccessKeySecret(accessKeySecret); |
| | | // 访问的域名 |
| | | config.endpoint = "dysmsapi.aliyuncs.com"; |
| | | return new com.aliyun.dysmsapi20170525.Client(config); |
| | | } |
| | | |
| | | public void sendMsg(String phone,String code) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient(accessKeyId,accessKeySecret); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName(signName) |
| | | .setTemplateCode(templateCode) |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"code\":\""+code+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.core.config; |
| | | |
| | | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * @author xiaochen |
| | | * @ClassName DataUpdateInterceptor |
| | | * @Description 数据更新操作处理 |
| | | * @date 2021-12-15 |
| | | * <p> |
| | | * 注意,之前在此处注入了 JwtTokenUtils |
| | | * <p> |
| | | * 造成spring循环依赖,项目支棱不起来 |
| | | */ |
| | | @Slf4j |
| | | @Configuration |
| | | public class DataUpdateHandlerConfig implements MetaObjectHandler { |
| | | |
| | | /** |
| | | * 新增数据执行 |
| | | * |
| | | * @param metaObject |
| | | */ |
| | | @Override |
| | | public void insertFill(MetaObject metaObject) { |
| | | // 获取登录信息 |
| | | String userName = SecurityUtils.getUsername(); |
| | | if (StringUtils.isNotBlank(userName)) { |
| | | this.setFieldValByName("createBy", userName, metaObject); |
| | | this.setFieldValByName("updateBy", userName, metaObject); |
| | | } else { |
| | | this.setFieldValByName("createBy", userName, metaObject); |
| | | this.setFieldValByName("updateBy", userName, metaObject); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 修改数据执行 |
| | | * |
| | | * @param metaObject |
| | | */ |
| | | @Override |
| | | public void updateFill(MetaObject metaObject) { |
| | | // 获取登录信息 |
| | | String userName = SecurityUtils.getUsername(); |
| | | if (StringUtils.isNotBlank(userName)){ |
| | | this.setFieldValByName("createBy", userName, metaObject); |
| | | this.setFieldValByName("updateBy", userName, metaObject); |
| | | } else { |
| | | this.setFieldValByName("createBy", userName, metaObject); |
| | | this.setFieldValByName("updateBy", userName, metaObject); |
| | | } |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.core.config; |
| | | |
| | | import com.qcloud.cos.COSClient; |
| | | import com.qcloud.cos.ClientConfig; |
| | | import com.qcloud.cos.auth.BasicCOSCredentials; |
| | | import com.qcloud.cos.auth.COSCredentials; |
| | | import com.qcloud.cos.http.HttpProtocol; |
| | | import com.qcloud.cos.region.Region; |
| | | import lombok.Data; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration |
| | | @Data |
| | | public class FileUploaderConfig { |
| | | |
| | | /** |
| | | * COS的SecretId |
| | | */ |
| | | @Value("${cos.client.accessKey}") |
| | | private String secretId; |
| | | /** |
| | | * COS的SecretKey |
| | | */ |
| | | @Value("${cos.client.secretKey}") |
| | | private String secretKey; |
| | | /** |
| | | * 文件上传后访问路径的根路径,后面要最佳文件名字与类型 |
| | | */ |
| | | @Value("${cos.client.rootSrc}") |
| | | private String rootSrc; |
| | | /** |
| | | * 上传的存储桶的地域 |
| | | */ |
| | | @Value("${cos.client.bucketAddr}") |
| | | private String bucketAddr; |
| | | /** |
| | | * 存储桶的名字,是自己在存储空间自己创建的,我创建的名字是:qq-test-1303****** |
| | | */ |
| | | @Value("${cos.client.bucket}") |
| | | private String bucketName; |
| | | /** |
| | | * 文件存放位置 |
| | | */ |
| | | @Value("${cos.client.location}") |
| | | private String location; |
| | | |
| | | @Value("${file.url.prefix}") |
| | | private String fileUrlPrefix; |
| | | |
| | | |
| | | @Bean |
| | | public COSClient cosClient() { |
| | | // 1 初始化用户身份信息(secretId, secretKey)。 |
| | | COSCredentials cred = new BasicCOSCredentials(secretId, secretKey); |
| | | // 2.1 设置存储桶的地域(上文获得) |
| | | Region region = new Region(bucketAddr); |
| | | ClientConfig clientConfig = new ClientConfig(region); |
| | | // 2.2 使用https协议传输 |
| | | clientConfig.setHttpProtocol(HttpProtocol.https); |
| | | // 生成 cos 客户端 |
| | | return new COSClient(cred, clientConfig); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.core.config; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.DbType; |
| | | import com.baomidou.mybatisplus.core.config.GlobalConfig; |
| | | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * @author liheng |
| | | * @ClassName MybatisPlusConfig |
| | | * @Description MybatisPlus相关配置 |
| | | * @date 2020-09-22 11:22、 |
| | | * 直接以实现类作为bean的注入(有事务管理的类) |
| | | * @EnableTransactionManagement(proxyTargetClass = true) |
| | | */ |
| | | @Configuration |
| | | public class MybatisPlusConfig { |
| | | private final DataUpdateHandlerConfig dataUpdateHandler; |
| | | |
| | | @Autowired |
| | | public MybatisPlusConfig(DataUpdateHandlerConfig dataUpdateHandler) { |
| | | this.dataUpdateHandler = dataUpdateHandler; |
| | | } |
| | | |
| | | /** |
| | | * 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题 |
| | | */ |
| | | @Bean |
| | | public MybatisPlusInterceptor mybatisPlusInterceptor() { |
| | | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
| | | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); |
| | | return interceptor; |
| | | } |
| | | |
| | | /** |
| | | * 自动填充功能 |
| | | * |
| | | * @return |
| | | */ |
| | | @Bean |
| | | public GlobalConfig globalConfig() { |
| | | GlobalConfig globalConfig = new GlobalConfig(); |
| | | globalConfig.setMetaObjectHandler(dataUpdateHandler); |
| | | return globalConfig; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | 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 io.swagger.models.auth.In; |
| | | 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.service.SecurityScheme; |
| | | import springfox.documentation.spi.DocumentationType; |
| | | import springfox.documentation.spi.service.contexts.SecurityContext; |
| | | import springfox.documentation.spring.web.plugins.Docket; |
| | | |
| | | /** |
| | | * Swagger2的接口配置 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Configuration |
| | | 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.OAS_30) |
| | | // 是否启用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<SecurityScheme> securitySchemes() |
| | | { |
| | | List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>(); |
| | | apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue())); |
| | | return apiKeyList; |
| | | } |
| | | |
| | | /** |
| | | * 安全上下文 |
| | | */ |
| | | private List<SecurityContext> securityContexts() |
| | | { |
| | | List<SecurityContext> securityContexts = new ArrayList<>(); |
| | | securityContexts.add( |
| | | SecurityContext.builder() |
| | | .securityReferences(defaultAuth()) |
| | | .operationSelector(o -> o.requestMappingPattern().matches("/.*")) |
| | | .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("西藏国投接口文档") |
| | | // 作者信息 |
| | | .contact(new Contact(ruoyiConfig.getName(), null, null)) |
| | | // 版本 |
| | | .version("版本号:" + ruoyiConfig.getVersion()) |
| | | .build(); |
| | | } |
| | | } |
New file |
| | |
| | | restart.include.json=/com.alibaba.fastjson.*.jar |
New file |
| | |
| | | # 项目相关配置 |
| | | ruoyi: |
| | | # 名称 |
| | | name: RuoYi |
| | | # 版本 |
| | | version: 3.8.6 |
| | | # 版权年份 |
| | | copyrightYear: 2023 |
| | | # 实例演示开关 |
| | | demoEnabled: true |
| | | # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) |
| | | profile: D:/ruoyi/uploadPath |
| | | # 获取ip地址开关 |
| | | addressEnabled: false |
| | | # 验证码类型 math 数字计算 char 字符验证 |
| | | captchaType: math |
| | | # 开发环境配置 |
| | | server: |
| | | # 服务器的HTTP端口,默认为8080 |
| | | port: 8080 |
| | | servlet: |
| | | # 应用的访问路径 |
| | | context-path: / |
| | | tomcat: |
| | | # tomcat的URI编码 |
| | | uri-encoding: UTF-8 |
| | | # 连接数满后的排队数,默认为100 |
| | | accept-count: 1000 |
| | | threads: |
| | | # tomcat最大线程数,默认为200 |
| | | max: 800 |
| | | # Tomcat启动初始化的线程数,默认值10 |
| | | min-spare: 100 |
| | | |
| | | # 日志配置 |
| | | logging: |
| | | level: |
| | | com.ruoyi: debug |
| | | org.springframework: warn |
| | | |
| | | # 用户配置 |
| | | user: |
| | | password: |
| | | # 密码最大错误次数 |
| | | maxRetryCount: 5 |
| | | # 密码锁定时间(默认10分钟) |
| | | lockTime: 10 |
| | | |
| | | # Spring配置 |
| | | spring: |
| | | main: |
| | | allow-bean-definition-overriding: true |
| | | # 资源信息 |
| | | messages: |
| | | # 国际化资源文件路径 |
| | | basename: i18n/messages |
| | | # 文件上传 |
| | | servlet: |
| | | multipart: |
| | | # 单个文件大小 |
| | | max-file-size: 500MB |
| | | # 设置总上传的文件大小 |
| | | max-request-size: 2000MB |
| | | # 服务模块 |
| | | devtools: |
| | | restart: |
| | | # 热部署开关 |
| | | enabled: true |
| | | # redis 配置 |
| | | redis: |
| | | # 地址 |
| | | # host: 127.0.0.1 |
| | | # # 端口,默认为6379 |
| | | # port: 6379 |
| | | # # 数据库索引 |
| | | # database: 0 |
| | | # # 密码 |
| | | # password: 123456 |
| | | host: 127.0.0.1 |
| | | # 端口,默认为6379 |
| | | port: 16379 |
| | | # 数据库索引 |
| | | database: 0 |
| | | # 密码 |
| | | password: 8f5z9g52gx4bg |
| | | # 连接超时时间 |
| | | timeout: 10s |
| | | lettuce: |
| | | pool: |
| | | # 连接池中的最小空闲连接 |
| | | min-idle: 0 |
| | | # 连接池中的最大空闲连接 |
| | | max-idle: 8 |
| | | # 连接池的最大数据库连接数 |
| | | max-active: 8 |
| | | # #连接池最大阻塞等待时间(使用负值表示没有限制) |
| | | max-wait: -1ms |
| | | # 数据源配置 |
| | | datasource: |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | driverClassName: com.mysql.cj.jdbc.Driver |
| | | druid: |
| | | # 主库数据源 |
| | | master: |
| | | url: jdbc:mysql://172.27.0.13:3306/xizang?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai |
| | | username: xzgt |
| | | password: changyun!6f2gshj6h3j |
| | | # 从库数据源 |
| | | slave: |
| | | # 从数据源开关/默认关闭 |
| | | enabled: false |
| | | url: |
| | | username: |
| | | password: |
| | | # 初始连接数 |
| | | initialSize: 5 |
| | | # 最小连接池数量 |
| | | minIdle: 10 |
| | | # 最大连接池数量 |
| | | maxActive: 20 |
| | | # 配置获取连接等待超时的时间 |
| | | maxWait: 60000 |
| | | # 配置连接超时时间 |
| | | connectTimeout: 30000 |
| | | # 配置网络超时时间 |
| | | socketTimeout: 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: ruoyi |
| | | login-password: 123456 |
| | | filter: |
| | | stat: |
| | | enabled: true |
| | | # 慢SQL记录 |
| | | log-slow-sql: true |
| | | slow-sql-millis: 1000 |
| | | merge-sql: true |
| | | wall: |
| | | config: |
| | | multi-statement-allow: true |
| | | # token配置 |
| | | token: |
| | | # 令牌自定义标识 |
| | | header: Authorization |
| | | # 令牌密钥 |
| | | secret: abcdefghijklmnopqrstuvwxyz |
| | | # 令牌有效期(默认30分钟) |
| | | expireTime: 120 |
| | | |
| | | mybatis-plus: |
| | | # 此处在多数据源中生效 |
| | | config-location: classpath:/mybatis-config.xml |
| | | global-config: |
| | | banner: false |
| | | db-config: |
| | | logic-not-delete-value: 0 |
| | | logic-delete-value: 1 |
| | | type-aliases-package: com.ruoyi.**.domain,com.ruoyi.**.vo,com.ruoyi.**.model |
| | | # 指定Mapper文件位置 |
| | | mapper-locations: classpath*:mapper/**/*.xml |
| | | |
| | | # Swagger配置 |
| | | swagger: |
| | | # 是否开启swagger |
| | | enabled: true |
| | | # 请求前缀 |
| | | pathMapping: / |
| | | |
| | | # 防止XSS攻击 |
| | | xss: |
| | | # 过滤开关 |
| | | enabled: true |
| | | # 排除链接(多个用逗号分隔) |
| | | excludes: /system/notice |
| | | # 匹配链接 |
| | | urlPatterns: /system/*,/monitor/*,/tool/* |
| | | # file upload |
| | | file: |
| | | upload: |
| | | location: /file/ |
| | | qrLocation: /file/qrCode/ |
| | | accessPath: /file/ |
| | | allowExt: .jpg|.png|.gif|.jpeg|.doc|.docx|.apk|.MP4|.mp4|.pdf|.PDF |
| | | url: |
| | | prefix: https://xzgt.test.591taxi.cn:${server.port}${server.servlet.context-path} |
| | | wx: |
| | | conf: |
| | | appId: wxe91f1af7638aa5dd |
| | | secretId: a787e1a462715604e0c9528b6d8960d1 |
| | | #OSS及短信配置 |
| | | code: |
| | | config: |
| | | templateCodeTest: "SMS_154950909" |
| | | signNameTest: "阿里云短信测试" |
| | | accessKeyId: LTAI5tAdba8HtT1C6UqtSxBt |
| | | accessKeySecret: 0SRb6XGkciQDPWn2rYqbJtq2qRMDY8 |
| | | signName: "四川金达通信工程" |
| | | templateCode: "SMS_293985284" |
| | | cos: |
| | | client: |
| | | accessKey: AKIDCF5EF2c0DE1e5JK8r4EGJF4mNsMgp26x |
| | | secretKey: lLl184rUyFOOE0d5KNGC3kmfNsCWk4GU |
| | | bucket: xzgttest-1305134071 |
| | | bucketAddr: ap-chengdu |
| | | rootSrc: https://xzgttest-1305134071.cos.ap-chengdu.myqcloud.com/ |
| | | location: /xizang |
| | | sms: |
| | | enable: true |
| | | appId: 1400957506 |
| | | secretid: AKIDCF5EF2c0DE1e5JK8r4EGJF4mNsMgp26x |
| | | secretkey: lLl184rUyFOOE0d5KNGC3kmfNsCWk4GU |
| | | sign: 畅云出行 |
| | | com: |
| | | taxi591: |
| | | bank: |
| | | cer-path: /usr/local/bank/TrustPay.cer |
| | | base-url: http://hello.enjoy.abchina.com |
| | | enable: true |
| | | keystore-password: gggs6666 |
| | | pfx-path: /usr/local/bank/103882597000441.pfx |
New file |
| | |
| | | # 项目相关配置 |
| | | ruoyi: |
| | | # 名称 |
| | | name: RuoYi |
| | | # 版本 |
| | | version: 3.8.6 |
| | | # 版权年份 |
| | | copyrightYear: 2023 |
| | | # 实例演示开关 |
| | | demoEnabled: true |
| | | # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) |
| | | profile: D:/ruoyi/uploadPath |
| | | # 获取ip地址开关 |
| | | addressEnabled: false |
| | | # 验证码类型 math 数字计算 char 字符验证 |
| | | captchaType: math |
| | | # 开发环境配置 |
| | | server: |
| | | # 服务器的HTTP端口,默认为8080 |
| | | port: 8081 |
| | | servlet: |
| | | # 应用的访问路径 |
| | | context-path: / |
| | | tomcat: |
| | | # tomcat的URI编码 |
| | | uri-encoding: UTF-8 |
| | | # 连接数满后的排队数,默认为100 |
| | | accept-count: 1000 |
| | | threads: |
| | | # tomcat最大线程数,默认为200 |
| | | max: 800 |
| | | # Tomcat启动初始化的线程数,默认值10 |
| | | min-spare: 100 |
| | | |
| | | # 日志配置 |
| | | logging: |
| | | level: |
| | | com.ruoyi: debug |
| | | org.springframework: warn |
| | | |
| | | # 用户配置 |
| | | user: |
| | | password: |
| | | # 密码最大错误次数 |
| | | maxRetryCount: 5 |
| | | # 密码锁定时间(默认10分钟) |
| | | lockTime: 10 |
| | | |
| | | # Spring配置 |
| | | spring: |
| | | main: |
| | | allow-bean-definition-overriding: true |
| | | # 资源信息 |
| | | messages: |
| | | # 国际化资源文件路径 |
| | | basename: i18n/messages |
| | | # 文件上传 |
| | | servlet: |
| | | multipart: |
| | | # 单个文件大小 |
| | | max-file-size: 500MB |
| | | # 设置总上传的文件大小 |
| | | max-request-size: 2000MB |
| | | # 服务模块 |
| | | devtools: |
| | | restart: |
| | | # 热部署开关 |
| | | enabled: true |
| | | # redis 配置 |
| | | redis: |
| | | # 地址 |
| | | # host: 127.0.0.1 |
| | | # # 端口,默认为6379 |
| | | # port: 6379 |
| | | # # 数据库索引 |
| | | # database: 0 |
| | | # # 密码 |
| | | # password: 123456 |
| | | host: xzgt.test.591taxi.cn |
| | | # 端口,默认为6379 |
| | | port: 16379 |
| | | # 数据库索引 |
| | | database: 0 |
| | | # 密码 |
| | | password: 8f5z9g52gx4bg |
| | | # 连接超时时间 |
| | | timeout: 10s |
| | | lettuce: |
| | | pool: |
| | | # 连接池中的最小空闲连接 |
| | | min-idle: 0 |
| | | # 连接池中的最大空闲连接 |
| | | max-idle: 8 |
| | | # 连接池的最大数据库连接数 |
| | | max-active: 8 |
| | | # #连接池最大阻塞等待时间(使用负值表示没有限制) |
| | | max-wait: -1ms |
| | | # 数据源配置 |
| | | datasource: |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | driverClassName: com.mysql.cj.jdbc.Driver |
| | | druid: |
| | | # 主库数据源 |
| | | master: |
| | | url: jdbc:mysql://127.0.0.1:3306/laboratory?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai |
| | | username: root |
| | | password: 123456 |
| | | # 从库数据源 |
| | | slave: |
| | | # 从数据源开关/默认关闭 |
| | | enabled: false |
| | | url: |
| | | username: |
| | | password: |
| | | # 初始连接数 |
| | | initialSize: 5 |
| | | # 最小连接池数量 |
| | | minIdle: 10 |
| | | # 最大连接池数量 |
| | | maxActive: 20 |
| | | # 配置获取连接等待超时的时间 |
| | | maxWait: 60000 |
| | | # 配置连接超时时间 |
| | | connectTimeout: 30000 |
| | | # 配置网络超时时间 |
| | | socketTimeout: 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: ruoyi |
| | | login-password: 123456 |
| | | filter: |
| | | stat: |
| | | enabled: true |
| | | # 慢SQL记录 |
| | | log-slow-sql: true |
| | | slow-sql-millis: 1000 |
| | | merge-sql: true |
| | | wall: |
| | | config: |
| | | multi-statement-allow: true |
| | | # token配置 |
| | | token: |
| | | # 令牌自定义标识 |
| | | header: Authorization |
| | | # 令牌密钥 |
| | | secret: abcdefghijklmnopqrstuvwxyz |
| | | # 令牌有效期(默认30分钟) |
| | | expireTime: 120 |
| | | |
| | | mybatis-plus: |
| | | # 此处在多数据源中生效 |
| | | config-location: classpath:/mybatis-config.xml |
| | | global-config: |
| | | banner: false |
| | | db-config: |
| | | logic-not-delete-value: 0 |
| | | logic-delete-value: 1 |
| | | type-aliases-package: com.ruoyi.**.domain,com.ruoyi.**.vo,com.ruoyi.**.model |
| | | # 指定Mapper文件位置 |
| | | mapper-locations: classpath*:mapper/**/*.xml |
| | | |
| | | # Swagger配置 |
| | | swagger: |
| | | # 是否开启swagger |
| | | enabled: true |
| | | # 请求前缀 |
| | | pathMapping: / |
| | | |
| | | # 防止XSS攻击 |
| | | xss: |
| | | # 过滤开关 |
| | | enabled: true |
| | | # 排除链接(多个用逗号分隔) |
| | | excludes: /system/notice |
| | | # 匹配链接 |
| | | urlPatterns: /system/*,/monitor/*,/tool/* |
| | | # file upload |
| | | file: |
| | | upload: |
| | | location: /file/ |
| | | qrLocation: /file/qrCode/ |
| | | accessPath: /file/ |
| | | allowExt: .jpg|.png|.gif|.jpeg|.doc|.docx|.apk|.MP4|.mp4|.pdf|.PDF |
| | | url: |
| | | # prefix: http://localhost:${server.port}${server.servlet.context-path} |
| | | prefix: https://xzgt.test.591taxi.cn:${server.port}${server.servlet.context-path} |
| | | wx: |
| | | conf: |
| | | appId: wxe91f1af7638aa5dd |
| | | secretId: a787e1a462715604e0c9528b6d8960d1 |
| | | #OSS及短信配置 |
| | | code: |
| | | config: |
| | | templateCodeTest: "SMS_154950909" |
| | | signNameTest: "阿里云短信测试" |
| | | accessKeyId: LTAI5tAdba8HtT1C6UqtSxBt |
| | | accessKeySecret: 0SRb6XGkciQDPWn2rYqbJtq2qRMDY8 |
| | | signName: "四川金达通信工程" |
| | | templateCode: "SMS_293985284" |
| | | cos: |
| | | client: |
| | | accessKey: AKIDCF5EF2c0DE1e5JK8r4EGJF4mNsMgp26x |
| | | secretKey: lLl184rUyFOOE0d5KNGC3kmfNsCWk4GU |
| | | bucket: xzgttest-1305134071 |
| | | bucketAddr: ap-chengdu |
| | | rootSrc: https://xzgttest-1305134071.cos.ap-chengdu.myqcloud.com/ |
| | | location: /xizang |
| | | sms: |
| | | enable: true |
| | | appId: 1400957506 |
| | | secretid: AKIDCF5EF2c0DE1e5JK8r4EGJF4mNsMgp26x |
| | | secretkey: lLl184rUyFOOE0d5KNGC3kmfNsCWk4GU |
| | | sign: 畅云出行 |
| | | com: |
| | | taxi591: |
| | | bank: |
| | | cer-path: D:\workspaces\工作文件\畅云\农业银行\正式\TrustPay.cer |
| | | base-url: http://hello.enjoy.abchina.com |
| | | enable: true |
| | | keystore-password: gggs6666 |
| | | pfx-path: D:\workspaces\工作文件\畅云\农业银行\正式\103882597000441.pfx |
New file |
| | |
| | | # 项目相关配置 |
| | | spring: |
| | | profiles: |
| | | active: test |
New file |
| | |
| | | Application Version: ${ruoyi.version} |
| | | Spring Boot Version: ${spring-boot.version} |
| | | //////////////////////////////////////////////////////////////////// |
| | | // _ooOoo_ // |
| | | // o8888888o // |
| | | // 88" . "88 // |
| | | // (| ^_^ |) // |
| | | // O\ = /O // |
| | | // ____/`---'\____ // |
| | | // .' \\| |// `. // |
| | | // / \\||| : |||// \ // |
| | | // / _||||| -:- |||||- \ // |
| | | // | | \\\ - /// | | // |
| | | // | \_| ''\---/'' | | // |
| | | // \ .-\__ `-` ___/-. / // |
| | | // ___`. .' /--.--\ `. . ___ // |
| | | // ."" '< `.___\_<|>_/___.' >'"". // |
| | | // | | : `- \`.;`\ _ /`;.`/ - ` : | | // |
| | | // \ \ `-. \_ __\ /__ _/ .-` / / // |
| | | // ========`-.____`-.___\_____/___.-`____.-'======== // |
| | | // `=---=' // |
| | | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // |
| | | // 佛祖保佑 永不宕机 永无BUG // |
| | | //////////////////////////////////////////////////////////////////// |
New file |
| | |
| | | #错误消息 |
| | | not.null=* 必须填写 |
| | | user.jcaptcha.error=验证码错误 |
| | | user.jcaptcha.expire=验证码已失效 |
| | | user.not.exists=用户不存在/密码错误 |
| | | user.password.not.match=用户不存在/密码错误 |
| | | user.password.retry.limit.count=密码输入错误{0}次 |
| | | user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定{1}分钟 |
| | | user.password.delete=对不起,您的账号已被删除 |
| | | user.blocked=用户已封禁,请联系管理员 |
| | | role.blocked=角色已封禁,请联系管理员 |
| | | login.blocked=很遗憾,访问IP已被列入系统黑名单 |
| | | user.logout.success=退出成功 |
| | | |
| | | length.not.valid=长度必须在{min}到{max}个字符之间 |
| | | |
| | | user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成,且必须以非数字开头 |
| | | user.password.not.valid=* 5-50个字符 |
| | | |
| | | user.email.not.valid=邮箱格式错误 |
| | | user.mobile.phone.number.not.valid=手机号格式错误 |
| | | user.login.success=登录成功 |
| | | user.register.success=注册成功 |
| | | user.notfound=请重新登录 |
| | | user.forcelogout=管理员强制退出,请重新登录 |
| | | user.unknown.error=未知错误,请重新登录 |
| | | |
| | | ##文件上传消息 |
| | | upload.exceed.maxSize=上传的文件大小超出限制的文件大小!<br/>允许的文件最大大小是:{0}MB! |
| | | upload.filename.exceed.length=上传的文件名最长{0}个字符 |
| | | |
| | | ##权限 |
| | | no.permission=您没有数据的权限,请联系管理员添加权限 [{0}] |
| | | no.create.permission=您没有创建数据的权限,请联系管理员添加权限 [{0}] |
| | | no.update.permission=您没有修改数据的权限,请联系管理员添加权限 [{0}] |
| | | no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}] |
| | | no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}] |
| | | no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}] |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <configuration> |
| | | <!-- 日志存放路径 --> |
| | | <property name="log.path" value="/home/ruoyi/logs" /> |
| | | <!-- 日志输出格式 --> |
| | | <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" /> |
| | | |
| | | <!-- 控制台输出 --> |
| | | <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> |
| | | <encoder> |
| | | <pattern>${log.pattern}</pattern> |
| | | </encoder> |
| | | </appender> |
| | | |
| | | <!-- 系统日志输出 --> |
| | | <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <file>${log.path}/sys-info.log</file> |
| | | <!-- 循环政策:基于时间创建日志文件 --> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
| | | <!-- 日志文件名格式 --> |
| | | <fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern> |
| | | <!-- 日志最大的历史 60天 --> |
| | | <maxHistory>60</maxHistory> |
| | | </rollingPolicy> |
| | | <encoder> |
| | | <pattern>${log.pattern}</pattern> |
| | | </encoder> |
| | | <filter class="ch.qos.logback.classic.filter.LevelFilter"> |
| | | <!-- 过滤的级别 --> |
| | | <level>INFO</level> |
| | | <!-- 匹配时的操作:接收(记录) --> |
| | | <onMatch>ACCEPT</onMatch> |
| | | <!-- 不匹配时的操作:拒绝(不记录) --> |
| | | <onMismatch>DENY</onMismatch> |
| | | </filter> |
| | | </appender> |
| | | |
| | | <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <file>${log.path}/sys-error.log</file> |
| | | <!-- 循环政策:基于时间创建日志文件 --> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
| | | <!-- 日志文件名格式 --> |
| | | <fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern> |
| | | <!-- 日志最大的历史 60天 --> |
| | | <maxHistory>60</maxHistory> |
| | | </rollingPolicy> |
| | | <encoder> |
| | | <pattern>${log.pattern}</pattern> |
| | | </encoder> |
| | | <filter class="ch.qos.logback.classic.filter.LevelFilter"> |
| | | <!-- 过滤的级别 --> |
| | | <level>ERROR</level> |
| | | <!-- 匹配时的操作:接收(记录) --> |
| | | <onMatch>ACCEPT</onMatch> |
| | | <!-- 不匹配时的操作:拒绝(不记录) --> |
| | | <onMismatch>DENY</onMismatch> |
| | | </filter> |
| | | </appender> |
| | | |
| | | <!-- 用户访问日志输出 --> |
| | | <appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <file>${log.path}/sys-user.log</file> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
| | | <!-- 按天回滚 daily --> |
| | | <fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern> |
| | | <!-- 日志最大的历史 60天 --> |
| | | <maxHistory>60</maxHistory> |
| | | </rollingPolicy> |
| | | <encoder> |
| | | <pattern>${log.pattern}</pattern> |
| | | </encoder> |
| | | </appender> |
| | | |
| | | <!-- 系统模块日志级别控制 --> |
| | | <logger name="com.ruoyi" level="info" /> |
| | | <!-- Spring日志级别控制 --> |
| | | <logger name="org.springframework" level="warn" /> |
| | | |
| | | <root level="info"> |
| | | <appender-ref ref="console" /> |
| | | </root> |
| | | |
| | | <!--系统操作日志--> |
| | | <root level="info"> |
| | | <appender-ref ref="file_info" /> |
| | | <appender-ref ref="file_error" /> |
| | | </root> |
| | | |
| | | <!--系统用户操作日志--> |
| | | <logger name="sys-user" level="info"> |
| | | <appender-ref ref="sys-user"/> |
| | | </logger> |
| | | </configuration> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> |
| | | <configuration> |
| | | |
| | | <settings> |
| | | <!-- 打印查询语句 不会写入到日志文件中--> |
| | | <setting name="logImpl" value="STDOUT_LOGGING"/> |
| | | <!--<setting name="logImpl" value="LOG4J" />--> |
| | | <!-- 控制全局缓存(二级缓存),按美团技术团队的说法,尽量别用缓存机制 emmmm.... --> |
| | | <setting name="cacheEnabled" value="true"/> |
| | | <!-- 延迟加载的全局开关。当开启时,所有关联对象都会延迟加载。默认 false --> |
| | | <!-- <setting name="lazyLoadingEnabled" value="true"/> --> |
| | | <setting name="mapUnderscoreToCamelCase" value="true"/><!--是否将map下划线方式转为驼峰式命名--> |
| | | <!-- 当开启时,任何方法的调用都会加载该对象的所有属性。默认 false,可通过select标签的 fetchType来覆盖--> |
| | | <!-- <setting name="aggressiveLazyLoading" value="false"/>--> |
| | | <!-- Mybatis 创建具有延迟加载能力的对象所用到的代理工具,默认JAVASSIST --> |
| | | <!--<setting name="proxyFactory" value="CGLIB" />--> |
| | | <!-- 关于mybatis的一二级缓存 请参照:https://tech.meituan.com/2018/01/19/mybatis-cache.html --> |
| | | <!-- 一级缓存范围默认:SESSION ,此范围在复杂应用场景中可能会出现脏读数据--> |
| | | <!-- STATEMENT级别的缓存,使一级缓存,只针对当前执行的这一statement有效 --> |
| | | <!--<setting name="localCacheScope" value="STATEMENT"/>--> |
| | | <setting name="localCacheScope" value="STATEMENT"/> |
| | | </settings> |
| | | |
| | | </configuration> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE configuration |
| | | PUBLIC "-//mybatis.org//DTD Config 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-config.dtd"> |
| | | <configuration> |
| | | <!-- 全局参数 --> |
| | | <settings> |
| | | <!-- 使全局的映射器启用或禁用缓存 --> |
| | | <setting name="cacheEnabled" value="true" /> |
| | | <!-- 允许JDBC 支持自动生成主键 --> |
| | | <setting name="useGeneratedKeys" value="true" /> |
| | | <!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 --> |
| | | <setting name="defaultExecutorType" value="SIMPLE" /> |
| | | <!-- 指定 MyBatis 所用日志的具体实现 --> |
| | | <setting name="logImpl" value="SLF4J" /> |
| | | <!-- 使用驼峰命名法转换字段 --> |
| | | <!-- <setting name="mapUnderscoreToCamelCase" value="true"/> --> |
| | | </settings> |
| | | |
| | | </configuration> |
New file |
| | |
| | | <?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.8.6</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <packaging>jar</packaging> |
| | | <artifactId>ruoyi-applet</artifactId> |
| | | |
| | | <description> |
| | | web服务入口 |
| | | </description> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>com.aliyun.oss</groupId> |
| | | <artifactId>aliyun-sdk-oss</artifactId> |
| | | <version>3.8.0</version> |
| | | </dependency> |
| | | <!-- spring-boot-devtools --> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-devtools</artifactId> |
| | | <optional>true</optional> <!-- 表示依赖不会传递 --> |
| | | </dependency> |
| | | |
| | | <!-- swagger3--> |
| | | <dependency> |
| | | <groupId>io.springfox</groupId> |
| | | <artifactId>springfox-boot-starter</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>com.github.xiaoymin</groupId>--> |
| | | <!-- <artifactId>swagger-bootstrap-ui</artifactId>--> |
| | | <!-- <version>1.9.6</version>--> |
| | | <!-- </dependency>--> |
| | | |
| | | |
| | | <!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 --> |
| | | <dependency> |
| | | <groupId>io.swagger</groupId> |
| | | <artifactId>swagger-models</artifactId> |
| | | <version>1.6.2</version> |
| | | </dependency> |
| | | |
| | | <!-- Mysql驱动包 --> |
| | | <dependency> |
| | | <groupId>mysql</groupId> |
| | | <artifactId>mysql-connector-java</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- 核心模块--> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-framework</artifactId> |
| | | <!-- <exclusions>--> |
| | | <!-- <exclusion>--> |
| | | <!-- <groupId>com.github.pagehelper</groupId>--> |
| | | <!-- <artifactId>pagehelper-spring-boot-starter</artifactId>--> |
| | | <!-- </exclusion>--> |
| | | <!-- </exclusions>--> |
| | | </dependency> |
| | | |
| | | <!-- 定时任务--> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-quartz</artifactId> |
| | | <!-- <exclusions>--> |
| | | <!-- <exclusion>--> |
| | | <!-- <groupId>com.github.pagehelper</groupId>--> |
| | | <!-- <artifactId>pagehelper-spring-boot-starter</artifactId>--> |
| | | <!-- </exclusion>--> |
| | | <!-- </exclusions>--> |
| | | </dependency> |
| | | |
| | | <!-- 代码生成--> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-generator</artifactId> |
| | | <!-- <exclusions>--> |
| | | <!-- <exclusion>--> |
| | | <!-- <groupId>com.github.pagehelper</groupId>--> |
| | | <!-- <artifactId>pagehelper-spring-boot-starter</artifactId>--> |
| | | <!-- </exclusion>--> |
| | | <!-- </exclusions>--> |
| | | </dependency> |
| | | |
| | | <!-- zxing生成二维码 --> |
| | | <dependency> |
| | | <groupId>com.google.zxing</groupId> |
| | | <artifactId>core</artifactId> |
| | | <version>3.3.3</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.google.zxing</groupId> |
| | | <artifactId>javase</artifactId> |
| | | <version>3.3.3</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.springframework</groupId> |
| | | <artifactId>spring-test</artifactId> |
| | | <version>5.1.3.RELEASE</version> |
| | | </dependency> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>org.apache.httpcomponents</groupId>--> |
| | | <!-- <artifactId>httpcore</artifactId>--> |
| | | <!-- <version>4.3.2</version>--> |
| | | <!-- </dependency>--> |
| | | |
| | | <dependency> |
| | | <groupId>com.squareup.okhttp3</groupId> |
| | | <artifactId>okhttp</artifactId> |
| | | <version>4.9.3</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>fastjson</artifactId> |
| | | <version>1.2.78</version> |
| | | </dependency> |
| | | |
| | | <!-- easypoi --> |
| | | <dependency> |
| | | <groupId>cn.afterturn</groupId> |
| | | <artifactId>easypoi-base</artifactId> |
| | | <version>3.0.3</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>cn.afterturn</groupId> |
| | | <artifactId>easypoi-web</artifactId> |
| | | <version>3.0.3</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>cn.afterturn</groupId> |
| | | <artifactId>easypoi-annotation</artifactId> |
| | | <version>3.0.3</version> |
| | | </dependency> |
| | | |
| | | <!-- 阿里云短信 --> |
| | | <dependency> |
| | | <groupId>com.aliyun</groupId> |
| | | <artifactId>dysmsapi20170525</artifactId> |
| | | <version>2.0.10</version> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | <version>2.5.15</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.1.0</version> |
| | | <configuration> |
| | | <failOnMissingWebXml>false</failOnMissingWebXml> |
| | | <warName>${project.artifactId}</warName> |
| | | </configuration> |
| | | </plugin> |
| | | </plugins> |
| | | <finalName>${project.artifactId}</finalName> |
| | | </build> |
| | | |
| | | </project> |
New file |
| | |
| | | package com.ruoyi; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
| | | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; |
| | | import org.springframework.context.ConfigurableApplicationContext; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.core.env.Environment; |
| | | import org.springframework.http.client.SimpleClientHttpRequestFactory; |
| | | import org.springframework.scheduling.annotation.EnableScheduling; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.net.UnknownHostException; |
| | | |
| | | /** |
| | | * 启动程序 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Slf4j |
| | | @EnableScheduling//开启定时任务 |
| | | @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) |
| | | public class RuoYiAppletApplication |
| | | { |
| | | public static void main(String[] args) { |
| | | |
| | | |
| | | ConfigurableApplicationContext application = SpringApplication.run(RuoYiAppletApplication.class, args); |
| | | try { |
| | | |
| | | Environment env = application.getEnvironment(); |
| | | log.info("\n----------------------------------------------------------\n\t" + |
| | | "应用 '{}' 运行成功! 访问连接:\n\t" + |
| | | "Swagger文档: \t\thttp://{}:{}/doc.html\n" + |
| | | "----------------------------------------------------------", |
| | | env.getProperty("spring.application.name", "后台"), |
| | | InetAddress.getLocalHost().getHostAddress(), |
| | | env.getProperty("server.port", "8081")); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 当不存在此 wxRestTemplate 使用此方法的bean注入 |
| | | * |
| | | * @return |
| | | */ |
| | | @Bean |
| | | @ConditionalOnMissingBean(name = "restTemplate") |
| | | public RestTemplate wxRestTemplate() { |
| | | //复杂构造函数的使用 |
| | | SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); |
| | | // 设置超时 |
| | | requestFactory.setConnectTimeout(6000); |
| | | requestFactory.setReadTimeout(6000); |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | restTemplate.setRequestFactory(requestFactory); |
| | | return restTemplate; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi; |
| | | |
| | | import org.springframework.boot.builder.SpringApplicationBuilder; |
| | | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
| | | |
| | | /** |
| | | * web容器中进行部署 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class RuoYiServletInitializer extends SpringBootServletInitializer |
| | | { |
| | | @Override |
| | | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) |
| | | { |
| | | return application.sources(RuoYiAppletApplication.class); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.aspect; |
| | | |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.annotation.Before; |
| | | import org.aspectj.lang.annotation.Pointcut; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | |
| | | @Aspect |
| | | @Component |
| | | |
| | | public class StateAspect { |
| | | |
| | | @Autowired |
| | | private ISysUserService sysUserService; |
| | | |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | @Pointcut("execution(* com.ruoyi.web.controller.manage.*.*(..)) && !execution( * com.ruoyi.web.controller.manage.LoginController.*.*(..))") |
| | | public void state(){} |
| | | |
| | | @Before("state()") |
| | | public void isfrozen(){ |
| | | System.err.println("进入切面"); |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | SysUser sysUser = sysUserService.selectUserById(loginUser.getUserId()); |
| | | if (sysUser.getStatus().equals("1")){ |
| | | throw new ServiceException("当前账号已停用"); |
| | | } |
| | | if (roleService.selectRoleByUserId(sysUser.getUserId()).getStatus()==1){ |
| | | throw new ServiceException("当前角色已停用"); |
| | | }; |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.common; |
| | | |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.IOException; |
| | | import java.util.concurrent.TimeUnit; |
| | | import javax.annotation.Resource; |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.FastByteArrayOutputStream; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.google.code.kaptcha.Producer; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.constant.CacheConstants; |
| | | 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.sign.Base64; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | |
| | | /** |
| | | * 验证码操作处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | public class CaptchaController |
| | | { |
| | | @Resource(name = "captchaProducer") |
| | | private Producer captchaProducer; |
| | | |
| | | @Resource(name = "captchaProducerMath") |
| | | private Producer captchaProducerMath; |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | /** |
| | | * 生成验证码 |
| | | */ |
| | | @GetMapping("/captchaImage") |
| | | public AjaxResult getCode(HttpServletResponse response) throws IOException |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | boolean captchaEnabled = configService.selectCaptchaEnabled(); |
| | | ajax.put("captchaEnabled", captchaEnabled); |
| | | if (!captchaEnabled) |
| | | { |
| | | return ajax; |
| | | } |
| | | |
| | | // 保存验证码信息 |
| | | String uuid = IdUtils.simpleUUID(); |
| | | String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid; |
| | | |
| | | String capStr = null, code = null; |
| | | BufferedImage image = null; |
| | | |
| | | // 生成验证码 |
| | | String captchaType = RuoYiConfig.getCaptchaType(); |
| | | if ("math".equals(captchaType)) |
| | | { |
| | | String capText = captchaProducerMath.createText(); |
| | | capStr = capText.substring(0, capText.lastIndexOf("@")); |
| | | code = capText.substring(capText.lastIndexOf("@") + 1); |
| | | image = captchaProducerMath.createImage(capStr); |
| | | } |
| | | else if ("char".equals(captchaType)) |
| | | { |
| | | capStr = code = captchaProducer.createText(); |
| | | image = captchaProducer.createImage(capStr); |
| | | } |
| | | |
| | | redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES); |
| | | // 转换流信息写出 |
| | | FastByteArrayOutputStream os = new FastByteArrayOutputStream(); |
| | | try |
| | | { |
| | | ImageIO.write(image, "jpg", os); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | ajax.put("uuid", uuid); |
| | | ajax.put("img", Base64.encode(os.toByteArray())); |
| | | return ajax; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.common; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | 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.http.MediaType; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | 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 |
| | | @RequestMapping("/common") |
| | | public class CommonController |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(CommonController.class); |
| | | |
| | | @Autowired |
| | | private ServerConfig serverConfig; |
| | | |
| | | private static final String FILE_DELIMETER = ","; |
| | | |
| | | /** |
| | | * 通用下载请求 |
| | | * |
| | | * @param fileName 文件名称 |
| | | * @param delete 是否删除 |
| | | */ |
| | | @GetMapping("/download") |
| | | public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) |
| | | { |
| | | try |
| | | { |
| | | if (!FileUtils.checkAllowDownload(fileName)) |
| | | { |
| | | throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName)); |
| | | } |
| | | String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); |
| | | String filePath = RuoYiConfig.getDownloadPath() + fileName; |
| | | |
| | | response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
| | | FileUtils.setAttachmentResponseHeader(response, realFileName); |
| | | FileUtils.writeBytes(filePath, response.getOutputStream()); |
| | | if (delete) |
| | | { |
| | | FileUtils.deleteFile(filePath); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | log.error("下载文件失败", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 通用上传请求(单个) |
| | | */ |
| | | @PostMapping("/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("url", url); |
| | | ajax.put("fileName", fileName); |
| | | ajax.put("newFileName", FileUtils.getName(fileName)); |
| | | ajax.put("originalFilename", file.getOriginalFilename()); |
| | | return ajax; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 通用上传请求(多个) |
| | | */ |
| | | @PostMapping("/uploads") |
| | | public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception |
| | | { |
| | | try |
| | | { |
| | | // 上传文件路径 |
| | | String filePath = RuoYiConfig.getUploadPath(); |
| | | List<String> urls = new ArrayList<String>(); |
| | | List<String> fileNames = new ArrayList<String>(); |
| | | List<String> newFileNames = new ArrayList<String>(); |
| | | List<String> originalFilenames = new ArrayList<String>(); |
| | | for (MultipartFile file : files) |
| | | { |
| | | // 上传并返回新文件名称 |
| | | String fileName = FileUploadUtils.upload(filePath, file); |
| | | String url = serverConfig.getUrl() + fileName; |
| | | urls.add(url); |
| | | fileNames.add(fileName); |
| | | newFileNames.add(FileUtils.getName(fileName)); |
| | | originalFilenames.add(file.getOriginalFilename()); |
| | | } |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER)); |
| | | ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER)); |
| | | ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER)); |
| | | ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER)); |
| | | return ajax; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 本地资源通用下载 |
| | | */ |
| | | @GetMapping("/download/resource") |
| | | public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response) |
| | | throws Exception |
| | | { |
| | | try |
| | | { |
| | | if (!FileUtils.checkAllowDownload(resource)) |
| | | { |
| | | throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource)); |
| | | } |
| | | // 本地资源路径 |
| | | String localPath = RuoYiConfig.getProfile(); |
| | | // 数据库资源地址 |
| | | String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX); |
| | | // 下载名称 |
| | | String downloadName = StringUtils.substringAfterLast(downloadPath, "/"); |
| | | response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
| | | FileUtils.setAttachmentResponseHeader(response, downloadName); |
| | | FileUtils.writeBytes(downloadPath, response.getOutputStream()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | log.error("下载文件失败", e); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.interceptor; |
| | | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration |
| | | public class MybatisConfiguration { |
| | | |
| | | /** |
| | | * 注册拦截器 |
| | | */ |
| | | @Bean |
| | | public MybatisInterceptor getMybatisInterceptor() { |
| | | return new MybatisInterceptor(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.interceptor; |
| | | |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.ibatis.executor.Executor; |
| | | import org.apache.ibatis.mapping.MappedStatement; |
| | | import org.apache.ibatis.mapping.SqlCommandType; |
| | | import org.apache.ibatis.plugin.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.util.*; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | @Intercepts({ @Signature(type = Executor.class, method = "update", args = { MappedStatement.class, Object.class }) }) |
| | | public class MybatisInterceptor implements Interceptor { |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @Override |
| | | public Object intercept(Invocation invocation) throws Throwable { |
| | | MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0]; |
| | | log.debug("{}:"+mappedStatement); |
| | | log.debug("------sqlId------" + mappedStatement.getId()); |
| | | if("com.ruoyi.system.mapper.SysLogininforMapper.insertLogininfor".equals(mappedStatement.getId())){ |
| | | return invocation.proceed(); |
| | | } |
| | | // sql类型:insert、update、select、delete |
| | | SqlCommandType sqlCommandType = mappedStatement.getSqlCommandType(); |
| | | Object parameter = invocation.getArgs()[1]; |
| | | log.debug("------sqlCommandType------" + sqlCommandType); |
| | | |
| | | if (parameter == null) { |
| | | return invocation.proceed(); |
| | | } |
| | | |
| | | // 当sql为新增或更新类型时,自动填充操作人相关信息 |
| | | if (SqlCommandType.INSERT == sqlCommandType) { |
| | | |
| | | Field[] fields = getAllFields(parameter); |
| | | for (Field field : fields) { |
| | | try { |
| | | // 注入创建人 |
| | | if ("createBy".equals(field.getName())) { |
| | | // 获取当前登录用户信息 |
| | | if(Objects.nonNull(tokenService.getLoginUser())){ |
| | | String userName = tokenService.getLoginUser().getUser().getUserName(); |
| | | field.setAccessible(true); |
| | | field.set(parameter, userName); |
| | | field.setAccessible(false); |
| | | } |
| | | } |
| | | //注入创建时间 |
| | | if ("createTime".equals(field.getName())) { |
| | | field.setAccessible(true); |
| | | // field.set(parameter, new Date()); |
| | | field.setAccessible(false); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("failed to insert data, exception = ", e); |
| | | } |
| | | } |
| | | } |
| | | if (SqlCommandType.UPDATE == sqlCommandType) { |
| | | Field[] fields = getAllFields(parameter); |
| | | for (Field field : fields) { |
| | | try { |
| | | if ("updateBy".equals(field.getName())) { |
| | | // 获取当前登录用户信息 |
| | | if(Objects.nonNull(tokenService.getLoginUser())){ |
| | | String userName = tokenService.getLoginUser().getUser().getUserName(); |
| | | field.setAccessible(true); |
| | | field.set(parameter, userName); |
| | | field.setAccessible(false); |
| | | } |
| | | } |
| | | if ("updateTime".equals(field.getName())) { |
| | | field.setAccessible(true); |
| | | // field.set(parameter, new Date()); |
| | | field.setAccessible(false); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("failed to update data, exception = ", e); |
| | | } |
| | | } |
| | | } |
| | | return invocation.proceed(); |
| | | } |
| | | |
| | | @Override |
| | | public Object plugin(Object target) { |
| | | return Plugin.wrap(target, this); |
| | | } |
| | | |
| | | @Override |
| | | public void setProperties(Properties properties) { |
| | | // TODO Auto-generated method stub |
| | | } |
| | | |
| | | /** |
| | | * 获取类的所有属性,包括父类 |
| | | * |
| | | * @param object |
| | | * @return |
| | | */ |
| | | private Field[] getAllFields(Object object) { |
| | | Class<?> clazz = object.getClass(); |
| | | List<Field> fieldList = new ArrayList<>(); |
| | | while (clazz != null) { |
| | | fieldList.addAll(new ArrayList<>(Arrays.asList(clazz.getDeclaredFields()))); |
| | | clazz = clazz.getSuperclass(); |
| | | } |
| | | Field[] fields = new Field[fieldList.size()]; |
| | | fieldList.toArray(fields); |
| | | return fields; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.monitor; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Properties; |
| | | import java.util.Set; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisCallback; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | 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.constant.CacheConstants; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.SysCache; |
| | | |
| | | /** |
| | | * 缓存监控 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/monitor/cache") |
| | | public class CacheController |
| | | { |
| | | @Autowired |
| | | private RedisTemplate<String, String> redisTemplate; |
| | | |
| | | private final static List<SysCache> caches = new ArrayList<SysCache>(); |
| | | { |
| | | caches.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "用户信息")); |
| | | caches.add(new SysCache(CacheConstants.SYS_CONFIG_KEY, "配置信息")); |
| | | caches.add(new SysCache(CacheConstants.SYS_DICT_KEY, "数据字典")); |
| | | caches.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "验证码")); |
| | | caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交")); |
| | | caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理")); |
| | | caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数")); |
| | | } |
| | | |
| | | @GetMapping() |
| | | public AjaxResult getInfo() throws Exception |
| | | { |
| | | Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info()); |
| | | Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats")); |
| | | Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize()); |
| | | |
| | | Map<String, Object> result = new HashMap<>(3); |
| | | result.put("info", info); |
| | | result.put("dbSize", dbSize); |
| | | |
| | | List<Map<String, String>> pieList = new ArrayList<>(); |
| | | commandStats.stringPropertyNames().forEach(key -> { |
| | | Map<String, String> data = new HashMap<>(2); |
| | | String property = commandStats.getProperty(key); |
| | | data.put("name", StringUtils.removeStart(key, "cmdstat_")); |
| | | data.put("value", StringUtils.substringBetween(property, "calls=", ",usec")); |
| | | pieList.add(data); |
| | | }); |
| | | result.put("commandStats", pieList); |
| | | return AjaxResult.success(result); |
| | | } |
| | | |
| | | @GetMapping("/getNames") |
| | | public AjaxResult cache() |
| | | { |
| | | return AjaxResult.success(caches); |
| | | } |
| | | |
| | | @GetMapping("/getKeys/{cacheName}") |
| | | public AjaxResult getCacheKeys(@PathVariable String cacheName) |
| | | { |
| | | Set<String> cacheKeys = redisTemplate.keys(cacheName + "*"); |
| | | return AjaxResult.success(cacheKeys); |
| | | } |
| | | |
| | | @GetMapping("/getValue/{cacheName}/{cacheKey}") |
| | | public AjaxResult getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey) |
| | | { |
| | | String cacheValue = redisTemplate.opsForValue().get(cacheKey); |
| | | SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue); |
| | | return AjaxResult.success(sysCache); |
| | | } |
| | | |
| | | @DeleteMapping("/clearCacheName/{cacheName}") |
| | | public AjaxResult clearCacheName(@PathVariable String cacheName) |
| | | { |
| | | Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*"); |
| | | redisTemplate.delete(cacheKeys); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @DeleteMapping("/clearCacheKey/{cacheKey}") |
| | | public AjaxResult clearCacheKey(@PathVariable String cacheKey) |
| | | { |
| | | redisTemplate.delete(cacheKey); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @DeleteMapping("/clearCacheAll") |
| | | public AjaxResult clearCacheAll() |
| | | { |
| | | Collection<String> cacheKeys = redisTemplate.keys("*"); |
| | | redisTemplate.delete(cacheKeys); |
| | | return AjaxResult.success(); |
| | | } |
| | | } |
New file |
| | |
| | | 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.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.domain.Server; |
| | | |
| | | /** |
| | | * 服务器监控 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/monitor/server") |
| | | public class ServerController |
| | | { |
| | | @GetMapping() |
| | | public AjaxResult getInfo() throws Exception |
| | | { |
| | | Server server = new Server(); |
| | | server.copyTo(); |
| | | return AjaxResult.success(server); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.monitor; |
| | | |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | 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.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.service.SysPasswordService; |
| | | 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; |
| | | |
| | | @Autowired |
| | | private SysPasswordService passwordService; |
| | | |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysLogininfor logininfor) |
| | | { |
| | | // startPage(); |
| | | List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | // @Log(title = "登录日志", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, SysLogininfor logininfor) |
| | | // { |
| | | // List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); |
| | | // ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class); |
| | | // util.exportExcel(response, list, "登录日志"); |
| | | // } |
| | | |
| | | @Log(title = "登录日志", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{infoIds}") |
| | | public AjaxResult remove(@PathVariable Long[] infoIds) |
| | | { |
| | | return toAjax(logininforService.deleteLogininforByIds(infoIds)); |
| | | } |
| | | |
| | | @Log(title = "登录日志", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/clean") |
| | | public AjaxResult clean() |
| | | { |
| | | logininforService.cleanLogininfor(); |
| | | return success(); |
| | | } |
| | | |
| | | @Log(title = "账户解锁", businessType = BusinessType.OTHER) |
| | | @GetMapping("/unlock/{userName}") |
| | | public AjaxResult unlock(@PathVariable("userName") String userName) |
| | | { |
| | | passwordService.clearLoginRecordCache(userName); |
| | | return success(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.monitor; |
| | | |
| | | 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 com.ruoyi.system.service.ISysOperLogService; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 操作日志记录 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Slf4j |
| | | @Api(tags = "操作日志记录") |
| | | @RestController |
| | | @RequestMapping("/monitor/operlog") |
| | | public class SysOperlogController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysOperLogService operLogService; |
| | | |
| | | // @ApiOperation(value = "操作日志分页列表") |
| | | // @PostMapping("/list") |
| | | // public AjaxResult list(@RequestBody SysOperLogQuery query) |
| | | // { |
| | | // startPage(query.getPageNum(), query.getPageSize()); |
| | | // List<SysOperLogVO> list = operLogService.selectOperLogPageList(query); |
| | | // operLogService.getLogDetail(list); |
| | | // return AjaxResult.success(getDataTable(list)); |
| | | // } |
| | | |
| | | /** |
| | | * 查询操作日志列表导出 |
| | | */ |
| | | // @ApiOperation(value = "查询操作日志列表导出") |
| | | // @Log(title = "操作日志-查询操作日志列表导出", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/exportOperLog") |
| | | // public void exportOperLog(@RequestBody SysOperLogQuery query) |
| | | // { |
| | | // List<SysOperLogVO> list = operLogService.selectOperLogPageList(query); |
| | | // List<TOperLogExport> operLogExports = new ArrayList<>(); |
| | | // for (SysOperLogVO sysOperLogVO : list) { |
| | | // TOperLogExport operLogExport = new TOperLogExport(); |
| | | // BeanUtils.copyProperties(sysOperLogVO,operLogExport); |
| | | // operLogService.getLogDetail(list); |
| | | // operLogExports.add(operLogExport); |
| | | // } |
| | | // Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOperLogExport.class, operLogExports); |
| | | // HttpServletResponse response = WebUtils.response(); |
| | | // response.setContentType("application/vnd.ms-excel"); |
| | | // response.setCharacterEncoding("utf-8"); |
| | | // ServletOutputStream outputStream = null; |
| | | // try { |
| | | // String fileName = URLEncoder.encode("操作日志信息.xls", "utf-8"); |
| | | // response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | // response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | // response.setHeader("Pragma", "no-cache"); |
| | | // response.setHeader("Cache-Control", "no-cache"); |
| | | // outputStream = response.getOutputStream(); |
| | | // workbook.write(outputStream); |
| | | // } catch (IOException e) { |
| | | // e.printStackTrace(); |
| | | // log.error("操作日志导出信息导出失败!"); |
| | | // } finally { |
| | | // try { |
| | | // outputStream.close(); |
| | | // } catch (IOException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | // @Log(title = "操作日志", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, SysOperLog operLog) |
| | | // { |
| | | // List<SysOperLog> list = operLogService.selectOperLogList(operLog); |
| | | // ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class); |
| | | // util.exportExcel(response, list, "操作日志"); |
| | | // } |
| | | |
| | | @Log(title = "操作日志", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/deleteById/{operIds}") |
| | | public AjaxResult remove(@PathVariable String operIds) |
| | | { |
| | | String[] split = operIds.split(","); |
| | | List<Long> id = new ArrayList<>(); |
| | | for (String s : split) { |
| | | id.add(Long.valueOf(s)); |
| | | } |
| | | return AjaxResult.success(operLogService.deleteOperLogByIds(id)); |
| | | } |
| | | |
| | | @Log(title = "操作日志", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/clean") |
| | | public AjaxResult clean() |
| | | { |
| | | operLogService.cleanOperLog(); |
| | | return success(); |
| | | } |
| | | } |
New file |
| | |
| | | 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.CacheConstants; |
| | | 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; |
| | | |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(String ipaddr, String userName) |
| | | { |
| | | Collection<String> keys = redisCache.keys(CacheConstants.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)) |
| | | { |
| | | userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user)); |
| | | } |
| | | else if (StringUtils.isNotEmpty(ipaddr)) |
| | | { |
| | | userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user)); |
| | | } |
| | | else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) |
| | | { |
| | | userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user)); |
| | | } |
| | | else |
| | | { |
| | | userOnlineList.add(userOnlineService.loginUserToUserOnline(user)); |
| | | } |
| | | } |
| | | Collections.reverse(userOnlineList); |
| | | userOnlineList.removeAll(Collections.singleton(null)); |
| | | return getDataTable(userOnlineList); |
| | | } |
| | | |
| | | /** |
| | | * 强退用户 |
| | | */ |
| | | @Log(title = "在线用户", businessType = BusinessType.FORCE) |
| | | @DeleteMapping("/{tokenId}") |
| | | public AjaxResult forceLogout(@PathVariable String tokenId) |
| | | { |
| | | redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId); |
| | | return success(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | 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.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; |
| | | |
| | | // @Log(title = "参数管理", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, SysConfig config) |
| | | // { |
| | | // List<SysConfig> list = configService.selectConfigList(config); |
| | | // ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class); |
| | | // util.exportExcel(response, list, "参数数据"); |
| | | // } |
| | | |
| | | /** |
| | | * 根据参数编号获取详细信息 |
| | | */ |
| | | @GetMapping(value = "/{configId}") |
| | | public AjaxResult getInfo(@PathVariable Long configId) |
| | | { |
| | | return success(configService.selectConfigById(configId)); |
| | | } |
| | | |
| | | /** |
| | | * 根据参数键名查询参数值 |
| | | */ |
| | | @GetMapping(value = "/configKey/{configKey}") |
| | | public AjaxResult getConfigKey(@PathVariable String configKey) |
| | | { |
| | | return success(configService.selectConfigByKey(configKey)); |
| | | } |
| | | |
| | | /** |
| | | * 新增参数配置 |
| | | */ |
| | | @Log(title = "参数管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysConfig config) |
| | | { |
| | | if (!configService.checkConfigKeyUnique(config)) |
| | | { |
| | | return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); |
| | | } |
| | | config.setCreateBy(getUsername()); |
| | | return toAjax(configService.insertConfig(config)); |
| | | } |
| | | |
| | | /** |
| | | * 修改参数配置 |
| | | */ |
| | | @Log(title = "参数管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysConfig config) |
| | | { |
| | | if (!configService.checkConfigKeyUnique(config)) |
| | | { |
| | | return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); |
| | | } |
| | | config.setUpdateBy(getUsername()); |
| | | return toAjax(configService.updateConfig(config)); |
| | | } |
| | | |
| | | /** |
| | | * 删除参数配置 |
| | | */ |
| | | @Log(title = "参数管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{configIds}") |
| | | public AjaxResult remove(@PathVariable Long[] configIds) |
| | | { |
| | | configService.deleteConfigByIds(configIds); |
| | | return success(); |
| | | } |
| | | |
| | | /** |
| | | * 刷新参数缓存 |
| | | */ |
| | | @Log(title = "参数管理", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/refreshCache") |
| | | public AjaxResult refreshCache() |
| | | { |
| | | configService.resetConfigCache(); |
| | | return success(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | 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.StringUtils; |
| | | import com.ruoyi.system.service.ISysDeptService; |
| | | |
| | | /** |
| | | * 部门信息 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/dept") |
| | | public class SysDeptController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysDeptService deptService; |
| | | |
| | | /** |
| | | * 获取部门列表 |
| | | */ |
| | | @GetMapping("/list") |
| | | public AjaxResult list(SysDept dept) |
| | | { |
| | | List<SysDept> depts = deptService.selectDeptList(dept); |
| | | return AjaxResult.success(depts); |
| | | } |
| | | |
| | | /** |
| | | * 查询部门列表(排除节点) |
| | | */ |
| | | @GetMapping("/list/exclude/{deptId}") |
| | | public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) |
| | | { |
| | | List<SysDept> depts = deptService.selectDeptList(new SysDept()); |
| | | depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); |
| | | return AjaxResult.success(depts); |
| | | } |
| | | |
| | | /** |
| | | * 根据部门编号获取详细信息 |
| | | */ |
| | | @GetMapping(value = "/{deptId}") |
| | | public AjaxResult getInfo(@PathVariable Long deptId) |
| | | { |
| | | deptService.checkDeptDataScope(deptId); |
| | | return AjaxResult.success(deptService.selectDeptById(deptId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增部门 |
| | | */ |
| | | @Log(title = "部门管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysDept dept) |
| | | { |
| | | if (!deptService.checkDeptNameUnique(dept)) |
| | | { |
| | | return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); |
| | | } |
| | | dept.setCreateBy(getUsername()); |
| | | return AjaxResult.success(deptService.insertDept(dept)); |
| | | } |
| | | |
| | | /** |
| | | * 修改部门 |
| | | */ |
| | | @Log(title = "部门管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysDept dept) |
| | | { |
| | | Long deptId = dept.getDeptId(); |
| | | deptService.checkDeptDataScope(deptId); |
| | | if (!deptService.checkDeptNameUnique(dept)) |
| | | { |
| | | return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); |
| | | } |
| | | else if (dept.getParentId().equals(deptId)) |
| | | { |
| | | return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); |
| | | } |
| | | else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) |
| | | { |
| | | return error("该部门包含未停用的子部门!"); |
| | | } |
| | | dept.setUpdateBy(getUsername()); |
| | | return AjaxResult.success(deptService.updateDept(dept)); |
| | | } |
| | | |
| | | /** |
| | | * 删除部门 |
| | | */ |
| | | @Log(title = "部门管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{deptId}") |
| | | public AjaxResult remove(@PathVariable Long deptId) |
| | | { |
| | | if (deptService.hasChildByDeptId(deptId)) |
| | | { |
| | | return warn("存在下级部门,不允许删除"); |
| | | } |
| | | if (deptService.checkDeptExistUser(deptId)) |
| | | { |
| | | return warn("部门存在用户,不允许删除"); |
| | | } |
| | | deptService.checkDeptDataScope(deptId); |
| | | return AjaxResult.success(deptService.deleteDeptById(deptId)); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | 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.StringUtils; |
| | | 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; |
| | | |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysDictData dictData) |
| | | { |
| | | // startPage(); |
| | | List<SysDictData> list = dictDataService.selectDictDataList(dictData); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | // @Log(title = "字典数据", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, SysDictData dictData) |
| | | // { |
| | | // List<SysDictData> list = dictDataService.selectDictDataList(dictData); |
| | | // ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class); |
| | | // util.exportExcel(response, list, "字典数据"); |
| | | // } |
| | | |
| | | /** |
| | | * 查询字典数据详细 |
| | | */ |
| | | @GetMapping(value = "/{dictCode}") |
| | | public AjaxResult getInfo(@PathVariable Long dictCode) |
| | | { |
| | | return success(dictDataService.selectDictDataById(dictCode)); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型查询字典数据信息 |
| | | */ |
| | | @GetMapping(value = "/type/{dictType}") |
| | | public AjaxResult dictType(@PathVariable String dictType) |
| | | { |
| | | List<SysDictData> data = dictTypeService.selectDictDataByType(dictType); |
| | | if (StringUtils.isNull(data)) |
| | | { |
| | | data = new ArrayList<SysDictData>(); |
| | | } |
| | | return success(data); |
| | | } |
| | | |
| | | /** |
| | | * 新增字典类型 |
| | | */ |
| | | @Log(title = "字典数据", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysDictData dict) |
| | | { |
| | | dict.setCreateBy(getUsername()); |
| | | return toAjax(dictDataService.insertDictData(dict)); |
| | | } |
| | | |
| | | /** |
| | | * 修改保存字典类型 |
| | | */ |
| | | @Log(title = "字典数据", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysDictData dict) |
| | | { |
| | | dict.setUpdateBy(getUsername()); |
| | | return toAjax(dictDataService.updateDictData(dict)); |
| | | } |
| | | |
| | | /** |
| | | * 删除字典类型 |
| | | */ |
| | | @Log(title = "字典类型", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictCodes}") |
| | | public AjaxResult remove(@PathVariable Long[] dictCodes) |
| | | { |
| | | dictDataService.deleteDictDataByIds(dictCodes); |
| | | return success(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | 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.SysDictType; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | 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; |
| | | |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysDictType dictType) |
| | | { |
| | | // startPage(); |
| | | List<SysDictType> list = dictTypeService.selectDictTypeList(dictType); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | // @Log(title = "字典类型", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, SysDictType dictType) |
| | | // { |
| | | // List<SysDictType> list = dictTypeService.selectDictTypeList(dictType); |
| | | // ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class); |
| | | // util.exportExcel(response, list, "字典类型"); |
| | | // } |
| | | |
| | | /** |
| | | * 查询字典类型详细 |
| | | */ |
| | | @GetMapping(value = "/{dictId}") |
| | | public AjaxResult getInfo(@PathVariable Long dictId) |
| | | { |
| | | return success(dictTypeService.selectDictTypeById(dictId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增字典类型 |
| | | */ |
| | | @Log(title = "字典类型", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysDictType dict) |
| | | { |
| | | if (!dictTypeService.checkDictTypeUnique(dict)) |
| | | { |
| | | return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); |
| | | } |
| | | dict.setCreateBy(getUsername()); |
| | | return toAjax(dictTypeService.insertDictType(dict)); |
| | | } |
| | | |
| | | /** |
| | | * 修改字典类型 |
| | | */ |
| | | @Log(title = "字典类型", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysDictType dict) |
| | | { |
| | | if (!dictTypeService.checkDictTypeUnique(dict)) |
| | | { |
| | | return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); |
| | | } |
| | | dict.setUpdateBy(getUsername()); |
| | | return toAjax(dictTypeService.updateDictType(dict)); |
| | | } |
| | | |
| | | /** |
| | | * 删除字典类型 |
| | | */ |
| | | @Log(title = "字典类型", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictIds}") |
| | | public AjaxResult remove(@PathVariable Long[] dictIds) |
| | | { |
| | | dictTypeService.deleteDictTypeByIds(dictIds); |
| | | return success(); |
| | | } |
| | | |
| | | /** |
| | | * 刷新字典缓存 |
| | | */ |
| | | @Log(title = "字典类型", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/refreshCache") |
| | | public AjaxResult refreshCache() |
| | | { |
| | | dictTypeService.resetDictCache(); |
| | | return success(); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典选择框列表 |
| | | */ |
| | | @GetMapping("/optionselect") |
| | | public AjaxResult optionselect() |
| | | { |
| | | List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll(); |
| | | return success(dictTypes); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | /** |
| | | * 首页 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | public class SysIndexController |
| | | { |
| | | /** 系统基础配置 */ |
| | | @Autowired |
| | | private RuoYiConfig ruoyiConfig; |
| | | |
| | | /** |
| | | * 访问首页,提示语 |
| | | */ |
| | | @RequestMapping("/") |
| | | public String index() |
| | | { |
| | | return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion()); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUserApplet; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.SmsUtil; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.web.controller.tool.MsgUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | 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.utils.SecurityUtils; |
| | | import com.ruoyi.framework.web.service.SysLoginService; |
| | | import com.ruoyi.framework.web.service.SysPermissionService; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | |
| | | /** |
| | | * 登录验证 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Api(tags = "登录") |
| | | @RestController |
| | | public class SysLoginController |
| | | { |
| | | @Autowired |
| | | private SysLoginService loginService; |
| | | |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | | @Autowired |
| | | private SysPermissionService permissionService; |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | @Autowired |
| | | private MsgUtils msgUtils; |
| | | @Autowired |
| | | private SmsUtil smsUtil; |
| | | |
| | | /** |
| | | * 账号密码登录 |
| | | * |
| | | * @param loginBody 登录信息 |
| | | * @return 结果 |
| | | */ |
| | | @ApiOperation(value = "账号密码登录",notes = "账号密码登录") |
| | | @PostMapping("/login") |
| | | public AjaxResult login(@RequestBody LoginBody loginBody) |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | // 生成令牌 |
| | | LoginUser loginUser = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), |
| | | loginBody.getUuid()); |
| | | ajax.put(Constants.TOKEN, tokenService.createToken(loginUser)); |
| | | List<SysRole> roles = loginUser.getUser().getRoles(); |
| | | if(CollectionUtils.isEmpty(roles)){ |
| | | return AjaxResult.error("请关联角色!"); |
| | | } |
| | | if(roles.get(0).getStatus() == 1){ |
| | | return AjaxResult.error("该账号角色已被禁用!"); |
| | | } |
| | | |
| | | List<SysMenu> menus = roleService.roleInfoFromUserId(loginUser.getUserId()); |
| | | |
| | | ajax.put("menus",menus); |
| | | ajax.put("roleName",roles.get(0).getRoleName()); |
| | | ajax.put("userInfo",loginUser); |
| | | return ajax; |
| | | } |
| | | |
| | | /** |
| | | * 账号密码登录 |
| | | * |
| | | * @param loginBody 登录信息 |
| | | * @return 结果 |
| | | */ |
| | | @ApiOperation(value = "短信登录",notes = "短信登录") |
| | | @PostMapping("/loginCode") |
| | | public AjaxResult loginCode(@RequestBody LoginBody loginBody) |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | // 生成令牌 |
| | | LoginUserApplet loginUser = loginService.loginCodeApplet(loginBody.getUsername(), loginBody.getCode()); |
| | | ajax.put(Constants.TOKEN, tokenService.createTokenApplet(loginUser)); |
| | | ajax.put("userInfo",loginUser); |
| | | return ajax; |
| | | } |
| | | |
| | | /** |
| | | * 获取验证码 |
| | | * |
| | | * @param phone 手机号 |
| | | * @return 结果 |
| | | */ |
| | | @ApiOperation(value = "获取验证码",notes = "获取验证码") |
| | | @GetMapping("/getCode") |
| | | public AjaxResult getCode(@RequestParam String phone) |
| | | { |
| | | // 发送验证码并存储到redis |
| | | if (StringUtils.hasLength(phone)) { |
| | | String code = String.valueOf((int) (Math.random() * 1000000)); |
| | | redisCache.setCacheObject(phone, code,5*60,TimeUnit.SECONDS); |
| | | try { |
| | | smsUtil.sendSms(phone, "2369926", new String[]{code}); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return AjaxResult.success("发送短信验证码成功!5分钟内有效"); |
| | | } |
| | | return AjaxResult.error(500, "发送短信验证码失败,请确认手机号码!"); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户信息 |
| | | * |
| | | * @return 用户信息 |
| | | */ |
| | | @GetMapping("getInfo") |
| | | public AjaxResult getInfo() |
| | | { |
| | | SysUser user = SecurityUtils.getLoginUser().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() |
| | | { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId); |
| | | return AjaxResult.success(menuService.buildMenus(menus)); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | 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.SysMenu; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | |
| | | /** |
| | | * 菜单信息 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Api(tags = "菜单信息") |
| | | @RestController |
| | | @RequestMapping("/system/menu") |
| | | public class SysMenuController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | | @ApiOperation("菜单权限(有层级)") |
| | | @GetMapping("/levelList") |
| | | public AjaxResult levelList() |
| | | { |
| | | // 获取当前角色的菜单列表 |
| | | List<SysMenu> menus = menuService.selectList(); |
| | | if(menus.size()==0){ |
| | | return AjaxResult.success(new ArrayList<>()); |
| | | } |
| | | // 第三级 |
| | | List<SysMenu> s3 = menus.stream().filter(e -> e.getMenuType().equals("F")).collect(Collectors.toList()); |
| | | // 第二级 |
| | | List<SysMenu> s2 = menus.stream().filter(e -> e.getMenuType().equals("C")).collect(Collectors.toList()); |
| | | // 第一级 |
| | | List<SysMenu> s1 = menus.stream().filter(e -> e.getMenuType().equals("M")).collect(Collectors.toList()); |
| | | |
| | | for (SysMenu menu : s2) { |
| | | List<SysMenu> collect = s3.stream().filter(e -> e.getParentId().equals(menu.getMenuId())).collect(Collectors.toList()); |
| | | menu.setChildren(collect); |
| | | } |
| | | for (SysMenu menu : s1) { |
| | | List<SysMenu> collect = s2.stream().filter(e -> e.getParentId().equals(menu.getMenuId())).collect(Collectors.toList()); |
| | | menu.setChildren(collect); |
| | | } |
| | | |
| | | return AjaxResult.success(s1); |
| | | } |
| | | |
| | | /** |
| | | * 获取菜单列表 |
| | | */ |
| | | @GetMapping("/list") |
| | | public AjaxResult list(SysMenu menu) |
| | | { |
| | | List<SysMenu> menus = menuService.selectMenuList(menu, getUserId()); |
| | | return AjaxResult.success(menus); |
| | | } |
| | | |
| | | /** |
| | | * 根据菜单编号获取详细信息 |
| | | */ |
| | | @GetMapping(value = "/{menuId}") |
| | | public AjaxResult getInfo(@PathVariable Long menuId) |
| | | { |
| | | return AjaxResult.success(menuService.selectMenuById(menuId)); |
| | | } |
| | | |
| | | /** |
| | | * 获取菜单下拉树列表 |
| | | */ |
| | | @GetMapping("/treeselect") |
| | | public AjaxResult treeselect(SysMenu menu) |
| | | { |
| | | List<SysMenu> menus = menuService.selectMenuList(menu, getUserId()); |
| | | return AjaxResult.success(menuService.buildMenuTreeSelect(menus)); |
| | | } |
| | | |
| | | /** |
| | | * 加载对应角色菜单列表树 |
| | | */ |
| | | @GetMapping(value = "/roleMenuTreeselect/{roleId}") |
| | | public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) |
| | | { |
| | | List<SysMenu> menus = menuService.selectMenuList(getUserId()); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); |
| | | ajax.put("menus", menuService.buildMenuTreeSelect(menus)); |
| | | return ajax; |
| | | } |
| | | |
| | | /** |
| | | * 新增菜单 |
| | | */ |
| | | @Log(title = "菜单管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysMenu menu) |
| | | { |
| | | if (!menuService.checkMenuNameUnique(menu)) |
| | | { |
| | | return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); |
| | | } |
| | | else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) |
| | | { |
| | | return error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); |
| | | } |
| | | menu.setCreateBy(getUsername()); |
| | | return AjaxResult.success(menuService.insertMenu(menu)); |
| | | } |
| | | |
| | | /** |
| | | * 修改菜单 |
| | | */ |
| | | @Log(title = "菜单管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysMenu menu) |
| | | { |
| | | if (!menuService.checkMenuNameUnique(menu)) |
| | | { |
| | | return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); |
| | | } |
| | | else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) |
| | | { |
| | | return error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); |
| | | } |
| | | else if (menu.getMenuId().equals(menu.getParentId())) |
| | | { |
| | | return error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己"); |
| | | } |
| | | menu.setUpdateBy(getUsername()); |
| | | return AjaxResult.success(menuService.updateMenu(menu)); |
| | | } |
| | | |
| | | /** |
| | | * 删除菜单 |
| | | */ |
| | | @Log(title = "菜单管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{menuId}") |
| | | public AjaxResult remove(@PathVariable("menuId") Long menuId) |
| | | { |
| | | if (menuService.hasChildByMenuId(menuId)) |
| | | { |
| | | return warn("存在子菜单,不允许删除"); |
| | | } |
| | | if (menuService.checkMenuExistRole(menuId)) |
| | | { |
| | | return warn("菜单已分配,不允许删除"); |
| | | } |
| | | return AjaxResult.success(menuService.deleteMenuById(menuId)); |
| | | } |
| | | } |
New file |
| | |
| | | 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.system.domain.SysNotice; |
| | | import com.ruoyi.system.service.ISysNoticeService; |
| | | |
| | | /** |
| | | * 公告 信息操作处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/system/notice") |
| | | public class SysNoticeController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysNoticeService noticeService; |
| | | |
| | | /** |
| | | * 获取通知公告列表 |
| | | */ |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysNotice notice) |
| | | { |
| | | // startPage(); |
| | | List<SysNotice> list = noticeService.selectNoticeList(notice); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 根据通知公告编号获取详细信息 |
| | | */ |
| | | @GetMapping(value = "/{noticeId}") |
| | | public AjaxResult getInfo(@PathVariable Long noticeId) |
| | | { |
| | | return success(noticeService.selectNoticeById(noticeId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增通知公告 |
| | | */ |
| | | @Log(title = "通知公告", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysNotice notice) |
| | | { |
| | | notice.setCreateBy(getUsername()); |
| | | return toAjax(noticeService.insertNotice(notice)); |
| | | } |
| | | |
| | | /** |
| | | * 修改通知公告 |
| | | */ |
| | | @Log(title = "通知公告", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysNotice notice) |
| | | { |
| | | notice.setUpdateBy(getUsername()); |
| | | return toAjax(noticeService.updateNotice(notice)); |
| | | } |
| | | |
| | | /** |
| | | * 删除通知公告 |
| | | */ |
| | | @Log(title = "通知公告", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{noticeIds}") |
| | | public AjaxResult remove(@PathVariable Long[] noticeIds) |
| | | { |
| | | return toAjax(noticeService.deleteNoticeByIds(noticeIds)); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | 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.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; |
| | | |
| | | /** |
| | | * 获取岗位列表 |
| | | */ |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysPost post) |
| | | { |
| | | // startPage(); |
| | | List<SysPost> list = postService.selectPostList(post); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | // @Log(title = "岗位管理", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, SysPost post) |
| | | // { |
| | | // List<SysPost> list = postService.selectPostList(post); |
| | | // ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class); |
| | | // util.exportExcel(response, list, "岗位数据"); |
| | | // } |
| | | |
| | | /** |
| | | * 根据岗位编号获取详细信息 |
| | | */ |
| | | @GetMapping(value = "/{postId}") |
| | | public AjaxResult getInfo(@PathVariable Long postId) |
| | | { |
| | | return success(postService.selectPostById(postId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增岗位 |
| | | */ |
| | | @Log(title = "岗位管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysPost post) |
| | | { |
| | | if (!postService.checkPostNameUnique(post)) |
| | | { |
| | | return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); |
| | | } |
| | | else if (!postService.checkPostCodeUnique(post)) |
| | | { |
| | | return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); |
| | | } |
| | | post.setCreateBy(getUsername()); |
| | | return toAjax(postService.insertPost(post)); |
| | | } |
| | | |
| | | /** |
| | | * 修改岗位 |
| | | */ |
| | | @Log(title = "岗位管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysPost post) |
| | | { |
| | | if (!postService.checkPostNameUnique(post)) |
| | | { |
| | | return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); |
| | | } |
| | | else if (!postService.checkPostCodeUnique(post)) |
| | | { |
| | | return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); |
| | | } |
| | | post.setUpdateBy(getUsername()); |
| | | return toAjax(postService.updatePost(post)); |
| | | } |
| | | |
| | | /** |
| | | * 删除岗位 |
| | | */ |
| | | @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 success(posts); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | 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.StringUtils; |
| | | import com.ruoyi.common.utils.file.FileUploadUtils; |
| | | import com.ruoyi.common.utils.file.MimeTypeUtils; |
| | | 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 = getLoginUser(); |
| | | 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) |
| | | { |
| | | LoginUser loginUser = getLoginUser(); |
| | | SysUser currentUser = loginUser.getUser(); |
| | | currentUser.setNickName(user.getNickName()); |
| | | currentUser.setEmail(user.getEmail()); |
| | | currentUser.setPhonenumber(user.getPhonenumber()); |
| | | currentUser.setSex(user.getSex()); |
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | | if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(currentUser)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); |
| | | } |
| | | if (userService.updateUserProfile(currentUser) > 0) |
| | | { |
| | | // 更新缓存用户信息 |
| | | tokenService.setLoginUser(loginUser); |
| | | return success(); |
| | | } |
| | | return error("修改个人信息异常,请联系管理员"); |
| | | } |
| | | |
| | | /** |
| | | * 重置密码 |
| | | */ |
| | | @Log(title = "个人信息", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/updatePwd") |
| | | public AjaxResult updatePwd(String oldPassword, String newPassword) |
| | | { |
| | | LoginUser loginUser = getLoginUser(); |
| | | String userName = loginUser.getUsername(); |
| | | String password = loginUser.getPassword(); |
| | | if (!SecurityUtils.matchesPassword(oldPassword, password)) |
| | | { |
| | | return error("修改密码失败,旧密码错误"); |
| | | } |
| | | if (SecurityUtils.matchesPassword(newPassword, password)) |
| | | { |
| | | return error("新密码不能与旧密码相同"); |
| | | } |
| | | if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) |
| | | { |
| | | // 更新缓存用户密码 |
| | | loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword)); |
| | | tokenService.setLoginUser(loginUser); |
| | | return success(); |
| | | } |
| | | return error("修改密码异常,请联系管理员"); |
| | | } |
| | | |
| | | /** |
| | | * 头像上传 |
| | | */ |
| | | @Log(title = "用户头像", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/avatar") |
| | | public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception |
| | | { |
| | | if (!file.isEmpty()) |
| | | { |
| | | LoginUser loginUser = getLoginUser(); |
| | | String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION); |
| | | if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("imgUrl", avatar); |
| | | // 更新缓存用户头像 |
| | | loginUser.getUser().setAvatar(avatar); |
| | | tokenService.setLoginUser(loginUser); |
| | | return ajax; |
| | | } |
| | | } |
| | | return error("上传图片异常,请联系管理员"); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.model.RegisterBody; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.SysRegisterService; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | |
| | | /** |
| | | * 注册验证 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | public class SysRegisterController extends BaseController |
| | | { |
| | | @Autowired |
| | | private SysRegisterService registerService; |
| | | |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | |
| | | @PostMapping("/register") |
| | | public AjaxResult register(@RequestBody RegisterBody user) |
| | | { |
| | | if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) |
| | | { |
| | | return error("当前系统没有开启注册功能!"); |
| | | } |
| | | String msg = registerService.register(user); |
| | | return StringUtils.isEmpty(msg) ? success() : error(msg); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | import com.ruoyi.system.dto.SysRoleDTO; |
| | | import com.ruoyi.system.query.SysRoleQuery; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | 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.SysDept; |
| | | 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.StringUtils; |
| | | import com.ruoyi.framework.web.service.SysPermissionService; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import com.ruoyi.system.service.ISysDeptService; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | |
| | | /** |
| | | * 角色信息 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Api(tags = "角色信息") |
| | | @RestController |
| | | @RequestMapping("/system/role") |
| | | public class SysRoleController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @Autowired |
| | | private SysPermissionService permissionService; |
| | | |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private ISysDeptService deptService; |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | | @ApiOperation(value = "角色列表") |
| | | @PostMapping("/list") |
| | | public AjaxResult list(@RequestBody SysRoleQuery query) |
| | | { |
| | | PageInfo<SysRole> list = roleService.selectPageList(query); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @ApiOperation(value = "角色列表不分页") |
| | | @PostMapping("/listNotPage") |
| | | public AjaxResult list() |
| | | { |
| | | List<SysRole> list = roleService.selectRoleList(new SysRole()); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @ApiOperation(value = "角色数量统计") |
| | | @PostMapping("/roleCount") |
| | | public AjaxResult roleCount() |
| | | { |
| | | int all = roleService.selectCount(null); |
| | | int normal = roleService.selectCount(0); |
| | | int stop = roleService.selectCount(1); |
| | | |
| | | Map<String,Integer> map = new HashMap<>(); |
| | | map.put("all",all); |
| | | map.put("normal",normal); |
| | | map.put("stop",stop); |
| | | return AjaxResult.success(map); |
| | | } |
| | | |
| | | // @Log(title = "角色管理", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, SysRole role) |
| | | // { |
| | | // List<SysRole> list = roleService.selectRoleList(role); |
| | | // ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); |
| | | // util.exportExcel(response, list, "角色数据"); |
| | | // } |
| | | |
| | | /** |
| | | * 根据角色编号获取详细信息 |
| | | */ |
| | | @GetMapping(value = "/{roleId}") |
| | | public AjaxResult getInfo(@PathVariable Long roleId) |
| | | { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return AjaxResult.success(roleService.selectRoleById(roleId)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("角色详情") |
| | | @GetMapping("/roleInfo") |
| | | public AjaxResult roleInfo(@RequestParam Long roleId) |
| | | { |
| | | SysRole role = roleService.selectRoleById(roleId); |
| | | RoleInfoVO roleInfoVo = new RoleInfoVO(); |
| | | roleInfoVo.setRoleId(role.getRoleId()); |
| | | roleInfoVo.setRoleName(role.getRoleName()); |
| | | |
| | | // 获取当前角色的菜单列表 |
| | | List<SysMenu> menus = menuService.selectListByRoleId(roleId); |
| | | if(menus.size()==0){ |
| | | return AjaxResult.success(new ArrayList<>()); |
| | | } |
| | | List<Long> menusId = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList()); |
| | | |
| | | // 获取当前的权限菜单(有层级) |
| | | List<SysMenu> levelMenus = roleService.getMenuLevelList(menusId); |
| | | |
| | | roleInfoVo.setMenus(menusId); |
| | | return AjaxResult.success(roleInfoVo); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("用户获取权限菜单") |
| | | @GetMapping("/roleInfoFromUserId") |
| | | public AjaxResult roleInfoFromUserId(@RequestParam Long userId) |
| | | { |
| | | return AjaxResult.success(roleService.roleInfoFromUserId(userId)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新增角色 |
| | | */ |
| | | @ApiOperation(value = "新增角色") |
| | | @Log(title = "角色信息-新增角色", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | | public AjaxResult add(@Validated @RequestBody SysRoleDTO dto) |
| | | { |
| | | Boolean flag= roleService.isExit(dto.getRoleId(),dto.getRoleName()); |
| | | if(flag){ |
| | | return error("新增角色'" + dto.getRoleName() + "'失败,角色名称已存在"); |
| | | } |
| | | roleService.saveRole(dto); |
| | | return AjaxResult.success(); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 修改保存角色 |
| | | */ |
| | | @ApiOperation(value = "编辑角色") |
| | | @Log(title = "角色信息-编辑角色", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysRoleDTO dto) |
| | | { |
| | | Boolean flag= roleService.isExit(dto.getRoleId(),dto.getRoleName()); |
| | | if (flag){ |
| | | return error("修改角色'" + dto.getRoleName() + "'失败,角色名称已存在"); |
| | | } |
| | | if (roleService.editRole(dto) > 0) |
| | | { |
| | | // 更新缓存用户权限 |
| | | LoginUser loginUser = getLoginUser(); |
| | | if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) |
| | | { |
| | | loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser())); |
| | | loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName())); |
| | | tokenService.setLoginUser(loginUser); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | return error("修改角色'" + dto.getRoleName() + "'失败,请联系管理员"); |
| | | } |
| | | |
| | | /** |
| | | * 修改保存数据权限 |
| | | */ |
| | | @Log(title = "角色管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/dataScope") |
| | | public AjaxResult dataScope(@RequestBody SysRole role) |
| | | { |
| | | roleService.checkRoleAllowed(role); |
| | | roleService.checkRoleDataScope(role.getRoleId()); |
| | | return AjaxResult.success(roleService.authDataScope(role)); |
| | | } |
| | | |
| | | /** |
| | | * 状态修改 |
| | | */ |
| | | @ApiOperation(value = "状态修改") |
| | | @Log(title = "角色信息-角色状态修改", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysRole role) |
| | | { |
| | | role.setUpdateBy(getUsername()); |
| | | roleService.updateStatus(role); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 删除角色 |
| | | */ |
| | | @ApiOperation(value = "删除角色") |
| | | @Log(title = "角色信息-角色删除角色", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/deleteById/{ids}") |
| | | public AjaxResult remove(@PathVariable String ids) |
| | | { |
| | | String[] split = ids.split(","); |
| | | List<Long> id = new ArrayList<>(); |
| | | for (String s : split) { |
| | | id.add(Long.valueOf(s)); |
| | | } |
| | | return AjaxResult.success(roleService.deleteRoleByIds(id)); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色选择框列表 |
| | | */ |
| | | @GetMapping("/optionselect") |
| | | public AjaxResult optionselect() |
| | | { |
| | | return AjaxResult.success(roleService.selectRoleAll()); |
| | | } |
| | | |
| | | /** |
| | | * 查询已分配用户角色列表 |
| | | */ |
| | | @GetMapping("/authUser/allocatedList") |
| | | public TableDataInfo allocatedList(SysUser user) |
| | | { |
| | | // startPage(); |
| | | List<SysUser> list = userService.selectAllocatedList(user); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 查询未分配用户角色列表 |
| | | */ |
| | | @GetMapping("/authUser/unallocatedList") |
| | | public TableDataInfo unallocatedList(SysUser user) |
| | | { |
| | | // startPage(); |
| | | List<SysUser> list = userService.selectUnallocatedList(user); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 取消授权用户 |
| | | */ |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/cancel") |
| | | public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole) |
| | | { |
| | | return AjaxResult.success(roleService.deleteAuthUser(userRole)); |
| | | } |
| | | |
| | | /** |
| | | * 批量取消授权用户 |
| | | */ |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/cancelAll") |
| | | public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) |
| | | { |
| | | return AjaxResult.success(roleService.deleteAuthUsers(roleId, userIds)); |
| | | } |
| | | |
| | | /** |
| | | * 批量选择用户授权 |
| | | */ |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/selectAll") |
| | | public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds) |
| | | { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return AjaxResult.success(roleService.insertAuthUsers(roleId, userIds)); |
| | | } |
| | | |
| | | /** |
| | | * 获取对应角色部门树列表 |
| | | */ |
| | | @GetMapping(value = "/deptTree/{roleId}") |
| | | public AjaxResult deptTree(@PathVariable("roleId") Long roleId) |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); |
| | | ajax.put("depts", deptService.selectDeptTreeList(new SysDept())); |
| | | return ajax; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | 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.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.SysUserUpdateStatusDTO; |
| | | import com.ruoyi.system.query.SysUserQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.SysUserVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 用户信息 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Api(tags = "用户信息") |
| | | @RestController |
| | | @RequestMapping("/system/user") |
| | | public class SysUserController extends BaseController |
| | | { |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | |
| | | @Autowired |
| | | private ISysDeptService deptService; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | /** |
| | | * 获取用户列表 |
| | | */ |
| | | @ApiOperation(value = "获取用户列表") |
| | | @PostMapping("/list") |
| | | public AjaxResult list(@RequestBody SysUserQuery query) |
| | | { |
| | | PageInfo<SysUserVO> list = userService.pageList(query); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取用户列表-不分页") |
| | | @PostMapping("/listNotPage") |
| | | public AjaxResult listNotPage() |
| | | { |
| | | List<SysUser> list = userService.selectList(); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户黑名单列表 |
| | | */ |
| | | // @ApiOperation(value = "获取用户黑名单列表") |
| | | // @PostMapping("/blacklist") |
| | | // public AjaxResult blacklist(@RequestBody SysUserQuery query) |
| | | // { |
| | | // startPage(query.getPageNum(), query.getPageSize()); |
| | | // List<SysUserVO> list = userService.selectBlackPageList(query); |
| | | // return AjaxResult.success(getDataTable(list)); |
| | | // } |
| | | |
| | | /** |
| | | * 人员借用列表 |
| | | */ |
| | | // @ApiOperation(value = "人员借用列表") |
| | | // @GetMapping("/userBorrowList") |
| | | // public AjaxResult userBorrowList(@RequestParam(required = false) String name, |
| | | // @RequestParam(required = false) Integer type) |
| | | // { |
| | | // |
| | | // UserAddListVO userAddListVO = new UserAddListVO(); |
| | | // |
| | | // Long companyId = tokenService.getLoginUser().getUser().getCompanyId(); |
| | | // |
| | | // List<TCompany> companyList = new ArrayList<>(); |
| | | // List<TDept> deptList = new ArrayList<>(); |
| | | // List<SysUser> userList = new ArrayList<>(); |
| | | // // 查询公司 |
| | | // if(Objects.nonNull(type) && type == 1){ |
| | | // companyList = companyService.userAddListByCompanyName(name); |
| | | // } |
| | | // // 查询部门 |
| | | // if(Objects.nonNull(type) && type == 2){ |
| | | // deptList = tDeptService.userAddListByDeptName(name); |
| | | // } |
| | | // // 查询用户 |
| | | // if(Objects.nonNull(type) && type == 3){ |
| | | // userList = userService.selectListByNamePhone(name); |
| | | // } |
| | | // |
| | | // if(Objects.isNull(type)){ |
| | | // companyList = companyService.userAddListByCompanyName(name); |
| | | // deptList = tDeptService.userAddListByDeptName(name); |
| | | // userList = userService.selectListByNamePhone(name); |
| | | // } |
| | | // |
| | | // List<Long> companyIds = companyList.stream().map(TCompany::getId).collect(Collectors.toList()); |
| | | // List<Long> deptCompanyIds = deptList.stream().map(TDept::getCompanyId).collect(Collectors.toList()); |
| | | // List<Long> userCompanyIds = userList.stream().map(SysUser::getCompanyId).collect(Collectors.toList()); |
| | | // companyIds.addAll(deptCompanyIds); |
| | | // companyIds.addAll(userCompanyIds); |
| | | // |
| | | // companyIds = companyIds.stream().distinct().collect(Collectors.toList()); |
| | | // |
| | | // if(CollectionUtils.isEmpty(companyIds)){ |
| | | // return AjaxResult.success(userAddListVO); |
| | | // } |
| | | // SysUser user1 = tokenService.getLoginUser().getUser(); |
| | | // if(!user1.isAdmin()){ |
| | | // companyIds = companyIds.stream().filter(e->!e.equals(companyId)).collect(Collectors.toList()); |
| | | // } |
| | | // |
| | | // // 查询符合要求的公司 |
| | | // List<UserLevelVO> parent = companyService.userAddListByCompanyIds(companyIds); |
| | | // |
| | | // List<TDept> depts = tDeptService.selectList(); |
| | | // |
| | | // List<SysUser> sysUsers = userService.selectList(); |
| | | // |
| | | // for (UserLevelVO userLevelVO : parent) { |
| | | // |
| | | // // 找到公司下的部门 |
| | | // List<TDept> tDepts = depts.stream().filter(e -> userLevelVO.getKey().equals(e.getCompanyId())).collect(Collectors.toList()); |
| | | // List<UserLevelVO> children = new ArrayList<>(); |
| | | // // 封装部门 |
| | | // for (TDept dept : tDepts) { |
| | | // userLevelVO.setChildren(children); |
| | | // UserLevelVO userLevelVO1 = new UserLevelVO(); |
| | | // userLevelVO1.setKey(dept.getId()); |
| | | // userLevelVO1.setTitle(dept.getDeptName()); |
| | | // // 找到部门下的人员 |
| | | // List<SysUser> users; |
| | | // if(StringUtils.isNotEmpty(name) && type == 3){ |
| | | // users = sysUsers.stream().filter(e -> userLevelVO1.getKey().equals(e.getDeptId()) |
| | | // && ((StringUtils.isNotEmpty(e.getNickName()) && e.getNickName().contains(name))) |
| | | // || (StringUtils.isNotEmpty(e.getPhonenumber()) && e.getPhonenumber().contains(name))).collect(Collectors.toList()); |
| | | // }else { |
| | | // users = sysUsers.stream().filter(e -> userLevelVO1.getKey().equals(e.getDeptId())).collect(Collectors.toList()); |
| | | // } |
| | | // List<UserLevelVO> children1 = new ArrayList<>(); |
| | | // // 封装人员 |
| | | // for (SysUser user : users) { |
| | | // UserLevelVO userLevelVO2 = new UserLevelVO(); |
| | | // userLevelVO2.setKey(user.getUserId()); |
| | | // userLevelVO2.setTitle(user.getNickName()); |
| | | // userLevelVO2.setAvatar(user.getAvatar()); |
| | | // userLevelVO2.setFlag(true); |
| | | // children1.add(userLevelVO2); |
| | | // } |
| | | // userLevelVO1.setChildren(children1); |
| | | // |
| | | // children.add(userLevelVO1); |
| | | // } |
| | | // userLevelVO.setChildren(children); |
| | | // } |
| | | // userAddListVO.setUserLevelVOS(parent); |
| | | // userAddListVO.setUserList(sysUsers); |
| | | // return AjaxResult.success(userAddListVO); |
| | | // } |
| | | |
| | | /** |
| | | * 获取用户详情 |
| | | */ |
| | | @ApiOperation(value = "获取用户详情") |
| | | @GetMapping("/getDetail") |
| | | public AjaxResult getDetail(@RequestParam Long userId) |
| | | { |
| | | SysUser sysUser = userService.selectUserById(userId); |
| | | SysUserVO sysUserVO = new SysUserVO(); |
| | | BeanUtils.copyProperties(sysUser,sysUserVO); |
| | | |
| | | return AjaxResult.success(sysUser); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取用户数量统计 |
| | | */ |
| | | @ApiOperation(value = "获取用户数量统计") |
| | | @PostMapping("/getUserCount") |
| | | public AjaxResult getUserCount() |
| | | { |
| | | Map<String,Integer> map = new HashMap<>(); |
| | | |
| | | Integer userCountSum = userService.selectCount(null); |
| | | Integer normalCount = userService.selectCount(0);// 正常 |
| | | Integer stopCount = userService.selectCount(1);// 停用 |
| | | |
| | | map.put("all",userCountSum); |
| | | map.put("normal",normalCount); |
| | | map.put("stop",stopCount); |
| | | |
| | | return AjaxResult.success(map); |
| | | } |
| | | |
| | | /** |
| | | * 移除黑名单 |
| | | */ |
| | | @GetMapping("/removeBlackList") |
| | | public AjaxResult removeBlackList(@RequestParam String ids) |
| | | { |
| | | String[] split = ids.split(","); |
| | | List<Long> id = new ArrayList<>(); |
| | | for (String s : split) { |
| | | id.add(Long.valueOf(s)); |
| | | } |
| | | userService.updateUserIfBlack(id); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | // @Log(title = "用户管理", businessType = BusinessType.EXPORT) |
| | | // @PostMapping("/export") |
| | | // public void export(HttpServletResponse response, SysUser user) |
| | | // { |
| | | // List<SysUser> list = userService.selectUserList(user); |
| | | // ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); |
| | | // util.exportExcel(response, list, "用户数据"); |
| | | // } |
| | | |
| | | // @Log(title = "用户管理", businessType = BusinessType.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()); |
| | | // String operName = getUsername(); |
| | | // String message = userService.importUser(userList, updateSupport, operName); |
| | | // return AjaxResult.success(message); |
| | | // } |
| | | |
| | | // @PostMapping("/importTemplate") |
| | | // public void importTemplate(HttpServletResponse response) |
| | | // { |
| | | // ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); |
| | | // util.importTemplateExcel(response, "用户数据"); |
| | | // } |
| | | |
| | | |
| | | /** |
| | | * 新增用户 |
| | | */ |
| | | @ApiOperation(value = "新增用户管理") |
| | | @Log(title = "用户信息-新增用户", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | | public AjaxResult add(@Validated @RequestBody SysUser user) |
| | | { |
| | | user.setUserName(user.getPhonenumber()); |
| | | if (!userService.checkUserNameUnique(user)) |
| | | { |
| | | return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } |
| | | else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) |
| | | { |
| | | return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | | user.setCreateBy(getUsername()); |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | userService.insertUser(user); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 修改用户 |
| | | */ |
| | | @ApiOperation(value = "修改用户管理") |
| | | @Log(title = "用户信息-修改用户", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/edit") |
| | | public AjaxResult edit(@Validated @RequestBody SysUser user) |
| | | { |
| | | user.setUserName(user.getPhonenumber()); |
| | | // userService.checkUserAllowed(user); |
| | | // userService.checkUserDataScope(user.getUserId()); |
| | | if (!userService.checkUserNameUnique(user)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } |
| | | else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | | |
| | | user.setUpdateBy(getUsername()); |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | return AjaxResult.success(userService.updateUser(user)); |
| | | } |
| | | |
| | | /** |
| | | * 删除用户 |
| | | */ |
| | | @ApiOperation(value = "批量删除用户") |
| | | @Log(title = "用户信息-批量删除用户", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/deleteById/{ids}") |
| | | public AjaxResult remove(@PathVariable String ids) |
| | | { |
| | | String[] split = ids.split(","); |
| | | List<Long> userIds = new ArrayList<>(); |
| | | for (String s : split) { |
| | | userIds.add(Long.valueOf(s)); |
| | | } |
| | | if (userIds.contains(getUserId())) |
| | | { |
| | | return error("当前用户不能删除"); |
| | | } |
| | | return AjaxResult.success(userService.deleteUserByIds(userIds)); |
| | | } |
| | | |
| | | /** |
| | | * 重置密码 |
| | | */ |
| | | @ApiOperation(value = "重置密码") |
| | | @Log(title = "用户信息-重置密码", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/resetPwd") |
| | | public AjaxResult resetPwd(@RequestBody SysUser user) |
| | | { |
| | | userService.checkUserAllowed(user); |
| | | // userService.checkUserDataScope(user.getUserId()); |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | user.setUpdateBy(getUsername()); |
| | | return AjaxResult.success(userService.resetPwd(user)); |
| | | } |
| | | |
| | | /** |
| | | * 状态修改 |
| | | */ |
| | | @ApiOperation(value = "状态修改") |
| | | @Log(title = "用户信息-状态修改", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysUserUpdateStatusDTO dto) |
| | | { |
| | | SysUser user = new SysUser(); |
| | | user.setUserId(dto.getUserId()); |
| | | user.setStatus(String.valueOf(dto.getStatus())); |
| | | user.setRemark(dto.getRemark()); |
| | | user.setUpdateBy(getUsername()); |
| | | return AjaxResult.success(userService.updateUserStatus(user)); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户编号获取授权角色 |
| | | */ |
| | | @GetMapping("/authRole/{userId}") |
| | | public AjaxResult authRole(@PathVariable("userId") Long userId) |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | SysUser user = userService.selectUserById(userId); |
| | | List<SysRole> roles = roleService.selectRolesByUserId(userId); |
| | | ajax.put("user", user); |
| | | ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); |
| | | return ajax; |
| | | } |
| | | |
| | | /** |
| | | * 用户授权角色 |
| | | */ |
| | | @Log(title = "用户管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authRole") |
| | | public AjaxResult insertAuthRole(Long userId, Long[] roleIds) |
| | | { |
| | | userService.checkUserDataScope(userId); |
| | | userService.insertUserAuth(userId, roleIds); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 获取部门树列表 |
| | | */ |
| | | @GetMapping("/deptTree") |
| | | public AjaxResult deptTree(SysDept dept) |
| | | { |
| | | return AjaxResult.success(deptService.selectDeptTreeList(dept)); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.tool; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.InputStream; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | |
| | | /** |
| | | * @author zhy |
| | | * @title: HttpClientUtil |
| | | * @projectName car_park |
| | | * @description: http连接工具类 |
| | | * @date 2019/10/2219:23 |
| | | */ |
| | | public class HttpClientUtil { |
| | | |
| | | |
| | | /** |
| | | * @param strUrl |
| | | * @return byte[] |
| | | * @throws |
| | | * @description: 获取网络图片转成字节流 |
| | | * @author zhy |
| | | * @date 2019/10/23 8:59 |
| | | */ |
| | | public static byte[] getImageFromNetByUrl(String strUrl) { |
| | | if (!isURL(strUrl)){ |
| | | return null; |
| | | } |
| | | try { |
| | | URL url = new URL(strUrl); |
| | | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
| | | conn.setRequestMethod("GET"); |
| | | conn.setConnectTimeout(2 * 1000); |
| | | InputStream inStream = conn.getInputStream();// 通过输入流获取图片数据 |
| | | byte[] btImg = readInputStream(inStream);// 得到图片的二进制数据 |
| | | return btImg; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 从输入流中获取字节流数据 |
| | | * |
| | | * @param inStream 输入流 |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static byte[] readInputStream(InputStream inStream) throws Exception { |
| | | ByteArrayOutputStream outStream = new ByteArrayOutputStream(); |
| | | byte[] buffer = new byte[10240]; |
| | | int len = 0; |
| | | while ((len = inStream.read(buffer)) != -1) { |
| | | outStream.write(buffer, 0, len); |
| | | } |
| | | inStream.close(); |
| | | return outStream.toByteArray(); |
| | | } |
| | | |
| | | public static boolean isURL(String str) { |
| | | str = str.toLowerCase(); |
| | | String regex = "^((https|http|ftp|rtsp|mms)?://)" |
| | | + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" |
| | | + "(([0-9]{1,3}\\.){3}[0-9]{1,3}" |
| | | + "|" |
| | | + "([0-9a-z_!~*'()-]+\\.)*" |
| | | + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\\." |
| | | + "[a-z]{2,6})" |
| | | + "(:[0-9]{1,5})?" |
| | | + "((/?)|" |
| | | + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$"; |
| | | return str.matches(regex); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.ruoyi.web.controller.tool; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 导出返回信息 |
| | | */ |
| | | @Slf4j |
| | | public class ImportExcelUtil { |
| | | |
| | | /** |
| | | * @param errorLines 错误行数 |
| | | * @param successLines 成功行数 |
| | | * @param errorMessage 错误信息 |
| | | * @return |
| | | * @throws IOException |
| | | */ |
| | | public static R<String> importReturnMsg(int errorLines, int successLines, List<String> errorMessage) throws IOException { |
| | | if (errorLines == 0) { |
| | | return R.ok("共" + successLines + "行数据全部导入成功!"); |
| | | } else { |
| | | JSONObject result = new JSONObject(5); |
| | | int totalCount = successLines + errorLines; |
| | | result.put("totalCount", totalCount); |
| | | result.put("errorCount", errorLines); |
| | | result.put("errorMessage", errorMessage); |
| | | result.put("successCount", successLines); |
| | | result.put("msg", "总上传行数:" + totalCount + ",已导入行数:" + successLines + ",错误行数:" + errorLines); |
| | | return R.ok(JSON.toJSONString(result)); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.tool; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.system.code.SubmitTemplateReg; |
| | | import org.apache.commons.codec.binary.Base64; |
| | | import org.apache.commons.codec.binary.Hex; |
| | | |
| | | import java.io.Serializable; |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | | /** |
| | | * 短信工具类 |
| | | */ |
| | | public class MsgCodeUtil implements Serializable { |
| | | |
| | | /**接口账号用户名*/ |
| | | private static final String AP_ID = ""; |
| | | /**企业名称*/ |
| | | private static final String EC_NAME = ""; |
| | | /**签名*/ |
| | | private static final String SECRET_KEY = ""; |
| | | /**签名编码*/ |
| | | private static final String SIGN = ""; |
| | | /**模板ID*/ |
| | | private static final String TEMPLATE_ID = ""; |
| | | |
| | | |
| | | /** |
| | | * 实体封装 |
| | | * @param code |
| | | * @return |
| | | */ |
| | | public static SubmitTemplateReg getSubmitTemplateReg(String code,String mobiles) { |
| | | SubmitTemplateReg submitReg =new SubmitTemplateReg(); |
| | | String[] paramss = {code}; |
| | | submitReg.setApId(AP_ID); |
| | | submitReg.setEcName(EC_NAME); |
| | | submitReg.setSecretKey(SECRET_KEY); |
| | | submitReg.setParams(JSONObject.toJSONString(paramss)); |
| | | submitReg.setMobiles(mobiles); |
| | | submitReg.setAddSerial(""); |
| | | submitReg.setSign(SIGN); |
| | | submitReg.setTemplateId(TEMPLATE_ID); |
| | | submitReg.setMac(TEMPLATE_ID); |
| | | StringBuffer stringBuffer = new StringBuffer(); |
| | | stringBuffer.append(submitReg.getEcName( ));stringBuffer.append(submitReg.getApId()); |
| | | stringBuffer.append(submitReg.getSecretKey());stringBuffer.append(submitReg.getTemplateId());stringBuffer.append(submitReg.getMobiles()); |
| | | stringBuffer.append(submitReg.getParams());stringBuffer.append(submitReg.getSign());stringBuffer.append(submitReg.getAddSerial()); |
| | | submitReg.setMac(Hex.encodeHexString(stringBuffer.toString().getBytes(StandardCharsets.UTF_8))); |
| | | String regText = JSONObject.toJSONString(submitReg); |
| | | //加密 |
| | | String encode = Base64.encodeBase64String(regText.getBytes()); |
| | | System.err.println(encode); |
| | | return submitReg; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | getSubmitTemplateReg("123456","18398968484"); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.tool; |
| | | |
| | | import com.aliyun.dysmsapi20170525.models.SendSmsRequest; |
| | | import com.aliyun.dysmsapi20170525.models.SendSmsResponse; |
| | | import com.aliyun.tea.TeaException; |
| | | import com.aliyun.teaopenapi.models.Config; |
| | | import com.aliyun.teautil.models.RuntimeOptions; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Component |
| | | @Slf4j |
| | | public class MsgUtils { |
| | | |
| | | @Value("${code.config.accessKeyId}") |
| | | private String accessKeyId; |
| | | @Value("${code.config.accessKeySecret}") |
| | | private String accessKeySecret; |
| | | @Value("${code.config.signName}") |
| | | private String signName; |
| | | @Value("${code.config.templateCode}") |
| | | private String templateCode; |
| | | @Value("${code.config.signNameTest}") |
| | | private String signNameTest; |
| | | @Value("${code.config.templateCodeTest}") |
| | | private String templateCodeTest; |
| | | |
| | | /** |
| | | * 使用AK&SK初始化账号Client |
| | | * @param accessKeyId |
| | | * @param accessKeySecret |
| | | * @return Client |
| | | * @throws Exception |
| | | */ |
| | | public static com.aliyun.dysmsapi20170525.Client createClient(String accessKeyId, String accessKeySecret) throws Exception { |
| | | Config config = new Config() |
| | | // 您的 AccessKey ID |
| | | .setAccessKeyId(accessKeyId) |
| | | // 您的 AccessKey Secret |
| | | .setAccessKeySecret(accessKeySecret); |
| | | // 访问的域名 |
| | | config.endpoint = "dysmsapi.aliyuncs.com"; |
| | | return new com.aliyun.dysmsapi20170525.Client(config); |
| | | } |
| | | |
| | | public void sendMsg(String phone,String code) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient(accessKeyId,accessKeySecret); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName(signName) |
| | | .setTemplateCode(templateCode) |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"code\":\""+code+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.tool; |
| | | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import java.io.*; |
| | | import java.nio.file.Files; |
| | | |
| | | |
| | | /** |
| | | * @author RainbowCloud |
| | | */ |
| | | public class MyFileUtil { |
| | | |
| | | /** |
| | | * 将 File 转换为 MultipartFile。 |
| | | * |
| | | * @param file 要转换的文件 |
| | | * @param fieldName 字段名,通常用于表单中的文件字段名 |
| | | * @return 转换后的 MultipartFile |
| | | * @throws IOException 如果发生I/O错误 |
| | | */ |
| | | public static MultipartFile fileToMultipartFile(File file, String fieldName) throws IOException { |
| | | try { |
| | | if (file == null || !file.exists()) { |
| | | throw new FileNotFoundException("文件未找到:" + file); |
| | | } |
| | | byte[] content = Files.readAllBytes(file.toPath()); |
| | | return new ByteArrayMultipartFile(content, file.getName(), fieldName, Files.probeContentType(file.toPath())); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } finally { |
| | | // 删除临时文件 |
| | | file.delete(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 将 MultipartFile 转换为 File。 |
| | | * |
| | | * @param multipartFile 要转换的 MultipartFile |
| | | * @return 转换后的 File |
| | | * @throws IOException 如果发生I/O错误 |
| | | */ |
| | | public static File multipartFileToFile(MultipartFile multipartFile) throws IOException { |
| | | if (multipartFile.isEmpty()) { |
| | | throw new IOException("传入的MultipartFile为空"); |
| | | } |
| | | String originalFilename = multipartFile.getOriginalFilename(); |
| | | String tempFileSuffix = originalFilename != null ? originalFilename.substring(originalFilename.lastIndexOf('.')) : ".tmp"; |
| | | File tempFile = File.createTempFile("temp", tempFileSuffix); |
| | | try (InputStream ins = multipartFile.getInputStream(); |
| | | OutputStream os = new FileOutputStream(tempFile)) { |
| | | byte[] buffer = new byte[8192]; |
| | | int bytesRead; |
| | | while ((bytesRead = ins.read(buffer)) != -1) { |
| | | os.write(buffer, 0, bytesRead); |
| | | } |
| | | } |
| | | return tempFile; |
| | | } |
| | | |
| | | /** |
| | | * 内置一个简单的 MultipartFile 实现类,用于File转换 |
| | | */ |
| | | private static class ByteArrayMultipartFile implements MultipartFile { |
| | | private final byte[] content; |
| | | private final String name; |
| | | private final String originalFilename; |
| | | private final String contentType; |
| | | |
| | | /** |
| | | * 构造函数 |
| | | * |
| | | * @param content 文件内容 |
| | | * @param originalFilename 文件原始名字 |
| | | * @param name 字段名 |
| | | * @param contentType 文件类型 |
| | | */ |
| | | public ByteArrayMultipartFile(byte[] content, String originalFilename, String name, String contentType) { |
| | | this.content = content; |
| | | this.originalFilename = originalFilename; |
| | | this.name = name; |
| | | this.contentType = contentType; |
| | | } |
| | | |
| | | @Override |
| | | public String getName() { |
| | | return this.name; |
| | | } |
| | | |
| | | @Override |
| | | public String getOriginalFilename() { |
| | | return this.originalFilename; |
| | | } |
| | | |
| | | @Override |
| | | public String getContentType() { |
| | | return this.contentType; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isEmpty() { |
| | | return (this.content == null || this.content.length == 0); |
| | | } |
| | | |
| | | @Override |
| | | public long getSize() { |
| | | return this.content.length; |
| | | } |
| | | |
| | | @Override |
| | | public byte[] getBytes() { |
| | | return this.content; |
| | | } |
| | | |
| | | @Override |
| | | public InputStream getInputStream() { |
| | | return new ByteArrayInputStream(this.content); |
| | | } |
| | | |
| | | @Override |
| | | public void transferTo(File dest) throws IOException, IllegalStateException { |
| | | try (OutputStream os = new FileOutputStream(dest)) { |
| | | os.write(this.content); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.tool; |
| | | |
| | | import com.google.zxing.BarcodeFormat; |
| | | import com.google.zxing.EncodeHintType; |
| | | import com.google.zxing.MultiFormatWriter; |
| | | import com.google.zxing.WriterException; |
| | | import com.google.zxing.common.BitMatrix; |
| | | import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.swing.filechooser.FileSystemView; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.File; |
| | | import java.io.OutputStream; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 二维码工具 |
| | | * @Author:debug (SteadyJack) |
| | | * @Link: weixin-> debug0868 qq-> 1948831260 |
| | | * @Date: 2020/11/16 22:38 |
| | | **/ |
| | | public class QRCodeUtil { |
| | | private static final Logger log= LoggerFactory.getLogger(QRCodeUtil.class); |
| | | |
| | | //CODE_WIDTH:二维码宽度,单位像素 |
| | | private static final int CODE_WIDTH = 400; |
| | | //CODE_HEIGHT:二维码高度,单位像素 |
| | | private static final int CODE_HEIGHT = 400; |
| | | //FRONT_COLOR:二维码前景色,0x000000 表示黑色 |
| | | private static final int FRONT_COLOR = 0x000000; |
| | | //BACKGROUND_COLOR:二维码背景色,0xFFFFFF 表示白色 |
| | | //演示用 16 进制表示,和前端页面 CSS 的取色是一样的,注意前后景颜色应该对比明显,如常见的黑白 |
| | | private static final int BACKGROUND_COLOR = 0xFFFFFF; |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | createCodeToFile("5261548530",new File("C:\\Users\\Admin\\Desktop\\qrcode"),"5261548530.png"); |
| | | } |
| | | |
| | | public static void createCodeToFile(String content, File codeImgFileSaveDir, String fileName) { |
| | | try { |
| | | if (StringUtils.isBlank(content) || StringUtils.isBlank(fileName)) { |
| | | return; |
| | | } |
| | | content = content.trim(); |
| | | if (codeImgFileSaveDir==null || codeImgFileSaveDir.isFile()) { |
| | | //二维码图片存在目录为空,默认放在桌面... |
| | | codeImgFileSaveDir = FileSystemView.getFileSystemView().getHomeDirectory(); |
| | | } |
| | | if (!codeImgFileSaveDir.exists()) { |
| | | //二维码图片存在目录不存在,开始创建... |
| | | codeImgFileSaveDir.mkdirs(); |
| | | } |
| | | |
| | | //核心代码-生成二维码 |
| | | BufferedImage bufferedImage = getBufferedImage(content); |
| | | |
| | | File codeImgFile = new File(codeImgFileSaveDir, fileName); |
| | | ImageIO.write(bufferedImage, "png", codeImgFile); |
| | | |
| | | log.info("二维码图片生成成功:" + codeImgFile.getPath()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 生成二维码并输出到输出流, 通常用于输出到网页上进行显示,输出到网页与输出到磁盘上的文件中,区别在于最后一句 ImageIO.write |
| | | * write(RenderedImage im,String formatName,File output):写到文件中 |
| | | * write(RenderedImage im,String formatName,OutputStream output):输出到输出流中 |
| | | * @param content :二维码内容 |
| | | * @param outputStream :输出流,比如 HttpServletResponse 的 getOutputStream |
| | | */ |
| | | public static void createCodeToOutputStream(String content, OutputStream outputStream) { |
| | | try { |
| | | if (StringUtils.isBlank(content)) { |
| | | return; |
| | | } |
| | | content = content.trim(); |
| | | //核心代码-生成二维码 |
| | | BufferedImage bufferedImage = getBufferedImage(content); |
| | | |
| | | //区别就是这一句,输出到输出流中,如果第三个参数是 File,则输出到文件中 |
| | | ImageIO.write(bufferedImage, "png", outputStream); |
| | | |
| | | log.info("二维码图片生成到输出流成功..."); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | //核心代码-生成二维码 |
| | | private static BufferedImage getBufferedImage(String content) throws WriterException { |
| | | |
| | | //com.google.zxing.EncodeHintType:编码提示类型,枚举类型 |
| | | Map<EncodeHintType, Object> hints = new HashMap(); |
| | | |
| | | //EncodeHintType.CHARACTER_SET:设置字符编码类型 |
| | | hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); |
| | | |
| | | //EncodeHintType.ERROR_CORRECTION:设置误差校正 |
| | | //ErrorCorrectionLevel:误差校正等级,L = ~7% correction、M = ~15% correction、Q = ~25% correction、H = ~30% correction |
| | | //不设置时,默认为 L 等级,等级不一样,生成的图案不同,但扫描的结果是一样的 |
| | | hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M); |
| | | |
| | | //EncodeHintType.MARGIN:设置二维码边距,单位像素,值越小,二维码距离四周越近 |
| | | hints.put(EncodeHintType.MARGIN, 1); |
| | | |
| | | MultiFormatWriter multiFormatWriter = new MultiFormatWriter(); |
| | | BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, CODE_WIDTH, CODE_HEIGHT, hints); |
| | | BufferedImage bufferedImage = new BufferedImage(CODE_WIDTH, CODE_HEIGHT, BufferedImage.TYPE_INT_BGR); |
| | | for (int x = 0; x < CODE_WIDTH; x++) { |
| | | for (int y = 0; y < CODE_HEIGHT; y++) { |
| | | bufferedImage.setRGB(x, y, bitMatrix.get(x, y) ? FRONT_COLOR : BACKGROUND_COLOR); |
| | | } |
| | | } |
| | | return bufferedImage; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.core.config; |
| | | |
| | | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * @author xiaochen |
| | | * @ClassName DataUpdateInterceptor |
| | | * @Description 数据更新操作处理 |
| | | * @date 2021-12-15 |
| | | * <p> |
| | | * 注意,之前在此处注入了 JwtTokenUtils |
| | | * <p> |
| | | * 造成spring循环依赖,项目支棱不起来 |
| | | */ |
| | | @Slf4j |
| | | @Configuration |
| | | public class DataUpdateHandlerConfig implements MetaObjectHandler { |
| | | |
| | | /** |
| | | * 新增数据执行 |
| | | * |
| | | * @param metaObject |
| | | */ |
| | | @Override |
| | | public void insertFill(MetaObject metaObject) { |
| | | // 获取登录信息 |
| | | // String userName = SecurityUtils.getUsernameApplet(); |
| | | // if (StringUtils.isNotBlank(userName)) { |
| | | // this.setFieldValByName("createBy", userName, metaObject); |
| | | // this.setFieldValByName("updateBy", userName, metaObject); |
| | | // } else { |
| | | // this.setFieldValByName("createBy", userName, metaObject); |
| | | // this.setFieldValByName("updateBy", userName, metaObject); |
| | | // } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 修改数据执行 |
| | | * |
| | | * @param metaObject |
| | | */ |
| | | @Override |
| | | public void updateFill(MetaObject metaObject) { |
| | | // 获取登录信息 |
| | | // String userName = SecurityUtils.getUsernameApplet(); |
| | | // if (StringUtils.isNotBlank(userName)){ |
| | | // this.setFieldValByName("createBy", userName, metaObject); |
| | | // this.setFieldValByName("updateBy", userName, metaObject); |
| | | // } else { |
| | | // this.setFieldValByName("createBy", userName, metaObject); |
| | | // this.setFieldValByName("updateBy", userName, metaObject); |
| | | // } |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.core.config; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.DbType; |
| | | import com.baomidou.mybatisplus.core.config.GlobalConfig; |
| | | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * @author liheng |
| | | * @ClassName MybatisPlusConfig |
| | | * @Description MybatisPlus相关配置 |
| | | * @date 2020-09-22 11:22、 |
| | | * 直接以实现类作为bean的注入(有事务管理的类) |
| | | * @EnableTransactionManagement(proxyTargetClass = true) |
| | | */ |
| | | @Configuration |
| | | public class MybatisPlusConfig { |
| | | private final DataUpdateHandlerConfig dataUpdateHandler; |
| | | |
| | | @Autowired |
| | | public MybatisPlusConfig(DataUpdateHandlerConfig dataUpdateHandler) { |
| | | this.dataUpdateHandler = dataUpdateHandler; |
| | | } |
| | | |
| | | /** |
| | | * 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题 |
| | | */ |
| | | @Bean |
| | | public MybatisPlusInterceptor mybatisPlusInterceptor() { |
| | | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
| | | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); |
| | | return interceptor; |
| | | } |
| | | |
| | | /** |
| | | * 自动填充功能 |
| | | * |
| | | * @return |
| | | */ |
| | | @Bean |
| | | public GlobalConfig globalConfig() { |
| | | GlobalConfig globalConfig = new GlobalConfig(); |
| | | globalConfig.setMetaObjectHandler(dataUpdateHandler); |
| | | return globalConfig; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | 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 io.swagger.models.auth.In; |
| | | 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.service.SecurityScheme; |
| | | import springfox.documentation.spi.DocumentationType; |
| | | import springfox.documentation.spi.service.contexts.SecurityContext; |
| | | import springfox.documentation.spring.web.plugins.Docket; |
| | | |
| | | /** |
| | | * Swagger2的接口配置 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Configuration |
| | | 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.OAS_30) |
| | | // 是否启用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<SecurityScheme> securitySchemes() |
| | | { |
| | | List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>(); |
| | | apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue())); |
| | | return apiKeyList; |
| | | } |
| | | |
| | | /** |
| | | * 安全上下文 |
| | | */ |
| | | private List<SecurityContext> securityContexts() |
| | | { |
| | | List<SecurityContext> securityContexts = new ArrayList<>(); |
| | | securityContexts.add( |
| | | SecurityContext.builder() |
| | | .securityReferences(defaultAuth()) |
| | | .operationSelector(o -> o.requestMappingPattern().matches("/.*")) |
| | | .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("西藏国投接口文档") |
| | | // 作者信息 |
| | | .contact(new Contact(ruoyiConfig.getName(), null, null)) |
| | | // 版本 |
| | | .version("版本号:" + ruoyiConfig.getVersion()) |
| | | .build(); |
| | | } |
| | | } |
New file |
| | |
| | | restart.include.json=/com.alibaba.fastjson.*.jar |
New file |
| | |
| | | # 项目相关配置 |
| | | ruoyi: |
| | | # 名称 |
| | | name: RuoYi |
| | | # 版本 |
| | | version: 3.8.6 |
| | | # 版权年份 |
| | | copyrightYear: 2023 |
| | | # 实例演示开关 |
| | | demoEnabled: true |
| | | # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) |
| | | profile: D:/ruoyi/uploadPath |
| | | # 获取ip地址开关 |
| | | addressEnabled: false |
| | | # 验证码类型 math 数字计算 char 字符验证 |
| | | captchaType: math |
| | | |
| | | # 开发环境配置 |
| | | server: |
| | | # 服务器的HTTP端口,默认为8080 |
| | | port: 8082 |
| | | servlet: |
| | | # 应用的访问路径 |
| | | context-path: / |
| | | tomcat: |
| | | # tomcat的URI编码 |
| | | uri-encoding: UTF-8 |
| | | # 连接数满后的排队数,默认为100 |
| | | accept-count: 1000 |
| | | threads: |
| | | # tomcat最大线程数,默认为200 |
| | | max: 800 |
| | | # Tomcat启动初始化的线程数,默认值10 |
| | | min-spare: 100 |
| | | |
| | | # 日志配置 |
| | | logging: |
| | | level: |
| | | com.ruoyi: debug |
| | | org.springframework: warn |
| | | |
| | | # 用户配置 |
| | | user: |
| | | password: |
| | | # 密码最大错误次数 |
| | | maxRetryCount: 5 |
| | | # 密码锁定时间(默认10分钟) |
| | | lockTime: 10 |
| | | |
| | | # Spring配置 |
| | | spring: |
| | | main: |
| | | allow-bean-definition-overriding: true |
| | | # 资源信息 |
| | | messages: |
| | | # 国际化资源文件路径 |
| | | basename: i18n/messages |
| | | # 文件上传 |
| | | servlet: |
| | | multipart: |
| | | # 单个文件大小 |
| | | max-file-size: 500MB |
| | | # 设置总上传的文件大小 |
| | | max-request-size: 2000MB |
| | | # 服务模块 |
| | | devtools: |
| | | restart: |
| | | # 热部署开关 |
| | | enabled: true |
| | | # redis 配置 |
| | | redis: |
| | | # 地址 |
| | | # host: 127.0.0.1 |
| | | # # 端口,默认为6379 |
| | | # port: 6379 |
| | | # # 数据库索引 |
| | | # database: 0 |
| | | # # 密码 |
| | | # password: 123456 |
| | | host: 127.0.0.1 |
| | | # 端口,默认为6379 |
| | | port: 16379 |
| | | # 数据库索引 |
| | | database: 0 |
| | | # 密码 |
| | | password: 8f5z9g52gx4bg |
| | | # 连接超时时间 |
| | | timeout: 10s |
| | | lettuce: |
| | | pool: |
| | | # 连接池中的最小空闲连接 |
| | | min-idle: 0 |
| | | # 连接池中的最大空闲连接 |
| | | max-idle: 8 |
| | | # 连接池的最大数据库连接数 |
| | | max-active: 8 |
| | | # #连接池最大阻塞等待时间(使用负值表示没有限制) |
| | | max-wait: -1ms |
| | | # 数据源配置 |
| | | datasource: |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | driverClassName: com.mysql.cj.jdbc.Driver |
| | | druid: |
| | | # 主库数据源 |
| | | master: |
| | | url: jdbc:mysql://172.27.0.13:3306/xizang?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai |
| | | username: xzgt |
| | | password: changyun!6f2gshj6h3j |
| | | # 从库数据源 |
| | | slave: |
| | | # 从数据源开关/默认关闭 |
| | | enabled: false |
| | | url: |
| | | username: |
| | | password: |
| | | # 初始连接数 |
| | | initialSize: 5 |
| | | # 最小连接池数量 |
| | | minIdle: 10 |
| | | # 最大连接池数量 |
| | | maxActive: 20 |
| | | # 配置获取连接等待超时的时间 |
| | | maxWait: 60000 |
| | | # 配置连接超时时间 |
| | | connectTimeout: 30000 |
| | | # 配置网络超时时间 |
| | | socketTimeout: 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: ruoyi |
| | | login-password: 123456 |
| | | filter: |
| | | stat: |
| | | enabled: true |
| | | # 慢SQL记录 |
| | | log-slow-sql: true |
| | | slow-sql-millis: 1000 |
| | | merge-sql: true |
| | | wall: |
| | | config: |
| | | multi-statement-allow: true |
| | | # token配置 |
| | | token: |
| | | # 令牌自定义标识 |
| | | header: Authorization |
| | | # 令牌密钥 |
| | | secret: abcdefghijklmnopqrstuvwxyz |
| | | # 令牌有效期(默认30分钟) |
| | | expireTime: 120 |
| | | |
| | | mybatis-plus: |
| | | # 此处在多数据源中生效 |
| | | config-location: classpath:/mybatis-config.xml |
| | | global-config: |
| | | banner: false |
| | | db-config: |
| | | logic-not-delete-value: 0 |
| | | logic-delete-value: 1 |
| | | type-aliases-package: com.ruoyi.**.domain,com.ruoyi.**.vo,com.ruoyi.**.model |
| | | # 指定Mapper文件位置 |
| | | mapper-locations: classpath*:mapper/**/*.xml |
| | | |
| | | # Swagger配置 |
| | | swagger: |
| | | # 是否开启swagger |
| | | enabled: true |
| | | # 请求前缀 |
| | | pathMapping: / |
| | | |
| | | # 防止XSS攻击 |
| | | xss: |
| | | # 过滤开关 |
| | | enabled: true |
| | | # 排除链接(多个用逗号分隔) |
| | | excludes: /system/notice |
| | | # 匹配链接 |
| | | urlPatterns: /system/*,/monitor/*,/tool/* |
| | | # file upload |
| | | file: |
| | | upload: |
| | | location: /file/ |
| | | qrLocation: /file/qrCode/ |
| | | accessPath: /file/ |
| | | allowExt: .jpg|.png|.gif|.jpeg|.doc|.docx|.apk|.MP4|.mp4|.pdf|.PDF |
| | | url: |
| | | prefix: https://xzgt.test.591taxi.cn:${server.port}${server.servlet.context-path} |
| | | wx: |
| | | conf: |
| | | appId: wxe91f1af7638aa5dd |
| | | secretId: a787e1a462715604e0c9528b6d8960d1 |
| | | #OSS及短信配置 |
| | | code: |
| | | config: |
| | | templateCodeTest: "SMS_154950909" |
| | | signNameTest: "阿里云短信测试" |
| | | accessKeyId: LTAI5tAdba8HtT1C6UqtSxBt |
| | | accessKeySecret: 0SRb6XGkciQDPWn2rYqbJtq2qRMDY8 |
| | | signName: "四川金达通信工程" |
| | | templateCode: "SMS_293985284" |
| | | cos: |
| | | client: |
| | | accessKey: AKIDCF5EF2c0DE1e5JK8r4EGJF4mNsMgp26x |
| | | secretKey: lLl184rUyFOOE0d5KNGC3kmfNsCWk4GU |
| | | bucket: xzgttest-1305134071 |
| | | bucketAddr: ap-chengdu |
| | | rootSrc: https://xzgttest-1305134071.cos.ap-chengdu.myqcloud.com/ |
| | | location: xizang |
| | | sms: |
| | | enable: true |
| | | appId: 1400957506 |
| | | secretid: AKIDCF5EF2c0DE1e5JK8r4EGJF4mNsMgp26x |
| | | secretkey: lLl184rUyFOOE0d5KNGC3kmfNsCWk4GU |
| | | sign: 畅云出行 |
New file |
| | |
| | | # 项目相关配置 |
| | | ruoyi: |
| | | # 名称 |
| | | name: RuoYi |
| | | # 版本 |
| | | version: 3.8.6 |
| | | # 版权年份 |
| | | copyrightYear: 2023 |
| | | # 实例演示开关 |
| | | demoEnabled: true |
| | | # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) |
| | | profile: D:/ruoyi/uploadPath |
| | | # 获取ip地址开关 |
| | | addressEnabled: false |
| | | # 验证码类型 math 数字计算 char 字符验证 |
| | | captchaType: math |
| | | |
| | | # 开发环境配置 |
| | | server: |
| | | # 服务器的HTTP端口,默认为8080 |
| | | port: 8082 |
| | | servlet: |
| | | # 应用的访问路径 |
| | | context-path: / |
| | | tomcat: |
| | | # tomcat的URI编码 |
| | | uri-encoding: UTF-8 |
| | | # 连接数满后的排队数,默认为100 |
| | | accept-count: 1000 |
| | | threads: |
| | | # tomcat最大线程数,默认为200 |
| | | max: 800 |
| | | # Tomcat启动初始化的线程数,默认值10 |
| | | min-spare: 100 |
| | | |
| | | # 日志配置 |
| | | logging: |
| | | level: |
| | | com.ruoyi: debug |
| | | org.springframework: warn |
| | | |
| | | # 用户配置 |
| | | user: |
| | | password: |
| | | # 密码最大错误次数 |
| | | maxRetryCount: 5 |
| | | # 密码锁定时间(默认10分钟) |
| | | lockTime: 10 |
| | | |
| | | # Spring配置 |
| | | spring: |
| | | main: |
| | | allow-bean-definition-overriding: true |
| | | # 资源信息 |
| | | messages: |
| | | # 国际化资源文件路径 |
| | | basename: i18n/messages |
| | | # 文件上传 |
| | | servlet: |
| | | multipart: |
| | | # 单个文件大小 |
| | | max-file-size: 500MB |
| | | # 设置总上传的文件大小 |
| | | max-request-size: 2000MB |
| | | # 服务模块 |
| | | devtools: |
| | | restart: |
| | | # 热部署开关 |
| | | enabled: true |
| | | # redis 配置 |
| | | redis: |
| | | # 地址 |
| | | # host: 127.0.0.1 |
| | | # # 端口,默认为6379 |
| | | # port: 6379 |
| | | # # 数据库索引 |
| | | # database: 0 |
| | | # # 密码 |
| | | # password: 123456 |
| | | host: xzgt.test.591taxi.cn |
| | | # 端口,默认为6379 |
| | | port: 16379 |
| | | # 数据库索引 |
| | | database: 0 |
| | | # 密码 |
| | | password: 8f5z9g52gx4bg |
| | | # 连接超时时间 |
| | | timeout: 10s |
| | | lettuce: |
| | | pool: |
| | | # 连接池中的最小空闲连接 |
| | | min-idle: 0 |
| | | # 连接池中的最大空闲连接 |
| | | max-idle: 8 |
| | | # 连接池的最大数据库连接数 |
| | | max-active: 8 |
| | | # #连接池最大阻塞等待时间(使用负值表示没有限制) |
| | | max-wait: -1ms |
| | | # 数据源配置 |
| | | datasource: |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | driverClassName: com.mysql.cj.jdbc.Driver |
| | | druid: |
| | | # 主库数据源 |
| | | master: |
| | | url: jdbc:mysql://xzgt.test.591taxi.cn:13306/xizang?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai |
| | | username: root |
| | | password: 8f5z9g52gx4bg |
| | | # 从库数据源 |
| | | slave: |
| | | # 从数据源开关/默认关闭 |
| | | enabled: false |
| | | url: |
| | | username: |
| | | password: |
| | | # 初始连接数 |
| | | initialSize: 5 |
| | | # 最小连接池数量 |
| | | minIdle: 10 |
| | | # 最大连接池数量 |
| | | maxActive: 20 |
| | | # 配置获取连接等待超时的时间 |
| | | maxWait: 60000 |
| | | # 配置连接超时时间 |
| | | connectTimeout: 30000 |
| | | # 配置网络超时时间 |
| | | socketTimeout: 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: ruoyi |
| | | login-password: 123456 |
| | | filter: |
| | | stat: |
| | | enabled: true |
| | | # 慢SQL记录 |
| | | log-slow-sql: true |
| | | slow-sql-millis: 1000 |
| | | merge-sql: true |
| | | wall: |
| | | config: |
| | | multi-statement-allow: true |
| | | # token配置 |
| | | token: |
| | | # 令牌自定义标识 |
| | | header: Authorization |
| | | # 令牌密钥 |
| | | secret: abcdefghijklmnopqrstuvwxyz |
| | | # 令牌有效期(默认30分钟) |
| | | expireTime: 120 |
| | | |
| | | mybatis-plus: |
| | | # 此处在多数据源中生效 |
| | | config-location: classpath:/mybatis-config.xml |
| | | global-config: |
| | | banner: false |
| | | db-config: |
| | | logic-not-delete-value: 0 |
| | | logic-delete-value: 1 |
| | | type-aliases-package: com.ruoyi.**.domain,com.ruoyi.**.vo,com.ruoyi.**.model |
| | | # 指定Mapper文件位置 |
| | | mapper-locations: classpath*:mapper/**/*.xml |
| | | |
| | | # Swagger配置 |
| | | swagger: |
| | | # 是否开启swagger |
| | | enabled: true |
| | | # 请求前缀 |
| | | pathMapping: / |
| | | |
| | | # 防止XSS攻击 |
| | | xss: |
| | | # 过滤开关 |
| | | enabled: true |
| | | # 排除链接(多个用逗号分隔) |
| | | excludes: /system/notice |
| | | # 匹配链接 |
| | | urlPatterns: /system/*,/monitor/*,/tool/* |
| | | # file upload |
| | | file: |
| | | upload: |
| | | location: /file/ |
| | | qrLocation: /file/qrCode/ |
| | | accessPath: /file/ |
| | | allowExt: .jpg|.png|.gif|.jpeg|.doc|.docx|.apk|.MP4|.mp4|.pdf|.PDF |
| | | url: |
| | | # prefix: http://localhost:${server.port}${server.servlet.context-path} |
| | | prefix: https://xzgt.test.591taxi.cn:${server.port}${server.servlet.context-path} |
| | | wx: |
| | | conf: |
| | | appId: wxe91f1af7638aa5dd |
| | | secretId: a787e1a462715604e0c9528b6d8960d1 |
| | | #OSS及短信配置 |
| | | code: |
| | | config: |
| | | templateCodeTest: "SMS_154950909" |
| | | signNameTest: "阿里云短信测试" |
| | | accessKeyId: LTAI5tAdba8HtT1C6UqtSxBt |
| | | accessKeySecret: 0SRb6XGkciQDPWn2rYqbJtq2qRMDY8 |
| | | signName: "四川金达通信工程" |
| | | templateCode: "SMS_293985284" |
| | | cos: |
| | | client: |
| | | accessKey: AKIDCF5EF2c0DE1e5JK8r4EGJF4mNsMgp26x |
| | | secretKey: lLl184rUyFOOE0d5KNGC3kmfNsCWk4GU |
| | | bucket: xzgttest-1305134071 |
| | | bucketAddr: ap-chengdu |
| | | rootSrc: https://xzgttest-1305134071.cos.ap-chengdu.myqcloud.com/ |
| | | location: xizang |
| | | sms: |
| | | enable: true |
| | | appId: 1400957506 |
| | | secretid: AKIDCF5EF2c0DE1e5JK8r4EGJF4mNsMgp26x |
| | | secretkey: lLl184rUyFOOE0d5KNGC3kmfNsCWk4GU |
| | | sign: 畅云出行 |
New file |
| | |
| | | # 项目相关配置 |
| | | spring: |
| | | profiles: |
| | | active: test |
New file |
| | |
| | | Application Version: ${ruoyi.version} |
| | | Spring Boot Version: ${spring-boot.version} |
| | | //////////////////////////////////////////////////////////////////// |
| | | // _ooOoo_ // |
| | | // o8888888o // |
| | | // 88" . "88 // |
| | | // (| ^_^ |) // |
| | | // O\ = /O // |
| | | // ____/`---'\____ // |
| | | // .' \\| |// `. // |
| | | // / \\||| : |||// \ // |
| | | // / _||||| -:- |||||- \ // |
| | | // | | \\\ - /// | | // |
| | | // | \_| ''\---/'' | | // |
| | | // \ .-\__ `-` ___/-. / // |
| | | // ___`. .' /--.--\ `. . ___ // |
| | | // ."" '< `.___\_<|>_/___.' >'"". // |
| | | // | | : `- \`.;`\ _ /`;.`/ - ` : | | // |
| | | // \ \ `-. \_ __\ /__ _/ .-` / / // |
| | | // ========`-.____`-.___\_____/___.-`____.-'======== // |
| | | // `=---=' // |
| | | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // |
| | | // 佛祖保佑 永不宕机 永无BUG // |
| | | //////////////////////////////////////////////////////////////////// |
New file |
| | |
| | | #错误消息 |
| | | not.null=* 必须填写 |
| | | user.jcaptcha.error=验证码错误 |
| | | user.jcaptcha.expire=验证码已失效 |
| | | user.not.exists=用户不存在/密码错误 |
| | | user.password.not.match=用户不存在/密码错误 |
| | | user.password.retry.limit.count=密码输入错误{0}次 |
| | | user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定{1}分钟 |
| | | user.password.delete=对不起,您的账号已被删除 |
| | | user.blocked=用户已封禁,请联系管理员 |
| | | role.blocked=角色已封禁,请联系管理员 |
| | | login.blocked=很遗憾,访问IP已被列入系统黑名单 |
| | | user.logout.success=退出成功 |
| | | |
| | | length.not.valid=长度必须在{min}到{max}个字符之间 |
| | | |
| | | user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成,且必须以非数字开头 |
| | | user.password.not.valid=* 5-50个字符 |
| | | |
| | | user.email.not.valid=邮箱格式错误 |
| | | user.mobile.phone.number.not.valid=手机号格式错误 |
| | | user.login.success=登录成功 |
| | | user.register.success=注册成功 |
| | | user.notfound=请重新登录 |
| | | user.forcelogout=管理员强制退出,请重新登录 |
| | | user.unknown.error=未知错误,请重新登录 |
| | | |
| | | ##文件上传消息 |
| | | upload.exceed.maxSize=上传的文件大小超出限制的文件大小!<br/>允许的文件最大大小是:{0}MB! |
| | | upload.filename.exceed.length=上传的文件名最长{0}个字符 |
| | | |
| | | ##权限 |
| | | no.permission=您没有数据的权限,请联系管理员添加权限 [{0}] |
| | | no.create.permission=您没有创建数据的权限,请联系管理员添加权限 [{0}] |
| | | no.update.permission=您没有修改数据的权限,请联系管理员添加权限 [{0}] |
| | | no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}] |
| | | no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}] |
| | | no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}] |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <configuration> |
| | | <!-- 日志存放路径 --> |
| | | <property name="log.path" value="/home/ruoyi/logs" /> |
| | | <!-- 日志输出格式 --> |
| | | <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" /> |
| | | |
| | | <!-- 控制台输出 --> |
| | | <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> |
| | | <encoder> |
| | | <pattern>${log.pattern}</pattern> |
| | | </encoder> |
| | | </appender> |
| | | |
| | | <!-- 系统日志输出 --> |
| | | <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <file>${log.path}/sys-info.log</file> |
| | | <!-- 循环政策:基于时间创建日志文件 --> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
| | | <!-- 日志文件名格式 --> |
| | | <fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern> |
| | | <!-- 日志最大的历史 60天 --> |
| | | <maxHistory>60</maxHistory> |
| | | </rollingPolicy> |
| | | <encoder> |
| | | <pattern>${log.pattern}</pattern> |
| | | </encoder> |
| | | <filter class="ch.qos.logback.classic.filter.LevelFilter"> |
| | | <!-- 过滤的级别 --> |
| | | <level>INFO</level> |
| | | <!-- 匹配时的操作:接收(记录) --> |
| | | <onMatch>ACCEPT</onMatch> |
| | | <!-- 不匹配时的操作:拒绝(不记录) --> |
| | | <onMismatch>DENY</onMismatch> |
| | | </filter> |
| | | </appender> |
| | | |
| | | <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <file>${log.path}/sys-error.log</file> |
| | | <!-- 循环政策:基于时间创建日志文件 --> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
| | | <!-- 日志文件名格式 --> |
| | | <fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern> |
| | | <!-- 日志最大的历史 60天 --> |
| | | <maxHistory>60</maxHistory> |
| | | </rollingPolicy> |
| | | <encoder> |
| | | <pattern>${log.pattern}</pattern> |
| | | </encoder> |
| | | <filter class="ch.qos.logback.classic.filter.LevelFilter"> |
| | | <!-- 过滤的级别 --> |
| | | <level>ERROR</level> |
| | | <!-- 匹配时的操作:接收(记录) --> |
| | | <onMatch>ACCEPT</onMatch> |
| | | <!-- 不匹配时的操作:拒绝(不记录) --> |
| | | <onMismatch>DENY</onMismatch> |
| | | </filter> |
| | | </appender> |
| | | |
| | | <!-- 用户访问日志输出 --> |
| | | <appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <file>${log.path}/sys-user.log</file> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
| | | <!-- 按天回滚 daily --> |
| | | <fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern> |
| | | <!-- 日志最大的历史 60天 --> |
| | | <maxHistory>60</maxHistory> |
| | | </rollingPolicy> |
| | | <encoder> |
| | | <pattern>${log.pattern}</pattern> |
| | | </encoder> |
| | | </appender> |
| | | |
| | | <!-- 系统模块日志级别控制 --> |
| | | <logger name="com.ruoyi" level="info" /> |
| | | <!-- Spring日志级别控制 --> |
| | | <logger name="org.springframework" level="warn" /> |
| | | |
| | | <root level="info"> |
| | | <appender-ref ref="console" /> |
| | | </root> |
| | | |
| | | <!--系统操作日志--> |
| | | <root level="info"> |
| | | <appender-ref ref="file_info" /> |
| | | <appender-ref ref="file_error" /> |
| | | </root> |
| | | |
| | | <!--系统用户操作日志--> |
| | | <logger name="sys-user" level="info"> |
| | | <appender-ref ref="sys-user"/> |
| | | </logger> |
| | | </configuration> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> |
| | | <configuration> |
| | | |
| | | <settings> |
| | | <!-- 打印查询语句 不会写入到日志文件中--> |
| | | <setting name="logImpl" value="STDOUT_LOGGING"/> |
| | | <!--<setting name="logImpl" value="LOG4J" />--> |
| | | <!-- 控制全局缓存(二级缓存),按美团技术团队的说法,尽量别用缓存机制 emmmm.... --> |
| | | <setting name="cacheEnabled" value="true"/> |
| | | <!-- 延迟加载的全局开关。当开启时,所有关联对象都会延迟加载。默认 false --> |
| | | <!-- <setting name="lazyLoadingEnabled" value="true"/> --> |
| | | <setting name="mapUnderscoreToCamelCase" value="true"/><!--是否将map下划线方式转为驼峰式命名--> |
| | | <!-- 当开启时,任何方法的调用都会加载该对象的所有属性。默认 false,可通过select标签的 fetchType来覆盖--> |
| | | <!-- <setting name="aggressiveLazyLoading" value="false"/>--> |
| | | <!-- Mybatis 创建具有延迟加载能力的对象所用到的代理工具,默认JAVASSIST --> |
| | | <!--<setting name="proxyFactory" value="CGLIB" />--> |
| | | <!-- 关于mybatis的一二级缓存 请参照:https://tech.meituan.com/2018/01/19/mybatis-cache.html --> |
| | | <!-- 一级缓存范围默认:SESSION ,此范围在复杂应用场景中可能会出现脏读数据--> |
| | | <!-- STATEMENT级别的缓存,使一级缓存,只针对当前执行的这一statement有效 --> |
| | | <!--<setting name="localCacheScope" value="STATEMENT"/>--> |
| | | <setting name="localCacheScope" value="STATEMENT"/> |
| | | </settings> |
| | | |
| | | </configuration> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE configuration |
| | | PUBLIC "-//mybatis.org//DTD Config 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-config.dtd"> |
| | | <configuration> |
| | | <!-- 全局参数 --> |
| | | <settings> |
| | | <!-- 使全局的映射器启用或禁用缓存 --> |
| | | <setting name="cacheEnabled" value="true" /> |
| | | <!-- 允许JDBC 支持自动生成主键 --> |
| | | <setting name="useGeneratedKeys" value="true" /> |
| | | <!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 --> |
| | | <setting name="defaultExecutorType" value="SIMPLE" /> |
| | | <!-- 指定 MyBatis 所用日志的具体实现 --> |
| | | <setting name="logImpl" value="SLF4J" /> |
| | | <!-- 使用驼峰命名法转换字段 --> |
| | | <!-- <setting name="mapUnderscoreToCamelCase" value="true"/> --> |
| | | </settings> |
| | | |
| | | </configuration> |
New file |
| | |
| | | <?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.8.6</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>ruoyi-common</artifactId> |
| | | |
| | | <description> |
| | | common通用工具 |
| | | </description> |
| | | <properties> |
| | | <swagger.fox.version>3.0.0</swagger.fox.version> |
| | | <swagger.core.version>1.6.2</swagger.core.version> |
| | | </properties> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>com.documents4j</groupId> |
| | | <artifactId>documents4j-local</artifactId> |
| | | <version>1.0.3</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.documents4j</groupId> |
| | | <artifactId>documents4j-transformer-msoffice-word</artifactId> |
| | | <version>1.0.3</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.freemarker</groupId> |
| | | <artifactId>freemarker</artifactId> |
| | | <version>2.3.33</version> |
| | | </dependency> |
| | | <!-- 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>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-validation</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> |
| | | |
| | | <!-- 动态数据源 --> |
| | | <dependency> |
| | | <groupId>com.baomidou</groupId> |
| | | <artifactId>dynamic-datasource-spring-boot-starter</artifactId> |
| | | <version>3.5.2</version> |
| | | </dependency> |
| | | |
| | | <!-- 阿里JSON解析器 --> |
| | | <dependency> |
| | | <groupId>com.alibaba.fastjson2</groupId> |
| | | <artifactId>fastjson2</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- io常用工具类 --> |
| | | <dependency> |
| | | <groupId>commons-io</groupId> |
| | | <artifactId>commons-io</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> |
| | | |
| | | <!-- Jaxb --> |
| | | <dependency> |
| | | <groupId>javax.xml.bind</groupId> |
| | | <artifactId>jaxb-api</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> |
| | | <!--mybatis-plus--> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>com.baomidou</groupId>--> |
| | | <!-- <artifactId>mybatis-plus-boot-starter</artifactId>--> |
| | | <!-- <version>3.5.2</version>--> |
| | | <!-- </dependency>--> |
| | | <dependency> |
| | | <groupId>com.baomidou</groupId> |
| | | <artifactId>mybatis-plus-boot-starter</artifactId> |
| | | <version>3.5.7</version> |
| | | </dependency> |
| | | <!--lombok--> |
| | | <dependency> |
| | | <groupId>org.projectlombok</groupId> |
| | | <artifactId>lombok</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>io.springfox</groupId> |
| | | <artifactId>springfox-swagger-ui</artifactId> |
| | | <version>3.0.0</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.github.xiaoymin</groupId> |
| | | <artifactId>knife4j-spring-boot-starter</artifactId> |
| | | <version>3.0.3</version> |
| | | </dependency> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>io.swagger</groupId>--> |
| | | <!-- <artifactId>swagger-models</artifactId>--> |
| | | <!-- <version>${swagger.core.version}</version>--> |
| | | <!-- </dependency>--> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>io.swagger</groupId>--> |
| | | <!-- <artifactId>swagger-annotations</artifactId>--> |
| | | <!-- <version>${swagger.core.version}</version>--> |
| | | <!-- </dependency>--> |
| | | |
| | | <dependency> |
| | | <groupId>ws.schild</groupId> |
| | | <artifactId>jave-all-deps</artifactId> |
| | | <version>2.5.1</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.tencentcloudapi</groupId> |
| | | <artifactId>tencentcloud-sdk-java</artifactId> |
| | | <version>4.0.11</version> |
| | | </dependency> |
| | | |
| | | <!-- 工作流--> |
| | | <dependency> |
| | | <groupId>com.aizuda</groupId> |
| | | <artifactId>flowlong-spring-boot-starter</artifactId> |
| | | <version>1.0.4</version> |
| | | </dependency> |
| | | |
| | | <!-- hutool--> |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-all</artifactId> |
| | | <version>5.8.4</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.sun.mail</groupId> |
| | | <artifactId>javax.mail</artifactId> |
| | | <version>1.6.2</version> <!-- 请检查是否有更新的版本 --> |
| | | </dependency> |
| | | |
| | | <!--国密加密依赖--> |
| | | <dependency> |
| | | <groupId>org.bouncycastle</groupId> |
| | | <artifactId>bcprov-jdk15on</artifactId> |
| | | <version>1.68</version> |
| | | </dependency> |
| | | |
| | | <!-- https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api --> |
| | | |
| | | </dependencies> |
| | | |
| | | </project> |
New file |
| | |
| | | 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, ElementType.TYPE }) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | public @interface Anonymous |
| | | { |
| | | } |
New file |
| | |
| | | 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 ""; |
| | | |
| | | /** |
| | | * 权限字符(用于多个角色匹配符合要求的权限)默认根据权限注解@ss获取,多个权限用逗号分隔开来 |
| | | */ |
| | | public String permission() default ""; |
| | | } |
New file |
| | |
| | | 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; |
| | | } |
New file |
| | |
| | | //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; |
| | | //import java.math.BigDecimal; |
| | | //import org.apache.poi.ss.usermodel.HorizontalAlignment; |
| | | //import org.apache.poi.ss.usermodel.IndexedColors; |
| | | //import com.ruoyi.common.utils.poi.ExcelHandlerAdapter; |
| | | // |
| | | ///** |
| | | // * 自定义导出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 ""; |
| | | // |
| | | // /** |
| | | // * 如果是字典类型,请设置字典的type值 (如: sys_user_sex) |
| | | // */ |
| | | // public String dictType() default ""; |
| | | // |
| | | // /** |
| | | // * 读取内容转表达式 (如: 0=男,1=女,2=未知) |
| | | // */ |
| | | // public String readConverterExp() default ""; |
| | | // |
| | | // /** |
| | | // * 分隔符,读取字符串组内容 |
| | | // */ |
| | | // public String separator() default ","; |
| | | // |
| | | // /** |
| | | // * BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化) |
| | | // */ |
| | | // public int scale() default -1; |
| | | // |
| | | // /** |
| | | // * BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN |
| | | // */ |
| | | // public int roundingMode() default BigDecimal.ROUND_HALF_EVEN; |
| | | // |
| | | // /** |
| | | // * 导出时在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 {}; |
| | | // |
| | | // /** |
| | | // * 是否需要纵向合并单元格,应对需求:含有list集合单元格) |
| | | // */ |
| | | // public boolean needMerge() default false; |
| | | // |
| | | // /** |
| | | // * 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写. |
| | | // */ |
| | | // public boolean isExport() default true; |
| | | // |
| | | // /** |
| | | // * 另一个类中的属性名称,支持多级获取,以小数点隔开 |
| | | // */ |
| | | // public String targetAttr() default ""; |
| | | // |
| | | // /** |
| | | // * 是否自动统计数据,在最后追加一行统计数据总和 |
| | | // */ |
| | | // public boolean isStatistics() default false; |
| | | // |
| | | // /** |
| | | // * 导出类型(0数字 1字符串 2图片) |
| | | // */ |
| | | // public ColumnType cellType() default ColumnType.STRING; |
| | | // |
| | | // /** |
| | | // * 导出列头背景颜色 |
| | | // */ |
| | | // public IndexedColors headerBackgroundColor() default IndexedColors.GREY_50_PERCENT; |
| | | // |
| | | // /** |
| | | // * 导出列头字体颜色 |
| | | // */ |
| | | // public IndexedColors headerColor() default IndexedColors.WHITE; |
| | | // |
| | | // /** |
| | | // * 导出单元格背景颜色 |
| | | // */ |
| | | // public IndexedColors backgroundColor() default IndexedColors.WHITE; |
| | | // |
| | | // /** |
| | | // * 导出单元格字体颜色 |
| | | // */ |
| | | // public IndexedColors color() default IndexedColors.BLACK; |
| | | // |
| | | // /** |
| | | // * 导出字段对齐方式 |
| | | // */ |
| | | // public HorizontalAlignment align() default HorizontalAlignment.CENTER; |
| | | // |
| | | // /** |
| | | // * 自定义数据处理器 |
| | | // */ |
| | | // public Class<?> handler() default ExcelHandlerAdapter.class; |
| | | // |
| | | // /** |
| | | // * 自定义数据处理器参数 |
| | | // */ |
| | | // public String[] args() 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), IMAGE(2); |
| | | // private final int value; |
| | | // |
| | | // ColumnType(int value) |
| | | // { |
| | | // this.value = value; |
| | | // } |
| | | // |
| | | // public int value() |
| | | // { |
| | | // return this.value; |
| | | // } |
| | | // } |
| | | //} |
New file |
| | |
| | | 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 |
| | | { |
| | | // public Excel[] value(); |
| | | } |
New file |
| | |
| | | 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; |
| | | |
| | | /** |
| | | * 是否保存响应的参数 |
| | | */ |
| | | public boolean isSaveResponseData() default true; |
| | | |
| | | /** |
| | | * 排除指定的请求参数 |
| | | */ |
| | | public String[] excludeParamNames() default {}; |
| | | } |
New file |
| | |
| | | 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.constant.CacheConstants; |
| | | import com.ruoyi.common.enums.LimitType; |
| | | |
| | | /** |
| | | * 限流注解 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Target(ElementType.METHOD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | public @interface RateLimiter |
| | | { |
| | | /** |
| | | * 限流key |
| | | */ |
| | | public String key() default CacheConstants.RATE_LIMIT_KEY; |
| | | |
| | | /** |
| | | * 限流时间,单位秒 |
| | | */ |
| | | public int time() default 60; |
| | | |
| | | /** |
| | | * 限流次数 |
| | | */ |
| | | public int count() default 100; |
| | | |
| | | /** |
| | | * 限流类型 |
| | | */ |
| | | public LimitType limitType() default LimitType.DEFAULT; |
| | | } |
New file |
| | |
| | | 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 |
| | | { |
| | | /** |
| | | * 间隔时间(ms),小于此时间视为重复提交 |
| | | */ |
| | | public int interval() default 5000; |
| | | |
| | | /** |
| | | * 提示消息 |
| | | */ |
| | | public String message() default "不允许重复提交,请稍候再试"; |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.basic; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author liheng |
| | | * @Date 2019/08/26 10:28 AM |
| | | * @Description |
| | | */ |
| | | @JsonIgnoreProperties({"orders", "optimizeCountSql", "hitCount", "countId", "maxLimit", "searchCount"}) |
| | | public class PageInfo<T> extends Page<T> implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | private boolean hasNextPage; |
| | | private boolean hasPrevPage; |
| | | private long startIndex; |
| | | |
| | | public PageInfo(long currentPage, long pageShowCount) { |
| | | super(currentPage, pageShowCount); |
| | | this.startIndex = super.offset(); |
| | | } |
| | | |
| | | public PageInfo() { |
| | | super(); |
| | | } |
| | | |
| | | private static boolean hasPrevPage(long currentPage) { |
| | | return currentPage != 1; |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<T> setRecords(List<T> records) { |
| | | super.setRecords(records); |
| | | this.hasNextPage = super.hasNext(); |
| | | this.hasPrevPage = super.hasPrevious(); |
| | | return this; |
| | | } |
| | | |
| | | public boolean getHasNextPage() { |
| | | return hasNextPage; |
| | | } |
| | | |
| | | public void setHasNextPage(boolean hasNextPage) { |
| | | this.hasNextPage = hasNextPage; |
| | | } |
| | | |
| | | public boolean getHasPrevPage() { |
| | | return hasPrevPage; |
| | | } |
| | | |
| | | public void setHasPrevPage(boolean hasPrevPage) { |
| | | this.hasPrevPage = hasPrevPage; |
| | | } |
| | | |
| | | private boolean hasNextPage(long currentPage, long totalPage) { |
| | | return currentPage < totalPage && totalPage != 0; |
| | | } |
| | | |
| | | public long getStartIndex() { |
| | | return startIndex; |
| | | } |
| | | |
| | | public void setStartIndex(long startIndex) { |
| | | this.startIndex = startIndex; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.config; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * <p>文件上传配置</p> |
| | | * |
| | | * @author mouseyCat |
| | | * @date 2020/10/13 16:10 |
| | | */ |
| | | @Data |
| | | @Component |
| | | @ConfigurationProperties(prefix = "file.upload") |
| | | public class FileUploadConfig { |
| | | private String accessPath; |
| | | private String allowExt; |
| | | private String location; |
| | | private String qrLocation; |
| | | private String fileUrlPrefix; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.config; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Data |
| | | @Component |
| | | @ConfigurationProperties(prefix = "mail") |
| | | public class MailProperties { |
| | | |
| | | private String smtpHost="gz-smtp.qcloudmail.com"; |
| | | |
| | | private Integer smtpPort = 465; |
| | | |
| | | private String userAddr = "test@xzgtmail.591taxi.cn"; |
| | | |
| | | private String password = "CY20250226pass"; |
| | | |
| | | private String userName = "测试"; |
| | | |
| | | /** |
| | | * 账单提醒 ,同一个用户离上次发送短信的最小间隔 |
| | | * 单位分钟 |
| | | */ |
| | | private Integer billSmsDelayPeriod = 60; |
| | | /** |
| | | * 账单提醒 ,同一个用户离上次发送邮件的最小间隔 |
| | | * 单位分钟 |
| | | */ |
| | | private Integer billMailDelayPeriod = 60; |
| | | } |
New file |
| | |
| | | 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; |
| | | |
| | | /** 验证码类型 */ |
| | | private static String captchaType; |
| | | |
| | | 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 getCaptchaType() { |
| | | return captchaType; |
| | | } |
| | | |
| | | public void setCaptchaType(String captchaType) { |
| | | RuoYiConfig.captchaType = captchaType; |
| | | } |
| | | |
| | | /** |
| | | * 获取导入上传路径 |
| | | */ |
| | | public static String getImportPath() |
| | | { |
| | | return getProfile() + "/import"; |
| | | } |
| | | |
| | | /** |
| | | * 获取头像上传路径 |
| | | */ |
| | | public static String getAvatarPath() |
| | | { |
| | | return getProfile() + "/avatar"; |
| | | } |
| | | |
| | | /** |
| | | * 获取下载路径 |
| | | */ |
| | | public static String getDownloadPath() |
| | | { |
| | | return getProfile() + "/download/"; |
| | | } |
| | | |
| | | /** |
| | | * 获取上传路径 |
| | | */ |
| | | public static String getUploadPath() |
| | | { |
| | | return getProfile() + "/upload"; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.config; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Data |
| | | @Component |
| | | @ConfigurationProperties(prefix = "sms") |
| | | public class SmsProperties { |
| | | |
| | | public static final String ENABLE_KEY = "sms.enable"; |
| | | |
| | | private Boolean enable; |
| | | |
| | | private String appId; |
| | | |
| | | private String secretid; |
| | | |
| | | private String secretkey; |
| | | /** |
| | | * 短信签名 |
| | | */ |
| | | private String sign; |
| | | |
| | | /** |
| | | * 账单提醒 ,同一个用户离上次发送短信的最小间隔 |
| | | * 单位分钟 |
| | | */ |
| | | private Integer billSmsDelayPeriod = 60; |
| | | /** |
| | | * 账单提醒 ,同一个用户离上次发送邮件的最小间隔 |
| | | * 单位分钟 |
| | | */ |
| | | private Integer billMailDelayPeriod = 60; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.config; |
| | | |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonProperty; |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | |
| | | /** |
| | | * 项目中需继承此类 |
| | | * |
| | | * @author lihen |
| | | */ |
| | | @Data |
| | | @Component |
| | | @ConfigurationProperties(prefix = "wx.config") |
| | | public class WxConfig { |
| | | |
| | | /** |
| | | * 获取 App ID |
| | | * |
| | | * @return App ID |
| | | */ |
| | | @JsonProperty("appId") |
| | | private String appId; |
| | | |
| | | /** |
| | | * 获取 Secret |
| | | * |
| | | * @return Secret |
| | | */ |
| | | @JsonProperty("secret") |
| | | private String secret; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.constant; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | public class AmountConstant { |
| | | |
| | | public static final BigDecimal b100 = new BigDecimal("100"); |
| | | |
| | | public static final BigDecimal b1000 = new BigDecimal("1000"); |
| | | |
| | | public static final BigDecimal b001 = new BigDecimal("0.01"); |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.constant; |
| | | |
| | | /** |
| | | * 缓存的key 常量 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class CacheConstants |
| | | { |
| | | /** |
| | | * 登录用户 redis key |
| | | */ |
| | | public static final String LOGIN_TOKEN_KEY = "login_tokens:"; |
| | | |
| | | /** |
| | | * 验证码 redis key |
| | | */ |
| | | public static final String CAPTCHA_CODE_KEY = "captcha_codes:"; |
| | | |
| | | /** |
| | | * 参数管理 cache key |
| | | */ |
| | | public static final String SYS_CONFIG_KEY = "sys_config:"; |
| | | |
| | | /** |
| | | * 字典管理 cache key |
| | | */ |
| | | public static final String SYS_DICT_KEY = "sys_dict:"; |
| | | |
| | | /** |
| | | * 防重提交 redis key |
| | | */ |
| | | public static final String REPEAT_SUBMIT_KEY = "repeat_submit:"; |
| | | |
| | | /** |
| | | * 限流 redis key |
| | | */ |
| | | public static final String RATE_LIMIT_KEY = "rate_limit:"; |
| | | |
| | | /** |
| | | * 登录账户密码错误次数 redis key |
| | | */ |
| | | public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:"; |
| | | |
| | | |
| | | public static final String BILL_UPDATE_LOCK_KEY = "bill_update_lock:"; |
| | | |
| | | |
| | | public static final String COMPLETE_PAY_LOCK_KEY = "complete_pay_lock:"; |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.constant; |
| | | |
| | | import io.jsonwebtoken.Claims; |
| | | |
| | | /** |
| | | * 通用常量信息 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class Constants |
| | | { |
| | | /** |
| | | * UTF-8 字符集 |
| | | */ |
| | | public static final String UTF8 = "UTF-8"; |
| | | |
| | | /** |
| | | * GBK 字符集 |
| | | */ |
| | | public static final String GBK = "GBK"; |
| | | |
| | | /** |
| | | * www主域 |
| | | */ |
| | | public static final String WWW = "www."; |
| | | |
| | | /** |
| | | * 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 REGISTER = "Register"; |
| | | |
| | | /** |
| | | * 登录失败 |
| | | */ |
| | | public static final String LOGIN_FAIL = "Error"; |
| | | |
| | | /** |
| | | * 验证码有效期(分钟) |
| | | */ |
| | | 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"; |
| | | /** |
| | | * 小程序 |
| | | */ |
| | | public static final String LOGIN_USER_APPLET_KEY = "login_user_applet_key"; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | public static final String JWT_USERID = "userid"; |
| | | |
| | | /** |
| | | * 用户名称 |
| | | */ |
| | | public static final String JWT_USERNAME = Claims.SUBJECT; |
| | | |
| | | /** |
| | | * 用户头像 |
| | | */ |
| | | public static final String JWT_AVATAR = "avatar"; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | public static final String JWT_CREATED = "created"; |
| | | |
| | | /** |
| | | * 用户权限 |
| | | */ |
| | | public static final String JWT_AUTHORITIES = "authorities"; |
| | | |
| | | /** |
| | | * 资源映射路径 前缀 |
| | | */ |
| | | public static final String RESOURCE_PREFIX = "/profile"; |
| | | |
| | | /** |
| | | * RMI 远程方法调用 |
| | | */ |
| | | public static final String LOOKUP_RMI = "rmi:"; |
| | | |
| | | /** |
| | | * LDAP 远程方法调用 |
| | | */ |
| | | public static final String LOOKUP_LDAP = "ldap:"; |
| | | |
| | | /** |
| | | * LDAPS 远程方法调用 |
| | | */ |
| | | public static final String LOOKUP_LDAPS = "ldaps:"; |
| | | /** |
| | | * LDAPS 远程方法调用 |
| | | */ |
| | | public static final String INFORMATION_VIEW = "information_view:"; |
| | | |
| | | /** |
| | | * 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全) |
| | | */ |
| | | public static final String[] JSON_WHITELIST_STR = { "org.springframework", "com.ruoyi" }; |
| | | |
| | | /** |
| | | * 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加) |
| | | */ |
| | | public static final String[] JOB_WHITELIST_STR = { "com.ruoyi" }; |
| | | |
| | | /** |
| | | * 定时任务违规的字符 |
| | | */ |
| | | public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml", |
| | | "org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config" }; |
| | | |
| | | /** |
| | | * 时间格式化 |
| | | */ |
| | | public static final String DATE_FORMATTER_TIME = "yyyy-MM-dd HH:mm:ss"; |
| | | |
| | | /** |
| | | * 用户类型 |
| | | */ |
| | | public static final String USER_TYPE = "用户类型"; |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.constant; |
| | | |
| | | /** |
| | | * 缓存的key 常量 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class DictConstants |
| | | { |
| | | /** |
| | | * 租户属性 |
| | | */ |
| | | public static final String DICT_TYPE_TENANT_ATTRIBUTE = "t_tenant_attribute"; |
| | | /** |
| | | * 租户类型 |
| | | */ |
| | | public static final String DICT_TYPE_TENANT_TYPE = "t_tenant_type"; |
| | | /** |
| | | * 租赁状态 1=待出租 2=已出租 3=维修中 |
| | | */ |
| | | public static final String DICT_TYPE_LEASE_STATUS = "t_lease_status"; |
| | | /** |
| | | * 租金支付方式 1=月付 季付 年付 |
| | | */ |
| | | public static final String DICT_TYPE_CONTRACT_PAY_TYPE = "t_contract_pay_type"; |
| | | /** |
| | | * 业务属性 1住宅2商业3工业4车位5办公6仓储 |
| | | */ |
| | | public static final String DICT_TYPE_BUSINESS_ATTRIBUTES = "t_business_attributes"; |
| | | /** |
| | | * 合同状态 1=待提交 2=待审批 3=未签订 4=已签订 5=已驳回 6=已终止 7=待结算 8=已结算 9合同已签订待审 |
| | | */ |
| | | public static final String DICT_TYPE_CONTRACT_STATUS = "t_contract_status"; |
| | | /** |
| | | * 验收状态 1=待验收 2=已验收 |
| | | */ |
| | | public static final String DICT_TYPE_CHECK_STATUS = "t_check_status"; |
| | | /** |
| | | * 缴费状态 1=未缴费 2=待确认 3=已缴费 4=已逾期 5=已失效 |
| | | */ |
| | | public static final String DICT_TYPE_PAY_FEES_STATUS = "t_pay_fees_status"; |
| | | /** |
| | | * 账单类型 1=租金 2=押金 3=生活费用 4=房屋验收 |
| | | */ |
| | | public static final String DICT_TYPE_BILL_TYPE = "t_bill_type"; |
| | | /** |
| | | * 验收记录情况 1=良好 2=一般 3=较差 |
| | | */ |
| | | public static final String DICT_TYPE_CHECK_SITUATION = "t_check_situation"; |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.constant; |
| | | |
| | | /** |
| | | * 代码生成通用常量 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class GenConstants |
| | | { |
| | | /** 单表(增删改查) */ |
| | | public static final String TPL_CRUD = "crud"; |
| | | |
| | | /** 树表(增删改查) */ |
| | | public static final String TPL_TREE = "tree"; |
| | | |
| | | /** 主子表(增删改查) */ |
| | | public static final String TPL_SUB = "sub"; |
| | | |
| | | /** 树编码字段 */ |
| | | public static final String TREE_CODE = "treeCode"; |
| | | |
| | | /** 树父编码字段 */ |
| | | public static final String TREE_PARENT_CODE = "treeParentCode"; |
| | | |
| | | /** 树名称字段 */ |
| | | public static final String TREE_NAME = "treeName"; |
| | | |
| | | /** 上级菜单ID字段 */ |
| | | public static final String PARENT_MENU_ID = "parentMenuId"; |
| | | |
| | | /** 上级菜单名称字段 */ |
| | | public static final String PARENT_MENU_NAME = "parentMenuName"; |
| | | |
| | | /** 数据库字符串类型 */ |
| | | public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" }; |
| | | |
| | | /** 数据库文本类型 */ |
| | | public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" }; |
| | | |
| | | /** 数据库时间类型 */ |
| | | public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" }; |
| | | |
| | | /** 数据库数字类型 */ |
| | | public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer", |
| | | "bit", "bigint", "float", "double", "decimal" }; |
| | | |
| | | /** 页面不需要编辑字段 */ |
| | | public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" }; |
| | | |
| | | /** 页面不需要显示的列表字段 */ |
| | | public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by", |
| | | "update_time" }; |
| | | |
| | | /** 页面不需要查询字段 */ |
| | | public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by", |
| | | "update_time", "remark" }; |
| | | |
| | | /** Entity基类字段 */ |
| | | public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" }; |
| | | |
| | | /** Tree基类字段 */ |
| | | public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors", "children" }; |
| | | |
| | | /** 文本框 */ |
| | | public static final String HTML_INPUT = "input"; |
| | | |
| | | /** 文本域 */ |
| | | public static final String HTML_TEXTAREA = "textarea"; |
| | | |
| | | /** 下拉框 */ |
| | | public static final String HTML_SELECT = "select"; |
| | | |
| | | /** 单选框 */ |
| | | public static final String HTML_RADIO = "radio"; |
| | | |
| | | /** 复选框 */ |
| | | public static final String HTML_CHECKBOX = "checkbox"; |
| | | |
| | | /** 日期控件 */ |
| | | public static final String HTML_DATETIME = "datetime"; |
| | | |
| | | /** 图片上传控件 */ |
| | | public static final String HTML_IMAGE_UPLOAD = "imageUpload"; |
| | | |
| | | /** 文件上传控件 */ |
| | | public static final String HTML_FILE_UPLOAD = "fileUpload"; |
| | | |
| | | /** 富文本控件 */ |
| | | public static final String HTML_EDITOR = "editor"; |
| | | |
| | | /** 字符串类型 */ |
| | | public static final String TYPE_STRING = "String"; |
| | | |
| | | /** 整型 */ |
| | | public static final String TYPE_INTEGER = "Integer"; |
| | | |
| | | /** 长整型 */ |
| | | public static final String TYPE_LONG = "Long"; |
| | | |
| | | /** 浮点型 */ |
| | | public static final String TYPE_DOUBLE = "Double"; |
| | | |
| | | /** 高精度计算类型 */ |
| | | public static final String TYPE_BIGDECIMAL = "BigDecimal"; |
| | | |
| | | /** 时间类型 */ |
| | | public static final String TYPE_DATE = "Date"; |
| | | |
| | | /** 模糊查询 */ |
| | | public static final String QUERY_LIKE = "LIKE"; |
| | | |
| | | /** 相等查询 */ |
| | | public static final String QUERY_EQ = "EQ"; |
| | | |
| | | /** 需要 */ |
| | | public static final String REQUIRE = "1"; |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.constant; |
| | | |
| | | /** |
| | | * 返回状态码 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class HttpStatus |
| | | { |
| | | /** |
| | | * 操作成功 |
| | | */ |
| | | public static final int SUCCESS = 200; |
| | | |
| | | /** |
| | | * 对象创建成功 |
| | | */ |
| | | public static final int CREATED = 201; |
| | | |
| | | /** |
| | | * 请求已经被接受 |
| | | */ |
| | | public static final int ACCEPTED = 202; |
| | | |
| | | /** |
| | | * 操作已经执行成功,但是没有返回数据 |
| | | */ |
| | | public static final int NO_CONTENT = 204; |
| | | |
| | | /** |
| | | * 资源已被移除 |
| | | */ |
| | | public static final int MOVED_PERM = 301; |
| | | |
| | | /** |
| | | * 重定向 |
| | | */ |
| | | public static final int SEE_OTHER = 303; |
| | | |
| | | /** |
| | | * 资源没有被修改 |
| | | */ |
| | | public static final int NOT_MODIFIED = 304; |
| | | |
| | | /** |
| | | * 参数列表错误(缺少,格式不匹配) |
| | | */ |
| | | public static final int BAD_REQUEST = 400; |
| | | |
| | | /** |
| | | * 未授权 |
| | | */ |
| | | public static final int UNAUTHORIZED = 401; |
| | | |
| | | /** |
| | | * 访问受限,授权过期 |
| | | */ |
| | | public static final int FORBIDDEN = 403; |
| | | |
| | | /** |
| | | * 资源,服务未找到 |
| | | */ |
| | | public static final int NOT_FOUND = 404; |
| | | |
| | | /** |
| | | * 不允许的http方法 |
| | | */ |
| | | public static final int BAD_METHOD = 405; |
| | | |
| | | /** |
| | | * 资源冲突,或者资源被锁 |
| | | */ |
| | | public static final int CONFLICT = 409; |
| | | |
| | | /** |
| | | * 不支持的数据,媒体类型 |
| | | */ |
| | | public static final int UNSUPPORTED_TYPE = 415; |
| | | |
| | | /** |
| | | * 系统内部错误 |
| | | */ |
| | | public static final int ERROR = 500; |
| | | |
| | | /** |
| | | * 接口未实现 |
| | | */ |
| | | public static final int NOT_IMPLEMENTED = 501; |
| | | |
| | | /** |
| | | * 系统警告消息 |
| | | */ |
| | | public static final int WARN = 601; |
| | | } |
New file |
| | |
| | | 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; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.constant; |
| | | |
| | | /** |
| | | * 用户常量信息 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class UserConstants |
| | | { |
| | | /** |
| | | * 平台内系统用户的唯一标志 |
| | | */ |
| | | public static final String SYS_USER = "SYS_USER"; |
| | | |
| | | /** 正常状态 */ |
| | | public static final String NORMAL = "0"; |
| | | |
| | | /** 异常状态 */ |
| | | public static final String EXCEPTION = "1"; |
| | | |
| | | /** 用户封禁状态 */ |
| | | public static final String USER_DISABLE = "1"; |
| | | |
| | | /** 角色封禁状态 */ |
| | | public static final String ROLE_DISABLE = "1"; |
| | | |
| | | /** 部门正常状态 */ |
| | | public static final String DEPT_NORMAL = "0"; |
| | | |
| | | /** 部门停用状态 */ |
| | | public static final String DEPT_DISABLE = "1"; |
| | | |
| | | /** 字典正常状态 */ |
| | | public static final String DICT_NORMAL = "0"; |
| | | |
| | | /** 是否为系统默认(是) */ |
| | | public static final String YES = "Y"; |
| | | |
| | | /** 是否菜单外链(是) */ |
| | | public static final String YES_FRAME = "0"; |
| | | |
| | | /** 是否菜单外链(否) */ |
| | | public static final String NO_FRAME = "1"; |
| | | |
| | | /** 菜单类型(目录) */ |
| | | public static final String TYPE_DIR = "M"; |
| | | |
| | | /** 菜单类型(菜单) */ |
| | | public static final String TYPE_MENU = "C"; |
| | | |
| | | /** 菜单类型(按钮) */ |
| | | public static final String TYPE_BUTTON = "F"; |
| | | |
| | | /** Layout组件标识 */ |
| | | public final static String LAYOUT = "Layout"; |
| | | |
| | | /** ParentView组件标识 */ |
| | | public final static String PARENT_VIEW = "ParentView"; |
| | | |
| | | /** InnerLink组件标识 */ |
| | | public final static String INNER_LINK = "InnerLink"; |
| | | |
| | | /** 校验是否唯一的返回标识 */ |
| | | public final static boolean UNIQUE = true; |
| | | public final static boolean NOT_UNIQUE = false; |
| | | |
| | | /** |
| | | * 用户名长度限制 |
| | | */ |
| | | public static final int USERNAME_MIN_LENGTH = 2; |
| | | public static final int USERNAME_MAX_LENGTH = 20; |
| | | |
| | | /** |
| | | * 密码长度限制 |
| | | */ |
| | | public static final int PASSWORD_MIN_LENGTH = 5; |
| | | public static final int PASSWORD_MAX_LENGTH = 20; |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.constant; |
| | | |
| | | /** |
| | | * @Description 对接微信小程序的常量 |
| | | * @Author xiaochen |
| | | * @Date 2021/10/19/01914:01 |
| | | */ |
| | | public class WxConstant { |
| | | |
| | | /** |
| | | * 生成小程序码地址 |
| | | */ |
| | | public static final String CREATE_CODE_URL = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=ACCESS_TOKEN"; |
| | | |
| | | /** |
| | | * 高德地图坐标转换 |
| | | */ |
| | | public static final String ADDRESS_CONVERT_TO_COORDINATE = "https://restapi.amap.com/v3/geocode/geo?key=KEY&address=ADDRESS"; |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.controller; |
| | | |
| | | 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.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.web.bind.WebDataBinder; |
| | | import org.springframework.web.bind.annotation.InitBinder; |
| | | |
| | | import java.beans.PropertyEditorSupport; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * web层通用数据处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class BaseController |
| | | { |
| | | protected final Logger logger = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | /** |
| | | * 将前台传递过来的日期格式的字符串,自动转化为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() |
| | | // { |
| | | // PageUtils.startPage(); |
| | | // } |
| | | |
| | | /** |
| | | * 设置请求分页数据 |
| | | */ |
| | | // protected void startPage(Integer pageNum,Integer pageSize) |
| | | // { |
| | | // PageUtils.startPage(pageNum,pageSize); |
| | | // } |
| | | |
| | | /** |
| | | * 设置请求排序数据 |
| | | */ |
| | | protected void startOrderBy() |
| | | { |
| | | // PageDomain pageDomain = TableSupport.buildPageRequest(); |
| | | // if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) |
| | | // { |
| | | // String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); |
| | | // PageHelper.orderBy(orderBy); |
| | | // } |
| | | } |
| | | |
| | | /** |
| | | * 清理分页的线程变量 |
| | | */ |
| | | // protected void clearPage() |
| | | // { |
| | | // PageUtils.clearPage(); |
| | | // } |
| | | |
| | | /** |
| | | * 响应请求分页数据 |
| | | */ |
| | | @SuppressWarnings({ "rawtypes", "unchecked" }) |
| | | protected TableDataInfo getDataTable(List<?> list) |
| | | { |
| | | TableDataInfo rspData = new TableDataInfo(); |
| | | rspData.setCode(HttpStatus.SUCCESS); |
| | | rspData.setMsg("查询成功"); |
| | | rspData.setRecords(list); |
| | | // rspData.setTotal(new PageInfo(list).getTotal()); |
| | | return rspData; |
| | | } |
| | | |
| | | /** |
| | | * 返回成功 |
| | | */ |
| | | public AjaxResult success() |
| | | { |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 返回失败消息 |
| | | */ |
| | | public AjaxResult error() |
| | | { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | /** |
| | | * 返回成功消息 |
| | | */ |
| | | public AjaxResult success(String message) |
| | | { |
| | | return AjaxResult.success(message); |
| | | } |
| | | |
| | | /** |
| | | * 返回成功消息 |
| | | */ |
| | | public AjaxResult success(Object data) |
| | | { |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | /** |
| | | * 返回失败消息 |
| | | */ |
| | | public AjaxResult error(String message) |
| | | { |
| | | return AjaxResult.error(message); |
| | | } |
| | | |
| | | /** |
| | | * 返回警告消息 |
| | | */ |
| | | public AjaxResult warn(String message) |
| | | { |
| | | return AjaxResult.warn(message); |
| | | } |
| | | |
| | | /** |
| | | * 响应返回结果 |
| | | * |
| | | * @param rows 影响行数 |
| | | * @return 操作结果 |
| | | */ |
| | | protected AjaxResult toAjax(int rows) |
| | | { |
| | | return rows > 0 ? AjaxResult.success() : AjaxResult.error(); |
| | | } |
| | | |
| | | /** |
| | | * 响应返回结果 |
| | | * |
| | | * @param result 结果 |
| | | * @return 操作结果 |
| | | */ |
| | | protected AjaxResult toAjax(boolean result) |
| | | { |
| | | return result ? success() : error(); |
| | | } |
| | | |
| | | /** |
| | | * 页面跳转 |
| | | */ |
| | | public String redirect(String url) |
| | | { |
| | | return StringUtils.format("redirect:{}", url); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户缓存信息 |
| | | */ |
| | | public LoginUser getLoginUser() |
| | | { |
| | | return SecurityUtils.getLoginUser(); |
| | | } |
| | | |
| | | /** |
| | | * 获取登录用户id |
| | | */ |
| | | public Long getUserId() |
| | | { |
| | | return getLoginUser().getUserId(); |
| | | } |
| | | |
| | | /** |
| | | * 获取登录部门id |
| | | */ |
| | | public Long getDeptId() |
| | | { |
| | | return getLoginUser().getDeptId(); |
| | | } |
| | | |
| | | /** |
| | | * 获取登录用户名 |
| | | */ |
| | | public String getUsername() |
| | | { |
| | | return getLoginUser().getUsername(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.controller; |
| | | |
| | | import com.ruoyi.common.config.FileUploadConfig; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.awt.*; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 文件上传控制类 |
| | | * |
| | | * @author junelee |
| | | * @date 2020/3/20 20:21 |
| | | */ |
| | | @Api(tags = "服务器文件上传") |
| | | @RestController |
| | | @CrossOrigin |
| | | @RequestMapping("/file/") |
| | | public class FileController { |
| | | |
| | | @Autowired |
| | | private FileUploadConfig fileUploadConfig; |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "单文件上传", notes = "单文件上传,rename 默认不重命名") |
| | | @PostMapping(value = "upload", headers = "content-type=multipart/form-data") |
| | | public AjaxResult uploadImageMany(@RequestParam(value = "file") MultipartFile mf) throws IOException { |
| | | if (mf.isEmpty()) { |
| | | return AjaxResult.error("请传入文件!"); |
| | | } |
| | | String TimeDir =new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| | | // String realPath = fileUploadConfig.getLocation() + TimeDir; |
| | | String realPath = "C:\\Users\\Admin\\Desktop\\qrcode\\" + TimeDir; |
| | | File file = new File(realPath); |
| | | // 没有目录就创建 |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | // 获取文件名称 |
| | | String filename = mf.getOriginalFilename(); |
| | | // 获取文件后缀 |
| | | String ext = filename.substring(filename.lastIndexOf("."), filename.length()); |
| | | // 检查文件类型 |
| | | if (!fileUploadConfig.getAllowExt().contains(ext)) { |
| | | return AjaxResult.error("上传文件格式不正确,仅支持" + fileUploadConfig.getAllowExt()); |
| | | } |
| | | File targetFile = new File(realPath, filename);//目标文件 |
| | | //开始从源文件拷贝到目标文件 |
| | | //传图片一步到位 |
| | | mf.transferTo(targetFile); |
| | | //拼接数据 |
| | | // String imgstr = fileUploadConfig.getAccessPath() + TimeDir +"\\"+ filename; |
| | | String imgstr = TimeDir +"/"+ filename; |
| | | return AjaxResult.success(imgstr); |
| | | } |
| | | |
| | | |
| | | // @ApiOperation(value = "单文件上传", notes = "单文件上传,rename 默认不重命名") |
| | | // @PostMapping(value = "strUpload", headers = "content-type=multipart/form-data") |
| | | // public String strUpload(@RequestParam(value = "file") MultipartFile mf,@RequestParam(value = "fileName")String fileName) throws IOException { |
| | | // if (mf.isEmpty()) { |
| | | // return "请传入文件!"; |
| | | // } |
| | | // String TimeDir =new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| | | // String realPath = fileUploadConfig.getQrLocation() + TimeDir; |
| | | // File file = new File(realPath); |
| | | // // 没有目录就创建 |
| | | // if (!file.exists()) { |
| | | // file.mkdirs(); |
| | | // } |
| | | // File targetFile = new File(realPath, fileName);//目标文件 |
| | | // //开始从源文件拷贝到目标文件 |
| | | // //传图片一步到位 |
| | | // mf.transferTo(targetFile); |
| | | // //拼接数据 |
| | | // return fileUploadConfig.getQrLocation() + TimeDir +"\\"+ fileName; |
| | | // } |
| | | |
| | | @ApiOperation(value = "单文件上传", notes = "单文件上传,rename 默认不重命名") |
| | | @PostMapping(value = "strUpload", headers = "content-type=multipart/form-data") |
| | | public String strUpload(@RequestParam(value = "file") MultipartFile mf,@RequestParam(value = "fileName")String fileName) throws IOException { |
| | | if (mf.isEmpty()) { |
| | | return "请传入文件!"; |
| | | } |
| | | String TimeDir =new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| | | String realPath = "C:\\Users\\Admin\\Desktop\\qrcode\\" + TimeDir; |
| | | File file = new File(realPath); |
| | | // 没有目录就创建 |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | File targetFile = new File(realPath, fileName);//目标文件 |
| | | //开始从源文件拷贝到目标文件 |
| | | //传图片一步到位 |
| | | mf.transferTo(targetFile); |
| | | //拼接数据 |
| | | return TimeDir +"/"+ fileName; |
| | | } |
| | | |
| | | @ApiOperation(value = "单文件上传(覆盖服务器原文件)", notes = "单文件上传,rename 默认不重命名") |
| | | @PostMapping(value = "test/upload", headers = "content-type=multipart/form-data") |
| | | public AjaxResult uploadTest(@RequestParam(value = "file") MultipartFile mf) throws IOException { |
| | | if (mf.isEmpty()) { |
| | | return AjaxResult.error("请传入文件!"); |
| | | } |
| | | String TimeDir = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| | | String realPath = fileUploadConfig.getLocation() + "2021-11-17"; |
| | | File file = new File(realPath); |
| | | // 没有目录就创建 |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | // 判断文件大小 |
| | | String filename = "6u2mGlqHkeE75e2ab51b4a03c6982ff7d68f4c024d43.jpg"; |
| | | // 获取文件后缀 |
| | | String ext = filename.substring(filename.lastIndexOf("."), filename.length()); |
| | | // 检查文件类型 |
| | | if (!fileUploadConfig.getAllowExt().contains(ext)) { |
| | | return AjaxResult.error("上传文件格式不正确,仅支持" + fileUploadConfig.getAllowExt()); |
| | | } |
| | | File targetFile = new File(realPath, filename);//目标文件 |
| | | //开始从源文件拷贝到目标文件 |
| | | //传图片一步到位 |
| | | mf.transferTo(targetFile); |
| | | //拼接数据 |
| | | String imgstr = fileUploadConfig.getAccessPath() + "2021-11-17" + "/" + filename; |
| | | return AjaxResult.success(imgstr); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.domain; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Objects; |
| | | import com.ruoyi.common.constant.HttpStatus; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | /** |
| | | * 操作消息提醒 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class AjaxResult<T> 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); |
| | | } |
| | | |
| | | /** |
| | | * 返回警告消息 |
| | | * |
| | | * @param msg 返回内容 |
| | | * @return 警告消息 |
| | | */ |
| | | public static AjaxResult warn(String msg) |
| | | { |
| | | return AjaxResult.warn(msg, null); |
| | | } |
| | | |
| | | /** |
| | | * 返回警告消息 |
| | | * |
| | | * @param msg 返回内容 |
| | | * @param data 数据对象 |
| | | * @return 警告消息 |
| | | */ |
| | | public static AjaxResult warn(String msg, Object data) |
| | | { |
| | | return new AjaxResult(HttpStatus.WARN, 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); |
| | | } |
| | | |
| | | /** |
| | | * 是否为成功消息 |
| | | * |
| | | * @return 结果 |
| | | */ |
| | | public boolean isSuccess() |
| | | { |
| | | return Objects.equals(HttpStatus.SUCCESS, this.get(CODE_TAG)); |
| | | } |
| | | |
| | | /** |
| | | * 是否为警告消息 |
| | | * |
| | | * @return 结果 |
| | | */ |
| | | public boolean isWarn() |
| | | { |
| | | return Objects.equals(HttpStatus.WARN, this.get(CODE_TAG)); |
| | | } |
| | | |
| | | /** |
| | | * 是否为错误消息 |
| | | * |
| | | * @return 结果 |
| | | */ |
| | | public boolean isError() |
| | | { |
| | | return Objects.equals(HttpStatus.ERROR, this.get(CODE_TAG)); |
| | | } |
| | | |
| | | /** |
| | | * 方便链式调用 |
| | | * |
| | | * @param key 键 |
| | | * @param value 值 |
| | | * @return 数据对象 |
| | | */ |
| | | @Override |
| | | public AjaxResult put(String key, Object value) |
| | | { |
| | | super.put(key, value); |
| | | return this; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.domain; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | /** |
| | | * Entity基类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class BaseEntity implements Serializable |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** 搜索值 */ |
| | | @JsonIgnore |
| | | 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; |
| | | |
| | | @ApiModelProperty(value = "禁用备注") |
| | | @TableField("disable_remark") |
| | | private String disableRemark; |
| | | |
| | | @ApiModelProperty(value = "操作时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField("operating_time") |
| | | private LocalDateTime operatingTime; |
| | | |
| | | @ApiModelProperty(value = "操作人 登录名(登录账号)") |
| | | @TableField("operating_person") |
| | | private String operatingPerson; |
| | | |
| | | public String getDisableRemark() { |
| | | return disableRemark; |
| | | } |
| | | |
| | | public void setDisableRemark(String disableRemark) { |
| | | this.disableRemark = disableRemark; |
| | | } |
| | | |
| | | public LocalDateTime getOperatingTime() { |
| | | return operatingTime; |
| | | } |
| | | |
| | | public void setOperatingTime(LocalDateTime operatingTime) { |
| | | this.operatingTime = operatingTime; |
| | | } |
| | | |
| | | public String getOperatingPerson() { |
| | | return operatingPerson; |
| | | } |
| | | |
| | | public void setOperatingPerson(String operatingPerson) { |
| | | this.operatingPerson = operatingPerson; |
| | | } |
| | | |
| | | /** 请求参数 */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | 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 Map<String, Object> getParams() |
| | | { |
| | | if (params == null) |
| | | { |
| | | params = new HashMap<>(); |
| | | } |
| | | return params; |
| | | } |
| | | |
| | | public void setParams(Map<String, Object> params) |
| | | { |
| | | this.params = params; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * @author xiaochen |
| | | * @ClassName BaseModel |
| | | * @Description |
| | | * @date 2024-04-02 19:38 |
| | | */ |
| | | @Data |
| | | public class BaseModel implements Serializable { |
| | | /** |
| | | * 字段常量属性 |
| | | */ |
| | | public static final String ID = "id"; |
| | | |
| | | public static final String CREATE_TIME = "create_time"; |
| | | |
| | | public static final String LAST_TIME = "last_time"; |
| | | |
| | | private static final long serialVersionUID = 2553749188490103197L; |
| | | /** |
| | | * 新增执行 |
| | | */ |
| | | @ApiModelProperty(value = "记录创建人,前端忽略") |
| | | @JsonIgnore |
| | | @TableField(value = "create_by", fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | /** |
| | | * 新增和更新执行 |
| | | */ |
| | | @ApiModelProperty(value = "记录修改人,前端忽略") |
| | | @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | /** |
| | | * 删除 未删除 |
| | | */ |
| | | @JsonIgnore |
| | | @TableField("`disabled`") |
| | | @TableLogic |
| | | private Boolean disabled; |
| | | |
| | | @ApiModelProperty(value = "记录创建时间,前端忽略") |
| | | @TableField("create_time") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * 最后修改时间 |
| | | */ |
| | | @ApiModelProperty(value = "记录修改时间,前端忽略") |
| | | @TableField("update_time") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime updateTime; |
| | | |
| | | |
| | | public String getCreateBy() { |
| | | return createBy; |
| | | } |
| | | |
| | | public void setCreateBy(String createBy) { |
| | | this.createBy = createBy; |
| | | } |
| | | |
| | | public String getUpdateBy() { |
| | | return updateBy; |
| | | } |
| | | |
| | | public void setUpdateBy(String updateBy) { |
| | | this.updateBy = updateBy; |
| | | } |
| | | |
| | | public Boolean getDisabled() { |
| | | return disabled; |
| | | } |
| | | |
| | | public void setDisabled(Boolean disabled) { |
| | | this.disabled = disabled; |
| | | } |
| | | |
| | | public LocalDateTime getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(LocalDateTime createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public LocalDateTime getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(LocalDateTime updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.domain; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * <p></p> |
| | | * |
| | | * @author mouseyCat |
| | | * @date 2020/8/24 16:39 |
| | | */ |
| | | @ApiModel(value = "基础查询列表dto") |
| | | public class BasePage implements Serializable { |
| | | /** |
| | | * 分页参数,当前页码 |
| | | */ |
| | | @ApiModelProperty(value = "分页参数,当前页码") |
| | | private Integer pageNum = 1; |
| | | /** |
| | | * 分页参数,每页数量 |
| | | */ |
| | | @ApiModelProperty(value = "分页参数,每页数量,默认为10") |
| | | private Integer pageSize = 10; |
| | | |
| | | 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; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "BasePage{" + |
| | | "pageNum=" + pageNum + |
| | | ", pageSize=" + pageSize + |
| | | '}'; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.domain; |
| | | |
| | | import java.io.Serializable; |
| | | import com.ruoyi.common.constant.HttpStatus; |
| | | |
| | | /** |
| | | * 响应信息主体 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class R<T> implements Serializable |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** 成功 */ |
| | | public static final int SUCCESS = HttpStatus.SUCCESS; |
| | | |
| | | /** 失败 */ |
| | | public static final int FAIL = HttpStatus.ERROR; |
| | | |
| | | private int code; |
| | | |
| | | private String msg; |
| | | |
| | | private T data; |
| | | |
| | | public static <T> R<T> ok() |
| | | { |
| | | return restResult(null, SUCCESS, "操作成功"); |
| | | } |
| | | |
| | | public static <T> R<T> ok(T data) |
| | | { |
| | | return restResult(data, SUCCESS, "操作成功"); |
| | | } |
| | | |
| | | public static <T> R<T> ok(T data, String msg) |
| | | { |
| | | return restResult(data, SUCCESS, msg); |
| | | } |
| | | |
| | | public static <T> R<T> fail() |
| | | { |
| | | return restResult(null, FAIL, "操作失败"); |
| | | } |
| | | |
| | | public static <T> R<T> fail(String msg) |
| | | { |
| | | return restResult(null, FAIL, msg); |
| | | } |
| | | |
| | | public static <T> R<T> fail(T data) |
| | | { |
| | | return restResult(data, FAIL, "操作失败"); |
| | | } |
| | | |
| | | public static <T> R<T> fail(T data, String msg) |
| | | { |
| | | return restResult(data, FAIL, msg); |
| | | } |
| | | |
| | | public static <T> R<T> fail(int code, String msg) |
| | | { |
| | | return restResult(null, code, msg); |
| | | } |
| | | |
| | | private static <T> R<T> restResult(T data, int code, String msg) |
| | | { |
| | | R<T> apiResult = new R<>(); |
| | | apiResult.setCode(code); |
| | | apiResult.setData(data); |
| | | apiResult.setMsg(msg); |
| | | return apiResult; |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | public T getData() |
| | | { |
| | | return data; |
| | | } |
| | | |
| | | public void setData(T data) |
| | | { |
| | | this.data = data; |
| | | } |
| | | |
| | | public static <T> Boolean isError(R<T> ret) |
| | | { |
| | | return !isSuccess(ret); |
| | | } |
| | | |
| | | public static <T> Boolean isSuccess(R<T> ret) |
| | | { |
| | | return R.SUCCESS == ret.getCode(); |
| | | } |
| | | } |
New file |
| | |
| | | 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; |
| | | } |
| | | } |
New file |
| | |
| | | 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; |
| | | } |
| | | } |
New file |
| | |
| | | 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.NotNull; |
| | | 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 Integer 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; |
| | | } |
| | | |
| | | @NotNull(message = "显示顺序不能为空") |
| | | public Integer getOrderNum() |
| | | { |
| | | return orderNum; |
| | | } |
| | | |
| | | public void setOrderNum(Integer 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(); |
| | | } |
| | | } |
New file |
| | |
| | | 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.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); |
| | | } |
| | | |
| | | 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(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.domain.entity; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.Pattern; |
| | | 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_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个字符") |
| | | @Pattern(regexp = "^[a-z][a-z0-9_]*$", message = "字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)") |
| | | 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(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.domain.entity; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | 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 Integer orderNum; |
| | | |
| | | /** 路由地址 */ |
| | | private String path; |
| | | |
| | | /** 组件路径 */ |
| | | private String component; |
| | | |
| | | /** 路由参数 */ |
| | | private String query; |
| | | |
| | | /** 是否为外链(0是 1否) */ |
| | | private String isFrame; |
| | | |
| | | /** 是否缓存(0缓存 1不缓存) */ |
| | | private String isCache; |
| | | |
| | | /** 类型(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; |
| | | } |
| | | |
| | | @NotNull(message = "显示顺序不能为空") |
| | | public Integer getOrderNum() |
| | | { |
| | | return orderNum; |
| | | } |
| | | |
| | | public void setOrderNum(Integer 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 getQuery() |
| | | { |
| | | return query; |
| | | } |
| | | |
| | | public void setQuery(String query) |
| | | { |
| | | this.query = query; |
| | | } |
| | | |
| | | public String getIsFrame() |
| | | { |
| | | return isFrame; |
| | | } |
| | | |
| | | public void setIsFrame(String isFrame) |
| | | { |
| | | this.isFrame = isFrame; |
| | | } |
| | | |
| | | public String getIsCache() |
| | | { |
| | | return isCache; |
| | | } |
| | | |
| | | public void setIsCache(String isCache) |
| | | { |
| | | this.isCache = isCache; |
| | | } |
| | | |
| | | @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("IsCache", getIsCache()) |
| | | .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(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.domain.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.ruoyi.common.core.domain.BaseModel; |
| | | import lombok.Data; |
| | | import org.apache.commons.lang3.builder.ToStringBuilder; |
| | | import org.apache.commons.lang3.builder.ToStringStyle; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.Size; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * 角色表 sys_role |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Data |
| | | public class SysRole extends BaseModel |
| | | { |
| | | 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 Integer roleSort; |
| | | |
| | | /** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) */ |
| | | //@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限") |
| | | private String dataScope; |
| | | |
| | | /** 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) */ |
| | | private boolean menuCheckStrictly; |
| | | |
| | | /** 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 ) */ |
| | | private boolean deptCheckStrictly; |
| | | |
| | | /** 角色状态(0正常 1停用) */ |
| | | //@Excel(name = "角色状态", readConverterExp = "0=正常,1=停用") |
| | | private Integer status; |
| | | |
| | | /** 删除标志(0代表存在 2代表删除) */ |
| | | private Integer delFlag; |
| | | |
| | | /** 用户是否存在此角色标识 默认不存在 */ |
| | | private boolean flag = false; |
| | | |
| | | /** 菜单组 */ |
| | | private Long[] menuIds; |
| | | |
| | | /** 部门组(数据权限) */ |
| | | private Long[] deptIds; |
| | | |
| | | /** 角色菜单权限 */ |
| | | private Set<String> permissions; |
| | | |
| | | private String remark; |
| | | |
| | | /** |
| | | * 删除天数 |
| | | */ |
| | | private Integer removeDays; |
| | | /** |
| | | * 岗位类型 1=经理 2=负责人 3=专员 |
| | | */ |
| | | private Integer postType; |
| | | /** |
| | | * 角色人数 |
| | | */ |
| | | @TableField(exist = false) |
| | | private Integer userCount; |
| | | |
| | | public Integer getPostType() { |
| | | return postType; |
| | | } |
| | | |
| | | public void setPostType(Integer postType) { |
| | | this.postType = postType; |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符") |
| | | public String getRoleKey() |
| | | { |
| | | return roleKey; |
| | | } |
| | | |
| | | public void setRoleKey(String roleKey) |
| | | { |
| | | this.roleKey = roleKey; |
| | | } |
| | | |
| | | public Integer getRoleSort() |
| | | { |
| | | return roleSort; |
| | | } |
| | | |
| | | public void setRoleSort(Integer roleSort) |
| | | { |
| | | this.roleSort = roleSort; |
| | | } |
| | | |
| | | public String getDataScope() |
| | | { |
| | | return dataScope; |
| | | } |
| | | |
| | | public void setDataScope(String dataScope) |
| | | { |
| | | this.dataScope = dataScope; |
| | | } |
| | | |
| | | public boolean isMenuCheckStrictly() |
| | | { |
| | | return menuCheckStrictly; |
| | | } |
| | | |
| | | public void setMenuCheckStrictly(boolean menuCheckStrictly) |
| | | { |
| | | this.menuCheckStrictly = menuCheckStrictly; |
| | | } |
| | | |
| | | public boolean isDeptCheckStrictly() |
| | | { |
| | | return deptCheckStrictly; |
| | | } |
| | | |
| | | public void setDeptCheckStrictly(boolean deptCheckStrictly) |
| | | { |
| | | this.deptCheckStrictly = deptCheckStrictly; |
| | | } |
| | | |
| | | public Integer getStatus() |
| | | { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(Integer status) |
| | | { |
| | | this.status = status; |
| | | } |
| | | |
| | | public Integer getDelFlag() |
| | | { |
| | | return delFlag; |
| | | } |
| | | |
| | | public void setDelFlag(Integer 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; |
| | | } |
| | | |
| | | public Set<String> getPermissions() |
| | | { |
| | | return permissions; |
| | | } |
| | | |
| | | public void setPermissions(Set<String> permissions) |
| | | { |
| | | this.permissions = permissions; |
| | | } |
| | | |
| | | public String getRemark() { |
| | | return remark; |
| | | } |
| | | |
| | | public void setRemark(String remark) { |
| | | this.remark = remark; |
| | | } |
| | | |
| | | public Integer getRemoveDays() { |
| | | return removeDays; |
| | | } |
| | | |
| | | public void setRemoveDays(Integer removeDays) { |
| | | this.removeDays = removeDays; |
| | | } |
| | | |
| | | @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("menuCheckStrictly", isMenuCheckStrictly()) |
| | | .append("deptCheckStrictly", isDeptCheckStrictly()) |
| | | .append("status", getStatus()) |
| | | .append("delFlag", getDelFlag()) |
| | | .append("createBy", getCreateBy()) |
| | | .append("createTime", getCreateTime()) |
| | | .append("updateBy", getUpdateBy()) |
| | | .append("updateTime", getUpdateTime()) |
| | | .toString(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.domain.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | import com.ruoyi.common.xss.Xss; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.apache.commons.lang3.builder.ToStringBuilder; |
| | | import org.apache.commons.lang3.builder.ToStringStyle; |
| | | |
| | | import javax.validation.constraints.Email; |
| | | import javax.validation.constraints.Size; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户对象 sys_user |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Data |
| | | public class SysUser extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** 用户ID */ |
| | | //@Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号") |
| | | @ApiModelProperty(value = "用户id") |
| | | @TableField("user_id") |
| | | private Long userId; |
| | | |
| | | /** 部门ID */ |
| | | //@Excel(name = "部门编号", type = Type.IMPORT) |
| | | @ApiModelProperty(value = "部门id") |
| | | private Long deptId; |
| | | |
| | | /** 用户账号 */ |
| | | //@Excel(name = "登录名称") |
| | | @ApiModelProperty(value = "登录名称") |
| | | private String userName; |
| | | |
| | | /** 用户昵称 */ |
| | | //@Excel(name = "用户名称") |
| | | @ApiModelProperty(value = "用户名称") |
| | | private String nickName; |
| | | |
| | | /** 用户邮箱 */ |
| | | //@Excel(name = "用户邮箱") |
| | | @ApiModelProperty(value = "用户邮箱") |
| | | private String email; |
| | | |
| | | /** 手机号码 */ |
| | | //@Excel(name = "手机号码") |
| | | @ApiModelProperty(value = "手机号码") |
| | | private String phonenumber; |
| | | |
| | | /** 用户性别 */ |
| | | //@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") |
| | | @ApiModelProperty(value = "用户性别 0=男,1=女,2=未知") |
| | | private String sex; |
| | | |
| | | /** 用户头像 */ |
| | | @ApiModelProperty(value = "用户头像") |
| | | private String avatar; |
| | | |
| | | /** 密码 */ |
| | | @ApiModelProperty(value = "密码") |
| | | private String password; |
| | | |
| | | /** 帐号状态(0正常 1停用) */ |
| | | //@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用") |
| | | @ApiModelProperty(value = "帐号状态 0=正常,1=停用") |
| | | private String status; |
| | | |
| | | /** 删除标志(0代表存在 2代表删除) */ |
| | | @ApiModelProperty(value = "删除标志(0代表存在 2代表删除)") |
| | | private String delFlag; |
| | | |
| | | /** 最后登录IP */ |
| | | //@Excel(name = "最后登录IP", type = Type.EXPORT) |
| | | @ApiModelProperty(value = "最后登录IP") |
| | | private String loginIp; |
| | | |
| | | /** 最后登录时间 */ |
| | | //@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty(value = "最后登录时间") |
| | | private Date loginDate; |
| | | |
| | | /** 部门对象 */ |
| | | //@Excels({ |
| | | //@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), |
| | | //@Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) |
| | | // }) |
| | | @ApiModelProperty(value = "部门对象") |
| | | private SysDept dept; |
| | | |
| | | /** 角色对象 */ |
| | | @ApiModelProperty(value = "角色对象") |
| | | private List<SysRole> roles; |
| | | |
| | | /** 角色组 */ |
| | | @ApiModelProperty(value = "角色组") |
| | | private Long[] roleIds; |
| | | |
| | | /** 岗位组 */ |
| | | @ApiModelProperty(value = "岗位组") |
| | | private Long[] postIds; |
| | | |
| | | /** 角色ID */ |
| | | @ApiModelProperty(value = "角色ID") |
| | | private Long roleId; |
| | | /** |
| | | * 是否为黑名单 1是 0否 |
| | | */ |
| | | @ApiModelProperty(value = "是否为黑名单 1是 0否") |
| | | private Integer ifBlack; |
| | | |
| | | /** |
| | | * 区县id |
| | | */ |
| | | @ApiModelProperty(value = "区县id") |
| | | private Integer districtId; |
| | | |
| | | @TableField(exist = false) |
| | | private String roleName; |
| | | @TableField(exist = false) |
| | | private String deptName; |
| | | @ApiModelProperty(value = "部门id集合") |
| | | @TableField(exist = false) |
| | | private List<String> deptIds; |
| | | |
| | | @ApiModelProperty(value = "营业部id") |
| | | @TableField("business_dept_id") |
| | | private String businessDeptId; |
| | | |
| | | public String getRoleName() { |
| | | return roleName; |
| | | } |
| | | |
| | | public void setRoleName(String roleName) { |
| | | this.roleName = roleName; |
| | | } |
| | | |
| | | public Integer getDistrictId() { |
| | | return districtId; |
| | | } |
| | | |
| | | public void setDistrictId(Integer districtId) { |
| | | this.districtId = districtId; |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | @Xss(message = "用户昵称不能包含脚本字符") |
| | | @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符") |
| | | public String getNickName() |
| | | { |
| | | return nickName; |
| | | } |
| | | |
| | | public void setNickName(String nickName) |
| | | { |
| | | this.nickName = nickName; |
| | | } |
| | | |
| | | @Xss(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; |
| | | } |
| | | |
| | | public String getPassword() |
| | | { |
| | | return password; |
| | | } |
| | | |
| | | public void setPassword(String password) |
| | | { |
| | | this.password = password; |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | public Long getRoleId() |
| | | { |
| | | return roleId; |
| | | } |
| | | |
| | | public void setRoleId(Long roleId) |
| | | { |
| | | this.roleId = roleId; |
| | | } |
| | | |
| | | public Integer getIfBlack() { |
| | | return ifBlack; |
| | | } |
| | | |
| | | public void setIfBlack(Integer ifBlack) { |
| | | this.ifBlack = ifBlack; |
| | | } |
| | | |
| | | @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("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(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.domain.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.core.domain.BaseModel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * <p> |
| | | * 租户 |
| | | * </p> |
| | | * |
| | | * @author xiaochen |
| | | * @since 2025-01-20 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value="TTenant对象", description="登录返回") |
| | | public class TTenantResp { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private String id; |
| | | |
| | | @ApiModelProperty(value = "住户名称") |
| | | private String residentName; |
| | | |
| | | @ApiModelProperty(value = "入住时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | private LocalDate checkinTime; |
| | | |
| | | @ApiModelProperty(value = "租户属性") |
| | | private String tenantAttributes; |
| | | |
| | | @ApiModelProperty(value = "租户类型") |
| | | private String tenantType; |
| | | |
| | | @ApiModelProperty(value = "联系电话") |
| | | private String phone; |
| | | |
| | | @ApiModelProperty(value = "证件号码") |
| | | private String idCard; |
| | | |
| | | @ApiModelProperty(value = "邮箱") |
| | | private String email; |
| | | |
| | | @ApiModelProperty(value = "银行转账专号") |
| | | private String bankNumber; |
| | | |
| | | @ApiModelProperty(value = "通讯地址") |
| | | private String mailAddress; |
| | | |
| | | @ApiModelProperty(value = "登录账号") |
| | | private String account; |
| | | |
| | | @ApiModelProperty(value = "登录密码") |
| | | private String password; |
| | | @ApiModelProperty(value = "微信openid") |
| | | private String openId; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.domain.model; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | /** |
| | | * 用户登录对象 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @ApiModel(value = "登录对象Body") |
| | | public class LoginBody |
| | | { |
| | | /** |
| | | * 用户名 |
| | | */ |
| | | @ApiModelProperty(value = "用户名",notes = "用户名") |
| | | private String username; |
| | | |
| | | /** |
| | | * 用户密码 |
| | | */ |
| | | @ApiModelProperty(value = "用户密码") |
| | | private String password; |
| | | |
| | | /** |
| | | * 验证码 |
| | | */ |
| | | @ApiModelProperty(value = "验证码") |
| | | 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; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.domain.model; |
| | | |
| | | import com.alibaba.fastjson2.annotation.JSONField; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import org.springframework.security.core.GrantedAuthority; |
| | | import org.springframework.security.core.userdetails.UserDetails; |
| | | import java.util.Collection; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * 登录用户身份权限 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class LoginUser implements UserDetails |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 部门ID |
| | | */ |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * 用户唯一标识 |
| | | */ |
| | | 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 LoginUser() |
| | | { |
| | | } |
| | | |
| | | public LoginUser(SysUser user, Set<String> permissions) |
| | | { |
| | | this.user = user; |
| | | this.permissions = permissions; |
| | | } |
| | | |
| | | public LoginUser(Long userId, Long deptId, SysUser user, Set<String> permissions) |
| | | { |
| | | this.userId = userId; |
| | | this.deptId = deptId; |
| | | this.user = user; |
| | | this.permissions = permissions; |
| | | } |
| | | |
| | | public Long getUserId() |
| | | { |
| | | return userId; |
| | | } |
| | | |
| | | public void setUserId(Long userId) |
| | | { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public Long getDeptId() |
| | | { |
| | | return deptId; |
| | | } |
| | | |
| | | public void setDeptId(Long deptId) |
| | | { |
| | | this.deptId = deptId; |
| | | } |
| | | |
| | | public String getToken() |
| | | { |
| | | return token; |
| | | } |
| | | |
| | | public void setToken(String token) |
| | | { |
| | | this.token = token; |
| | | } |
| | | |
| | | @JSONField(serialize = false) |
| | | @Override |
| | | public String getPassword() |
| | | { |
| | | return user.getPassword(); |
| | | } |
| | | |
| | | @Override |
| | | public String getUsername() |
| | | { |
| | | return user.getUserName(); |
| | | } |
| | | |
| | | /** |
| | | * 账户是否未过期,过期无法验证 |
| | | */ |
| | | @JSONField(serialize = false) |
| | | @Override |
| | | public boolean isAccountNonExpired() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 指定用户是否解锁,锁定的用户无法进行身份验证 |
| | | * |
| | | * @return |
| | | */ |
| | | @JSONField(serialize = false) |
| | | @Override |
| | | public boolean isAccountNonLocked() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 指示是否已过期的用户的凭据(密码),过期的凭据防止认证 |
| | | * |
| | | * @return |
| | | */ |
| | | @JSONField(serialize = false) |
| | | @Override |
| | | public boolean isCredentialsNonExpired() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 是否可用 ,禁用的用户不能身份验证 |
| | | * |
| | | * @return |
| | | */ |
| | | @JSONField(serialize = false) |
| | | @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; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.domain.model; |
| | | |
| | | import com.alibaba.fastjson2.annotation.JSONField; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.entity.TTenantResp; |
| | | import lombok.Data; |
| | | import org.springframework.security.core.GrantedAuthority; |
| | | import org.springframework.security.core.userdetails.UserDetails; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * 登录用户身份权限 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Data |
| | | public class LoginUserApplet implements UserDetails |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | private String userId; |
| | | |
| | | /** |
| | | * 部门ID |
| | | */ |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * 用户唯一标识 |
| | | */ |
| | | 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 TTenantResp user; |
| | | |
| | | |
| | | public LoginUserApplet() |
| | | { |
| | | } |
| | | |
| | | public LoginUserApplet(TTenantResp user, Set<String> permissions) |
| | | { |
| | | this.user = user; |
| | | this.permissions = permissions; |
| | | } |
| | | |
| | | public LoginUserApplet(String userId, Long deptId, TTenantResp user, Set<String> permissions) |
| | | { |
| | | this.userId = userId; |
| | | this.deptId = deptId; |
| | | this.user = user; |
| | | this.permissions = permissions; |
| | | } |
| | | |
| | | public String getUserId() |
| | | { |
| | | return userId; |
| | | } |
| | | |
| | | public void setUserId(String userId) |
| | | { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public Long getDeptId() |
| | | { |
| | | return deptId; |
| | | } |
| | | |
| | | public void setDeptId(Long deptId) |
| | | { |
| | | this.deptId = deptId; |
| | | } |
| | | |
| | | public String getToken() |
| | | { |
| | | return token; |
| | | } |
| | | |
| | | public void setToken(String token) |
| | | { |
| | | this.token = token; |
| | | } |
| | | |
| | | @JSONField(serialize = false) |
| | | @Override |
| | | public String getPassword() |
| | | { |
| | | return user.getPassword(); |
| | | } |
| | | |
| | | @Override |
| | | public String getUsername() |
| | | { |
| | | return user.getResidentName(); |
| | | } |
| | | |
| | | /** |
| | | * 账户是否未过期,过期无法验证 |
| | | */ |
| | | @JSONField(serialize = false) |
| | | @Override |
| | | public boolean isAccountNonExpired() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 指定用户是否解锁,锁定的用户无法进行身份验证 |
| | | * |
| | | * @return |
| | | */ |
| | | @JSONField(serialize = false) |
| | | @Override |
| | | public boolean isAccountNonLocked() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 指示是否已过期的用户的凭据(密码),过期的凭据防止认证 |
| | | * |
| | | * @return |
| | | */ |
| | | @JSONField(serialize = false) |
| | | @Override |
| | | public boolean isCredentialsNonExpired() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 是否可用 ,禁用的用户不能身份验证 |
| | | * |
| | | * @return |
| | | */ |
| | | @JSONField(serialize = false) |
| | | @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; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Collection<? extends GrantedAuthority> getAuthorities() |
| | | { |
| | | return null; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.domain.model; |
| | | |
| | | /** |
| | | * 用户注册对象 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class RegisterBody extends LoginBody |
| | | { |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.domain.model; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.core.domain.BasePage; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.Objects; |
| | | |
| | | @ApiModel("时间范围分页dto") |
| | | public class TimeRangeQueryBody extends BasePage { |
| | | |
| | | @ApiModelProperty("开始时间 格式 yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | private Date startTime; |
| | | |
| | | @ApiModelProperty("结束时间 格式 yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | private Date endTime; |
| | | |
| | | public String getStartTime() { |
| | | if (Objects.nonNull(startTime)) { |
| | | return new SimpleDateFormat("yyyy-MM-dd").format(startTime) + " 00:00:00"; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public void setStartTime(Date startTime) { |
| | | this.startTime = startTime; |
| | | } |
| | | |
| | | public String getEndTime() { |
| | | if (Objects.nonNull(endTime)) { |
| | | return new SimpleDateFormat("yyyy-MM-dd").format(endTime) + " 23:59:59"; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public void setEndTime(Date endTime) { |
| | | this.endTime = endTime; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.exception; |
| | | |
| | | /** |
| | | * 业务异常 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public final class ServiceException extends RuntimeException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 错误码 |
| | | */ |
| | | private Integer code; |
| | | |
| | | /** |
| | | * 错误提示 |
| | | */ |
| | | private String message; |
| | | |
| | | /** |
| | | * 错误明细,内部调试错误 |
| | | * |
| | | * 和 {@link CommonResult#getDetailMessage()} 一致的设计 |
| | | */ |
| | | private String detailMessage; |
| | | |
| | | /** |
| | | * 空构造方法,避免反序列化问题 |
| | | */ |
| | | public ServiceException() |
| | | { |
| | | } |
| | | |
| | | public ServiceException(String message) |
| | | { |
| | | this.message = message; |
| | | } |
| | | |
| | | public ServiceException(String message, Integer code) |
| | | { |
| | | this.message = message; |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getDetailMessage() |
| | | { |
| | | return detailMessage; |
| | | } |
| | | |
| | | @Override |
| | | public String getMessage() |
| | | { |
| | | return message; |
| | | } |
| | | |
| | | public Integer getCode() |
| | | { |
| | | return code; |
| | | } |
| | | |
| | | public ServiceException setMessage(String message) |
| | | { |
| | | this.message = message; |
| | | return this; |
| | | } |
| | | |
| | | public ServiceException setDetailMessage(String detailMessage) |
| | | { |
| | | this.detailMessage = detailMessage; |
| | | return this; |
| | | } |
| | | } |
New file |
| | |
| | | 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 = "asc"; |
| | | |
| | | /** 分页参数合理化 */ |
| | | private Boolean reasonable = true; |
| | | |
| | | 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) |
| | | { |
| | | if (StringUtils.isNotEmpty(isAsc)) |
| | | { |
| | | // 兼容前端排序类型 |
| | | if ("ascending".equals(isAsc)) |
| | | { |
| | | isAsc = "asc"; |
| | | } |
| | | else if ("descending".equals(isAsc)) |
| | | { |
| | | isAsc = "desc"; |
| | | } |
| | | this.isAsc = isAsc; |
| | | } |
| | | } |
| | | |
| | | public Boolean getReasonable() |
| | | { |
| | | if (StringUtils.isNull(reasonable)) |
| | | { |
| | | return Boolean.TRUE; |
| | | } |
| | | return reasonable; |
| | | } |
| | | |
| | | public void setReasonable(Boolean reasonable) |
| | | { |
| | | this.reasonable = reasonable; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.page; |
| | | |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 表格分页数据对象 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class TableDataInfo<T> implements Serializable |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** 总记录数 */ |
| | | private long total; |
| | | |
| | | /** 列表数据 */ |
| | | private List<?> records; |
| | | |
| | | /** 消息状态码 */ |
| | | private int code; |
| | | |
| | | /** 消息内容 */ |
| | | private String msg; |
| | | |
| | | // private boolean hasNextPage; |
| | | // private boolean hasPrevPage; |
| | | // private long startIndex; |
| | | |
| | | // public boolean getHasNextPage() { |
| | | // return hasNextPage; |
| | | // } |
| | | // |
| | | // public void setHasNextPage(boolean hasNextPage) { |
| | | // this.hasNextPage = hasNextPage; |
| | | // } |
| | | // |
| | | // public boolean getHasPrevPage() { |
| | | // return hasPrevPage; |
| | | // } |
| | | // |
| | | // public void setHasPrevPage(boolean hasPrevPage) { |
| | | // this.hasPrevPage = hasPrevPage; |
| | | // } |
| | | // |
| | | // private boolean hasNextPage(long currentPage, long totalPage) { |
| | | // return currentPage < totalPage && totalPage != 0; |
| | | // } |
| | | // private static boolean hasPrevPage(long currentPage) { |
| | | // return currentPage != 1; |
| | | // } |
| | | // |
| | | // public long getStartIndex() { |
| | | // return startIndex; |
| | | // } |
| | | // |
| | | // public void setStartIndex(long startIndex) { |
| | | // this.startIndex = startIndex; |
| | | // } |
| | | |
| | | |
| | | /** |
| | | * 表格数据对象 |
| | | */ |
| | | public TableDataInfo() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * 分页 |
| | | * |
| | | * @param list 列表数据 |
| | | * @param total 总记录数 |
| | | */ |
| | | public TableDataInfo(List<?> list, int total) |
| | | { |
| | | this.records = list; |
| | | this.total = total; |
| | | } |
| | | |
| | | public long getTotal() |
| | | { |
| | | return total; |
| | | } |
| | | |
| | | public void setTotal(long total) |
| | | { |
| | | this.total = total; |
| | | } |
| | | |
| | | public List<?> getRecords() |
| | | { |
| | | return records; |
| | | } |
| | | |
| | | public void setRecords(List<?> records) |
| | | { |
| | | this.records = records; |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.page; |
| | | |
| | | import com.ruoyi.common.core.text.Convert; |
| | | 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 final String REASONABLE = "reasonable"; |
| | | |
| | | /** |
| | | * 封装分页对象 |
| | | */ |
| | | public static PageDomain getPageDomain() |
| | | { |
| | | PageDomain pageDomain = new PageDomain(); |
| | | pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1)); |
| | | pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10)); |
| | | pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN)); |
| | | pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC)); |
| | | pageDomain.setReasonable(ServletUtils.getParameterToBool(REASONABLE)); |
| | | return pageDomain; |
| | | } |
| | | |
| | | public static PageDomain buildPageRequest() |
| | | { |
| | | return getPageDomain(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.redis; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.BoundSetOperations; |
| | | import org.springframework.data.redis.core.HashOperations; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.core.ValueOperations; |
| | | import org.springframework.data.redis.core.script.DefaultRedisScript; |
| | | import org.springframework.data.redis.core.script.RedisScript; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * spring redis 工具类 |
| | | * |
| | | * @author ruoyi |
| | | **/ |
| | | @SuppressWarnings(value = { "unchecked", "rawtypes" }) |
| | | @Component |
| | | public class RedisCache |
| | | { |
| | | private static final String LOCK_PREFIX = "lock:"; |
| | | private static final RedisScript<Long> UNLOCK_SCRIPT = new DefaultRedisScript<>( |
| | | "if redis.call('get', KEYS[1]) == ARGV[1] then " + |
| | | " return redis.call('del', KEYS[1]) " + |
| | | "else " + |
| | | " return 0 " + |
| | | "end", |
| | | Long.class |
| | | ); |
| | | @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 Redis键 |
| | | * @return 有效时间 |
| | | */ |
| | | public long getExpire(final String key) |
| | | { |
| | | return redisTemplate.getExpire(key); |
| | | } |
| | | |
| | | /** |
| | | * 判断 key是否存在 |
| | | * |
| | | * @param key 键 |
| | | * @return true 存在 false不存在 |
| | | */ |
| | | public Boolean hasKey(String key) |
| | | { |
| | | return redisTemplate.hasKey(key); |
| | | } |
| | | |
| | | /** |
| | | * 获得缓存的基本对象。 |
| | | * |
| | | * @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 boolean deleteObject(final Collection collection) |
| | | { |
| | | return redisTemplate.delete(collection) > 0; |
| | | } |
| | | |
| | | /** |
| | | * 缓存List数据 |
| | | * |
| | | * @param key 缓存的键值 |
| | | * @param dataList 待缓存的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> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) |
| | | { |
| | | BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key); |
| | | Iterator<T> it = dataSet.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | setOperation.add(it.next()); |
| | | } |
| | | return setOperation; |
| | | } |
| | | |
| | | /** |
| | | * 获得缓存的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); |
| | | } |
| | | |
| | | /** |
| | | * 删除Hash中的某条数据 |
| | | * |
| | | * @param key Redis键 |
| | | * @param hKey Hash键 |
| | | * @return 是否成功 |
| | | */ |
| | | public boolean deleteCacheMapValue(final String key, final String hKey) |
| | | { |
| | | return redisTemplate.opsForHash().delete(key, hKey) > 0; |
| | | } |
| | | |
| | | /** |
| | | * 获得缓存的基本对象列表 |
| | | * |
| | | * @param pattern 字符串前缀 |
| | | * @return 对象列表 |
| | | */ |
| | | public Collection<String> keys(final String pattern) |
| | | { |
| | | return redisTemplate.keys(pattern); |
| | | } |
| | | |
| | | /** |
| | | * 尝试加锁 |
| | | * |
| | | * @param lockKey 锁的key |
| | | * @param requestId 锁的持有者标识符(如UUID) |
| | | * @param expireTime 锁的过期时间(秒) |
| | | * @return 加锁成功返回true,否则返回false |
| | | */ |
| | | public boolean tryLock(String lockKey, String requestId, long expireTime) { |
| | | String lockKeyWithPrefix = LOCK_PREFIX + lockKey; |
| | | // 使用SET命令的NX和PX选项来加锁 |
| | | Boolean result = redisTemplate.opsForValue().setIfAbsent(lockKeyWithPrefix, requestId, expireTime, TimeUnit.SECONDS); |
| | | return result != null && result; |
| | | } |
| | | |
| | | /** |
| | | * 尝试加锁 |
| | | * |
| | | * @param lockKey 锁的key |
| | | * @param requestId 锁的持有者标识符(如UUID) |
| | | * @param expireTime 锁的过期时间(秒) |
| | | * @return 加锁成功返回true,否则返回false |
| | | */ |
| | | public boolean trylockLoop(String lockKey, String requestId,long expireTime) { |
| | | String lockKeyWithPrefix = LOCK_PREFIX + lockKey; |
| | | // 使用SET命令的NX和PX选项来加锁 |
| | | Boolean result = false; |
| | | int num = 50; |
| | | while (num>0){ |
| | | result = redisTemplate.opsForValue().setIfAbsent(lockKeyWithPrefix, requestId, expireTime, TimeUnit.SECONDS); |
| | | if (result){ |
| | | break; |
| | | } |
| | | try { |
| | | TimeUnit.MILLISECONDS.sleep(200); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | num--; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 解锁 |
| | | * |
| | | * @param lockKey 锁的key |
| | | * @param requestId 锁的持有者标识符(如UUID) |
| | | * @return 解锁成功返回true,否则返回false |
| | | */ |
| | | public boolean unlock(String lockKey, String requestId) { |
| | | String lockKeyWithPrefix = LOCK_PREFIX + lockKey; |
| | | // 使用Lua脚本来验证锁的持有者并解锁 |
| | | Long result = (Long) redisTemplate.execute(UNLOCK_SCRIPT, Collections.singletonList(lockKeyWithPrefix), requestId); |
| | | return result != null && result == 1L; |
| | | } |
| | | |
| | | /** |
| | | * 自增 |
| | | * @param key 要加一的键 |
| | | */ |
| | | public int increment(String key) { |
| | | // +1 操作 |
| | | return redisTemplate.opsForValue().increment(key).intValue(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.text; |
| | | |
| | | import java.nio.charset.Charset; |
| | | import java.nio.charset.StandardCharsets; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | /** |
| | | * 字符集工具类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class CharsetKit |
| | | { |
| | | /** ISO-8859-1 */ |
| | | public static final String ISO_8859_1 = "ISO-8859-1"; |
| | | /** UTF-8 */ |
| | | public static final String UTF_8 = "UTF-8"; |
| | | /** GBK */ |
| | | public static final String GBK = "GBK"; |
| | | |
| | | /** ISO-8859-1 */ |
| | | public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1); |
| | | /** UTF-8 */ |
| | | public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8); |
| | | /** GBK */ |
| | | public static final Charset CHARSET_GBK = Charset.forName(GBK); |
| | | |
| | | /** |
| | | * 转换为Charset对象 |
| | | * |
| | | * @param charset 字符集,为空则返回默认字符集 |
| | | * @return Charset |
| | | */ |
| | | public static Charset charset(String charset) |
| | | { |
| | | return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset); |
| | | } |
| | | |
| | | /** |
| | | * 转换字符串的字符集编码 |
| | | * |
| | | * @param source 字符串 |
| | | * @param srcCharset 源字符集,默认ISO-8859-1 |
| | | * @param destCharset 目标字符集,默认UTF-8 |
| | | * @return 转换后的字符集 |
| | | */ |
| | | public static String convert(String source, String srcCharset, String destCharset) |
| | | { |
| | | return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset)); |
| | | } |
| | | |
| | | /** |
| | | * 转换字符串的字符集编码 |
| | | * |
| | | * @param source 字符串 |
| | | * @param srcCharset 源字符集,默认ISO-8859-1 |
| | | * @param destCharset 目标字符集,默认UTF-8 |
| | | * @return 转换后的字符集 |
| | | */ |
| | | public static String convert(String source, Charset srcCharset, Charset destCharset) |
| | | { |
| | | if (null == srcCharset) |
| | | { |
| | | srcCharset = StandardCharsets.ISO_8859_1; |
| | | } |
| | | |
| | | if (null == destCharset) |
| | | { |
| | | destCharset = StandardCharsets.UTF_8; |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset)) |
| | | { |
| | | return source; |
| | | } |
| | | return new String(source.getBytes(srcCharset), destCharset); |
| | | } |
| | | |
| | | /** |
| | | * @return 系统字符集编码 |
| | | */ |
| | | public static String systemCharset() |
| | | { |
| | | return Charset.defaultCharset().name(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.text; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.charset.Charset; |
| | | import java.text.NumberFormat; |
| | | import java.util.Set; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | |
| | | /** |
| | | * 类型转换器 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class Convert |
| | | { |
| | | /** |
| | | * 转换为字符串<br> |
| | | * 如果给定的值为null,或者转换失败,返回默认值<br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @param defaultValue 转换错误时的默认值 |
| | | * @return 结果 |
| | | */ |
| | | public static String toStr(Object value, String defaultValue) |
| | | { |
| | | if (null == value) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | if (value instanceof String) |
| | | { |
| | | return (String) value; |
| | | } |
| | | return value.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 转换为字符串<br> |
| | | * 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static String toStr(Object value) |
| | | { |
| | | return toStr(value, null); |
| | | } |
| | | |
| | | /** |
| | | * 转换为字符<br> |
| | | * 如果给定的值为null,或者转换失败,返回默认值<br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @param defaultValue 转换错误时的默认值 |
| | | * @return 结果 |
| | | */ |
| | | public static Character toChar(Object value, Character defaultValue) |
| | | { |
| | | if (null == value) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | if (value instanceof Character) |
| | | { |
| | | return (Character) value; |
| | | } |
| | | |
| | | final String valueStr = toStr(value, null); |
| | | return StringUtils.isEmpty(valueStr) ? defaultValue : valueStr.charAt(0); |
| | | } |
| | | |
| | | /** |
| | | * 转换为字符<br> |
| | | * 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static Character toChar(Object value) |
| | | { |
| | | return toChar(value, null); |
| | | } |
| | | |
| | | /** |
| | | * 转换为byte<br> |
| | | * 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @param defaultValue 转换错误时的默认值 |
| | | * @return 结果 |
| | | */ |
| | | public static Byte toByte(Object value, Byte defaultValue) |
| | | { |
| | | if (value == null) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | if (value instanceof Byte) |
| | | { |
| | | return (Byte) value; |
| | | } |
| | | if (value instanceof Number) |
| | | { |
| | | return ((Number) value).byteValue(); |
| | | } |
| | | final String valueStr = toStr(value, null); |
| | | if (StringUtils.isEmpty(valueStr)) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | try |
| | | { |
| | | return Byte.parseByte(valueStr); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转换为byte<br> |
| | | * 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static Byte toByte(Object value) |
| | | { |
| | | return toByte(value, null); |
| | | } |
| | | |
| | | /** |
| | | * 转换为Short<br> |
| | | * 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @param defaultValue 转换错误时的默认值 |
| | | * @return 结果 |
| | | */ |
| | | public static Short toShort(Object value, Short defaultValue) |
| | | { |
| | | if (value == null) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | if (value instanceof Short) |
| | | { |
| | | return (Short) value; |
| | | } |
| | | if (value instanceof Number) |
| | | { |
| | | return ((Number) value).shortValue(); |
| | | } |
| | | final String valueStr = toStr(value, null); |
| | | if (StringUtils.isEmpty(valueStr)) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | try |
| | | { |
| | | return Short.parseShort(valueStr.trim()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转换为Short<br> |
| | | * 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static Short toShort(Object value) |
| | | { |
| | | return toShort(value, null); |
| | | } |
| | | |
| | | /** |
| | | * 转换为Number<br> |
| | | * 如果给定的值为空,或者转换失败,返回默认值<br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @param defaultValue 转换错误时的默认值 |
| | | * @return 结果 |
| | | */ |
| | | public static Number toNumber(Object value, Number defaultValue) |
| | | { |
| | | if (value == null) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | if (value instanceof Number) |
| | | { |
| | | return (Number) value; |
| | | } |
| | | final String valueStr = toStr(value, null); |
| | | if (StringUtils.isEmpty(valueStr)) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | try |
| | | { |
| | | return NumberFormat.getInstance().parse(valueStr); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转换为Number<br> |
| | | * 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static Number toNumber(Object value) |
| | | { |
| | | return toNumber(value, null); |
| | | } |
| | | |
| | | /** |
| | | * 转换为int<br> |
| | | * 如果给定的值为空,或者转换失败,返回默认值<br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @param defaultValue 转换错误时的默认值 |
| | | * @return 结果 |
| | | */ |
| | | public static Integer toInt(Object value, Integer defaultValue) |
| | | { |
| | | if (value == null) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | if (value instanceof Integer) |
| | | { |
| | | return (Integer) value; |
| | | } |
| | | if (value instanceof Number) |
| | | { |
| | | return ((Number) value).intValue(); |
| | | } |
| | | final String valueStr = toStr(value, null); |
| | | if (StringUtils.isEmpty(valueStr)) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | try |
| | | { |
| | | return Integer.parseInt(valueStr.trim()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转换为int<br> |
| | | * 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static Integer toInt(Object value) |
| | | { |
| | | return toInt(value, null); |
| | | } |
| | | |
| | | /** |
| | | * 转换为Integer数组<br> |
| | | * |
| | | * @param str 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static Integer[] toIntArray(String str) |
| | | { |
| | | return toIntArray(",", str); |
| | | } |
| | | |
| | | /** |
| | | * 转换为Long数组<br> |
| | | * |
| | | * @param str 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static Long[] toLongArray(String str) |
| | | { |
| | | return toLongArray(",", str); |
| | | } |
| | | |
| | | /** |
| | | * 转换为Integer数组<br> |
| | | * |
| | | * @param split 分隔符 |
| | | * @param split 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static Integer[] toIntArray(String split, String str) |
| | | { |
| | | if (StringUtils.isEmpty(str)) |
| | | { |
| | | return new Integer[] {}; |
| | | } |
| | | String[] arr = str.split(split); |
| | | final Integer[] ints = new Integer[arr.length]; |
| | | for (int i = 0; i < arr.length; i++) |
| | | { |
| | | final Integer v = toInt(arr[i], 0); |
| | | ints[i] = v; |
| | | } |
| | | return ints; |
| | | } |
| | | |
| | | /** |
| | | * 转换为Long数组<br> |
| | | * |
| | | * @param split 分隔符 |
| | | * @param str 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static Long[] toLongArray(String split, String str) |
| | | { |
| | | if (StringUtils.isEmpty(str)) |
| | | { |
| | | return new Long[] {}; |
| | | } |
| | | String[] arr = str.split(split); |
| | | final Long[] longs = new Long[arr.length]; |
| | | for (int i = 0; i < arr.length; i++) |
| | | { |
| | | final Long v = toLong(arr[i], null); |
| | | longs[i] = v; |
| | | } |
| | | return longs; |
| | | } |
| | | |
| | | /** |
| | | * 转换为String数组<br> |
| | | * |
| | | * @param str 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static String[] toStrArray(String str) |
| | | { |
| | | return toStrArray(",", str); |
| | | } |
| | | |
| | | /** |
| | | * 转换为String数组<br> |
| | | * |
| | | * @param split 分隔符 |
| | | * @param split 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static String[] toStrArray(String split, String str) |
| | | { |
| | | return str.split(split); |
| | | } |
| | | |
| | | /** |
| | | * 转换为long<br> |
| | | * 如果给定的值为空,或者转换失败,返回默认值<br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @param defaultValue 转换错误时的默认值 |
| | | * @return 结果 |
| | | */ |
| | | public static Long toLong(Object value, Long defaultValue) |
| | | { |
| | | if (value == null) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | if (value instanceof Long) |
| | | { |
| | | return (Long) value; |
| | | } |
| | | if (value instanceof Number) |
| | | { |
| | | return ((Number) value).longValue(); |
| | | } |
| | | final String valueStr = toStr(value, null); |
| | | if (StringUtils.isEmpty(valueStr)) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | try |
| | | { |
| | | // 支持科学计数法 |
| | | return new BigDecimal(valueStr.trim()).longValue(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转换为long<br> |
| | | * 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static Long toLong(Object value) |
| | | { |
| | | return toLong(value, null); |
| | | } |
| | | |
| | | /** |
| | | * 转换为double<br> |
| | | * 如果给定的值为空,或者转换失败,返回默认值<br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @param defaultValue 转换错误时的默认值 |
| | | * @return 结果 |
| | | */ |
| | | public static Double toDouble(Object value, Double defaultValue) |
| | | { |
| | | if (value == null) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | if (value instanceof Double) |
| | | { |
| | | return (Double) value; |
| | | } |
| | | if (value instanceof Number) |
| | | { |
| | | return ((Number) value).doubleValue(); |
| | | } |
| | | final String valueStr = toStr(value, null); |
| | | if (StringUtils.isEmpty(valueStr)) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | try |
| | | { |
| | | // 支持科学计数法 |
| | | return new BigDecimal(valueStr.trim()).doubleValue(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转换为double<br> |
| | | * 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static Double toDouble(Object value) |
| | | { |
| | | return toDouble(value, null); |
| | | } |
| | | |
| | | /** |
| | | * 转换为Float<br> |
| | | * 如果给定的值为空,或者转换失败,返回默认值<br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @param defaultValue 转换错误时的默认值 |
| | | * @return 结果 |
| | | */ |
| | | public static Float toFloat(Object value, Float defaultValue) |
| | | { |
| | | if (value == null) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | if (value instanceof Float) |
| | | { |
| | | return (Float) value; |
| | | } |
| | | if (value instanceof Number) |
| | | { |
| | | return ((Number) value).floatValue(); |
| | | } |
| | | final String valueStr = toStr(value, null); |
| | | if (StringUtils.isEmpty(valueStr)) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | try |
| | | { |
| | | return Float.parseFloat(valueStr.trim()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转换为Float<br> |
| | | * 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static Float toFloat(Object value) |
| | | { |
| | | return toFloat(value, null); |
| | | } |
| | | |
| | | /** |
| | | * 转换为boolean<br> |
| | | * String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值<br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @param defaultValue 转换错误时的默认值 |
| | | * @return 结果 |
| | | */ |
| | | public static Boolean toBool(Object value, Boolean defaultValue) |
| | | { |
| | | if (value == null) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | if (value instanceof Boolean) |
| | | { |
| | | return (Boolean) value; |
| | | } |
| | | String valueStr = toStr(value, null); |
| | | if (StringUtils.isEmpty(valueStr)) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | valueStr = valueStr.trim().toLowerCase(); |
| | | switch (valueStr) |
| | | { |
| | | case "true": |
| | | case "yes": |
| | | case "ok": |
| | | case "1": |
| | | return true; |
| | | case "false": |
| | | case "no": |
| | | case "0": |
| | | return false; |
| | | default: |
| | | return defaultValue; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转换为boolean<br> |
| | | * 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static Boolean toBool(Object value) |
| | | { |
| | | return toBool(value, null); |
| | | } |
| | | |
| | | /** |
| | | * 转换为Enum对象<br> |
| | | * 如果给定的值为空,或者转换失败,返回默认值<br> |
| | | * |
| | | * @param clazz Enum的Class |
| | | * @param value 值 |
| | | * @param defaultValue 默认值 |
| | | * @return Enum |
| | | */ |
| | | public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue) |
| | | { |
| | | if (value == null) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | if (clazz.isAssignableFrom(value.getClass())) |
| | | { |
| | | @SuppressWarnings("unchecked") |
| | | E myE = (E) value; |
| | | return myE; |
| | | } |
| | | final String valueStr = toStr(value, null); |
| | | if (StringUtils.isEmpty(valueStr)) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | try |
| | | { |
| | | return Enum.valueOf(clazz, valueStr); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转换为Enum对象<br> |
| | | * 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br> |
| | | * |
| | | * @param clazz Enum的Class |
| | | * @param value 值 |
| | | * @return Enum |
| | | */ |
| | | public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value) |
| | | { |
| | | return toEnum(clazz, value, null); |
| | | } |
| | | |
| | | /** |
| | | * 转换为BigInteger<br> |
| | | * 如果给定的值为空,或者转换失败,返回默认值<br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @param defaultValue 转换错误时的默认值 |
| | | * @return 结果 |
| | | */ |
| | | public static BigInteger toBigInteger(Object value, BigInteger defaultValue) |
| | | { |
| | | if (value == null) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | if (value instanceof BigInteger) |
| | | { |
| | | return (BigInteger) value; |
| | | } |
| | | if (value instanceof Long) |
| | | { |
| | | return BigInteger.valueOf((Long) value); |
| | | } |
| | | final String valueStr = toStr(value, null); |
| | | if (StringUtils.isEmpty(valueStr)) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | try |
| | | { |
| | | return new BigInteger(valueStr); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转换为BigInteger<br> |
| | | * 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static BigInteger toBigInteger(Object value) |
| | | { |
| | | return toBigInteger(value, null); |
| | | } |
| | | |
| | | /** |
| | | * 转换为BigDecimal<br> |
| | | * 如果给定的值为空,或者转换失败,返回默认值<br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @param defaultValue 转换错误时的默认值 |
| | | * @return 结果 |
| | | */ |
| | | public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) |
| | | { |
| | | if (value == null) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | if (value instanceof BigDecimal) |
| | | { |
| | | return (BigDecimal) value; |
| | | } |
| | | if (value instanceof Long) |
| | | { |
| | | return new BigDecimal((Long) value); |
| | | } |
| | | if (value instanceof Double) |
| | | { |
| | | return BigDecimal.valueOf((Double) value); |
| | | } |
| | | if (value instanceof Integer) |
| | | { |
| | | return new BigDecimal((Integer) value); |
| | | } |
| | | final String valueStr = toStr(value, null); |
| | | if (StringUtils.isEmpty(valueStr)) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | try |
| | | { |
| | | return new BigDecimal(valueStr); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转换为BigDecimal<br> |
| | | * 如果给定的值为空,或者转换失败,返回默认值<br> |
| | | * 转换失败不会报错 |
| | | * |
| | | * @param value 被转换的值 |
| | | * @return 结果 |
| | | */ |
| | | public static BigDecimal toBigDecimal(Object value) |
| | | { |
| | | return toBigDecimal(value, null); |
| | | } |
| | | |
| | | /** |
| | | * 将对象转为字符串<br> |
| | | * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 |
| | | * |
| | | * @param obj 对象 |
| | | * @return 字符串 |
| | | */ |
| | | public static String utf8Str(Object obj) |
| | | { |
| | | return str(obj, CharsetKit.CHARSET_UTF_8); |
| | | } |
| | | |
| | | /** |
| | | * 将对象转为字符串<br> |
| | | * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 |
| | | * |
| | | * @param obj 对象 |
| | | * @param charsetName 字符集 |
| | | * @return 字符串 |
| | | */ |
| | | public static String str(Object obj, String charsetName) |
| | | { |
| | | return str(obj, Charset.forName(charsetName)); |
| | | } |
| | | |
| | | /** |
| | | * 将对象转为字符串<br> |
| | | * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 |
| | | * |
| | | * @param obj 对象 |
| | | * @param charset 字符集 |
| | | * @return 字符串 |
| | | */ |
| | | public static String str(Object obj, Charset charset) |
| | | { |
| | | if (null == obj) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | if (obj instanceof String) |
| | | { |
| | | return (String) obj; |
| | | } |
| | | else if (obj instanceof byte[]) |
| | | { |
| | | return str((byte[]) obj, charset); |
| | | } |
| | | else if (obj instanceof Byte[]) |
| | | { |
| | | byte[] bytes = ArrayUtils.toPrimitive((Byte[]) obj); |
| | | return str(bytes, charset); |
| | | } |
| | | else if (obj instanceof ByteBuffer) |
| | | { |
| | | return str((ByteBuffer) obj, charset); |
| | | } |
| | | return obj.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 将byte数组转为字符串 |
| | | * |
| | | * @param bytes byte数组 |
| | | * @param charset 字符集 |
| | | * @return 字符串 |
| | | */ |
| | | public static String str(byte[] bytes, String charset) |
| | | { |
| | | return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset)); |
| | | } |
| | | |
| | | /** |
| | | * 解码字节码 |
| | | * |
| | | * @param data 字符串 |
| | | * @param charset 字符集,如果此字段为空,则解码的结果取决于平台 |
| | | * @return 解码后的字符串 |
| | | */ |
| | | public static String str(byte[] data, Charset charset) |
| | | { |
| | | if (data == null) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | if (null == charset) |
| | | { |
| | | return new String(data); |
| | | } |
| | | return new String(data, charset); |
| | | } |
| | | |
| | | /** |
| | | * 将编码的byteBuffer数据转换为字符串 |
| | | * |
| | | * @param data 数据 |
| | | * @param charset 字符集,如果为空使用当前系统字符集 |
| | | * @return 字符串 |
| | | */ |
| | | public static String str(ByteBuffer data, String charset) |
| | | { |
| | | if (data == null) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | return str(data, Charset.forName(charset)); |
| | | } |
| | | |
| | | /** |
| | | * 将编码的byteBuffer数据转换为字符串 |
| | | * |
| | | * @param data 数据 |
| | | * @param charset 字符集,如果为空使用当前系统字符集 |
| | | * @return 字符串 |
| | | */ |
| | | public static String str(ByteBuffer data, Charset charset) |
| | | { |
| | | if (null == charset) |
| | | { |
| | | charset = Charset.defaultCharset(); |
| | | } |
| | | return charset.decode(data).toString(); |
| | | } |
| | | |
| | | // ----------------------------------------------------------------------- 全角半角转换 |
| | | /** |
| | | * 半角转全角 |
| | | * |
| | | * @param input String. |
| | | * @return 全角字符串. |
| | | */ |
| | | public static String toSBC(String input) |
| | | { |
| | | return toSBC(input, null); |
| | | } |
| | | |
| | | /** |
| | | * 半角转全角 |
| | | * |
| | | * @param input String |
| | | * @param notConvertSet 不替换的字符集合 |
| | | * @return 全角字符串. |
| | | */ |
| | | public static String toSBC(String input, Set<Character> notConvertSet) |
| | | { |
| | | char[] c = input.toCharArray(); |
| | | for (int i = 0; i < c.length; i++) |
| | | { |
| | | if (null != notConvertSet && notConvertSet.contains(c[i])) |
| | | { |
| | | // 跳过不替换的字符 |
| | | continue; |
| | | } |
| | | |
| | | if (c[i] == ' ') |
| | | { |
| | | c[i] = '\u3000'; |
| | | } |
| | | else if (c[i] < '\177') |
| | | { |
| | | c[i] = (char) (c[i] + 65248); |
| | | |
| | | } |
| | | } |
| | | return new String(c); |
| | | } |
| | | |
| | | /** |
| | | * 全角转半角 |
| | | * |
| | | * @param input String. |
| | | * @return 半角字符串 |
| | | */ |
| | | public static String toDBC(String input) |
| | | { |
| | | return toDBC(input, null); |
| | | } |
| | | |
| | | /** |
| | | * 替换全角为半角 |
| | | * |
| | | * @param text 文本 |
| | | * @param notConvertSet 不替换的字符集合 |
| | | * @return 替换后的字符 |
| | | */ |
| | | public static String toDBC(String text, Set<Character> notConvertSet) |
| | | { |
| | | char[] c = text.toCharArray(); |
| | | for (int i = 0; i < c.length; i++) |
| | | { |
| | | if (null != notConvertSet && notConvertSet.contains(c[i])) |
| | | { |
| | | // 跳过不替换的字符 |
| | | continue; |
| | | } |
| | | |
| | | if (c[i] == '\u3000') |
| | | { |
| | | c[i] = ' '; |
| | | } |
| | | else if (c[i] > '\uFF00' && c[i] < '\uFF5F') |
| | | { |
| | | c[i] = (char) (c[i] - 65248); |
| | | } |
| | | } |
| | | String returnString = new String(c); |
| | | |
| | | return returnString; |
| | | } |
| | | |
| | | /** |
| | | * 数字金额大写转换 先写个完整的然后将如零拾替换成零 |
| | | * |
| | | * @param n 数字 |
| | | * @return 中文大写数字 |
| | | */ |
| | | public static String digitUppercase(double n) |
| | | { |
| | | String[] fraction = { "角", "分" }; |
| | | String[] digit = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }; |
| | | String[][] unit = { { "元", "万", "亿" }, { "", "拾", "佰", "仟" } }; |
| | | |
| | | String head = n < 0 ? "负" : ""; |
| | | n = Math.abs(n); |
| | | |
| | | String s = ""; |
| | | for (int i = 0; i < fraction.length; i++) |
| | | { |
| | | s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", ""); |
| | | } |
| | | if (s.length() < 1) |
| | | { |
| | | s = "整"; |
| | | } |
| | | int integerPart = (int) Math.floor(n); |
| | | |
| | | for (int i = 0; i < unit[0].length && integerPart > 0; i++) |
| | | { |
| | | String p = ""; |
| | | for (int j = 0; j < unit[1].length && n > 0; j++) |
| | | { |
| | | p = digit[integerPart % 10] + unit[1][j] + p; |
| | | integerPart = integerPart / 10; |
| | | } |
| | | s = p.replaceAll("(零.)*零$", "").replaceAll("^$", "零") + unit[0][i] + s; |
| | | } |
| | | return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整"); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.text; |
| | | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | /** |
| | | * 字符串格式化 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class StrFormatter |
| | | { |
| | | public static final String EMPTY_JSON = "{}"; |
| | | public static final char C_BACKSLASH = '\\'; |
| | | public static final char C_DELIM_START = '{'; |
| | | public static final char C_DELIM_END = '}'; |
| | | |
| | | /** |
| | | * 格式化字符串<br> |
| | | * 此方法只是简单将占位符 {} 按照顺序替换为参数<br> |
| | | * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br> |
| | | * 例:<br> |
| | | * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br> |
| | | * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br> |
| | | * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br> |
| | | * |
| | | * @param strPattern 字符串模板 |
| | | * @param argArray 参数列表 |
| | | * @return 结果 |
| | | */ |
| | | public static String format(final String strPattern, final Object... argArray) |
| | | { |
| | | if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray)) |
| | | { |
| | | return strPattern; |
| | | } |
| | | final int strPatternLength = strPattern.length(); |
| | | |
| | | // 初始化定义好的长度以获得更好的性能 |
| | | StringBuilder sbuf = new StringBuilder(strPatternLength + 50); |
| | | |
| | | int handledPosition = 0; |
| | | int delimIndex;// 占位符所在位置 |
| | | for (int argIndex = 0; argIndex < argArray.length; argIndex++) |
| | | { |
| | | delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition); |
| | | if (delimIndex == -1) |
| | | { |
| | | if (handledPosition == 0) |
| | | { |
| | | return strPattern; |
| | | } |
| | | else |
| | | { // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果 |
| | | sbuf.append(strPattern, handledPosition, strPatternLength); |
| | | return sbuf.toString(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH) |
| | | { |
| | | if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH) |
| | | { |
| | | // 转义符之前还有一个转义符,占位符依旧有效 |
| | | sbuf.append(strPattern, handledPosition, delimIndex - 1); |
| | | sbuf.append(Convert.utf8Str(argArray[argIndex])); |
| | | handledPosition = delimIndex + 2; |
| | | } |
| | | else |
| | | { |
| | | // 占位符被转义 |
| | | argIndex--; |
| | | sbuf.append(strPattern, handledPosition, delimIndex - 1); |
| | | sbuf.append(C_DELIM_START); |
| | | handledPosition = delimIndex + 1; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // 正常占位符 |
| | | sbuf.append(strPattern, handledPosition, delimIndex); |
| | | sbuf.append(Convert.utf8Str(argArray[argIndex])); |
| | | handledPosition = delimIndex + 2; |
| | | } |
| | | } |
| | | } |
| | | // 加入最后一个占位符后所有的字符 |
| | | sbuf.append(strPattern, handledPosition, strPattern.length()); |
| | | |
| | | return sbuf.toString(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.utils; |
| | | |
| | | /** |
| | | * 通用常量信息 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class Constants |
| | | { |
| | | /** |
| | | * UTF-8 字符集 |
| | | */ |
| | | public static final String UTF8 = "UTF-8"; |
| | | |
| | | /** |
| | | * GBK 字符集 |
| | | */ |
| | | public static final String GBK = "GBK"; |
| | | |
| | | /** |
| | | * www主域 |
| | | */ |
| | | public static final String WWW = "www."; |
| | | |
| | | /** |
| | | * RMI 远程方法调用 |
| | | */ |
| | | public static final String LOOKUP_RMI = "rmi:"; |
| | | |
| | | /** |
| | | * LDAP 远程方法调用 |
| | | */ |
| | | public static final String LOOKUP_LDAP = "ldap:"; |
| | | |
| | | /** |
| | | * LDAPS 远程方法调用 |
| | | */ |
| | | public static final String LOOKUP_LDAPS = "ldaps:"; |
| | | |
| | | /** |
| | | * http请求 |
| | | */ |
| | | public static final String HTTP = "http://"; |
| | | |
| | | /** |
| | | * https请求 |
| | | */ |
| | | public static final String HTTPS = "https://"; |
| | | |
| | | /** |
| | | * 成功标记 |
| | | */ |
| | | public static final Integer SUCCESS = 200; |
| | | |
| | | /** |
| | | * 失败标记 |
| | | */ |
| | | public static final Integer FAIL = 500; |
| | | |
| | | /** |
| | | * 登录成功状态 |
| | | */ |
| | | public static final String LOGIN_SUCCESS_STATUS = "1"; |
| | | |
| | | /** |
| | | * 登录失败状态 |
| | | */ |
| | | public static final String LOGIN_FAIL_STATUS = "2"; |
| | | |
| | | /** |
| | | * 登录成功 |
| | | */ |
| | | public static final String LOGIN_SUCCESS = "Success"; |
| | | |
| | | /** |
| | | * 注销 |
| | | */ |
| | | public static final String LOGOUT = "Logout"; |
| | | |
| | | /** |
| | | * 注册 |
| | | */ |
| | | public static final String REGISTER = "Register"; |
| | | |
| | | /** |
| | | * 登录失败 |
| | | */ |
| | | public static final String LOGIN_FAIL = "Error"; |
| | | |
| | | /** |
| | | * 当前记录起始索引 |
| | | */ |
| | | 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 final long CAPTCHA_EXPIRATION = 2; |
| | | |
| | | /** |
| | | * 资源映射路径 前缀 |
| | | */ |
| | | public static final String RESOURCE_PREFIX = "/profile"; |
| | | |
| | | /** |
| | | * 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加) |
| | | */ |
| | | public static final String[] JOB_WHITELIST_STR = { "com.ruoyi" }; |
| | | |
| | | /** |
| | | * 时间格式化 |
| | | */ |
| | | public static final String DATE_FORMATTER_TIME = "yyyy-MM-dd HH:mm:ss"; |
| | | public static final String DATE_FORMATTER_DATE = "yyyy-MM-dd"; |
| | | /** |
| | | * 修改手机号后缀 |
| | | */ |
| | | public static final String UPDATE_PHONE = "_updatePhone"; |
| | | /** |
| | | * 申请建桩后缀 |
| | | */ |
| | | public static final String APPLY_CHARGING = "_applyCharging"; |
| | | /** |
| | | * 定时任务违规的字符 |
| | | */ |
| | | public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml", |
| | | "org.springframework", "org.apache", "com.ruoyi.common.core.utils.file" }; |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.utils; |
| | | |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import javax.net.ssl.*; |
| | | import java.io.*; |
| | | import java.net.*; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.security.cert.X509Certificate; |
| | | |
| | | /** |
| | | * 通用http发送方法 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class HttpUtils |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(HttpUtils.class); |
| | | |
| | | /** |
| | | * 向指定 URL 发送GET方法的请求 |
| | | * |
| | | * @param url 发送请求的 URL |
| | | * @return 所代表远程资源的响应结果 |
| | | */ |
| | | public static String sendGet(String url) |
| | | { |
| | | return sendGet(url, StringUtils.EMPTY); |
| | | } |
| | | |
| | | /** |
| | | * 向指定 URL 发送GET方法的请求 |
| | | * |
| | | * @param url 发送请求的 URL |
| | | * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 |
| | | * @return 所代表远程资源的响应结果 |
| | | */ |
| | | public static String sendGet(String url, String param) |
| | | { |
| | | return sendGet(url, param, Constants.UTF8); |
| | | } |
| | | |
| | | /** |
| | | * 向指定 URL 发送GET方法的请求 |
| | | * |
| | | * @param url 发送请求的 URL |
| | | * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 |
| | | * @param contentType 编码类型 |
| | | * @return 所代表远程资源的响应结果 |
| | | */ |
| | | public static String sendGet(String url, String param, String contentType) |
| | | { |
| | | StringBuilder result = new StringBuilder(); |
| | | BufferedReader in = null; |
| | | try |
| | | { |
| | | String urlNameString = StringUtils.isNotBlank(param) ? url + "?" + param : url; |
| | | log.info("sendGet - {}", urlNameString); |
| | | URL realUrl = new URL(urlNameString); |
| | | URLConnection connection = realUrl.openConnection(); |
| | | connection.setRequestProperty("accept", "*/*"); |
| | | connection.setRequestProperty("connection", "Keep-Alive"); |
| | | connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); |
| | | connection.connect(); |
| | | in = new BufferedReader(new InputStreamReader(connection.getInputStream(), contentType)); |
| | | String line; |
| | | while ((line = in.readLine()) != null) |
| | | { |
| | | result.append(line); |
| | | } |
| | | log.info("recv - {}", result); |
| | | } |
| | | catch (ConnectException e) |
| | | { |
| | | log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e); |
| | | } |
| | | catch (SocketTimeoutException e) |
| | | { |
| | | log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | log.error("调用HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | log.error("调用HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e); |
| | | } |
| | | finally |
| | | { |
| | | try |
| | | { |
| | | if (in != null) |
| | | { |
| | | in.close(); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | log.error("调用in.close Exception, url=" + url + ",param=" + param, ex); |
| | | } |
| | | } |
| | | return result.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 向指定 URL 发送POST方法的请求 |
| | | * |
| | | * @param url 发送请求的 URL |
| | | * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 |
| | | * @return 所代表远程资源的响应结果 |
| | | */ |
| | | public static String sendPost(String url, String param) |
| | | { |
| | | PrintWriter out = null; |
| | | BufferedReader in = null; |
| | | StringBuilder result = new StringBuilder(); |
| | | try |
| | | { |
| | | log.info("sendPost - {}", url); |
| | | URL realUrl = new URL(url); |
| | | URLConnection conn = realUrl.openConnection(); |
| | | conn.setRequestProperty("accept", "*/*"); |
| | | conn.setRequestProperty("connection", "Keep-Alive"); |
| | | conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); |
| | | conn.setRequestProperty("Accept-Charset", "utf-8"); |
| | | conn.setRequestProperty("contentType", "utf-8"); |
| | | conn.setDoOutput(true); |
| | | conn.setDoInput(true); |
| | | out = new PrintWriter(conn.getOutputStream()); |
| | | out.print(param); |
| | | out.flush(); |
| | | in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8)); |
| | | String line; |
| | | while ((line = in.readLine()) != null) |
| | | { |
| | | result.append(line); |
| | | } |
| | | log.info("recv - {}", result); |
| | | } |
| | | catch (ConnectException e) |
| | | { |
| | | log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e); |
| | | } |
| | | catch (SocketTimeoutException e) |
| | | { |
| | | log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e); |
| | | } |
| | | finally |
| | | { |
| | | try |
| | | { |
| | | if (out != null) |
| | | { |
| | | out.close(); |
| | | } |
| | | if (in != null) |
| | | { |
| | | in.close(); |
| | | } |
| | | } |
| | | catch (IOException ex) |
| | | { |
| | | log.error("调用in.close Exception, url=" + url + ",param=" + param, ex); |
| | | } |
| | | } |
| | | return result.toString(); |
| | | } |
| | | |
| | | public static String sendSSLPost(String url, String param) |
| | | { |
| | | StringBuilder result = new StringBuilder(); |
| | | String urlNameString = url + "?" + param; |
| | | try |
| | | { |
| | | log.info("sendSSLPost - {}", urlNameString); |
| | | SSLContext sc = SSLContext.getInstance("SSL"); |
| | | sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom()); |
| | | URL console = new URL(urlNameString); |
| | | HttpsURLConnection conn = (HttpsURLConnection) console.openConnection(); |
| | | conn.setRequestProperty("accept", "*/*"); |
| | | conn.setRequestProperty("connection", "Keep-Alive"); |
| | | conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); |
| | | conn.setRequestProperty("Accept-Charset", "utf-8"); |
| | | conn.setRequestProperty("contentType", "utf-8"); |
| | | conn.setDoOutput(true); |
| | | conn.setDoInput(true); |
| | | |
| | | conn.setSSLSocketFactory(sc.getSocketFactory()); |
| | | conn.setHostnameVerifier(new TrustAnyHostnameVerifier()); |
| | | conn.connect(); |
| | | InputStream is = conn.getInputStream(); |
| | | BufferedReader br = new BufferedReader(new InputStreamReader(is)); |
| | | String ret = ""; |
| | | while ((ret = br.readLine()) != null) |
| | | { |
| | | if (ret != null && !"".equals(ret.trim())) |
| | | { |
| | | result.append(new String(ret.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8)); |
| | | } |
| | | } |
| | | log.info("recv - {}", result); |
| | | conn.disconnect(); |
| | | br.close(); |
| | | } |
| | | catch (ConnectException e) |
| | | { |
| | | log.error("调用HttpUtils.sendSSLPost ConnectException, url=" + url + ",param=" + param, e); |
| | | } |
| | | catch (SocketTimeoutException e) |
| | | { |
| | | log.error("调用HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + ",param=" + param, e); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | log.error("调用HttpUtils.sendSSLPost IOException, url=" + url + ",param=" + param, e); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | log.error("调用HttpsUtil.sendSSLPost Exception, url=" + url + ",param=" + param, e); |
| | | } |
| | | return result.toString(); |
| | | } |
| | | |
| | | public static String post(String strURL, String params) { |
| | | String result = ""; |
| | | BufferedReader reader = null; |
| | | try { |
| | | URL url = new URL(strURL);// 创建连接 |
| | | HttpURLConnection connection = (HttpURLConnection) url |
| | | .openConnection(); |
| | | connection.setDoOutput(true); |
| | | connection.setDoInput(true); |
| | | connection.setUseCaches(false); |
| | | connection.setInstanceFollowRedirects(true); |
| | | connection.setRequestMethod("POST"); // 设置请求方式 |
| | | connection.setRequestProperty("Accept", "application/json"); // 设置接收数据的格式 |
| | | connection.setRequestProperty("Content-Type", "application/json"); // 设置发送数据的格式 |
| | | connection.connect(); |
| | | if (params != null && !StringUtils.isEmpty(params)) { |
| | | byte[] writebytes = params.getBytes(); |
| | | // 设置文件长度 |
| | | // connection.setRequestProperty("Content-Length", String.valueOf(writebytes.length)); |
| | | OutputStream outwritestream = connection.getOutputStream(); |
| | | outwritestream.write(params.getBytes()); |
| | | outwritestream.flush(); |
| | | outwritestream.close(); |
| | | // Log.d("hlhupload", "doJsonPost: conn"+connection.getResponseCode()); |
| | | } |
| | | if (connection.getResponseCode() == 200) { |
| | | log.info("<<<<<<<<<<<<<请求响应:{}", connection.getResponseMessage()); |
| | | reader = new BufferedReader( |
| | | new InputStreamReader(connection.getInputStream())); |
| | | result = reader.readLine(); |
| | | log.info("<<<<<<<<<<<<<请求响应:{}", result); |
| | | } else { |
| | | throw new ServiceException(connection.getResponseMessage()); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new ServiceException("http的post请求异常!" + e.getMessage()); |
| | | } finally { |
| | | if (reader != null) { |
| | | try { |
| | | reader.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private static class TrustAnyTrustManager implements X509TrustManager |
| | | { |
| | | @Override |
| | | public void checkClientTrusted(X509Certificate[] chain, String authType) |
| | | { |
| | | } |
| | | |
| | | @Override |
| | | public void checkServerTrusted(X509Certificate[] chain, String authType) |
| | | { |
| | | } |
| | | |
| | | @Override |
| | | public X509Certificate[] getAcceptedIssuers() |
| | | { |
| | | return new X509Certificate[] {}; |
| | | } |
| | | } |
| | | |
| | | private static class TrustAnyHostnameVerifier implements HostnameVerifier |
| | | { |
| | | @Override |
| | | public boolean verify(String hostname, SSLSession session) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | @Getter |
| | | public enum BillTypeEnum { |
| | | |
| | | Zujin(1,"租金"), |
| | | Yajin(2,"押金"), |
| | | ShenghuoFee(3,"生活费用"), |
| | | FangwuYanshou(4,"房屋验收"), |
| | | ; |
| | | |
| | | private Integer code; |
| | | |
| | | private String name; |
| | | BillTypeEnum(Integer code,String name){ |
| | | this.code = code; |
| | | this.name = name; |
| | | } |
| | | |
| | | public static BillTypeEnum getByCode(Integer code){ |
| | | BillTypeEnum[] values = BillTypeEnum.values(); |
| | | for (BillTypeEnum value : values) { |
| | | if (value.code==code){ |
| | | return value; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | /** |
| | | * 操作状态 |
| | | * |
| | | * @author ruoyi |
| | | * |
| | | */ |
| | | public enum BusinessStatus |
| | | { |
| | | /** |
| | | * 成功 |
| | | */ |
| | | SUCCESS, |
| | | |
| | | /** |
| | | * 失败 |
| | | */ |
| | | FAIL, |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | /** |
| | | * 业务操作类型 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public enum BusinessType |
| | | { |
| | | /** |
| | | * 其它 |
| | | */ |
| | | OTHER, |
| | | |
| | | /** |
| | | * 新增 |
| | | */ |
| | | INSERT, |
| | | |
| | | /** |
| | | * 修改 |
| | | */ |
| | | UPDATE, |
| | | |
| | | /** |
| | | * 删除 |
| | | */ |
| | | DELETE, |
| | | |
| | | /** |
| | | * 授权 |
| | | */ |
| | | GRANT, |
| | | |
| | | /** |
| | | * 导出 |
| | | */ |
| | | EXPORT, |
| | | |
| | | /** |
| | | * 导入 |
| | | */ |
| | | IMPORT, |
| | | |
| | | /** |
| | | * 强退 |
| | | */ |
| | | FORCE, |
| | | |
| | | /** |
| | | * 生成代码 |
| | | */ |
| | | GENCODE, |
| | | |
| | | /** |
| | | * 清空数据 |
| | | */ |
| | | CLEAN, |
| | | /** |
| | | * 查询 |
| | | */ |
| | | SELECT, |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | /** |
| | | * 数据源 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public enum DataSourceType |
| | | { |
| | | /** |
| | | * 主库 |
| | | */ |
| | | MASTER, |
| | | |
| | | /** |
| | | * 从库 |
| | | */ |
| | | SLAVE |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * @author xiaochen |
| | | * @ClassName Disable |
| | | * @Description |
| | | * @date 2022-06-08 16:55 |
| | | */ |
| | | public enum DisabledEnum { |
| | | NO(0, "否"), |
| | | YES(1, "是"); |
| | | |
| | | @Getter |
| | | private String desc; |
| | | |
| | | |
| | | @Getter |
| | | private int code; |
| | | |
| | | |
| | | DisabledEnum(int code, String desc) { |
| | | this.code = code; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | /** |
| | | * 通过code获取枚举 |
| | | * |
| | | * @param code |
| | | * @return |
| | | */ |
| | | public static DisabledEnum fromCode(Integer code) { |
| | | DisabledEnum[] resultTypes = DisabledEnum.values(); |
| | | for (DisabledEnum resultType : resultTypes) { |
| | | if (code.equals(resultType.getCode())) { |
| | | return resultType; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import org.springframework.lang.Nullable; |
| | | |
| | | /** |
| | | * 请求方式 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public enum HttpMethod |
| | | { |
| | | GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE; |
| | | |
| | | private static final Map<String, HttpMethod> mappings = new HashMap<>(16); |
| | | |
| | | static |
| | | { |
| | | for (HttpMethod httpMethod : values()) |
| | | { |
| | | mappings.put(httpMethod.name(), httpMethod); |
| | | } |
| | | } |
| | | |
| | | @Nullable |
| | | public static HttpMethod resolve(@Nullable String method) |
| | | { |
| | | return (method != null ? mappings.get(method) : null); |
| | | } |
| | | |
| | | public boolean matches(String method) |
| | | { |
| | | return (this == resolve(method)); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | /** |
| | | * 限流类型 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | |
| | | public enum LimitType |
| | | { |
| | | /** |
| | | * 默认策略全局限流 |
| | | */ |
| | | DEFAULT, |
| | | |
| | | /** |
| | | * 根据请求者IP进行限流 |
| | | */ |
| | | IP |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | /** |
| | | * 操作人类别 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public enum OperatorType |
| | | { |
| | | /** |
| | | * 其它 |
| | | */ |
| | | OTHER, |
| | | |
| | | /** |
| | | * 后台用户 |
| | | */ |
| | | MANAGE, |
| | | |
| | | /** |
| | | * 手机端用户 |
| | | */ |
| | | MOBILE |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 1. 入户调查 |
| | | * 2. 价格评估 |
| | | * 3. 协议签订 |
| | | * 固定对应表 state_process_module |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum ProcessCategoryEnum { |
| | | CATEGORY0(0, "错误分类"), |
| | | CATEGORY1(1, "合同新增审批"), |
| | | CATEGORY2(2, "合同签订审批"), |
| | | CATEGORY3(3, "合同提前终止审批"), |
| | | ; |
| | | |
| | | |
| | | private final Integer value; |
| | | private final String text; |
| | | |
| | | public static Integer getValue(String text) { |
| | | for (ProcessCategoryEnum v : ProcessCategoryEnum.values()) { |
| | | if (v.text.equals(text)) { |
| | | return v.value; |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | public static String getValueByKey(Integer key) { |
| | | for (ProcessCategoryEnum v : ProcessCategoryEnum.values()) { |
| | | if (v.getValue().equals(key)) { |
| | | return v.getText(); |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | public static ProcessCategoryEnum getEnumByKey(Integer key) { |
| | | for (ProcessCategoryEnum v : ProcessCategoryEnum.values()) { |
| | | if (v.getValue().equals(key)) { |
| | | return v; |
| | | } |
| | | } |
| | | return CATEGORY0; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 流程动作枚举 |
| | | * |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum StateProcessActionEnum { |
| | | |
| | | START(0), // "发起" |
| | | REJECTED(3), // "拒绝" |
| | | APPROVED(4), // "通过" |
| | | CANCELED(5), // "撤销" |
| | | BACK(7), // "回退" |
| | | COPY(12), // "抄送" |
| | | FORWARD(13), // "转发" |
| | | COMMENT(14), // "评论" |
| | | TRANSACT(15); // "办理" |
| | | |
| | | private final int value; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | @Getter |
| | | public enum SubmitStatusEnum { |
| | | SUBMITTED(-1, ""), |
| | | REJECT(0, "已退回"), |
| | | PENDING_REVIEW(1, "待审核"), |
| | | ACCEPT(3, "已接收"); |
| | | |
| | | private final int value; |
| | | private final String text; |
| | | |
| | | public static String getTextByValue(Integer value) { |
| | | if (Objects.isNull(value)) { |
| | | return ""; |
| | | } |
| | | for (SubmitStatusEnum v : SubmitStatusEnum.values()) { |
| | | if (v.getValue() == (value)) { |
| | | return v.getText(); |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | SubmitStatusEnum(int value, String text) { |
| | | this.text = text; |
| | | this.value = value; |
| | | } |
| | | } |
New file |
| | |
| | | /* |
| | | * Copyright 2023-2025 Licensed under the Dual Licensing |
| | | * website: https://aizuda.com |
| | | */ |
| | | package com.ruoyi.common.enums; |
| | | |
| | | /** |
| | | * 流程引擎监听类型 |
| | | * |
| | | * <p> |
| | | * <a href="https://aizuda.com">官网</a>尊重知识产权,不允许非法使用,后果自负 |
| | | * </p> |
| | | * |
| | | * @author lizhongyuan |
| | | * @since 1.0 |
| | | */ |
| | | public enum TaskEventType { |
| | | /** |
| | | * 发起 |
| | | */ |
| | | start, |
| | | /** |
| | | * 创建 |
| | | */ |
| | | create, |
| | | /** |
| | | * 再创建,仅用于流程回退 |
| | | */ |
| | | recreate, |
| | | /** |
| | | * 抄送 |
| | | */ |
| | | cc, |
| | | /** |
| | | * 分配 |
| | | */ |
| | | assignment, |
| | | /** |
| | | * 委派任务解决 |
| | | */ |
| | | delegateResolve, |
| | | /** |
| | | * 任务加签 |
| | | */ |
| | | addTaskActor, |
| | | /** |
| | | * 任务减签 |
| | | */ |
| | | removeTaskActor, |
| | | /** |
| | | * 驳回至上一步处理 |
| | | */ |
| | | reject, |
| | | /** |
| | | * 角色认领 |
| | | */ |
| | | claimRole, |
| | | /** |
| | | * 部门认领 |
| | | */ |
| | | claimDepartment, |
| | | /** |
| | | * 拿回未执行任务 |
| | | */ |
| | | reclaim, |
| | | /** |
| | | * 撤回指定任务 |
| | | */ |
| | | withdraw, |
| | | /** |
| | | * 唤醒历史任务 |
| | | */ |
| | | resume, |
| | | /** |
| | | * 完成 |
| | | */ |
| | | complete, |
| | | /** |
| | | * 撤销 |
| | | */ |
| | | revoke, |
| | | /** |
| | | * 终止 |
| | | */ |
| | | terminate, |
| | | /** |
| | | * 更新 |
| | | */ |
| | | update, |
| | | /** |
| | | * 删除 |
| | | */ |
| | | delete, |
| | | /** |
| | | * 调用外部流程任务【办理子流程】 |
| | | */ |
| | | callProcess, |
| | | /** |
| | | * 超时 |
| | | */ |
| | | timeout, |
| | | /** |
| | | * 跳转 |
| | | */ |
| | | jump, |
| | | /** |
| | | * 自动跳转 |
| | | */ |
| | | autoJump, |
| | | /** |
| | | * 驳回跳转 |
| | | */ |
| | | rejectJump, |
| | | /** |
| | | * 路由跳转 |
| | | */ |
| | | routeJump, |
| | | /** |
| | | * 驳回重新审批跳转 |
| | | */ |
| | | reApproveJump, |
| | | /** |
| | | * 自动审批完成 |
| | | */ |
| | | autoComplete, |
| | | /** |
| | | * 自动审批拒绝 |
| | | */ |
| | | autoReject, |
| | | /** |
| | | * 触发器任务 |
| | | */ |
| | | trigger, |
| | | /** |
| | | * 结束 |
| | | */ |
| | | end; |
| | | |
| | | public boolean eq(TaskEventType eventType) { |
| | | return this == eventType; |
| | | } |
| | | |
| | | public boolean ne(TaskEventType eventType) { |
| | | return this != eventType; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * @author xiaochen |
| | | * @ClassName Disable |
| | | * @Description |
| | | * @date 2022-06-08 16:55 |
| | | */ |
| | | public enum UpdateTypeEnum { |
| | | /*调整类型 1=经理更换,2=负责人更换,3=人员新增,4=调整计划时间*/ |
| | | PROJECT_MANAGER(1, "经理更换"), |
| | | WORK_HEADER(2, "负责人更换"), |
| | | ADD_USER(3, "人员新增"), |
| | | UPDATE_PLAN_TIME(4, "调整计划时间"), |
| | | REDUCE_USER(5, "人员减少"); |
| | | |
| | | @Getter |
| | | private String desc; |
| | | |
| | | |
| | | @Getter |
| | | private int code; |
| | | |
| | | |
| | | UpdateTypeEnum(int code, String desc) { |
| | | this.code = code; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | /** |
| | | * 通过code获取枚举 |
| | | * |
| | | * @param code |
| | | * @return |
| | | */ |
| | | public static UpdateTypeEnum fromCode(Integer code) { |
| | | UpdateTypeEnum[] resultTypes = UpdateTypeEnum.values(); |
| | | for (UpdateTypeEnum resultType : resultTypes) { |
| | | if (code.equals(resultType.getCode())) { |
| | | return resultType; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | /** |
| | | * 用户状态 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public enum UserStatus |
| | | { |
| | | OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除"); |
| | | |
| | | private final String code; |
| | | private final String info; |
| | | |
| | | UserStatus(String code, String info) |
| | | { |
| | | this.code = code; |
| | | this.info = info; |
| | | } |
| | | |
| | | public String getCode() |
| | | { |
| | | return code; |
| | | } |
| | | |
| | | public String getInfo() |
| | | { |
| | | return info; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception; |
| | | |
| | | /** |
| | | * 演示模式异常 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class DemoModeException extends RuntimeException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public DemoModeException() |
| | | { |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception; |
| | | |
| | | /** |
| | | * 全局异常 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class GlobalException extends RuntimeException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 错误提示 |
| | | */ |
| | | private String message; |
| | | |
| | | /** |
| | | * 错误明细,内部调试错误 |
| | | * |
| | | * 和 {@link CommonResult#getDetailMessage()} 一致的设计 |
| | | */ |
| | | private String detailMessage; |
| | | |
| | | /** |
| | | * 空构造方法,避免反序列化问题 |
| | | */ |
| | | public GlobalException() |
| | | { |
| | | } |
| | | |
| | | public GlobalException(String message) |
| | | { |
| | | this.message = message; |
| | | } |
| | | |
| | | public String getDetailMessage() |
| | | { |
| | | return detailMessage; |
| | | } |
| | | |
| | | public GlobalException setDetailMessage(String detailMessage) |
| | | { |
| | | this.detailMessage = detailMessage; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public String getMessage() |
| | | { |
| | | return message; |
| | | } |
| | | |
| | | public GlobalException setMessage(String message) |
| | | { |
| | | this.message = message; |
| | | return this; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception; |
| | | |
| | | /** |
| | | * 业务异常 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public final class ServiceException extends RuntimeException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 错误码 |
| | | */ |
| | | private Integer code; |
| | | |
| | | /** |
| | | * 错误提示 |
| | | */ |
| | | private String message; |
| | | |
| | | /** |
| | | * 错误明细,内部调试错误 |
| | | * |
| | | * 和 {@link CommonResult#getDetailMessage()} 一致的设计 |
| | | */ |
| | | private String detailMessage; |
| | | |
| | | /** |
| | | * 空构造方法,避免反序列化问题 |
| | | */ |
| | | public ServiceException() |
| | | { |
| | | } |
| | | |
| | | public ServiceException(String message) |
| | | { |
| | | this.message = message; |
| | | } |
| | | |
| | | public ServiceException(String message, Integer code) |
| | | { |
| | | this.message = message; |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getDetailMessage() |
| | | { |
| | | return detailMessage; |
| | | } |
| | | |
| | | @Override |
| | | public String getMessage() |
| | | { |
| | | return message; |
| | | } |
| | | |
| | | public Integer getCode() |
| | | { |
| | | return code; |
| | | } |
| | | |
| | | public ServiceException setMessage(String message) |
| | | { |
| | | this.message = message; |
| | | return this; |
| | | } |
| | | |
| | | public ServiceException setDetailMessage(String detailMessage) |
| | | { |
| | | this.detailMessage = detailMessage; |
| | | return this; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception; |
| | | |
| | | /** |
| | | * 工具类异常 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class UtilException extends RuntimeException |
| | | { |
| | | private static final long serialVersionUID = 8247610319171014183L; |
| | | |
| | | public UtilException(Throwable e) |
| | | { |
| | | super(e.getMessage(), e); |
| | | } |
| | | |
| | | public UtilException(String message) |
| | | { |
| | | super(message); |
| | | } |
| | | |
| | | public UtilException(String message, Throwable throwable) |
| | | { |
| | | super(message, throwable); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception.base; |
| | | |
| | | import com.ruoyi.common.utils.MessageUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | /** |
| | | * 基础异常 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class BaseException extends RuntimeException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 所属模块 |
| | | */ |
| | | private String module; |
| | | |
| | | /** |
| | | * 错误码 |
| | | */ |
| | | private String code; |
| | | |
| | | /** |
| | | * 错误码对应的参数 |
| | | */ |
| | | private Object[] args; |
| | | |
| | | /** |
| | | * 错误消息 |
| | | */ |
| | | private String defaultMessage; |
| | | |
| | | public BaseException(String module, String code, Object[] args, String defaultMessage) |
| | | { |
| | | this.module = module; |
| | | this.code = code; |
| | | this.args = args; |
| | | this.defaultMessage = defaultMessage; |
| | | } |
| | | |
| | | public BaseException(String module, String code, Object[] args) |
| | | { |
| | | this(module, code, args, null); |
| | | } |
| | | |
| | | public BaseException(String module, String defaultMessage) |
| | | { |
| | | this(module, null, null, defaultMessage); |
| | | } |
| | | |
| | | public BaseException(String code, Object[] args) |
| | | { |
| | | this(null, code, args, null); |
| | | } |
| | | |
| | | public BaseException(String defaultMessage) |
| | | { |
| | | this(null, null, null, defaultMessage); |
| | | } |
| | | |
| | | @Override |
| | | public String getMessage() |
| | | { |
| | | String message = null; |
| | | if (!StringUtils.isEmpty(code)) |
| | | { |
| | | message = MessageUtils.message(code, args); |
| | | } |
| | | if (message == null) |
| | | { |
| | | message = defaultMessage; |
| | | } |
| | | return message; |
| | | } |
| | | |
| | | public String getModule() |
| | | { |
| | | return module; |
| | | } |
| | | |
| | | public String getCode() |
| | | { |
| | | return code; |
| | | } |
| | | |
| | | public Object[] getArgs() |
| | | { |
| | | return args; |
| | | } |
| | | |
| | | public String getDefaultMessage() |
| | | { |
| | | return defaultMessage; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception.file; |
| | | |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | |
| | | /** |
| | | * 文件信息异常类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class FileException extends BaseException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public FileException(String code, Object[] args) |
| | | { |
| | | super("file", code, args, null); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception.file; |
| | | |
| | | /** |
| | | * 文件名称超长限制异常类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class FileNameLengthLimitExceededException extends FileException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public FileNameLengthLimitExceededException(int defaultFileNameLength) |
| | | { |
| | | super("upload.filename.exceed.length", new Object[] { defaultFileNameLength }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception.file; |
| | | |
| | | /** |
| | | * 文件名大小限制异常类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class FileSizeLimitExceededException extends FileException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public FileSizeLimitExceededException(long defaultMaxSize) |
| | | { |
| | | super("upload.exceed.maxSize", new Object[] { defaultMaxSize }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception.file; |
| | | |
| | | import java.io.PrintStream; |
| | | import java.io.PrintWriter; |
| | | |
| | | /** |
| | | * 文件上传异常类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class FileUploadException extends Exception |
| | | { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private final Throwable cause; |
| | | |
| | | public FileUploadException() |
| | | { |
| | | this(null, null); |
| | | } |
| | | |
| | | public FileUploadException(final String msg) |
| | | { |
| | | this(msg, null); |
| | | } |
| | | |
| | | public FileUploadException(String msg, Throwable cause) |
| | | { |
| | | super(msg); |
| | | this.cause = cause; |
| | | } |
| | | |
| | | @Override |
| | | public void printStackTrace(PrintStream stream) |
| | | { |
| | | super.printStackTrace(stream); |
| | | if (cause != null) |
| | | { |
| | | stream.println("Caused by:"); |
| | | cause.printStackTrace(stream); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void printStackTrace(PrintWriter writer) |
| | | { |
| | | super.printStackTrace(writer); |
| | | if (cause != null) |
| | | { |
| | | writer.println("Caused by:"); |
| | | cause.printStackTrace(writer); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Throwable getCause() |
| | | { |
| | | return cause; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception.file; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * 文件上传 误异常类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class InvalidExtensionException extends FileUploadException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String[] allowedExtension; |
| | | private String extension; |
| | | private String filename; |
| | | |
| | | public InvalidExtensionException(String[] allowedExtension, String extension, String filename) |
| | | { |
| | | super("文件[" + filename + "]后缀[" + extension + "]不正确,请上传" + Arrays.toString(allowedExtension) + "格式"); |
| | | this.allowedExtension = allowedExtension; |
| | | this.extension = extension; |
| | | this.filename = filename; |
| | | } |
| | | |
| | | public String[] getAllowedExtension() |
| | | { |
| | | return allowedExtension; |
| | | } |
| | | |
| | | public String getExtension() |
| | | { |
| | | return extension; |
| | | } |
| | | |
| | | public String getFilename() |
| | | { |
| | | return filename; |
| | | } |
| | | |
| | | public static class InvalidImageExtensionException extends InvalidExtensionException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) |
| | | { |
| | | super(allowedExtension, extension, filename); |
| | | } |
| | | } |
| | | |
| | | public static class InvalidFlashExtensionException extends InvalidExtensionException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) |
| | | { |
| | | super(allowedExtension, extension, filename); |
| | | } |
| | | } |
| | | |
| | | public static class InvalidMediaExtensionException extends InvalidExtensionException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) |
| | | { |
| | | super(allowedExtension, extension, filename); |
| | | } |
| | | } |
| | | |
| | | public static class InvalidVideoExtensionException extends InvalidExtensionException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename) |
| | | { |
| | | super(allowedExtension, extension, filename); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | 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 |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception.state; |
| | | |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum StateErrorCode { |
| | | |
| | | PROCESS_TEMPLATE_KEY_EXISTS("已经存在此名称的模版了!"), |
| | | PROCESS_TEMPLATE_NOT_EXISTS("流程模版不存在!"), |
| | | PROCESS_NOT_DEPLOY("模版尚未部署成功"), |
| | | PROCESS_VERSION_ERROR("流程引擎版本不一致"), |
| | | ; |
| | | |
| | | private final String value; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception.user; |
| | | |
| | | /** |
| | | * 黑名单IP异常类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class BlackListException extends UserException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public BlackListException() |
| | | { |
| | | super("login.blocked", null); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception.user; |
| | | |
| | | /** |
| | | * 验证码错误异常类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class CaptchaException extends UserException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public CaptchaException() |
| | | { |
| | | super("user.jcaptcha.error", null); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception.user; |
| | | |
| | | /** |
| | | * 验证码失效异常类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class CaptchaExpireException extends UserException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public CaptchaExpireException() |
| | | { |
| | | super("user.jcaptcha.expire", null); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception.user; |
| | | |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | |
| | | /** |
| | | * 用户信息异常类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class UserException extends BaseException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public UserException(String code, Object[] args) |
| | | { |
| | | super("user", code, args, null); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception.user; |
| | | |
| | | /** |
| | | * 用户不存在异常类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class UserNotExistsException extends UserException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public UserNotExistsException() |
| | | { |
| | | super("user.not.exists", null); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception.user; |
| | | |
| | | /** |
| | | * 用户密码不正确或不符合规范异常类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class UserPasswordNotMatchException extends UserException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public UserPasswordNotMatchException() |
| | | { |
| | | super("user.password.not.match", null); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.exception.user; |
| | | |
| | | /** |
| | | * 用户错误最大次数异常类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class UserPasswordRetryLimitExceedException extends UserException |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public UserPasswordRetryLimitExceedException(int retryLimitCount, int lockTime) |
| | | { |
| | | super("user.password.retry.limit.exceed", new Object[] { retryLimitCount, lockTime }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.filter; |
| | | |
| | | |
| | | import javax.servlet.ReadListener; |
| | | import javax.servlet.ServletInputStream; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletRequestWrapper; |
| | | import java.io.BufferedReader; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | |
| | | public class CustomRequestWrapper extends HttpServletRequestWrapper { |
| | | private final String body; |
| | | |
| | | /** |
| | | * 构造函数,用于创建自定义请求包装器。 |
| | | * |
| | | * @param request 原始 HTTP 请求对象 |
| | | * @param body 新的请求体内容 |
| | | * @throws IOException 如果读取或处理请求体时发生错误 |
| | | */ |
| | | public CustomRequestWrapper(HttpServletRequest request, String body) throws IOException { |
| | | super(request); |
| | | this.body = body; |
| | | } |
| | | |
| | | /** |
| | | * 重写 getInputStream 方法,返回一个新的 ServletInputStream, |
| | | * 其中包含修改后的请求体内容。 |
| | | * |
| | | * @return 包含修改后请求体内容的 ServletInputStream |
| | | * @throws IOException 如果读取输入流时发生错误 |
| | | */ |
| | | @Override |
| | | public ServletInputStream getInputStream() throws IOException { |
| | | final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes()); |
| | | return new ServletInputStream() { |
| | | @Override |
| | | public boolean isFinished() { |
| | | // 返回是否已经完成读取 |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isReady() { |
| | | // 返回是否准备好读取数据 |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public void setReadListener(ReadListener readListener) { |
| | | // 设置读监听器,这里不需要实现 |
| | | } |
| | | |
| | | @Override |
| | | public int read() throws IOException { |
| | | // 从字节数组输入流中读取下一个字节 |
| | | return byteArrayInputStream.read(); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * 重写 getReader 方法,返回一个新的 BufferedReader, |
| | | * 其中包含修改后的请求体内容。 |
| | | * |
| | | * @return 包含修改后请求体内容的 BufferedReader |
| | | * @throws IOException 如果读取输入流时发生错误 |
| | | */ |
| | | @Override |
| | | public BufferedReader getReader() throws IOException { |
| | | return new BufferedReader(new InputStreamReader(this.getInputStream())); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.filter; |
| | | |
| | | import com.alibaba.fastjson2.filter.SimplePropertyPreFilter; |
| | | |
| | | /** |
| | | * 排除JSON敏感属性 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class PropertyPreExcludeFilter extends SimplePropertyPreFilter |
| | | { |
| | | public PropertyPreExcludeFilter() |
| | | { |
| | | } |
| | | |
| | | public PropertyPreExcludeFilter addExcludes(String... filters) |
| | | { |
| | | for (int i = 0; i < filters.length; i++) |
| | | { |
| | | this.getExcludes().add(filters[i]); |
| | | } |
| | | return this; |
| | | } |
| | | } |
New file |
| | |
| | | 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.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE)) |
| | | { |
| | | requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response); |
| | | } |
| | | if (null == requestWrapper) |
| | | { |
| | | chain.doFilter(request, response); |
| | | } |
| | | else |
| | | { |
| | | chain.doFilter(requestWrapper, response); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void destroy() |
| | | { |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | 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; |
| | | import com.ruoyi.common.constant.Constants; |
| | | |
| | | /** |
| | | * 构建可重复读取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(Constants.UTF8); |
| | | response.setCharacterEncoding(Constants.UTF8); |
| | | |
| | | body = HttpHelper.getBodyString(request).getBytes(Constants.UTF8); |
| | | } |
| | | |
| | | @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 int available() throws IOException |
| | | { |
| | | return body.length; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isFinished() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isReady() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public void setReadListener(ReadListener readListener) |
| | | { |
| | | |
| | | } |
| | | }; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.filter; |
| | | |
| | | import org.springframework.boot.web.servlet.FilterRegistrationBean; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration |
| | | public class RequestFilterConfig { |
| | | |
| | | @Bean |
| | | public FilterRegistrationBean<SmCryptoFilter> loggingFilter(){ |
| | | FilterRegistrationBean<SmCryptoFilter> registrationBean = new FilterRegistrationBean<>(); |
| | | |
| | | registrationBean.setFilter(new SmCryptoFilter()); |
| | | registrationBean.addUrlPatterns("/api/*"); // 根据实际需求调整URL模式 |
| | | // registrationBean.addInitParameter("excludedUrls","/api/*"); |
| | | |
| | | return registrationBean; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.filter; |
| | | |
| | | import com.ruoyi.common.utils.Sm4Utils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import org.springframework.web.util.ContentCachingResponseWrapper; |
| | | |
| | | import javax.servlet.*; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.rmi.ServerException; |
| | | |
| | | public class SmCryptoFilter implements Filter { |
| | | |
| | | private static final Logger logger = LoggerFactory.getLogger(SmCryptoFilter.class); |
| | | |
| | | @Override |
| | | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { |
| | | HttpServletRequest httpRequest = (HttpServletRequest) request; |
| | | HttpServletResponse httpResponse = (HttpServletResponse) response; |
| | | |
| | | try { |
| | | // 对请求进行解密 |
| | | String decryptedRequestBody = decryptRequest(httpRequest); |
| | | // 处理解密后的请求体 CustomRequestWrapper为自定义请求包装器,请看下面实现 |
| | | CustomRequestWrapper customRequestWrapper = new CustomRequestWrapper(httpRequest, decryptedRequestBody); |
| | | |
| | | // 继续处理请求 |
| | | ContentCachingResponseWrapper responseWrapper = new ContentCachingResponseWrapper(httpResponse); |
| | | chain.doFilter(customRequestWrapper, responseWrapper); |
| | | |
| | | // 获取并加密响应内容 |
| | | byte[] content = responseWrapper.getContentAsByteArray(); |
| | | String originalResponseBody = new String(content); |
| | | String encryptedResponseBody = encryptResponse(originalResponseBody); |
| | | |
| | | // 写回客户端 |
| | | responseWrapper.reset(); |
| | | responseWrapper.getWriter().write(encryptedResponseBody); |
| | | responseWrapper.copyBodyToResponse(); |
| | | |
| | | } catch (Exception e) { |
| | | logger.error("内部响应错误:{}", e.getMessage()); |
| | | e.printStackTrace(); |
| | | // 返回标准错误响应 |
| | | httpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); |
| | | httpResponse.getWriter().write("Internal Server Error"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 解密 HTTP 请求的主体内容。 |
| | | * |
| | | * @param request HTTP 请求对象 |
| | | * @return 解密后的请求体字符串 |
| | | * @throws IOException 如果读取或解密过程中发生错误 |
| | | */ |
| | | private String decryptRequest(HttpServletRequest request) throws IOException { |
| | | StringBuilder jb = new StringBuilder(); |
| | | String line; |
| | | BufferedReader reader = request.getReader(); |
| | | while ((line = reader.readLine()) != null) { |
| | | jb.append(line); |
| | | } |
| | | try { |
| | | return Sm4Utils.sm4DecryptUtil(jb.toString()); |
| | | } catch (Exception e) { |
| | | throw new ServerException("参数解密失败:{}", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 加密 HTTP 响应的主体内容。 |
| | | * |
| | | * @param response 原始响应体字符串 |
| | | * @return 加密后的响应体字符串 |
| | | */ |
| | | private String encryptResponse(String response) throws ServerException { |
| | | try { |
| | | return Sm4Utils.sm4EncryptUtil(response); |
| | | } catch (Exception e) { |
| | | throw new ServerException("参数解密失败:{}", e); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.filter; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | 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 javax.servlet.http.HttpServletResponse; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.enums.HttpMethod; |
| | | |
| | | /** |
| | | * 防止XSS攻击的过滤器 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class XssFilter implements Filter |
| | | { |
| | | /** |
| | | * 排除链接 |
| | | */ |
| | | public List<String> excludes = new ArrayList<>(); |
| | | |
| | | @Override |
| | | public void init(FilterConfig filterConfig) throws ServletException |
| | | { |
| | | String tempExcludes = filterConfig.getInitParameter("excludes"); |
| | | if (StringUtils.isNotEmpty(tempExcludes)) |
| | | { |
| | | String[] url = tempExcludes.split(","); |
| | | for (int i = 0; url != null && i < url.length; i++) |
| | | { |
| | | excludes.add(url[i]); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) |
| | | throws IOException, ServletException |
| | | { |
| | | HttpServletRequest req = (HttpServletRequest) request; |
| | | HttpServletResponse resp = (HttpServletResponse) response; |
| | | if (handleExcludeURL(req, resp)) |
| | | { |
| | | chain.doFilter(request, response); |
| | | return; |
| | | } |
| | | XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper((HttpServletRequest) request); |
| | | chain.doFilter(xssRequest, response); |
| | | } |
| | | |
| | | private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) |
| | | { |
| | | String url = request.getServletPath(); |
| | | String method = request.getMethod(); |
| | | // GET DELETE 不过滤 |
| | | if (method == null || HttpMethod.GET.matches(method) || HttpMethod.DELETE.matches(method)) |
| | | { |
| | | return true; |
| | | } |
| | | return StringUtils.matches(url, excludes); |
| | | } |
| | | |
| | | @Override |
| | | public void destroy() |
| | | { |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.filter; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | | import javax.servlet.ReadListener; |
| | | import javax.servlet.ServletInputStream; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletRequestWrapper; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.html.EscapeUtil; |
| | | |
| | | /** |
| | | * XSS过滤处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper |
| | | { |
| | | /** |
| | | * @param request |
| | | */ |
| | | public XssHttpServletRequestWrapper(HttpServletRequest request) |
| | | { |
| | | super(request); |
| | | } |
| | | |
| | | @Override |
| | | public String[] getParameterValues(String name) |
| | | { |
| | | String[] values = super.getParameterValues(name); |
| | | if (values != null) |
| | | { |
| | | int length = values.length; |
| | | String[] escapesValues = new String[length]; |
| | | for (int i = 0; i < length; i++) |
| | | { |
| | | // 防xss攻击和过滤前后空格 |
| | | escapesValues[i] = EscapeUtil.clean(values[i]).trim(); |
| | | } |
| | | return escapesValues; |
| | | } |
| | | return super.getParameterValues(name); |
| | | } |
| | | |
| | | @Override |
| | | public ServletInputStream getInputStream() throws IOException |
| | | { |
| | | // 非json类型,直接返回 |
| | | if (!isJsonRequest()) |
| | | { |
| | | return super.getInputStream(); |
| | | } |
| | | |
| | | // 为空,直接返回 |
| | | String json = IOUtils.toString(super.getInputStream(), "utf-8"); |
| | | if (StringUtils.isEmpty(json)) |
| | | { |
| | | return super.getInputStream(); |
| | | } |
| | | |
| | | // xss过滤 |
| | | json = EscapeUtil.clean(json).trim(); |
| | | byte[] jsonBytes = json.getBytes("utf-8"); |
| | | final ByteArrayInputStream bis = new ByteArrayInputStream(jsonBytes); |
| | | return new ServletInputStream() |
| | | { |
| | | @Override |
| | | public boolean isFinished() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isReady() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public int available() throws IOException |
| | | { |
| | | return jsonBytes.length; |
| | | } |
| | | |
| | | @Override |
| | | public void setReadListener(ReadListener readListener) |
| | | { |
| | | } |
| | | |
| | | @Override |
| | | public int read() throws IOException |
| | | { |
| | | return bis.read(); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * 是否是Json请求 |
| | | * |
| | | * @param request |
| | | */ |
| | | public boolean isJsonRequest() |
| | | { |
| | | String header = super.getHeader(HttpHeaders.CONTENT_TYPE); |
| | | return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.redis.configure; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONReader; |
| | | import com.alibaba.fastjson2.JSONWriter; |
| | | import org.springframework.data.redis.serializer.RedisSerializer; |
| | | import org.springframework.data.redis.serializer.SerializationException; |
| | | |
| | | import java.nio.charset.Charset; |
| | | |
| | | /** |
| | | * Redis使用FastJson序列化 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T> |
| | | { |
| | | public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); |
| | | |
| | | private Class<T> clazz; |
| | | |
| | | |
| | | public FastJson2JsonRedisSerializer(Class<T> clazz) |
| | | { |
| | | super(); |
| | | this.clazz = clazz; |
| | | } |
| | | |
| | | @Override |
| | | public byte[] serialize(T t) throws SerializationException |
| | | { |
| | | if (t == null) |
| | | { |
| | | return new byte[0]; |
| | | } |
| | | return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName).getBytes(DEFAULT_CHARSET); |
| | | } |
| | | |
| | | @Override |
| | | public T deserialize(byte[] bytes) throws SerializationException |
| | | { |
| | | if (bytes == null || bytes.length <= 0) |
| | | { |
| | | return null; |
| | | } |
| | | String str = new String(bytes, DEFAULT_CHARSET); |
| | | |
| | | return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.redis.service; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.BoundSetOperations; |
| | | 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; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * spring redis 工具类 |
| | | * |
| | | * @author ruoyi |
| | | **/ |
| | | @SuppressWarnings(value = { "unchecked", "rawtypes" }) |
| | | @Component |
| | | public class RedisService |
| | | { |
| | | @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 Long 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 Redis键 |
| | | * @return 有效时间 |
| | | */ |
| | | public long getExpire(final String key) |
| | | { |
| | | return redisTemplate.getExpire(key); |
| | | } |
| | | |
| | | /** |
| | | * 判断 key是否存在 |
| | | * |
| | | * @param key 键 |
| | | * @return true 存在 false不存在 |
| | | */ |
| | | public Boolean hasKey(String key) |
| | | { |
| | | return redisTemplate.hasKey(key); |
| | | } |
| | | |
| | | /** |
| | | * 获得缓存的基本对象。 |
| | | * |
| | | * @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 boolean deleteObject(final Collection collection) |
| | | { |
| | | return redisTemplate.delete(collection) > 0; |
| | | } |
| | | |
| | | /** |
| | | * 缓存List数据 |
| | | * |
| | | * @param key 缓存的键值 |
| | | * @param dataList 待缓存的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> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) |
| | | { |
| | | BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key); |
| | | Iterator<T> it = dataSet.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | setOperation.add(it.next()); |
| | | } |
| | | return setOperation; |
| | | } |
| | | |
| | | /** |
| | | * 获得缓存的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); |
| | | } |
| | | } |
| | | |
| | | public <T> void setCacheMap(final String key, final Map<String, T> dataMap, long timeout) |
| | | { |
| | | if (dataMap != null) { |
| | | redisTemplate.opsForHash().putAll(key, dataMap); |
| | | redisTemplate.expire(key, timeout, TimeUnit.SECONDS); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获得缓存的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); |
| | | } |
| | | |
| | | /** |
| | | * 删除Hash中的某条数据 |
| | | * |
| | | * @param key Redis键 |
| | | * @param hKey Hash键 |
| | | * @return 是否成功 |
| | | */ |
| | | public boolean deleteCacheMapValue(final String key, final String hKey) |
| | | { |
| | | return redisTemplate.opsForHash().delete(key, hKey) > 0; |
| | | } |
| | | |
| | | /** |
| | | * 获得缓存的基本对象列表 |
| | | * |
| | | * @param pattern 字符串前缀 |
| | | * @return 对象列表 |
| | | */ |
| | | public Collection<String> keys(final String pattern) |
| | | { |
| | | return redisTemplate.keys(pattern); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.resp; |
| | | |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * AccessToken 全局唯一 |
| | | * |
| | | * @author liheng |
| | | */ |
| | | @Data |
| | | public class AccessTokenRespBody implements Serializable { |
| | | |
| | | /** |
| | | * 获取到的凭证 |
| | | */ |
| | | @JsonProperty("access_token") |
| | | private String accessToken; |
| | | /** |
| | | * 凭证有效时间,单位:秒 |
| | | */ |
| | | @JsonProperty("expires_in") |
| | | private int expiresIn; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | |
| | | /** |
| | | * 精确的浮点数运算 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class Arith |
| | | { |
| | | |
| | | /** 默认除法运算精度 */ |
| | | private static final int DEF_DIV_SCALE = 10; |
| | | |
| | | /** 这个类不能实例化 */ |
| | | private Arith() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * 提供精确的加法运算。 |
| | | * @param v1 被加数 |
| | | * @param v2 加数 |
| | | * @return 两个参数的和 |
| | | */ |
| | | public static double add(double v1, double v2) |
| | | { |
| | | BigDecimal b1 = new BigDecimal(Double.toString(v1)); |
| | | BigDecimal b2 = new BigDecimal(Double.toString(v2)); |
| | | return b1.add(b2).doubleValue(); |
| | | } |
| | | |
| | | /** |
| | | * 提供精确的减法运算。 |
| | | * @param v1 被减数 |
| | | * @param v2 减数 |
| | | * @return 两个参数的差 |
| | | */ |
| | | public static double sub(double v1, double v2) |
| | | { |
| | | BigDecimal b1 = new BigDecimal(Double.toString(v1)); |
| | | BigDecimal b2 = new BigDecimal(Double.toString(v2)); |
| | | return b1.subtract(b2).doubleValue(); |
| | | } |
| | | |
| | | /** |
| | | * 提供精确的乘法运算。 |
| | | * @param v1 被乘数 |
| | | * @param v2 乘数 |
| | | * @return 两个参数的积 |
| | | */ |
| | | public static double mul(double v1, double v2) |
| | | { |
| | | BigDecimal b1 = new BigDecimal(Double.toString(v1)); |
| | | BigDecimal b2 = new BigDecimal(Double.toString(v2)); |
| | | return b1.multiply(b2).doubleValue(); |
| | | } |
| | | |
| | | /** |
| | | * 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 |
| | | * 小数点以后10位,以后的数字四舍五入。 |
| | | * @param v1 被除数 |
| | | * @param v2 除数 |
| | | * @return 两个参数的商 |
| | | */ |
| | | public static double div(double v1, double v2) |
| | | { |
| | | return div(v1, v2, DEF_DIV_SCALE); |
| | | } |
| | | |
| | | /** |
| | | * 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 |
| | | * 定精度,以后的数字四舍五入。 |
| | | * @param v1 被除数 |
| | | * @param v2 除数 |
| | | * @param scale 表示表示需要精确到小数点以后几位。 |
| | | * @return 两个参数的商 |
| | | */ |
| | | public static double div(double v1, double v2, int scale) |
| | | { |
| | | if (scale < 0) |
| | | { |
| | | throw new IllegalArgumentException( |
| | | "The scale must be a positive integer or zero"); |
| | | } |
| | | BigDecimal b1 = new BigDecimal(Double.toString(v1)); |
| | | BigDecimal b2 = new BigDecimal(Double.toString(v2)); |
| | | if (b1.compareTo(BigDecimal.ZERO) == 0) |
| | | { |
| | | return BigDecimal.ZERO.doubleValue(); |
| | | } |
| | | return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue(); |
| | | } |
| | | |
| | | /** |
| | | * 提供精确的小数位四舍五入处理。 |
| | | * @param v 需要四舍五入的数字 |
| | | * @param scale 小数点后保留几位 |
| | | * @return 四舍五入后的结果 |
| | | */ |
| | | public static double round(double v, int scale) |
| | | { |
| | | if (scale < 0) |
| | | { |
| | | throw new IllegalArgumentException( |
| | | "The scale must be a positive integer or zero"); |
| | | } |
| | | BigDecimal b = new BigDecimal(Double.toString(v)); |
| | | BigDecimal one = BigDecimal.ONE; |
| | | return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | /** |
| | | * @Description |
| | | * @Author xiaochen |
| | | * @Date 2021/7/28 10:26 |
| | | */ |
| | | public class CodeGenerateUtils { |
| | | |
| | | /** |
| | | * @return |
| | | * @Description 获取商品编码 |
| | | * 商品编码规则:nanoTime(后5位)*5位随机数(10000~99999) |
| | | * @Author xiaochen |
| | | */ |
| | | public static String generateProductCode() { |
| | | long nanoPart = System.nanoTime() % 100000L; |
| | | if (nanoPart < 10000L) { |
| | | nanoPart += 10000L; |
| | | } |
| | | long randomPart = (long) (Math.random() * (90000) + 10000); |
| | | String code = "0" + new BigDecimal(nanoPart).multiply(new BigDecimal(randomPart)); |
| | | return code.substring(code.length() - 10); |
| | | } |
| | | |
| | | /** |
| | | * @return |
| | | * @Description 生成订单编号 10位 |
| | | * 订单编号规则:(10位):(年末尾*月,取后2位)+(用户ID%3.33*日取整后2位)+(timestamp*10000以内随机数,取后6位) |
| | | * @Author xiaochen |
| | | */ |
| | | public static String generateOrderSn() { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | int year = calendar.get(Calendar.YEAR); |
| | | year = year % 10; |
| | | if (year == 0) year = 10; |
| | | int month = calendar.get(Calendar.MONTH) + 1; |
| | | int yearMonth = year * month; |
| | | String yearMonthPart = "0" + yearMonth; |
| | | yearMonthPart = yearMonthPart.substring(yearMonthPart.length() - 2); |
| | | |
| | | int day = calendar.get(Calendar.DAY_OF_MONTH); |
| | | double v = Math.random() * 10000; |
| | | int dayNum = (int) ((v % 3.33) * day); |
| | | String dayPart = "0" + dayNum; |
| | | dayPart = dayPart.substring(dayPart.length() - 2); |
| | | |
| | | String timestampPart = "" + (Math.random() * 10000) * (System.currentTimeMillis() / 10000); |
| | | timestampPart = timestampPart.replace(".", "").replace("E", ""); |
| | | timestampPart = timestampPart.substring(0, 6); |
| | | return yearMonthPart + dayPart + timestampPart; |
| | | } |
| | | |
| | | /** |
| | | * @return |
| | | * @Description 生成统一支付单号 规则:年(2)月(2)日(2)时(2)分(2)+timestamp*5位随机整数取后5位 |
| | | * @Author xiaochen |
| | | */ |
| | | public static String generateVolumeSn() { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmmss"); |
| | | String dateTime = dateFormat.format(calendar.getTime()); |
| | | dateTime = dateTime.substring(2); |
| | | String timestampPart = "" + (Math.random() * 10000) * (System.currentTimeMillis() / 10000); |
| | | timestampPart = timestampPart.replace(".", "").replace("E", ""); |
| | | timestampPart = timestampPart.substring(0, 0); |
| | | return dateTime + timestampPart; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | | |
| | | import java.lang.management.ManagementFactory; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Instant; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.ZoneId; |
| | | import java.time.ZonedDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 时间工具类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class DateUtils extends org.apache.commons.lang3.time.DateUtils |
| | | { |
| | | public static String YYYY = "yyyy"; |
| | | |
| | | public static String YYYY_MM = "yyyy-MM"; |
| | | |
| | | public static String YYYY_MM_DD = "yyyy-MM-dd"; |
| | | |
| | | public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss"; |
| | | |
| | | public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; |
| | | |
| | | private static String[] parsePatterns = { |
| | | "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", |
| | | "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", |
| | | "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"}; |
| | | |
| | | /** |
| | | * 获取当前Date型日期 |
| | | * |
| | | * @return Date() 当前日期 |
| | | */ |
| | | public static Date getNowDate() |
| | | { |
| | | return new Date(); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前日期, 默认格式为yyyy-MM-dd |
| | | * |
| | | * @return String |
| | | */ |
| | | public static String getDate() |
| | | { |
| | | return dateTimeNow(YYYY_MM_DD); |
| | | } |
| | | |
| | | public static final String getTime() |
| | | { |
| | | return dateTimeNow(YYYY_MM_DD_HH_MM_SS); |
| | | } |
| | | |
| | | public static final String dateTimeNow() |
| | | { |
| | | return dateTimeNow(YYYYMMDDHHMMSS); |
| | | } |
| | | |
| | | public static final String dateTimeNow(final String format) |
| | | { |
| | | return parseDateToStr(format, new Date()); |
| | | } |
| | | |
| | | public static final String dateTime(final Date date) |
| | | { |
| | | return parseDateToStr(YYYY_MM_DD, date); |
| | | } |
| | | |
| | | public static final String parseDateToStr(final String format, final Date date) |
| | | { |
| | | return new SimpleDateFormat(format).format(date); |
| | | } |
| | | |
| | | public static final Date dateTime(final String format, final String ts) |
| | | { |
| | | try |
| | | { |
| | | return new SimpleDateFormat(format).parse(ts); |
| | | } |
| | | catch (ParseException e) |
| | | { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 日期路径 即年/月/日 如2018/08/08 |
| | | */ |
| | | public static final String datePath() |
| | | { |
| | | Date now = new Date(); |
| | | return DateFormatUtils.format(now, "yyyy/MM/dd"); |
| | | } |
| | | |
| | | /** |
| | | * 日期路径 即年/月/日 如20180808 |
| | | */ |
| | | public static final String dateTime() |
| | | { |
| | | Date now = new Date(); |
| | | return DateFormatUtils.format(now, "yyyyMMdd"); |
| | | } |
| | | |
| | | /** |
| | | * 日期型字符串转化为日期 格式 |
| | | */ |
| | | public static Date parseDate(Object str) |
| | | { |
| | | if (str == null) |
| | | { |
| | | return null; |
| | | } |
| | | try |
| | | { |
| | | return parseDate(str.toString(), parsePatterns); |
| | | } |
| | | catch (ParseException e) |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取服务器启动时间 |
| | | */ |
| | | public static Date getServerStartDate() |
| | | { |
| | | long time = ManagementFactory.getRuntimeMXBean().getStartTime(); |
| | | return new Date(time); |
| | | } |
| | | |
| | | /** |
| | | * 计算相差天数 |
| | | */ |
| | | public static int differentDaysByMillisecond(Date date1, Date date2) |
| | | { |
| | | return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24))); |
| | | } |
| | | |
| | | /** |
| | | * 计算时间差 |
| | | * |
| | | * @param endDate 最后时间 |
| | | * @param startTime 开始时间 |
| | | * @return 时间差(天/小时/分钟) |
| | | */ |
| | | public static String timeDistance(Date endDate, Date startTime) |
| | | { |
| | | long nd = 1000 * 24 * 60 * 60; |
| | | long nh = 1000 * 60 * 60; |
| | | long nm = 1000 * 60; |
| | | // long ns = 1000; |
| | | // 获得两个时间的毫秒时间差异 |
| | | long diff = endDate.getTime() - startTime.getTime(); |
| | | // 计算差多少天 |
| | | long day = diff / nd; |
| | | // 计算差多少小时 |
| | | long hour = diff % nd / nh; |
| | | // 计算差多少分钟 |
| | | long min = diff % nd % nh / nm; |
| | | // 计算差多少秒//输出结果 |
| | | // long sec = diff % nd % nh % nm / ns; |
| | | return day + "天" + hour + "小时" + min + "分钟"; |
| | | } |
| | | |
| | | /** |
| | | * 增加 LocalDateTime ==> Date |
| | | */ |
| | | public static Date toDate(LocalDateTime temporalAccessor) |
| | | { |
| | | ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault()); |
| | | return Date.from(zdt.toInstant()); |
| | | } |
| | | |
| | | /** |
| | | * 增加 LocalDate ==> Date |
| | | */ |
| | | public static Date toDate(LocalDate temporalAccessor) |
| | | { |
| | | LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0)); |
| | | ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault()); |
| | | return Date.from(zdt.toInstant()); |
| | | } |
| | | |
| | | /** |
| | | * 指定日期所在周的周一和周日时间 |
| | | * |
| | | * @return 结果集 |
| | | */ |
| | | public static Map<String, Date> getWeekDate(Date date) { |
| | | Map<String, Date> map = new HashMap<>(2); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(date); |
| | | // 设置一个星期的第一天,按中国的习惯一个星期的第一天是星期一 |
| | | cal.setFirstDayOfWeek(Calendar.MONDAY); |
| | | // 获得当前日期是一个星期的第几天 |
| | | int dayWeek = cal.get(Calendar.DAY_OF_WEEK); |
| | | if (dayWeek == 1) { |
| | | dayWeek = 8; |
| | | } |
| | | // 根据日历的规则,给当前日期减去星期几与一个星期第一天的差值 |
| | | cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - dayWeek); |
| | | Date mondayDate = cal.getTime(); |
| | | cal.add(Calendar.DATE, 4 + cal.getFirstDayOfWeek()); |
| | | Date sundayDate = cal.getTime(); |
| | | map.put("first", mondayDate); |
| | | map.put("last", sundayDate); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 指定日期所在月的第一天/最后一天时间 |
| | | * |
| | | * @return 结果集 |
| | | */ |
| | | public static Map<String, Date> getMonthDate(Date date) { |
| | | Map<String, Date> map = new HashMap<>(2); |
| | | Calendar cal = Calendar.getInstance(); |
| | | //设置指定日期 |
| | | cal.setTime(date); |
| | | //获取当月第一天日期 |
| | | int first = cal.getActualMinimum(Calendar.DAY_OF_MONTH); |
| | | cal.set(Calendar.DAY_OF_MONTH, first); |
| | | Date firstDay = cal.getTime(); |
| | | map.put("first", firstDay); |
| | | //获取当月最后一天日期 |
| | | int last = cal.getActualMaximum(Calendar.DAY_OF_MONTH); |
| | | cal.set(Calendar.DAY_OF_MONTH, last); |
| | | Date lastDay = cal.getTime(); |
| | | map.put("last", lastDay); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 获取日期逻辑中所在的季度数 |
| | | * |
| | | * @param date 当前日期 |
| | | * @return 第几季度 |
| | | */ |
| | | public static int getQuarterOfYear(Date date) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | return calendar.get(Calendar.MONTH) / 3 + 1; |
| | | } |
| | | /** |
| | | * 指定日期所在季度的第一天/最后一天时间 |
| | | * |
| | | * @return 结果集 |
| | | */ |
| | | public static Map<String, Date> getQuarterDate(Date date) { |
| | | Map<String, Date> map = new HashMap<>(2); |
| | | |
| | | int quarter = getQuarterOfYear(date); |
| | | int year = dateToLocalDateTime(date).getYear(); |
| | | |
| | | int startMonth = (quarter - 1) * 3; |
| | | // 根据月获取开始时间 |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.set(Calendar.YEAR, year); |
| | | cal.set(Calendar.MONTH, startMonth); |
| | | cal.set(Calendar.DAY_OF_MONTH, 1); |
| | | cal.set(Calendar.HOUR_OF_DAY, 0); |
| | | cal.set(Calendar.MINUTE, 0); |
| | | cal.set(Calendar.SECOND, 0); |
| | | Date first = cal.getTime(); |
| | | map.put("first", first); |
| | | |
| | | int lastMonth = quarter * 3 - 1; |
| | | // 根据月获取结束时间 |
| | | cal = Calendar.getInstance(); |
| | | cal.set(Calendar.YEAR, year); |
| | | cal.set(Calendar.MONTH, lastMonth); |
| | | cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); |
| | | cal.set(Calendar.HOUR_OF_DAY, 23); |
| | | cal.set(Calendar.MINUTE, 59); |
| | | cal.set(Calendar.SECOND, 59); |
| | | Date last = cal.getTime(); |
| | | map.put("last", last); |
| | | |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 指定日期所在年的第一天/最后一天时间 |
| | | * |
| | | * @return 结果集 |
| | | */ |
| | | public static Map<String, Date> getYearDate(Date date) { |
| | | Map<String, Date> map = new HashMap<>(2); |
| | | Calendar cal = Calendar.getInstance(); |
| | | //设置指定日期 |
| | | cal.setTime(date); |
| | | //获取本年第一天日期 |
| | | int first = cal.getActualMinimum(Calendar.DAY_OF_YEAR); |
| | | cal.set(Calendar.DAY_OF_YEAR, first); |
| | | Date firstDay = cal.getTime(); |
| | | map.put("first", firstDay); |
| | | //获取本年最后一天日期 |
| | | int last = cal.getActualMaximum(Calendar.DAY_OF_YEAR); |
| | | cal.set(Calendar.DAY_OF_YEAR, last); |
| | | Date lastDay = cal.getTime(); |
| | | map.put("last", lastDay); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 获取当天的00:00:00 |
| | | * |
| | | * @return |
| | | */ |
| | | public static LocalDateTime getDayStart(LocalDateTime time) { |
| | | return time.with(LocalTime.MIN); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取当天的23:59:59 |
| | | * |
| | | * @return |
| | | */ |
| | | public static LocalDateTime getDayEnd(LocalDateTime time) { |
| | | return time.with(LocalTime.MAX); |
| | | } |
| | | |
| | | /** |
| | | * localdatetime转为字符串 |
| | | * |
| | | * @param time localdatetime |
| | | * @return 字符串 |
| | | */ |
| | | public static String localDateTimeToString(LocalDateTime time) { |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | return df.format(time); |
| | | } |
| | | /** |
| | | * localdatetime转为字符串 |
| | | * |
| | | * @param time localdatetime |
| | | * @return 字符串 |
| | | */ |
| | | public static String localDateTimeToStringYear(LocalDateTime time) { |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); |
| | | return df.format(time); |
| | | } |
| | | |
| | | /** |
| | | * Date转为LocalDateTime |
| | | * |
| | | * @param date 日期 |
| | | * @return LocalDateTime |
| | | */ |
| | | public static LocalDateTime dateToLocalDateTime(Date date) { |
| | | Instant instant = date.toInstant(); |
| | | ZoneId zoneId = ZoneId.systemDefault(); |
| | | return instant.atZone(zoneId).toLocalDateTime(); |
| | | } |
| | | |
| | | /** |
| | | * localdate转为字符串 |
| | | * |
| | | * @param time localdate |
| | | * @return 字符串 |
| | | */ |
| | | public static String localDateToString(LocalDate time) { |
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | return df.format(time); |
| | | } |
| | | |
| | | /** |
| | | * 字符串转为localdate |
| | | * |
| | | * @param time localdate |
| | | * @return 字符串 |
| | | */ |
| | | public static LocalDate stringToLocalDate(String time) { |
| | | return LocalDate.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.ruoyi.common.constant.CacheConstants; |
| | | 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 |
| | | { |
| | | /** |
| | | * 分隔符 |
| | | */ |
| | | public static final String SEPARATOR = ","; |
| | | |
| | | /** |
| | | * 设置字典缓存 |
| | | * |
| | | * @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) |
| | | { |
| | | JSONArray arrayCache = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key)); |
| | | if (StringUtils.isNotNull(arrayCache)) |
| | | { |
| | | return arrayCache.toList(SysDictData.class); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型和字典值获取字典标签 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @param dictValue 字典值 |
| | | * @return 字典标签 |
| | | */ |
| | | public static String getDictLabel(String dictType, String dictValue) |
| | | { |
| | | return getDictLabel(dictType, dictValue, SEPARATOR); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型和字典标签获取字典值 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @param dictLabel 字典标签 |
| | | * @return 字典值 |
| | | */ |
| | | public static String getDictValue(String dictType, String dictLabel) |
| | | { |
| | | return getDictValue(dictType, dictLabel, SEPARATOR); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型和字典值获取字典标签 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @param dictValue 字典值 |
| | | * @param separator 分隔符 |
| | | * @return 字典标签 |
| | | */ |
| | | public static String getDictLabel(String dictType, String dictValue, String separator) |
| | | { |
| | | StringBuilder propertyString = new StringBuilder(); |
| | | List<SysDictData> datas = getDictCache(dictType); |
| | | |
| | | if (StringUtils.isNotNull(datas)) |
| | | { |
| | | if (StringUtils.containsAny(separator, dictValue)) |
| | | { |
| | | for (SysDictData dict : datas) |
| | | { |
| | | for (String value : dictValue.split(separator)) |
| | | { |
| | | if (value.equals(dict.getDictValue())) |
| | | { |
| | | propertyString.append(dict.getDictLabel()).append(separator); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (SysDictData dict : datas) |
| | | { |
| | | if (dictValue.equals(dict.getDictValue())) |
| | | { |
| | | return dict.getDictLabel(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return StringUtils.stripEnd(propertyString.toString(), separator); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型和字典标签获取字典值 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @param dictLabel 字典标签 |
| | | * @param separator 分隔符 |
| | | * @return 字典值 |
| | | */ |
| | | public static String getDictValue(String dictType, String dictLabel, String separator) |
| | | { |
| | | StringBuilder propertyString = new StringBuilder(); |
| | | List<SysDictData> datas = getDictCache(dictType); |
| | | |
| | | if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas)) |
| | | { |
| | | for (SysDictData dict : datas) |
| | | { |
| | | for (String label : dictLabel.split(separator)) |
| | | { |
| | | if (label.equals(dict.getDictLabel())) |
| | | { |
| | | propertyString.append(dict.getDictValue()).append(separator); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (SysDictData dict : datas) |
| | | { |
| | | if (dictLabel.equals(dict.getDictLabel())) |
| | | { |
| | | return dict.getDictValue(); |
| | | } |
| | | } |
| | | } |
| | | return StringUtils.stripEnd(propertyString.toString(), separator); |
| | | } |
| | | |
| | | /** |
| | | * 删除指定字典缓存 |
| | | * |
| | | * @param key 字典键 |
| | | */ |
| | | public static void removeDictCache(String key) |
| | | { |
| | | SpringUtils.getBean(RedisCache.class).deleteObject(getCacheKey(key)); |
| | | } |
| | | |
| | | /** |
| | | * 清空字典缓存 |
| | | */ |
| | | public static void clearDictCache() |
| | | { |
| | | Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(CacheConstants.SYS_DICT_KEY + "*"); |
| | | SpringUtils.getBean(RedisCache.class).deleteObject(keys); |
| | | } |
| | | |
| | | /** |
| | | * 设置cache key |
| | | * |
| | | * @param configKey 参数键 |
| | | * @return 缓存键key |
| | | */ |
| | | public static String getCacheKey(String configKey) |
| | | { |
| | | return CacheConstants.SYS_DICT_KEY + configKey; |
| | | } |
| | | } |
New file |
| | |
| | | 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)); |
| | | return sw.toString(); |
| | | } |
| | | |
| | | public static String getRootErrorMessage(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); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | public class IDCardUtils { |
| | | |
| | | public static void main(String[] args) { |
| | | String idCardNumber = "110101199001011234"; |
| | | String birthday = getBirthdayFromIdCard(idCardNumber); |
| | | System.out.println("出生日期为:" + birthday); |
| | | } |
| | | |
| | | public static String getBirthdayFromIdCard(String idCardNumber) { |
| | | String birthday = idCardNumber.substring(6, 14); |
| | | String year = birthday.substring(0, 4); |
| | | String month = birthday.substring(4, 6); |
| | | String day = birthday.substring(6, 8); |
| | | return year + "-" + month + "-" + day; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | /** |
| | | * 处理并记录日志文件 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class LogUtils |
| | | { |
| | | public static String getBlock(Object msg) |
| | | { |
| | | if (msg == null) |
| | | { |
| | | msg = ""; |
| | | } |
| | | return "[" + msg.toString() + "]"; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import org.springframework.context.MessageSource; |
| | | import org.springframework.context.i18n.LocaleContextHolder; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | |
| | | /** |
| | | * 获取i18n资源文件 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class MessageUtils |
| | | { |
| | | /** |
| | | * 根据消息键和参数 获取消息 委托给spring messageSource |
| | | * |
| | | * @param code 消息键 |
| | | * @param args 参数 |
| | | * @return 获取国际化翻译值 |
| | | */ |
| | | public static String message(String code, Object... args) |
| | | { |
| | | MessageSource messageSource = SpringUtils.getBean(MessageSource.class); |
| | | return messageSource.getMessage(code, args, LocaleContextHolder.getLocale()); |
| | | } |
| | | } |
New file |
| | |
| | | //package com.ruoyi.common.utils; |
| | | // |
| | | //import cn.hutool.core.io.unit.DataSize; |
| | | //import cn.hutool.core.util.IdUtil; |
| | | //import cn.hutool.http.HttpRequest; |
| | | //import cn.hutool.http.HttpResponse; |
| | | //import com.google.common.collect.ImmutableList; |
| | | //import javafx.util.Duration; |
| | | //import org.apache.catalina.Manager; |
| | | //import org.apache.commons.io.FilenameUtils; |
| | | //import org.apache.commons.lang3.StringUtils; |
| | | //import org.apache.http.entity.ContentType; |
| | | //import org.springframework.mock.web.MockMultipartFile; |
| | | //import org.springframework.web.multipart.MultipartFile; |
| | | //import javafx.scene.media.Media; |
| | | //import javafx.scene.media.MediaPlayer; |
| | | //import ws.schild.jave.EncoderException; |
| | | //import ws.schild.jave.MultimediaInfo; |
| | | //import ws.schild.jave.MultimediaObject; |
| | | // |
| | | //import java.io.File; |
| | | // |
| | | //import java.io.*; |
| | | //import java.math.BigDecimal; |
| | | //import java.math.RoundingMode; |
| | | //import java.net.URL; |
| | | //import java.nio.channels.FileChannel; |
| | | //import java.util.ArrayList; |
| | | //import java.util.List; |
| | | // |
| | | ///** |
| | | // * MultipartFile和File互转工具类 |
| | | // */ |
| | | //public class MultipartFileUtil { |
| | | // |
| | | // /** |
| | | // * 输入流转MultipartFile |
| | | // * |
| | | // * @param fileName |
| | | // * @param inputStream |
| | | // * @return |
| | | // */ |
| | | // public static MultipartFile getMultipartFile(String fileName, InputStream inputStream) { |
| | | // MultipartFile multipartFile = null; |
| | | // try { |
| | | // multipartFile = new MockMultipartFile(fileName, fileName, |
| | | // ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // return multipartFile; |
| | | // } |
| | | // |
| | | // /** |
| | | // * 读取网络文件 |
| | | // * |
| | | // * @param url 文件地址 |
| | | // * @param fileName 文件名称(需带文件名后缀) |
| | | // * @return |
| | | // */ |
| | | // public static MultipartFile getMultipartFile(String url, String fileName) { |
| | | // HttpResponse response = HttpRequest.get(url).execute(); |
| | | // InputStream inputStream = response.bodyStream(); |
| | | // return MultipartFileUtil.getMultipartFile(fileName, inputStream); |
| | | // } |
| | | // |
| | | // /** |
| | | // * File 转MultipartFile |
| | | // * |
| | | // * @param file |
| | | // * @return |
| | | // */ |
| | | // public static MultipartFile getMultipartFile(File file) { |
| | | // FileInputStream fileInputStream = null; |
| | | // MultipartFile multipartFile = null; |
| | | // try { |
| | | // fileInputStream = new FileInputStream(file); |
| | | // multipartFile = new MockMultipartFile(file.getName(), file.getName(), |
| | | // ContentType.APPLICATION_OCTET_STREAM.toString(), fileInputStream); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // return multipartFile; |
| | | // } |
| | | // |
| | | // /** |
| | | // * MultipartFileUtil 转File |
| | | // * |
| | | // * @param multipartFile |
| | | // * @return |
| | | // */ |
| | | // public static File getFile(MultipartFile multipartFile) { |
| | | // // 获取文件名 |
| | | // String fileName = multipartFile.getOriginalFilename(); |
| | | // // 获取文件后缀 |
| | | // String prefix = "." + getExtensionName(fileName); |
| | | // File file = null; |
| | | // try { |
| | | // // 用uuid作为文件名,防止生成的临时文件重复 |
| | | // file = File.createTempFile(IdUtil.simpleUUID(), prefix); |
| | | // // MultipartFile to File |
| | | // multipartFile.transferTo(file); |
| | | // } catch (IOException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // return file; |
| | | // } |
| | | // |
| | | // /** |
| | | // * 获取文件扩展名,不带 . |
| | | // */ |
| | | // public static String getExtensionName(String filename) { |
| | | // if ((filename != null) && (filename.length() > 0)) { |
| | | // int dot = filename.lastIndexOf('.'); |
| | | // if ((dot > -1) && (dot < (filename.length() - 1))) { |
| | | // return filename.substring(dot + 1); |
| | | // } |
| | | // } |
| | | // return filename; |
| | | // } |
| | | // |
| | | // /** |
| | | // 前端上传视频之后,根据上传的视频文件获取视频的大小和时长 |
| | | // 1、获取视频时长 |
| | | // */ |
| | | // public static int readVideoTime(File source) { |
| | | // int vedioSecond = Integer.parseInt(parseDuration(source.getAbsolutePath())); |
| | | // return vedioSecond; |
| | | // } |
| | | // |
| | | // |
| | | // /** |
| | | // * 视频时长 |
| | | // * |
| | | // * @param fileUrl |
| | | // * @return String[] 0=秒时长,1=展示时长(格式如 01:00:00) |
| | | // */ |
| | | // public static String parseDuration(String fileUrl) { |
| | | // long ls = 0L; |
| | | // String[] length = new String[2]; |
| | | // try { |
| | | // // |
| | | //// URL source = new URL(fileUrl); |
| | | // // 构造方法 接受URL对象 |
| | | //// MultimediaObject instance = new MultimediaObject(source); |
| | | // // 构造方法 接受File对象 |
| | | // MultimediaObject instance = new MultimediaObject(new File(fileUrl)); |
| | | // MultimediaInfo result = instance.getInfo(); |
| | | // ls = result.getDuration() / 1000; |
| | | // length[0] = String.valueOf(ls); |
| | | // Integer hour = (int) (ls / 3600); |
| | | // Integer minute = (int) (ls % 3600) / 60; |
| | | // Integer second = (int) (ls - hour * 3600 - minute * 60); |
| | | // String hr = hour.toString(); |
| | | // String mi = minute.toString(); |
| | | // String se = second.toString(); |
| | | // if (hr.length() < 2) { |
| | | // hr = "0" + hr; |
| | | // } |
| | | // if (mi.length() < 2) { |
| | | // mi = "0" + mi; |
| | | // } |
| | | // if (se.length() < 2) { |
| | | // se = "0" + se; |
| | | // } |
| | | // |
| | | // String noHour = "00"; |
| | | // if (noHour.equals(hr)) { |
| | | // length[1] = mi + ":" + se; |
| | | // } else { |
| | | // length[1] = hr + ":" + mi + ":" + se; |
| | | // } |
| | | // |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // System.out.println(length);//{"20","00:20"} |
| | | // return String.valueOf(ls); |
| | | // } |
| | | // |
| | | // |
| | | // |
| | | // |
| | | // |
| | | // |
| | | // /** |
| | | // * 2、获取文件大小 |
| | | // * @param source |
| | | // * @return |
| | | // * //***获取视频大小的时候,由于用到了流,使用完之后一定要及时的关闭流,避免无法删除视频文件*** |
| | | // * |
| | | // */ |
| | | // public static BigDecimal readFileSize(File source) { |
| | | // //cn.hutool.core.io.unit.DataSize.ofMegabytes() |
| | | // FileChannel fc= null; |
| | | // //String size = ""; |
| | | // BigDecimal size = null ; |
| | | // try { |
| | | // @SuppressWarnings("resource") |
| | | // FileInputStream fis = new FileInputStream(source); |
| | | // fc= fis.getChannel(); |
| | | // BigDecimal fileSize = new BigDecimal(fc.size()); |
| | | // //size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB"; |
| | | // size = fileSize.divide(new BigDecimal(1024*1024), 2, RoundingMode.HALF_UP) ; |
| | | // } catch (FileNotFoundException e) { |
| | | // e.printStackTrace(); |
| | | // } catch (IOException e) { |
| | | // e.printStackTrace(); |
| | | // } finally { |
| | | // if (null!=fc){ |
| | | // try{ |
| | | // fc.close(); |
| | | // }catch(IOException e){ |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // } |
| | | // return size; |
| | | // } |
| | | // |
| | | // |
| | | //} |
New file |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import com.ruoyi.common.utils.ip.IpUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import java.util.concurrent.atomic.AtomicLong; |
| | | |
| | | public class OrderNos { |
| | | |
| | | public static final char PADCHAR = '0'; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 长度24位全球唯一标识 |
| | | */ |
| | | |
| | | /** |
| | | * 统一不重复内部订单号 |
| | | * |
| | | * @param systemCode |
| | | * 4字节系统编码 |
| | | * @return 24字节不重复编码 |
| | | */ |
| | | public static String oid(String systemCode) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(padding(systemCode, 4)); |
| | | sb.append(Did.getInstance().getId(20)); |
| | | return sb.toString(); |
| | | } |
| | | |
| | | public static String oid() { |
| | | return oid("O001"); |
| | | } |
| | | |
| | | /** |
| | | * 获取分布式Id |
| | | * |
| | | * @return 默认20字符长度的数字不重复编码 |
| | | */ |
| | | public static String getDid() { |
| | | return Did.getInstance().getId(); |
| | | } |
| | | |
| | | public static String getDid(int size) { |
| | | return Did.getInstance().getId(size); |
| | | } |
| | | |
| | | public static String getDid(String prefix) { |
| | | return prefix + Did.getInstance().getId(); |
| | | } |
| | | |
| | | private static String padding(String text, int size) { |
| | | String txt = StringUtils.trimToEmpty(text); |
| | | if (StringUtils.length(txt) > size) { |
| | | txt = StringUtils.substring(txt, StringUtils.length(txt) - size); |
| | | } |
| | | return StringUtils.leftPad(txt, size, PADCHAR); |
| | | } |
| | | |
| | | /** |
| | | * ID生成器 |
| | | * |
| | | * 20字符长度 yyMMddHHmmss+3位本机IP末三位+5位随机数字 |
| | | * |
| | | * @author zhangpu |
| | | * |
| | | */ |
| | | public static class Did { |
| | | private static final Logger logger = LoggerFactory.getLogger(OrderNos.class); |
| | | private static final int MIN_LENGTH = 19; |
| | | private static final int SEQU_MAX = 99999; |
| | | private static final int SEQU_19_MAX = 9999; |
| | | private volatile static long BASE = 0; |
| | | private AtomicLong sequence = new AtomicLong(0); |
| | | private String nodeFlag; |
| | | private Object nodeFlagLock = new Object(); |
| | | private static Did did = new Did(); |
| | | |
| | | |
| | | public static Did getInstance() { |
| | | return did; |
| | | } |
| | | |
| | | /** |
| | | * 生产新Id |
| | | * |
| | | * @return |
| | | */ |
| | | public String getId() { |
| | | return getId(20); |
| | | } |
| | | |
| | | public String getId(int size) { |
| | | if (size < MIN_LENGTH) { |
| | | throw new RuntimeException("did最小长度为" + MIN_LENGTH); |
| | | } |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(DateUtils.dateTimeNow("yyMMddHHmmss")); |
| | | sb.append(getNodeFlag()); |
| | | sb.append(getSequ(size-15)); |
| | | return sb.toString(); |
| | | } |
| | | |
| | | public synchronized String getSequ(int size) { |
| | | long timeCount = System.currentTimeMillis() / 1000; |
| | | |
| | | while (true) { |
| | | long now = sequence.get(); |
| | | if (timeCount > now) { |
| | | // 已经过了本秒,则设置新的值 |
| | | if (sequence.compareAndSet(now, timeCount)) { |
| | | break; |
| | | } |
| | | } else { |
| | | if (sequence.compareAndSet(now, now + 1)) { |
| | | timeCount = now + 1; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | int sn = (int) (timeCount % (size>=5?SEQU_MAX:SEQU_19_MAX)); |
| | | return StringUtils.leftPad(String.valueOf(sn), size, '0'); |
| | | } |
| | | |
| | | private String getNodeFlag(){ |
| | | if (this.nodeFlag == null) { |
| | | synchronized (Did.class){ |
| | | if (this.nodeFlag==null){ |
| | | this.nodeFlag = generateNodeFlag(); |
| | | } |
| | | } |
| | | } |
| | | return this.nodeFlag; |
| | | } |
| | | |
| | | /** |
| | | * 简单节点编码 |
| | | * |
| | | * 逻辑:Ip地址后三位,便于快速知道是哪个节点 |
| | | * |
| | | * @return |
| | | */ |
| | | private String generateNodeFlag() { |
| | | String ipPostfix = null; |
| | | try { |
| | | String ip = IpUtils.getFirstNoLoopbackIPV4Address(); |
| | | ipPostfix = StringUtils.substringAfterLast(ip, "."); |
| | | } catch (Exception e) { |
| | | logger.warn("生产DID要素本机IP获取失败:" + e.getMessage()); |
| | | } |
| | | return StringUtils.leftPad(ipPostfix, 3, "0"); |
| | | } |
| | | |
| | | private Did() { |
| | | super(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/Sm4Util.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/Sm4Utils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/SmsUtil.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/TimeConverter.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/VideoUtil.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/WebUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/WxAppletTools.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanValidators.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileTypeUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/ImageUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/html/EscapeUtil.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/IpUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelHandlerAdapter.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Base64.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Md5Utils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/IdUtils.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/Seq.java
ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/UUID.java
ruoyi-common/src/main/java/com/ruoyi/common/xss/Xss.java
ruoyi-common/src/main/java/com/ruoyi/common/xss/XssValidator.java
ruoyi-framework/pom.xml
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java
ruoyi-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java
ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java
ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java
ruoyi-framework/src/main/java/com/ruoyi/framework/config/FilterConfig.java
ruoyi-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java
ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java
ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ThreadPoolConfig.java
ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/DruidProperties.java
ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/PermitAllUrlProperties.java
ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java
ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSourceContextHolder.java
ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java
ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java
ruoyi-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java
ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java
ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java
ruoyi-framework/src/main/java/com/ruoyi/framework/security/context/AuthenticationContextHolder.java
ruoyi-framework/src/main/java/com/ruoyi/framework/security/context/PermissionContextHolder.java
ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java
ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java
ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java
ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java
ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java
ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Jvm.java
ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Mem.java
ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Sys.java
ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/SysFile.java
ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPasswordService.java
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPermissionService.java
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysRegisterService.java
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java
ruoyi-generator/pom.xml
ruoyi-generator/src/main/java/com/ruoyi/generator/config/GenConfig.java
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableColumnMapper.java
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java
ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableColumnServiceImpl.java
ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableColumnService.java
ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java
ruoyi-generator/src/main/java/com/ruoyi/generator/util/GenUtils.java
ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java
ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
ruoyi-generator/src/main/resources/generator.yml
ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml
ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml
ruoyi-generator/src/main/resources/vm/java/controller.java.vm
ruoyi-generator/src/main/resources/vm/java/domain.java.vm
ruoyi-generator/src/main/resources/vm/java/mapper.java.vm
ruoyi-generator/src/main/resources/vm/java/service.java.vm
ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm
ruoyi-generator/src/main/resources/vm/java/sub-domain.java.vm
ruoyi-generator/src/main/resources/vm/js/api.js.vm
ruoyi-generator/src/main/resources/vm/sql/sql.vm
ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm
ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
ruoyi-generator/src/main/resources/vm/vue/v3/index-tree.vue.vm
ruoyi-generator/src/main/resources/vm/vue/v3/index.vue.vm
ruoyi-generator/src/main/resources/vm/vue/v3/readme.txt
ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm
ruoyi-quartz/pom.xml
ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java
ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java
ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml
ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml
ruoyi-system/pom.xml
ruoyi-system/src/main/java/com/ruoyi/system/bo/DeployBO.java
ruoyi-system/src/main/java/com/ruoyi/system/bo/ProcessAgreeBO.java
ruoyi-system/src/main/java/com/ruoyi/system/bo/ProcessCreateBO.java
ruoyi-system/src/main/java/com/ruoyi/system/bo/ProcessModuleUpdateBO.java
ruoyi-system/src/main/java/com/ruoyi/system/bo/ProcessRefuseBO.java
ruoyi-system/src/main/java/com/ruoyi/system/bo/ProcessStartBO.java
ruoyi-system/src/main/java/com/ruoyi/system/bo/ProcessTaskListBO.java
ruoyi-system/src/main/java/com/ruoyi/system/bo/ProcessTemplatePageBO.java
ruoyi-system/src/main/java/com/ruoyi/system/bo/ProcessUpdateBO.java
ruoyi-system/src/main/java/com/ruoyi/system/code/SubmitTemplateReg.java
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysCache.java
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysConfig.java
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleDept.java
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleMenu.java
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserOnline.java
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserPost.java
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserRole.java
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/MetaVo.java
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RouterVo.java
ruoyi-system/src/main/java/com/ruoyi/system/dto/SysRoleDTO.java
ruoyi-system/src/main/java/com/ruoyi/system/dto/SysUserUpdateStatusDTO.java
ruoyi-system/src/main/java/com/ruoyi/system/dto/TDeptUpAndDownDTO.java
ruoyi-system/src/main/java/com/ruoyi/system/dto/TExamineDTO.java
ruoyi-system/src/main/java/com/ruoyi/system/dto/TerminateContractDTO.java
ruoyi-system/src/main/java/com/ruoyi/system/export/ContractExport.java
ruoyi-system/src/main/java/com/ruoyi/system/export/OpticalInspectionExport.java
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java
ruoyi-system/src/main/java/com/ruoyi/system/query/SysOperLogQuery.java
ruoyi-system/src/main/java/com/ruoyi/system/query/SysRoleQuery.java
ruoyi-system/src/main/java/com/ruoyi/system/query/SysUserQuery.java
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserOnlineService.java
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
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/java/com/ruoyi/system/utils/wx/body/resp/AccessTokenRespBody.java
ruoyi-system/src/main/java/com/ruoyi/system/utils/wx/body/resp/Code2SessionRespBody.java
ruoyi-system/src/main/java/com/ruoyi/system/utils/wx/body/resp/RespBody.java
ruoyi-system/src/main/java/com/ruoyi/system/utils/wx/body/resq/Code2SessionResqBody.java
ruoyi-system/src/main/java/com/ruoyi/system/utils/wx/model/WeixinProperties.java
ruoyi-system/src/main/java/com/ruoyi/system/utils/wx/pojo/AppletPhoneEncrypteData.java
ruoyi-system/src/main/java/com/ruoyi/system/utils/wx/pojo/AppletUserDecodeData.java
ruoyi-system/src/main/java/com/ruoyi/system/utils/wx/pojo/AppletUserEncrypteData.java
ruoyi-system/src/main/java/com/ruoyi/system/utils/wx/pojo/Watermark.java
ruoyi-system/src/main/java/com/ruoyi/system/utils/wx/tools/SHA1.java
ruoyi-system/src/main/java/com/ruoyi/system/utils/wx/tools/WebUtils.java
ruoyi-system/src/main/java/com/ruoyi/system/utils/wx/tools/WxAppletTools.java
ruoyi-system/src/main/java/com/ruoyi/system/utils/wx/tools/WxCache.java
ruoyi-system/src/main/java/com/ruoyi/system/utils/wx/tools/WxCacheTemplate.java
ruoyi-system/src/main/java/com/ruoyi/system/utils/wx/tools/WxException.java
ruoyi-system/src/main/java/com/ruoyi/system/utils/wx/tools/WxJsonUtils.java
ruoyi-system/src/main/java/com/ruoyi/system/utils/wx/tools/WxUtils.java
ruoyi-system/src/main/java/com/ruoyi/system/vo/RoleInfoVO.java
ruoyi-system/src/main/java/com/ruoyi/system/vo/SysOperLogVO.java
ruoyi-system/src/main/java/com/ruoyi/system/vo/SysUserVO.java
ruoyi-system/src/main/java/com/ruoyi/system/vo/UserInfoVo.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/.editorconfig
ruoyi-ui/.env.development
ruoyi-ui/.env.production
ruoyi-ui/.env.staging
ruoyi-ui/.eslintignore
ruoyi-ui/.eslintrc.js
ruoyi-ui/.gitignore
ruoyi-ui/README.md
ruoyi-ui/babel.config.js
ruoyi-ui/bin/build.bat
ruoyi-ui/bin/package.bat
ruoyi-ui/bin/run-web.bat
ruoyi-ui/build/index.js
ruoyi-ui/package.json
ruoyi-ui/public/favicon.ico
ruoyi-ui/public/html/ie.html
ruoyi-ui/public/index.html
ruoyi-ui/public/robots.txt
ruoyi-ui/src/App.vue
ruoyi-ui/src/api/login.js
ruoyi-ui/src/api/menu.js
ruoyi-ui/src/api/monitor/cache.js
ruoyi-ui/src/api/monitor/job.js
ruoyi-ui/src/api/monitor/jobLog.js
ruoyi-ui/src/api/monitor/logininfor.js
ruoyi-ui/src/api/monitor/online.js
ruoyi-ui/src/api/monitor/operlog.js
ruoyi-ui/src/api/monitor/server.js
ruoyi-ui/src/api/system/config.js
ruoyi-ui/src/api/system/dept.js
ruoyi-ui/src/api/system/dict/data.js
ruoyi-ui/src/api/system/dict/type.js
ruoyi-ui/src/api/system/menu.js
ruoyi-ui/src/api/system/notice.js
ruoyi-ui/src/api/system/post.js
ruoyi-ui/src/api/system/role.js
ruoyi-ui/src/api/system/user.js
ruoyi-ui/src/api/tool/gen.js
ruoyi-ui/src/api/type/type.js
ruoyi-ui/src/assets/401_images/401.gif
ruoyi-ui/src/assets/404_images/404.png
ruoyi-ui/src/assets/404_images/404_cloud.png
ruoyi-ui/src/assets/icons/index.js
ruoyi-ui/src/assets/icons/svg/404.svg
ruoyi-ui/src/assets/icons/svg/bug.svg
ruoyi-ui/src/assets/icons/svg/build.svg
ruoyi-ui/src/assets/icons/svg/button.svg
ruoyi-ui/src/assets/icons/svg/cascader.svg
ruoyi-ui/src/assets/icons/svg/chart.svg
ruoyi-ui/src/assets/icons/svg/checkbox.svg
ruoyi-ui/src/assets/icons/svg/clipboard.svg
ruoyi-ui/src/assets/icons/svg/code.svg
ruoyi-ui/src/assets/icons/svg/color.svg
ruoyi-ui/src/assets/icons/svg/component.svg
ruoyi-ui/src/assets/icons/svg/dashboard.svg
ruoyi-ui/src/assets/icons/svg/date-range.svg
ruoyi-ui/src/assets/icons/svg/date.svg
ruoyi-ui/src/assets/icons/svg/dict.svg
ruoyi-ui/src/assets/icons/svg/documentation.svg
ruoyi-ui/src/assets/icons/svg/download.svg
ruoyi-ui/src/assets/icons/svg/drag.svg
ruoyi-ui/src/assets/icons/svg/druid.svg
ruoyi-ui/src/assets/icons/svg/edit.svg
ruoyi-ui/src/assets/icons/svg/education.svg
ruoyi-ui/src/assets/icons/svg/email.svg
ruoyi-ui/src/assets/icons/svg/example.svg
ruoyi-ui/src/assets/icons/svg/excel.svg
ruoyi-ui/src/assets/icons/svg/exit-fullscreen.svg
ruoyi-ui/src/assets/icons/svg/eye-open.svg
ruoyi-ui/src/assets/icons/svg/eye.svg
ruoyi-ui/src/assets/icons/svg/form.svg
ruoyi-ui/src/assets/icons/svg/fullscreen.svg
ruoyi-ui/src/assets/icons/svg/github.svg
ruoyi-ui/src/assets/icons/svg/guide.svg
ruoyi-ui/src/assets/icons/svg/icon.svg
ruoyi-ui/src/assets/icons/svg/input.svg
ruoyi-ui/src/assets/icons/svg/international.svg
ruoyi-ui/src/assets/icons/svg/job.svg
ruoyi-ui/src/assets/icons/svg/language.svg
ruoyi-ui/src/assets/icons/svg/link.svg
ruoyi-ui/src/assets/icons/svg/list.svg
ruoyi-ui/src/assets/icons/svg/lock.svg
ruoyi-ui/src/assets/icons/svg/log.svg
ruoyi-ui/src/assets/icons/svg/logininfor.svg
ruoyi-ui/src/assets/icons/svg/message.svg
ruoyi-ui/src/assets/icons/svg/money.svg
ruoyi-ui/src/assets/icons/svg/monitor.svg
ruoyi-ui/src/assets/icons/svg/nested.svg
ruoyi-ui/src/assets/icons/svg/number.svg
ruoyi-ui/src/assets/icons/svg/online.svg
ruoyi-ui/src/assets/icons/svg/password.svg
ruoyi-ui/src/assets/icons/svg/pdf.svg
ruoyi-ui/src/assets/icons/svg/people.svg
ruoyi-ui/src/assets/icons/svg/peoples.svg
ruoyi-ui/src/assets/icons/svg/phone.svg
ruoyi-ui/src/assets/icons/svg/post.svg
ruoyi-ui/src/assets/icons/svg/qq.svg
ruoyi-ui/src/assets/icons/svg/question.svg
ruoyi-ui/src/assets/icons/svg/radio.svg
ruoyi-ui/src/assets/icons/svg/rate.svg
ruoyi-ui/src/assets/icons/svg/redis-list.svg
ruoyi-ui/src/assets/icons/svg/redis.svg
ruoyi-ui/src/assets/icons/svg/row.svg
ruoyi-ui/src/assets/icons/svg/search.svg
ruoyi-ui/src/assets/icons/svg/select.svg
ruoyi-ui/src/assets/icons/svg/server.svg
ruoyi-ui/src/assets/icons/svg/shopping.svg
ruoyi-ui/src/assets/icons/svg/size.svg
ruoyi-ui/src/assets/icons/svg/skill.svg
ruoyi-ui/src/assets/icons/svg/slider.svg
ruoyi-ui/src/assets/icons/svg/star.svg
ruoyi-ui/src/assets/icons/svg/swagger.svg
ruoyi-ui/src/assets/icons/svg/switch.svg
ruoyi-ui/src/assets/icons/svg/system.svg
ruoyi-ui/src/assets/icons/svg/tab.svg
ruoyi-ui/src/assets/icons/svg/table.svg
ruoyi-ui/src/assets/icons/svg/textarea.svg
ruoyi-ui/src/assets/icons/svg/theme.svg
ruoyi-ui/src/assets/icons/svg/time-range.svg
ruoyi-ui/src/assets/icons/svg/time.svg
ruoyi-ui/src/assets/icons/svg/tool.svg
ruoyi-ui/src/assets/icons/svg/tree-table.svg
ruoyi-ui/src/assets/icons/svg/tree.svg
ruoyi-ui/src/assets/icons/svg/upload.svg
ruoyi-ui/src/assets/icons/svg/user.svg
ruoyi-ui/src/assets/icons/svg/validCode.svg
ruoyi-ui/src/assets/icons/svg/wechat.svg
ruoyi-ui/src/assets/icons/svg/zip.svg
ruoyi-ui/src/assets/icons/svgo.yml
ruoyi-ui/src/assets/images/dark.svg
ruoyi-ui/src/assets/images/light.svg
ruoyi-ui/src/assets/images/login-background.jpg
ruoyi-ui/src/assets/images/pay.png
ruoyi-ui/src/assets/images/profile.jpg
ruoyi-ui/src/assets/logo/logo.png
ruoyi-ui/src/assets/styles/btn.scss
ruoyi-ui/src/assets/styles/element-ui.scss
ruoyi-ui/src/assets/styles/element-variables.scss
ruoyi-ui/src/assets/styles/index.scss
ruoyi-ui/src/assets/styles/mixin.scss
ruoyi-ui/src/assets/styles/ruoyi.scss
ruoyi-ui/src/assets/styles/sidebar.scss
ruoyi-ui/src/assets/styles/transition.scss
ruoyi-ui/src/assets/styles/variables.scss
ruoyi-ui/src/components/Breadcrumb/index.vue
ruoyi-ui/src/components/Crontab/day.vue
ruoyi-ui/src/components/Crontab/hour.vue
ruoyi-ui/src/components/Crontab/index.vue
ruoyi-ui/src/components/Crontab/min.vue
ruoyi-ui/src/components/Crontab/month.vue
ruoyi-ui/src/components/Crontab/result.vue
ruoyi-ui/src/components/Crontab/second.vue
ruoyi-ui/src/components/Crontab/week.vue
ruoyi-ui/src/components/Crontab/year.vue
ruoyi-ui/src/components/DictData/index.js
ruoyi-ui/src/components/DictTag/index.vue
ruoyi-ui/src/components/Editor/index.vue
ruoyi-ui/src/components/FileUpload/index.vue
ruoyi-ui/src/components/Hamburger/index.vue
ruoyi-ui/src/components/HeaderSearch/index.vue
ruoyi-ui/src/components/IconSelect/index.vue
ruoyi-ui/src/components/IconSelect/requireIcons.js
ruoyi-ui/src/components/ImagePreview/index.vue
ruoyi-ui/src/components/ImageUpload/index.vue
ruoyi-ui/src/components/Pagination/index.vue
ruoyi-ui/src/components/PanThumb/index.vue
ruoyi-ui/src/components/ParentView/index.vue
ruoyi-ui/src/components/RightPanel/index.vue
ruoyi-ui/src/components/RightToolbar/index.vue
ruoyi-ui/src/components/RuoYi/Doc/index.vue
ruoyi-ui/src/components/RuoYi/Git/index.vue
ruoyi-ui/src/components/Screenfull/index.vue
ruoyi-ui/src/components/SizeSelect/index.vue
ruoyi-ui/src/components/SvgIcon/index.vue
ruoyi-ui/src/components/ThemePicker/index.vue
ruoyi-ui/src/components/TopNav/index.vue
ruoyi-ui/src/components/iFrame/index.vue
ruoyi-ui/src/directive/dialog/drag.js
ruoyi-ui/src/directive/dialog/dragHeight.js
ruoyi-ui/src/directive/dialog/dragWidth.js
ruoyi-ui/src/directive/index.js
ruoyi-ui/src/directive/module/clipboard.js
ruoyi-ui/src/directive/permission/hasPermi.js
ruoyi-ui/src/directive/permission/hasRole.js
ruoyi-ui/src/layout/components/AppMain.vue
ruoyi-ui/src/layout/components/IframeToggle/index.vue
ruoyi-ui/src/layout/components/InnerLink/index.vue
ruoyi-ui/src/layout/components/Navbar.vue
ruoyi-ui/src/layout/components/Settings/index.vue
ruoyi-ui/src/layout/components/Sidebar/FixiOSBug.js
ruoyi-ui/src/layout/components/Sidebar/Item.vue
ruoyi-ui/src/layout/components/Sidebar/Link.vue
ruoyi-ui/src/layout/components/Sidebar/Logo.vue
ruoyi-ui/src/layout/components/Sidebar/SidebarItem.vue
ruoyi-ui/src/layout/components/Sidebar/index.vue
ruoyi-ui/src/layout/components/TagsView/ScrollPane.vue
ruoyi-ui/src/layout/components/TagsView/index.vue
ruoyi-ui/src/layout/components/index.js
ruoyi-ui/src/layout/index.vue
ruoyi-ui/src/layout/mixin/ResizeHandler.js
ruoyi-ui/src/main.js
ruoyi-ui/src/permission.js
ruoyi-ui/src/plugins/auth.js
ruoyi-ui/src/plugins/cache.js
ruoyi-ui/src/plugins/download.js
ruoyi-ui/src/plugins/index.js
ruoyi-ui/src/plugins/modal.js
ruoyi-ui/src/plugins/tab.js
ruoyi-ui/src/router/index.js
ruoyi-ui/src/settings.js
ruoyi-ui/src/store/getters.js
ruoyi-ui/src/store/index.js
ruoyi-ui/src/store/modules/app.js
ruoyi-ui/src/store/modules/dict.js
ruoyi-ui/src/store/modules/permission.js
ruoyi-ui/src/store/modules/settings.js
ruoyi-ui/src/store/modules/tagsView.js
ruoyi-ui/src/store/modules/user.js
ruoyi-ui/src/utils/auth.js
ruoyi-ui/src/utils/dict/Dict.js
ruoyi-ui/src/utils/dict/DictConverter.js
ruoyi-ui/src/utils/dict/DictData.js
ruoyi-ui/src/utils/dict/DictMeta.js
ruoyi-ui/src/utils/dict/DictOptions.js
ruoyi-ui/src/utils/dict/index.js
ruoyi-ui/src/utils/errorCode.js
ruoyi-ui/src/utils/generator/config.js
ruoyi-ui/src/utils/generator/css.js
ruoyi-ui/src/utils/generator/drawingDefault.js
ruoyi-ui/src/utils/generator/html.js
ruoyi-ui/src/utils/generator/icon.json
ruoyi-ui/src/utils/generator/js.js
ruoyi-ui/src/utils/generator/render.js
ruoyi-ui/src/utils/index.js
ruoyi-ui/src/utils/jsencrypt.js
ruoyi-ui/src/utils/permission.js
ruoyi-ui/src/utils/request.js
ruoyi-ui/src/utils/ruoyi.js
ruoyi-ui/src/utils/scroll-to.js
ruoyi-ui/src/utils/validate.js
ruoyi-ui/src/views/components/icons/element-icons.js
ruoyi-ui/src/views/components/icons/index.vue
ruoyi-ui/src/views/components/icons/svg-icons.js
ruoyi-ui/src/views/dashboard/BarChart.vue
ruoyi-ui/src/views/dashboard/LineChart.vue
ruoyi-ui/src/views/dashboard/PanelGroup.vue
ruoyi-ui/src/views/dashboard/PieChart.vue
ruoyi-ui/src/views/dashboard/RaddarChart.vue
ruoyi-ui/src/views/dashboard/mixins/resize.js
ruoyi-ui/src/views/error/401.vue
ruoyi-ui/src/views/error/404.vue
ruoyi-ui/src/views/index.vue
ruoyi-ui/src/views/index_v1.vue
ruoyi-ui/src/views/login.vue
ruoyi-ui/src/views/monitor/cache/index.vue
ruoyi-ui/src/views/monitor/cache/list.vue
ruoyi-ui/src/views/monitor/druid/index.vue
ruoyi-ui/src/views/monitor/job/index.vue
ruoyi-ui/src/views/monitor/job/log.vue
ruoyi-ui/src/views/monitor/logininfor/index.vue
ruoyi-ui/src/views/monitor/online/index.vue
ruoyi-ui/src/views/monitor/operlog/index.vue
ruoyi-ui/src/views/monitor/server/index.vue
ruoyi-ui/src/views/redirect.vue
ruoyi-ui/src/views/register.vue
ruoyi-ui/src/views/system/config/index.vue
ruoyi-ui/src/views/system/dept/index.vue
ruoyi-ui/src/views/system/dict/data.vue
ruoyi-ui/src/views/system/dict/index.vue
ruoyi-ui/src/views/system/menu/index.vue
ruoyi-ui/src/views/system/notice/index.vue
ruoyi-ui/src/views/system/post/index.vue
ruoyi-ui/src/views/system/role/authUser.vue
ruoyi-ui/src/views/system/role/index.vue
ruoyi-ui/src/views/system/role/selectUser.vue
ruoyi-ui/src/views/system/user/authRole.vue
ruoyi-ui/src/views/system/user/index.vue
ruoyi-ui/src/views/system/user/profile/index.vue
ruoyi-ui/src/views/system/user/profile/resetPwd.vue
ruoyi-ui/src/views/system/user/profile/userAvatar.vue
ruoyi-ui/src/views/system/user/profile/userInfo.vue
ruoyi-ui/src/views/tool/build/CodeTypeDialog.vue
ruoyi-ui/src/views/tool/build/DraggableItem.vue
ruoyi-ui/src/views/tool/build/IconsDialog.vue
ruoyi-ui/src/views/tool/build/RightPanel.vue
ruoyi-ui/src/views/tool/build/TreeNodeDialog.vue
ruoyi-ui/src/views/tool/build/index.vue
ruoyi-ui/src/views/tool/gen/basicInfoForm.vue
ruoyi-ui/src/views/tool/gen/editTable.vue
ruoyi-ui/src/views/tool/gen/genInfoForm.vue
ruoyi-ui/src/views/tool/gen/importTable.vue
ruoyi-ui/src/views/tool/gen/index.vue
ruoyi-ui/src/views/tool/swagger/index.vue
ruoyi-ui/vue.config.js |