!78 同步dev分支
Merge pull request !78 from 疯狂的狮子Li/dev
已修改180个文件
已添加30个文件
已重命名16个文件
已删除10个文件
| | |
| | | [](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/blob/master/LICENSE) |
| | | [](https://www.jetbrains.com/?from=RuoYi-Vue-Plus) |
| | | <br> |
| | | [](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus) |
| | | []() |
| | | [](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus) |
| | | []() |
| | | []() |
| | | []() |
| | | |
| | |
| | | * æéè®¤è¯æ¡æ¶ Spring SecurityãJwtï¼æ¯æå¤ç»ç«¯è®¤è¯ç³»ç» |
| | | * å
³ç³»æ°æ®åº MySQL éé
8.X |
| | | * ç¼åæ°æ®åº Redis éé
6.X |
| | | * æ°æ®åºå¼åæ¡æ¶ Mybatis-Plus å¿«é CRUD å¢å å¼åæç æä»¶åæ¯æåç±»éæ± |
| | | * æ°æ®åºæ¡æ¶ Mybatis-Plus å¿«é CRUD å¢å å¼åæç æä»¶åæ¯æåç±»éæ± |
| | | * æ°æ®åºæ¡æ¶ 夿°æ®æºæ¡æ¶ dynamic-datasource æ¯æä¸»ä»ä¸å¤ç§ç±»æ°æ®åºå¼æ |
| | | * æ°æ®åºæ¡æ¶ Redis客æ·ç«¯ éç¨ Redisson æ§è½æ´å¼º |
| | | * æ°æ®åºæ¡æ¶ æ§è½åææä»¶ p6spy æ´å¼ºå²ç SQL åæ |
| | | * åºååæ¡æ¶ ç»ä¸ä½¿ç¨ jackson 髿å¯é |
| | | * ç½ç»æ¡æ¶ FeignãOkHttp3 æ¥å£å管ç HTTP è¯·æ± |
| | | * å·¥å
·ç±»æ¡æ¶ HutoolãLombok åå°ä»£ç åä½ å¢å å®å
¨æ§ |
| | | * åå¸å¼é Lock4j 注解éãå·¥å
·é å¤ç§å¤æ · |
| | | * æä»¶åå¨ OSS 对象å卿¨¡å æ¯æ(Minioãä¸çãé¿éãè
¾è®¯) |
| | | * çæ§æ¡æ¶ spring-boot-admin å
¨æ¹ä½æå¡çæ§ |
| | | * æ ¡éªæ¡æ¶ validation å¢å¼ºæ¥å£å®å
¨æ§ ä¸¥è°¨æ§ |
| | | * Excelæ¡æ¶ Alibaba EasyExcel æ§è½ä¼å¼ æ©å±æ§å¼º |
| | | * ææ¡£æ¡æ¶ knife4j ç¾åæ¥å£ææ¡£ |
| | | * åºååæ¡æ¶ ç»ä¸ä½¿ç¨ jackson 髿å¯é |
| | | * å·¥å
·ç±»æ¡æ¶ HutoolãLombok åå°ä»£ç åä½ å¢å å®å
¨æ§ |
| | | * 代ç çæå¨ ä¸é®çæåå端代ç |
| | | * 夿°æ®æºæ¡æ¶ dynamic-datasource æ¯æä¸»ä»ä¸å¤ç§ç±»æ°æ®åºå¼æ |
| | | * Redis客æ·ç«¯ éç¨ Redisson æ§è½æ´å¼º |
| | | * åå¸å¼é Lock4j 注解éãå·¥å
·é å¤ç§å¤æ · |
| | | * é¨ç½²æ¹å¼ Docker 容å¨ç¼æ ä¸é®é¨ç½²ä¸å¡é群 |
| | | * æä»¶åå¨ OSS 对象å卿¨¡å æ¯æ(Minioãä¸çãé¿éãè
¾è®¯) |
| | | * å½é
å Spring æ åå½é
åæ¹è§£å³æ¹æ¡ |
| | | |
| | | ## åèææ¡£ |
| | | |
| | | ä½¿ç¨æ¡æ¶å请ä»ç»é
è¯»ææ¡£éç¹æ³¨æäºé¡¹ |
| | | <br> |
| | | >[åå§åé¡¹ç® å¿
ç](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/å
³äºåå§å项ç®?sort_id=4164117) |
| | | >>[https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/å
³äºåå§å项ç®?sort_id=4164117](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/å
³äºåå§å项ç®?sort_id=4164117) |
| | | > |
| | | >[é¨ç½²é¡¹ç® å¿
ç](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/å
³äºåºç¨é¨ç½²?sort_id=4219382) |
| | | >>[https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/å
³äºåºç¨é¨ç½²?sort_id=4219382](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/å
³äºåºç¨é¨ç½²?sort_id=4219382) |
| | | > |
| | | >[åèææ¡£ Wiki](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages) |
| | | >>[https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages) |
| | | |
| | | ## æé®å鍿² |
| | | ### ä¸ãæ¥é
wiki |
| | | ä¼å
å¨`wiki->éç¹äºé¡¹`ï¼æ¥æ¾æ¯å¦æç¸å
³é®é¢åè§£å³æ¹æ¡ï¼å°¤å
¶æ¯æ¡æ¶æ´æ°å产ççé®é¢ï¼å¤ä¼å¨wiki䏿å |
| | | ## è½¯ä»¶æ¶æå¾ |
| | | |
| | | > [åèææ¡£ Wiki](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages) |
| | | |
| | | ### äºãåå©issues |
| | | å°è¯issuesä¸æç´¢é®é¢å
³é®åï¼è®°å¾éæ©å·²å®æï¼ï¼ççæ¯å¦æå
¶ä»äººæåºç¸åé®é¢ |
| | | - `妿æ`é£ä¹ä¾æ®è¯è®ºä¸çè§£å³æ¹æ¡èªè¡å°è¯è§£å³ |
| | | - `å¦ææ²¡æ`é£ä¹æäº¤ä¸ä¸ªæ°çissuesæè¿°æ¸
æ¥ä½ çé®é¢ï¼éè¦å
å«ä»¥ä¸å
容ï¼ä¼è´¨çissuesï¼è½å¤å¸®å©ä½è
æ´é«æçå¸®ä½ è§£å³é®é¢ï¼ï¼ |
| | | - åºç°é®é¢ç模åæåè½æç±»ï¼æ»ä¹ä½ è¦è¯´æ¸
æ¥å¨åªåºçé®é¢ |
| | | - æè¿°äº§çé®é¢çç¸å
³æä½æµç¨ï¼ä»¥ä¾¿å¤ç°å¿«éè§£å³ |
| | | - æ¥éçæ¥å¿æªå¾ï¼ä¸å®æ¯æªå¾ï¼ä¸è¦å¤å¶ä¸å æ¥éçææ¬ |
| | | > [issues](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/issues) |
| | | |
| | | ### ä¸ãç¾åº¦ |
| | | 大家齿ï¼ä¸å¤æè¿°ï¼å°å
³é®çæ¥éä¿¡æ¯CC->CVå°ç¾åº¦ä¸çç大佬们æä¹è§£å³ç |
| | | > [ç¾åº¦](http://www.baidu.com) |
| | | |
| | | ### åãå 群 |
| | | 以ä¸ä¸ç¹å·²ç»è½è§£å³å¤§å®¶ç»å¤§é¨åé®é¢äºï¼å¦æè¿æé®é¢æ²¡è½éè¿è¿å ç§æ¹å¼è§£å³ï¼é£ä¹å 群ï¼å¤§å®¶ä¸èµ·å¨ç¾¤éæ¢è®¨ä¸ä¸ |
| | |  |
| | | |
| | | ## è´¡ç®ä»£ç |
| | | |
| | |
| | | * ORMæ¡æ¶ ä½¿ç¨ Mybatis-Plus ç®åCRUD (䏿¯æä¸»å表) |
| | | * Beanç®å ä½¿ç¨ Lombok ç®å get set toString çç |
| | | * 容卿¹å¨ Tomcat æ¹ä¸º å¹¶åæ§è½æ´å¥½ç undertow |
| | | * åé¡µç§»é¤ pagehelper æ¹ä¸º Mybatis-Plus å页 |
| | | * ç§»é¤ pagehelper æ¹ä¸º Mybatis-Plus å页 |
| | | * éæ p6spy æ´å¼ºå²ç SQL åæ |
| | | * å级 swagger 为 knife4j |
| | | * éæ Hutool 5.X å¹¶éåRuoYié¨ååè½ |
| | | * éæ Feign æ¥å£å管ç Http 请æ±(å¦ä¸æ¹è¯·æ± æ¯ä»,çä¿¡,æ¨éç) |
| | |
| | | * éæ dynamic-datasource 夿°æ®æº(é»è®¤æ¯æMySQL,å
¶ä»ç§ç±»éèªè¡éé
) |
| | | * éæ Lock4j å®ç°åå¸å¼ 注解éãå·¥å
·é å¤ç§å¤æ · |
| | | * å¢å Docker 容å¨ç¼æ æå
æä»¶ä¸é¨ç½²èæ¬ |
| | | * ç§»é¤ æ¬å°æä»¶ä¸ä¼ æ¹ä¸º OSS对象åå¨ æ¯æ(Minioãä¸çãé¿éãè
¾è®¯) |
| | | * ç§»é¤ éç¨ä¸ä¼ ä¸è½½ æ¹ä¸º OSS对象åå¨ æ¯æ(Minioãä¸çãé¿éãè
¾è®¯) |
| | | * ç§»é¤ RuoYièªå¸¦ Excel å·¥å
· æ¹ä¸º EasyExcel å·¥å
· |
| | | |
| | | ### ä»£ç æ¹å¨ |
| | | |
| | |
| | | * 忍¡å fast 忝 [RuoYi-Vue-Plus-fast](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/fast/) |
| | | * Oracle 模å oracle 忝 [RuoYi-Vue-Plus-oracle](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/oracle/) |
| | | |
| | | ## æ«ç å 群 ä¸èµ·äº¤æµ |
| | |  |
| | | ## å ç¾¤ä¸æç® |
| | | >[å ç¾¤ä¸æç®](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/å ç¾¤ä¸æç®?sort_id=4104598) |
| | | >>[https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/å ç¾¤ä¸æç®?sort_id=4104598](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/å ç¾¤ä¸æç®?sort_id=4104598) |
| | | |
| | | ## æç®ä½è
|
| | | ä½è
为å
¼èå弿º,å¹³æ¶è¿éè¦å·¥ä½,妿叮å°äºæ¨å¯ä»¥è¯·ä½è
å个çé¥ |
| | |
| | | - /docker/mysql/data/:/var/lib/mysql/ |
| | | # é
ç½®æè½½ |
| | | - /docker/mysql/conf/:/etc/mysql/conf.d/ |
| | | # ä¸»æºæ¬æºæ¶é´æä»¶æ å° ä¸æ¬æºæ¶é´åæ¥ |
| | | - /etc/localtime:/etc/localtime:ro |
| | | command: |
| | | # å°mysql8.0é»è®¤å¯ç çç¥ ä¿®æ¹ä¸º åå
çç¥ (mysql8.0对å
¶é»è®¤çç¥åäºæ´æ¹ ä¼å¯¼è´å¯ç æ æ³å¹é
) |
| | | --default-authentication-plugin=mysql_native_password |
| | |
| | | # 妿éè¦æå®çæ¬ å°±æ latest æ¢æçæ¬å· |
| | | image: nginx:latest |
| | | container_name: nginx-web |
| | | environment: |
| | | # æ¶åºä¸æµ· |
| | | TZ: Asia/Shanghai |
| | | ports: |
| | | - 80:80 |
| | | - 443:443 |
| | |
| | | - /docker/nginx/html:/usr/share/nginx/html |
| | | # æ¥å¿ç®å½ |
| | | - /docker/nginx/log:/var/log/nginx |
| | | # ä¸»æºæ¬æºæ¶é´æä»¶æ å° ä¸æ¬æºæ¶é´åæ¥ |
| | | - /etc/localtime:/etc/localtime:ro |
| | | privileged: true |
| | | restart: always |
| | | networks: |
| | |
| | | ports: |
| | | - 6379:6379 |
| | | environment: |
| | | # 设置ç¯å¢åé æ¶åºä¸æµ· ç¼ç UTF-8 |
| | | # æ¶åºä¸æµ· |
| | | TZ: Asia/Shanghai |
| | | LANG: en_US.UTF-8 |
| | | volumes: |
| | | # é
ç½®æä»¶ |
| | | - /docker/redis/conf/redis.conf:/redis.conf:rw |
| | | # æ°æ®æä»¶ |
| | | - /docker/redis/data:/data:rw |
| | | # ä¸»æºæ¬æºæ¶é´æä»¶æ å° ä¸æ¬æºæ¶é´åæ¥ |
| | | - /etc/localtime:/etc/localtime:ro |
| | | command: "redis-server --appendonly yes" |
| | | privileged: true |
| | | restart: always |
| | |
| | | # æ§å¶å°ç«¯å£ |
| | | - 9001:9001 |
| | | environment: |
| | | # æ¶åºä¸æµ· |
| | | TZ: Asia/Shanghai |
| | | # 管çåå°ç¨æ·å |
| | | MINIO_ACCESS_KEY: ruoyi |
| | | # 管çåå°å¯ç ï¼æå°8个å符 |
| | |
| | | - /docker/minio/data:/data |
| | | # æ å°é
ç½®ç®å½ |
| | | - /docker/minio/config:/root/.minio/ |
| | | # ä¸»æºæ¬æºæ¶é´æä»¶æ å° ä¸æ¬æºæ¶é´åæ¥ |
| | | - /etc/localtime:/etc/localtime:ro |
| | | command: server --console-address ':9001' /data # æå®å®¹å¨ä¸çç®å½ /data |
| | | privileged: true |
| | | restart: always |
| | |
| | | ipv4_address: 172.30.0.54 |
| | | |
| | | ruoyi-server1: |
| | | image: "ruoyi/ruoyi-server:2.6.0" |
| | | image: "ruoyi/ruoyi-server:3.0.0" |
| | | environment: |
| | | - TZ=Asia/Shanghai |
| | | # æ¶åºä¸æµ· |
| | | TZ: Asia/Shanghai |
| | | volumes: |
| | | # é
ç½®æä»¶ |
| | | - /docker/server1/logs/:/ruoyi/server/logs/ |
| | |
| | | ipv4_address: 172.30.0.60 |
| | | |
| | | ruoyi-server2: |
| | | image: "ruoyi/ruoyi-server:2.6.0" |
| | | image: "ruoyi/ruoyi-server:3.0.0" |
| | | environment: |
| | | - TZ=Asia/Shanghai |
| | | # æ¶åºä¸æµ· |
| | | TZ: Asia/Shanghai |
| | | volumes: |
| | | # é
ç½®æä»¶ |
| | | - /docker/server2/logs/:/ruoyi/server/logs/ |
| | |
| | | ipv4_address: 172.30.0.61 |
| | | |
| | | ruoyi-monitor-admin: |
| | | image: "ruoyi/ruoyi-monitor-admin:2.6.0" |
| | | image: "ruoyi/ruoyi-monitor-admin:3.0.0" |
| | | environment: |
| | | - TZ=Asia/Shanghai |
| | | # æ¶åºä¸æµ· |
| | | TZ: Asia/Shanghai |
| | | privileged: true |
| | | restart: always |
| | | networks: |
| | |
| | | |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <version>2.6.0</version> |
| | | <version>3.0.0</version> |
| | | |
| | | <name>RuoYi-Vue-Plus</name> |
| | | <url>https://gitee.com/JavaLionLi/RuoYi-Vue-Plus</url> |
| | | <description>RuoYi-Vue-Plusåå°ç®¡çç³»ç»</description> |
| | | |
| | | <properties> |
| | | <ruoyi-vue-plus.version>2.6.0</ruoyi-vue-plus.version> |
| | | <ruoyi-vue-plus.version>3.0.0</ruoyi-vue-plus.version> |
| | | <spring-boot.version>2.5.3</spring-boot.version> |
| | | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| | | <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> |
| | |
| | | <druid.version>1.2.6</druid.version> |
| | | <knife4j.version>3.0.3</knife4j.version> |
| | | <poi.version>4.1.2</poi.version> |
| | | <easyexcel.version>2.2.10</easyexcel.version> |
| | | <velocity.version>1.7</velocity.version> |
| | | <jwt.version>0.9.1</jwt.version> |
| | | <mybatis-plus.version>3.4.3</mybatis-plus.version> |
| | | <hutool.version>5.7.6</hutool.version> |
| | | <p6spy.version>3.9.1</p6spy.version> |
| | | <hutool.version>5.7.7</hutool.version> |
| | | <feign.version>3.0.3</feign.version> |
| | | <feign-okhttp.version>11.0</feign-okhttp.version> |
| | | <spring-boot-admin.version>2.4.3</spring-boot-admin.version> |
| | | <feign-okhttp.version>11.2</feign-okhttp.version> |
| | | <okhttp.version>4.9.1</okhttp.version> |
| | | <spring-boot-admin.version>2.5.0</spring-boot-admin.version> |
| | | <redisson.version>3.16.1</redisson.version> |
| | | <lock4j.version>2.2.1</lock4j.version> |
| | | <datasource.version>3.4.1</datasource.version> |
| | | <dynamic-ds.version>3.4.1</dynamic-ds.version> |
| | | |
| | | <!-- OSS é
ç½® --> |
| | | <qiniu.version>7.8.0</qiniu.version> |
| | |
| | | <version>${poi.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>easyexcel</artifactId> |
| | | <version>${easyexcel.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- velocity代ç çæä½¿ç¨æ¨¡æ¿ --> |
| | | <dependency> |
| | | <groupId>org.apache.velocity</groupId> |
| | |
| | | <dependency> |
| | | <groupId>com.baomidou</groupId> |
| | | <artifactId>dynamic-datasource-spring-boot-starter</artifactId> |
| | | <version>${datasource.version}</version> |
| | | <version>${dynamic-ds.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | |
| | | <groupId>com.baomidou</groupId> |
| | | <artifactId>mybatis-plus-extension</artifactId> |
| | | <version>${mybatis-plus.version}</version> |
| | | </dependency> |
| | | <!-- sqlæ§è½åææä»¶ --> |
| | | <dependency> |
| | | <groupId>p6spy</groupId> |
| | | <artifactId>p6spy</artifactId> |
| | | <version>${p6spy.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | |
| | | <groupId>io.github.openfeign</groupId> |
| | | <artifactId>feign-okhttp</artifactId> |
| | | <version>${feign-okhttp.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.squareup.okhttp3</groupId> |
| | | <artifactId>okhttp</artifactId> |
| | | <version>${okhttp.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | |
| | | <repository> |
| | | <id>public</id> |
| | | <name>aliyun nexus</name> |
| | | <url>http://maven.aliyun.com/nexus/content/groups/public/</url> |
| | | <url>https://maven.aliyun.com/repository/public/</url> |
| | | <releases> |
| | | <enabled>true</enabled> |
| | | </releases> |
| | |
| | | <pluginRepository> |
| | | <id>public</id> |
| | | <name>aliyun nexus</name> |
| | | <url>http://maven.aliyun.com/nexus/content/groups/public/</url> |
| | | <url>https://maven.aliyun.com/repository/public/</url> |
| | | <releases> |
| | | <enabled>true</enabled> |
| | | </releases> |
| | |
| | | <!-- ç¯å¢æ è¯ï¼éè¦ä¸é
ç½®æä»¶çåç§°ç¸å¯¹åº --> |
| | | <profiles.active>local</profiles.active> |
| | | <logging.level>debug</logging.level> |
| | | <endpoints.include>'*'</endpoints.include> |
| | | </properties> |
| | | </profile> |
| | | <profile> |
| | |
| | | <!-- ç¯å¢æ è¯ï¼éè¦ä¸é
ç½®æä»¶çåç§°ç¸å¯¹åº --> |
| | | <profiles.active>dev</profiles.active> |
| | | <logging.level>debug</logging.level> |
| | | <endpoints.include>'*'</endpoints.include> |
| | | </properties> |
| | | <activation> |
| | | <!-- é»è®¤ç¯å¢ --> |
| | |
| | | <properties> |
| | | <profiles.active>prod</profiles.active> |
| | | <logging.level>warn</logging.level> |
| | | <endpoints.include>health,info</endpoints.include> |
| | | </properties> |
| | | </profile> |
| | | |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.6.0</version> |
| | | <version>3.0.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <packaging>jar</packaging> |
| | |
| | | import cn.hutool.captcha.generator.RandomGenerator; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | |
| | | |
| | | private String getCodeResult(String capStr) { |
| | | int numberLength = captchaProperties.getNumberLength(); |
| | | int a = Convert.toInt(StrUtil.sub(capStr, 0, numberLength).trim()); |
| | | int a = Convert.toInt(StringUtils.substring(capStr, 0, numberLength).trim()); |
| | | char operator = capStr.charAt(numberLength); |
| | | int b = Convert.toInt(StrUtil.sub(capStr, numberLength + 1, numberLength + 1 + numberLength).trim()); |
| | | int b = Convert.toInt(StringUtils.substring(capStr, numberLength + 1, numberLength + 1 + numberLength).trim()); |
| | | switch (operator) { |
| | | case '*': |
| | | return a * b + ""; |
| | |
| | | package com.ruoyi.web.controller.monitor;
|
| | |
|
| | | import cn.hutool.core.util.StrUtil;
|
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.data.redis.core.RedisCallback;
|
| | |
| | | commandStats.stringPropertyNames().forEach(key -> {
|
| | | Map<String, String> data = new HashMap<>(2);
|
| | | String property = commandStats.getProperty(key);
|
| | | data.put("name", StrUtil.removePrefix(key, "cmdstat_"));
|
| | | data.put("value", StrUtil.subBetween(property, "calls=", ",usec"));
|
| | | data.put("name", StringUtils.removeStart(key, "cmdstat_")); |
| | | data.put("value", StringUtils.substringBetween(property, "calls=", ",usec")); |
| | | pieList.add(data);
|
| | | });
|
| | | result.put("commandStats", pieList);
|
| | |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Log(title = "ç»å½æ¥å¿", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('monitor:logininfor:export')") |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysLogininfor logininfor) |
| | | public void export(SysLogininfor logininfor, HttpServletResponse response) |
| | | { |
| | | List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); |
| | | ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class); |
| | | return util.exportExcel(list, "ç»å½æ¥å¿"); |
| | | ExcelUtil.exportExcel(list, "ç»å½æ¥å¿", SysLogininfor.class, response); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')") |
| | |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Log(title = "æä½æ¥å¿", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('monitor:operlog:export')") |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysOperLog operLog) |
| | | public void export(SysOperLog operLog, HttpServletResponse response) |
| | | { |
| | | List<SysOperLog> list = operLogService.selectOperLogList(operLog); |
| | | ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class); |
| | | return util.exportExcel(list, "æä½æ¥å¿"); |
| | | ExcelUtil.exportExcel(list, "æä½æ¥å¿", SysOperLog.class, response); |
| | | } |
| | | |
| | | @Log(title = "æä½æ¥å¿", businessType = BusinessType.DELETE) |
| | |
| | | package com.ruoyi.web.controller.monitor; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.SysUserOnline; |
| | | import com.ruoyi.system.service.ISysUserOnlineService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | for (String key : keys) |
| | | { |
| | | LoginUser user = redisCache.getCacheObject(key); |
| | | if (Validator.isNotEmpty(ipaddr) && Validator.isNotEmpty(userName)) |
| | | if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) |
| | | { |
| | | if (StrUtil.equals(ipaddr, user.getIpaddr()) && StrUtil.equals(userName, user.getUsername())) |
| | | if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) |
| | | { |
| | | userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user)); |
| | | } |
| | | } |
| | | else if (Validator.isNotEmpty(ipaddr)) |
| | | else if (StringUtils.isNotEmpty(ipaddr)) |
| | | { |
| | | if (StrUtil.equals(ipaddr, user.getIpaddr())) |
| | | if (StringUtils.equals(ipaddr, user.getIpaddr())) |
| | | { |
| | | userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user)); |
| | | } |
| | | } |
| | | else if (Validator.isNotEmpty(userName) && Validator.isNotNull(user.getUser())) |
| | | else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) |
| | | { |
| | | if (StrUtil.equals(userName, user.getUsername())) |
| | | if (StringUtils.equals(userName, user.getUsername())) |
| | | { |
| | | userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user)); |
| | | } |
| | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:config:export')") |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysConfig config) |
| | | public void export(SysConfig config, HttpServletResponse response) |
| | | { |
| | | List<SysConfig> list = configService.selectConfigList(config); |
| | | ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class); |
| | | return util.exportExcel(list, "åæ°æ°æ®"); |
| | | ExcelUtil.exportExcel(list, "åæ°æ°æ®", SysConfig.class, response); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | return AjaxResult.error("æ°å¢åæ°'" + config.getConfigName() + "'失败ï¼åæ°é®åå·²åå¨"); |
| | | } |
| | | config.setCreateBy(SecurityUtils.getUsername()); |
| | | config.setCreateBy(getUsername()); |
| | | return toAjax(configService.insertConfig(config)); |
| | | } |
| | | |
| | |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹åæ°'" + config.getConfigName() + "'失败ï¼åæ°é®åå·²åå¨"); |
| | | } |
| | | config.setUpdateBy(SecurityUtils.getUsername()); |
| | | config.setUpdateBy(getUsername()); |
| | | return toAjax(configService.updateConfig(config)); |
| | | } |
| | | |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.service.ISysDeptService; |
| | | 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; |
| | |
| | | { |
| | | SysDept d = (SysDept) it.next(); |
| | | if (d.getDeptId().intValue() == deptId |
| | | || ArrayUtils.contains(StrUtil.splitToArray(d.getAncestors(), ","), deptId + "")) |
| | | || ArrayUtil.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")) |
| | | { |
| | | it.remove(); |
| | | } |
| | |
| | | { |
| | | return AjaxResult.error("æ°å¢é¨é¨'" + dept.getDeptName() + "'失败ï¼é¨é¨åç§°å·²åå¨"); |
| | | } |
| | | dept.setCreateBy(SecurityUtils.getUsername()); |
| | | dept.setCreateBy(getUsername()); |
| | | return toAjax(deptService.insertDept(dept)); |
| | | } |
| | | |
| | |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹é¨é¨'" + dept.getDeptName() + "'失败ï¼ä¸çº§é¨é¨ä¸è½æ¯èªå·±"); |
| | | } |
| | | else if (StrUtil.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) |
| | | else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) |
| | | && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) |
| | | { |
| | | return AjaxResult.error("该é¨é¨å
嫿ªåç¨çåé¨é¨ï¼"); |
| | | } |
| | | dept.setUpdateBy(SecurityUtils.getUsername()); |
| | | dept.setUpdateBy(getUsername()); |
| | | return toAjax(deptService.updateDept(dept)); |
| | | } |
| | | |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.system.service.ISysDictDataService; |
| | | import com.ruoyi.system.service.ISysDictTypeService; |
| | |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | @Log(title = "åå
¸æ°æ®", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:dict:export')") |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysDictData dictData) |
| | | public void export(SysDictData dictData, HttpServletResponse response) |
| | | { |
| | | List<SysDictData> list = dictDataService.selectDictDataList(dictData); |
| | | ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class); |
| | | return util.exportExcel(list, "åå
¸æ°æ®"); |
| | | ExcelUtil.exportExcel(list, "åå
¸æ°æ®", SysDictData.class, response); |
| | | } |
| | | |
| | | /** |
| | |
| | | public AjaxResult dictType(@PathVariable String dictType) |
| | | { |
| | | List<SysDictData> data = dictTypeService.selectDictDataByType(dictType); |
| | | if (Validator.isNull(data)) |
| | | if (StringUtils.isNull(data)) |
| | | { |
| | | data = new ArrayList<SysDictData>(); |
| | | } |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysDictData dict) |
| | | { |
| | | dict.setCreateBy(SecurityUtils.getUsername()); |
| | | dict.setCreateBy(getUsername()); |
| | | return toAjax(dictDataService.insertDictData(dict)); |
| | | } |
| | | |
| | |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysDictData dict) |
| | | { |
| | | dict.setUpdateBy(SecurityUtils.getUsername()); |
| | | dict.setUpdateBy(getUsername()); |
| | | return toAjax(dictDataService.updateDictData(dict)); |
| | | } |
| | | |
| | |
| | | import com.ruoyi.common.core.domain.entity.SysDictType; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.system.service.ISysDictTypeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:dict:export')") |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysDictType dictType) |
| | | public void export(SysDictType dictType, HttpServletResponse response) |
| | | { |
| | | List<SysDictType> list = dictTypeService.selectDictTypeList(dictType); |
| | | ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class); |
| | | return util.exportExcel(list, "åå
¸ç±»å"); |
| | | ExcelUtil.exportExcel(list, "åå
¸ç±»å", SysDictType.class, response); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | return AjaxResult.error("æ°å¢åå
¸'" + dict.getDictName() + "'失败ï¼åå
¸ç±»åå·²åå¨"); |
| | | } |
| | | dict.setCreateBy(SecurityUtils.getUsername()); |
| | | dict.setCreateBy(getUsername()); |
| | | return toAjax(dictTypeService.insertDictType(dict)); |
| | | } |
| | | |
| | |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹åå
¸'" + dict.getDictName() + "'失败ï¼åå
¸ç±»åå·²åå¨"); |
| | | } |
| | | dict.setUpdateBy(SecurityUtils.getUsername()); |
| | | dict.setUpdateBy(getUsername()); |
| | | return toAjax(dictTypeService.updateDictType(dict)); |
| | | } |
| | | |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | @RequestMapping("/") |
| | | public String index() |
| | | { |
| | | return StrUtil.format("欢è¿ä½¿ç¨{}åå°ç®¡çæ¡æ¶ï¼å½åçæ¬ï¼v{}ï¼è¯·éè¿å端å°å访é®ã", ruoyiConfig.getName(), ruoyiConfig.getVersion()); |
| | | return StringUtils.format("欢è¿ä½¿ç¨{}åå°ç®¡çæ¡æ¶ï¼å½åçæ¬ï¼v{}ï¼è¯·éè¿å端å°å访é®ã", ruoyiConfig.getName(), ruoyiConfig.getVersion()); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginBody; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.framework.web.service.SysLoginService; |
| | | import com.ruoyi.framework.web.service.SysPermissionService; |
| | |
| | | @GetMapping("getRouters") |
| | | public AjaxResult getRouters() |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | // ç¨æ·ä¿¡æ¯ |
| | | SysUser user = loginUser.getUser(); |
| | | List<SysMenu> menus = menuService.selectMenuTreeByUserId(user.getUserId()); |
| | | Long userId = SecurityUtils.getUserId(); |
| | | List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId); |
| | | return AjaxResult.success(menuService.buildMenus(menus)); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | 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.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | /** |
| | | * è·åèåå表 |
| | | */ |
| | |
| | | @GetMapping("/list") |
| | | public AjaxResult list(SysMenu menu) |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | Long userId = loginUser.getUser().getUserId(); |
| | | List<SysMenu> menus = menuService.selectMenuList(menu, userId); |
| | | List<SysMenu> menus = menuService.selectMenuList(menu, getUserId()); |
| | | return AjaxResult.success(menus); |
| | | } |
| | | |
| | |
| | | @GetMapping("/treeselect") |
| | | public AjaxResult treeselect(SysMenu menu) |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | Long userId = loginUser.getUser().getUserId(); |
| | | List<SysMenu> menus = menuService.selectMenuList(menu, userId); |
| | | List<SysMenu> menus = menuService.selectMenuList(menu, getUserId()); |
| | | return AjaxResult.success(menuService.buildMenuTreeSelect(menus)); |
| | | } |
| | | |
| | |
| | | @GetMapping(value = "/roleMenuTreeselect/{roleId}") |
| | | public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId()); |
| | | List<SysMenu> menus = menuService.selectMenuList(getUserId()); |
| | | Map<String,Object> ajax = new HashMap<>(); |
| | | ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); |
| | | ajax.put("menus", menuService.buildMenuTreeSelect(menus)); |
| | |
| | | { |
| | | return AjaxResult.error("æ°å¢èå'" + menu.getMenuName() + "'失败ï¼èååç§°å·²åå¨"); |
| | | } |
| | | else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !Validator.isUrl(menu.getPath())) |
| | | else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) |
| | | { |
| | | return AjaxResult.error("æ°å¢èå'" + menu.getMenuName() + "'失败ï¼å°åå¿
须以http(s)://å¼å¤´"); |
| | | } |
| | | menu.setCreateBy(SecurityUtils.getUsername()); |
| | | menu.setCreateBy(getUsername()); |
| | | return toAjax(menuService.insertMenu(menu)); |
| | | } |
| | | |
| | |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹èå'" + menu.getMenuName() + "'失败ï¼èååç§°å·²åå¨"); |
| | | } |
| | | else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !Validator.isUrl(menu.getPath())) |
| | | else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹èå'" + menu.getMenuName() + "'失败ï¼å°åå¿
须以http(s)://å¼å¤´"); |
| | | } |
| | |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹èå'" + menu.getMenuName() + "'失败ï¼ä¸çº§èåä¸è½éæ©èªå·±"); |
| | | } |
| | | menu.setUpdateBy(SecurityUtils.getUsername()); |
| | | menu.setUpdateBy(getUsername()); |
| | | return toAjax(menuService.updateMenu(menu)); |
| | | } |
| | | |
| | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.system.domain.SysNotice; |
| | | import com.ruoyi.system.service.ISysNoticeService; |
| | | |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysNotice notice) |
| | | { |
| | | notice.setCreateBy(SecurityUtils.getUsername()); |
| | | notice.setCreateBy(getUsername()); |
| | | return toAjax(noticeService.insertNotice(notice)); |
| | | } |
| | | |
| | |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysNotice notice) |
| | | { |
| | | notice.setUpdateBy(SecurityUtils.getUsername()); |
| | | notice.setUpdateBy(getUsername()); |
| | | return toAjax(noticeService.updateNotice(notice)); |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.validate.AddGroup; |
| | | import com.ruoyi.common.core.validate.EditGroup; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.system.domain.bo.SysOssConfigBo; |
| | | import com.ruoyi.system.domain.vo.SysOssConfigVo; |
| | | import com.ruoyi.system.service.ISysOssConfigService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | 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 javax.validation.constraints.NotEmpty; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * äºåå¨é
ç½®Controller |
| | | * |
| | | * @author Lion Li |
| | | * @author å¤èçé¨ |
| | | * @date 2021-08-13 |
| | | */ |
| | | @Validated |
| | | @Api(value = "äºåå¨é
ç½®æ§å¶å¨", tags = {"äºåå¨é
置管ç"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RestController |
| | | @RequestMapping("/system/oss/config") |
| | | public class SysOssConfigController extends BaseController { |
| | | |
| | | private final ISysOssConfigService iSysOssConfigService; |
| | | |
| | | /** |
| | | * æ¥è¯¢äºåå¨é
ç½®å表 |
| | | */ |
| | | @ApiOperation("æ¥è¯¢äºåå¨é
ç½®å表") |
| | | @PreAuthorize("@ss.hasPermi('system:oss:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysOssConfigVo> list(@Validated SysOssConfigBo bo) { |
| | | return iSysOssConfigService.queryPageList(bo); |
| | | } |
| | | |
| | | /** |
| | | * è·åäºåå¨é
置详ç»ä¿¡æ¯ |
| | | */ |
| | | @ApiOperation("è·åäºåå¨é
置详ç»ä¿¡æ¯") |
| | | @PreAuthorize("@ss.hasPermi('system:oss:query')") |
| | | @GetMapping("/{ossConfigId}") |
| | | public AjaxResult<SysOssConfigVo> getInfo(@NotNull(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable("ossConfigId") Integer ossConfigId) { |
| | | return AjaxResult.success(iSysOssConfigService.queryById(ossConfigId)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢äºåå¨é
ç½® |
| | | */ |
| | | @ApiOperation("æ°å¢äºåå¨é
ç½®") |
| | | @PreAuthorize("@ss.hasPermi('system:oss:add')") |
| | | @Log(title = "äºåå¨é
ç½®", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit() |
| | | @PostMapping() |
| | | public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody SysOssConfigBo bo) { |
| | | return toAjax(iSysOssConfigService.insertByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹äºåå¨é
ç½® |
| | | */ |
| | | @ApiOperation("ä¿®æ¹äºåå¨é
ç½®") |
| | | @PreAuthorize("@ss.hasPermi('system:oss:edit')") |
| | | @Log(title = "äºåå¨é
ç½®", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit() |
| | | @PutMapping() |
| | | public AjaxResult<Void> edit(@Validated(EditGroup.class) @RequestBody SysOssConfigBo bo) { |
| | | return toAjax(iSysOssConfigService.updateByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | | /** |
| | | * å é¤äºåå¨é
ç½® |
| | | */ |
| | | @ApiOperation("å é¤äºåå¨é
ç½®") |
| | | @PreAuthorize("@ss.hasPermi('system:oss:remove')") |
| | | @Log(title = "äºåå¨é
ç½®", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ossConfigIds}") |
| | | public AjaxResult<Void> remove(@NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable Long[] ossConfigIds) { |
| | | return toAjax(iSysOssConfigService.deleteWithValidByIds(Arrays.asList(ossConfigIds), true) ? 1 : 0); |
| | | } |
| | | |
| | | /** |
| | | * ç¶æä¿®æ¹ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:oss:edit')") |
| | | @Log(title = "äºåå¨ç¶æä¿®æ¹", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysOssConfigBo bo) { |
| | | return toAjax(iSysOssConfigService.updateOssConfigStatus(bo)); |
| | | } |
| | | } |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/system/controller/SysOssController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.system.controller; |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | | import com.ruoyi.system.domain.bo.SysOssBo; |
| | | import com.ruoyi.oss.constant.CloudConstant; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.system.domain.SysOss; |
| | | import com.ruoyi.system.service.ISysOssService; |
| | | import com.ruoyi.system.domain.bo.SysOssBo; |
| | | import com.ruoyi.system.domain.vo.SysOssVo; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.system.service.ISysOssService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | public class SysOssController extends BaseController { |
| | | |
| | | private final ISysOssService iSysOssService; |
| | | private final ISysConfigService iSysConfigService; |
| | | |
| | | /** |
| | | * æ¥è¯¢OSSäºåå¨å表 |
| | |
| | | @RepeatSubmit |
| | | @PostMapping("/upload") |
| | | public AjaxResult<Map<String, String>> upload(@RequestPart("file") MultipartFile file) { |
| | | if (file.isEmpty()) { |
| | | throw new CustomException("ä¸ä¼ æä»¶ä¸è½ä¸ºç©º"); |
| | | if (ObjectUtil.isNull(file)) { |
| | | throw new ServiceException("ä¸ä¼ æä»¶ä¸è½ä¸ºç©º"); |
| | | } |
| | | SysOss oss = iSysOssService.upload(file); |
| | | Map<String, String> map = new HashMap<>(2); |
| | |
| | | @GetMapping("/download/{ossId}") |
| | | public void download(@PathVariable Long ossId, HttpServletResponse response) throws IOException { |
| | | SysOss sysOss = iSysOssService.getById(ossId); |
| | | if (sysOss == null) { |
| | | throw new CustomException("æä»¶æ°æ®ä¸åå¨!"); |
| | | if (ObjectUtil.isNull(sysOss)) { |
| | | throw new ServiceException("æä»¶æ°æ®ä¸åå¨!"); |
| | | } |
| | | response.reset(); |
| | | response.addHeader("Access-Control-Allow-Origin", "*"); |
| | |
| | | return toAjax(iSysOssService.deleteWithValidByIds(Arrays.asList(ossIds), true) ? 1 : 0); |
| | | } |
| | | |
| | | /** |
| | | * åæ´å¾çå表é¢è§ç¶æ |
| | | */ |
| | | @ApiOperation("åæ´å¾çå表é¢è§ç¶æ") |
| | | @PreAuthorize("@ss.hasPermi('system:oss:edit')") |
| | | @Log(title = "OSSäºåå¨" , businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changePreviewListResource") |
| | | public AjaxResult<Void> changePreviewListResource(@RequestBody String body) { |
| | | Map<String, Boolean> map = JsonUtils.parseMap(body); |
| | | SysConfig config = iSysConfigService.getOne(new LambdaQueryWrapper<SysConfig>() |
| | | .eq(SysConfig::getConfigKey, CloudConstant.PEREVIEW_LIST_RESOURCE_KEY)); |
| | | config.setConfigValue(map.get("previewListResource").toString()); |
| | | return toAjax(iSysConfigService.updateConfig(config)); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.system.domain.SysPost; |
| | | import com.ruoyi.system.service.ISysPostService; |
| | | 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 javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å²ä½ä¿¡æ¯æä½å¤ç |
| | |
| | | @Log(title = "å²ä½ç®¡ç", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:post:export')") |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysPost post) |
| | | public void export(SysPost post, HttpServletResponse response) |
| | | { |
| | | List<SysPost> list = postService.selectPostList(post); |
| | | ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class); |
| | | return util.exportExcel(list, "å²ä½æ°æ®"); |
| | | ExcelUtil.exportExcel(list, "å²ä½æ°æ®", SysPost.class, response); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | return AjaxResult.error("æ°å¢å²ä½'" + post.getPostName() + "'失败ï¼å²ä½ç¼ç å·²åå¨"); |
| | | } |
| | | post.setCreateBy(SecurityUtils.getUsername()); |
| | | post.setCreateBy(getUsername()); |
| | | return toAjax(postService.insertPost(post)); |
| | | } |
| | | |
| | |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹å²ä½'" + post.getPostName() + "'失败ï¼å²ä½ç¼ç å·²åå¨"); |
| | | } |
| | | post.setUpdateBy(SecurityUtils.getUsername()); |
| | | post.setUpdateBy(getUsername()); |
| | | return toAjax(postService.updatePost(post)); |
| | | } |
| | | |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.file.FileUploadUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.domain.SysOss; |
| | | import com.ruoyi.system.service.ISysOssService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @Autowired |
| | | private ISysOssService iSysOssService; |
| | | |
| | | /** |
| | | * ä¸ªäººä¿¡æ¯ |
| | | */ |
| | |
| | | @PutMapping |
| | | public AjaxResult updateProfile(@RequestBody SysUser user) |
| | | { |
| | | if (StrUtil.isNotEmpty(user.getPhonenumber()) |
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'å¤±è´¥ï¼ææºå·ç å·²åå¨"); |
| | | } |
| | | if (StrUtil.isNotEmpty(user.getEmail()) |
| | | if (StringUtils.isNotEmpty(user.getEmail()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'失败ï¼é®ç®±è´¦å·å·²åå¨"); |
| | |
| | | if (!file.isEmpty()) |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file); |
| | | SysOss oss = iSysOssService.upload(file); |
| | | String avatar = oss.getUrl(); |
| | | if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) |
| | | { |
| | | Map<String,Object> ajax = new HashMap<>(); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | 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; |
| | | 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; |
| | | |
| | | /** |
| | | * 注åéªè¯ |
| | | * |
| | | * @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); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | 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.model.LoginUser; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.service.SysPermissionService; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:role:export')") |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysRole role) |
| | | public void export(SysRole role, HttpServletResponse response) |
| | | { |
| | | List<SysRole> list = roleService.selectRoleList(role); |
| | | ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); |
| | | return util.exportExcel(list, "è§è²æ°æ®"); |
| | | ExcelUtil.exportExcel(list, "è§è²æ°æ®", SysRole.class, response); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | return AjaxResult.error("æ°å¢è§è²'" + role.getRoleName() + "'失败ï¼è§è²æéå·²åå¨"); |
| | | } |
| | | role.setCreateBy(SecurityUtils.getUsername()); |
| | | role.setCreateBy(getUsername()); |
| | | return toAjax(roleService.insertRole(role)); |
| | | |
| | | } |
| | |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹è§è²'" + role.getRoleName() + "'失败ï¼è§è²æéå·²åå¨"); |
| | | } |
| | | role.setUpdateBy(SecurityUtils.getUsername()); |
| | | role.setUpdateBy(getUsername()); |
| | | |
| | | if (roleService.updateRole(role) > 0) |
| | | { |
| | | // æ´æ°ç¼åç¨æ·æé |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | if (Validator.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) |
| | | if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) |
| | | { |
| | | loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser())); |
| | | loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName())); |
| | |
| | | public AjaxResult changeStatus(@RequestBody SysRole role) |
| | | { |
| | | roleService.checkRoleAllowed(role); |
| | | role.setUpdateBy(SecurityUtils.getUsername()); |
| | | role.setUpdateBy(getUsername()); |
| | | return toAjax(roleService.updateRoleStatus(role)); |
| | | } |
| | | |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | 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.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.domain.vo.SysUserExportVo; |
| | | import com.ruoyi.system.domain.vo.SysUserImportVo; |
| | | import com.ruoyi.system.service.ISysPostService; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:user:export')") |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysUser user) |
| | | public void export(SysUser user, HttpServletResponse response) |
| | | { |
| | | List<SysUser> list = userService.selectUserList(user); |
| | | ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); |
| | | return util.exportExcel(list, "ç¨æ·æ°æ®"); |
| | | List<SysUserExportVo> listVo = BeanUtil.copyToList(list, SysUserExportVo.class); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | SysDept dept = list.get(i).getDept(); |
| | | SysUserExportVo vo = listVo.get(i); |
| | | if (ObjectUtil.isNotEmpty(dept)) { |
| | | vo.setDeptName(dept.getDeptName()); |
| | | vo.setLeader(dept.getLeader()); |
| | | } |
| | | } |
| | | ExcelUtil.exportExcel(listVo, "ç¨æ·æ°æ®", SysUserExportVo.class, response); |
| | | } |
| | | |
| | | @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()); |
| | | List<SysUserImportVo> userListVo = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class); |
| | | List<SysUser> userList = BeanUtil.copyToList(userListVo, SysUser.class); |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | String operName = loginUser.getUsername(); |
| | | String message = userService.importUser(userList, updateSupport, operName); |
| | |
| | | } |
| | | |
| | | @GetMapping("/importTemplate") |
| | | public AjaxResult importTemplate() |
| | | public void importTemplate(HttpServletResponse response) |
| | | { |
| | | ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); |
| | | return util.importTemplateExcel("ç¨æ·æ°æ®"); |
| | | ExcelUtil.exportExcel(new ArrayList<>(), "ç¨æ·æ°æ®", SysUserImportVo.class, response); |
| | | } |
| | | |
| | | /** |
| | |
| | | List<SysRole> roles = roleService.selectRoleAll(); |
| | | ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); |
| | | ajax.put("posts", postService.selectPostAll()); |
| | | if (Validator.isNotNull(userId)) |
| | | if (StringUtils.isNotNull(userId)) |
| | | { |
| | | ajax.put("user", userService.selectUserById(userId)); |
| | | ajax.put("postIds", postService.selectPostListByUserId(userId)); |
| | |
| | | { |
| | | return AjaxResult.error("æ°å¢ç¨æ·'" + user.getUserName() + "'失败ï¼ç»å½è´¦å·å·²åå¨"); |
| | | } |
| | | else if (Validator.isNotEmpty(user.getPhonenumber()) |
| | | else if (StringUtils.isNotEmpty(user.getPhonenumber()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) |
| | | { |
| | | return AjaxResult.error("æ°å¢ç¨æ·'" + user.getUserName() + "'å¤±è´¥ï¼ææºå·ç å·²åå¨"); |
| | | } |
| | | else if (Validator.isNotEmpty(user.getEmail()) |
| | | else if (StringUtils.isNotEmpty(user.getEmail()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) |
| | | { |
| | | return AjaxResult.error("æ°å¢ç¨æ·'" + user.getUserName() + "'失败ï¼é®ç®±è´¦å·å·²åå¨"); |
| | | } |
| | | user.setCreateBy(SecurityUtils.getUsername()); |
| | | user.setCreateBy(getUsername()); |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | return toAjax(userService.insertUser(user)); |
| | | } |
| | |
| | | public AjaxResult edit(@Validated @RequestBody SysUser user) |
| | | { |
| | | userService.checkUserAllowed(user); |
| | | if (Validator.isNotEmpty(user.getPhonenumber()) |
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'å¤±è´¥ï¼ææºå·ç å·²åå¨"); |
| | | } |
| | | else if (Validator.isNotEmpty(user.getEmail()) |
| | | else if (StringUtils.isNotEmpty(user.getEmail()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'失败ï¼é®ç®±è´¦å·å·²åå¨"); |
| | | } |
| | | user.setUpdateBy(SecurityUtils.getUsername()); |
| | | user.setUpdateBy(getUsername()); |
| | | return toAjax(userService.updateUser(user)); |
| | | } |
| | | |
| | |
| | | @DeleteMapping("/{userIds}") |
| | | public AjaxResult remove(@PathVariable Long[] userIds) |
| | | { |
| | | if (ArrayUtil.contains(userIds, getUserId())) |
| | | { |
| | | return error("å½åç¨æ·ä¸è½å é¤"); |
| | | } |
| | | return toAjax(userService.deleteUserByIds(userIds)); |
| | | } |
| | | |
| | |
| | | { |
| | | userService.checkUserAllowed(user); |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | user.setUpdateBy(SecurityUtils.getUsername()); |
| | | user.setUpdateBy(getUsername()); |
| | | return toAjax(userService.resetPwd(user)); |
| | | } |
| | | |
| | |
| | | public AjaxResult changeStatus(@RequestBody SysUser user) |
| | | { |
| | | userService.checkUserAllowed(user); |
| | | user.setUpdateBy(SecurityUtils.getUsername()); |
| | | user.setUpdateBy(getUsername()); |
| | | return toAjax(userService.updateUserStatus(user)); |
| | | } |
| | | |
| | |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | # å¨ææ°æ®æºææ¡£ https://www.kancloud.cn/tracy5546/dynamic-datasource/content |
| | | dynamic: |
| | | # æ§è½åææä»¶(ææ§è½æè ä¸å»ºè®®ç产ç¯å¢ä½¿ç¨) |
| | | p6spy: true |
| | | #设置é»è®¤çæ°æ®æºæè
æ°æ®æºç»,é»è®¤å¼å³ä¸º master |
| | | primary: master |
| | | datasource: |
| | |
| | | admin: |
| | | # Spring Boot Admin Client 客æ·ç«¯çç¸å
³é
ç½® |
| | | client: |
| | | # å¢å 客æ·ç«¯å¼å
³ |
| | | enabled: true |
| | | # 设置 Spring Boot Admin Server å°å |
| | | url: http://localhost:9090/admin |
| | | instance: |
| | | prefer-ip: true # 注åå®ä¾æ¶ï¼ä¼å
ä½¿ç¨ IP |
| | | username: ruoyi |
| | | password: 123456 |
| | | |
| | | # Actuator çæ§ç«¯ç¹çé
置项 |
| | | management: |
| | | endpoints: |
| | | web: |
| | | # Actuator æä¾ç API æ¥å£çæ ¹ç®å½ãé»è®¤ä¸º /actuator |
| | | base-path: /actuator |
| | | exposure: |
| | | # éè¦å¼æ¾ç端ç¹ãé»è®¤å¼åªæå¼ health å info 两个端ç¹ãéè¿è®¾ç½® * ï¼å¯ä»¥å¼æ¾ææç«¯ç¹ã |
| | | # ç产ç¯å¢ä¸å»ºè®®æ¾å¼ææ æ ¹æ®é¡¹ç®éæ±æ¾å¼å³å¯ |
| | | include: '*' |
| | | endpoint: |
| | | logfile: |
| | | external-file: ./logs/sys-console.log |
| | | |
| | | --- # OSS äºåå¨(çé¢ <åæ°è®¾ç½®> å¯åæ¢) |
| | | cloud-storage: |
| | | # minioé
ç½® |
| | | minio: |
| | | endpoint: http://localhost:9000 |
| | | accessKey: ruoyi |
| | | secretKey: ruoyi123 |
| | | bucketName: ruoyi |
| | | # ä¸çäºé
ç½® |
| | | qiniu: |
| | | domain: http://XXX.XXXX.com |
| | | prefix: |
| | | accessKey: XXXXXXXXXXXXXXX |
| | | secretKey: XXXXXXXXXXXXXXX |
| | | bucketName: ruoyi |
| | | isHttps: false |
| | | # z0 åä¸ z1 åå z2 åå na0 åç¾ as0 ä¸åäº |
| | | # ä¸å¡«ä¸ºèªå¨è·å(æ§è½ä½ æåºé®é¢) |
| | | region: z0 |
| | | # é¿éäºé
ç½® |
| | | aliyun: |
| | | endpoint: http://oss-cn-beijing.aliyuncs.com |
| | | prefix: |
| | | accessKeyId: XXXXXXXXXXXXXXX |
| | | accessKeySecret: XXXXXXXXXXXXXXX |
| | | bucketName: ruoyi |
| | | # è
¾è®¯äºé
ç½® |
| | | qcloud: |
| | | endpoint: http://cos.ap-beijing.myqcloud.com |
| | | prefix: |
| | | secretId: XXXXXXXXXXXXXXX |
| | | secretKey: XXXXXXXXXXXXXXX |
| | | # è
¾è®¯äºbucketåè§å æ ¼å¼ä¸º BucketName-APPID æ¤å¤å¡«åçå卿¡¶åç§°å¿
é¡»ä¸ºæ¤æ ¼å¼ |
| | | bucketName: ruoyi-1250000000 |
| | | isHttps: false |
| | | # å°åååè宿¹ææ¡£ |
| | | # https://cloud.tencent.com/document/product/436/6224 |
| | | region: ap-beijing |
| | |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | # å¨ææ°æ®æºææ¡£ https://www.kancloud.cn/tracy5546/dynamic-datasource/content |
| | | dynamic: |
| | | # æ§è½åææä»¶(ææ§è½æè ä¸å»ºè®®ç产ç¯å¢ä½¿ç¨) |
| | | p6spy: false |
| | | #设置é»è®¤çæ°æ®æºæè
æ°æ®æºç»,é»è®¤å¼å³ä¸º master |
| | | primary: master |
| | | datasource: |
| | |
| | | admin: |
| | | # Spring Boot Admin Client 客æ·ç«¯çç¸å
³é
ç½® |
| | | client: |
| | | # å¢å 客æ·ç«¯å¼å
³ |
| | | enabled: true |
| | | # 设置 Spring Boot Admin Server å°å |
| | | url: http://172.30.0.90:9090/admin |
| | | instance: |
| | | prefer-ip: true # 注åå®ä¾æ¶ï¼ä¼å
ä½¿ç¨ IP |
| | | username: ruoyi |
| | | password: 123456 |
| | | |
| | | # Actuator çæ§ç«¯ç¹çé
置项 |
| | | management: |
| | | endpoints: |
| | | web: |
| | | # Actuator æä¾ç API æ¥å£çæ ¹ç®å½ãé»è®¤ä¸º /actuator |
| | | base-path: /actuator |
| | | exposure: |
| | | # éè¦å¼æ¾ç端ç¹ãé»è®¤å¼åªæå¼ health å info 两个端ç¹ãéè¿è®¾ç½® * ï¼å¯ä»¥å¼æ¾ææç«¯ç¹ã |
| | | # ç产ç¯å¢ä¸å»ºè®®æ¾å¼ææ æ ¹æ®é¡¹ç®éæ±æ¾å¼å³å¯ |
| | | include: health,info |
| | | endpoint: |
| | | logfile: |
| | | external-file: ./logs/sys-console.log |
| | | |
| | | --- # OSS äºåå¨(çé¢ <åæ°è®¾ç½®> å¯åæ¢) |
| | | cloud-storage: |
| | | # minioé
ç½® |
| | | minio: |
| | | endpoint: http://172.30.0.54:9000 |
| | | accessKey: ruoyi |
| | | secretKey: ruoyi123 |
| | | bucketName: ruoyi |
| | | # ä¸çäºé
ç½® |
| | | qiniu: |
| | | domain: http://XXX.XXXX.com |
| | | prefix: |
| | | accessKey: XXXXXXXXXXXXXXX |
| | | secretKey: XXXXXXXXXXXXXXX |
| | | bucketName: ruoyi |
| | | isHttps: false |
| | | # z0 åä¸ z1 åå z2 åå na0 åç¾ as0 ä¸åäº |
| | | # ä¸å¡«ä¸ºèªå¨è·å(æ§è½ä½ æåºé®é¢) |
| | | region: z0 |
| | | # é¿éäºé
ç½® |
| | | aliyun: |
| | | endpoint: http://oss-cn-beijing.aliyuncs.com |
| | | prefix: |
| | | accessKeyId: XXXXXXXXXXXXXXX |
| | | accessKeySecret: XXXXXXXXXXXXXXX |
| | | bucketName: ruoyi |
| | | # è
¾è®¯äºé
ç½® |
| | | qcloud: |
| | | endpoint: http://cos.ap-beijing.myqcloud.com |
| | | prefix: |
| | | secretId: XXXXXXXXXXXXXXX |
| | | secretKey: XXXXXXXXXXXXXXX |
| | | # è
¾è®¯äºbucketåè§å æ ¼å¼ä¸º BucketName-APPID æ¤å¤å¡«åçå卿¡¶åç§°å¿
é¡»ä¸ºæ¤æ ¼å¼ |
| | | bucketName: ruoyi-1250000000 |
| | | isHttps: false |
| | | # å°åååè宿¹ææ¡£ |
| | | # https://cloud.tencent.com/document/product/436/6224 |
| | | region: ap-beijing |
| | |
| | | copyrightYear: 2021 |
| | | # å®ä¾æ¼ç¤ºå¼å
³ |
| | | demoEnabled: true |
| | | # æä»¶è·¯å¾ |
| | | profile: ./ruoyi/uploadPath |
| | | # è·åipå°åå¼å
³ |
| | | addressEnabled: true |
| | | |
| | |
| | | # ä»¤çæææï¼é»è®¤30åéï¼ |
| | | expireTime: 30 |
| | | |
| | | # éå¤æäº¤ |
| | | repeat-submit: |
| | | # å
¨å±é´éæ¶é´(毫ç§) |
| | | intervalTime: 1000 |
| | | |
| | | # MyBatisPlusé
ç½® |
| | | # https://baomidou.com/config/ |
| | | mybatis-plus: |
| | |
| | | localCacheScope: SESSION |
| | | # å¼å¯Mybatisäºçº§ç¼åï¼é»è®¤ä¸º true |
| | | cacheEnabled: false |
| | | # æ´è¯¦ç»çæ¥å¿è¾åº 伿æ§è½æè |
| | | # logImpl: org.apache.ibatis.logging.stdout.StdOutImpl |
| | | # æ´è¯¦ç»çæ¥å¿è¾åº 伿æ§è½æè org.apache.ibatis.logging.stdout.StdOutImpl |
| | | # å
³éæ¥å¿è®°å½ (å¯åçº¯ä½¿ç¨ p6spy åæ) org.apache.ibatis.logging.nologging.NoLoggingImpl |
| | | # é»è®¤æ¥å¿è¾åº org.apache.ibatis.logging.slf4j.Slf4jImpl |
| | | logImpl: org.apache.ibatis.logging.nologging.NoLoggingImpl |
| | | global-config: |
| | | # æ¯å¦æå° Logo banner |
| | | banner: true |
| | |
| | | # è¿æ»¤å¼å
³ |
| | | enabled: true |
| | | # æé¤é¾æ¥ï¼å¤ä¸ªç¨éå·åéï¼ |
| | | excludes: /system/notice/* |
| | | excludes: /system/notice |
| | | # å¹é
龿¥ |
| | | urlPatterns: /system/*,/monitor/*,/tool/* |
| | | |
| | |
| | | # åå¸å¼éçè¶
æ¶æ¶é´ï¼é»è®¤ä¸º 30 æ¯«ç§ |
| | | expire: 30000 |
| | | |
| | | --- # Actuator çæ§ç«¯ç¹çé
置项 |
| | | management: |
| | | endpoints: |
| | | web: |
| | | # Actuator æä¾ç API æ¥å£çæ ¹ç®å½ãé»è®¤ä¸º /actuator |
| | | base-path: /actuator |
| | | exposure: |
| | | # éè¦å¼æ¾ç端ç¹ãé»è®¤å¼åªæå¼ health å info 两个端ç¹ãéè¿è®¾ç½® * ï¼å¯ä»¥å¼æ¾ææç«¯ç¹ã |
| | | # ç产ç¯å¢ä¸å»ºè®®æ¾å¼ææ æ ¹æ®é¡¹ç®éæ±æ¾å¼å³å¯ |
| | | include: @endpoints.include@ |
| | | endpoint: |
| | | logfile: |
| | | external-file: ./logs/sys-console.log |
| | | |
| | | --- # 宿¶ä»»å¡é
ç½® |
| | | spring: |
| | | quartz: |
| | |
| | | user.email.not.valid=é®ç®±æ ¼å¼é误 |
| | | user.mobile.phone.number.not.valid=ææºå·æ ¼å¼é误 |
| | | user.login.success=ç»å½æå |
| | | user.register.success=注åæå |
| | | user.notfound=è¯·éæ°ç»å½ |
| | | user.forcelogout=管çå强å¶éåºï¼è¯·éæ°ç»å½ |
| | | user.unknown.error=æªç¥é误ï¼è¯·éæ°ç»å½ |
| | |
| | | user.email.not.valid= |
| | | user.mobile.phone.number.not.valid= |
| | | user.login.success= |
| | | user.register.success=register success |
| | | user.notfound= |
| | | user.forcelogout= |
| | | user.unknown.error= |
| | | |
| | | ##æä»¶ä¸ä¼ æ¶æ¯ |
| | |
| | | user.email.not.valid=é®ç®±æ ¼å¼é误 |
| | | user.mobile.phone.number.not.valid=ææºå·æ ¼å¼é误 |
| | | user.login.success=ç»å½æå |
| | | user.register.success=注åæå |
| | | user.notfound=è¯·éæ°ç»å½ |
| | | user.forcelogout=管çå强å¶éåºï¼è¯·éæ°ç»å½ |
| | | user.unknown.error=æªç¥é误ï¼è¯·éæ°ç»å½ |
¶Ô±ÈÐÂÎļþ |
| | |
| | | # p6spy æ§è½åææä»¶é
ç½®æä»¶ |
| | | modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory |
| | | # èªå®ä¹æ¥å¿æå° |
| | | logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger |
| | | #æ¥å¿è¾åºå°æ§å¶å° |
| | | appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger |
| | | # ä½¿ç¨æ¥å¿ç³»ç»è®°å½ sql |
| | | #appender=com.p6spy.engine.spy.appender.Slf4JLogger |
| | | # 设置 p6spy driver 代ç |
| | | #deregisterdrivers=true |
| | | # åæ¶JDBC URLåç¼ |
| | | useprefix=true |
| | | # é
ç½®è®°å½ Log ä¾å¤,å¯å»æçç»æéæerror,info,batch,debug,statement,commit,rollback,result,resultset. |
| | | excludecategories=info,debug,result,commit,resultset |
| | | # æ¥ææ ¼å¼ |
| | | dateformat=yyyy-MM-dd HH:mm:ss |
| | | # å®é
驱å¨å¯å¤ä¸ª |
| | | #driverlist=org.h2.Driver |
| | | # æ¯å¦å¼å¯æ
¢SQLè®°å½ |
| | | outagedetection=true |
| | | # æ
¢SQLè®°å½æ å 2 ç§ |
| | | outagedetectioninterval=2 |
| | | # æ¯å¦è¿æ»¤ Log |
| | | filter=true |
| | | # è¿æ»¤ Log æ¶ææé¤ç表åå表ï¼ä»¥éå·åé |
| | | exclude=QRTZ_ |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.6.0</version> |
| | | <version>3.0.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi-ooxml</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>easyexcel</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- ymlè§£æå¨ --> |
| | |
| | | <groupId>com.baomidou</groupId> |
| | | <artifactId>dynamic-datasource-spring-boot-starter</artifactId> |
| | | </dependency> |
| | | <!-- sqlæ§è½åææä»¶ --> |
| | | <dependency> |
| | | <groupId>p6spy</groupId> |
| | | <artifactId>p6spy</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.baomidou</groupId> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.annotation; |
| | | |
| | | import java.lang.annotation.*; |
| | | |
| | | /** |
| | | * åå
¸æ ¼å¼å |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Target({ElementType.FIELD}) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Inherited |
| | | public @interface ExcelDictFormat { |
| | | |
| | | /** |
| | | * 妿æ¯åå
¸ç±»åï¼è¯·è®¾ç½®åå
¸çtypeå¼ (å¦: sys_user_sex) |
| | | */ |
| | | String dictType() default ""; |
| | | |
| | | /** |
| | | * 读åå
å®¹è½¬è¡¨è¾¾å¼ (å¦: 0=ç·,1=女,2=æªç¥) |
| | | */ |
| | | String readConverterExp() default ""; |
| | | |
| | | /** |
| | | * åé符ï¼è¯»åå符串ç»å
容 |
| | | */ |
| | | String separator() default ","; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.Constants;
|
| | | import com.ruoyi.common.enums.LimitType;
|
| | |
|
| | | /**
|
| | | * éæµæ³¨è§£
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @Target(ElementType.METHOD)
|
| | | @Retention(RetentionPolicy.RUNTIME)
|
| | | @Documented
|
| | | public @interface RateLimiter
|
| | | {
|
| | | /**
|
| | | * éæµkey
|
| | | */
|
| | | public String key() default Constants.RATE_LIMIT_KEY;
|
| | |
|
| | | /**
|
| | | * éæµæ¶é´,åä½ç§
|
| | | */
|
| | | public int time() default 60;
|
| | |
|
| | | /**
|
| | | * éæµæ¬¡æ°
|
| | | */
|
| | | public int count() default 100;
|
| | |
|
| | | /**
|
| | | * éæµç±»å
|
| | | */
|
| | | public LimitType limitType() default LimitType.DEFAULT;
|
| | | }
|
| | |
| | | import java.lang.annotation.Retention;
|
| | | import java.lang.annotation.RetentionPolicy;
|
| | | import java.lang.annotation.Target;
|
| | | import java.util.concurrent.TimeUnit; |
| | |
|
| | | /**
|
| | | * èªå®ä¹æ³¨è§£é²æ¢è¡¨åéå¤æäº¤
|
| | | *
|
| | | * @author ruoyi
|
| | | *
|
| | | * @author Lion Li |
| | | */
|
| | | @Inherited
|
| | | @Target(ElementType.METHOD)
|
| | | @Retention(RetentionPolicy.RUNTIME)
|
| | | @Documented
|
| | | public @interface RepeatSubmit
|
| | | {
|
| | | public @interface RepeatSubmit { |
| | | |
| | | /** |
| | | * é»è®¤ä½¿ç¨å
¨å±é
ç½® |
| | | */ |
| | | int intervalTime() default 0; |
| | | |
| | | TimeUnit timeUnit() default TimeUnit.MILLISECONDS; |
| | |
|
| | | }
|
| | |
| | | /** å®ä¾æ¼ç¤ºå¼å
³ */ |
| | | private boolean demoEnabled; |
| | | |
| | | /** ä¸ä¼ è·¯å¾ */ |
| | | @Getter |
| | | private static String profile; |
| | | |
| | | /** è·åå°åå¼å
³ */ |
| | | @Getter |
| | | private static boolean addressEnabled; |
| | | |
| | | public void setProfile(String profile) |
| | | { |
| | | RuoYiConfig.profile = profile; |
| | | } |
| | | |
| | | public void setAddressEnabled(boolean addressEnabled) |
| | | { |
| | | RuoYiConfig.addressEnabled = addressEnabled; |
| | | } |
| | | |
| | | /** |
| | | * è·å头åä¸ä¼ è·¯å¾ |
| | | */ |
| | | public static String getAvatarPath() |
| | | { |
| | | return getProfile() + "/avatar"; |
| | | } |
| | | |
| | | /** |
| | | * è·åä¸è½½è·¯å¾ |
| | | */ |
| | | public static String getDownloadPath() |
| | | { |
| | | return getProfile() + "/download/"; |
| | | } |
| | | |
| | | /** |
| | | * è·åä¸ä¼ è·¯å¾ |
| | | */ |
| | | public static String getUploadPath() |
| | | { |
| | | return getProfile() + "/upload"; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.common.constant; |
| | | |
| | | import io.jsonwebtoken.Claims; |
| | | |
| | | /** |
| | | * éç¨å¸¸éä¿¡æ¯ |
| | | * |
| | |
| | | public static final String LOGOUT = "Logout"; |
| | | |
| | | /** |
| | | * 注å |
| | | */ |
| | | public static final String REGISTER = "Register"; |
| | | |
| | | /** |
| | | * ç»å½å¤±è´¥ |
| | | */ |
| | | public static final String LOGIN_FAIL = "Error"; |
| | |
| | | * é²éæäº¤ redis key |
| | | */ |
| | | public static final String REPEAT_SUBMIT_KEY = "repeat_submit:"; |
| | | |
| | | /** |
| | | * éæµ redis key |
| | | */ |
| | | public static final String RATE_LIMIT_KEY = "rate_limit:"; |
| | | |
| | | /** |
| | | * éªè¯ç æææï¼åéï¼ |
| | |
| | | /** |
| | | * ç¨æ·åç§° |
| | | */ |
| | | public static final String JWT_USERNAME = "sub"; |
| | | public static final String JWT_USERNAME = Claims.SUBJECT; |
| | | |
| | | /** |
| | | * ç¨æ·å¤´å |
| | |
| | | public static final String SYS_DICT_KEY = "sys_dict:"; |
| | | |
| | | /** |
| | | * èµæºæ å°è·¯å¾ åç¼ |
| | | */ |
| | | public static final String RESOURCE_PREFIX = "/profile"; |
| | | |
| | | /** |
| | | * RMI è¿ç¨æ¹æ³è°ç¨ |
| | | */ |
| | | public static final String LOOKUP_RMI = "rmi://"; |
| | | |
| | | /** |
| | | * èµæºæ å°è·¯å¾ åç¼ |
| | | */ |
| | | public static final String REDIS_LOCK_KEY = "redis_lock:"; |
| | | } |
| | |
| | | /** æ ¡éªè¿åç»æç */ |
| | | public final static String UNIQUE = "0"; |
| | | public final static String NOT_UNIQUE = "1"; |
| | | |
| | | /** |
| | | * ç¨æ·åé¿åº¦éå¶ |
| | | */ |
| | | 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; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.convert; |
| | | |
| | | import cn.hutool.core.annotation.AnnotationUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.alibaba.excel.converters.Converter; |
| | | import com.alibaba.excel.enums.CellDataTypeEnum; |
| | | import com.alibaba.excel.metadata.CellData; |
| | | import com.alibaba.excel.metadata.GlobalConfiguration; |
| | | import com.alibaba.excel.metadata.property.ExcelContentProperty; |
| | | import com.ruoyi.common.annotation.ExcelDictFormat; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.lang.reflect.Field; |
| | | |
| | | /** |
| | | * åå
¸æ ¼å¼å转æ¢å¤ç |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | public class ExcelDictConvert implements Converter<Object> { |
| | | |
| | | @Override |
| | | public Class<Object> supportJavaTypeKey() { |
| | | return Object.class; |
| | | } |
| | | |
| | | @Override |
| | | public CellDataTypeEnum supportExcelTypeKey() { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public Object convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { |
| | | ExcelDictFormat anno = getAnnotation(contentProperty.getField()); |
| | | String type = anno.dictType(); |
| | | String label = cellData.getStringValue(); |
| | | String value; |
| | | if (StringUtils.isBlank(type)) { |
| | | value = ExcelUtil.reverseByExp(label, anno.readConverterExp(), anno.separator()); |
| | | } else { |
| | | value = ExcelUtil.reverseDictByExp(label, type, anno.separator()); |
| | | } |
| | | return Convert.convert(contentProperty.getField().getType(), value); |
| | | } |
| | | |
| | | @Override |
| | | public CellData<String> convertToExcelData(Object object, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { |
| | | if (StringUtils.isNull(object)) { |
| | | return new CellData<>(""); |
| | | } |
| | | ExcelDictFormat anno = getAnnotation(contentProperty.getField()); |
| | | String type = anno.dictType(); |
| | | String value = Convert.toStr(object); |
| | | String label; |
| | | if (StringUtils.isBlank(type)) { |
| | | label = ExcelUtil.convertByExp(value, anno.readConverterExp(), anno.separator()); |
| | | } else { |
| | | label = ExcelUtil.convertDictByExp(value, type, anno.separator()); |
| | | } |
| | | return new CellData<>(label); |
| | | } |
| | | |
| | | private ExcelDictFormat getAnnotation(Field field) { |
| | | return AnnotationUtil.getAnnotation(field, ExcelDictFormat.class); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.common.core.controller; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | |
| | | */ |
| | | public String redirect(String url) |
| | | { |
| | | return StrUtil.format("redirect:{}", 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(); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.common.core.domain; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | |
| | | @Data |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | public class BaseEntity implements Serializable |
| | | { |
| | | public class BaseEntity implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** æç´¢å¼ */ |
| | | /** |
| | | * æç´¢å¼ |
| | | */ |
| | | @ApiModelProperty(value = "æç´¢å¼") |
| | | private String searchValue; |
| | | |
| | | /** å建è
*/ |
| | | /** |
| | | * å建è
|
| | | */ |
| | | @ApiModelProperty(value = "å建è
") |
| | | private String createBy; |
| | | |
| | | /** å建æ¶é´ */ |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @ApiModelProperty(value = "å建æ¶é´") |
| | | private Date createTime; |
| | | |
| | | /** æ´æ°è
*/ |
| | | /** |
| | | * æ´æ°è
|
| | | */ |
| | | @ApiModelProperty(value = "æ´æ°è
") |
| | | private String updateBy; |
| | | |
| | | /** æ´æ°æ¶é´ */ |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @ApiModelProperty(value = "æ´æ°æ¶é´") |
| | | private Date updateTime; |
| | | |
| | | /** 夿³¨ */ |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | @ApiModelProperty(value = "夿³¨") |
| | | private String remark; |
| | | |
| | | /** 请æ±åæ° */ |
| | | /** |
| | | * 请æ±åæ° |
| | | */ |
| | | @ApiModelProperty(value = "请æ±åæ°") |
| | | private Map<String, Object> params = new HashMap<>(); |
| | | |
| | | } |
| | |
| | | package com.ruoyi.common.core.domain;
|
| | |
|
| | | import lombok.*;
|
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors;
|
| | |
|
| | | import java.util.ArrayList;
|
| | |
| | | @Data
|
| | | @NoArgsConstructor
|
| | | @Accessors(chain = true)
|
| | | public class TreeEntity extends BaseEntity
|
| | | {
|
| | | public class TreeEntity extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | /** ç¶èååç§° */
|
| | | /** |
| | | * ç¶èååç§° |
| | | */ |
| | | @ApiModelProperty(value = "ç¶èååç§°") |
| | | private String parentName;
|
| | |
|
| | | /** ç¶èåID */
|
| | | /** |
| | | * ç¶èåID |
| | | */ |
| | | @ApiModelProperty(value = "ç¶èåID") |
| | | private Long parentId;
|
| | |
|
| | | /** æ¾ç¤ºé¡ºåº */
|
| | | /** |
| | | * æ¾ç¤ºé¡ºåº |
| | | */ |
| | | @ApiModelProperty(value = "æ¾ç¤ºé¡ºåº") |
| | | private Integer orderNum;
|
| | |
|
| | | /** ç¥çº§å表 */
|
| | | /** |
| | | * ç¥çº§å表 |
| | | */ |
| | | @ApiModelProperty(value = "ç¥çº§å表") |
| | | private String ancestors;
|
| | |
|
| | | /** åé¨é¨ */
|
| | | /** |
| | | * åé¨é¨ |
| | | */ |
| | | @ApiModelProperty(value = "åé¨é¨") |
| | | private List<?> children = new ArrayList<>();
|
| | |
|
| | | }
|
| | |
| | | package com.ruoyi.common.core.domain.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | @TableName("sys_dept") |
| | | public class SysDept implements Serializable |
| | | { |
| | | public class SysDept implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** é¨é¨ID */ |
| | | /** |
| | | * é¨é¨ID |
| | | */ |
| | | @TableId(value = "dept_id",type = IdType.AUTO) |
| | | private Long deptId; |
| | | |
| | | /** ç¶é¨é¨ID */ |
| | | /** |
| | | * ç¶é¨é¨ID |
| | | */ |
| | | private Long parentId; |
| | | |
| | | /** ç¥çº§å表 */ |
| | | /** |
| | | * ç¥çº§å表 |
| | | */ |
| | | private String ancestors; |
| | | |
| | | /** é¨é¨åç§° */ |
| | | /** |
| | | * é¨é¨åç§° |
| | | */ |
| | | @NotBlank(message = "é¨é¨åç§°ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 30, message = "é¨é¨åç§°é¿åº¦ä¸è½è¶
è¿30个å符") |
| | | private String deptName; |
| | | |
| | | /** æ¾ç¤ºé¡ºåº */ |
| | | /** |
| | | * æ¾ç¤ºé¡ºåº |
| | | */ |
| | | @NotBlank(message = "æ¾ç¤ºé¡ºåºä¸è½ä¸ºç©º") |
| | | private String orderNum; |
| | | |
| | | /** è´è´£äºº */ |
| | | /** |
| | | * è´è´£äºº |
| | | */ |
| | | private String leader; |
| | | |
| | | /** èç³»çµè¯ */ |
| | | /** |
| | | * èç³»çµè¯ |
| | | */ |
| | | @Size(min = 0, max = 11, message = "èç³»çµè¯é¿åº¦ä¸è½è¶
è¿11个å符") |
| | | private String phone; |
| | | |
| | | /** é®ç®± */ |
| | | /** |
| | | * é®ç®± |
| | | */ |
| | | @Email(message = "é®ç®±æ ¼å¼ä¸æ£ç¡®") |
| | | @Size(min = 0, max = 50, message = "é®ç®±é¿åº¦ä¸è½è¶
è¿50个å符") |
| | | private String email; |
| | | |
| | | /** é¨é¨ç¶æ:0æ£å¸¸,1åç¨ */ |
| | | /** |
| | | * é¨é¨ç¶æ:0æ£å¸¸,1åç¨ |
| | | */ |
| | | private String status; |
| | | |
| | | /** å 餿 å¿ï¼0代表åå¨ 2代表å é¤ï¼ */ |
| | | /** |
| | | * å 餿 å¿ï¼0代表åå¨ 2代表å é¤ï¼ |
| | | */ |
| | | @TableLogic |
| | | private String delFlag; |
| | | |
| | | /** ç¶é¨é¨åç§° */ |
| | | /** |
| | | * ç¶é¨é¨åç§° |
| | | */ |
| | | @TableField(exist = false) |
| | | private String parentName; |
| | | |
| | | /** å建è
*/ |
| | | /** |
| | | * å建è
|
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | /** å建æ¶é´ */ |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** æ´æ°è
*/ |
| | | /** |
| | | * æ´æ°è
|
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | /** æ´æ°æ¶é´ */ |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | /** åé¨é¨ */ |
| | | /** |
| | | * åé¨é¨ |
| | | */ |
| | | @TableField(exist = false) |
| | | private List<SysDept> children = new ArrayList<SysDept>(); |
| | | |
| | |
| | | package com.ruoyi.common.core.domain.entity; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.ruoyi.common.annotation.Excel.ColumnType; |
| | | import com.ruoyi.common.annotation.ExcelDictFormat; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.convert.ExcelDictConvert; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | @TableName("sys_dict_data") |
| | | public class SysDictData implements Serializable |
| | | { |
| | | @ExcelIgnoreUnannotated |
| | | public class SysDictData implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** åå
¸ç¼ç */ |
| | | @Excel(name = "åå
¸ç¼ç ", cellType = ColumnType.NUMERIC) |
| | | /** |
| | | * åå
¸ç¼ç |
| | | */ |
| | | @ExcelProperty(value = "åå
¸ç¼ç ") |
| | | @TableId(value = "dict_code",type = IdType.AUTO) |
| | | private Long dictCode; |
| | | |
| | | /** åå
¸æåº */ |
| | | @Excel(name = "åå
¸æåº", cellType = ColumnType.NUMERIC) |
| | | /** |
| | | * åå
¸æåº |
| | | */ |
| | | @ExcelProperty(value = "åå
¸æåº") |
| | | private Long dictSort; |
| | | |
| | | /** åå
¸æ ç¾ */ |
| | | @Excel(name = "åå
¸æ ç¾") |
| | | /** |
| | | * åå
¸æ ç¾ |
| | | */ |
| | | @ExcelProperty(value = "åå
¸æ ç¾") |
| | | @NotBlank(message = "åå
¸æ ç¾ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 100, message = "åå
¸æ ç¾é¿åº¦ä¸è½è¶
è¿100个å符") |
| | | private String dictLabel; |
| | | |
| | | /** åå
¸é®å¼ */ |
| | | @Excel(name = "åå
¸é®å¼") |
| | | /** |
| | | * åå
¸é®å¼ |
| | | */ |
| | | @ExcelProperty(value = "åå
¸é®å¼") |
| | | @NotBlank(message = "åå
¸é®å¼ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 100, message = "åå
¸é®å¼é¿åº¦ä¸è½è¶
è¿100个å符") |
| | | private String dictValue; |
| | | |
| | | /** åå
¸ç±»å */ |
| | | @Excel(name = "åå
¸ç±»å") |
| | | /** |
| | | * åå
¸ç±»å |
| | | */ |
| | | @ExcelProperty(value = "åå
¸ç±»å") |
| | | @NotBlank(message = "åå
¸ç±»åä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 100, message = "åå
¸ç±»åé¿åº¦ä¸è½è¶
è¿100个å符") |
| | | private String dictType; |
| | | |
| | | /** æ ·å¼å±æ§ï¼å
¶ä»æ ·å¼æ©å±ï¼ */ |
| | | /** |
| | | * æ ·å¼å±æ§ï¼å
¶ä»æ ·å¼æ©å±ï¼ |
| | | */ |
| | | @Size(min = 0, max = 100, message = "æ ·å¼å±æ§é¿åº¦ä¸è½è¶
è¿100个å符") |
| | | private String cssClass; |
| | | |
| | | /** è¡¨æ ¼åå
¸æ ·å¼ */ |
| | | /** |
| | | * è¡¨æ ¼åå
¸æ ·å¼ |
| | | */ |
| | | private String listClass; |
| | | |
| | | /** æ¯å¦é»è®¤ï¼Yæ¯ Nå¦ï¼ */ |
| | | @Excel(name = "æ¯å¦é»è®¤", readConverterExp = "Y=æ¯,N=å¦") |
| | | /** |
| | | * æ¯å¦é»è®¤ï¼Yæ¯ Nå¦ï¼ |
| | | */ |
| | | @ExcelProperty(value = "æ¯å¦é»è®¤", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_yes_no") |
| | | private String isDefault; |
| | | |
| | | /** ç¶æï¼0æ£å¸¸ 1åç¨ï¼ */ |
| | | @Excel(name = "ç¶æ", readConverterExp = "0=æ£å¸¸,1=åç¨") |
| | | /** |
| | | * ç¶æï¼0æ£å¸¸ 1åç¨ï¼ |
| | | */ |
| | | @ExcelProperty(value = "ç¶æ", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_common_status") |
| | | private String status; |
| | | |
| | | /** å建è
*/ |
| | | /** |
| | | * å建è
|
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | /** å建æ¶é´ */ |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** æ´æ°è
*/ |
| | | /** |
| | | * æ´æ°è
|
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | /** æ´æ°æ¶é´ */ |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | /** 夿³¨ */ |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | |
| | | @TableField(exist = false) |
| | | private Map<String, Object> params = new HashMap<>(); |
| | | |
| | | public boolean getDefault() |
| | | { |
| | | public boolean getDefault() { |
| | | return UserConstants.YES.equals(this.isDefault) ? true : false; |
| | | } |
| | | |
| | |
| | | package com.ruoyi.common.core.domain.entity; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.ruoyi.common.annotation.Excel.ColumnType; |
| | | import com.ruoyi.common.annotation.ExcelDictFormat; |
| | | import com.ruoyi.common.convert.ExcelDictConvert; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | @TableName("sys_dict_type") |
| | | public class SysDictType implements Serializable |
| | | { |
| | | @ExcelIgnoreUnannotated |
| | | public class SysDictType implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** åå
¸ä¸»é® */ |
| | | @Excel(name = "åå
¸ä¸»é®", cellType = ColumnType.NUMERIC) |
| | | /** |
| | | * åå
¸ä¸»é® |
| | | */ |
| | | @ExcelProperty(value = "åå
¸ä¸»é®") |
| | | @TableId(value = "dict_id",type = IdType.AUTO) |
| | | private Long dictId; |
| | | |
| | | /** åå
¸åç§° */ |
| | | @Excel(name = "åå
¸åç§°") |
| | | /** |
| | | * åå
¸åç§° |
| | | */ |
| | | @ExcelProperty(value = "åå
¸åç§°") |
| | | @NotBlank(message = "åå
¸åç§°ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 100, message = "åå
¸ç±»ååç§°é¿åº¦ä¸è½è¶
è¿100个å符") |
| | | private String dictName; |
| | | |
| | | /** åå
¸ç±»å */ |
| | | @Excel(name = "åå
¸ç±»å") |
| | | /** |
| | | * åå
¸ç±»å |
| | | */ |
| | | @ExcelProperty(value = "åå
¸ç±»å") |
| | | @NotBlank(message = "åå
¸ç±»åä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 100, message = "åå
¸ç±»åç±»åé¿åº¦ä¸è½è¶
è¿100个å符") |
| | | private String dictType; |
| | | |
| | | /** ç¶æï¼0æ£å¸¸ 1åç¨ï¼ */ |
| | | @Excel(name = "ç¶æ", readConverterExp = "0=æ£å¸¸,1=åç¨") |
| | | /** |
| | | * ç¶æï¼0æ£å¸¸ 1åç¨ï¼ |
| | | */ |
| | | @ExcelProperty(value = "ç¶æ", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_common_status") |
| | | private String status; |
| | | |
| | | /** å建è
*/ |
| | | /** |
| | | * å建è
|
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | /** å建æ¶é´ */ |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** æ´æ°è
*/ |
| | | /** |
| | | * æ´æ°è
|
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | /** æ´æ°æ¶é´ */ |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | /** 夿³¨ */ |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | @TableName("sys_menu") |
| | | public class SysMenu implements Serializable |
| | | { |
| | | public class SysMenu implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** èåID */ |
| | | /** |
| | | * èåID |
| | | */ |
| | | @TableId(value = "menu_id",type = IdType.AUTO) |
| | | private Long menuId; |
| | | |
| | | /** èååç§° */ |
| | | /** |
| | | * èååç§° |
| | | */ |
| | | @NotBlank(message = "èååç§°ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 50, message = "èååç§°é¿åº¦ä¸è½è¶
è¿50个å符") |
| | | private String menuName; |
| | | |
| | | /** ç¶èååç§° */ |
| | | /** |
| | | * ç¶èååç§° |
| | | */ |
| | | @TableField(exist = false) |
| | | private String parentName; |
| | | |
| | | /** ç¶èåID */ |
| | | /** |
| | | * ç¶èåID |
| | | */ |
| | | private Long parentId; |
| | | |
| | | /** æ¾ç¤ºé¡ºåº */ |
| | | /** |
| | | * æ¾ç¤ºé¡ºåº |
| | | */ |
| | | @NotBlank(message = "æ¾ç¤ºé¡ºåºä¸è½ä¸ºç©º") |
| | | private String orderNum; |
| | | |
| | | /** è·¯ç±å°å */ |
| | | /** |
| | | * è·¯ç±å°å |
| | | */ |
| | | @Size(min = 0, max = 200, message = "è·¯ç±å°åä¸è½è¶
è¿200个å符") |
| | | private String path; |
| | | |
| | | /** ç»ä»¶è·¯å¾ */ |
| | | /** |
| | | * ç»ä»¶è·¯å¾ |
| | | */ |
| | | @Size(min = 0, max = 200, message = "ç»ä»¶è·¯å¾ä¸è½è¶
è¿255个å符") |
| | | private String component; |
| | | |
| | | /** æ¯å¦ä¸ºå¤é¾ï¼0æ¯ 1å¦ï¼ */ |
| | | /** |
| | | * æ¯å¦ä¸ºå¤é¾ï¼0æ¯ 1å¦ï¼ |
| | | */ |
| | | private String isFrame; |
| | | |
| | | /** æ¯å¦ç¼åï¼0ç¼å 1ä¸ç¼åï¼ */ |
| | | /** |
| | | * æ¯å¦ç¼åï¼0ç¼å 1ä¸ç¼åï¼ |
| | | */ |
| | | private String isCache; |
| | | |
| | | /** ç±»åï¼Mç®å½ Cèå Fæé®ï¼ */ |
| | | /** |
| | | * ç±»åï¼Mç®å½ Cèå Fæé®ï¼ |
| | | */ |
| | | @NotBlank(message = "èåç±»åä¸è½ä¸ºç©º") |
| | | private String menuType; |
| | | |
| | | /** æ¾ç¤ºç¶æï¼0æ¾ç¤º 1éèï¼ */ |
| | | /** |
| | | * æ¾ç¤ºç¶æï¼0æ¾ç¤º 1éèï¼ |
| | | */ |
| | | private String visible; |
| | | |
| | | /** èåç¶æï¼0æ¾ç¤º 1éèï¼ */ |
| | | /** |
| | | * èåç¶æï¼0æ¾ç¤º 1éèï¼ |
| | | */ |
| | | private String status; |
| | | |
| | | /** æéå符串 */ |
| | | /** |
| | | * æéå符串 |
| | | */ |
| | | @Size(min = 0, max = 100, message = "æéæ è¯é¿åº¦ä¸è½è¶
è¿100个å符") |
| | | private String perms; |
| | | |
| | | /** èå徿 */ |
| | | /** |
| | | * èå徿 |
| | | */ |
| | | private String icon; |
| | | |
| | | /** å建è
*/ |
| | | /** |
| | | * å建è
|
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | /** å建æ¶é´ */ |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** æ´æ°è
*/ |
| | | /** |
| | | * æ´æ°è
|
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | /** æ´æ°æ¶é´ */ |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | /** 夿³¨ */ |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | private String remark; |
| | | |
| | | /** 请æ±åæ° */ |
| | | /** |
| | | * 请æ±åæ° |
| | | */ |
| | | @TableField(exist = false) |
| | | private Map<String, Object> params = new HashMap<>(); |
| | | |
| | | /** åèå */ |
| | | /** |
| | | * åèå |
| | | */ |
| | | @TableField(exist = false) |
| | | private List<SysMenu> children = new ArrayList<SysMenu>(); |
| | | |
| | |
| | | package com.ruoyi.common.core.domain.entity; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.ruoyi.common.annotation.Excel.ColumnType; |
| | | import com.ruoyi.common.annotation.ExcelDictFormat; |
| | | import com.ruoyi.common.convert.ExcelDictConvert; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | @TableName("sys_role") |
| | | public class SysRole implements Serializable |
| | | { |
| | | @ExcelIgnoreUnannotated |
| | | public class SysRole implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** è§è²ID */ |
| | | @Excel(name = "è§è²åºå·", cellType = ColumnType.NUMERIC) |
| | | /** |
| | | * è§è²ID |
| | | */ |
| | | @ExcelProperty(value = "è§è²åºå·") |
| | | @TableId(value = "role_id",type = IdType.AUTO) |
| | | private Long roleId; |
| | | |
| | | /** è§è²åç§° */ |
| | | @Excel(name = "è§è²åç§°") |
| | | /** |
| | | * è§è²åç§° |
| | | */ |
| | | @ExcelProperty(value = "è§è²åç§°") |
| | | @NotBlank(message = "è§è²åç§°ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 30, message = "è§è²åç§°é¿åº¦ä¸è½è¶
è¿30个å符") |
| | | private String roleName; |
| | | |
| | | /** è§è²æé */ |
| | | @Excel(name = "è§è²æé") |
| | | /** |
| | | * è§è²æé |
| | | */ |
| | | @ExcelProperty(value = "è§è²æé") |
| | | @NotBlank(message = "æéå符ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 100, message = "æéå符é¿åº¦ä¸è½è¶
è¿100个å符") |
| | | private String roleKey; |
| | | |
| | | /** è§è²æåº */ |
| | | @Excel(name = "è§è²æåº") |
| | | /** |
| | | * è§è²æåº |
| | | */ |
| | | @ExcelProperty(value = "è§è²æåº") |
| | | @NotBlank(message = "æ¾ç¤ºé¡ºåºä¸è½ä¸ºç©º") |
| | | private String roleSort; |
| | | |
| | | /** æ°æ®èå´ï¼1ï¼æææ°æ®æéï¼2ï¼èªå®ä¹æ°æ®æéï¼3ï¼æ¬é¨é¨æ°æ®æéï¼4ï¼æ¬é¨é¨å以䏿°æ®æéï¼5ï¼ä»
æ¬äººæ°æ®æéï¼ */ |
| | | @Excel(name = "æ°æ®èå´", readConverterExp = "1=æææ°æ®æé,2=èªå®ä¹æ°æ®æé,3=æ¬é¨é¨æ°æ®æé,4=æ¬é¨é¨å以䏿°æ®æé,5=ä»
æ¬äººæ°æ®æé") |
| | | /** |
| | | * æ°æ®èå´ï¼1ï¼æææ°æ®æéï¼2ï¼èªå®ä¹æ°æ®æéï¼3ï¼æ¬é¨é¨æ°æ®æéï¼4ï¼æ¬é¨é¨å以䏿°æ®æéï¼5ï¼ä»
æ¬äººæ°æ®æéï¼ |
| | | */ |
| | | @ExcelProperty(value = "æ°æ®èå´", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(readConverterExp = "1=æææ°æ®æé,2=èªå®ä¹æ°æ®æé,3=æ¬é¨é¨æ°æ®æé,4=æ¬é¨é¨å以䏿°æ®æé,5=ä»
æ¬äººæ°æ®æé") |
| | | private String dataScope; |
| | | |
| | | /** èåæ éæ©é¡¹æ¯å¦å
³èæ¾ç¤ºï¼ 0ï¼ç¶åä¸äºç¸å
³èæ¾ç¤º 1ï¼ç¶åäºç¸å
³èæ¾ç¤ºï¼ */ |
| | | /** |
| | | * èåæ éæ©é¡¹æ¯å¦å
³èæ¾ç¤ºï¼ 0ï¼ç¶åä¸äºç¸å
³èæ¾ç¤º 1ï¼ç¶åäºç¸å
³èæ¾ç¤ºï¼ |
| | | */ |
| | | private boolean menuCheckStrictly; |
| | | |
| | | /** é¨é¨æ 鿩项æ¯å¦å
³èæ¾ç¤ºï¼0ï¼ç¶åä¸äºç¸å
³èæ¾ç¤º 1ï¼ç¶åäºç¸å
³èæ¾ç¤º ï¼ */ |
| | | /** |
| | | * é¨é¨æ 鿩项æ¯å¦å
³èæ¾ç¤ºï¼0ï¼ç¶åä¸äºç¸å
³èæ¾ç¤º 1ï¼ç¶åäºç¸å
³èæ¾ç¤º ï¼ |
| | | */ |
| | | private boolean deptCheckStrictly; |
| | | |
| | | /** è§è²ç¶æï¼0æ£å¸¸ 1åç¨ï¼ */ |
| | | @Excel(name = "è§è²ç¶æ", readConverterExp = "0=æ£å¸¸,1=åç¨") |
| | | /** |
| | | * è§è²ç¶æï¼0æ£å¸¸ 1åç¨ï¼ |
| | | */ |
| | | @ExcelProperty(value = "è§è²ç¶æ", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_common_status") |
| | | private String status; |
| | | |
| | | /** å 餿 å¿ï¼0代表åå¨ 2代表å é¤ï¼ */ |
| | | /** |
| | | * å 餿 å¿ï¼0代表åå¨ 2代表å é¤ï¼ |
| | | */ |
| | | @TableLogic |
| | | private String delFlag; |
| | | |
| | | /** å建è
*/ |
| | | /** |
| | | * å建è
|
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | /** å建æ¶é´ */ |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** æ´æ°è
*/ |
| | | /** |
| | | * æ´æ°è
|
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | /** æ´æ°æ¶é´ */ |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | /** 夿³¨ */ |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | |
| | | @TableField(exist = false) |
| | | private Map<String, Object> params = new HashMap<>(); |
| | | |
| | | /** ç¨æ·æ¯å¦å卿¤è§è²æ è¯ é»è®¤ä¸åå¨ */ |
| | | /** |
| | | * ç¨æ·æ¯å¦å卿¤è§è²æ è¯ é»è®¤ä¸åå¨ |
| | | */ |
| | | @TableField(exist = false) |
| | | private boolean flag = false; |
| | | |
| | | /** èåç» */ |
| | | /** |
| | | * èåç» |
| | | */ |
| | | @TableField(exist = false) |
| | | private Long[] menuIds; |
| | | |
| | | /** é¨é¨ç»ï¼æ°æ®æéï¼ */ |
| | | /** |
| | | * é¨é¨ç»ï¼æ°æ®æéï¼ |
| | | */ |
| | | @TableField(exist = false) |
| | | private Long[] deptIds; |
| | | |
| | | public SysRole(Long roleId) |
| | | { |
| | | public SysRole(Long roleId) { |
| | | this.roleId = roleId; |
| | | } |
| | | |
| | | public boolean isAdmin() |
| | | { |
| | | public boolean isAdmin() { |
| | | return isAdmin(this.roleId); |
| | | } |
| | | |
| | | public static boolean isAdmin(Long roleId) |
| | | { |
| | | public static boolean isAdmin(Long roleId) { |
| | | return roleId != null && 1L == roleId; |
| | | } |
| | | |
| | |
| | | package com.ruoyi.common.core.domain.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import com.fasterxml.jackson.annotation.JsonProperty; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.ruoyi.common.annotation.Excel.ColumnType; |
| | | import com.ruoyi.common.annotation.Excel.Type; |
| | | import com.ruoyi.common.annotation.Excels; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | @TableName("sys_user") |
| | | public class SysUser implements Serializable |
| | | { |
| | | public class SysUser implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** ç¨æ·ID */ |
| | | @Excel(name = "ç¨æ·åºå·", cellType = ColumnType.NUMERIC, prompt = "ç¨æ·ç¼å·") |
| | | /** |
| | | * ç¨æ·ID |
| | | */ |
| | | @TableId(value = "user_id",type = IdType.AUTO) |
| | | private Long userId; |
| | | |
| | | /** é¨é¨ID */ |
| | | @Excel(name = "é¨é¨ç¼å·", type = Type.IMPORT) |
| | | /** |
| | | * é¨é¨ID |
| | | */ |
| | | private Long deptId; |
| | | |
| | | /** ç¨æ·è´¦å· */ |
| | | /** |
| | | * ç¨æ·è´¦å· |
| | | */ |
| | | @NotBlank(message = "ç¨æ·è´¦å·ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 30, message = "ç¨æ·è´¦å·é¿åº¦ä¸è½è¶
è¿30个å符") |
| | | @Excel(name = "ç»å½åç§°") |
| | | private String userName; |
| | | |
| | | /** ç¨æ·æµç§° */ |
| | | /** |
| | | * ç¨æ·æµç§° |
| | | */ |
| | | @Size(min = 0, max = 30, message = "ç¨æ·æµç§°é¿åº¦ä¸è½è¶
è¿30个å符") |
| | | @Excel(name = "ç¨æ·åç§°") |
| | | private String nickName; |
| | | |
| | | /** ç¨æ·é®ç®± */ |
| | | /** |
| | | * ç¨æ·é®ç®± |
| | | */ |
| | | @Email(message = "é®ç®±æ ¼å¼ä¸æ£ç¡®") |
| | | @Size(min = 0, max = 50, message = "é®ç®±é¿åº¦ä¸è½è¶
è¿50个å符") |
| | | @Excel(name = "ç¨æ·é®ç®±") |
| | | private String email; |
| | | |
| | | /** ææºå·ç */ |
| | | @Size(min = 0, max = 11, message = "ææºå·ç é¿åº¦ä¸è½è¶
è¿11个å符") |
| | | @Excel(name = "ææºå·ç ") |
| | | /** |
| | | * ææºå·ç |
| | | */ |
| | | private String phonenumber; |
| | | |
| | | /** ç¨æ·æ§å« */ |
| | | @Excel(name = "ç¨æ·æ§å«", readConverterExp = "0=ç·,1=女,2=æªç¥") |
| | | /** |
| | | * ç¨æ·æ§å« |
| | | */ |
| | | private String sex; |
| | | |
| | | /** ç¨æ·å¤´å */ |
| | | /** |
| | | * ç¨æ·å¤´å |
| | | */ |
| | | private String avatar; |
| | | |
| | | /** å¯ç */ |
| | | /** |
| | | * å¯ç |
| | | */ |
| | | private String password; |
| | | |
| | | @JsonIgnore |
| | |
| | | return password; |
| | | } |
| | | |
| | | /** çå å¯ */ |
| | | /** |
| | | * çå å¯ |
| | | */ |
| | | private String salt; |
| | | |
| | | /** å¸å·ç¶æï¼0æ£å¸¸ 1åç¨ï¼ */ |
| | | @Excel(name = "å¸å·ç¶æ", readConverterExp = "0=æ£å¸¸,1=åç¨") |
| | | /** |
| | | * å¸å·ç¶æï¼0æ£å¸¸ 1åç¨ï¼ |
| | | */ |
| | | private String status; |
| | | |
| | | /** å 餿 å¿ï¼0代表åå¨ 2代表å é¤ï¼ */ |
| | | /** |
| | | * å 餿 å¿ï¼0代表åå¨ 2代表å é¤ï¼ |
| | | */ |
| | | @TableLogic |
| | | private String delFlag; |
| | | |
| | | /** æåç»å½IP */ |
| | | @Excel(name = "æåç»å½IP", type = Type.EXPORT) |
| | | /** |
| | | * æåç»å½IP |
| | | */ |
| | | private String loginIp; |
| | | |
| | | /** æåç»å½æ¶é´ */ |
| | | @Excel(name = "æåç»å½æ¶é´", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) |
| | | /** |
| | | * æåç»å½æ¶é´ |
| | | */ |
| | | private Date loginDate; |
| | | |
| | | /** å建è
*/ |
| | | /** |
| | | * å建è
|
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | /** å建æ¶é´ */ |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** æ´æ°è
*/ |
| | | /** |
| | | * æ´æ°è
|
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | /** æ´æ°æ¶é´ */ |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | /** 夿³¨ */ |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | |
| | | @TableField(exist = false) |
| | | private Map<String, Object> params = new HashMap<>(); |
| | | |
| | | /** é¨é¨å¯¹è±¡ */ |
| | | @Excels({ |
| | | @Excel(name = "é¨é¨åç§°", targetAttr = "deptName", type = Type.EXPORT), |
| | | @Excel(name = "é¨é¨è´è´£äºº", targetAttr = "leader", type = Type.EXPORT) |
| | | }) |
| | | /** |
| | | * é¨é¨å¯¹è±¡ |
| | | */ |
| | | @TableField(exist = false) |
| | | private SysDept dept; |
| | | |
| | | /** è§è²å¯¹è±¡ */ |
| | | /** |
| | | * è§è²å¯¹è±¡ |
| | | */ |
| | | @TableField(exist = false) |
| | | private List<SysRole> roles; |
| | | |
| | | /** è§è²ç» */ |
| | | /** |
| | | * è§è²ç» |
| | | */ |
| | | @TableField(exist = false) |
| | | private Long[] roleIds; |
| | | |
| | | /** å²ä½ç» */ |
| | | /** |
| | | * å²ä½ç» |
| | | */ |
| | | @TableField(exist = false) |
| | | private Long[] postIds; |
| | | |
| | | /** è§è²ID */ |
| | | /** |
| | | * è§è²ID |
| | | */ |
| | | @TableField(exist = false) |
| | | private Long roleId; |
| | | |
| | | public SysUser(Long userId) |
| | | { |
| | | public SysUser(Long userId) { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public boolean isAdmin() |
| | | { |
| | | public boolean isAdmin() { |
| | | return isAdmin(this.userId); |
| | | } |
| | | |
| | | public static boolean isAdmin(Long userId) |
| | | { |
| | | public static boolean isAdmin(Long userId) { |
| | | return userId != null && 1L == userId; |
| | | } |
| | | |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ç¨æ·ID |
| | | */ |
| | | private Long userId; |
| | | |
| | | /** |
| | | * é¨é¨ID |
| | | */ |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * ç¨æ·å¯ä¸æ è¯ |
| | | */ |
| | | private String token; |
| | |
| | | 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; |
| | | } |
| | | |
| | | @JsonIgnore |
| | | @Override |
| | | public String getPassword() |
| | |
| | | return user.getPassword(); |
| | | } |
| | | |
| | | @JsonIgnore |
| | | @Override |
| | | public String getUsername() |
| | | { |
| | |
| | | return true; |
| | | } |
| | | |
| | | @JsonIgnore |
| | | @Override |
| | | public Collection<? extends GrantedAuthority> getAuthorities() |
| | | { |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.domain.model;
|
| | |
|
| | | /**
|
| | | * ç¨æ·æ³¨å对象
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class RegisterBody extends LoginBody
|
| | | {
|
| | |
|
| | | }
|
| | |
| | | package com.ruoyi.common.core.mybatisplus.methods; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.core.enums.SqlMethod; |
| | | import com.baomidou.mybatisplus.core.injector.AbstractMethod; |
| | | import com.baomidou.mybatisplus.core.metadata.TableInfo; |
| | | import com.baomidou.mybatisplus.core.metadata.TableInfoHelper; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator; |
| | | import org.apache.ibatis.executor.keygen.KeyGenerator; |
| | | import org.apache.ibatis.executor.keygen.NoKeyGenerator; |
| | |
| | | final String fieldSql = prepareFieldSql(tableInfo); |
| | | final String valueSql = prepareValuesSqlForMysqlBatch(tableInfo); |
| | | KeyGenerator keyGenerator = new NoKeyGenerator(); |
| | | SqlMethod sqlMethod = SqlMethod.INSERT_ONE; |
| | | String sqlMethod = "insertAll"; |
| | | String keyProperty = null; |
| | | String keyColumn = null; |
| | | // 表å
å«ä¸»é®å¤çé»è¾,妿ä¸å
å«ä¸»é®å½æ®éåæ®µå¤ç |
| | | if (StrUtil.isNotBlank(tableInfo.getKeyProperty())) { |
| | | if (StringUtils.isNotBlank(tableInfo.getKeyProperty())) { |
| | | if (tableInfo.getIdType() == IdType.AUTO) { |
| | | /** èªå¢ä¸»é® */ |
| | | keyGenerator = new Jdbc3KeyGenerator(); |
| | |
| | | keyColumn = tableInfo.getKeyColumn(); |
| | | } else { |
| | | if (null != tableInfo.getKeySequence()) { |
| | | keyGenerator = TableInfoHelper.genKeyGenerator(getMethod(sqlMethod), tableInfo, builderAssistant); |
| | | keyGenerator = TableInfoHelper.genKeyGenerator(sqlMethod, tableInfo, builderAssistant); |
| | | keyProperty = tableInfo.getKeyProperty(); |
| | | keyColumn = tableInfo.getKeyColumn(); |
| | | } |
| | |
| | | } |
| | | final String sqlResult = String.format(sql, tableInfo.getTableName(), fieldSql, valueSql); |
| | | SqlSource sqlSource = languageDriver.createSqlSource(configuration, sqlResult, modelClass); |
| | | return this.addInsertMappedStatement(mapperClass, modelClass, "insertAll", sqlSource, keyGenerator, keyProperty, keyColumn); |
| | | return this.addInsertMappedStatement(mapperClass, modelClass, sqlMethod, sqlSource, keyGenerator, keyProperty, keyColumn); |
| | | } |
| | | |
| | | private String prepareFieldSql(TableInfo tableInfo) { |
| | | StringBuilder fieldSql = new StringBuilder(); |
| | | if (StrUtil.isNotBlank(tableInfo.getKeyColumn())) { |
| | | if (StringUtils.isNotBlank(tableInfo.getKeyColumn())) { |
| | | fieldSql.append(tableInfo.getKeyColumn()).append(","); |
| | | } |
| | | tableInfo.getFieldList().forEach(x -> fieldSql.append(x.getColumn()).append(",")); |
| | |
| | | private String prepareValuesSqlForMysqlBatch(TableInfo tableInfo) { |
| | | final StringBuilder valueSql = new StringBuilder(); |
| | | valueSql.append("<foreach collection=\"list\" item=\"item\" index=\"index\" open=\"(\" separator=\"),(\" close=\")\">"); |
| | | if (StrUtil.isNotBlank(tableInfo.getKeyColumn())) { |
| | | if (StringUtils.isNotBlank(tableInfo.getKeyColumn())) { |
| | | valueSql.append("#{item.").append(tableInfo.getKeyProperty()).append("},"); |
| | | } |
| | | tableInfo.getFieldList().forEach(x -> valueSql.append("#{item.").append(x.getProperty()).append("},")); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.enums;
|
| | |
|
| | | /**
|
| | | * éæµç±»å
|
| | | *
|
| | | * @author ruoyi
|
| | | */
|
| | |
|
| | | public enum LimitType
|
| | | {
|
| | | /**
|
| | | * é»è®¤çç¥å
¨å±éæµ
|
| | | */
|
| | | DEFAULT,
|
| | |
|
| | | /**
|
| | | * æ ¹æ®è¯·æ±è
IPè¿è¡éæµ
|
| | | */
|
| | | IP
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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;
|
| | | }
|
| | |
|
| | | public String getMessage()
|
| | | {
|
| | | return message;
|
| | | }
|
| | |
|
| | | public GlobalException setMessage(String message)
|
| | | {
|
| | | this.message = message;
|
| | | return this;
|
| | | }
|
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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;
|
| | | }
|
| | |
|
| | | 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;
|
| | | }
|
| | | } |
ÎļþÃû´Ó ruoyi-common/src/main/java/com/ruoyi/common/exception/BaseException.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.common.exception; |
| | | package com.ruoyi.common.exception.base; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.ruoyi.common.utils.MessageUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | /** |
| | | * åºç¡å¼å¸¸ |
| | |
| | | public String getMessage() |
| | | { |
| | | String message = null; |
| | | if (!Validator.isEmpty(code)) |
| | | if (!StringUtils.isEmpty(code)) |
| | | { |
| | | message = MessageUtils.message(code, args); |
| | | } |
| | |
| | | package com.ruoyi.common.exception.file; |
| | | |
| | | import com.ruoyi.common.exception.BaseException; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | |
| | | /** |
| | | * æä»¶ä¿¡æ¯å¼å¸¸ç±» |
| | |
| | | package com.ruoyi.common.exception.user; |
| | | |
| | | import com.ruoyi.common.exception.BaseException; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | |
| | | /** |
| | | * ç¨æ·ä¿¡æ¯å¼å¸¸ç±» |
| | |
| | | package com.ruoyi.common.filter;
|
| | |
|
| | | import cn.hutool.core.util.StrUtil;
|
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.springframework.http.MediaType;
|
| | |
|
| | | import javax.servlet.*;
|
| | |
| | | {
|
| | | ServletRequest requestWrapper = null;
|
| | | if (request instanceof HttpServletRequest
|
| | | && StrUtil.startWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE))
|
| | | && StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE)) |
| | | {
|
| | | requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response);
|
| | | }
|
| | |
| | | package com.ruoyi.common.filter; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | import javax.servlet.*; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * 鲿¢XSSæ»å»çè¿æ»¤å¨ |
| | |
| | | */ |
| | | public List<String> excludes = new ArrayList<>(); |
| | | |
| | | /** |
| | | * xssè¿æ»¤å¼å
³ |
| | | */ |
| | | public boolean enabled = false; |
| | | |
| | | @Override |
| | | public void init(FilterConfig filterConfig) throws ServletException |
| | | { |
| | | String tempExcludes = filterConfig.getInitParameter("excludes"); |
| | | String tempEnabled = filterConfig.getInitParameter("enabled"); |
| | | if (StrUtil.isNotEmpty(tempExcludes)) |
| | | if (StringUtils.isNotEmpty(tempExcludes)) |
| | | { |
| | | String[] url = tempExcludes.split(","); |
| | | for (int i = 0; url != null && i < url.length; i++) |
| | | { |
| | | excludes.add(url[i]); |
| | | } |
| | | } |
| | | if (StrUtil.isNotEmpty(tempEnabled)) |
| | | { |
| | | enabled = Boolean.valueOf(tempEnabled); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) |
| | | { |
| | | if (!enabled) |
| | | { |
| | | return true; |
| | | } |
| | | if (excludes == null || excludes.isEmpty()) |
| | | { |
| | | return false; |
| | | } |
| | | String url = request.getServletPath(); |
| | | for (String pattern : excludes) |
| | | { |
| | | Pattern p = Pattern.compile("^" + pattern); |
| | | Matcher m = p.matcher(url); |
| | | if (m.find()) |
| | | String method = request.getMethod(); |
| | | // GET DELETE ä¸è¿æ»¤ |
| | | if (method == null || method.matches("GET") || method.matches("DELETE")) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | return StringUtils.matches(url, excludes); |
| | | } |
| | | |
| | | @Override |
| | |
| | | package com.ruoyi.common.filter; |
| | | |
| | | import cn.hutool.core.io.IoUtil; |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.http.HtmlUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | |
| | |
| | | |
| | | // 为空ï¼ç´æ¥è¿å |
| | | String json = IoUtil.read(super.getInputStream(), StandardCharsets.UTF_8); |
| | | if (Validator.isEmpty(json)) |
| | | if (StringUtils.isEmpty(json)) |
| | | { |
| | | return super.getInputStream(); |
| | | } |
| | |
| | | public boolean isJsonRequest() |
| | | { |
| | | String header = super.getHeader(HttpHeaders.CONTENT_TYPE); |
| | | return StrUtil.startWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE); |
| | | return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.common.utils;
|
| | |
|
| | | import cn.hutool.core.collection.CollUtil;
|
| | | import cn.hutool.core.lang.Validator;
|
| | | import cn.hutool.core.util.StrUtil;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.core.domain.entity.SysDictData;
|
| | | import com.ruoyi.common.core.redis.RedisCache;
|
| | |
| | | public static List<SysDictData> getDictCache(String key)
|
| | | {
|
| | | Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
|
| | | if (Validator.isNotNull(cacheObj))
|
| | | if (StringUtils.isNotNull(cacheObj)) |
| | | {
|
| | | List<SysDictData> dictDatas = (List<SysDictData>)cacheObj;
|
| | | return dictDatas;
|
| | |
| | | StringBuilder propertyString = new StringBuilder();
|
| | | List<SysDictData> datas = getDictCache(dictType);
|
| | |
|
| | | if (StrUtil.containsAny(dictValue, separator) && CollUtil.isNotEmpty(datas))
|
| | | if (StringUtils.containsAny(dictValue, separator) && CollUtil.isNotEmpty(datas)) |
| | | {
|
| | | for (SysDictData dict : datas)
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | return StrUtil.strip(propertyString.toString(), null, separator);
|
| | | return StringUtils.stripEnd(propertyString.toString(), separator); |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | StringBuilder propertyString = new StringBuilder();
|
| | | List<SysDictData> datas = getDictCache(dictType);
|
| | |
|
| | | if (StrUtil.containsAny(dictLabel, separator) && CollUtil.isNotEmpty(datas))
|
| | | if (StringUtils.containsAny(dictLabel, separator) && CollUtil.isNotEmpty(datas)) |
| | | {
|
| | | for (SysDictData dict : datas)
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | return StrUtil.strip(propertyString.toString(), null, separator);
|
| | | return StringUtils.stripEnd(propertyString.toString(), separator); |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | |
| | | } |
| | | |
| | | public static String toJsonString(Object object) { |
| | | if (Validator.isEmpty(object)) { |
| | | if (StringUtils.isNull(object)) { |
| | | return null; |
| | | } |
| | | try { |
| | |
| | | } |
| | | |
| | | public static <T> T parseObject(String text, Class<T> clazz) { |
| | | if (StrUtil.isEmpty(text)) { |
| | | if (StringUtils.isEmpty(text)) { |
| | | return null; |
| | | } |
| | | try { |
| | |
| | | } |
| | | |
| | | public static <T> T parseObject(String text, TypeReference<T> typeReference) { |
| | | if (StrUtil.isBlank(text)) { |
| | | if (StringUtils.isBlank(text)) { |
| | | return null; |
| | | } |
| | | try { |
| | |
| | | } |
| | | |
| | | public static <T> Map<String, T> parseMap(String text) { |
| | | if (StrUtil.isBlank(text)) { |
| | | if (StringUtils.isBlank(text)) { |
| | | return null; |
| | | } |
| | | try { |
| | |
| | | } |
| | | |
| | | public static <T> List<T> parseArray(String text, Class<T> clazz) { |
| | | if (StrUtil.isEmpty(text)) { |
| | | if (StringUtils.isEmpty(text)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | try { |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.baomidou.mybatisplus.core.metadata.OrderItem; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | String orderByColumn = ServletUtils.getParameter(ORDER_BY_COLUMN); |
| | | String isAsc = ServletUtils.getParameter(IS_ASC); |
| | | PagePlus<T, K> page = new PagePlus<>(pageNum, pageSize); |
| | | if (StrUtil.isNotBlank(orderByColumn)) { |
| | | if (StringUtils.isNotBlank(orderByColumn)) { |
| | | String orderBy = SqlUtil.escapeOrderBySql(orderByColumn); |
| | | if ("asc".equals(isAsc)) { |
| | | page.addOrder(OrderItem.asc(orderBy)); |
| | |
| | | isAsc = "desc"; |
| | | } |
| | | Page<T> page = new Page<>(pageNum, pageSize); |
| | | if (StrUtil.isNotBlank(orderByColumn)) { |
| | | if (StringUtils.isNotBlank(orderByColumn)) { |
| | | String orderBy = SqlUtil.escapeOrderBySql(orderByColumn); |
| | | orderBy = StrUtil.toUnderlineCase(orderBy); |
| | | orderBy = StringUtils.toUnderScoreCase(orderBy); |
| | | if ("asc".equals(isAsc)) { |
| | | page.addOrder(OrderItem.asc(orderBy)); |
| | | } else if ("desc".equals(isAsc)) { |
| | |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | |
| | | /** |
| | | * å®å
¨æå¡å·¥å
·ç±» |
| | |
| | | */ |
| | | public class SecurityUtils |
| | | { |
| | | /** |
| | | * ç¨æ·ID |
| | | **/ |
| | | public static Long getUserId() |
| | | { |
| | | try |
| | | { |
| | | return getLoginUser().getUserId(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new ServiceException("è·åç¨æ·IDå¼å¸¸", HttpStatus.HTTP_UNAUTHORIZED); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åé¨é¨ID |
| | | **/ |
| | | public static Long getDeptId() |
| | | { |
| | | try |
| | | { |
| | | return getLoginUser().getDeptId(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new ServiceException("è·åé¨é¨IDå¼å¸¸", HttpStatus.HTTP_UNAUTHORIZED); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åç¨æ·è´¦æ· |
| | | **/ |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new CustomException("è·åç¨æ·è´¦æ·å¼å¸¸", HttpStatus.HTTP_UNAUTHORIZED); |
| | | throw new ServiceException("è·åç¨æ·è´¦æ·å¼å¸¸", HttpStatus.HTTP_UNAUTHORIZED); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new CustomException("è·åç¨æ·ä¿¡æ¯å¼å¸¸", HttpStatus.HTTP_UNAUTHORIZED); |
| | | throw new ServiceException("è·åç¨æ·ä¿¡æ¯å¼å¸¸", HttpStatus.HTTP_UNAUTHORIZED); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.extra.servlet.ServletUtil; |
| | | import cn.hutool.http.HttpStatus; |
| | | import org.springframework.http.MediaType; |
| | |
| | | } |
| | | |
| | | String uri = request.getRequestURI(); |
| | | if (StrUtil.equalsAnyIgnoreCase(uri, ".json", ".xml")) { |
| | | if (StringUtils.equalsAnyIgnoreCase(uri, ".json", ".xml")) { |
| | | return true; |
| | | } |
| | | |
| | | String ajax = request.getParameter("__ajax"); |
| | | if (StrUtil.equalsAnyIgnoreCase(ajax, "json", "xml")) { |
| | | if (StringUtils.equalsAnyIgnoreCase(ajax, "json", "xml")) { |
| | | return true; |
| | | } |
| | | return false; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.map.MapUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.ReUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * å符串工å
·ç±» |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class StringUtils extends org.apache.commons.lang3.StringUtils { |
| | | |
| | | /** |
| | | * è·ååæ°ä¸ä¸ºç©ºå¼ |
| | | * |
| | | * @param value defaultValue è¦å¤æçvalue |
| | | * @return value è¿åå¼ |
| | | */ |
| | | public static <T> T nvl(T value, T defaultValue) { |
| | | return ObjectUtil.defaultIfNull(value, defaultValue); |
| | | } |
| | | |
| | | /** |
| | | * è·ååæ°ä¸ä¸ºç©ºå¼ |
| | | * |
| | | * @param str defaultValue è¦å¤æçvalue |
| | | * @return value è¿åå¼ |
| | | */ |
| | | public static String blankToDefault(String str, String defaultValue) { |
| | | return StrUtil.blankToDefault(str, defaultValue); |
| | | } |
| | | |
| | | /** |
| | | * * 夿ä¸ä¸ªCollectionæ¯å¦ä¸ºç©ºï¼ å
å«Listï¼Setï¼Queue |
| | | * |
| | | * @param coll è¦å¤æçCollection |
| | | * @return trueï¼ä¸ºç©º falseï¼é空 |
| | | */ |
| | | public static boolean isEmpty(Collection<?> coll) { |
| | | return CollUtil.isEmpty(coll); |
| | | } |
| | | |
| | | /** |
| | | * * 夿ä¸ä¸ªCollectionæ¯å¦é空ï¼å
å«Listï¼Setï¼Queue |
| | | * |
| | | * @param coll è¦å¤æçCollection |
| | | * @return trueï¼é空 falseï¼ç©º |
| | | */ |
| | | public static boolean isNotEmpty(Collection<?> coll) { |
| | | return !isEmpty(coll); |
| | | } |
| | | |
| | | /** |
| | | * * 夿ä¸ä¸ªå¯¹è±¡æ°ç»æ¯å¦ä¸ºç©º |
| | | * |
| | | * @param objects è¦å¤æç对象æ°ç» |
| | | * * @return trueï¼ä¸ºç©º falseï¼é空 |
| | | */ |
| | | public static boolean isEmpty(Object[] objects) { |
| | | return ArrayUtil.isEmpty(objects); |
| | | } |
| | | |
| | | /** |
| | | * * 夿ä¸ä¸ªå¯¹è±¡æ°ç»æ¯å¦é空 |
| | | * |
| | | * @param objects è¦å¤æç对象æ°ç» |
| | | * @return trueï¼é空 falseï¼ç©º |
| | | */ |
| | | public static boolean isNotEmpty(Object[] objects) { |
| | | return !isEmpty(objects); |
| | | } |
| | | |
| | | /** |
| | | * * 夿ä¸ä¸ªå¯¹è±¡æ¯å¦ä¸ºç©º |
| | | * |
| | | * @param object è¦å¤æç对象æ°ç» |
| | | * * @return trueï¼ä¸ºç©º falseï¼é空 |
| | | */ |
| | | public static boolean isEmpty(Object object) { |
| | | return ObjectUtil.isEmpty(object); |
| | | } |
| | | |
| | | /** |
| | | * * 夿ä¸ä¸ªå¯¹è±¡æ¯å¦é空 |
| | | * |
| | | * @param object è¦å¤æç对象æ°ç» |
| | | * @return trueï¼é空 falseï¼ç©º |
| | | */ |
| | | public static boolean isNotEmpty(Object object) { |
| | | return !isEmpty(object); |
| | | } |
| | | |
| | | /** |
| | | * * 夿ä¸ä¸ªMapæ¯å¦ä¸ºç©º |
| | | * |
| | | * @param map è¦å¤æçMap |
| | | * @return trueï¼ä¸ºç©º falseï¼é空 |
| | | */ |
| | | public static boolean isEmpty(Map<?, ?> map) { |
| | | return MapUtil.isEmpty(map); |
| | | } |
| | | |
| | | /** |
| | | * * 夿ä¸ä¸ªMapæ¯å¦ä¸ºç©º |
| | | * |
| | | * @param map è¦å¤æçMap |
| | | * @return trueï¼é空 falseï¼ç©º |
| | | */ |
| | | public static boolean isNotEmpty(Map<?, ?> map) { |
| | | return !isEmpty(map); |
| | | } |
| | | |
| | | /** |
| | | * * 夿ä¸ä¸ªå符串æ¯å¦ä¸ºç©ºä¸² |
| | | * |
| | | * @param str String |
| | | * @return trueï¼ä¸ºç©º falseï¼é空 |
| | | */ |
| | | public static boolean isEmpty(String str) { |
| | | return StrUtil.isEmpty(str); |
| | | } |
| | | |
| | | /** |
| | | * * 夿ä¸ä¸ªå符串æ¯å¦ä¸ºé空串 |
| | | * |
| | | * @param str String |
| | | * @return trueï¼é空串 falseï¼ç©ºä¸² |
| | | */ |
| | | public static boolean isNotEmpty(String str) { |
| | | return !isEmpty(str); |
| | | } |
| | | |
| | | /** |
| | | * * 夿ä¸ä¸ªå¯¹è±¡æ¯å¦ä¸ºç©º |
| | | * |
| | | * @param object Object |
| | | * @return trueï¼ä¸ºç©º falseï¼é空 |
| | | */ |
| | | public static boolean isNull(Object object) { |
| | | return ObjectUtil.isNull(object); |
| | | } |
| | | |
| | | /** |
| | | * * 夿ä¸ä¸ªå¯¹è±¡æ¯å¦é空 |
| | | * |
| | | * @param object Object |
| | | * @return trueï¼é空 falseï¼ç©º |
| | | */ |
| | | public static boolean isNotNull(Object object) { |
| | | return !isNull(object); |
| | | } |
| | | |
| | | /** |
| | | * * 夿ä¸ä¸ªå¯¹è±¡æ¯å¦æ¯æ°ç»ç±»åï¼Javaåºæ¬åå«çæ°ç»ï¼ |
| | | * |
| | | * @param object 对象 |
| | | * @return trueï¼æ¯æ°ç» falseï¼ä¸æ¯æ°ç» |
| | | */ |
| | | public static boolean isArray(Object object) { |
| | | return ArrayUtil.isArray(object); |
| | | } |
| | | |
| | | /** |
| | | * å»ç©ºæ ¼ |
| | | */ |
| | | public static String trim(String str) { |
| | | return StrUtil.trim(str); |
| | | } |
| | | |
| | | /** |
| | | * æªåå符串 |
| | | * |
| | | * @param str å符串 |
| | | * @param start å¼å§ |
| | | * @return ç»æ |
| | | */ |
| | | public static String substring(final String str, int start) { |
| | | return substring(str, start, str.length()); |
| | | } |
| | | |
| | | /** |
| | | * æªåå符串 |
| | | * |
| | | * @param str å符串 |
| | | * @param start å¼å§ |
| | | * @param end ç»æ |
| | | * @return ç»æ |
| | | */ |
| | | public static String substring(final String str, int start, int end) { |
| | | return StrUtil.sub(str, start, 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 template ææ¬æ¨¡æ¿ï¼è¢«æ¿æ¢çé¨åç¨ {} 表示 |
| | | * @param params åæ°å¼ |
| | | * @return æ ¼å¼ååçææ¬ |
| | | */ |
| | | public static String format(String template, Object... params) { |
| | | return StrUtil.format(template, params); |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦ä¸ºhttp(s)://å¼å¤´ |
| | | * |
| | | * @param link 龿¥ |
| | | * @return ç»æ |
| | | */ |
| | | public static boolean ishttp(String link) { |
| | | return Validator.isUrl(link); |
| | | } |
| | | |
| | | /** |
| | | * å符串转set |
| | | * |
| | | * @param str å符串 |
| | | * @param sep åé符 |
| | | * @return setéå |
| | | */ |
| | | public static Set<String> str2Set(String str, String sep) { |
| | | return new HashSet<>(str2List(str, sep, true, false)); |
| | | } |
| | | |
| | | /** |
| | | * å符串转list |
| | | * |
| | | * @param str å符串 |
| | | * @param sep åé符 |
| | | * @param filterBlank è¿æ»¤çº¯ç©ºç½ |
| | | * @param trim 廿é¦å°¾ç©ºç½ |
| | | * @return listéå |
| | | */ |
| | | public static List<String> str2List(String str, String sep, boolean filterBlank, boolean trim) { |
| | | List<String> list = new ArrayList<>(); |
| | | if (isEmpty(str)) { |
| | | return list; |
| | | } |
| | | |
| | | // è¿æ»¤ç©ºç½å符串 |
| | | if (filterBlank && isBlank(str)) { |
| | | return list; |
| | | } |
| | | String[] split = str.split(sep); |
| | | for (String string : split) { |
| | | if (filterBlank && isBlank(string)) { |
| | | continue; |
| | | } |
| | | if (trim) { |
| | | string = trim(string); |
| | | } |
| | | list.add(string); |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * æ¥æ¾æå®å符串æ¯å¦å
嫿å®å符串å表ä¸çä»»æä¸ä¸ªåç¬¦ä¸²åæ¶ä¸²å¿½ç¥å¤§å°å |
| | | * |
| | | * @param cs æå®å符串 |
| | | * @param searchCharSequences éè¦æ£æ¥çå符串æ°ç» |
| | | * @return æ¯å¦å
å«ä»»æä¸ä¸ªå符串 |
| | | */ |
| | | public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences) { |
| | | return StrUtil.containsAnyIgnoreCase(cs, searchCharSequences); |
| | | } |
| | | |
| | | /** |
| | | * 驼峰转ä¸å线å½å |
| | | */ |
| | | public static String toUnderScoreCase(String str) { |
| | | return StrUtil.toUnderlineCase(str); |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦å
å«å符串 |
| | | * |
| | | * @param str éªè¯å符串 |
| | | * @param strs åç¬¦ä¸²ç» |
| | | * @return å
å«è¿åtrue |
| | | */ |
| | | public static boolean inStringIgnoreCase(String str, String... strs) { |
| | | return StrUtil.equalsAnyIgnoreCase(str, strs); |
| | | } |
| | | |
| | | /** |
| | | * å°ä¸åçº¿å¤§åæ¹å¼å½åçå符串转æ¢ä¸ºé©¼å³°å¼ãå¦æè½¬æ¢åçä¸åçº¿å¤§åæ¹å¼å½åçå符串为空ï¼åè¿å空å符串ã ä¾å¦ï¼HELLO_WORLD->HelloWorld |
| | | * |
| | | * @param name 转æ¢åçä¸åçº¿å¤§åæ¹å¼å½åçå符串 |
| | | * @return 转æ¢åç驼峰å¼å½åçå符串 |
| | | */ |
| | | public static String convertToCamelCase(String name) { |
| | | return StrUtil.upperFirst(StrUtil.toCamelCase(name)); |
| | | } |
| | | |
| | | /** |
| | | * 驼峰å¼å½åæ³ ä¾å¦ï¼user_name->userName |
| | | */ |
| | | public static String toCamelCase(String s) { |
| | | return StrUtil.toCamelCase(s); |
| | | } |
| | | |
| | | /** |
| | | * æ¥æ¾æå®å符串æ¯å¦å¹é
æå®å符串å表ä¸çä»»æä¸ä¸ªå符串 |
| | | * |
| | | * @param str æå®å符串 |
| | | * @param strs éè¦æ£æ¥çå符串æ°ç» |
| | | * @return æ¯å¦å¹é
|
| | | */ |
| | | public static boolean matches(String str, List<String> strs) { |
| | | if (isEmpty(str) || isEmpty(strs)) { |
| | | return false; |
| | | } |
| | | for (String pattern : strs) { |
| | | if (isMatch(pattern, str)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 夿urlæ¯å¦ä¸è§åé
ç½®: |
| | | * ? 表示å个å符; |
| | | * * 表示ä¸å±è·¯å¾å
çä»»æå符串ï¼ä¸å¯è·¨å±çº§; |
| | | * ** 表示任æå±è·¯å¾; |
| | | * |
| | | * @param pattern å¹é
è§å |
| | | * @param url éè¦å¹é
çurl |
| | | * @return |
| | | */ |
| | | public static boolean isMatch(String pattern, String url) { |
| | | return ReUtil.isMatch(pattern, url); |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | public static <T> T cast(Object obj) { |
| | | return (T) obj; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.common.utils.file; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.*; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | |
| | | */ |
| | | public class FileUtils extends FileUtil |
| | | { |
| | | public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"; |
| | | |
| | | /** |
| | | * æä»¶åç§°éªè¯ |
| | | * |
| | | * @param filename æä»¶åç§° |
| | | * @return true æ£å¸¸ false éæ³ |
| | | */ |
| | | public static boolean isValidFilename(String filename) |
| | | { |
| | | return filename.matches(FILENAME_PATTERN); |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥æä»¶æ¯å¦å¯ä¸è½½ |
| | | * |
| | | * @param resource éè¦ä¸è½½çæä»¶ |
| | | * @return true æ£å¸¸ false éæ³ |
| | | */ |
| | | public static boolean checkAllowDownload(String resource) |
| | | { |
| | | // ç¦æ¢ç®å½ä¸è·³çº§å« |
| | | if (StrUtil.contains(resource, "..")) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | // æ£æ¥å
许ä¸è½½çæä»¶è§å |
| | | if (ArrayUtil.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource))) |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | // ä¸å¨å
许ä¸è½½çæä»¶è§å |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * ä¸è½½æä»¶åéæ°ç¼ç |
| | | * |
| | | * @param request 请æ±å¯¹è±¡ |
| | | * @param fileName æä»¶å |
| | | * @return ç¼ç åçæä»¶å |
| | | */ |
| | | public static String setFileDownloadHeader(HttpServletRequest request, String fileName) throws UnsupportedEncodingException |
| | | { |
| | | final String agent = request.getHeader("USER-AGENT"); |
| | | String filename = fileName; |
| | | if (agent.contains("MSIE")) |
| | | { |
| | | // IEæµè§å¨ |
| | | filename = URLEncoder.encode(filename, StandardCharsets.UTF_8.toString()); |
| | | filename = filename.replace("+", " "); |
| | | } |
| | | else if (agent.contains("Firefox")) |
| | | { |
| | | // ç«çæµè§å¨ |
| | | filename = new String(fileName.getBytes(), "ISO8859-1"); |
| | | } |
| | | else if (agent.contains("Chrome")) |
| | | { |
| | | // googleæµè§å¨ |
| | | filename = URLEncoder.encode(filename, StandardCharsets.UTF_8.toString()); |
| | | } |
| | | else |
| | | { |
| | | // å
¶å®æµè§å¨ |
| | | filename = URLEncoder.encode(filename, StandardCharsets.UTF_8.toString()); |
| | | } |
| | | return filename; |
| | | } |
| | | |
| | | /** |
| | | * ä¸è½½æä»¶åéæ°ç¼ç |
| | |
| | | package com.ruoyi.common.utils.ip; |
| | | |
| | | import cn.hutool.core.net.NetUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.http.HtmlUtil; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.Map; |
| | |
| | | .body("ip=" + ip + "&json=true", Constants.GBK) |
| | | .execute() |
| | | .body(); |
| | | if (StrUtil.isEmpty(rspStr)) { |
| | | if (StringUtils.isEmpty(rspStr)) { |
| | | log.error("è·åå°çä½ç½®å¼å¸¸ {}", ip); |
| | | return UNKNOWN; |
| | | } |
| | |
| | | package com.ruoyi.common.utils.poi; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.ruoyi.common.annotation.Excel.ColumnType; |
| | | import com.ruoyi.common.annotation.Excel.Type; |
| | | import com.ruoyi.common.annotation.Excels; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.ruoyi.common.utils.DictUtils; |
| | | import com.ruoyi.common.utils.file.FileTypeUtils; |
| | | import com.ruoyi.common.utils.file.ImageUtils; |
| | | import com.ruoyi.common.utils.reflect.ReflectUtils; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.ss.util.CellRangeAddressList; |
| | | import org.apache.poi.xssf.streaming.SXSSFWorkbook; |
| | | import org.apache.poi.xssf.usermodel.XSSFClientAnchor; |
| | | import org.apache.poi.xssf.usermodel.XSSFDataValidation; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | | |
| | | import java.io.*; |
| | | import java.lang.reflect.Field; |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Excelç¸å
³å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class ExcelUtil<T> |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class); |
| | | public class ExcelUtil { |
| | | |
| | | /** |
| | | * Excel sheetæå¤§è¡æ°ï¼é»è®¤65536 |
| | | */ |
| | | public static final int sheetSize = 65536; |
| | | |
| | | /** |
| | | * å·¥ä½è¡¨åç§° |
| | | */ |
| | | private String sheetName; |
| | | |
| | | /** |
| | | * 导åºç±»åï¼EXPORT:å¯¼åºæ°æ®ï¼IMPORTï¼å¯¼å
¥æ¨¡æ¿ï¼ |
| | | */ |
| | | private Type type; |
| | | |
| | | /** |
| | | * å·¥ä½è对象 |
| | | */ |
| | | private Workbook wb; |
| | | |
| | | /** |
| | | * å·¥ä½è¡¨å¯¹è±¡ |
| | | */ |
| | | private Sheet sheet; |
| | | |
| | | /** |
| | | * æ ·å¼å表 |
| | | */ |
| | | private Map<String, CellStyle> styles; |
| | | |
| | | /** |
| | | * 导å
¥å¯¼åºæ°æ®å表 |
| | | */ |
| | | private List<T> list; |
| | | |
| | | /** |
| | | * 注解å表 |
| | | */ |
| | | private List<Object[]> fields; |
| | | |
| | | /** |
| | | * æå¤§é«åº¦ |
| | | */ |
| | | private short maxHeight; |
| | | |
| | | /** |
| | | * ç»è®¡å表 |
| | | */ |
| | | private Map<Integer, Double> statistics = new HashMap<Integer, Double>(); |
| | | |
| | | /** |
| | | * æ°åæ ¼å¼ |
| | | */ |
| | | private static final DecimalFormat DOUBLE_FORMAT = new DecimalFormat("######0.00"); |
| | | |
| | | /** |
| | | * å®ä½å¯¹è±¡ |
| | | */ |
| | | public Class<T> clazz; |
| | | |
| | | public ExcelUtil(Class<T> clazz) |
| | | { |
| | | this.clazz = clazz; |
| | | } |
| | | |
| | | public void init(List<T> list, String sheetName, Type type) |
| | | { |
| | | if (list == null) |
| | | { |
| | | list = new ArrayList<T>(); |
| | | } |
| | | this.list = list; |
| | | this.sheetName = sheetName; |
| | | this.type = type; |
| | | createExcelField(); |
| | | createWorkbook(); |
| | | } |
| | | |
| | | /** |
| | | * 对excel表åé»è®¤ç¬¬ä¸ä¸ªç´¢å¼åè½¬æ¢ælist |
| | | * 对excel表åé»è®¤ç¬¬ä¸ä¸ªç´¢å¼åè½¬æ¢ælistï¼EasyExcelï¼ |
| | | * |
| | | * @param is è¾å
¥æµ |
| | | * @return 转æ¢åéå |
| | | */ |
| | | public List<T> importExcel(InputStream is) throws Exception |
| | | { |
| | | return importExcel(StrUtil.EMPTY, is); |
| | | public static <T> List<T> importExcel(InputStream is, Class<T> clazz) { |
| | | return EasyExcel.read(is).autoCloseStream(false).sheet().doReadSync(); |
| | | } |
| | | |
| | | /** |
| | | * 对excel表åæå®è¡¨æ ¼ç´¢å¼åè½¬æ¢ælist |
| | | * |
| | | * @param sheetName è¡¨æ ¼ç´¢å¼å |
| | | * @param is è¾å
¥æµ |
| | | * @return 转æ¢åéå |
| | | */ |
| | | public List<T> importExcel(String sheetName, InputStream is) throws Exception |
| | | { |
| | | this.type = Type.IMPORT; |
| | | this.wb = WorkbookFactory.create(is); |
| | | List<T> list = new ArrayList<T>(); |
| | | Sheet sheet = null; |
| | | if (Validator.isNotEmpty(sheetName)) |
| | | { |
| | | // 妿æå®sheetå,ååæå®sheetä¸çå
容. |
| | | sheet = wb.getSheet(sheetName); |
| | | } |
| | | else |
| | | { |
| | | // å¦æä¼ å
¥çsheetåä¸åå¨åé»è®¤æå第1个sheet. |
| | | sheet = wb.getSheetAt(0); |
| | | } |
| | | |
| | | if (sheet == null) |
| | | { |
| | | throw new IOException("æä»¶sheetä¸åå¨"); |
| | | } |
| | | |
| | | int rows = sheet.getPhysicalNumberOfRows(); |
| | | |
| | | if (rows > 0) |
| | | { |
| | | // å®ä¹ä¸ä¸ªmapç¨äºåæ¾excelåçåºå·åfield. |
| | | Map<String, Integer> cellMap = new HashMap<String, Integer>(); |
| | | // è·å表头 |
| | | Row heard = sheet.getRow(0); |
| | | for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) |
| | | { |
| | | Cell cell = heard.getCell(i); |
| | | if (Validator.isNotNull(cell)) |
| | | { |
| | | String value = this.getCellValue(heard, i).toString(); |
| | | cellMap.put(value, i); |
| | | } |
| | | else |
| | | { |
| | | cellMap.put(null, i); |
| | | } |
| | | } |
| | | // ææ°æ®æ¶æå¤ç å¾å°ç±»çææfield. |
| | | Field[] allFields = clazz.getDeclaredFields(); |
| | | // å®ä¹ä¸ä¸ªmapç¨äºåæ¾åçåºå·åfield. |
| | | Map<Integer, Field> fieldsMap = new HashMap<Integer, Field>(); |
| | | for (int col = 0; col < allFields.length; col++) |
| | | { |
| | | Field field = allFields[col]; |
| | | Excel attr = field.getAnnotation(Excel.class); |
| | | if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) |
| | | { |
| | | // 设置类çç§æåæ®µå±æ§å¯è®¿é®. |
| | | field.setAccessible(true); |
| | | Integer column = cellMap.get(attr.name()); |
| | | if (column != null) |
| | | { |
| | | fieldsMap.put(column, field); |
| | | } |
| | | } |
| | | } |
| | | for (int i = 1; i < rows; i++) |
| | | { |
| | | // ä»ç¬¬2è¡å¼å§åæ°æ®,é»è®¤ç¬¬ä¸è¡æ¯è¡¨å¤´. |
| | | Row row = sheet.getRow(i); |
| | | if(row == null) |
| | | { |
| | | continue; |
| | | } |
| | | T entity = null; |
| | | for (Map.Entry<Integer, Field> entry : fieldsMap.entrySet()) |
| | | { |
| | | Object val = this.getCellValue(row, entry.getKey()); |
| | | |
| | | // 妿ä¸åå¨å®ä¾åæ°å»º. |
| | | entity = (entity == null ? clazz.newInstance() : entity); |
| | | // ä»mapä¸å¾å°å¯¹åºåçfield. |
| | | Field field = fieldsMap.get(entry.getKey()); |
| | | // åå¾ç±»å,å¹¶æ ¹æ®å¯¹è±¡ç±»å设置å¼. |
| | | Class<?> fieldType = field.getType(); |
| | | if (String.class == fieldType) |
| | | { |
| | | String s = Convert.toStr(val); |
| | | if (StrUtil.endWith(s, ".0")) |
| | | { |
| | | val = StrUtil.subBefore(s, ".0",false); |
| | | } |
| | | else |
| | | { |
| | | String dateFormat = field.getAnnotation(Excel.class).dateFormat(); |
| | | if (Validator.isNotEmpty(dateFormat)) |
| | | { |
| | | val = DateUtils.parseDateToStr(dateFormat, (Date) val); |
| | | } |
| | | else |
| | | { |
| | | val = Convert.toStr(val); |
| | | } |
| | | } |
| | | } |
| | | else if ((Integer.TYPE == fieldType || Integer.class == fieldType) && Validator.isNumber(Convert.toStr(val))) |
| | | { |
| | | val = Convert.toInt(val); |
| | | } |
| | | else if (Long.TYPE == fieldType || Long.class == fieldType) |
| | | { |
| | | val = Convert.toLong(val); |
| | | } |
| | | else if (Double.TYPE == fieldType || Double.class == fieldType) |
| | | { |
| | | val = Convert.toDouble(val); |
| | | } |
| | | else if (Float.TYPE == fieldType || Float.class == fieldType) |
| | | { |
| | | val = Convert.toFloat(val); |
| | | } |
| | | else if (BigDecimal.class == fieldType) |
| | | { |
| | | val = Convert.toBigDecimal(val); |
| | | } |
| | | else if (Date.class == fieldType) |
| | | { |
| | | if (val instanceof String) |
| | | { |
| | | val = DateUtils.parseDate(val); |
| | | } |
| | | else if (val instanceof Double) |
| | | { |
| | | val = DateUtil.getJavaDate((Double) val); |
| | | } |
| | | } |
| | | else if (Boolean.TYPE == fieldType || Boolean.class == fieldType) |
| | | { |
| | | val = Convert.toBool(val, false); |
| | | } |
| | | if (Validator.isNotNull(fieldType)) |
| | | { |
| | | Excel attr = field.getAnnotation(Excel.class); |
| | | String propertyName = field.getName(); |
| | | if (Validator.isNotEmpty(attr.targetAttr())) |
| | | { |
| | | propertyName = field.getName() + "." + attr.targetAttr(); |
| | | } |
| | | else if (Validator.isNotEmpty(attr.readConverterExp())) |
| | | { |
| | | val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator()); |
| | | } |
| | | else if (Validator.isNotEmpty(attr.dictType())) |
| | | { |
| | | val = reverseDictByExp(Convert.toStr(val), attr.dictType(), attr.separator()); |
| | | } |
| | | ReflectUtils.invokeSetter(entity, propertyName, val); |
| | | } |
| | | } |
| | | list.add(entity); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 对listæ°æ®æºå°å
¶éé¢çæ°æ®å¯¼å
¥å°excel表å |
| | | * 对listæ°æ®æºå°å
¶éé¢çæ°æ®å¯¼å
¥å°excel表åï¼EasyExcelï¼ |
| | | * |
| | | * @param list å¯¼åºæ°æ®éå |
| | | * @param sheetName å·¥ä½è¡¨çåç§° |
| | | * @return ç»æ |
| | | */ |
| | | public AjaxResult exportExcel(List<T> list, String sheetName) |
| | | { |
| | | this.init(list, sheetName, Type.EXPORT); |
| | | return exportExcel(); |
| | | } |
| | | |
| | | /** |
| | | * 对listæ°æ®æºå°å
¶éé¢çæ°æ®å¯¼å
¥å°excel表å |
| | | * |
| | | * @param sheetName å·¥ä½è¡¨çåç§° |
| | | * @return ç»æ |
| | | */ |
| | | public AjaxResult importTemplateExcel(String sheetName) |
| | | { |
| | | this.init(null, sheetName, Type.IMPORT); |
| | | return exportExcel(); |
| | | } |
| | | |
| | | /** |
| | | * 对listæ°æ®æºå°å
¶éé¢çæ°æ®å¯¼å
¥å°excel表å |
| | | * |
| | | * @return ç»æ |
| | | */ |
| | | public AjaxResult exportExcel() |
| | | { |
| | | OutputStream out = null; |
| | | try |
| | | { |
| | | // ååºä¸å
±æå¤å°ä¸ªsheet. |
| | | double sheetNo = Math.ceil(list.size() / sheetSize); |
| | | for (int index = 0; index <= sheetNo; index++) |
| | | { |
| | | createSheet(sheetNo, index); |
| | | |
| | | // 产çä¸è¡ |
| | | Row row = sheet.createRow(0); |
| | | int column = 0; |
| | | // åå
¥åä¸ªåæ®µçå头åç§° |
| | | for (Object[] os : fields) |
| | | { |
| | | Excel excel = (Excel) os[1]; |
| | | this.createCell(excel, row, column++); |
| | | } |
| | | if (Type.EXPORT.equals(type)) |
| | | { |
| | | fillExcelData(index, row); |
| | | addStatisticsRow(); |
| | | } |
| | | } |
| | | public static <T> void exportExcel(List<T> list, String sheetName, Class<T> clazz, HttpServletResponse response) { |
| | | try { |
| | | String filename = encodingFilename(sheetName); |
| | | out = new FileOutputStream(getAbsoluteFile(filename)); |
| | | wb.write(out); |
| | | return AjaxResult.success(filename); |
| | | response.reset(); |
| | | response.addHeader("Access-Control-Allow-Origin", "*"); |
| | | response.addHeader("Access-Control-Expose-Headers", "Content-Disposition"); |
| | | FileUtils.setAttachmentResponseHeader(response, URLEncoder.encode(filename, StandardCharsets.UTF_8.toString())); |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"); |
| | | ServletOutputStream os = response.getOutputStream(); |
| | | EasyExcel.write(os, clazz) |
| | | .autoCloseStream(false) |
| | | // èªå¨éé
|
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | | .sheet(sheetName).doWrite(list); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException("导åºExcelå¼å¸¸"); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | log.error("导åºExcelå¼å¸¸{}", e.getMessage()); |
| | | throw new CustomException("导åºExcel失败ï¼è¯·èç³»ç½ç«ç®¡çåï¼"); |
| | | } |
| | | finally |
| | | { |
| | | if (wb != null) |
| | | { |
| | | try |
| | | { |
| | | wb.close(); |
| | | } |
| | | catch (IOException e1) |
| | | { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | if (out != null) |
| | | { |
| | | try |
| | | { |
| | | out.close(); |
| | | } |
| | | catch (IOException e1) |
| | | { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å¡«å
excelæ°æ® |
| | | * |
| | | * @param index åºå· |
| | | * @param row åå
æ ¼è¡ |
| | | */ |
| | | public void fillExcelData(int index, Row row) |
| | | { |
| | | int startNo = index * sheetSize; |
| | | int endNo = Math.min(startNo + sheetSize, list.size()); |
| | | for (int i = startNo; i < endNo; i++) |
| | | { |
| | | row = sheet.createRow(i + 1 - startNo); |
| | | // å¾å°å¯¼åºå¯¹è±¡. |
| | | T vo = (T) list.get(i); |
| | | int column = 0; |
| | | for (Object[] os : fields) |
| | | { |
| | | Field field = (Field) os[0]; |
| | | Excel excel = (Excel) os[1]; |
| | | // 设置å®ä½ç±»ç§æå±æ§å¯è®¿é® |
| | | field.setAccessible(true); |
| | | this.addCell(excel, row, vo, field, column++); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * åå»ºè¡¨æ ¼æ ·å¼ |
| | | * |
| | | * @param wb å·¥ä½è对象 |
| | | * @return æ ·å¼å表 |
| | | */ |
| | | private Map<String, CellStyle> createStyles(Workbook wb) |
| | | { |
| | | // åå
¥åæ¡è®°å½,æ¯æ¡è®°å½å¯¹åºexcel表ä¸çä¸è¡ |
| | | Map<String, CellStyle> styles = new HashMap<String, CellStyle>(); |
| | | CellStyle style = wb.createCellStyle(); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | style.setBorderRight(BorderStyle.THIN); |
| | | style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | style.setBorderLeft(BorderStyle.THIN); |
| | | style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | style.setBorderTop(BorderStyle.THIN); |
| | | style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | style.setBorderBottom(BorderStyle.THIN); |
| | | style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | Font dataFont = wb.createFont(); |
| | | dataFont.setFontName("Arial"); |
| | | dataFont.setFontHeightInPoints((short) 10); |
| | | style.setFont(dataFont); |
| | | styles.put("data", style); |
| | | |
| | | style = wb.createCellStyle(); |
| | | style.cloneStyleFrom(styles.get("data")); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | style.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
| | | Font headerFont = wb.createFont(); |
| | | headerFont.setFontName("Arial"); |
| | | headerFont.setFontHeightInPoints((short) 10); |
| | | headerFont.setBold(true); |
| | | headerFont.setColor(IndexedColors.WHITE.getIndex()); |
| | | style.setFont(headerFont); |
| | | styles.put("header", style); |
| | | |
| | | style = wb.createCellStyle(); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | Font totalFont = wb.createFont(); |
| | | totalFont.setFontName("Arial"); |
| | | totalFont.setFontHeightInPoints((short) 10); |
| | | style.setFont(totalFont); |
| | | styles.put("total", style); |
| | | |
| | | style = wb.createCellStyle(); |
| | | style.cloneStyleFrom(styles.get("data")); |
| | | style.setAlignment(HorizontalAlignment.LEFT); |
| | | styles.put("data1", style); |
| | | |
| | | style = wb.createCellStyle(); |
| | | style.cloneStyleFrom(styles.get("data")); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | styles.put("data2", style); |
| | | |
| | | style = wb.createCellStyle(); |
| | | style.cloneStyleFrom(styles.get("data")); |
| | | style.setAlignment(HorizontalAlignment.RIGHT); |
| | | styles.put("data3", style); |
| | | |
| | | return styles; |
| | | } |
| | | |
| | | /** |
| | | * å建åå
æ ¼ |
| | | */ |
| | | public Cell createCell(Excel attr, Row row, int column) |
| | | { |
| | | // å建å |
| | | Cell cell = row.createCell(column); |
| | | // åå
¥åä¿¡æ¯ |
| | | cell.setCellValue(attr.name()); |
| | | setDataValidation(attr, row, column); |
| | | cell.setCellStyle(styles.get("header")); |
| | | return cell; |
| | | } |
| | | |
| | | /** |
| | | * 设置åå
æ ¼ä¿¡æ¯ |
| | | * |
| | | * @param value åå
æ ¼å¼ |
| | | * @param attr 注解ç¸å
³ |
| | | * @param cell åå
æ ¼ä¿¡æ¯ |
| | | */ |
| | | public void setCellVo(Object value, Excel attr, Cell cell) |
| | | { |
| | | if (ColumnType.STRING == attr.cellType()) |
| | | { |
| | | cell.setCellValue(Validator.isNull(value) ? attr.defaultValue() : value + attr.suffix()); |
| | | } |
| | | else if (ColumnType.NUMERIC == attr.cellType()) |
| | | { |
| | | if (Validator.isNotNull(value)) |
| | | { |
| | | cell.setCellValue(StrUtil.contains(Convert.toStr(value), ".") ? Convert.toDouble(value) : Convert.toInt(value)); |
| | | } |
| | | } |
| | | else if (ColumnType.IMAGE == attr.cellType()) |
| | | { |
| | | ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) cell.getColumnIndex(), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() + 1), |
| | | cell.getRow().getRowNum() + 1); |
| | | String imagePath = Convert.toStr(value); |
| | | if (Validator.isNotEmpty(imagePath)) |
| | | { |
| | | byte[] data = ImageUtils.getImage(imagePath); |
| | | getDrawingPatriarch(cell.getSheet()).createPicture(anchor, |
| | | cell.getSheet().getWorkbook().addPicture(data, getImageType(data))); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åç»å¸ |
| | | */ |
| | | public static Drawing<?> getDrawingPatriarch(Sheet sheet) |
| | | { |
| | | if (sheet.getDrawingPatriarch() == null) |
| | | { |
| | | sheet.createDrawingPatriarch(); |
| | | } |
| | | return sheet.getDrawingPatriarch(); |
| | | } |
| | | |
| | | /** |
| | | * è·åå¾çç±»å,设置å¾çæå
¥ç±»å |
| | | */ |
| | | public int getImageType(byte[] value) |
| | | { |
| | | String type = FileTypeUtils.getFileExtendName(value); |
| | | if ("JPG".equalsIgnoreCase(type)) |
| | | { |
| | | return Workbook.PICTURE_TYPE_JPEG; |
| | | } |
| | | else if ("PNG".equalsIgnoreCase(type)) |
| | | { |
| | | return Workbook.PICTURE_TYPE_PNG; |
| | | } |
| | | return Workbook.PICTURE_TYPE_JPEG; |
| | | } |
| | | |
| | | /** |
| | | * åå»ºè¡¨æ ¼æ ·å¼ |
| | | */ |
| | | public void setDataValidation(Excel attr, Row row, int column) |
| | | { |
| | | if (attr.name().indexOf("注ï¼") >= 0) |
| | | { |
| | | sheet.setColumnWidth(column, 6000); |
| | | } |
| | | else |
| | | { |
| | | // 设置å宽 |
| | | sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256)); |
| | | } |
| | | // å¦æè®¾ç½®äºæç¤ºä¿¡æ¯åé¼ æ æ¾ä¸å»æç¤º. |
| | | if (Validator.isNotEmpty(attr.prompt())) |
| | | { |
| | | // è¿éé»è®¤è®¾äº2-101åæç¤º. |
| | | setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column); |
| | | } |
| | | // å¦æè®¾ç½®äºcombo屿§åæ¬ååªè½éæ©ä¸è½è¾å
¥ |
| | | if (attr.combo().length > 0) |
| | | { |
| | | // è¿éé»è®¤è®¾äº2-101ååªè½éæ©ä¸è½è¾å
¥. |
| | | setXSSFValidation(sheet, attr.combo(), 1, 100, column, column); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ·»å åå
æ ¼ |
| | | */ |
| | | public Cell addCell(Excel attr, Row row, T vo, Field field, int column) |
| | | { |
| | | Cell cell = null; |
| | | try |
| | | { |
| | | // 设置è¡é« |
| | | row.setHeight(maxHeight); |
| | | // æ ¹æ®Excelä¸è®¾ç½®æ
åµå³å®æ¯å¦å¯¼åº,æäºæ
åµéè¦ä¿æä¸ºç©º,å¸æç¨æ·å¡«åè¿ä¸å. |
| | | if (attr.isExport()) |
| | | { |
| | | // å建cell |
| | | cell = row.createCell(column); |
| | | int align = attr.align().value(); |
| | | cell.setCellStyle(styles.get("data" + (align >= 1 && align <= 3 ? align : ""))); |
| | | |
| | | // ç¨äºè¯»å对象ä¸ç屿§ |
| | | Object value = getTargetValue(vo, field, attr); |
| | | String dateFormat = attr.dateFormat(); |
| | | String readConverterExp = attr.readConverterExp(); |
| | | String separator = attr.separator(); |
| | | String dictType = attr.dictType(); |
| | | if (Validator.isNotEmpty(dateFormat) && Validator.isNotNull(value)) |
| | | { |
| | | cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value)); |
| | | } |
| | | else if (Validator.isNotEmpty(readConverterExp) && Validator.isNotNull(value)) |
| | | { |
| | | cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator)); |
| | | } |
| | | else if (Validator.isNotEmpty(dictType) && Validator.isNotNull(value)) |
| | | { |
| | | cell.setCellValue(convertDictByExp(Convert.toStr(value), dictType, separator)); |
| | | } |
| | | else if (value instanceof BigDecimal && -1 != attr.scale()) |
| | | { |
| | | cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).toString()); |
| | | } |
| | | else |
| | | { |
| | | // 设置åç±»å |
| | | setCellVo(value, attr, cell); |
| | | } |
| | | addStatisticsData(column, Convert.toStr(value), attr); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | log.error("导åºExcel失败{}", e); |
| | | } |
| | | return cell; |
| | | } |
| | | |
| | | /** |
| | | * 设置 POI XSSFSheet åå
æ ¼æç¤º |
| | | * |
| | | * @param sheet 表å |
| | | * @param promptTitle æç¤ºæ é¢ |
| | | * @param promptContent æç¤ºå
容 |
| | | * @param firstRow å¼å§è¡ |
| | | * @param endRow ç»æè¡ |
| | | * @param firstCol å¼å§å |
| | | * @param endCol ç»æå |
| | | */ |
| | | public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow, |
| | | int firstCol, int endCol) |
| | | { |
| | | DataValidationHelper helper = sheet.getDataValidationHelper(); |
| | | DataValidationConstraint constraint = helper.createCustomConstraint("DD1"); |
| | | CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); |
| | | DataValidation dataValidation = helper.createValidation(constraint, regions); |
| | | dataValidation.createPromptBox(promptTitle, promptContent); |
| | | dataValidation.setShowPromptBox(true); |
| | | sheet.addValidationData(dataValidation); |
| | | } |
| | | |
| | | /** |
| | | * 设置æäºåçå¼åªè½è¾å
¥é¢å¶çæ°æ®,æ¾ç¤ºä¸ææ¡. |
| | | * |
| | | * @param sheet è¦è®¾ç½®çsheet. |
| | | * @param textlist ä¸ææ¡æ¾ç¤ºçå
容 |
| | | * @param firstRow å¼å§è¡ |
| | | * @param endRow ç»æè¡ |
| | | * @param firstCol å¼å§å |
| | | * @param endCol ç»æå |
| | | * @return 设置好çsheet. |
| | | */ |
| | | public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol) |
| | | { |
| | | DataValidationHelper helper = sheet.getDataValidationHelper(); |
| | | // å è½½ä¸æå表å
容 |
| | | DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist); |
| | | // è®¾ç½®æ°æ®æææ§å è½½å¨åªä¸ªåå
æ ¼ä¸,åä¸ªåæ°å嫿¯ï¼èµ·å§è¡ãç»æ¢è¡ãèµ·å§åãç»æ¢å |
| | | CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); |
| | | // æ°æ®æææ§å¯¹è±¡ |
| | | DataValidation dataValidation = helper.createValidation(constraint, regions); |
| | | // å¤çExcelå
¼å®¹æ§é®é¢ |
| | | if (dataValidation instanceof XSSFDataValidation) |
| | | { |
| | | dataValidation.setSuppressDropDownArrow(true); |
| | | dataValidation.setShowErrorBox(true); |
| | | } |
| | | else |
| | | { |
| | | dataValidation.setSuppressDropDownArrow(false); |
| | | } |
| | | |
| | | sheet.addValidationData(dataValidation); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param separator åé符 |
| | | * @return è§£æåå¼ |
| | | */ |
| | | public static String convertByExp(String propertyValue, String converterExp, String separator) |
| | | { |
| | | public static String convertByExp(String propertyValue, String converterExp, String separator) { |
| | | StringBuilder propertyString = new StringBuilder(); |
| | | String[] convertSource = converterExp.split(","); |
| | | for (String item : convertSource) |
| | | { |
| | | for (String item : convertSource) { |
| | | String[] itemArray = item.split("="); |
| | | if (StrUtil.containsAny(propertyValue, separator)) |
| | | { |
| | | for (String value : propertyValue.split(separator)) |
| | | { |
| | | if (itemArray[0].equals(value)) |
| | | { |
| | | if (StringUtils.containsAny(separator, propertyValue)) { |
| | | for (String value : propertyValue.split(separator)) { |
| | | if (itemArray[0].equals(value)) { |
| | | propertyString.append(itemArray[1] + separator); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (itemArray[0].equals(propertyValue)) |
| | | { |
| | | } else { |
| | | if (itemArray[0].equals(propertyValue)) { |
| | | return itemArray[1]; |
| | | } |
| | | } |
| | | } |
| | | return StrUtil.strip(propertyString.toString(), null,separator); |
| | | return StringUtils.stripEnd(propertyString.toString(), separator); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param separator åé符 |
| | | * @return è§£æåå¼ |
| | | */ |
| | | public static String reverseByExp(String propertyValue, String converterExp, String separator) |
| | | { |
| | | public static String reverseByExp(String propertyValue, String converterExp, String separator) { |
| | | StringBuilder propertyString = new StringBuilder(); |
| | | String[] convertSource = converterExp.split(","); |
| | | for (String item : convertSource) |
| | | { |
| | | for (String item : convertSource) { |
| | | String[] itemArray = item.split("="); |
| | | if (StrUtil.containsAny(propertyValue, separator)) |
| | | { |
| | | for (String value : propertyValue.split(separator)) |
| | | { |
| | | if (itemArray[1].equals(value)) |
| | | { |
| | | if (StringUtils.containsAny(separator, propertyValue)) { |
| | | for (String value : propertyValue.split(separator)) { |
| | | if (itemArray[1].equals(value)) { |
| | | propertyString.append(itemArray[0] + separator); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (itemArray[1].equals(propertyValue)) |
| | | { |
| | | } else { |
| | | if (itemArray[1].equals(propertyValue)) { |
| | | return itemArray[0]; |
| | | } |
| | | } |
| | | } |
| | | return StrUtil.strip(propertyString.toString(), null,separator); |
| | | return StringUtils.stripEnd(propertyString.toString(), separator); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param separator åé符 |
| | | * @return åå
¸æ ç¾ |
| | | */ |
| | | public static String convertDictByExp(String dictValue, String dictType, String separator) |
| | | { |
| | | public static String convertDictByExp(String dictValue, String dictType, String separator) { |
| | | return DictUtils.getDictLabel(dictType, dictValue, separator); |
| | | } |
| | | |
| | |
| | | * @param separator åé符 |
| | | * @return åå
¸å¼ |
| | | */ |
| | | public static String reverseDictByExp(String dictLabel, String dictType, String separator) |
| | | { |
| | | public static String reverseDictByExp(String dictLabel, String dictType, String separator) { |
| | | return DictUtils.getDictValue(dictType, dictLabel, separator); |
| | | } |
| | | |
| | | /** |
| | | * å计ç»è®¡ä¿¡æ¯ |
| | | */ |
| | | private void addStatisticsData(Integer index, String text, Excel entity) |
| | | { |
| | | if (entity != null && entity.isStatistics()) |
| | | { |
| | | Double temp = 0D; |
| | | if (!statistics.containsKey(index)) |
| | | { |
| | | statistics.put(index, temp); |
| | | } |
| | | try |
| | | { |
| | | temp = Double.valueOf(text); |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | | } |
| | | statistics.put(index, statistics.get(index) + temp); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å建ç»è®¡è¡ |
| | | */ |
| | | public void addStatisticsRow() |
| | | { |
| | | if (statistics.size() > 0) |
| | | { |
| | | Cell cell = null; |
| | | Row row = sheet.createRow(sheet.getLastRowNum() + 1); |
| | | Set<Integer> keys = statistics.keySet(); |
| | | cell = row.createCell(0); |
| | | cell.setCellStyle(styles.get("total")); |
| | | cell.setCellValue("å计"); |
| | | |
| | | for (Integer key : keys) |
| | | { |
| | | cell = row.createCell(key); |
| | | cell.setCellStyle(styles.get("total")); |
| | | cell.setCellValue(DOUBLE_FORMAT.format(statistics.get(key))); |
| | | } |
| | | statistics.clear(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ç¼ç æä»¶å |
| | | */ |
| | | public String encodingFilename(String filename) |
| | | { |
| | | filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx"; |
| | | return filename; |
| | | public static String encodingFilename(String filename) { |
| | | return IdUtil.fastSimpleUUID() + "_" + filename + ".xlsx"; |
| | | } |
| | | |
| | | /** |
| | | * è·åä¸è½½è·¯å¾ |
| | | * |
| | | * @param filename æä»¶åç§° |
| | | */ |
| | | public String getAbsoluteFile(String filename) |
| | | { |
| | | String downloadPath = RuoYiConfig.getDownloadPath() + filename; |
| | | File desc = new File(downloadPath); |
| | | if (!desc.getParentFile().exists()) |
| | | { |
| | | desc.getParentFile().mkdirs(); |
| | | } |
| | | return downloadPath; |
| | | } |
| | | |
| | | /** |
| | | * è·åbeanä¸ç屿§å¼ |
| | | * |
| | | * @param vo å®ä½å¯¹è±¡ |
| | | * @param field åæ®µ |
| | | * @param excel 注解 |
| | | * @return æç»ç屿§å¼ |
| | | * @throws Exception |
| | | */ |
| | | private Object getTargetValue(T vo, Field field, Excel excel) throws Exception |
| | | { |
| | | Object o = field.get(vo); |
| | | if (Validator.isNotEmpty(excel.targetAttr())) |
| | | { |
| | | String target = excel.targetAttr(); |
| | | if (target.contains(".")) |
| | | { |
| | | String[] targets = target.split("[.]"); |
| | | for (String name : targets) |
| | | { |
| | | o = getValue(o, name); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | o = getValue(o, target); |
| | | } |
| | | } |
| | | return o; |
| | | } |
| | | |
| | | /** |
| | | * 以类ç屿§çgetæ¹æ³æ¹æ³å½¢å¼è·åå¼ |
| | | * |
| | | * @param o |
| | | * @param name |
| | | * @return value |
| | | * @throws Exception |
| | | */ |
| | | private Object getValue(Object o, String name) throws Exception |
| | | { |
| | | if (Validator.isNotNull(o) && Validator.isNotEmpty(name)) |
| | | { |
| | | Class<?> clazz = o.getClass(); |
| | | Field field = clazz.getDeclaredField(name); |
| | | field.setAccessible(true); |
| | | o = field.get(o); |
| | | } |
| | | return o; |
| | | } |
| | | |
| | | /** |
| | | * å¾å°ææå®ä¹å段 |
| | | */ |
| | | private void createExcelField() |
| | | { |
| | | this.fields = new ArrayList<Object[]>(); |
| | | List<Field> tempFields = new ArrayList<>(); |
| | | tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields())); |
| | | tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); |
| | | for (Field field : tempFields) |
| | | { |
| | | // åæ³¨è§£ |
| | | if (field.isAnnotationPresent(Excel.class)) |
| | | { |
| | | putToField(field, field.getAnnotation(Excel.class)); |
| | | } |
| | | |
| | | // 夿³¨è§£ |
| | | if (field.isAnnotationPresent(Excels.class)) |
| | | { |
| | | Excels attrs = field.getAnnotation(Excels.class); |
| | | Excel[] excels = attrs.value(); |
| | | for (Excel excel : excels) |
| | | { |
| | | putToField(field, excel); |
| | | } |
| | | } |
| | | } |
| | | this.fields = this.fields.stream().sorted(Comparator.comparing(objects -> ((Excel) objects[1]).sort())).collect(Collectors.toList()); |
| | | this.maxHeight = getRowHeight(); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®æ³¨è§£è·åæå¤§è¡é« |
| | | */ |
| | | public short getRowHeight() |
| | | { |
| | | double maxHeight = 0; |
| | | for (Object[] os : this.fields) |
| | | { |
| | | Excel excel = (Excel) os[1]; |
| | | maxHeight = maxHeight > excel.height() ? maxHeight : excel.height(); |
| | | } |
| | | return (short) (maxHeight * 20); |
| | | } |
| | | |
| | | /** |
| | | * æ¾å°å段éåä¸ |
| | | */ |
| | | private void putToField(Field field, Excel attr) |
| | | { |
| | | if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) |
| | | { |
| | | this.fields.add(new Object[] { field, attr }); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å建ä¸ä¸ªå·¥ä½ç°¿ |
| | | */ |
| | | public void createWorkbook() |
| | | { |
| | | this.wb = new SXSSFWorkbook(500); |
| | | } |
| | | |
| | | /** |
| | | * å建工ä½è¡¨ |
| | | * |
| | | * @param sheetNo sheetæ°é |
| | | * @param index åºå· |
| | | */ |
| | | public void createSheet(double sheetNo, int index) |
| | | { |
| | | this.sheet = wb.createSheet(); |
| | | this.styles = createStyles(wb); |
| | | // 设置工ä½è¡¨çåç§°. |
| | | if (sheetNo == 0) |
| | | { |
| | | wb.setSheetName(index, sheetName); |
| | | } |
| | | else |
| | | { |
| | | wb.setSheetName(index, sheetName + index); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·ååå
æ ¼å¼ |
| | | * |
| | | * @param row è·åçè¡ |
| | | * @param column è·ååå
æ ¼åå· |
| | | * @return åå
æ ¼å¼ |
| | | */ |
| | | public Object getCellValue(Row row, int column) |
| | | { |
| | | if (row == null) |
| | | { |
| | | return row; |
| | | } |
| | | Object val = ""; |
| | | try |
| | | { |
| | | Cell cell = row.getCell(column); |
| | | if (Validator.isNotNull(cell)) |
| | | { |
| | | if (cell.getCellType() == CellType.NUMERIC || cell.getCellType() == CellType.FORMULA) |
| | | { |
| | | val = cell.getNumericCellValue(); |
| | | if (DateUtil.isCellDateFormatted(cell)) |
| | | { |
| | | val = DateUtil.getJavaDate((Double) val); // POI Excel æ¥ææ ¼å¼è½¬æ¢ |
| | | } |
| | | else |
| | | { |
| | | if ((Double) val % 1 != 0) |
| | | { |
| | | val = new BigDecimal(val.toString()); |
| | | } |
| | | else |
| | | { |
| | | val = new DecimalFormat("0").format(val); |
| | | } |
| | | } |
| | | } |
| | | else if (cell.getCellType() == CellType.STRING) |
| | | { |
| | | val = cell.getStringCellValue(); |
| | | } |
| | | else if (cell.getCellType() == CellType.BOOLEAN) |
| | | { |
| | | val = cell.getBooleanCellValue(); |
| | | } |
| | | else if (cell.getCellType() == CellType.ERROR) |
| | | { |
| | | val = cell.getErrorCellValue(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return val; |
| | | } |
| | | return val; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.common.utils.reflect; |
| | | |
| | | import cn.hutool.core.util.ReflectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * åå°å·¥å
·ç±». æä¾è°ç¨getter/setteræ¹æ³, 访é®ç§æåé, è°ç¨ç§ææ¹æ³, è·åæ³åç±»åClass, 被AOPè¿ççå®ç±»çå·¥å
·å½æ°. |
| | |
| | | @SuppressWarnings("unchecked") |
| | | public static <E> E invokeGetter(Object obj, String propertyName) { |
| | | Object object = obj; |
| | | for (String name : StrUtil.split(propertyName, ".")) { |
| | | String getterMethodName = GETTER_PREFIX + StrUtil.upperFirst(name); |
| | | for (String name : StringUtils.split(propertyName, ".")) { |
| | | String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name); |
| | | object = invoke(object, getterMethodName); |
| | | } |
| | | return (E) object; |
| | |
| | | */ |
| | | public static <E> void invokeSetter(Object obj, String propertyName, E value) { |
| | | Object object = obj; |
| | | List<String> names = StrUtil.split(propertyName, "."); |
| | | for (int i = 0; i < names.size(); i++) { |
| | | if (i < names.size() - 1) { |
| | | String getterMethodName = GETTER_PREFIX + StrUtil.upperFirst(names.get(i)); |
| | | String[] names = StringUtils.split(propertyName, "."); |
| | | for (int i = 0; i < names.length; i++) { |
| | | if (i < names.length - 1) { |
| | | String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]); |
| | | object = invoke(object, getterMethodName); |
| | | } else { |
| | | String setterMethodName = SETTER_PREFIX + StrUtil.upperFirst(names.get(i)); |
| | | String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]); |
| | | Method method = getMethodByName(object.getClass(), setterMethodName); |
| | | invoke(object, method, value); |
| | | } |
| | |
| | | package com.ruoyi.common.utils.sql; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.ruoyi.common.exception.BaseException; |
| | | import com.ruoyi.common.exception.UtilException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | /** |
| | | * sqlæä½å·¥å
·ç±» |
| | |
| | | */ |
| | | public static String escapeOrderBySql(String value) |
| | | { |
| | | if (Validator.isNotEmpty(value) && !isValidOrderBySql(value)) |
| | | if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value)) |
| | | { |
| | | throw new BaseException("åæ°ä¸ç¬¦åè§èï¼ä¸è½è¿è¡æ¥è¯¢"); |
| | | throw new UtilException("åæ°ä¸ç¬¦åè§èï¼ä¸è½è¿è¡æ¥è¯¢"); |
| | | } |
| | | return value; |
| | | } |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.6.0</version> |
| | | <version>3.0.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.demo.domain.TestDemo; |
| | | import com.ruoyi.demo.service.ITestDemoService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | |
| | | * @author Lion Li |
| | | * @date 2021-05-30 |
| | | */ |
| | | @Api(value = "æµè¯æ¹éæ¹æ³", tags = {"æµè¯æ¹éæ¹æ³"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RestController |
| | | @RequestMapping("/demo/batch") |
| | |
| | | /** |
| | | * æ°å¢æ¹éæ¹æ³ ( å
¨éè¦çå¡«å
) |
| | | */ |
| | | @ApiOperation(value = "æ°å¢æ¹éæ¹æ³") |
| | | @PostMapping() |
| | | // @DataSource(DataSourceType.SLAVE) |
| | | public AjaxResult<Void> add() { |
| | | List<TestDemo> list = new ArrayList<>(); |
| | | for (int i = 0; i < 1000; i++) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹æ¹éæ¹æ³ |
| | | * å 餿¹éæ¹æ³ |
| | | */ |
| | | @ApiOperation(value = "å 餿¹éæ¹æ³") |
| | | @DeleteMapping() |
| | | public AjaxResult<Void> edit() { |
| | | // @DataSource(DataSourceType.SLAVE) |
| | | public AjaxResult<Void> remove() { |
| | | return toAjax(iTestDemoService.remove(new LambdaQueryWrapper<TestDemo>() |
| | | .eq(TestDemo::getOrderNum, -1L)) ? 1 : 0); |
| | | } |
| | |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.constraints.NotEmpty; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * æµè¯å表Controller |
| | |
| | | @PreAuthorize("@ss.hasPermi('demo:demo:export')") |
| | | @Log(title = "æµè¯å表", businessType = BusinessType.EXPORT) |
| | | @GetMapping("/export") |
| | | public AjaxResult<TestDemoVo> export(@Validated TestDemoBo bo) { |
| | | public void export(@Validated TestDemoBo bo, HttpServletResponse response) { |
| | | List<TestDemoVo> list = iTestDemoService.queryList(bo); |
| | | ExcelUtil<TestDemoVo> util = new ExcelUtil<TestDemoVo>(TestDemoVo.class); |
| | | return util.exportExcel(list, "æµè¯å表"); |
| | | ExcelUtil.exportExcel(list, "æµè¯å表", TestDemoVo.class, response); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("æ°å¢æµè¯å表") |
| | | @PreAuthorize("@ss.hasPermi('demo:demo:add')") |
| | | @Log(title = "æµè¯å表", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit |
| | | @RepeatSubmit(intervalTime = 2, timeUnit = TimeUnit.SECONDS) |
| | | @PostMapping() |
| | | public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody TestDemoBo bo) { |
| | | return toAjax(iTestDemoService.insertByBo(bo) ? 1 : 0); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.demo.controller; |
| | | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.MessageUtils; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | |
| | | /** |
| | | * æµè¯å½é
å |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/demo/i18n") |
| | | public class TestI18nController { |
| | | |
| | | /** |
| | | * éè¿codeè·åå½é
åå
容 |
| | | * code为 messages.properties ä¸ç key |
| | | * |
| | | * æµè¯ä½¿ç¨ user.register.success |
| | | */ |
| | | @GetMapping() |
| | | public AjaxResult<Void> get(String code) { |
| | | return AjaxResult.success(MessageUtils.message(code)); |
| | | } |
| | | } |
| | |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.constraints.NotEmpty; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Arrays; |
| | |
| | | @PreAuthorize("@ss.hasPermi('demo:tree:export')") |
| | | @Log(title = "æµè¯æ 表", businessType = BusinessType.EXPORT) |
| | | @GetMapping("/export") |
| | | public AjaxResult<TestTreeVo> export(@Validated TestTreeBo bo) { |
| | | public void export(@Validated TestTreeBo bo, HttpServletResponse response) { |
| | | List<TestTreeVo> list = iTestTreeService.queryList(bo); |
| | | ExcelUtil<TestTreeVo> util = new ExcelUtil<TestTreeVo>(TestTreeVo.class); |
| | | return util.exportExcel(list, "æµè¯æ 表"); |
| | | ExcelUtil.exportExcel(list, "æµè¯æ 表", TestTreeVo.class, response); |
| | | } |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.demo.domain.vo; |
| | | |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | |
| | |
| | | */ |
| | | @Data |
| | | @ApiModel("æµè¯å表è§å¾å¯¹è±¡") |
| | | @ExcelIgnoreUnannotated |
| | | public class TestDemoVo { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | |
| | | /** |
| | | * é¨é¨id |
| | | */ |
| | | @Excel(name = "é¨é¨id") |
| | | @ExcelProperty(value = "é¨é¨id") |
| | | @ApiModelProperty("é¨é¨id") |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * ç¨æ·id |
| | | */ |
| | | @Excel(name = "ç¨æ·id") |
| | | @ExcelProperty(value = "ç¨æ·id") |
| | | @ApiModelProperty("ç¨æ·id") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * æåºå· |
| | | */ |
| | | @Excel(name = "æåºå·") |
| | | @ExcelProperty(value = "æåºå·") |
| | | @ApiModelProperty("æåºå·") |
| | | private Long orderNum; |
| | | |
| | | /** |
| | | * keyé® |
| | | */ |
| | | @Excel(name = "keyé®") |
| | | @ExcelProperty(value = "keyé®") |
| | | @ApiModelProperty("keyé®") |
| | | private String testKey; |
| | | |
| | | /** |
| | | * å¼ |
| | | */ |
| | | @Excel(name = "å¼") |
| | | @ExcelProperty(value = "å¼") |
| | | @ApiModelProperty("å¼") |
| | | private String value; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @Excel(name = "å建æ¶é´" , width = 30, dateFormat = "yyyy-MM-dd") |
| | | @ExcelProperty(value = "å建æ¶é´") |
| | | @ApiModelProperty("å建æ¶é´") |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * å建人 |
| | | */ |
| | | @Excel(name = "å建人") |
| | | @ExcelProperty(value = "å建人") |
| | | @ApiModelProperty("å建人") |
| | | private String createBy; |
| | | |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @Excel(name = "æ´æ°æ¶é´" , width = 30, dateFormat = "yyyy-MM-dd") |
| | | @ExcelProperty(value = "æ´æ°æ¶é´") |
| | | @ApiModelProperty("æ´æ°æ¶é´") |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * æ´æ°äºº |
| | | */ |
| | | @Excel(name = "æ´æ°äºº") |
| | | @ExcelProperty(value = "æ´æ°äºº") |
| | | @ApiModelProperty("æ´æ°äºº") |
| | | private String updateBy; |
| | | |
| | |
| | | package com.ruoyi.demo.domain.vo; |
| | | |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | |
| | |
| | | */ |
| | | @Data |
| | | @ApiModel("æµè¯æ 表è§å¾å¯¹è±¡") |
| | | @ExcelIgnoreUnannotated |
| | | public class TestTreeVo { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | |
| | | /** |
| | | * ç¶id |
| | | */ |
| | | @Excel(name = "ç¶id") |
| | | @ExcelProperty(value = "ç¶id") |
| | | @ApiModelProperty("ç¶id") |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * é¨é¨id |
| | | */ |
| | | @Excel(name = "é¨é¨id") |
| | | @ExcelProperty(value = "é¨é¨id") |
| | | @ApiModelProperty("é¨é¨id") |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * ç¨æ·id |
| | | */ |
| | | @Excel(name = "ç¨æ·id") |
| | | @ExcelProperty(value = "ç¨æ·id") |
| | | @ApiModelProperty("ç¨æ·id") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * æ èç¹å |
| | | */ |
| | | @Excel(name = "æ èç¹å") |
| | | @ExcelProperty(value = "æ èç¹å") |
| | | @ApiModelProperty("æ èç¹å") |
| | | private String treeName; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @Excel(name = "å建æ¶é´" , width = 30, dateFormat = "yyyy-MM-dd") |
| | | @ExcelProperty(value = "å建æ¶é´") |
| | | @ApiModelProperty("å建æ¶é´") |
| | | private Date createTime; |
| | | |
| | |
| | | package com.ruoyi.demo.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | Map<String, Object> params = bo.getParams(); |
| | | Object dataScope = params.get("dataScope"); |
| | | LambdaQueryWrapper<TestDemo> lqw = Wrappers.lambdaQuery(); |
| | | lqw.like(StrUtil.isNotBlank(bo.getTestKey()), TestDemo::getTestKey, bo.getTestKey()); |
| | | lqw.eq(StrUtil.isNotBlank(bo.getValue()), TestDemo::getValue, bo.getValue()); |
| | | lqw.like(StringUtils.isNotBlank(bo.getTestKey()), TestDemo::getTestKey, bo.getTestKey()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getValue()), TestDemo::getValue, bo.getValue()); |
| | | lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null, |
| | | TestDemo::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime")); |
| | | lqw.apply(dataScope != null && StrUtil.isNotBlank(dataScope.toString()), |
| | | lqw.apply(dataScope != null && StringUtils.isNotBlank(dataScope.toString()), |
| | | dataScope != null ? dataScope.toString() : null); |
| | | return lqw; |
| | | } |
| | |
| | | package com.ruoyi.demo.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | |
| | | Map<String, Object> params = bo.getParams(); |
| | | Object dataScope = params.get("dataScope"); |
| | | LambdaQueryWrapper<TestTree> lqw = Wrappers.lambdaQuery(); |
| | | lqw.like(StrUtil.isNotBlank(bo.getTreeName()), TestTree::getTreeName, bo.getTreeName()); |
| | | lqw.like(StringUtils.isNotBlank(bo.getTreeName()), TestTree::getTreeName, bo.getTreeName()); |
| | | lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null, |
| | | TestTree::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime")); |
| | | lqw.apply(dataScope != null && StrUtil.isNotBlank(dataScope.toString()), |
| | | lqw.apply(dataScope != null && StringUtils.isNotBlank(dataScope.toString()), |
| | | dataScope != null ? dataScope.toString() : null); |
| | | return lqw; |
| | | } |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.6.0</version> |
| | | <version>3.0.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <artifactId>ruoyi-extend</artifactId> |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-extend</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.6.0</version> |
| | | <version>3.0.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <packaging>jar</packaging> |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.6.0</version> |
| | | <version>3.0.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | |
| | | package com.ruoyi.framework.aspectj; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.reflect.ReflectUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | |
| | | } |
| | | // è·åå½åçç¨æ· |
| | | LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest()); |
| | | if (Validator.isNotNull(loginUser)) { |
| | | if (StringUtils.isNotNull(loginUser)) { |
| | | SysUser currentUser = loginUser.getUser(); |
| | | // 妿æ¯è¶
级管çåï¼åä¸è¿æ»¤æ°æ® |
| | | if (Validator.isNotNull(currentUser) && !currentUser.isAdmin()) { |
| | | if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) { |
| | | dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), |
| | | controllerDataScope.userAlias(), controllerDataScope.isUser()); |
| | | } |
| | |
| | | StringBuilder sqlString = new StringBuilder(); |
| | | |
| | | // å° "." æååº,ä¸åå«å为å表æ¥è¯¢,åå«å为å¤è¡¨æ¥è¯¢ |
| | | deptAlias = StrUtil.isNotBlank(deptAlias) ? deptAlias + "." : ""; |
| | | userAlias = StrUtil.isNotBlank(userAlias) ? userAlias + "." : ""; |
| | | deptAlias = StringUtils.isNotBlank(deptAlias) ? deptAlias + "." : ""; |
| | | userAlias = StringUtils.isNotBlank(userAlias) ? userAlias + "." : ""; |
| | | |
| | | for (SysRole role : user.getRoles()) { |
| | | String dataScope = role.getDataScope(); |
| | |
| | | sqlString = new StringBuilder(); |
| | | break; |
| | | } else if (DATA_SCOPE_CUSTOM.equals(dataScope)) { |
| | | sqlString.append(StrUtil.format( |
| | | sqlString.append(StringUtils.format( |
| | | " OR {}dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", |
| | | deptAlias, role.getRoleId())); |
| | | } else if (DATA_SCOPE_DEPT.equals(dataScope)) { |
| | | sqlString.append(StrUtil.format(" OR {}dept_id = {} ", |
| | | sqlString.append(StringUtils.format(" OR {}dept_id = {} ", |
| | | deptAlias, user.getDeptId())); |
| | | } else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) { |
| | | sqlString.append(StrUtil.format( |
| | | sqlString.append(StringUtils.format( |
| | | " OR {}dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", |
| | | deptAlias, user.getDeptId(), user.getDeptId())); |
| | | } else if (DATA_SCOPE_SELF.equals(dataScope)) { |
| | | if (isUser) { |
| | | sqlString.append(StrUtil.format(" OR {}user_id = {} ", |
| | | sqlString.append(StringUtils.format(" OR {}user_id = {} ", |
| | | userAlias, user.getUserId())); |
| | | } else { |
| | | // æ°æ®æé为ä»
æ¬äººä¸æ²¡æuserAliaså«å䏿¥è¯¢ä»»ä½æ°æ® |
| | |
| | | } |
| | | } |
| | | |
| | | if (StrUtil.isNotBlank(sqlString.toString())) { |
| | | if (StringUtils.isNotBlank(sqlString.toString())) { |
| | | putDataScope(joinPoint, sqlString.substring(4)); |
| | | } |
| | | } |
| | |
| | | */ |
| | | private void clearDataScope(final JoinPoint joinPoint) { |
| | | Object params = joinPoint.getArgs()[0]; |
| | | if (Validator.isNotNull(params)) { |
| | | if (StringUtils.isNotNull(params)) { |
| | | putDataScope(joinPoint, ""); |
| | | } |
| | | } |
| | | |
| | | private static void putDataScope(JoinPoint joinPoint, String sql) { |
| | | Object params = joinPoint.getArgs()[0]; |
| | | if (Validator.isNotNull(params)) { |
| | | if (StringUtils.isNotNull(params)) { |
| | | if (params instanceof BaseEntity) { |
| | | BaseEntity baseEntity = (BaseEntity) params; |
| | | baseEntity.getParams().put(DATA_SCOPE, sql); |
| | |
| | | package com.ruoyi.framework.aspectj; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; |
| | | import com.ruoyi.common.annotation.DataSource; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.annotation.Around; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | |
| | | public Object around(ProceedingJoinPoint point) throws Throwable { |
| | | DataSource dataSource = getDataSource(point); |
| | | |
| | | if (Validator.isNotNull(dataSource)) { |
| | | if (StringUtils.isNotNull(dataSource)) { |
| | | DynamicDataSourceContextHolder.poll(); |
| | | String source = dataSource.value().getSource(); |
| | | DynamicDataSourceContextHolder.push(source); |
| | |
| | | package com.ruoyi.framework.aspectj; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.enums.BusinessStatus; |
| | | import com.ruoyi.common.enums.HttpMethod; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.framework.web.service.AsyncService; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | |
| | | if (e != null) |
| | | { |
| | | operLog.setStatus(BusinessStatus.FAIL.ordinal()); |
| | | operLog.setErrorMsg(StrUtil.sub(e.getMessage(), 0, 2000)); |
| | | operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000)); |
| | | } |
| | | // è®¾ç½®æ¹æ³åç§° |
| | | String className = joinPoint.getTarget().getClass().getName(); |
| | |
| | | if (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)) |
| | | { |
| | | String params = argsArrayToString(joinPoint.getArgs()); |
| | | operLog.setOperParam(StrUtil.sub(params, 0, 2000)); |
| | | operLog.setOperParam(StringUtils.substring(params, 0, 2000)); |
| | | } |
| | | else |
| | | { |
| | | Map<?, ?> paramsMap = (Map<?, ?>) ServletUtils.getRequest().getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE); |
| | | operLog.setOperParam(StrUtil.sub(paramsMap.toString(), 0, 2000)); |
| | | operLog.setOperParam(StringUtils.substring(paramsMap.toString(), 0, 2000)); |
| | | } |
| | | } |
| | | |
| | |
| | | if (paramsArray != null && paramsArray.length > 0) |
| | | { |
| | | for (Object o : paramsArray) { |
| | | if (Validator.isNotNull(o) && !isFilterObject(o)) { |
| | | if (StringUtils.isNotNull(o) && !isFilterObject(o)) { |
| | | params.append(JsonUtils.toJsonString(o)).append(" "); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.aspectj; |
| | | |
| | | import com.ruoyi.common.annotation.RateLimiter; |
| | | import com.ruoyi.common.enums.LimitType; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.aspectj.lang.Signature; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.annotation.Before; |
| | | import org.aspectj.lang.annotation.Pointcut; |
| | | import org.aspectj.lang.reflect.MethodSignature; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.core.script.RedisScript; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * éæµå¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Aspect |
| | | @Component |
| | | public class RateLimiterAspect |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(RateLimiterAspect.class); |
| | | |
| | | private RedisTemplate<Object, Object> redisTemplate; |
| | | |
| | | private RedisScript<Long> limitScript; |
| | | |
| | | @Autowired |
| | | public void setRedisTemplate1(RedisTemplate<Object, Object> redisTemplate) |
| | | { |
| | | this.redisTemplate = redisTemplate; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setLimitScript(RedisScript<Long> limitScript) |
| | | { |
| | | this.limitScript = limitScript; |
| | | } |
| | | |
| | | // é
ç½®ç»å
¥ç¹ |
| | | @Pointcut("@annotation(com.ruoyi.common.annotation.RateLimiter)") |
| | | public void rateLimiterPointCut() |
| | | { |
| | | } |
| | | |
| | | @Before("rateLimiterPointCut()") |
| | | public void doBefore(JoinPoint point) throws Throwable |
| | | { |
| | | RateLimiter rateLimiter = getAnnotationRateLimiter(point); |
| | | String key = rateLimiter.key(); |
| | | int time = rateLimiter.time(); |
| | | int count = rateLimiter.count(); |
| | | |
| | | String combineKey = getCombineKey(rateLimiter, point); |
| | | List<Object> keys = Collections.singletonList(combineKey); |
| | | try |
| | | { |
| | | Long number = redisTemplate.execute(limitScript, keys, count, time); |
| | | if (StringUtils.isNull(number) || number.intValue() > count) |
| | | { |
| | | throw new ServiceException("访é®è¿äºé¢ç¹ï¼è¯·ç¨ååè¯"); |
| | | } |
| | | log.info("éå¶è¯·æ±'{}',å½å请æ±'{}',ç¼åkey'{}'", count, number.intValue(), key); |
| | | } |
| | | catch (ServiceException e) |
| | | { |
| | | throw e; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new RuntimeException("æå¡å¨éæµå¼å¸¸ï¼è¯·ç¨ååè¯"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦å卿³¨è§£ï¼å¦æåå¨å°±è·å |
| | | */ |
| | | private RateLimiter getAnnotationRateLimiter(JoinPoint joinPoint) |
| | | { |
| | | Signature signature = joinPoint.getSignature(); |
| | | MethodSignature methodSignature = (MethodSignature) signature; |
| | | Method method = methodSignature.getMethod(); |
| | | |
| | | if (method != null) |
| | | { |
| | | return method.getAnnotation(RateLimiter.class); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getCombineKey(RateLimiter rateLimiter, JoinPoint point) |
| | | { |
| | | StringBuffer stringBuffer = new StringBuffer(rateLimiter.key()); |
| | | if (rateLimiter.limitType() == LimitType.IP) |
| | | { |
| | | stringBuffer.append(ServletUtils.getClientIP()); |
| | | } |
| | | MethodSignature signature = (MethodSignature) point.getSignature(); |
| | | Method method = signature.getMethod(); |
| | | Class<?> targetClass = method.getDeclaringClass(); |
| | | stringBuffer.append("-").append(targetClass.getName()).append("- ").append(method.getName()); |
| | | return stringBuffer.toString(); |
| | | } |
| | | } |
| | |
| | | import cn.hutool.core.math.Calculator; |
| | | import cn.hutool.core.util.CharUtil; |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | /** |
| | | * æ 符å·è®¡ç®çæå¨ |
| | |
| | | int max = RandomUtil.randomInt(min, limit); |
| | | String number1 = Integer.toString(max); |
| | | String number2 = Integer.toString(min); |
| | | number1 = StrUtil.padAfter(number1, this.numberLength, CharUtil.SPACE); |
| | | number2 = StrUtil.padAfter(number2, this.numberLength, CharUtil.SPACE); |
| | | number1 = StringUtils.rightPad(number1, this.numberLength, CharUtil.SPACE); |
| | | number2 = StringUtils.rightPad(number2, this.numberLength, CharUtil.SPACE); |
| | | |
| | | return number1 + RandomUtil.randomChar(operators) + number2 + '='; |
| | | } |
| | |
| | | * @return æå¤§å¼ |
| | | */ |
| | | private int getLimit() { |
| | | return Integer.parseInt("1" + StrUtil.repeat('0', this.numberLength)); |
| | | return Integer.parseInt("1" + StringUtils.repeat('0', this.numberLength)); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.context.annotation.EnableAspectJAutoProxy; |
| | | |
| | | import java.util.TimeZone; |
| | | |
| | | /** |
| | | * ç¨åºæ³¨è§£é
ç½® |
| | |
| | | // 表示éè¿aopæ¡æ¶æ´é²è¯¥ä»£ç对象,AopContextè½å¤è®¿é® |
| | | @EnableAspectJAutoProxy(exposeProxy = true) |
| | | public class ApplicationConfig { |
| | | /** |
| | | * æ¶åºé
ç½® |
| | | */ |
| | | @Bean |
| | | public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() { |
| | | return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault()); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | |
| | | public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { |
| | | return (throwable, method, objects) -> { |
| | | throwable.printStackTrace(); |
| | | throw new CustomException( |
| | | throw new ServiceException( |
| | | "Exception message - " + throwable.getMessage() |
| | | + ", Method name - " + method.getName() |
| | | + ", Parameter value - " + Arrays.toString(objects)); |
| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.filter.RepeatableFilter; |
| | | import com.ruoyi.common.filter.XssFilter; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.config.properties.XssProperties; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.boot.web.servlet.FilterRegistrationBean; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Configuration |
| | | @ConditionalOnProperty(value = "xss.enabled", havingValue = "true") |
| | | public class FilterConfig { |
| | | |
| | | @Autowired |
| | |
| | | FilterRegistrationBean registration = new FilterRegistrationBean(); |
| | | registration.setDispatcherTypes(DispatcherType.REQUEST); |
| | | registration.setFilter(new XssFilter()); |
| | | registration.addUrlPatterns(StrUtil.splitToArray(xssProperties.getUrlPatterns(), ",")); |
| | | registration.addUrlPatterns(StringUtils.split(xssProperties.getUrlPatterns(), ",")); |
| | | registration.setName("xssFilter"); |
| | | registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE); |
| | | Map<String, String> initParameters = new HashMap<String, String>(); |
| | | initParameters.put("excludes", xssProperties.getExcludes()); |
| | | initParameters.put("enabled", xssProperties.getEnabled()); |
| | | registration.setInitParameters(initParameters); |
| | | return registration; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.servlet.LocaleResolver; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.Locale; |
| | | |
| | | /** |
| | | * å½é
åé
ç½® |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Configuration |
| | | public class I18nConfig { |
| | | |
| | | @Bean |
| | | public LocaleResolver localeResolver() { |
| | | return new I18nLocaleResolver(); |
| | | } |
| | | |
| | | /** |
| | | * è·å请æ±å¤´å½é
åä¿¡æ¯ |
| | | */ |
| | | static class I18nLocaleResolver implements LocaleResolver { |
| | | |
| | | @NotNull |
| | | @Override |
| | | public Locale resolveLocale(HttpServletRequest httpServletRequest) { |
| | | String language = httpServletRequest.getHeader("content-language"); |
| | | Locale locale = Locale.getDefault(); |
| | | if (StrUtil.isNotBlank(language)) { |
| | | String[] split = language.split("_"); |
| | | locale = new Locale(split[0], split[1]); |
| | | } |
| | | return locale; |
| | | } |
| | | |
| | | @Override |
| | | public void setLocale(@NotNull HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) { |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.fasterxml.jackson.databind.module.SimpleModule; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; |
| | | import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.framework.jackson.BigNumberSerializer; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeansException; |
| | | import org.springframework.beans.factory.config.BeanPostProcessor; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | | import java.time.LocalDateTime; |
| | | import java.util.TimeZone; |
| | | |
| | |
| | | ObjectMapper objectMapper = (ObjectMapper) bean; |
| | | // å
¨å±é
ç½®åºååè¿å JSON å¤ç |
| | | SimpleModule simpleModule = new SimpleModule(); |
| | | simpleModule.addSerializer(Long.class, BigNumberSerializer.INSTANCE); |
| | | simpleModule.addSerializer(Long.TYPE, BigNumberSerializer.INSTANCE); |
| | | simpleModule.addSerializer(BigInteger.class, BigNumberSerializer.INSTANCE); |
| | | simpleModule.addSerializer(BigDecimal.class, ToStringSerializer.instance); |
| | | simpleModule.addSerializer(LocalDateTime.class, LocalDateTimeSerializer.INSTANCE); |
| | | simpleModule.addDeserializer(LocalDateTime.class, LocalDateTimeDeserializer.INSTANCE); |
| | | objectMapper.registerModule(simpleModule); |
| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.config.properties.RedissonProperties; |
| | | import org.redisson.Redisson; |
| | | import org.redisson.api.RedissonClient; |
| | |
| | | import org.springframework.cache.annotation.EnableCaching; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.data.redis.core.script.DefaultRedisScript; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | |
| | | .setAddress(prefix + redisProperties.getHost() + ":" + redisProperties.getPort()) |
| | | .setConnectTimeout(((Long) redisProperties.getTimeout().toMillis()).intValue()) |
| | | .setDatabase(redisProperties.getDatabase()) |
| | | .setPassword(StrUtil.isNotBlank(redisProperties.getPassword()) ? redisProperties.getPassword() : null) |
| | | .setPassword(StringUtils.isNotBlank(redisProperties.getPassword()) ? redisProperties.getPassword() : null) |
| | | .setTimeout(singleServerConfig.getTimeout()) |
| | | .setRetryAttempts(singleServerConfig.getRetryAttempts()) |
| | | .setRetryInterval(singleServerConfig.getRetryInterval()) |
| | |
| | | return new RedissonSpringCacheManager(redissonClient, config, JsonJacksonCodec.INSTANCE); |
| | | } |
| | | |
| | | @Bean |
| | | public DefaultRedisScript<Long> limitScript() { |
| | | DefaultRedisScript<Long> redisScript = new DefaultRedisScript<>(); |
| | | redisScript.setScriptText(limitScriptText()); |
| | | redisScript.setResultType(Long.class); |
| | | return redisScript; |
| | | } |
| | | |
| | | /** |
| | | * éæµèæ¬ |
| | | */ |
| | | private String limitScriptText() { |
| | | return StrUtil.builder() |
| | | .append("local key = KEYS[1]\n") |
| | | .append("local count = tonumber(ARGV[1])\n") |
| | | .append("local time = tonumber(ARGV[2])\n") |
| | | .append("local current = redis.call('get', key);\n") |
| | | .append("if current and tonumber(current) > count then\n") |
| | | .append(" return current;\n") |
| | | .append("end\n") |
| | | .append("current = redis.call('incr', key)\n") |
| | | .append("if tonumber(current) == 1 then\n") |
| | | .append(" redis.call('expire', key, time)\n") |
| | | .append("end\n") |
| | | .append("return current;") |
| | | .toString(); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | |
| | | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
| | | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor; |
| | | |
| | | /** |
| | | * éç¨é
ç½® |
| | |
| | | @Override |
| | | public void addResourceHandlers(ResourceHandlerRegistry registry) |
| | | { |
| | | /** æ¬å°æä»¶ä¸ä¼ è·¯å¾ */ |
| | | registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + RuoYiConfig.getProfile() + "/"); |
| | | } |
| | | |
| | | /** |
| | |
| | | .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() |
| | | // è¿æ»¤è¯·æ± |
| | | .authorizeRequests() |
| | | // 对äºç»å½login éªè¯ç captchaImage å
许å¿åè®¿é® |
| | | .antMatchers("/login", "/captchaImage").anonymous() |
| | | // 对äºç»å½login 注åregister éªè¯ç captchaImage å
许å¿åè®¿é® |
| | | .antMatchers("/login", "/register", "/captchaImage").anonymous() |
| | | .antMatchers( |
| | | HttpMethod.GET, |
| | | "/", |
| | | "/*.html", |
| | | "/**/*.html", |
| | | "/**/*.css", |
| | | "/**/*.js", |
| | | "/profile/**" |
| | | "/**/*.js" |
| | | ).permitAll() |
| | | .antMatchers("/common/download**").anonymous() |
| | | .antMatchers("/common/download/resource**").anonymous() |
| | | .antMatchers("/doc.html").anonymous() |
| | | .antMatchers("/swagger-resources/**").anonymous() |
| | | .antMatchers("/webjars/**").anonymous() |
| | |
| | | httpSecurity.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class); |
| | | httpSecurity.addFilterBefore(corsFilter, LogoutFilter.class); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 强æ£ååå¸å å¯å®ç° |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.config.properties; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * éå¤æäº¤ é
ç½®å±æ§ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @Component |
| | | @ConfigurationProperties(prefix = "repeat-submit") |
| | | public class RepeatSubmitProperties { |
| | | |
| | | /** |
| | | * é´éæ¶é´(毫ç§) |
| | | */ |
| | | private int intervalTime; |
| | | |
| | | } |
| | |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.method.HandlerMethod; |
| | | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; |
| | | import org.springframework.web.servlet.HandlerInterceptor; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | /** |
| | | * 鲿¢éå¤æäº¤æ¦æªå¨ |
| | | * |
| | | * @author ruoyi |
| | | * ç§»é¤ç»§æ¿ HandlerInterceptorAdapter è¿æç±» |
| | | * æ¹ä¸ºå®ç° HandlerInterceptor æ¥å£(宿¹æ¨èåæ³) |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Component |
| | | public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter |
| | | { |
| | | public abstract class RepeatSubmitInterceptor implements HandlerInterceptor { |
| | | |
| | | @Override |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception |
| | | { |
| | | if (handler instanceof HandlerMethod) |
| | | { |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) |
| | | throws Exception { |
| | | if (handler instanceof HandlerMethod) { |
| | | HandlerMethod handlerMethod = (HandlerMethod) handler; |
| | | Method method = handlerMethod.getMethod(); |
| | | RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class); |
| | | if (annotation != null) |
| | | { |
| | | if (this.isRepeatSubmit(request)) |
| | | { |
| | | if (annotation != null) { |
| | | if (this.isRepeatSubmit(annotation, request)) { |
| | | AjaxResult ajaxResult = AjaxResult.error("ä¸å
许éå¤æäº¤ï¼è¯·ç¨ååè¯"); |
| | | ServletUtils.renderString(response, JsonUtils.toJsonString(ajaxResult)); |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return super.preHandle(request, response, handler); |
| | | } else { |
| | | return HandlerInterceptor.super.preHandle(request, response, handler); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * éªè¯æ¯å¦éå¤æäº¤ç±åç±»å®ç°å
·ä½çé²éå¤æäº¤çè§å |
| | | * |
| | | * @param request |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public abstract boolean isRepeatSubmit(HttpServletRequest request); |
| | | public abstract boolean isRepeatSubmit(RepeatSubmit annotation, HttpServletRequest request); |
| | | } |
| | |
| | | package com.ruoyi.framework.interceptor.impl; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.io.IoUtil; |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.filter.RepeatedlyRequestWrapper; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.config.properties.RepeatSubmitProperties; |
| | | import com.ruoyi.framework.config.properties.TokenProperties; |
| | | import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | |
| | | /** |
| | | * å¤æè¯·æ±urlåæ°æ®æ¯å¦åä¸ä¸æ¬¡ç¸åï¼ |
| | | * 妿å䏿¬¡ç¸åï¼åæ¯éå¤æäº¤è¡¨åã æææ¶é´ä¸º10ç§å
ã |
| | | * 妿å䏿¬¡ç¸åï¼åæ¯éå¤æäº¤è¡¨åã |
| | | * |
| | | * @author ruoyi |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @Component |
| | | public class SameUrlDataInterceptor extends RepeatSubmitInterceptor |
| | | { |
| | | public class SameUrlDataInterceptor extends RepeatSubmitInterceptor { |
| | | public final String REPEAT_PARAMS = "repeatParams"; |
| | | |
| | | public final String REPEAT_TIME = "repeatTime"; |
| | | |
| | | // 令çèªå®ä¹æ è¯ |
| | | @Value("${token.header}") |
| | | private String header; |
| | | private final TokenProperties tokenProperties; |
| | | private final RepeatSubmitProperties repeatSubmitProperties; |
| | | private final RedisCache redisCache; |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | /** |
| | | * é´éæ¶é´ï¼åä½:ç§ é»è®¤10ç§ |
| | | * |
| | | * 两次ç¸ååæ°ç请æ±ï¼å¦æé´éæ¶é´å¤§äºè¯¥åæ°ï¼ç³»ç»ä¸ä¼è®¤å®ä¸ºéå¤æäº¤çæ°æ® |
| | | */ |
| | | private int intervalTime = 10; |
| | | |
| | | public void setIntervalTime(int intervalTime) |
| | | { |
| | | this.intervalTime = intervalTime; |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | @Override |
| | | public boolean isRepeatSubmit(HttpServletRequest request) |
| | | { |
| | | public boolean isRepeatSubmit(RepeatSubmit repeatSubmit, HttpServletRequest request) { |
| | | // å¦ææ³¨è§£ä¸ä¸º0 åä½¿ç¨æ³¨è§£æ°å¼ |
| | | long intervalTime = repeatSubmitProperties.getIntervalTime(); |
| | | if (repeatSubmit.intervalTime() > 0) { |
| | | intervalTime = repeatSubmit.timeUnit().toMillis(repeatSubmit.intervalTime()); |
| | | } |
| | | String nowParams = ""; |
| | | if (request instanceof RepeatedlyRequestWrapper) |
| | | { |
| | | if (request instanceof RepeatedlyRequestWrapper) { |
| | | RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper) request; |
| | | try { |
| | | nowParams = IoUtil.readUtf8(repeatedlyRequest.getInputStream()); |
| | |
| | | } |
| | | |
| | | // bodyåæ°ä¸ºç©ºï¼è·åParameterçæ°æ® |
| | | if (Validator.isEmpty(nowParams)) |
| | | { |
| | | if (StringUtils.isEmpty(nowParams)) { |
| | | nowParams = JsonUtils.toJsonString(request.getParameterMap()); |
| | | } |
| | | Map<String, Object> nowDataMap = new HashMap<String, Object>(); |
| | |
| | | String url = request.getRequestURI(); |
| | | |
| | | // å¯ä¸å¼ï¼æ²¡ææ¶æ¯å¤´å使ç¨è¯·æ±å°åï¼ |
| | | String submitKey = request.getHeader(header); |
| | | if (Validator.isEmpty(submitKey)) |
| | | { |
| | | String submitKey = request.getHeader(tokenProperties.getHeader()); |
| | | if (StringUtils.isEmpty(submitKey)) { |
| | | submitKey = url; |
| | | } |
| | | |
| | |
| | | String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + submitKey; |
| | | |
| | | Object sessionObj = redisCache.getCacheObject(cacheRepeatKey); |
| | | if (sessionObj != null) |
| | | { |
| | | if (sessionObj != null) { |
| | | Map<String, Object> sessionMap = (Map<String, Object>) sessionObj; |
| | | if (sessionMap.containsKey(url)) |
| | | { |
| | | if (sessionMap.containsKey(url)) { |
| | | Map<String, Object> preDataMap = (Map<String, Object>) sessionMap.get(url); |
| | | if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap)) |
| | | { |
| | | if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap, intervalTime)) { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | Map<String, Object> cacheMap = new HashMap<String, Object>(); |
| | | cacheMap.put(url, nowDataMap); |
| | | redisCache.setCacheObject(cacheRepeatKey, cacheMap, intervalTime, TimeUnit.SECONDS); |
| | | redisCache.setCacheObject(cacheRepeatKey, cacheMap, Convert.toInt(intervalTime), TimeUnit.MILLISECONDS); |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 夿忰æ¯å¦ç¸å |
| | | */ |
| | | private boolean compareParams(Map<String, Object> nowMap, Map<String, Object> preMap) |
| | | { |
| | | private boolean compareParams(Map<String, Object> nowMap, Map<String, Object> preMap) { |
| | | String nowParams = (String) nowMap.get(REPEAT_PARAMS); |
| | | String preParams = (String) preMap.get(REPEAT_PARAMS); |
| | | return nowParams.equals(preParams); |
| | |
| | | /** |
| | | * å¤æä¸¤æ¬¡é´éæ¶é´ |
| | | */ |
| | | private boolean compareTime(Map<String, Object> nowMap, Map<String, Object> preMap) |
| | | { |
| | | private boolean compareTime(Map<String, Object> nowMap, Map<String, Object> preMap, long intervalTime) { |
| | | long time1 = (Long) nowMap.get(REPEAT_TIME); |
| | | long time2 = (Long) preMap.get(REPEAT_TIME); |
| | | if ((time1 - time2) < (this.intervalTime * 1000)) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | return (time1 - time2) < intervalTime; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.jackson; |
| | | |
| | | import com.fasterxml.jackson.core.JsonGenerator; |
| | | import com.fasterxml.jackson.databind.SerializerProvider; |
| | | import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; |
| | | import com.fasterxml.jackson.databind.ser.std.NumberSerializer; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * è¶
åº JS æå¤§æå°å¼ å¤ç |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @JacksonStdImpl |
| | | public class BigNumberSerializer extends NumberSerializer { |
| | | |
| | | /** |
| | | * æ ¹æ® JS Number.MAX_SAFE_INTEGER ä¸ Number.MIN_SAFE_INTEGER 徿¥ |
| | | */ |
| | | private static final long MAX_SAFE_INTEGER = 9007199254740991L; |
| | | private static final long MIN_SAFE_INTEGER = -9007199254740991L; |
| | | |
| | | /** |
| | | * æä¾å®ä¾ |
| | | */ |
| | | public static final BigNumberSerializer INSTANCE = new BigNumberSerializer(Number.class); |
| | | |
| | | public BigNumberSerializer(Class<? extends Number> rawType) { |
| | | super(rawType); |
| | | } |
| | | |
| | | @Override |
| | | public void serialize(Number value, JsonGenerator gen, SerializerProvider provider) throws IOException { |
| | | // è¶
åºèå´ åºååä½å符串 |
| | | if (value.longValue() > MIN_SAFE_INTEGER && value.longValue() < MAX_SAFE_INTEGER) { |
| | | super.serialize(value, gen, provider); |
| | | } else { |
| | | gen.writeString(value.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | |
| | | import java.util.Date; |
| | |
| | | * @author Lion Li |
| | | * @date 2021/4/25 |
| | | */ |
| | | @Slf4j |
| | | public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler { |
| | | |
| | | @Override |
| | |
| | | try { |
| | | //æ ¹æ®å±æ§åå设置è¦å¡«å
çå¼ |
| | | if (metaObject.hasGetter("createTime")) { |
| | | if (metaObject.getValue("createTime") == null) { |
| | | this.setFieldValByName("createTime", new Date(), metaObject); |
| | | } |
| | | } |
| | | if (metaObject.hasGetter("createBy")) { |
| | | if (metaObject.getValue("createBy") == null) { |
| | | this.setFieldValByName("createBy", SecurityUtils.getUsername(), metaObject); |
| | | } |
| | | this.setFieldValByName("createBy", getLoginUsername(), metaObject); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new CustomException("èªå¨æ³¨å
¥å¼å¸¸ => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED); |
| | | throw new ServiceException("èªå¨æ³¨å
¥å¼å¸¸ => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED); |
| | | } |
| | | updateFill(metaObject); |
| | | } |
| | | |
| | | @Override |
| | | public void updateFill(MetaObject metaObject) { |
| | | try { |
| | | if (metaObject.hasGetter("updateBy")) { |
| | | if (metaObject.getValue("updateBy") == null) { |
| | | this.setFieldValByName("updateBy", SecurityUtils.getUsername(), metaObject); |
| | | } |
| | | this.setFieldValByName("updateBy", getLoginUsername(), metaObject); |
| | | } |
| | | if (metaObject.hasGetter("updateTime")) { |
| | | if (metaObject.getValue("updateTime") == null) { |
| | | this.setFieldValByName("updateTime", new Date(), metaObject); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | throw new CustomException("èªå¨æ³¨å
¥å¼å¸¸ => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED); |
| | | throw new ServiceException("èªå¨æ³¨å
¥å¼å¸¸ => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åç»å½ç¨æ·å |
| | | */ |
| | | private String getLoginUsername() { |
| | | LoginUser loginUser; |
| | | try { |
| | | loginUser = SecurityUtils.getLoginUser(); |
| | | } catch (Exception e) { |
| | | log.error("èªå¨æ³¨å
¥è¦å => ç¨æ·æªç»å½"); |
| | | return null; |
| | | } |
| | | return loginUser.getUsername(); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.framework.security.filter; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| | |
| | | throws ServletException, IOException |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(request); |
| | | if (Validator.isNotNull(loginUser) && Validator.isNull(SecurityUtils.getAuthentication())) |
| | | if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication())) |
| | | { |
| | | tokenService.verifyToken(loginUser); |
| | | UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities()); |
| | |
| | | package com.ruoyi.framework.security.handle; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | |
| | | throws IOException |
| | | { |
| | | int code = HttpStatus.HTTP_UNAUTHORIZED; |
| | | String msg = StrUtil.format("请æ±è®¿é®ï¼{}ï¼è®¤è¯å¤±è´¥ï¼æ æ³è®¿é®ç³»ç»èµæº", request.getRequestURI()); |
| | | String msg = StringUtils.format("请æ±è®¿é®ï¼{}ï¼è®¤è¯å¤±è´¥ï¼æ æ³è®¿é®ç³»ç»èµæº", request.getRequestURI()); |
| | | ServletUtils.renderString(response, JsonUtils.toJsonString(AjaxResult.error(code, msg))); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.framework.security.handle; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.AsyncService; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) |
| | | throws IOException, ServletException { |
| | | LoginUser loginUser = tokenService.getLoginUser(request); |
| | | if (Validator.isNotNull(loginUser)) { |
| | | if (StringUtils.isNotNull(loginUser)) { |
| | | String userName = loginUser.getUsername(); |
| | | // å é¤ç¨æ·ç¼åè®°å½ |
| | | tokenService.delLoginUser(loginUser.getToken()); |
| | |
| | | package com.ruoyi.framework.web.exception; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.exception.BaseException; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.exception.DemoModeException; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.security.access.AccessDeniedException; |
| | | import org.springframework.security.authentication.AccountExpiredException; |
| | | import org.springframework.security.core.userdetails.UsernameNotFoundException; |
| | | import org.springframework.validation.BindException; |
| | | import org.springframework.web.HttpRequestMethodNotSupportedException; |
| | | import org.springframework.web.bind.MethodArgumentNotValidException; |
| | | import org.springframework.web.bind.annotation.ExceptionHandler; |
| | | import org.springframework.web.bind.annotation.RestControllerAdvice; |
| | | import org.springframework.web.servlet.NoHandlerFoundException; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.validation.ConstraintViolationException; |
| | | |
| | | /** |
| | |
| | | private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class); |
| | | |
| | | /** |
| | | * åºç¡å¼å¸¸ |
| | | * æéæ ¡éªå¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(BaseException.class) |
| | | public AjaxResult baseException(BaseException e) |
| | | @ExceptionHandler(AccessDeniedException.class) |
| | | public AjaxResult handleAccessDeniedException(AccessDeniedException e, HttpServletRequest request) |
| | | { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±å°å'{}',æéæ ¡éªå¤±è´¥'{}'", requestURI, e.getMessage()); |
| | | return AjaxResult.error(HttpStatus.HTTP_FORBIDDEN, "没ææéï¼è¯·è系管çåææ"); |
| | | } |
| | | |
| | | /** |
| | | * è¯·æ±æ¹å¼ä¸æ¯æ |
| | | */ |
| | | @ExceptionHandler(HttpRequestMethodNotSupportedException.class) |
| | | public AjaxResult handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e, |
| | | HttpServletRequest request) |
| | | { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±å°å'{}',䏿¯æ'{}'请æ±", requestURI, e.getMethod()); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * ä¸å¡å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(CustomException.class) |
| | | public AjaxResult businessException(CustomException e) |
| | | { |
| | | if (Validator.isNull(e.getCode())) |
| | | { |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | return AjaxResult.error(e.getCode(), e.getMessage()); |
| | | } |
| | | |
| | | @ExceptionHandler(NoHandlerFoundException.class) |
| | | public AjaxResult handlerNoFoundException(Exception e) |
| | | @ExceptionHandler(ServiceException.class) |
| | | public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request) |
| | | { |
| | | log.error(e.getMessage(), e); |
| | | return AjaxResult.error(HttpStatus.HTTP_NOT_FOUND, "è·¯å¾ä¸åå¨ï¼è¯·æ£æ¥è·¯å¾æ¯å¦æ£ç¡®"); |
| | | Integer code = e.getCode(); |
| | | return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | @ExceptionHandler(AccessDeniedException.class) |
| | | public AjaxResult handleAuthorizationException(AccessDeniedException e) |
| | | /** |
| | | * æ¦æªæªç¥çè¿è¡æ¶å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(RuntimeException.class) |
| | | public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request) |
| | | { |
| | | log.error(e.getMessage()); |
| | | return AjaxResult.error(HttpStatus.HTTP_FORBIDDEN, "没ææéï¼è¯·è系管çåææ"); |
| | | } |
| | | |
| | | @ExceptionHandler(AccountExpiredException.class) |
| | | public AjaxResult handleAccountExpiredException(AccountExpiredException e) |
| | | { |
| | | log.error(e.getMessage(), e); |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±å°å'{}',åçæªç¥å¼å¸¸.", requestURI, e); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | @ExceptionHandler(UsernameNotFoundException.class) |
| | | public AjaxResult handleUsernameNotFoundException(UsernameNotFoundException e) |
| | | { |
| | | log.error(e.getMessage(), e); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * ç³»ç»å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(Exception.class) |
| | | public AjaxResult handleException(Exception e) |
| | | public AjaxResult handleException(Exception e, HttpServletRequest request) |
| | | { |
| | | log.error(e.getMessage(), e); |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±å°å'{}',åçç³»ç»å¼å¸¸.", requestURI, e); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | |
| | | * èªå®ä¹éªè¯å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(BindException.class) |
| | | public AjaxResult validatedBindException(BindException e) |
| | | public AjaxResult handleBindException(BindException e) |
| | | { |
| | | log.error(e.getMessage(), e); |
| | | String message = e.getAllErrors().get(0).getDefaultMessage(); |
| | |
| | | * èªå®ä¹éªè¯å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(MethodArgumentNotValidException.class) |
| | | public Object validExceptionHandler(MethodArgumentNotValidException e) |
| | | public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e) |
| | | { |
| | | log.error(e.getMessage(), e); |
| | | String message = e.getBindingResult().getFieldError().getDefaultMessage(); |
| | |
| | | * æ¼ç¤ºæ¨¡å¼å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(DemoModeException.class) |
| | | public AjaxResult demoModeException(DemoModeException e) |
| | | public AjaxResult handleDemoModeException(DemoModeException e) |
| | | { |
| | | return AjaxResult.error("æ¼ç¤ºæ¨¡å¼ï¼ä¸å
许æä½"); |
| | | } |
| | |
| | | package com.ruoyi.framework.web.service; |
| | | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import cn.hutool.http.useragent.UserAgent; |
| | | import cn.hutool.http.useragent.UserAgentUtil; |
| | | import com.ruoyi.common.constant.Constants; |
| | |
| | | logininfor.setOs(os); |
| | | logininfor.setMsg(message); |
| | | // æ¥å¿ç¶æ |
| | | if (Constants.LOGIN_SUCCESS.equals(status) || Constants.LOGOUT.equals(status)) { |
| | | if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER)) { |
| | | logininfor.setStatus(Constants.SUCCESS); |
| | | } else if (Constants.LOGIN_FAIL.equals(status)) { |
| | | logininfor.setStatus(Constants.FAIL); |
| | |
| | | package com.ruoyi.framework.web.service; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Set; |
| | | |
| | |
| | | */ |
| | | public boolean hasPermi(String permission) |
| | | { |
| | | if (Validator.isEmpty(permission)) |
| | | if (StringUtils.isEmpty(permission)) |
| | | { |
| | | return false; |
| | | } |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | if (Validator.isNull(loginUser) || Validator.isEmpty(loginUser.getPermissions())) |
| | | if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | */ |
| | | public boolean hasAnyPermi(String permissions) |
| | | { |
| | | if (Validator.isEmpty(permissions)) |
| | | if (StringUtils.isEmpty(permissions)) |
| | | { |
| | | return false; |
| | | } |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | if (Validator.isNull(loginUser) || Validator.isEmpty(loginUser.getPermissions())) |
| | | if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | */ |
| | | public boolean hasRole(String role) |
| | | { |
| | | if (Validator.isEmpty(role)) |
| | | if (StringUtils.isEmpty(role)) |
| | | { |
| | | return false; |
| | | } |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | if (Validator.isNull(loginUser) || Validator.isEmpty(loginUser.getUser().getRoles())) |
| | | if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles())) |
| | | { |
| | | return false; |
| | | } |
| | | for (SysRole sysRole : loginUser.getUser().getRoles()) |
| | | { |
| | | String roleKey = sysRole.getRoleKey(); |
| | | if (SUPER_ADMIN.equals(roleKey) || roleKey.equals(StrUtil.trim(role))) |
| | | if (SUPER_ADMIN.equals(roleKey) || roleKey.equals(StringUtils.trim(role))) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | */ |
| | | public boolean hasAnyRoles(String roles) |
| | | { |
| | | if (Validator.isEmpty(roles)) |
| | | if (StringUtils.isEmpty(roles)) |
| | | { |
| | | return false; |
| | | } |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | if (Validator.isNull(loginUser) || Validator.isEmpty(loginUser.getUser().getRoles())) |
| | | if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles())) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | */ |
| | | private boolean hasPermissions(Set<String> permissions, String permission) |
| | | { |
| | | return permissions.contains(ALL_PERMISSION) || permissions.contains(StrUtil.trim(permission)); |
| | | return permissions.contains(ALL_PERMISSION) || permissions.contains(StringUtils.trim(permission)); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.exception.user.CaptchaException; |
| | | import com.ruoyi.common.exception.user.CaptchaExpireException; |
| | | import com.ruoyi.common.exception.user.UserPasswordNotMatchException; |
| | |
| | | else |
| | | { |
| | | asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage(), request); |
| | | throw new CustomException(e.getMessage()); |
| | | throw new ServiceException(e.getMessage()); |
| | | } |
| | | } |
| | | asyncService.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"), request); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.web.service; |
| | | |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.RegisterBody; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.exception.user.CaptchaException; |
| | | import com.ruoyi.common.exception.user.CaptchaExpireException; |
| | | import com.ruoyi.common.utils.MessageUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * æ³¨åæ ¡éªæ¹æ³ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class SysRegisterService |
| | | { |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | @Autowired |
| | | private AsyncService asyncService; |
| | | |
| | | /** |
| | | * 注å |
| | | */ |
| | | public String register(RegisterBody registerBody) |
| | | { |
| | | String msg = "", username = registerBody.getUsername(), password = registerBody.getPassword(); |
| | | |
| | | boolean captchaOnOff = configService.selectCaptchaOnOff(); |
| | | // éªè¯ç å¼å
³ |
| | | if (captchaOnOff) |
| | | { |
| | | validateCaptcha(username, registerBody.getCode(), registerBody.getUuid()); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(username)) |
| | | { |
| | | msg = "ç¨æ·åä¸è½ä¸ºç©º"; |
| | | } |
| | | else if (StringUtils.isEmpty(password)) |
| | | { |
| | | msg = "ç¨æ·å¯ç ä¸è½ä¸ºç©º"; |
| | | } |
| | | else if (username.length() < UserConstants.USERNAME_MIN_LENGTH |
| | | || username.length() > UserConstants.USERNAME_MAX_LENGTH) |
| | | { |
| | | msg = "è´¦æ·é¿åº¦å¿
é¡»å¨2å°20个å符ä¹é´"; |
| | | } |
| | | else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH |
| | | || password.length() > UserConstants.PASSWORD_MAX_LENGTH) |
| | | { |
| | | msg = "å¯ç é¿åº¦å¿
é¡»å¨5å°20个å符ä¹é´"; |
| | | } |
| | | else if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username))) |
| | | { |
| | | msg = "ä¿åç¨æ·'" + username + "'å¤±è´¥ï¼æ³¨åè´¦å·å·²åå¨"; |
| | | } |
| | | else |
| | | { |
| | | SysUser sysUser = new SysUser(); |
| | | sysUser.setUserName(username); |
| | | sysUser.setNickName(username); |
| | | sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword())); |
| | | boolean regFlag = userService.registerUser(sysUser); |
| | | if (!regFlag) |
| | | { |
| | | msg = "注å失败,请è系系ç»ç®¡ç人å"; |
| | | } |
| | | else |
| | | { |
| | | asyncService.recordLogininfor(username, Constants.REGISTER, |
| | | MessageUtils.message("user.register.success"), ServletUtils.getRequest()); |
| | | } |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªéªè¯ç |
| | | * |
| | | * @param username ç¨æ·å |
| | | * @param code éªè¯ç |
| | | * @param uuid å¯ä¸æ è¯ |
| | | * @return ç»æ |
| | | */ |
| | | public void validateCaptcha(String username, String code, String uuid) |
| | | { |
| | | String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; |
| | | String captcha = redisCache.getCacheObject(verifyKey); |
| | | redisCache.deleteObject(verifyKey); |
| | | if (captcha == null) |
| | | { |
| | | throw new CaptchaExpireException(); |
| | | } |
| | | if (!code.equalsIgnoreCase(captcha)) |
| | | { |
| | | throw new CaptchaException(); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.framework.web.service; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.http.useragent.UserAgent; |
| | | import cn.hutool.http.useragent.UserAgentUtil; |
| | |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.ip.AddressUtils; |
| | | import com.ruoyi.framework.config.properties.TokenProperties; |
| | | import io.jsonwebtoken.Claims; |
| | |
| | | public LoginUser getLoginUser(HttpServletRequest request) { |
| | | // è·åè¯·æ±æºå¸¦ç令ç |
| | | String token = getToken(request); |
| | | if (Validator.isNotEmpty(token)) { |
| | | if (StringUtils.isNotEmpty(token)) { |
| | | try { |
| | | Claims claims = parseToken(token); |
| | | // è§£æå¯¹åºçæé以åç¨æ·ä¿¡æ¯ |
| | | String uuid = (String) claims.get(Constants.LOGIN_USER_KEY); |
| | | String userKey = getTokenKey(uuid); |
| | | LoginUser user = redisCache.getCacheObject(userKey); |
| | | return user; |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | |
| | | * è®¾ç½®ç¨æ·èº«ä»½ä¿¡æ¯ |
| | | */ |
| | | public void setLoginUser(LoginUser loginUser) { |
| | | if (Validator.isNotNull(loginUser) && Validator.isNotEmpty(loginUser.getToken())) { |
| | | if (StringUtils.isNotNull(loginUser) && StringUtils.isNotEmpty(loginUser.getToken())) { |
| | | refreshToken(loginUser); |
| | | } |
| | | } |
| | |
| | | * å é¤ç¨æ·èº«ä»½ä¿¡æ¯ |
| | | */ |
| | | public void delLoginUser(String token) { |
| | | if (Validator.isNotEmpty(token)) { |
| | | if (StringUtils.isNotEmpty(token)) { |
| | | String userKey = getTokenKey(token); |
| | | redisCache.deleteObject(userKey); |
| | | } |
| | |
| | | */ |
| | | private String getToken(HttpServletRequest request) { |
| | | String token = request.getHeader(tokenProperties.getHeader()); |
| | | if (Validator.isNotEmpty(token) && token.startsWith(Constants.TOKEN_PREFIX)) { |
| | | if (StringUtils.isNotEmpty(token) && token.startsWith(Constants.TOKEN_PREFIX)) { |
| | | token = token.replace(Constants.TOKEN_PREFIX, ""); |
| | | } |
| | | return token; |
| | |
| | | package com.ruoyi.framework.web.service; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.enums.UserStatus; |
| | | import com.ruoyi.common.exception.BaseException; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.security.core.userdetails.UserDetailsService; |
| | | import org.springframework.security.core.userdetails.UsernameNotFoundException; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.enums.UserStatus; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | |
| | | /** |
| | | * ç¨æ·éªè¯å¤ç |
| | |
| | | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException |
| | | { |
| | | SysUser user = userService.selectUserByUserName(username); |
| | | if (Validator.isNull(user)) |
| | | if (StringUtils.isNull(user)) |
| | | { |
| | | log.info("ç»å½ç¨æ·ï¼{} ä¸åå¨.", username); |
| | | throw new UsernameNotFoundException("ç»å½ç¨æ·ï¼" + username + " ä¸åå¨"); |
| | | throw new ServiceException("ç»å½ç¨æ·ï¼" + username + " ä¸åå¨"); |
| | | } |
| | | else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) |
| | | { |
| | | log.info("ç»å½ç¨æ·ï¼{} 已被å é¤.", username); |
| | | throw new BaseException("对ä¸èµ·ï¼æ¨çè´¦å·ï¼" + username + " 已被å é¤"); |
| | | throw new ServiceException("对ä¸èµ·ï¼æ¨çè´¦å·ï¼" + username + " 已被å é¤"); |
| | | } |
| | | else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) |
| | | { |
| | | log.info("ç»å½ç¨æ·ï¼{} 已被åç¨.", username); |
| | | throw new BaseException("对ä¸èµ·ï¼æ¨çè´¦å·ï¼" + username + " å·²åç¨"); |
| | | throw new ServiceException("对ä¸èµ·ï¼æ¨çè´¦å·ï¼" + username + " å·²åç¨"); |
| | | } |
| | | |
| | | return createLoginUser(user); |
| | |
| | | |
| | | public UserDetails createLoginUser(SysUser user) |
| | | { |
| | | return new LoginUser(user, permissionService.getMenuPermission(user)); |
| | | return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user)); |
| | | } |
| | | } |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.6.0</version> |
| | | <version>3.0.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | |
| | | package com.ruoyi.generator.domain; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.constant.GenConstants; |
| | |
| | | } |
| | | |
| | | public static boolean isSub(String tplCategory) { |
| | | return tplCategory != null && StrUtil.equals(GenConstants.TPL_SUB, tplCategory); |
| | | return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory); |
| | | } |
| | | |
| | | public boolean isTree() { |
| | |
| | | } |
| | | |
| | | public static boolean isTree(String tplCategory) { |
| | | return tplCategory != null && StrUtil.equals(GenConstants.TPL_TREE, tplCategory); |
| | | return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory); |
| | | } |
| | | |
| | | public boolean isCrud() { |
| | |
| | | } |
| | | |
| | | public static boolean isCrud(String tplCategory) { |
| | | return tplCategory != null && StrUtil.equals(GenConstants.TPL_CRUD, tplCategory); |
| | | return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory); |
| | | } |
| | | |
| | | public boolean isSuperColumn(String javaField) { |
| | |
| | | |
| | | public static boolean isSuperColumn(String tplCategory, String javaField) { |
| | | if (isTree(tplCategory)) { |
| | | return StrUtil.equalsAnyIgnoreCase(javaField, |
| | | return StringUtils.equalsAnyIgnoreCase(javaField, |
| | | ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY)); |
| | | } |
| | | return StrUtil.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY); |
| | | return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.generator.domain; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.*; |
| | |
| | | private Map<String, Object> params = new HashMap<>(); |
| | | |
| | | public String getCapJavaField() { |
| | | return StrUtil.upperFirst(javaField); |
| | | return StringUtils.uncapitalize(javaField); |
| | | } |
| | | |
| | | public boolean isPk() { |
| | |
| | | } |
| | | |
| | | public boolean isPk(String isPk) { |
| | | return isPk != null && StrUtil.equals("1", isPk); |
| | | return isPk != null && StringUtils.equals("1", isPk); |
| | | } |
| | | |
| | | public boolean isIncrement() { |
| | |
| | | } |
| | | |
| | | public boolean isIncrement(String isIncrement) { |
| | | return isIncrement != null && StrUtil.equals("1", isIncrement); |
| | | return isIncrement != null && StringUtils.equals("1", isIncrement); |
| | | } |
| | | |
| | | public boolean isRequired() { |
| | |
| | | } |
| | | |
| | | public boolean isRequired(String isRequired) { |
| | | return isRequired != null && StrUtil.equals("1", isRequired); |
| | | return isRequired != null && StringUtils.equals("1", isRequired); |
| | | } |
| | | |
| | | public boolean isInsert() { |
| | |
| | | } |
| | | |
| | | public boolean isInsert(String isInsert) { |
| | | return isInsert != null && StrUtil.equals("1", isInsert); |
| | | return isInsert != null && StringUtils.equals("1", isInsert); |
| | | } |
| | | |
| | | public boolean isEdit() { |
| | |
| | | } |
| | | |
| | | public boolean isEdit(String isEdit) { |
| | | return isEdit != null && StrUtil.equals("1", isEdit); |
| | | return isEdit != null && StringUtils.equals("1", isEdit); |
| | | } |
| | | |
| | | public boolean isList() { |
| | |
| | | } |
| | | |
| | | public boolean isList(String isList) { |
| | | return isList != null && StrUtil.equals("1", isList); |
| | | return isList != null && StringUtils.equals("1", isList); |
| | | } |
| | | |
| | | public boolean isQuery() { |
| | |
| | | } |
| | | |
| | | public boolean isQuery(String isQuery) { |
| | | return isQuery != null && StrUtil.equals("1", isQuery); |
| | | return isQuery != null && StringUtils.equals("1", isQuery); |
| | | } |
| | | |
| | | public boolean isSuperColumn() { |
| | |
| | | } |
| | | |
| | | public static boolean isSuperColumn(String javaField) { |
| | | return StrUtil.equalsAnyIgnoreCase(javaField, |
| | | return StringUtils.equalsAnyIgnoreCase(javaField, |
| | | // BaseEntity |
| | | "createBy", "createTime", "updateBy", "updateTime", "remark", |
| | | // TreeEntity |
| | |
| | | |
| | | public static boolean isUsableColumn(String javaField) { |
| | | // isSuperColumn()ä¸çååç¨äºé¿å
çæå¤ä½Domain屿§ï¼è¥æäºå±æ§å¨çæé¡µé¢æ¶éè¦ç¨å°ä¸è½å¿½ç¥ï¼åæ¾å¨æ¤å¤ç½åå |
| | | return StrUtil.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark"); |
| | | return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark"); |
| | | } |
| | | |
| | | public String readConverterExp() { |
| | | String remarks = StrUtil.subBetween(this.columnComment, "ï¼", "ï¼"); |
| | | String remarks = StringUtils.substringBetween(this.columnComment, "ï¼", "ï¼"); |
| | | StringBuffer sb = new StringBuffer(); |
| | | if (StrUtil.isNotEmpty(remarks)) { |
| | | if (StringUtils.isNotEmpty(remarks)) { |
| | | for (String value : remarks.split(" ")) { |
| | | if (StrUtil.isNotEmpty(value)) { |
| | | if (StringUtils.isNotEmpty(value)) { |
| | | Object startStr = value.subSequence(0, 1); |
| | | String endStr = value.substring(1); |
| | | sb.append("").append(startStr).append("=").append(endStr).append(","); |
| | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.GenConstants; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | |
| | | for (GenTableColumn cenTableColumn : genTable.getColumns()) { |
| | | genTableColumnMapper.update(cenTableColumn, |
| | | new LambdaUpdateWrapper<GenTableColumn>() |
| | | .set(StrUtil.isBlank(cenTableColumn.getColumnComment()), GenTableColumn::getColumnComment, null) |
| | | .set(StrUtil.isBlank(cenTableColumn.getIsPk()), GenTableColumn::getIsPk, null) |
| | | .set(StrUtil.isBlank(cenTableColumn.getIsIncrement()), GenTableColumn::getIsIncrement, null) |
| | | .set(StrUtil.isBlank(cenTableColumn.getIsInsert()), GenTableColumn::getIsInsert, null) |
| | | .set(StrUtil.isBlank(cenTableColumn.getIsEdit()), GenTableColumn::getIsEdit, null) |
| | | .set(StrUtil.isBlank(cenTableColumn.getIsList()), GenTableColumn::getIsList, null) |
| | | .set(StrUtil.isBlank(cenTableColumn.getIsQuery()), GenTableColumn::getIsQuery, null) |
| | | .set(StrUtil.isBlank(cenTableColumn.getIsRequired()), GenTableColumn::getIsRequired, null) |
| | | .set(StrUtil.isBlank(cenTableColumn.getDictType()), GenTableColumn::getDictType, "") |
| | | .set(StringUtils.isBlank(cenTableColumn.getColumnComment()), GenTableColumn::getColumnComment, null) |
| | | .set(StringUtils.isBlank(cenTableColumn.getIsPk()), GenTableColumn::getIsPk, null) |
| | | .set(StringUtils.isBlank(cenTableColumn.getIsIncrement()), GenTableColumn::getIsIncrement, null) |
| | | .set(StringUtils.isBlank(cenTableColumn.getIsInsert()), GenTableColumn::getIsInsert, null) |
| | | .set(StringUtils.isBlank(cenTableColumn.getIsEdit()), GenTableColumn::getIsEdit, null) |
| | | .set(StringUtils.isBlank(cenTableColumn.getIsList()), GenTableColumn::getIsList, null) |
| | | .set(StringUtils.isBlank(cenTableColumn.getIsQuery()), GenTableColumn::getIsQuery, null) |
| | | .set(StringUtils.isBlank(cenTableColumn.getIsRequired()), GenTableColumn::getIsRequired, null) |
| | | .set(StringUtils.isBlank(cenTableColumn.getDictType()), GenTableColumn::getDictType, "") |
| | | .eq(GenTableColumn::getColumnId,cenTableColumn.getColumnId())); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | throw new CustomException("导å
¥å¤±è´¥ï¼" + e.getMessage()); |
| | | throw new ServiceException("导å
¥å¤±è´¥ï¼" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | // è·å模æ¿å表 |
| | | List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); |
| | | for (String template : templates) { |
| | | if (!StrUtil.containsAny("sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm", template)) { |
| | | if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) { |
| | | // æ¸²ææ¨¡æ¿ |
| | | StringWriter sw = new StringWriter(); |
| | | Template tpl = Velocity.getTemplate(template, Constants.UTF8); |
| | | tpl.merge(context, sw); |
| | | try { |
| | | String path = getGenPath(table, template); |
| | | FileUtils.writeUtf8String(sw.toString(), path); |
| | | } catch (Exception e) { |
| | | throw new ServiceException("æ¸²ææ¨¡æ¿å¤±è´¥ï¼è¡¨åï¼" + table.getTableName()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | List<String> tableColumnNames = tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); |
| | | |
| | | List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); |
| | | if (Validator.isEmpty(dbTableColumns)) { |
| | | throw new CustomException("åæ¥æ°æ®å¤±è´¥ï¼åè¡¨ç»æä¸åå¨"); |
| | | if (StringUtils.isEmpty(dbTableColumns)) { |
| | | throw new ServiceException("åæ¥æ°æ®å¤±è´¥ï¼åè¡¨ç»æä¸åå¨"); |
| | | } |
| | | List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); |
| | | |
| | |
| | | public void validateEdit(GenTable genTable) { |
| | | if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) { |
| | | Map<String, Object> paramsObj = genTable.getParams(); |
| | | if (Validator.isEmpty(paramsObj.get(GenConstants.TREE_CODE))) { |
| | | throw new CustomException("æ ç¼ç åæ®µä¸è½ä¸ºç©º"); |
| | | } else if (Validator.isEmpty(paramsObj.get(GenConstants.TREE_PARENT_CODE))) { |
| | | throw new CustomException("æ ç¶ç¼ç åæ®µä¸è½ä¸ºç©º"); |
| | | } else if (Validator.isEmpty(paramsObj.get(GenConstants.TREE_NAME))) { |
| | | throw new CustomException("æ åç§°åæ®µä¸è½ä¸ºç©º"); |
| | | if (StringUtils.isEmpty(paramsObj.get(GenConstants.TREE_CODE))) { |
| | | throw new ServiceException("æ ç¼ç åæ®µä¸è½ä¸ºç©º"); |
| | | } else if (StringUtils.isEmpty(paramsObj.get(GenConstants.TREE_PARENT_CODE))) { |
| | | throw new ServiceException("æ ç¶ç¼ç åæ®µä¸è½ä¸ºç©º"); |
| | | } else if (StringUtils.isEmpty(paramsObj.get(GenConstants.TREE_NAME))) { |
| | | throw new ServiceException("æ åç§°åæ®µä¸è½ä¸ºç©º"); |
| | | } else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) { |
| | | if (Validator.isEmpty(genTable.getSubTableName())) { |
| | | throw new CustomException("å
³èå表ç表åä¸è½ä¸ºç©º"); |
| | | } else if (Validator.isEmpty(genTable.getSubTableFkName())) { |
| | | throw new CustomException("å表å
³èçå¤é®åä¸è½ä¸ºç©º"); |
| | | if (StringUtils.isEmpty(genTable.getSubTableName())) { |
| | | throw new ServiceException("å
³èå表ç表åä¸è½ä¸ºç©º"); |
| | | } else if (StringUtils.isEmpty(genTable.getSubTableFkName())) { |
| | | throw new ServiceException("å表å
³èçå¤é®åä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | | } |
| | |
| | | break; |
| | | } |
| | | } |
| | | if (Validator.isNull(table.getPkColumn())) { |
| | | if (StringUtils.isNull(table.getPkColumn())) { |
| | | table.setPkColumn(table.getColumns().get(0)); |
| | | } |
| | | if (GenConstants.TPL_SUB.equals(table.getTplCategory())) { |
| | |
| | | break; |
| | | } |
| | | } |
| | | if (Validator.isNull(table.getSubTable().getPkColumn())) { |
| | | if (StringUtils.isNull(table.getSubTable().getPkColumn())) { |
| | | table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0)); |
| | | } |
| | | } |
| | |
| | | */ |
| | | public void setSubTable(GenTable table) { |
| | | String subTableName = table.getSubTableName(); |
| | | if (Validator.isNotEmpty(subTableName)) { |
| | | if (StringUtils.isNotEmpty(subTableName)) { |
| | | table.setSubTable(baseMapper.selectGenTableByName(subTableName)); |
| | | } |
| | | } |
| | |
| | | */ |
| | | public void setTableFromOptions(GenTable genTable) { |
| | | Map<String, Object> paramsObj = JsonUtils.parseMap(genTable.getOptions()); |
| | | if (Validator.isNotNull(paramsObj)) { |
| | | if (StringUtils.isNotNull(paramsObj)) { |
| | | String treeCode = Convert.toStr(paramsObj.get(GenConstants.TREE_CODE)); |
| | | String treeParentCode = Convert.toStr(paramsObj.get(GenConstants.TREE_PARENT_CODE)); |
| | | String treeName = Convert.toStr(paramsObj.get(GenConstants.TREE_NAME)); |
| | |
| | | */ |
| | | public static String getGenPath(GenTable table, String template) { |
| | | String genPath = table.getGenPath(); |
| | | if (StrUtil.equals(genPath, "/")) { |
| | | if (StringUtils.equals(genPath, "/")) { |
| | | return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table); |
| | | } |
| | | return genPath + File.separator + VelocityUtils.getFileName(template, table); |
| | |
| | | package com.ruoyi.generator.util; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.constant.GenConstants; |
| | | import com.ruoyi.generator.config.GenConfig; |
| | | import com.ruoyi.generator.domain.GenTable; |
| | |
| | | column.setTableId(table.getTableId()); |
| | | column.setCreateBy(table.getCreateBy()); |
| | | // 设置javaåæ®µå |
| | | column.setJavaField(StrUtil.toCamelCase(columnName)); |
| | | column.setJavaField(StringUtils.toCamelCase(columnName)); |
| | | // 设置é»è®¤ç±»å |
| | | column.setJavaType(GenConstants.TYPE_STRING); |
| | | |
| | |
| | | column.setHtmlType(GenConstants.HTML_INPUT); |
| | | |
| | | // å¦ææ¯æµ®ç¹å ç»ä¸ç¨BigDecimal |
| | | String[] str = StrUtil.splitToArray(StrUtil.subBetween(column.getColumnType(), "(", ")"), ","); |
| | | String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ","); |
| | | if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) |
| | | { |
| | | column.setJavaType(GenConstants.TYPE_BIGDECIMAL); |
| | |
| | | } |
| | | |
| | | // æ¥è¯¢å段类å |
| | | if (StrUtil.endWithIgnoreCase(columnName, "name")) |
| | | if (StringUtils.endsWithIgnoreCase(columnName, "name")) |
| | | { |
| | | column.setQueryType(GenConstants.QUERY_LIKE); |
| | | } |
| | | // ç¶æåæ®µè®¾ç½®åéæ¡ |
| | | if (StrUtil.endWithIgnoreCase(columnName, "status")) |
| | | if (StringUtils.endsWithIgnoreCase(columnName, "status")) |
| | | { |
| | | column.setHtmlType(GenConstants.HTML_RADIO); |
| | | } |
| | | // ç±»å&æ§å«åæ®µè®¾ç½®ä¸ææ¡ |
| | | else if (StrUtil.endWithIgnoreCase(columnName, "type") |
| | | || StrUtil.endWithIgnoreCase(columnName, "sex")) |
| | | else if (StringUtils.endsWithIgnoreCase(columnName, "type") |
| | | || StringUtils.endsWithIgnoreCase(columnName, "sex")) |
| | | { |
| | | column.setHtmlType(GenConstants.HTML_SELECT); |
| | | } |
| | | // å¾çåæ®µè®¾ç½®å¾çä¸ä¼ æ§ä»¶ |
| | | else if (StrUtil.endWithIgnoreCase(columnName, "image")) |
| | | else if (StringUtils.endsWithIgnoreCase(columnName, "image")) |
| | | { |
| | | column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD); |
| | | } |
| | | // æä»¶å段设置æä»¶ä¸ä¼ æ§ä»¶ |
| | | else if (StrUtil.endWithIgnoreCase(columnName, "file")) |
| | | else if (StringUtils.endsWithIgnoreCase(columnName, "file")) |
| | | { |
| | | column.setHtmlType(GenConstants.HTML_FILE_UPLOAD); |
| | | } |
| | | // å
容忮µè®¾ç½®å¯ææ¬æ§ä»¶ |
| | | else if (StrUtil.endWithIgnoreCase(columnName, "content")) |
| | | else if (StringUtils.endsWithIgnoreCase(columnName, "content")) |
| | | { |
| | | column.setHtmlType(GenConstants.HTML_EDITOR); |
| | | } |
| | |
| | | { |
| | | int lastIndex = packageName.lastIndexOf("."); |
| | | int nameLength = packageName.length(); |
| | | String moduleName = StrUtil.sub(packageName, lastIndex + 1, nameLength); |
| | | String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength); |
| | | return moduleName; |
| | | } |
| | | |
| | |
| | | { |
| | | int lastIndex = tableName.lastIndexOf("_"); |
| | | int nameLength = tableName.length(); |
| | | String businessName = StrUtil.sub(tableName, lastIndex + 1, nameLength); |
| | | String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength); |
| | | return businessName; |
| | | } |
| | | |
| | |
| | | { |
| | | boolean autoRemovePre = GenConfig.getAutoRemovePre(); |
| | | String tablePrefix = GenConfig.getTablePrefix(); |
| | | if (autoRemovePre && StrUtil.isNotEmpty(tablePrefix)) |
| | | if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) |
| | | { |
| | | String[] searchList = StrUtil.splitToArray(tablePrefix, ","); |
| | | String[] searchList = StringUtils.split(tablePrefix, ","); |
| | | tableName = replaceFirst(tableName, searchList); |
| | | } |
| | | return StrUtil.upperFirst(StrUtil.toCamelCase(tableName)); |
| | | return StringUtils.convertToCamelCase(tableName); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static String getDbType(String columnType) |
| | | { |
| | | if (StrUtil.indexOf(columnType, '(') > 0) |
| | | if (StringUtils.indexOf(columnType, '(') > 0) |
| | | { |
| | | return StrUtil.subBefore(columnType, "(",false); |
| | | return StringUtils.substringBefore(columnType, "("); |
| | | } |
| | | else |
| | | { |
| | |
| | | */ |
| | | public static Integer getColumnLength(String columnType) |
| | | { |
| | | if (StrUtil.indexOf(columnType, '(') > 0) |
| | | if (StringUtils.indexOf(columnType, '(') > 0) |
| | | { |
| | | String length = StrUtil.subBetween(columnType, "(", ")"); |
| | | String length = StringUtils.substringBetween(columnType, "(", ")"); |
| | | return Integer.valueOf(length); |
| | | } |
| | | else |
| | |
| | | package com.ruoyi.generator.util; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.constant.GenConstants; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.generator.domain.GenTable; |
| | | import com.ruoyi.generator.domain.GenTableColumn; |
| | | import org.apache.velocity.VelocityContext; |
| | |
| | | VelocityContext velocityContext = new VelocityContext(); |
| | | velocityContext.put("tplCategory", genTable.getTplCategory()); |
| | | velocityContext.put("tableName", genTable.getTableName()); |
| | | velocityContext.put("functionName", StrUtil.isNotEmpty(functionName) ? functionName : "ã请填ååè½åç§°ã"); |
| | | velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "ã请填ååè½åç§°ã"); |
| | | velocityContext.put("ClassName", genTable.getClassName()); |
| | | velocityContext.put("className", StrUtil.lowerFirst(genTable.getClassName())); |
| | | velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName())); |
| | | velocityContext.put("moduleName", genTable.getModuleName()); |
| | | velocityContext.put("BusinessName", StrUtil.upperFirst(genTable.getBusinessName())); |
| | | velocityContext.put("BusinessName", StringUtils.capitalize(genTable.getBusinessName())); |
| | | velocityContext.put("businessName", genTable.getBusinessName()); |
| | | velocityContext.put("basePackage", getPackagePrefix(packageName)); |
| | | velocityContext.put("packageName", packageName); |
| | |
| | | String subTableName = genTable.getSubTableName(); |
| | | String subTableFkName = genTable.getSubTableFkName(); |
| | | String subClassName = genTable.getSubTable().getClassName(); |
| | | String subTableFkClassName = StrUtil.toCamelCase(subTableFkName); |
| | | String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName); |
| | | |
| | | context.put("subTable", subTable); |
| | | context.put("subTableName", subTableName); |
| | | context.put("subTableFkName", subTableFkName); |
| | | context.put("subTableFkClassName", subTableFkClassName); |
| | | context.put("subTableFkclassName", StrUtil.lowerFirst(subTableFkClassName)); |
| | | context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName)); |
| | | context.put("subClassName", subClassName); |
| | | context.put("subclassName", StrUtil.lowerFirst(subClassName)); |
| | | context.put("subclassName", StringUtils.uncapitalize(subClassName)); |
| | | context.put("subImportList", getImportList(genTable.getSubTable())); |
| | | } |
| | | |
| | |
| | | // ä¸å¡åç§° |
| | | String businessName = genTable.getBusinessName(); |
| | | |
| | | String javaPath = PROJECT_PATH + "/" + StrUtil.replace(packageName, ".", "/"); |
| | | String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/"); |
| | | String mybatisPath = MYBATIS_PATH + "/" + moduleName; |
| | | String vuePath = "vue"; |
| | | |
| | | if (template.contains("domain.java.vm")) |
| | | { |
| | | fileName = StrUtil.format("{}/domain/{}.java", javaPath, className); |
| | | fileName = StringUtils.format("{}/domain/{}.java", javaPath, className); |
| | | } |
| | | if (template.contains("vo.java.vm")) |
| | | { |
| | | fileName = StrUtil.format("{}/domain/vo/{}Vo.java", javaPath, className); |
| | | fileName = StringUtils.format("{}/domain/vo/{}Vo.java", javaPath, className); |
| | | } |
| | | if (template.contains("bo.java.vm")) |
| | | { |
| | | fileName = StrUtil.format("{}/domain/bo/{}Bo.java", javaPath, className); |
| | | fileName = StringUtils.format("{}/domain/bo/{}Bo.java", javaPath, className); |
| | | } |
| | | if (template.contains("sub-domain.java.vm") && StrUtil.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) |
| | | if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) |
| | | { |
| | | fileName = StrUtil.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName()); |
| | | fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName()); |
| | | } |
| | | else if (template.contains("mapper.java.vm")) |
| | | { |
| | | fileName = StrUtil.format("{}/mapper/{}Mapper.java", javaPath, className); |
| | | fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className); |
| | | } |
| | | else if (template.contains("service.java.vm")) |
| | | { |
| | | fileName = StrUtil.format("{}/service/I{}Service.java", javaPath, className); |
| | | fileName = StringUtils.format("{}/service/I{}Service.java", javaPath, className); |
| | | } |
| | | else if (template.contains("serviceImpl.java.vm")) |
| | | { |
| | | fileName = StrUtil.format("{}/service/impl/{}ServiceImpl.java", javaPath, className); |
| | | fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className); |
| | | } |
| | | else if (template.contains("controller.java.vm")) |
| | | { |
| | | fileName = StrUtil.format("{}/controller/{}Controller.java", javaPath, className); |
| | | fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className); |
| | | } |
| | | else if (template.contains("mapper.xml.vm")) |
| | | { |
| | | fileName = StrUtil.format("{}/{}Mapper.xml", mybatisPath, className); |
| | | fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className); |
| | | } |
| | | else if (template.contains("sql.vm")) |
| | | { |
| | |
| | | } |
| | | else if (template.contains("api.js.vm")) |
| | | { |
| | | fileName = StrUtil.format("{}/api/{}/{}.js", vuePath, moduleName, businessName); |
| | | fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName); |
| | | } |
| | | else if (template.contains("index.vue.vm")) |
| | | { |
| | | fileName = StrUtil.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); |
| | | fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); |
| | | } |
| | | else if (template.contains("index-tree.vue.vm")) |
| | | { |
| | | fileName = StrUtil.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); |
| | | fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); |
| | | } |
| | | return fileName; |
| | | } |
| | |
| | | public static String getPackagePrefix(String packageName) |
| | | { |
| | | int lastIndex = packageName.lastIndexOf("."); |
| | | String basePackage = StrUtil.sub(packageName, 0, lastIndex); |
| | | String basePackage = StringUtils.substring(packageName, 0, lastIndex); |
| | | return basePackage; |
| | | } |
| | | |
| | |
| | | List<GenTableColumn> columns = genTable.getColumns(); |
| | | GenTable subGenTable = genTable.getSubTable(); |
| | | HashSet<String> importList = new HashSet<String>(); |
| | | if (Validator.isNotNull(subGenTable)) |
| | | if (StringUtils.isNotNull(subGenTable)) |
| | | { |
| | | importList.add("java.util.List"); |
| | | } |
| | |
| | | */ |
| | | public static String getPermissionPrefix(String moduleName, String businessName) |
| | | { |
| | | return StrUtil.format("{}:{}", moduleName, businessName); |
| | | return StringUtils.format("{}:{}", moduleName, businessName); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static String getParentMenuId(Map<String, Object> paramsObj) |
| | | { |
| | | if (Validator.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)) |
| | | if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID) |
| | | && StringUtils.isNotEmpty(Convert.toStr(paramsObj.get(GenConstants.PARENT_MENU_ID)))) |
| | | { |
| | | return Convert.toStr(paramsObj.get(GenConstants.PARENT_MENU_ID)); |
| | | } |
| | |
| | | */ |
| | | public static String getTreecode(Map<String, Object> paramsObj) |
| | | { |
| | | if (Validator.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_CODE)) |
| | | if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_CODE)) |
| | | { |
| | | return StrUtil.toCamelCase(Convert.toStr(paramsObj.get(GenConstants.TREE_CODE))); |
| | | return StringUtils.toCamelCase(Convert.toStr(paramsObj.get(GenConstants.TREE_CODE))); |
| | | } |
| | | return StrUtil.EMPTY; |
| | | return StringUtils.EMPTY; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static String getTreeParentCode(Map<String, Object> paramsObj) |
| | | { |
| | | if (Validator.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) |
| | | if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) |
| | | { |
| | | return StrUtil.toCamelCase(Convert.toStr(paramsObj.get(GenConstants.TREE_PARENT_CODE))); |
| | | return StringUtils.toCamelCase(Convert.toStr(paramsObj.get(GenConstants.TREE_PARENT_CODE))); |
| | | } |
| | | return StrUtil.EMPTY; |
| | | return StringUtils.EMPTY; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static String getTreeName(Map<String, Object> paramsObj) |
| | | { |
| | | if (Validator.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_NAME)) |
| | | if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_NAME)) |
| | | { |
| | | return StrUtil.toCamelCase(Convert.toStr(paramsObj.get(GenConstants.TREE_NAME))); |
| | | return StringUtils.toCamelCase(Convert.toStr(paramsObj.get(GenConstants.TREE_NAME))); |
| | | } |
| | | return StrUtil.EMPTY; |
| | | return StringUtils.EMPTY; |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * $column.columnComment |
| | | */ |
| | | @ApiModelProperty("$column.columnComment") |
| | | #if($column.isInsert && $column.isEdit) |
| | | #set($Group="AddGroup.class, EditGroup.class") |
| | | #elseif($column.isInsert) |
| | |
| | | #set($Group="EditGroup.class") |
| | | #end |
| | | #if($column.isRequired == 1) |
| | | @ApiModelProperty(value = "$column.columnComment", required = true) |
| | | #if($column.javaType == 'String') |
| | | @NotBlank(message = "$column.columnCommentä¸è½ä¸ºç©º", groups = { $Group }) |
| | | #else |
| | | @NotNull(message = "$column.columnCommentä¸è½ä¸ºç©º", groups = { $Group }) |
| | | #end |
| | | #else |
| | | @ApiModelProperty(value = "$column.columnComment") |
| | | #end |
| | | private $column.javaType $column.javaField; |
| | | |
| | |
| | | |
| | | import java.util.List; |
| | | import java.util.Arrays; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.constraints.*; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import com.ruoyi.common.core.validate.AddGroup; |
| | | import com.ruoyi.common.core.validate.EditGroup; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import ${packageName}.domain.vo.${ClassName}Vo; |
| | | import ${packageName}.domain.bo.${ClassName}Bo; |
| | | import ${packageName}.service.I${ClassName}Service; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | #if($table.crud || $table.sub) |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | #elseif($table.tree) |
| | |
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')") |
| | | @Log(title = "${functionName}", businessType = BusinessType.EXPORT) |
| | | @GetMapping("/export") |
| | | public AjaxResult<${ClassName}Vo> export(@Validated ${ClassName}Bo bo) { |
| | | public void export(@Validated ${ClassName}Bo bo, HttpServletResponse response) { |
| | | List<${ClassName}Vo> list = i${ClassName}Service.queryList(bo); |
| | | ExcelUtil<${ClassName}Vo> util = new ExcelUtil<${ClassName}Vo>(${ClassName}Vo.class); |
| | | return util.exportExcel(list, "${functionName}"); |
| | | ExcelUtil.exportExcel(list, "${functionName}", ${ClassName}Vo.class, response); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("æ°å¢${functionName}") |
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')") |
| | | @Log(title = "${functionName}", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit |
| | | @RepeatSubmit() |
| | | @PostMapping() |
| | | public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody ${ClassName}Bo bo) { |
| | | return toAjax(i${ClassName}Service.insertByBo(bo) ? 1 : 0); |
| | |
| | | @ApiOperation("ä¿®æ¹${functionName}") |
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')") |
| | | @Log(title = "${functionName}", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit |
| | | @RepeatSubmit() |
| | | @PutMapping() |
| | | public AjaxResult<Void> edit(@Validated(EditGroup.class) @RequestBody ${ClassName}Bo bo) { |
| | | return toAjax(i${ClassName}Service.updateByBo(bo) ? 1 : 0); |
| | |
| | | package ${packageName}.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | #if($table.crud || $table.sub) |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.core.page.PagePlus; |
| | |
| | | #set($mpMethod=$column.queryType.toLowerCase()) |
| | | #if($queryType != 'BETWEEN') |
| | | #if($javaType == 'String') |
| | | #set($condition='StrUtil.isNotBlank(bo.get'+$AttrName+'())') |
| | | #set($condition='StringUtils.isNotBlank(bo.get'+$AttrName+'())') |
| | | #else |
| | | #set($condition='bo.get'+$AttrName+'() != null') |
| | | #end |
| | |
| | | package ${packageName}.domain.vo; |
| | | |
| | | import com.ruoyi.common.annotation.Excel; |
| | | #foreach ($import in $importList) |
| | | import ${import}; |
| | | #end |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.ruoyi.common.annotation.ExcelDictFormat; |
| | | import com.ruoyi.common.convert.ExcelDictConvert; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | */ |
| | | @Data |
| | | @ApiModel("${functionName}è§å¾å¯¹è±¡") |
| | | @ExcelIgnoreUnannotated |
| | | public class ${ClassName}Vo { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | #if($parentheseIndex != -1) |
| | | @Excel(name = "${comment}" , readConverterExp = "$column.readConverterExp()") |
| | | #elseif($column.javaType == 'Date') |
| | | @Excel(name = "${comment}" , width = 30, dateFormat = "yyyy-MM-dd") |
| | | #if(${column.dictType} && ${column.dictType} != '') |
| | | @ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "${column.dictType}") |
| | | #elseif($parentheseIndex != -1) |
| | | @ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(readConverterExp = "$column.readConverterExp()") |
| | | #else |
| | | @Excel(name = "${comment}") |
| | | @ExcelProperty(value = "${comment}") |
| | | #end |
| | | @ApiModelProperty("$column.columnComment") |
| | | private $column.javaType $column.javaField; |
| | |
| | | method: 'delete' |
| | | }) |
| | | } |
| | | |
| | | // 导åº${functionName} |
| | | export function export${BusinessName}(query) { |
| | | return request({ |
| | | url: '/${moduleName}/${businessName}/export', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}"; |
| | | import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"; |
| | | import Treeselect from "@riophae/vue-treeselect"; |
| | | import "@riophae/vue-treeselect/dist/vue-treeselect.css"; |
| | | |
| | |
| | | this.loading = false; |
| | | this.getList(); |
| | | this.msgSuccess("å 餿å"); |
| | | }).catch(() => {}); |
| | | }).finally(() => { |
| | | this.loading = false; |
| | | }); |
| | | } |
| | | } |
| | | }; |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}"; |
| | | import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"; |
| | | import { downLoadExcel } from "@/utils/download"; |
| | | |
| | | export default { |
| | | name: "${BusinessName}", |
| | |
| | | this.loading = false; |
| | | this.getList(); |
| | | this.msgSuccess("å 餿å"); |
| | | }).catch(() => {}); |
| | | }).finally(() => { |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | | #if($table.sub) |
| | | /** ${subTable.functionName}åºå· */ |
| | |
| | | /** ${subTable.functionName}å é¤æé®æä½ */ |
| | | handleDelete${subClassName}() { |
| | | if (this.checked${subClassName}.length == 0) { |
| | | this.$alert("请å
éæ©è¦å é¤ç${subTable.functionName}æ°æ®", "æç¤º", { confirmButtonText: "ç¡®å®", }); |
| | | this.msgError("请å
éæ©è¦å é¤ç${subTable.functionName}æ°æ®"); |
| | | } else { |
| | | this.${subclassName}List.splice(this.checked${subClassName}[0].index - 1, 1); |
| | | const ${subclassName}List = this.${subclassName}List; |
| | | const checked${subClassName} = this.checked${subClassName}; |
| | | this.${subclassName}List = ${subclassName}List.filter(function(item) { |
| | | return checked${subClassName}.indexOf(item.index) == -1 |
| | | }); |
| | | } |
| | | }, |
| | | /** åéæ¡é䏿°æ® */ |
| | | /** å¤éæ¡é䏿°æ® */ |
| | | handle${subClassName}SelectionChange(selection) { |
| | | if (selection.length > 1) { |
| | | this.$refs.${subclassName}.clearSelection(); |
| | | this.$refs.${subclassName}.toggleRowSelection(selection.pop()); |
| | | } else { |
| | | this.checked${subClassName} = selection; |
| | | } |
| | | this.checked${subClassName} = selection.map(item => item.index) |
| | | }, |
| | | #end |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | const queryParams = this.queryParams; |
| | | this.$confirm('æ¯å¦ç¡®è®¤å¯¼åºææ${functionName}æ°æ®é¡¹?', "è¦å", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.exportLoading = true; |
| | | return export${BusinessName}(queryParams); |
| | | }).then(response => { |
| | | this.download(response.msg); |
| | | this.exportLoading = false; |
| | | }).catch(() => {}); |
| | | downLoadExcel('/${moduleName}/${businessName}/export', this.queryParams); |
| | | } |
| | | } |
| | | }; |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.6.0</version> |
| | | <version>3.0.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-common</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-system</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | |
| | | package com.ruoyi.oss.constant; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * äºåå¨å¸¸é |
| | | * |
| | |
| | | public class CloudConstant { |
| | | |
| | | /** |
| | | * OSS模åKEY |
| | | */ |
| | | public static final String SYS_OSS_KEY = "sys_oss:"; |
| | | |
| | | /** |
| | | * äºåå¨é
ç½®KEY |
| | | */ |
| | | public final static String CLOUD_STORAGE_CONFIG_KEY = "sys.oss.cloudStorageService"; |
| | | public static final String CLOUD_STORAGE_CONFIG_KEY = "CloudStorageConfig"; |
| | | |
| | | /** |
| | | * ç¼åé
ç½®KEY |
| | | */ |
| | | public static final String CACHE_CONFIG_KEY = SYS_OSS_KEY + CLOUD_STORAGE_CONFIG_KEY; |
| | | |
| | | /** |
| | | * é¢è§åè¡¨èµæºå¼å
³Key |
| | | */ |
| | | public final static String PEREVIEW_LIST_RESOURCE_KEY = "sys.oss.previewListResource"; |
| | | public static final String PEREVIEW_LIST_RESOURCE_KEY = "sys.oss.previewListResource"; |
| | | |
| | | /** |
| | | * ç³»ç»æ°æ®ids |
| | | */ |
| | | public static final List<Integer> SYSTEM_DATA_IDS = Arrays.asList(1, 2, 3, 4); |
| | | |
| | | } |
| | |
| | | package com.ruoyi.oss.enumd; |
| | | |
| | | import com.ruoyi.oss.service.impl.AliyunCloudStorageServiceImpl; |
| | | import com.ruoyi.oss.service.impl.MinioCloudStorageServiceImpl; |
| | | import com.ruoyi.oss.service.impl.QcloudCloudStorageServiceImpl; |
| | | import com.ruoyi.oss.service.impl.QiniuCloudStorageServiceImpl; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.oss.service.impl.AliyunCloudStorageStrategy; |
| | | import com.ruoyi.oss.service.impl.MinioCloudStorageStrategy; |
| | | import com.ruoyi.oss.service.impl.QcloudCloudStorageStrategy; |
| | | import com.ruoyi.oss.service.impl.QiniuCloudStorageStrategy; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | |
| | | /** |
| | | * ä¸çäº |
| | | */ |
| | | QINIU("qiniu", QiniuCloudStorageServiceImpl.class), |
| | | QINIU("qiniu", QiniuCloudStorageStrategy.class), |
| | | |
| | | /** |
| | | * é¿éäº |
| | | */ |
| | | ALIYUN("aliyun", AliyunCloudStorageServiceImpl.class), |
| | | ALIYUN("aliyun", AliyunCloudStorageStrategy.class), |
| | | |
| | | /** |
| | | * è
¾è®¯äº |
| | | */ |
| | | QCLOUD("qcloud", QcloudCloudStorageServiceImpl.class), |
| | | QCLOUD("qcloud", QcloudCloudStorageStrategy.class), |
| | | |
| | | /** |
| | | * minio |
| | | */ |
| | | MINIO("minio", MinioCloudStorageServiceImpl.class); |
| | | MINIO("minio", MinioCloudStorageStrategy.class); |
| | | |
| | | private final String value; |
| | | |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static String getServiceName(String value) { |
| | | for (CloudServiceEnumd clazz : values()) { |
| | | if (clazz.getValue().equals(value)) { |
| | | return StringUtils.uncapitalize(clazz.getServiceClass().getSimpleName()); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.ruoyi.oss.factory; |
| | | |
| | | import cn.hutool.core.lang.Assert; |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.reflect.ReflectUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.oss.constant.CloudConstant; |
| | | import com.ruoyi.oss.enumd.CloudServiceEnumd; |
| | | import com.ruoyi.oss.service.ICloudStorageService; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.oss.exception.OssException; |
| | | import com.ruoyi.oss.properties.CloudStorageProperties; |
| | | import com.ruoyi.oss.service.ICloudStorageStrategy; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | |
| | | */ |
| | | public class OssFactory { |
| | | |
| | | private static ISysConfigService sysConfigService; |
| | | private static RedisCache redisCache; |
| | | |
| | | static { |
| | | OssFactory.sysConfigService = SpringUtils.getBean(ISysConfigService.class); |
| | | OssFactory.redisCache = SpringUtils.getBean(RedisCache.class); |
| | | } |
| | | |
| | | private static final Map<String, ICloudStorageService> SERVICES = new ConcurrentHashMap<>(); |
| | | /** |
| | | * æå¡å®ä¾ç¼å |
| | | */ |
| | | private static final Map<String, ICloudStorageStrategy> SERVICES = new ConcurrentHashMap<>(); |
| | | |
| | | public static ICloudStorageService instance() { |
| | | String type = sysConfigService.selectConfigByKey(CloudConstant.CLOUD_STORAGE_CONFIG_KEY); |
| | | /** |
| | | * æå¡é
ç½®æ´æ°æ¶é´ç¼å |
| | | */ |
| | | private static final Map<String, Date> SERVICES_UPDATE_TIME = new ConcurrentHashMap<>(); |
| | | |
| | | /** |
| | | * è·åé»è®¤å®ä¾ |
| | | */ |
| | | public static ICloudStorageStrategy instance() { |
| | | // è·åredis é»è®¤ç±»å |
| | | String type = Convert.toStr(redisCache.getCacheObject(CloudConstant.CACHE_CONFIG_KEY)); |
| | | if (StringUtils.isEmpty(type)) { |
| | | throw new OssException("æä»¶å卿å¡ç±»åæ æ³æ¾å°!"); |
| | | } |
| | | return instance(type); |
| | | } |
| | | |
| | | public static ICloudStorageService instance(String type) { |
| | | ICloudStorageService service = SERVICES.get(type); |
| | | if (service == null) { |
| | | service = (ICloudStorageService) SpringUtils.getBean(CloudServiceEnumd.getServiceClass(type)); |
| | | /** |
| | | * æ ¹æ®ç±»åè·åå®ä¾ |
| | | */ |
| | | public static ICloudStorageStrategy instance(String type) { |
| | | ICloudStorageStrategy service = SERVICES.get(type); |
| | | Date oldDate = SERVICES_UPDATE_TIME.get(type); |
| | | Object json = redisCache.getCacheObject(CloudConstant.SYS_OSS_KEY + type); |
| | | CloudStorageProperties properties = JsonUtils.parseObject(json.toString(), CloudStorageProperties.class); |
| | | if (properties == null) { |
| | | throw new OssException("ç³»ç»å¼å¸¸, '" + type + "'é
置信æ¯ä¸åå¨!"); |
| | | } |
| | | Date nowDate = properties.getUpdateTime(); |
| | | // æå¡åå¨å¹¶æ´æ°æ¶é´ç¸ååè¿å(ä½¿ç¨æ´æ°æ¶é´ç¡®ä¿é
ç½®æç»ä¸è´æ§) |
| | | if (service != null && oldDate.equals(nowDate)) { |
| | | return service; |
| | | } |
| | | // è·åredisé
ç½®ä¿¡æ¯ å建对象 å¹¶ç¼å |
| | | service = (ICloudStorageStrategy) ReflectUtils.newInstance(CloudServiceEnumd.getServiceClass(type), properties); |
| | | SERVICES.put(type, service); |
| | | SERVICES_UPDATE_TIME.put(type, nowDate); |
| | | return service; |
| | | } |
| | | |
| | | public static void register(String type, ICloudStorageService iCloudStorageService) { |
| | | Assert.notNull(type, "type can't be null"); |
| | | SERVICES.put(type, iCloudStorageService); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.oss.properties; |
| | | |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * OSSäºåå¨ é
ç½®å±æ§ |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @Component |
| | | @ConfigurationProperties(prefix = "cloud-storage") |
| | | public class CloudStorageProperties { |
| | | |
| | | private Boolean previewListImage; |
| | | |
| | | private QiniuProperties qiniu; |
| | | |
| | | private AliyunProperties aliyun; |
| | | |
| | | private QcloudProperties qcloud; |
| | | |
| | | private MinioProperties minio; |
| | | |
| | | /** |
| | | * é¿éäº é
ç½®å±æ§ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @NoArgsConstructor |
| | | public static class AliyunProperties { |
| | | |
| | | /** |
| | | * é¿éäºç»å®çåå |
| | | * åå |
| | | */ |
| | | private String endpoint; |
| | | |
| | | /** |
| | | * é¿éäºè·¯å¾åç¼ |
| | | * åç¼ |
| | | */ |
| | | private String prefix; |
| | | |
| | | /** |
| | | * é¿éäºAccessKeyId |
| | | */ |
| | | private String accessKeyId; |
| | | |
| | | /** |
| | | * é¿éäºAccessKeySecret |
| | | */ |
| | | private String accessKeySecret; |
| | | |
| | | /** |
| | | * é¿éäºBucketName |
| | | */ |
| | | private String bucketName; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * Minio é
ç½®å±æ§ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @NoArgsConstructor |
| | | public static class MinioProperties { |
| | | |
| | | /** |
| | | * minioåå |
| | | */ |
| | | private String endpoint; |
| | | |
| | | /** |
| | | * minio ACCESS_KEY |
| | | * ACCESS_KEY |
| | | */ |
| | | private String accessKey; |
| | | |
| | | /** |
| | | * minio SECRET_KEY |
| | | * SECRET_KEY |
| | | */ |
| | | private String secretKey; |
| | | |
| | | /** |
| | | * minio åå¨ç©ºé´å |
| | | */ |
| | | private String bucketName; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * è
¾è®¯äºCOS é
ç½®å±æ§ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @NoArgsConstructor |
| | | public static class QcloudProperties { |
| | | |
| | | /** |
| | | * è
¾è®¯äºç»å®çåå |
| | | */ |
| | | private String endpoint; |
| | | |
| | | /** |
| | | * è
¾è®¯äºè·¯å¾åç¼ |
| | | */ |
| | | private String prefix; |
| | | |
| | | /** |
| | | * è
¾è®¯äºSecretId |
| | | */ |
| | | private String secretId; |
| | | |
| | | /** |
| | | * è
¾è®¯äºSecretKey |
| | | */ |
| | | private String secretKey; |
| | | |
| | | /** |
| | | * è
¾è®¯äºBucketName |
| | | * åå¨ç©ºé´å |
| | | */ |
| | | private String bucketName; |
| | | |
| | | /** |
| | | * ä¸çæ¯å¦ä½¿ç¨https |
| | | */ |
| | | private Boolean isHttps; |
| | | |
| | | /** |
| | | * è
¾è®¯äºCOSæå±å°åº |
| | | */ |
| | | private String region; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * ä¸çäº é
ç½®å±æ§ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @NoArgsConstructor |
| | | public static class QiniuProperties { |
| | | |
| | | /** |
| | | * ä¸çç»å®çåå |
| | | */ |
| | | private String domain; |
| | | |
| | | /** |
| | | * ä¸çè·¯å¾åç¼ |
| | | */ |
| | | private String prefix; |
| | | |
| | | /** |
| | | * ä¸çACCESS_KEY |
| | | */ |
| | | private String accessKey; |
| | | |
| | | /** |
| | | * ä¸çSECRET_KEY |
| | | */ |
| | | private String secretKey; |
| | | |
| | | /** |
| | | * ä¸çåå¨ç©ºé´å |
| | | */ |
| | | private String bucketName; |
| | | |
| | | /** |
| | | * ä¸çåå¨åºå |
| | | * åå¨åºå |
| | | */ |
| | | private String region; |
| | | |
| | | /** |
| | | * ä¸çæ¯å¦ä½¿ç¨https |
| | | * æ¯å¦httpsï¼Y=æ¯,N=å¦ï¼ |
| | | */ |
| | | private Boolean isHttps; |
| | | private String isHttps; |
| | | |
| | | } |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | private Date updateTime; |
| | | |
| | | } |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/oss/service/ICloudStorageService.java ÐÞ¸Ä |
| | |
| | | import java.io.InputStream; |
| | | |
| | | /** |
| | | * äºå卿塿¥å£ |
| | | * äºåå¨çç¥ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ICloudStorageService { |
| | | public interface ICloudStorageStrategy { |
| | | |
| | | void createBucket(); |
| | | |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/oss/service/abstractd/AbstractCloudStorageService.java ÐÞ¸Ä |
| | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.io.IoUtil; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.oss.entity.UploadResult; |
| | | import com.ruoyi.oss.service.ICloudStorageService; |
| | | import org.springframework.beans.factory.InitializingBean; |
| | | import com.ruoyi.oss.properties.CloudStorageProperties; |
| | | import com.ruoyi.oss.service.ICloudStorageStrategy; |
| | | |
| | | import java.io.InputStream; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * äºåå¨(æ¯æä¸çãé¿éäºãè
¾è®¯äºãminio) |
| | | * äºåå¨çç¥(æ¯æä¸çãé¿éäºãè
¾è®¯äºãminio) |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public abstract class AbstractCloudStorageService implements ICloudStorageService, InitializingBean { |
| | | public abstract class AbstractCloudStorageStrategy implements ICloudStorageStrategy { |
| | | |
| | | protected CloudStorageProperties properties; |
| | | |
| | | @Override |
| | | public abstract void createBucket(); |
| | |
| | | String uuid = IdUtil.fastSimpleUUID(); |
| | | // æä»¶è·¯å¾ |
| | | String path = DateUtil.format(new Date(), "yyyyMMdd") + "/" + uuid; |
| | | if (StrUtil.isNotBlank(prefix)) { |
| | | if (StringUtils.isNotBlank(prefix)) { |
| | | path = prefix + "/" + path; |
| | | } |
| | | return path + suffix; |
| | |
| | | |
| | | @Override |
| | | public abstract UploadResult uploadSuffix(InputStream inputStream, String suffix, String contentType); |
| | | |
| | | @Override |
| | | public abstract void afterPropertiesSet() throws Exception; |
| | | |
| | | @Override |
| | | public abstract String getEndpointLink(); |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/oss/service/impl/AliyunCloudStorageServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.oss.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.aliyun.oss.ClientConfiguration; |
| | | import com.aliyun.oss.OSSClient; |
| | | import com.aliyun.oss.common.auth.DefaultCredentialProvider; |
| | |
| | | import com.aliyun.oss.model.CreateBucketRequest; |
| | | import com.aliyun.oss.model.ObjectMetadata; |
| | | import com.aliyun.oss.model.PutObjectRequest; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.oss.entity.UploadResult; |
| | | import com.ruoyi.oss.enumd.CloudServiceEnumd; |
| | | import com.ruoyi.oss.exception.OssException; |
| | | import com.ruoyi.oss.factory.OssFactory; |
| | | import com.ruoyi.oss.properties.CloudStorageProperties; |
| | | import com.ruoyi.oss.properties.CloudStorageProperties.AliyunProperties; |
| | | import com.ruoyi.oss.service.abstractd.AbstractCloudStorageService; |
| | | import org.springframework.beans.factory.InitializingBean; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.oss.service.abstractd.AbstractCloudStorageStrategy; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.InputStream; |
| | | |
| | | /** |
| | | * é¿éäºåå¨ |
| | | * é¿éäºåå¨çç¥ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Lazy |
| | | @Service |
| | | public class AliyunCloudStorageServiceImpl extends AbstractCloudStorageService implements InitializingBean { |
| | | public class AliyunCloudStorageStrategy extends AbstractCloudStorageStrategy { |
| | | |
| | | private final OSSClient client; |
| | | private final AliyunProperties properties; |
| | | |
| | | @Autowired |
| | | public AliyunCloudStorageServiceImpl(CloudStorageProperties properties) { |
| | | this.properties = properties.getAliyun(); |
| | | public AliyunCloudStorageStrategy(CloudStorageProperties cloudStorageProperties) { |
| | | properties = cloudStorageProperties; |
| | | try { |
| | | ClientConfiguration configuration = new ClientConfiguration(); |
| | | DefaultCredentialProvider credentialProvider = new DefaultCredentialProvider( |
| | | this.properties.getAccessKeyId(), |
| | | this.properties.getAccessKeySecret()); |
| | | client = new OSSClient(this.properties.getEndpoint(), credentialProvider, configuration); |
| | | properties.getAccessKey(), properties.getSecretKey()); |
| | | client = new OSSClient(properties.getEndpoint(), credentialProvider, configuration); |
| | | createBucket(); |
| | | } catch (Exception e) { |
| | | throw new IllegalArgumentException("é¿éäºåå¨é
ç½®é误! è¯·æ£æ¥ç³»ç»é
ç½®!"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void afterPropertiesSet() throws Exception { |
| | | OssFactory.register(getServiceType(), this); |
| | | } |
| | | |
| | | @Override |
| | | public String getEndpointLink() { |
| | | String endpoint = properties.getEndpoint(); |
| | | StringBuilder sb = new StringBuilder(endpoint); |
| | | if (StrUtil.containsAnyIgnoreCase(endpoint, "http://")) { |
| | | if (StringUtils.containsAnyIgnoreCase(endpoint, "http://")) { |
| | | sb.insert(7, properties.getBucketName() + "."); |
| | | } else if (StrUtil.containsAnyIgnoreCase(endpoint, "https://")) { |
| | | } else if (StringUtils.containsAnyIgnoreCase(endpoint, "https://")) { |
| | | sb.insert(8, properties.getBucketName() + "."); |
| | | } else { |
| | | throw new OssException("Endpointé
ç½®é误"); |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/oss/service/impl/MinioCloudStorageServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.oss.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.oss.entity.UploadResult; |
| | | import com.ruoyi.oss.enumd.CloudServiceEnumd; |
| | | import com.ruoyi.oss.enumd.PolicyType; |
| | | import com.ruoyi.oss.exception.OssException; |
| | | import com.ruoyi.oss.factory.OssFactory; |
| | | import com.ruoyi.oss.properties.CloudStorageProperties; |
| | | import com.ruoyi.oss.properties.CloudStorageProperties.MinioProperties; |
| | | import com.ruoyi.oss.service.abstractd.AbstractCloudStorageService; |
| | | import com.ruoyi.oss.service.abstractd.AbstractCloudStorageStrategy; |
| | | import io.minio.*; |
| | | import org.springframework.beans.factory.InitializingBean; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.InputStream; |
| | | |
| | | /** |
| | | * minioåå¨ |
| | | * minioåå¨çç¥ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Lazy |
| | | @Service |
| | | public class MinioCloudStorageServiceImpl extends AbstractCloudStorageService implements InitializingBean { |
| | | public class MinioCloudStorageStrategy extends AbstractCloudStorageStrategy { |
| | | |
| | | private final MinioClient minioClient; |
| | | private final MinioProperties properties; |
| | | |
| | | @Autowired |
| | | public MinioCloudStorageServiceImpl(CloudStorageProperties properties) { |
| | | this.properties = properties.getMinio(); |
| | | public MinioCloudStorageStrategy(CloudStorageProperties cloudStorageProperties) { |
| | | properties = cloudStorageProperties; |
| | | try { |
| | | minioClient = MinioClient.builder() |
| | | .endpoint(this.properties.getEndpoint()) |
| | | .credentials(this.properties.getAccessKey(), this.properties.getSecretKey()) |
| | | .endpoint(properties.getEndpoint()) |
| | | .credentials(properties.getAccessKey(), properties.getSecretKey()) |
| | | .build(); |
| | | createBucket(); |
| | | } catch (Exception e) { |
| | |
| | | minioClient.putObject(PutObjectArgs.builder() |
| | | .bucket(properties.getBucketName()) |
| | | .object(path) |
| | | .contentType(StrUtil.blankToDefault(contentType, MediaType.APPLICATION_OCTET_STREAM_VALUE)) |
| | | .contentType(StringUtils.blankToDefault(contentType, MediaType.APPLICATION_OCTET_STREAM_VALUE)) |
| | | .stream(inputStream, inputStream.available(), -1) |
| | | .build()); |
| | | } catch (Exception e) { |
| | |
| | | @Override |
| | | public UploadResult uploadSuffix(InputStream inputStream, String suffix, String contentType) { |
| | | return upload(inputStream, getPath("", suffix), contentType); |
| | | } |
| | | |
| | | @Override |
| | | public void afterPropertiesSet() throws Exception { |
| | | OssFactory.register(getServiceType(), this); |
| | | } |
| | | |
| | | @Override |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/oss/service/impl/QcloudCloudStorageServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.oss.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.qcloud.cos.COSClient; |
| | | import com.qcloud.cos.ClientConfig; |
| | | import com.qcloud.cos.auth.BasicCOSCredentials; |
| | |
| | | import com.qcloud.cos.http.HttpProtocol; |
| | | import com.qcloud.cos.model.*; |
| | | import com.qcloud.cos.region.Region; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.oss.entity.UploadResult; |
| | | import com.ruoyi.oss.enumd.CloudServiceEnumd; |
| | | import com.ruoyi.oss.exception.OssException; |
| | | import com.ruoyi.oss.factory.OssFactory; |
| | | import com.ruoyi.oss.properties.CloudStorageProperties; |
| | | import com.ruoyi.oss.properties.CloudStorageProperties.QcloudProperties; |
| | | import com.ruoyi.oss.service.abstractd.AbstractCloudStorageService; |
| | | import org.springframework.beans.factory.InitializingBean; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.oss.service.abstractd.AbstractCloudStorageStrategy; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.InputStream; |
| | | |
| | | /** |
| | | * è
¾è®¯äºåå¨ |
| | | * è
¾è®¯äºåå¨çç¥ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Lazy |
| | | @Service |
| | | public class QcloudCloudStorageServiceImpl extends AbstractCloudStorageService implements InitializingBean { |
| | | public class QcloudCloudStorageStrategy extends AbstractCloudStorageStrategy { |
| | | |
| | | private final COSClient client; |
| | | private final QcloudProperties properties; |
| | | |
| | | @Autowired |
| | | public QcloudCloudStorageServiceImpl(CloudStorageProperties properties) { |
| | | this.properties = properties.getQcloud(); |
| | | public QcloudCloudStorageStrategy(CloudStorageProperties cloudStorageProperties) { |
| | | properties = cloudStorageProperties; |
| | | try { |
| | | COSCredentials credentials = new BasicCOSCredentials( |
| | | this.properties.getSecretId(), |
| | | this.properties.getSecretKey()); |
| | | properties.getAccessKey(), properties.getSecretKey()); |
| | | // åå§å客æ·ç«¯é
ç½® |
| | | ClientConfig clientConfig = new ClientConfig(); |
| | | // 设置bucketæå¨çåºåï¼ååï¼gz ååï¼tj åä¸ï¼sh |
| | | clientConfig.setRegion(new Region(this.properties.getRegion())); |
| | | if (this.properties.getIsHttps()) { |
| | | clientConfig.setRegion(new Region(properties.getRegion())); |
| | | if ("Y".equals(properties.getIsHttps())) { |
| | | clientConfig.setHttpProtocol(HttpProtocol.https); |
| | | } else { |
| | | clientConfig.setHttpProtocol(HttpProtocol.http); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void afterPropertiesSet() throws Exception { |
| | | OssFactory.register(getServiceType(),this); |
| | | } |
| | | |
| | | @Override |
| | | public String getEndpointLink() { |
| | | String endpoint = properties.getEndpoint(); |
| | | StringBuilder sb = new StringBuilder(endpoint); |
| | | if (StrUtil.containsAnyIgnoreCase(endpoint, "http://")) { |
| | | if (StringUtils.containsAnyIgnoreCase(endpoint, "http://")) { |
| | | sb.insert(7, properties.getBucketName() + "."); |
| | | } else if (StrUtil.containsAnyIgnoreCase(endpoint, "https://")) { |
| | | } else if (StringUtils.containsAnyIgnoreCase(endpoint, "https://")) { |
| | | sb.insert(8, properties.getBucketName() + "."); |
| | | } else { |
| | | throw new OssException("Endpointé
ç½®é误"); |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/oss/service/impl/QiniuCloudStorageServiceImpl.java ÐÞ¸Ä |
| | |
| | | import com.ruoyi.oss.entity.UploadResult; |
| | | import com.ruoyi.oss.enumd.CloudServiceEnumd; |
| | | import com.ruoyi.oss.exception.OssException; |
| | | import com.ruoyi.oss.factory.OssFactory; |
| | | import com.ruoyi.oss.properties.CloudStorageProperties; |
| | | import com.ruoyi.oss.properties.CloudStorageProperties.QiniuProperties; |
| | | import com.ruoyi.oss.service.abstractd.AbstractCloudStorageService; |
| | | import org.springframework.beans.factory.InitializingBean; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.oss.service.abstractd.AbstractCloudStorageStrategy; |
| | | |
| | | import java.io.InputStream; |
| | | |
| | | /** |
| | | * ä¸çäºåå¨ |
| | | * ä¸çäºåå¨çç¥ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Lazy |
| | | @Service |
| | | public class QiniuCloudStorageServiceImpl extends AbstractCloudStorageService implements InitializingBean { |
| | | public class QiniuCloudStorageStrategy extends AbstractCloudStorageStrategy { |
| | | |
| | | private final UploadManager uploadManager; |
| | | private final BucketManager bucketManager; |
| | | private final String token; |
| | | private final QiniuProperties properties; |
| | | |
| | | @Autowired |
| | | public QiniuCloudStorageServiceImpl(CloudStorageProperties properties) { |
| | | this.properties = properties.getQiniu(); |
| | | public QiniuCloudStorageStrategy(CloudStorageProperties cloudStorageProperties) { |
| | | properties = cloudStorageProperties; |
| | | try { |
| | | Configuration config = new Configuration(getRegion(this.properties.getRegion())); |
| | | Configuration config = new Configuration(getRegion(properties.getRegion())); |
| | | // https设置 |
| | | config.useHttpsDomains = false; |
| | | if (this.properties.getIsHttps() != null) { |
| | | config.useHttpsDomains = this.properties.getIsHttps(); |
| | | } |
| | | config.useHttpsDomains = "Y".equals(properties.getIsHttps()); |
| | | uploadManager = new UploadManager(config); |
| | | Auth auth = Auth.create( |
| | | this.properties.getAccessKey(), |
| | | this.properties.getSecretKey()); |
| | | String bucketName = this.properties.getBucketName(); |
| | | Auth auth = Auth.create(properties.getAccessKey(), properties.getSecretKey()); |
| | | String bucketName = properties.getBucketName(); |
| | | token = auth.uploadToken(bucketName); |
| | | bucketManager = new BucketManager(auth, config); |
| | | |
| | | if (!ArrayUtil.contains(bucketManager.buckets(), bucketName)) { |
| | | bucketManager.createBucket(bucketName, this.properties.getRegion()); |
| | | bucketManager.createBucket(bucketName, properties.getRegion()); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new IllegalArgumentException("ä¸çäºåå¨é
ç½®é误! è¯·æ£æ¥ç³»ç»é
ç½®!"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void afterPropertiesSet() throws Exception { |
| | | OssFactory.register(getServiceType(),this); |
| | | } |
| | | |
| | | @Override |
| | | public String getEndpointLink() { |
| | | return properties.getDomain(); |
| | | return properties.getEndpoint(); |
| | | } |
| | | |
| | | private Region getRegion(String region) { |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.6.0</version> |
| | | <version>3.0.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | |
| | | package com.ruoyi.quartz.controller; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.exception.job.TaskException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.quartz.domain.SysJob; |
| | | import com.ruoyi.quartz.service.ISysJobService; |
| | |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:export')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.EXPORT) |
| | | @GetMapping("/export") |
| | | public AjaxResult export(SysJob sysJob) |
| | | public void export(SysJob sysJob, HttpServletResponse response) |
| | | { |
| | | List<SysJob> list = jobService.selectJobList(sysJob); |
| | | ExcelUtil<SysJob> util = new ExcelUtil<SysJob>(SysJob.class); |
| | | return util.exportExcel(list, "宿¶ä»»å¡"); |
| | | ExcelUtil.exportExcel(list, "宿¶ä»»å¡", SysJob.class, response); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:add')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException |
| | | public AjaxResult add(@RequestBody SysJob job) throws SchedulerException, TaskException |
| | | { |
| | | if (!CronUtils.isValid(sysJob.getCronExpression())) |
| | | if (!CronUtils.isValid(job.getCronExpression())) |
| | | { |
| | | return AjaxResult.error("æ°å¢ä»»å¡'" + sysJob.getJobName() + "'失败ï¼Cron表达å¼ä¸æ£ç¡®"); |
| | | return error("æ°å¢ä»»å¡'" + job.getJobName() + "'失败ï¼Cron表达å¼ä¸æ£ç¡®"); |
| | | } |
| | | else if (StrUtil.containsIgnoreCase(sysJob.getInvokeTarget(), Constants.LOOKUP_RMI)) |
| | | else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI)) |
| | | { |
| | | return AjaxResult.error("æ°å¢ä»»å¡'" + sysJob.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'rmi://'è°ç¨"); |
| | | return error("æ°å¢ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'rmi://'è°ç¨"); |
| | | } |
| | | sysJob.setCreateBy(SecurityUtils.getUsername()); |
| | | return toAjax(jobService.insertJob(sysJob)); |
| | | else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS })) |
| | | { |
| | | return error("æ°å¢ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'http(s)//'è°ç¨"); |
| | | } |
| | | job.setCreateBy(getUsername()); |
| | | return toAjax(jobService.insertJob(job)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:edit')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException |
| | | public AjaxResult edit(@RequestBody SysJob job) throws SchedulerException, TaskException |
| | | { |
| | | if (!CronUtils.isValid(sysJob.getCronExpression())) |
| | | if (!CronUtils.isValid(job.getCronExpression())) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹ä»»å¡'" + sysJob.getJobName() + "'失败ï¼Cron表达å¼ä¸æ£ç¡®"); |
| | | return error("ä¿®æ¹ä»»å¡'" + job.getJobName() + "'失败ï¼Cron表达å¼ä¸æ£ç¡®"); |
| | | } |
| | | else if (StrUtil.containsIgnoreCase(sysJob.getInvokeTarget(), Constants.LOOKUP_RMI)) |
| | | else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI)) |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹ä»»å¡'" + sysJob.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'rmi://'è°ç¨"); |
| | | return error("ä¿®æ¹ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'rmi://'è°ç¨"); |
| | | } |
| | | sysJob.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(jobService.updateJob(sysJob)); |
| | | else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS })) |
| | | { |
| | | return error("ä¿®æ¹ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'http(s)//'è°ç¨"); |
| | | } |
| | | job.setUpdateBy(getUsername()); |
| | | return toAjax(jobService.updateJob(job)); |
| | | } |
| | | |
| | | /** |
| | |
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | |
|
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List;
|
| | |
|
| | | /**
|
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:export')")
|
| | | @Log(title = "ä»»å¡è°åº¦æ¥å¿", businessType = BusinessType.EXPORT)
|
| | | @GetMapping("/export")
|
| | | public AjaxResult export(SysJobLog sysJobLog)
|
| | | public void export(SysJobLog sysJobLog, HttpServletResponse response) |
| | | {
|
| | | List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
|
| | | ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class);
|
| | | return util.exportExcel(list, "è°åº¦æ¥å¿");
|
| | | ExcelUtil.exportExcel(list, "è°åº¦æ¥å¿", SysJobLog.class, response); |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | package com.ruoyi.quartz.domain; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.ruoyi.common.annotation.Excel.ColumnType; |
| | | import com.ruoyi.common.annotation.ExcelDictFormat; |
| | | import com.ruoyi.common.constant.ScheduleConstants; |
| | | import com.ruoyi.common.convert.ExcelDictConvert; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.quartz.util.CronUtils; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | @TableName("sys_job") |
| | | @ExcelIgnoreUnannotated |
| | | public class SysJob implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ä»»å¡ID |
| | | */ |
| | | @Excel(name = "ä»»å¡åºå·", cellType = ColumnType.NUMERIC) |
| | | @ExcelProperty(value = "ä»»å¡åºå·") |
| | | @TableId(value = "job_id", type = IdType.AUTO) |
| | | private Long jobId; |
| | | |
| | |
| | | */ |
| | | @NotBlank(message = "ä»»å¡åç§°ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 64, message = "ä»»å¡åç§°ä¸è½è¶
è¿64个å符") |
| | | @Excel(name = "ä»»å¡åç§°") |
| | | @ExcelProperty(value = "ä»»å¡åç§°") |
| | | private String jobName; |
| | | |
| | | /** |
| | | * ä»»å¡ç»å |
| | | */ |
| | | @Excel(name = "ä»»å¡ç»å") |
| | | @ExcelProperty(value = "ä»»å¡ç»å", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_job_group") |
| | | private String jobGroup; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @NotBlank(message = "è°ç¨ç®æ å符串ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 500, message = "è°ç¨ç®æ å符串é¿åº¦ä¸è½è¶
è¿500个å符") |
| | | @Excel(name = "è°ç¨ç®æ å符串") |
| | | @ExcelProperty(value = "è°ç¨ç®æ å符串") |
| | | private String invokeTarget; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @NotBlank(message = "Cronæ§è¡è¡¨è¾¾å¼ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 255, message = "Cronæ§è¡è¡¨è¾¾å¼ä¸è½è¶
è¿255个å符") |
| | | @Excel(name = "æ§è¡è¡¨è¾¾å¼ ") |
| | | @ExcelProperty(value = "æ§è¡è¡¨è¾¾å¼") |
| | | private String cronExpression; |
| | | |
| | | /** |
| | | * cron计åçç¥ |
| | | */ |
| | | @Excel(name = "计åçç¥ ", readConverterExp = "0=é»è®¤,1=ç«å³è§¦åæ§è¡,2=触å䏿¬¡æ§è¡,3=ä¸è§¦åç«å³æ§è¡") |
| | | @ExcelProperty(value = "计åçç¥ ", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(readConverterExp = "0=é»è®¤,1=ç«å³è§¦åæ§è¡,2=触å䏿¬¡æ§è¡,3=ä¸è§¦åç«å³æ§è¡") |
| | | private String misfirePolicy = ScheduleConstants.MISFIRE_DEFAULT; |
| | | |
| | | /** |
| | | * æ¯å¦å¹¶åæ§è¡ï¼0å
许 1ç¦æ¢ï¼ |
| | | */ |
| | | @Excel(name = "å¹¶åæ§è¡", readConverterExp = "0=å
许,1=ç¦æ¢") |
| | | @ExcelProperty(value = "å¹¶åæ§è¡", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(readConverterExp = "0=å
许,1=ç¦æ¢") |
| | | private String concurrent; |
| | | |
| | | /** |
| | | * ä»»å¡ç¶æï¼0æ£å¸¸ 1æåï¼ |
| | | */ |
| | | @Excel(name = "ä»»å¡ç¶æ", readConverterExp = "0=æ£å¸¸,1=æå") |
| | | @ExcelProperty(value = "ä»»å¡ç¶æ", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_job_status") |
| | | private String status; |
| | | |
| | | /** |
| | |
| | | * å建æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** |
| | |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | /** |
| | |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | public Date getNextValidTime() { |
| | | if (StrUtil.isNotEmpty(cronExpression)) { |
| | | if (StringUtils.isNotEmpty(cronExpression)) { |
| | | return CronUtils.getNextExecution(cronExpression); |
| | | } |
| | | return null; |
| | |
| | | package com.ruoyi.quartz.domain;
|
| | |
|
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.baomidou.mybatisplus.annotation.*;
|
| | | import com.fasterxml.jackson.annotation.JsonFormat;
|
| | | import com.ruoyi.common.annotation.Excel;
|
| | | import com.ruoyi.common.annotation.ExcelDictFormat; |
| | | import com.ruoyi.common.convert.ExcelDictConvert; |
| | | import lombok.Data;
|
| | | import lombok.NoArgsConstructor;
|
| | | import lombok.experimental.Accessors;
|
| | |
| | | @NoArgsConstructor
|
| | | @Accessors(chain = true)
|
| | | @TableName("sys_job_log")
|
| | | @ExcelIgnoreUnannotated |
| | | public class SysJobLog
|
| | | {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | /** ID */
|
| | | @Excel(name = "æ¥å¿åºå·")
|
| | | @ExcelProperty(value = "æ¥å¿åºå·") |
| | | @TableId(value = "job_log_id", type = IdType.AUTO)
|
| | | private Long jobLogId;
|
| | |
|
| | | /** ä»»å¡åç§° */
|
| | | @Excel(name = "ä»»å¡åç§°")
|
| | | @ExcelProperty(value = "ä»»å¡åç§°") |
| | | private String jobName;
|
| | |
|
| | | /** ä»»å¡ç»å */
|
| | | @Excel(name = "ä»»å¡ç»å")
|
| | | @ExcelProperty(value = "ä»»å¡ç»å", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_job_group") |
| | | private String jobGroup;
|
| | |
|
| | | /** è°ç¨ç®æ å符串 */
|
| | | @Excel(name = "è°ç¨ç®æ å符串")
|
| | | @ExcelProperty(value = "è°ç¨ç®æ å符串") |
| | | private String invokeTarget;
|
| | |
|
| | | /** æ¥å¿ä¿¡æ¯ */
|
| | | @Excel(name = "æ¥å¿ä¿¡æ¯")
|
| | | @ExcelProperty(value = "æ¥å¿ä¿¡æ¯") |
| | | private String jobMessage;
|
| | |
|
| | | /** æ§è¡ç¶æï¼0æ£å¸¸ 1å¤±è´¥ï¼ */
|
| | | @Excel(name = "æ§è¡ç¶æ", readConverterExp = "0=æ£å¸¸,1=失败")
|
| | | @ExcelProperty(value = "æ§è¡ç¶æ", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_common_status") |
| | | private String status;
|
| | |
|
| | | /** å¼å¸¸ä¿¡æ¯ */
|
| | | @Excel(name = "å¼å¸¸ä¿¡æ¯")
|
| | | @ExcelProperty(value = "å¼å¸¸ä¿¡æ¯") |
| | | private String exceptionInfo;
|
| | |
|
| | | /**
|
| | | * å建æ¶é´
|
| | | */
|
| | | @TableField(fill = FieldFill.INSERT)
|
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
| | | private Date createTime;
|
| | |
|
| | | /**
|
| | |
| | | package com.ruoyi.quartz.service.impl; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | |
| | | public TableDataInfo<SysJobLog> selectPageJobLogList(SysJobLog jobLog) { |
| | | Map<String, Object> params = jobLog.getParams(); |
| | | LambdaQueryWrapper<SysJobLog> lqw = new LambdaQueryWrapper<SysJobLog>() |
| | | .like(StrUtil.isNotBlank(jobLog.getJobName()), SysJobLog::getJobName, jobLog.getJobName()) |
| | | .eq(StrUtil.isNotBlank(jobLog.getJobGroup()), SysJobLog::getJobGroup, jobLog.getJobGroup()) |
| | | .eq(StrUtil.isNotBlank(jobLog.getStatus()), SysJobLog::getStatus, jobLog.getStatus()) |
| | | .like(StrUtil.isNotBlank(jobLog.getInvokeTarget()), SysJobLog::getInvokeTarget, jobLog.getInvokeTarget()) |
| | | .apply(Validator.isNotEmpty(params.get("beginTime")), |
| | | .like(StringUtils.isNotBlank(jobLog.getJobName()), SysJobLog::getJobName, jobLog.getJobName()) |
| | | .eq(StringUtils.isNotBlank(jobLog.getJobGroup()), SysJobLog::getJobGroup, jobLog.getJobGroup()) |
| | | .eq(StringUtils.isNotBlank(jobLog.getStatus()), SysJobLog::getStatus, jobLog.getStatus()) |
| | | .like(StringUtils.isNotBlank(jobLog.getInvokeTarget()), SysJobLog::getInvokeTarget, jobLog.getInvokeTarget()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(Validator.isNotEmpty(params.get("endTime")), |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime")); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); |
| | |
| | | public List<SysJobLog> selectJobLogList(SysJobLog jobLog) { |
| | | Map<String, Object> params = jobLog.getParams(); |
| | | return list(new LambdaQueryWrapper<SysJobLog>() |
| | | .like(StrUtil.isNotBlank(jobLog.getJobName()), SysJobLog::getJobName, jobLog.getJobName()) |
| | | .eq(StrUtil.isNotBlank(jobLog.getJobGroup()), SysJobLog::getJobGroup, jobLog.getJobGroup()) |
| | | .eq(StrUtil.isNotBlank(jobLog.getStatus()), SysJobLog::getStatus, jobLog.getStatus()) |
| | | .like(StrUtil.isNotBlank(jobLog.getInvokeTarget()), SysJobLog::getInvokeTarget, jobLog.getInvokeTarget()) |
| | | .apply(Validator.isNotEmpty(params.get("beginTime")), |
| | | .like(StringUtils.isNotBlank(jobLog.getJobName()), SysJobLog::getJobName, jobLog.getJobName()) |
| | | .eq(StringUtils.isNotBlank(jobLog.getJobGroup()), SysJobLog::getJobGroup, jobLog.getJobGroup()) |
| | | .eq(StringUtils.isNotBlank(jobLog.getStatus()), SysJobLog::getStatus, jobLog.getStatus()) |
| | | .like(StringUtils.isNotBlank(jobLog.getInvokeTarget()), SysJobLog::getInvokeTarget, jobLog.getInvokeTarget()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(Validator.isNotEmpty(params.get("endTime")), |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime"))); |
| | | } |
| | |
| | | package com.ruoyi.quartz.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.constant.ScheduleConstants; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | |
| | | @Override |
| | | public TableDataInfo<SysJob> selectPageJobList(SysJob job) { |
| | | LambdaQueryWrapper<SysJob> lqw = new LambdaQueryWrapper<SysJob>() |
| | | .like(StrUtil.isNotBlank(job.getJobName()), SysJob::getJobName, job.getJobName()) |
| | | .eq(StrUtil.isNotBlank(job.getJobGroup()), SysJob::getJobGroup, job.getJobGroup()) |
| | | .eq(StrUtil.isNotBlank(job.getStatus()), SysJob::getStatus, job.getStatus()) |
| | | .like(StrUtil.isNotBlank(job.getInvokeTarget()), SysJob::getInvokeTarget, job.getInvokeTarget()); |
| | | .like(StringUtils.isNotBlank(job.getJobName()), SysJob::getJobName, job.getJobName()) |
| | | .eq(StringUtils.isNotBlank(job.getJobGroup()), SysJob::getJobGroup, job.getJobGroup()) |
| | | .eq(StringUtils.isNotBlank(job.getStatus()), SysJob::getStatus, job.getStatus()) |
| | | .like(StringUtils.isNotBlank(job.getInvokeTarget()), SysJob::getInvokeTarget, job.getInvokeTarget()); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public List<SysJob> selectJobList(SysJob job) { |
| | | return list(new LambdaQueryWrapper<SysJob>() |
| | | .like(StrUtil.isNotBlank(job.getJobName()), SysJob::getJobName, job.getJobName()) |
| | | .eq(StrUtil.isNotBlank(job.getJobGroup()), SysJob::getJobGroup, job.getJobGroup()) |
| | | .eq(StrUtil.isNotBlank(job.getStatus()), SysJob::getStatus, job.getStatus()) |
| | | .like(StrUtil.isNotBlank(job.getInvokeTarget()), SysJob::getInvokeTarget, job.getInvokeTarget())); |
| | | .like(StringUtils.isNotBlank(job.getJobName()), SysJob::getJobName, job.getJobName()) |
| | | .eq(StringUtils.isNotBlank(job.getJobGroup()), SysJob::getJobGroup, job.getJobGroup()) |
| | | .eq(StringUtils.isNotBlank(job.getStatus()), SysJob::getStatus, job.getStatus()) |
| | | .like(StringUtils.isNotBlank(job.getInvokeTarget()), SysJob::getInvokeTarget, job.getInvokeTarget())); |
| | | } |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.quartz.task;
|
| | |
|
| | | import cn.hutool.core.lang.Console;
|
| | | import cn.hutool.core.util.StrUtil;
|
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | /**
|
| | |
| | | {
|
| | | public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
|
| | | {
|
| | | Console.log(StrUtil.format("æ§è¡å¤åæ¹æ³ï¼ å符串类å{}ï¼å¸å°ç±»å{}ï¼é¿æ´å{}ï¼æµ®ç¹å{}ï¼æ´å½¢{}", s, b, l, d, i));
|
| | | Console.log(StringUtils.format("æ§è¡å¤åæ¹æ³ï¼ å符串类å{}ï¼å¸å°ç±»å{}ï¼é¿æ´å{}ï¼æµ®ç¹å{}ï¼æ´å½¢{}", s, b, l, d, i)); |
| | | }
|
| | |
|
| | | public void ryParams(String params)
|
| | |
| | |
|
| | | import cn.hutool.core.bean.BeanUtil;
|
| | | import cn.hutool.core.exceptions.ExceptionUtil;
|
| | | import cn.hutool.core.lang.Validator;
|
| | | import cn.hutool.core.util.StrUtil;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.constant.ScheduleConstants;
|
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils;
|
| | | import com.ruoyi.quartz.domain.SysJob;
|
| | | import com.ruoyi.quartz.domain.SysJobLog;
|
| | |
| | | try
|
| | | {
|
| | | before(context, sysJob);
|
| | | if (Validator.isNotNull(sysJob))
|
| | | if (StringUtils.isNotNull(sysJob)) |
| | | {
|
| | | doExecute(context, sysJob);
|
| | | }
|
| | |
| | | if (e != null)
|
| | | {
|
| | | sysJobLog.setStatus(Constants.FAIL);
|
| | | String errorMsg = StrUtil.sub(ExceptionUtil.stacktraceToString(e), 0, 2000);
|
| | | String errorMsg = StringUtils.substring(ExceptionUtil.stacktraceToString(e), 0, 2000); |
| | | sysJobLog.setExceptionInfo(errorMsg);
|
| | | }
|
| | | else
|
| | |
| | | package com.ruoyi.quartz.util;
|
| | |
|
| | | import cn.hutool.core.lang.Validator;
|
| | | import cn.hutool.core.util.StrUtil;
|
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils;
|
| | | import com.ruoyi.quartz.domain.SysJob;
|
| | |
|
| | |
| | | throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException,
|
| | | InvocationTargetException
|
| | | {
|
| | | if (Validator.isNotNull(methodParams) && methodParams.size() > 0)
|
| | | if (StringUtils.isNotNull(methodParams) && methodParams.size() > 0) |
| | | {
|
| | | Method method = bean.getClass().getDeclaredMethod(methodName, getMethodParamsType(methodParams));
|
| | | method.invoke(bean, getMethodParamsValue(methodParams));
|
| | |
| | | */
|
| | | public static boolean isValidClassName(String invokeTarget)
|
| | | {
|
| | | return StrUtil.count(invokeTarget, ".") > 1;
|
| | | return StringUtils.countMatches(invokeTarget, ".") > 1; |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | public static String getBeanName(String invokeTarget)
|
| | | {
|
| | | String beanName = StrUtil.subBefore(invokeTarget, "(",false);
|
| | | return StrUtil.subBefore(beanName, ".",true);
|
| | | String beanName = StringUtils.substringBefore(invokeTarget, "("); |
| | | return StringUtils.substringBefore(beanName, "."); |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | public static String getMethodName(String invokeTarget)
|
| | | {
|
| | | String methodName = StrUtil.subBefore(invokeTarget, "(",false);
|
| | | return StrUtil.subAfter(methodName, ".",true);
|
| | | String methodName = StringUtils.substringBefore(invokeTarget, "("); |
| | | return StringUtils.substringBefore(methodName, "."); |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | public static List<Object[]> getMethodParams(String invokeTarget)
|
| | | {
|
| | | String methodStr = StrUtil.subBetween(invokeTarget, "(", ")");
|
| | | if (StrUtil.isEmpty(methodStr))
|
| | | String methodStr = StringUtils.substringBetween(invokeTarget, "(", ")"); |
| | | if (StringUtils.isEmpty(methodStr)) |
| | | {
|
| | | return null;
|
| | | }
|
| | |
| | | List<Object[]> classs = new LinkedList<>();
|
| | | for (int i = 0; i < methodParams.length; i++)
|
| | | {
|
| | | String str = StrUtil.trimToEmpty(methodParams[i]);
|
| | | String str = StringUtils.trimToEmpty(methodParams[i]); |
| | | // Stringå符串类åï¼å
å«'
|
| | | if (StrUtil.contains(str, "'"))
|
| | | if (StringUtils.contains(str, "'")) |
| | | {
|
| | | classs.add(new Object[] { StrUtil.replace(str, "'", ""), String.class });
|
| | | classs.add(new Object[] { StringUtils.replace(str, "'", ""), String.class }); |
| | | }
|
| | | // booleanå¸å°ç±»åï¼çäºtrueæè
false
|
| | | else if (StrUtil.equals(str, "true") || StrUtil.equalsIgnoreCase(str, "false"))
|
| | | else if (StringUtils.equals(str, "true") || StringUtils.equalsIgnoreCase(str, "false")) |
| | | {
|
| | | classs.add(new Object[] { Boolean.valueOf(str), Boolean.class });
|
| | | }
|
| | | // longé¿æ´å½¢ï¼å
å«L
|
| | | else if (StrUtil.containsIgnoreCase(str, "L"))
|
| | | else if (StringUtils.containsIgnoreCase(str, "L")) |
| | | {
|
| | | classs.add(new Object[] { Long.valueOf(StrUtil.replaceIgnoreCase(str, "L", "")), Long.class });
|
| | | classs.add(new Object[] { Long.valueOf(StringUtils.replaceIgnoreCase(str, "L", "")), Long.class }); |
| | | }
|
| | | // doubleæµ®ç¹ç±»åï¼å
å«D
|
| | | else if (StrUtil.containsIgnoreCase(str, "D"))
|
| | | else if (StringUtils.containsIgnoreCase(str, "D")) |
| | | {
|
| | | classs.add(new Object[] { Double.valueOf(StrUtil.replaceIgnoreCase(str, "D", "")), Double.class });
|
| | | classs.add(new Object[] { Double.valueOf(StringUtils.replaceIgnoreCase(str, "D", "")), Double.class }); |
| | | }
|
| | | // å
¶ä»ç±»åå½ç±»ä¸ºæ´å½¢
|
| | | else
|
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.6.0</version> |
| | | <version>3.0.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | |
| | | <artifactId>ruoyi-common</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- OSSåè½æ¨¡å --> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-oss</artifactId> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | </project> |
| | |
| | | package com.ruoyi.system.domain; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.ruoyi.common.annotation.Excel.ColumnType; |
| | | import com.ruoyi.common.annotation.ExcelDictFormat; |
| | | import com.ruoyi.common.convert.ExcelDictConvert; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | @TableName("sys_config") |
| | | @ExcelIgnoreUnannotated |
| | | public class SysConfig implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * åæ°ä¸»é® |
| | | */ |
| | | @Excel(name = "忰䏻é®", cellType = ColumnType.NUMERIC) |
| | | @ExcelProperty(value = "忰䏻é®") |
| | | @TableId(value = "config_id", type = IdType.AUTO) |
| | | private Long configId; |
| | | |
| | | /** |
| | | * åæ°åç§° |
| | | */ |
| | | @Excel(name = "åæ°åç§°") |
| | | @ExcelProperty(value = "åæ°åç§°") |
| | | @NotBlank(message = "åæ°åç§°ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 100, message = "åæ°åç§°ä¸è½è¶
è¿100个å符") |
| | | private String configName; |
| | |
| | | /** |
| | | * åæ°é®å |
| | | */ |
| | | @Excel(name = "åæ°é®å") |
| | | @ExcelProperty(value = "åæ°é®å") |
| | | @NotBlank(message = "åæ°é®åé¿åº¦ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 100, message = "åæ°é®åé¿åº¦ä¸è½è¶
è¿100个å符") |
| | | private String configKey; |
| | |
| | | /** |
| | | * åæ°é®å¼ |
| | | */ |
| | | @Excel(name = "åæ°é®å¼") |
| | | @ExcelProperty(value = "åæ°é®å¼") |
| | | @NotBlank(message = "åæ°é®å¼ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 500, message = "åæ°é®å¼é¿åº¦ä¸è½è¶
è¿500个å符") |
| | | private String configValue; |
| | |
| | | /** |
| | | * ç³»ç»å
ç½®ï¼Yæ¯ Nå¦ï¼ |
| | | */ |
| | | @Excel(name = "ç³»ç»å
ç½®", readConverterExp = "Y=æ¯,N=å¦") |
| | | @ExcelProperty(value = "ç³»ç»å
ç½®", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_yes_no") |
| | | private String configType; |
| | | |
| | | /** |
| | |
| | | * å建æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** |
| | |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.system.domain; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.ruoyi.common.annotation.Excel.ColumnType; |
| | | import com.ruoyi.common.annotation.ExcelDictFormat; |
| | | import com.ruoyi.common.convert.ExcelDictConvert; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | @TableName("sys_logininfor") |
| | | @ExcelIgnoreUnannotated |
| | | public class SysLogininfor implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ID |
| | | */ |
| | | @Excel(name = "åºå·", cellType = ColumnType.NUMERIC) |
| | | @ExcelProperty(value = "åºå·") |
| | | @TableId(value = "info_id", type = IdType.AUTO) |
| | | private Long infoId; |
| | | |
| | | /** |
| | | * ç¨æ·è´¦å· |
| | | */ |
| | | @Excel(name = "ç¨æ·è´¦å·") |
| | | @ExcelProperty(value = "ç¨æ·è´¦å·") |
| | | private String userName; |
| | | |
| | | /** |
| | | * ç»å½ç¶æ 0æå 1失败 |
| | | */ |
| | | @Excel(name = "ç»å½ç¶æ", readConverterExp = "0=æå,1=失败") |
| | | @ExcelProperty(value = "ç»å½ç¶æ", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_common_status") |
| | | private String status; |
| | | |
| | | /** |
| | | * ç»å½IPå°å |
| | | */ |
| | | @Excel(name = "ç»å½å°å") |
| | | @ExcelProperty(value = "ç»å½å°å") |
| | | private String ipaddr; |
| | | |
| | | /** |
| | | * ç»å½å°ç¹ |
| | | */ |
| | | @Excel(name = "ç»å½å°ç¹") |
| | | @ExcelProperty(value = "ç»å½å°ç¹") |
| | | private String loginLocation; |
| | | |
| | | /** |
| | | * æµè§å¨ç±»å |
| | | */ |
| | | @Excel(name = "æµè§å¨") |
| | | @ExcelProperty(value = "æµè§å¨") |
| | | private String browser; |
| | | |
| | | /** |
| | | * æä½ç³»ç» |
| | | */ |
| | | @Excel(name = "æä½ç³»ç»") |
| | | @ExcelProperty(value = "æä½ç³»ç»") |
| | | private String os; |
| | | |
| | | /** |
| | | * æç¤ºæ¶æ¯ |
| | | */ |
| | | @Excel(name = "æç¤ºæ¶æ¯") |
| | | @ExcelProperty(value = "æç¤ºæ¶æ¯") |
| | | private String msg; |
| | | |
| | | /** |
| | | * è®¿é®æ¶é´ |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Excel(name = "è®¿é®æ¶é´", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | @ExcelProperty(value = "è®¿é®æ¶é´") |
| | | private Date loginTime; |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.system.domain; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.ruoyi.common.annotation.Excel.ColumnType; |
| | | import com.ruoyi.common.annotation.ExcelDictFormat; |
| | | import com.ruoyi.common.convert.ExcelDictConvert; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | @TableName("sys_oper_log") |
| | | @ExcelIgnoreUnannotated |
| | | public class SysOperLog implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * æ¥å¿ä¸»é® |
| | | */ |
| | | @Excel(name = "æä½åºå·", cellType = ColumnType.NUMERIC) |
| | | @ExcelProperty(value = "æä½åºå·") |
| | | @TableId(value = "oper_id", type = IdType.AUTO) |
| | | private Long operId; |
| | | |
| | | /** |
| | | * æä½æ¨¡å |
| | | */ |
| | | @Excel(name = "æä½æ¨¡å") |
| | | @ExcelProperty(value = "æä½æ¨¡å") |
| | | private String title; |
| | | |
| | | /** |
| | | * ä¸å¡ç±»åï¼0å
¶å® 1æ°å¢ 2ä¿®æ¹ 3å é¤ï¼ |
| | | */ |
| | | @Excel(name = "ä¸å¡ç±»å", readConverterExp = "0=å
¶å®,1=æ°å¢,2=ä¿®æ¹,3=å é¤,4=ææ,5=导åº,6=导å
¥,7=强é,8=çæä»£ç ,9=æ¸
ç©ºæ°æ®") |
| | | @ExcelProperty(value = "ä¸å¡ç±»å", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_oper_type") |
| | | private Integer businessType; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * è¯·æ±æ¹æ³ |
| | | */ |
| | | @Excel(name = "è¯·æ±æ¹æ³") |
| | | @ExcelProperty(value = "è¯·æ±æ¹æ³") |
| | | private String method; |
| | | |
| | | /** |
| | | * è¯·æ±æ¹å¼ |
| | | */ |
| | | @Excel(name = "è¯·æ±æ¹å¼") |
| | | @ExcelProperty(value = "è¯·æ±æ¹å¼") |
| | | private String requestMethod; |
| | | |
| | | /** |
| | | * æä½ç±»å«ï¼0å
¶å® 1åå°ç¨æ· 2ææºç«¯ç¨æ·ï¼ |
| | | */ |
| | | @Excel(name = "æä½ç±»å«", readConverterExp = "0=å
¶å®,1=åå°ç¨æ·,2=ææºç«¯ç¨æ·") |
| | | @ExcelProperty(value = "æä½ç±»å«", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(readConverterExp = "0=å
¶å®,1=åå°ç¨æ·,2=ææºç«¯ç¨æ·") |
| | | private Integer operatorType; |
| | | |
| | | /** |
| | | * æä½äººå |
| | | */ |
| | | @Excel(name = "æä½äººå") |
| | | @ExcelProperty(value = "æä½äººå") |
| | | private String operName; |
| | | |
| | | /** |
| | | * é¨é¨åç§° |
| | | */ |
| | | @Excel(name = "é¨é¨åç§°") |
| | | @ExcelProperty(value = "é¨é¨åç§°") |
| | | private String deptName; |
| | | |
| | | /** |
| | | * 请æ±url |
| | | */ |
| | | @Excel(name = "请æ±å°å") |
| | | @ExcelProperty(value = "请æ±å°å") |
| | | private String operUrl; |
| | | |
| | | /** |
| | | * æä½å°å |
| | | */ |
| | | @Excel(name = "æä½å°å") |
| | | @ExcelProperty(value = "æä½å°å") |
| | | private String operIp; |
| | | |
| | | /** |
| | | * æä½å°ç¹ |
| | | */ |
| | | @Excel(name = "æä½å°ç¹") |
| | | @ExcelProperty(value = "æä½å°ç¹") |
| | | private String operLocation; |
| | | |
| | | /** |
| | | * 请æ±åæ° |
| | | */ |
| | | @Excel(name = "请æ±åæ°") |
| | | @ExcelProperty(value = "请æ±åæ°") |
| | | private String operParam; |
| | | |
| | | /** |
| | | * è¿ååæ° |
| | | */ |
| | | @Excel(name = "è¿ååæ°") |
| | | @ExcelProperty(value = "è¿ååæ°") |
| | | private String jsonResult; |
| | | |
| | | /** |
| | | * æä½ç¶æï¼0æ£å¸¸ 1å¼å¸¸ï¼ |
| | | */ |
| | | @Excel(name = "ç¶æ", readConverterExp = "0=æ£å¸¸,1=å¼å¸¸") |
| | | @ExcelProperty(value = "ç¶æ", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_common_status") |
| | | private Integer status; |
| | | |
| | | /** |
| | | * éè¯¯æ¶æ¯ |
| | | */ |
| | | @Excel(name = "éè¯¯æ¶æ¯") |
| | | @ExcelProperty(value = "éè¯¯æ¶æ¯") |
| | | private String errorMsg; |
| | | |
| | | /** |
| | | * æä½æ¶é´ |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Excel(name = "æä½æ¶é´", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | @ExcelProperty(value = "æä½æ¶é´") |
| | | private Date operTime; |
| | | |
| | | /** |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * äºåå¨é
置对象 sys_oss_config |
| | | * |
| | | * @author ruoyi |
| | | * @date 2021-08-11 |
| | | */ |
| | | @Data |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | @TableName("sys_oss_config") |
| | | public class SysOssConfig implements Serializable { |
| | | |
| | | private static final long serialVersionUID=1L; |
| | | |
| | | |
| | | /** |
| | | * 主建 |
| | | */ |
| | | @TableId(value = "oss_config_id") |
| | | private Integer ossConfigId; |
| | | |
| | | /** |
| | | * é
ç½®key |
| | | */ |
| | | private String configKey; |
| | | |
| | | /** |
| | | * accessKey |
| | | */ |
| | | private String accessKey; |
| | | |
| | | /** |
| | | * ç§é¥ |
| | | */ |
| | | private String secretKey; |
| | | |
| | | /** |
| | | * æ¡¶åç§° |
| | | */ |
| | | private String bucketName; |
| | | |
| | | /** |
| | | * åç¼ |
| | | */ |
| | | private String prefix; |
| | | |
| | | /** |
| | | * 访é®ç«ç¹ |
| | | */ |
| | | private String endpoint; |
| | | |
| | | /** |
| | | * æ¯å¦httpsï¼0å¦ 1æ¯ï¼ |
| | | */ |
| | | private String isHttps; |
| | | |
| | | /** |
| | | * å |
| | | */ |
| | | private String region; |
| | | |
| | | /** |
| | | * ç¶æ(0æ£å¸¸ 1åç¨) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * æ©å±å段 |
| | | */ |
| | | private String ext1; |
| | | |
| | | /** |
| | | * å建è
|
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * æ´æ°è
|
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | private String remark; |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.domain; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.ruoyi.common.annotation.Excel.ColumnType; |
| | | import com.ruoyi.common.annotation.ExcelDictFormat; |
| | | import com.ruoyi.common.convert.ExcelDictConvert; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | @TableName("sys_post") |
| | | @ExcelIgnoreUnannotated |
| | | public class SysPost implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * å²ä½åºå· |
| | | */ |
| | | @Excel(name = "å²ä½åºå·", cellType = ColumnType.NUMERIC) |
| | | @ExcelProperty(value = "å²ä½åºå·") |
| | | @TableId(value = "post_id", type = IdType.AUTO) |
| | | private Long postId; |
| | | |
| | | /** |
| | | * å²ä½ç¼ç |
| | | */ |
| | | @Excel(name = "å²ä½ç¼ç ") |
| | | @ExcelProperty(value = "å²ä½ç¼ç ") |
| | | @NotBlank(message = "å²ä½ç¼ç ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 64, message = "å²ä½ç¼ç é¿åº¦ä¸è½è¶
è¿64个å符") |
| | | private String postCode; |
| | |
| | | /** |
| | | * å²ä½åç§° |
| | | */ |
| | | @Excel(name = "å²ä½åç§°") |
| | | @ExcelProperty(value = "å²ä½åç§°") |
| | | @NotBlank(message = "å²ä½åç§°ä¸è½ä¸ºç©º") |
| | | @Size(min = 0, max = 50, message = "å²ä½åç§°é¿åº¦ä¸è½è¶
è¿50个å符") |
| | | private String postName; |
| | |
| | | /** |
| | | * å²ä½æåº |
| | | */ |
| | | @Excel(name = "å²ä½æåº") |
| | | @ExcelProperty(value = "å²ä½æåº") |
| | | @NotBlank(message = "æ¾ç¤ºé¡ºåºä¸è½ä¸ºç©º") |
| | | private String postSort; |
| | | |
| | | /** |
| | | * ç¶æï¼0æ£å¸¸ 1åç¨ï¼ |
| | | */ |
| | | @Excel(name = "ç¶æ", readConverterExp = "0=æ£å¸¸,1=åç¨") |
| | | @ExcelProperty(value = "ç¶æ", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_common_status") |
| | | private String status; |
| | | |
| | | /** |
| | |
| | | * å建æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** |
| | |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | /** |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.domain.bo; |
| | | |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | import com.ruoyi.common.core.validate.AddGroup; |
| | | import com.ruoyi.common.core.validate.EditGroup; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import javax.validation.constraints.Size; |
| | | |
| | | /** |
| | | * äºåå¨é
ç½®ä¸å¡å¯¹è±¡ sys_oss_config |
| | | * |
| | | * @author Lion Li |
| | | * @author å¤èçé¨ |
| | | * @date 2021-08-13 |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel("äºåå¨é
ç½®ä¸å¡å¯¹è±¡") |
| | | public class SysOssConfigBo extends BaseEntity { |
| | | |
| | | /** |
| | | * 主建 |
| | | */ |
| | | @ApiModelProperty(value = "主建", required = true) |
| | | @NotNull(message = "主建ä¸è½ä¸ºç©º", groups = { EditGroup.class }) |
| | | private Long ossConfigId; |
| | | |
| | | /** |
| | | * é
ç½®key |
| | | */ |
| | | @ApiModelProperty(value = "configKey", required = true) |
| | | @NotBlank(message = "configKeyä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | @Size(min = 2, max = 100, message = "configKeyé¿åº¦å¿
é¡»ä»äº2å20 ä¹é´") |
| | | private String configKey; |
| | | |
| | | /** |
| | | * accessKey |
| | | */ |
| | | @ApiModelProperty(value = "accessKey", required = true) |
| | | @NotBlank(message = "accessKeyä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | @Size(min = 2, max = 100, message = "accessKeyé¿åº¦å¿
é¡»ä»äº2å100 ä¹é´") |
| | | private String accessKey; |
| | | |
| | | /** |
| | | * ç§é¥ |
| | | */ |
| | | @ApiModelProperty(value = "secretKey", required = true) |
| | | @NotBlank(message = "secretKeyä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | @Size(min = 2, max = 100, message = "secretKeyé¿åº¦å¿
é¡»ä»äº2å100 ä¹é´") |
| | | private String secretKey; |
| | | |
| | | /** |
| | | * æ¡¶åç§° |
| | | */ |
| | | @ApiModelProperty(value = "bucketName", required = true) |
| | | @NotBlank(message = "bucketNameä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | @Size(min = 2, max = 100, message = "bucketNameé¿åº¦å¿
é¡»ä»äº2å100ä¹é´") |
| | | private String bucketName; |
| | | |
| | | /** |
| | | * åç¼ |
| | | */ |
| | | @ApiModelProperty(value = "åç¼") |
| | | private String prefix; |
| | | |
| | | /** |
| | | * 访é®ç«ç¹ |
| | | */ |
| | | @ApiModelProperty(value = "endpoint", required = true) |
| | | @NotBlank(message = "endpointä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | @Size(min = 2, max = 100, message = "endpointé¿åº¦å¿
é¡»ä»äº2å100ä¹é´") |
| | | private String endpoint; |
| | | |
| | | /** |
| | | * æ¯å¦httpsï¼Y=æ¯,N=å¦ï¼ |
| | | */ |
| | | @ApiModelProperty("æ¯å¦httpsï¼Y=æ¯,N=å¦ï¼") |
| | | private String isHttps; |
| | | |
| | | /** |
| | | * ç¶æï¼0=æ£å¸¸,1=åç¨ï¼ |
| | | */ |
| | | @ApiModelProperty("ç¶æï¼0=æ£å¸¸,1=åç¨ï¼") |
| | | private String status; |
| | | |
| | | /** |
| | | * å |
| | | */ |
| | | @ApiModelProperty(value = "region") |
| | | private String region; |
| | | |
| | | /** |
| | | * æ©å±å段 |
| | | */ |
| | | @ApiModelProperty(value = "æ©å±å段") |
| | | private String ext1; |
| | | |
| | | |
| | | /** |
| | | * åé¡µå¤§å° |
| | | */ |
| | | @ApiModelProperty("å页大å°") |
| | | private Integer pageSize; |
| | | |
| | | /** |
| | | * å½åé¡µæ° |
| | | */ |
| | | @ApiModelProperty("å½å页æ°") |
| | | private Integer pageNum; |
| | | |
| | | /** |
| | | * æåºå |
| | | */ |
| | | @ApiModelProperty("æåºå") |
| | | private String orderByColumn; |
| | | |
| | | /** |
| | | * æåºçæ¹ådescæè
asc |
| | | */ |
| | | @ApiModelProperty(value = "æåºçæ¹å", example = "asc,desc") |
| | | private String isAsc; |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.domain.vo; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | |
| | | this.title = title; |
| | | this.icon = icon; |
| | | this.noCache = noCache; |
| | | if (Validator.isUrl(link)) { |
| | | if (StringUtils.ishttp(link)) { |
| | | this.link = link; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | |
| | | |
| | | /** |
| | | * äºåå¨é
ç½®è§å¾å¯¹è±¡ sys_oss_config |
| | | * |
| | | * @author Lion Li |
| | | * @author å¤èçé¨ |
| | | * @date 2021-08-13 |
| | | */ |
| | | @Data |
| | | @ApiModel("äºåå¨é
ç½®è§å¾å¯¹è±¡") |
| | | @ExcelIgnoreUnannotated |
| | | public class SysOssConfigVo { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主建 |
| | | */ |
| | | @ApiModelProperty("主建") |
| | | private Long ossConfigId; |
| | | |
| | | /** |
| | | * é
ç½®key |
| | | */ |
| | | @ApiModelProperty("é
ç½®key") |
| | | private String configKey; |
| | | |
| | | /** |
| | | * accessKey |
| | | */ |
| | | @ApiModelProperty("accessKey") |
| | | private String accessKey; |
| | | |
| | | /** |
| | | * ç§é¥ |
| | | */ |
| | | @ApiModelProperty("secretKey") |
| | | private String secretKey; |
| | | |
| | | /** |
| | | * æ¡¶åç§° |
| | | */ |
| | | @ApiModelProperty("æ¡¶åç§°") |
| | | private String bucketName; |
| | | |
| | | /** |
| | | * åç¼ |
| | | */ |
| | | @ApiModelProperty("åç¼") |
| | | private String prefix; |
| | | |
| | | /** |
| | | * 访é®ç«ç¹ |
| | | */ |
| | | @ApiModelProperty("访é®ç«ç¹") |
| | | private String endpoint; |
| | | |
| | | /** |
| | | * æ¯å¦httpsï¼Y=æ¯,N=å¦ï¼ |
| | | */ |
| | | @ApiModelProperty("æ¯å¦httpsï¼Y=æ¯,N=å¦ï¼") |
| | | private String isHttps; |
| | | |
| | | /** |
| | | * å |
| | | */ |
| | | @ApiModelProperty("å") |
| | | private String region; |
| | | |
| | | /** |
| | | * ç¶æï¼0=æ£å¸¸,1=åç¨ï¼ |
| | | */ |
| | | @ApiModelProperty("ç¶æï¼0=æ£å¸¸,1=åç¨ï¼") |
| | | private String status; |
| | | |
| | | /** |
| | | * æ©å±å段 |
| | | */ |
| | | @ApiModelProperty("æ©å±å段") |
| | | private String ext1; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | @ApiModelProperty("夿³¨") |
| | | private String remark; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.ruoyi.common.annotation.ExcelDictFormat; |
| | | import com.ruoyi.common.convert.ExcelDictConvert; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * ç¨æ·å¯¹è±¡å¯¼åºVO |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | public class SysUserExportVo implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ç¨æ·ID |
| | | */ |
| | | @ExcelProperty(value = "ç¨æ·åºå·") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * ç¨æ·è´¦å· |
| | | */ |
| | | @ExcelProperty(value = "ç»å½åç§°") |
| | | private String userName; |
| | | |
| | | /** |
| | | * ç¨æ·æµç§° |
| | | */ |
| | | @ExcelProperty(value = "ç¨æ·åç§°") |
| | | private String nickName; |
| | | |
| | | /** |
| | | * ç¨æ·é®ç®± |
| | | */ |
| | | @ExcelProperty(value = "ç¨æ·é®ç®±") |
| | | private String email; |
| | | |
| | | /** |
| | | * ææºå·ç |
| | | */ |
| | | @ExcelProperty(value = "ææºå·ç ") |
| | | private String phonenumber; |
| | | |
| | | /** |
| | | * ç¨æ·æ§å« |
| | | */ |
| | | @ExcelProperty(value = "ç¨æ·æ§å«", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_user_sex") |
| | | private String sex; |
| | | |
| | | /** |
| | | * å¸å·ç¶æï¼0æ£å¸¸ 1åç¨ï¼ |
| | | */ |
| | | @ExcelProperty(value = "å¸å·ç¶æ", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_common_status") |
| | | private String status; |
| | | |
| | | /** |
| | | * æåç»å½IP |
| | | */ |
| | | @ExcelProperty(value = "æåç»å½IP") |
| | | private String loginIp; |
| | | |
| | | /** |
| | | * æåç»å½æ¶é´ |
| | | */ |
| | | @ExcelProperty(value = "æåç»å½æ¶é´") |
| | | private Date loginDate; |
| | | |
| | | /** |
| | | * é¨é¨åç§° |
| | | */ |
| | | @ExcelProperty(value = "é¨é¨åç§°") |
| | | private String deptName; |
| | | |
| | | /** |
| | | * è´è´£äºº |
| | | */ |
| | | @ExcelProperty(value = "é¨é¨è´è´£äºº") |
| | | private String leader; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.ruoyi.common.annotation.ExcelDictFormat; |
| | | import com.ruoyi.common.convert.ExcelDictConvert; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * ç¨æ·å¯¹è±¡å¯¼å
¥VO |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @NoArgsConstructor |
| | | // @Accessors(chain = true) // 导å
¥ä¸å
è®¸ä½¿ç¨ ä¼æ¾ä¸å°setæ¹æ³ |
| | | public class SysUserImportVo implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ç¨æ·ID |
| | | */ |
| | | @ExcelProperty(value = "ç¨æ·åºå·") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * é¨é¨ID |
| | | */ |
| | | @ExcelProperty(value = "é¨é¨ç¼å·") |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * ç¨æ·è´¦å· |
| | | */ |
| | | @ExcelProperty(value = "ç»å½åç§°") |
| | | private String userName; |
| | | |
| | | /** |
| | | * ç¨æ·æµç§° |
| | | */ |
| | | @ExcelProperty(value = "ç¨æ·åç§°") |
| | | private String nickName; |
| | | |
| | | /** |
| | | * ç¨æ·é®ç®± |
| | | */ |
| | | @ExcelProperty(value = "ç¨æ·é®ç®±") |
| | | private String email; |
| | | |
| | | /** |
| | | * ææºå·ç |
| | | */ |
| | | @ExcelProperty(value = "ææºå·ç ") |
| | | private String phonenumber; |
| | | |
| | | /** |
| | | * ç¨æ·æ§å« |
| | | */ |
| | | @ExcelProperty(value = "ç¨æ·æ§å«", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_user_sex") |
| | | private String sex; |
| | | |
| | | /** |
| | | * å¸å·ç¶æï¼0æ£å¸¸ 1åç¨ï¼ |
| | | */ |
| | | @ExcelProperty(value = "å¸å·ç¶æ", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_common_status") |
| | | private String status; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysOssConfig; |
| | | |
| | | /** |
| | | * äºåå¨é
ç½®Mapperæ¥å£ |
| | | * |
| | | * @author Lion Li |
| | | * @author å¤èçé¨ |
| | | * @date 2021-08-13 |
| | | */ |
| | | public interface SysOssConfigMapper extends BaseMapperPlus<SysOssConfig> { |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysOssConfig; |
| | | import com.ruoyi.system.domain.bo.SysOssConfigBo; |
| | | import com.ruoyi.system.domain.vo.SysOssConfigVo; |
| | | |
| | | import java.util.Collection; |
| | | |
| | | /** |
| | | * äºåå¨é
ç½®Serviceæ¥å£ |
| | | * |
| | | * @author Lion Li |
| | | * @author å¤èçé¨ |
| | | * @date 2021-08-13 |
| | | */ |
| | | public interface ISysOssConfigService extends IServicePlus<SysOssConfig, SysOssConfigVo> { |
| | | |
| | | /** |
| | | * æ¥è¯¢å个 |
| | | */ |
| | | SysOssConfigVo queryById(Integer ossConfigId); |
| | | |
| | | /** |
| | | * æ¥è¯¢å表 |
| | | */ |
| | | TableDataInfo<SysOssConfigVo> queryPageList(SysOssConfigBo bo); |
| | | |
| | | |
| | | /** |
| | | * æ ¹æ®æ°å¢ä¸å¡å¯¹è±¡æå
¥äºåå¨é
ç½® |
| | | * @param bo äºåå¨é
ç½®æ°å¢ä¸å¡å¯¹è±¡ |
| | | * @return |
| | | */ |
| | | Boolean insertByBo(SysOssConfigBo bo); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¼è¾ä¸å¡å¯¹è±¡ä¿®æ¹äºåå¨é
ç½® |
| | | * @param bo äºåå¨é
ç½®ç¼è¾ä¸å¡å¯¹è±¡ |
| | | * @return |
| | | */ |
| | | Boolean updateByBo(SysOssConfigBo bo); |
| | | |
| | | /** |
| | | * æ ¡éªå¹¶å 餿°æ® |
| | | * @param ids 主é®éå |
| | | * @param isValid æ¯å¦æ ¡éª,true-å é¤åæ ¡éª,false-䏿 ¡éª |
| | | * @return |
| | | */ |
| | | Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
| | | |
| | | /** |
| | | * å¯ç¨åç¨ç¶æ |
| | | */ |
| | | int updateOssConfigStatus(SysOssConfigBo bo); |
| | | |
| | | } |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/system/service/ISysOssService.java ÐÞ¸Ä |
| | |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.bo.SysOssBo; |
| | | import com.ruoyi.system.domain.SysOss; |
| | | import com.ruoyi.system.domain.bo.SysOssBo; |
| | | import com.ruoyi.system.domain.vo.SysOssVo; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | |
| | | public int insertUser(SysUser user); |
| | | |
| | | /** |
| | | * 注åç¨æ·ä¿¡æ¯ |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | public boolean registerUser(SysUser user); |
| | | |
| | | /** |
| | | * ä¿®æ¹ç¨æ·ä¿¡æ¯ |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.annotation.DataSource; |
| | | import com.ruoyi.common.constant.Constants; |
| | |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.enums.DataSourceType; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.system.mapper.SysConfigMapper; |
| | |
| | | public TableDataInfo<SysConfig> selectPageConfigList(SysConfig config) { |
| | | Map<String, Object> params = config.getParams(); |
| | | LambdaQueryWrapper<SysConfig> lqw = new LambdaQueryWrapper<SysConfig>() |
| | | .like(StrUtil.isNotBlank(config.getConfigName()), SysConfig::getConfigName, config.getConfigName()) |
| | | .eq(StrUtil.isNotBlank(config.getConfigType()), SysConfig::getConfigType, config.getConfigType()) |
| | | .like(StrUtil.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey()) |
| | | .apply(Validator.isNotEmpty(params.get("beginTime")), |
| | | .like(StringUtils.isNotBlank(config.getConfigName()), SysConfig::getConfigName, config.getConfigName()) |
| | | .eq(StringUtils.isNotBlank(config.getConfigType()), SysConfig::getConfigType, config.getConfigType()) |
| | | .like(StringUtils.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(Validator.isNotEmpty(params.get("endTime")), |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime")); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); |
| | |
| | | @Override |
| | | public String selectConfigByKey(String configKey) { |
| | | String configValue = Convert.toStr(redisCache.getCacheObject(getCacheKey(configKey))); |
| | | if (Validator.isNotEmpty(configValue)) { |
| | | if (StringUtils.isNotEmpty(configValue)) { |
| | | return configValue; |
| | | } |
| | | SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>() |
| | | .eq(SysConfig::getConfigKey, configKey)); |
| | | if (Validator.isNotNull(retConfig)) { |
| | | if (StringUtils.isNotNull(retConfig)) { |
| | | redisCache.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue()); |
| | | return retConfig.getConfigValue(); |
| | | } |
| | | return StrUtil.EMPTY; |
| | | return StringUtils.EMPTY; |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public boolean selectCaptchaOnOff() { |
| | | String captchaOnOff = selectConfigByKey("sys.account.captchaOnOff"); |
| | | if (StrUtil.isEmpty(captchaOnOff)) { |
| | | if (StringUtils.isEmpty(captchaOnOff)) { |
| | | return true; |
| | | } |
| | | return Convert.toBool(captchaOnOff); |
| | |
| | | public List<SysConfig> selectConfigList(SysConfig config) { |
| | | Map<String, Object> params = config.getParams(); |
| | | LambdaQueryWrapper<SysConfig> lqw = new LambdaQueryWrapper<SysConfig>() |
| | | .like(StrUtil.isNotBlank(config.getConfigName()), SysConfig::getConfigName, config.getConfigName()) |
| | | .eq(StrUtil.isNotBlank(config.getConfigType()), SysConfig::getConfigType, config.getConfigType()) |
| | | .like(StrUtil.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey()) |
| | | .apply(Validator.isNotEmpty(params.get("beginTime")), |
| | | .like(StringUtils.isNotBlank(config.getConfigName()), SysConfig::getConfigName, config.getConfigName()) |
| | | .eq(StringUtils.isNotBlank(config.getConfigType()), SysConfig::getConfigType, config.getConfigType()) |
| | | .like(StringUtils.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(Validator.isNotEmpty(params.get("endTime")), |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime")); |
| | | return baseMapper.selectList(lqw); |
| | |
| | | public void deleteConfigByIds(Long[] configIds) { |
| | | for (Long configId : configIds) { |
| | | SysConfig config = selectConfigById(configId); |
| | | if (StrUtil.equals(UserConstants.YES, config.getConfigType())) { |
| | | throw new CustomException(String.format("å
ç½®åæ°ã%1$sãä¸è½å é¤ ", config.getConfigKey())); |
| | | if (StringUtils.equals(UserConstants.YES, config.getConfigType())) { |
| | | throw new ServiceException(String.format("å
ç½®åæ°ã%1$sãä¸è½å é¤ ", config.getConfigKey())); |
| | | } |
| | | redisCache.deleteObject(getCacheKey(config.getConfigKey())); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public String checkConfigKeyUnique(SysConfig config) { |
| | | Long configId = Validator.isNull(config.getConfigId()) ? -1L : config.getConfigId(); |
| | | Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId(); |
| | | SysConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getConfigKey, config.getConfigKey())); |
| | | if (Validator.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) { |
| | | if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMapper; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | |
| | | */ |
| | | @Override |
| | | public String checkDeptNameUnique(SysDept dept) { |
| | | Long deptId = Validator.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); |
| | | Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); |
| | | SysDept info = getOne(new LambdaQueryWrapper<SysDept>() |
| | | .eq(SysDept::getDeptName, dept.getDeptName()) |
| | | .eq(SysDept::getParentId, dept.getParentId()) |
| | | .last("limit 1")); |
| | | if (Validator.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) { |
| | | if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | SysDept info = getById(dept.getParentId()); |
| | | // 妿ç¶èç¹ä¸ä¸ºæ£å¸¸ç¶æ,åä¸å
许æ°å¢åèç¹ |
| | | if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) { |
| | | throw new CustomException("é¨é¨åç¨ï¼ä¸å
许æ°å¢"); |
| | | throw new ServiceException("é¨é¨åç¨ï¼ä¸å
许æ°å¢"); |
| | | } |
| | | dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); |
| | | return baseMapper.insert(dept); |
| | |
| | | public int updateDept(SysDept dept) { |
| | | SysDept newParentDept = getById(dept.getParentId()); |
| | | SysDept oldDept = getById(dept.getDeptId()); |
| | | if (Validator.isNotNull(newParentDept) && Validator.isNotNull(oldDept)) { |
| | | if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) { |
| | | String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); |
| | | String oldAncestors = oldDept.getAncestors(); |
| | | dept.setAncestors(newAncestors); |
| | | updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); |
| | | } |
| | | int result = baseMapper.updateById(dept); |
| | | if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) { |
| | | if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) |
| | | && !StringUtils.equals("0", dept.getAncestors())) { |
| | | // å¦æè¯¥é¨é¨æ¯å¯ç¨ç¶æï¼åå¯ç¨è¯¥é¨é¨çææä¸çº§é¨é¨ |
| | | updateParentDeptStatusNormal(dept); |
| | | } |
| | |
| | | private List<SysDept> getChildList(List<SysDept> list, SysDept t) { |
| | | List<SysDept> tlist = new ArrayList<SysDept>(); |
| | | for (SysDept n : list) { |
| | | if (Validator.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) { |
| | | if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) { |
| | | tlist.add(n); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | |
| | | @Override |
| | | public TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData) { |
| | | LambdaQueryWrapper<SysDictData> lqw = new LambdaQueryWrapper<SysDictData>() |
| | | .eq(StrUtil.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType()) |
| | | .like(StrUtil.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel()) |
| | | .eq(StrUtil.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus()) |
| | | .eq(StringUtils.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType()) |
| | | .like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel()) |
| | | .eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus()) |
| | | .orderByAsc(SysDictData::getDictSort); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); |
| | | } |
| | |
| | | @Override |
| | | public List<SysDictData> selectDictDataList(SysDictData dictData) { |
| | | return list(new LambdaQueryWrapper<SysDictData>() |
| | | .eq(StrUtil.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType()) |
| | | .like(StrUtil.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel()) |
| | | .eq(StrUtil.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus()) |
| | | .eq(StringUtils.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType()) |
| | | .like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel()) |
| | | .eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus()) |
| | | .orderByAsc(SysDictData::getDictSort)); |
| | | } |
| | | |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | |
| | | import com.ruoyi.common.core.domain.entity.SysDictType; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.DictUtils; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.system.mapper.SysDictDataMapper; |
| | |
| | | public TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType) { |
| | | Map<String, Object> params = dictType.getParams(); |
| | | LambdaQueryWrapper<SysDictType> lqw = new LambdaQueryWrapper<SysDictType>() |
| | | .like(StrUtil.isNotBlank(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName()) |
| | | .eq(StrUtil.isNotBlank(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus()) |
| | | .like(StrUtil.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType()) |
| | | .apply(Validator.isNotEmpty(params.get("beginTime")), |
| | | .like(StringUtils.isNotBlank(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName()) |
| | | .eq(StringUtils.isNotBlank(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus()) |
| | | .like(StringUtils.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(Validator.isNotEmpty(params.get("endTime")), |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime")); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); |
| | |
| | | public List<SysDictType> selectDictTypeList(SysDictType dictType) { |
| | | Map<String, Object> params = dictType.getParams(); |
| | | return list(new LambdaQueryWrapper<SysDictType>() |
| | | .like(StrUtil.isNotBlank(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName()) |
| | | .eq(StrUtil.isNotBlank(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus()) |
| | | .like(StrUtil.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType()) |
| | | .apply(Validator.isNotEmpty(params.get("beginTime")), |
| | | .like(StringUtils.isNotBlank(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName()) |
| | | .eq(StringUtils.isNotBlank(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus()) |
| | | .like(StringUtils.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(Validator.isNotEmpty(params.get("endTime")), |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime"))); |
| | | } |
| | |
| | | SysDictType dictType = selectDictTypeById(dictId); |
| | | if (dictDataMapper.selectCount(new LambdaQueryWrapper<SysDictData>() |
| | | .eq(SysDictData::getDictType, dictType.getDictType())) > 0) { |
| | | throw new CustomException(String.format("%1$så·²åé
,ä¸è½å é¤", dictType.getDictName())); |
| | | throw new ServiceException(String.format("%1$så·²åé
,ä¸è½å é¤", dictType.getDictName())); |
| | | } |
| | | DictUtils.removeDictCache(dictType.getDictType()); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public String checkDictTypeUnique(SysDictType dict) { |
| | | Long dictId = Validator.isNull(dict.getDictId()) ? -1L : dict.getDictId(); |
| | | Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId(); |
| | | SysDictType dictType = getOne(new LambdaQueryWrapper<SysDictType>() |
| | | .eq(SysDictType::getDictType, dict.getDictType()) |
| | | .last("limit 1")); |
| | | if (Validator.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) { |
| | | if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.SysLogininfor; |
| | | import com.ruoyi.system.mapper.SysLogininforMapper; |
| | | import com.ruoyi.system.service.ISysLogininforService; |
| | |
| | | public TableDataInfo<SysLogininfor> selectPageLogininforList(SysLogininfor logininfor) { |
| | | Map<String, Object> params = logininfor.getParams(); |
| | | LambdaQueryWrapper<SysLogininfor> lqw = new LambdaQueryWrapper<SysLogininfor>() |
| | | .like(StrUtil.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr()) |
| | | .eq(StrUtil.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus()) |
| | | .like(StrUtil.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName()) |
| | | .apply(Validator.isNotEmpty(params.get("beginTime")), |
| | | .like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr()) |
| | | .eq(StringUtils.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus()) |
| | | .like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(login_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(Validator.isNotEmpty(params.get("endTime")), |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(login_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime")); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage("info_id","desc"), lqw)); |
| | |
| | | public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor) { |
| | | Map<String, Object> params = logininfor.getParams(); |
| | | return list(new LambdaQueryWrapper<SysLogininfor>() |
| | | .like(StrUtil.isNotBlank(logininfor.getIpaddr()),SysLogininfor::getIpaddr,logininfor.getIpaddr()) |
| | | .eq(StrUtil.isNotBlank(logininfor.getStatus()),SysLogininfor::getStatus,logininfor.getStatus()) |
| | | .like(StrUtil.isNotBlank(logininfor.getUserName()),SysLogininfor::getUserName,logininfor.getUserName()) |
| | | .apply(Validator.isNotEmpty(params.get("beginTime")), |
| | | .like(StringUtils.isNotBlank(logininfor.getIpaddr()),SysLogininfor::getIpaddr,logininfor.getIpaddr()) |
| | | .eq(StringUtils.isNotBlank(logininfor.getStatus()),SysLogininfor::getStatus,logininfor.getStatus()) |
| | | .like(StringUtils.isNotBlank(logininfor.getUserName()),SysLogininfor::getUserName,logininfor.getUserName()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(login_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(Validator.isNotEmpty(params.get("endTime")), |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(login_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime")) |
| | | .orderByDesc(SysLogininfor::getInfoId)); |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.SysRoleMenu; |
| | | import com.ruoyi.system.domain.vo.MetaVo; |
| | | import com.ruoyi.system.domain.vo.RouterVo; |
| | |
| | | import com.ruoyi.system.mapper.SysRoleMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMenuMapper; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | // 管çåæ¾ç¤ºææèåä¿¡æ¯ |
| | | if (SysUser.isAdmin(userId)) { |
| | | menuList = list(new LambdaQueryWrapper<SysMenu>() |
| | | .like(StrUtil.isNotBlank(menu.getMenuName()),SysMenu::getMenuName,menu.getMenuName()) |
| | | .eq(StrUtil.isNotBlank(menu.getVisible()),SysMenu::getVisible,menu.getVisible()) |
| | | .eq(StrUtil.isNotBlank(menu.getStatus()),SysMenu::getStatus,menu.getStatus()) |
| | | .like(StringUtils.isNotBlank(menu.getMenuName()),SysMenu::getMenuName,menu.getMenuName()) |
| | | .eq(StringUtils.isNotBlank(menu.getVisible()),SysMenu::getVisible,menu.getVisible()) |
| | | .eq(StringUtils.isNotBlank(menu.getStatus()),SysMenu::getStatus,menu.getStatus()) |
| | | .orderByAsc(SysMenu::getParentId) |
| | | .orderByAsc(SysMenu::getOrderNum)); |
| | | } else { |
| | |
| | | List<String> perms = baseMapper.selectMenuPermsByUserId(userId); |
| | | Set<String> permsSet = new HashSet<>(); |
| | | for (String perm : perms) { |
| | | if (Validator.isNotEmpty(perm)) { |
| | | if (StringUtils.isNotEmpty(perm)) { |
| | | permsSet.addAll(Arrays.asList(perm.trim().split(","))); |
| | | } |
| | | } |
| | |
| | | router.setName(getRouteName(menu)); |
| | | router.setPath(getRouterPath(menu)); |
| | | router.setComponent(getComponent(menu)); |
| | | router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StrUtil.equals("1", menu.getIsCache()), menu.getPath())); |
| | | router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath())); |
| | | List<SysMenu> cMenus = menu.getChildren(); |
| | | if (!cMenus.isEmpty() && UserConstants.TYPE_DIR.equals(menu.getMenuType())) { |
| | | router.setAlwaysShow(true); |
| | |
| | | RouterVo children = new RouterVo(); |
| | | children.setPath(menu.getPath()); |
| | | children.setComponent(menu.getComponent()); |
| | | children.setName(StrUtil.upperFirst(menu.getPath())); |
| | | children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StrUtil.equals("1", menu.getIsCache()), menu.getPath())); |
| | | children.setName(StringUtils.capitalize(menu.getPath())); |
| | | children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath())); |
| | | childrenList.add(children); |
| | | router.setChildren(childrenList); |
| | | } else if (menu.getParentId().intValue() == 0 && isInnerLink(menu)) { |
| | |
| | | String routerPath = StringUtils.replaceEach(menu.getPath(), new String[] { Constants.HTTP, Constants.HTTPS }, new String[] { "", "" }); |
| | | children.setPath(routerPath); |
| | | children.setComponent(UserConstants.INNER_LINK); |
| | | children.setName(StrUtil.upperFirst(routerPath)); |
| | | children.setName(StringUtils.capitalize(routerPath)); |
| | | children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.getPath())); |
| | | childrenList.add(children); |
| | | router.setChildren(childrenList); |
| | |
| | | */ |
| | | @Override |
| | | public String checkMenuNameUnique(SysMenu menu) { |
| | | Long menuId = Validator.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); |
| | | Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); |
| | | SysMenu info = getOne(new LambdaQueryWrapper<SysMenu>() |
| | | .eq(SysMenu::getMenuName,menu.getMenuName()) |
| | | .eq(SysMenu::getParentId,menu.getParentId()) |
| | | .last("limit 1")); |
| | | if (Validator.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) { |
| | | if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | * @return è·¯ç±åç§° |
| | | */ |
| | | public String getRouteName(SysMenu menu) { |
| | | String routerName = StrUtil.upperFirst(menu.getPath()); |
| | | String routerName = StringUtils.capitalize(menu.getPath()); |
| | | // éå¤é¾å¹¶ä¸æ¯ä¸çº§ç®å½ï¼ç±»å为ç®å½ï¼ |
| | | if (isMenuFrame(menu)) { |
| | | routerName = StrUtil.EMPTY; |
| | | routerName = StringUtils.EMPTY; |
| | | } |
| | | return routerName; |
| | | } |
| | |
| | | */ |
| | | public String getComponent(SysMenu menu) { |
| | | String component = UserConstants.LAYOUT; |
| | | if (StrUtil.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu)) { |
| | | if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu)) { |
| | | component = menu.getComponent(); |
| | | } else if (StrUtil.isEmpty(menu.getComponent()) && menu.getParentId().intValue() != 0 && isInnerLink(menu)) { |
| | | } else if (StringUtils.isEmpty(menu.getComponent()) && menu.getParentId().intValue() != 0 && isInnerLink(menu)) { |
| | | component = UserConstants.INNER_LINK; |
| | | } else if (StrUtil.isEmpty(menu.getComponent()) && isParentView(menu)) { |
| | | } else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu)) { |
| | | component = UserConstants.PARENT_VIEW; |
| | | } |
| | | return component; |
| | |
| | | * @return ç»æ |
| | | */ |
| | | public boolean isInnerLink(SysMenu menu) { |
| | | return menu.getIsFrame().equals(UserConstants.NO_FRAME) && Validator.isUrl(menu.getPath()); |
| | | return menu.getIsFrame().equals(UserConstants.NO_FRAME) && StringUtils.ishttp(menu.getPath()); |
| | | } |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | |
| | | @Override |
| | | public TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice) { |
| | | LambdaQueryWrapper<SysNotice> lqw = new LambdaQueryWrapper<SysNotice>() |
| | | .like(StrUtil.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle()) |
| | | .eq(StrUtil.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType()) |
| | | .like(StrUtil.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy()); |
| | | .like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle()) |
| | | .eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType()) |
| | | .like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy()); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage(),lqw)); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public List<SysNotice> selectNoticeList(SysNotice notice) { |
| | | return list(new LambdaQueryWrapper<SysNotice>() |
| | | .like(StrUtil.isNotBlank(notice.getNoticeTitle()),SysNotice::getNoticeTitle,notice.getNoticeTitle()) |
| | | .eq(StrUtil.isNotBlank(notice.getNoticeType()),SysNotice::getNoticeType,notice.getNoticeType()) |
| | | .like(StrUtil.isNotBlank(notice.getCreateBy()),SysNotice::getCreateBy,notice.getCreateBy())); |
| | | .like(StringUtils.isNotBlank(notice.getNoticeTitle()),SysNotice::getNoticeTitle,notice.getNoticeTitle()) |
| | | .eq(StringUtils.isNotBlank(notice.getNoticeType()),SysNotice::getNoticeType,notice.getNoticeType()) |
| | | .like(StringUtils.isNotBlank(notice.getCreateBy()),SysNotice::getCreateBy,notice.getCreateBy())); |
| | | } |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | |
| | | public TableDataInfo<SysOperLog> selectPageOperLogList(SysOperLog operLog) { |
| | | Map<String, Object> params = operLog.getParams(); |
| | | LambdaQueryWrapper<SysOperLog> lqw = new LambdaQueryWrapper<SysOperLog>() |
| | | .like(StrUtil.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle()) |
| | | .like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle()) |
| | | .eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0, |
| | | SysOperLog::getBusinessType, operLog.getBusinessType()) |
| | | .func(f -> { |
| | |
| | | f.in(SysOperLog::getBusinessType, Arrays.asList(operLog.getBusinessTypes())); |
| | | } |
| | | }) |
| | | .eq(operLog.getStatus() != null && operLog.getStatus() > 0, |
| | | .eq(operLog.getStatus() != null, |
| | | SysOperLog::getStatus, operLog.getStatus()) |
| | | .like(StrUtil.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName()) |
| | | .apply(Validator.isNotEmpty(params.get("beginTime")), |
| | | .like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(oper_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(Validator.isNotEmpty(params.get("endTime")), |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(oper_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime")); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage("oper_id","desc"), lqw)); |
| | |
| | | public List<SysOperLog> selectOperLogList(SysOperLog operLog) { |
| | | Map<String, Object> params = operLog.getParams(); |
| | | return list(new LambdaQueryWrapper<SysOperLog>() |
| | | .like(StrUtil.isNotBlank(operLog.getTitle()),SysOperLog::getTitle,operLog.getTitle()) |
| | | .like(StringUtils.isNotBlank(operLog.getTitle()),SysOperLog::getTitle,operLog.getTitle()) |
| | | .eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0, |
| | | SysOperLog::getBusinessType,operLog.getBusinessType()) |
| | | .func(f -> { |
| | |
| | | }) |
| | | .eq(operLog.getStatus() != null && operLog.getStatus() > 0, |
| | | SysOperLog::getStatus,operLog.getStatus()) |
| | | .like(StrUtil.isNotBlank(operLog.getOperName()),SysOperLog::getOperName,operLog.getOperName()) |
| | | .apply(Validator.isNotEmpty(params.get("beginTime")), |
| | | .like(StringUtils.isNotBlank(operLog.getOperName()),SysOperLog::getOperName,operLog.getOperName()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(oper_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(Validator.isNotEmpty(params.get("endTime")), |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(oper_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime")) |
| | | .orderByDesc(SysOperLog::getOperId)); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.PagePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.oss.constant.CloudConstant; |
| | | import com.ruoyi.system.domain.SysOssConfig; |
| | | import com.ruoyi.system.domain.bo.SysOssConfigBo; |
| | | import com.ruoyi.system.domain.vo.SysOssConfigVo; |
| | | import com.ruoyi.system.mapper.SysOssConfigMapper; |
| | | import com.ruoyi.system.service.ISysOssConfigService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * äºåå¨é
ç½®Serviceä¸å¡å±å¤ç |
| | | * |
| | | * @author Lion Li |
| | | * @author å¤èçé¨ |
| | | * @date 2021-08-13 |
| | | */ |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @Service |
| | | public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper, SysOssConfig, SysOssConfigVo> implements ISysOssConfigService { |
| | | |
| | | private final RedisCache redisCache; |
| | | |
| | | /** |
| | | * 项ç®å¯å¨æ¶ï¼åå§ååæ°å°ç¼åï¼å è½½é
置类 |
| | | */ |
| | | @PostConstruct |
| | | public void init() { |
| | | List<SysOssConfig> list = list(); |
| | | for (SysOssConfig config : list) { |
| | | String configKey = config.getConfigKey(); |
| | | if ("0".equals(config.getStatus())) { |
| | | redisCache.setCacheObject(CloudConstant.CACHE_CONFIG_KEY, configKey); |
| | | } |
| | | setConfigCache(true, config); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public SysOssConfigVo queryById(Integer ossConfigId){ |
| | | return getVoById(ossConfigId); |
| | | } |
| | | |
| | | @Override |
| | | public TableDataInfo<SysOssConfigVo> queryPageList(SysOssConfigBo bo) { |
| | | PagePlus<SysOssConfig, SysOssConfigVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo)); |
| | | return PageUtils.buildDataInfo(result); |
| | | } |
| | | |
| | | |
| | | private LambdaQueryWrapper<SysOssConfig> buildQueryWrapper(SysOssConfigBo bo) { |
| | | LambdaQueryWrapper<SysOssConfig> lqw = Wrappers.lambdaQuery(); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getConfigKey()), SysOssConfig::getConfigKey, bo.getConfigKey()); |
| | | lqw.like(StringUtils.isNotBlank(bo.getBucketName()), SysOssConfig::getBucketName, bo.getBucketName()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysOssConfig::getStatus, bo.getStatus()); |
| | | return lqw; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean insertByBo(SysOssConfigBo bo) { |
| | | SysOssConfig config = BeanUtil.toBean(bo, SysOssConfig.class); |
| | | validEntityBeforeSave(config); |
| | | return setConfigCache(save(config), config); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean updateByBo(SysOssConfigBo bo) { |
| | | SysOssConfig config = BeanUtil.toBean(bo, SysOssConfig.class); |
| | | validEntityBeforeSave(config); |
| | | return setConfigCache(updateById(config), config); |
| | | } |
| | | |
| | | /** |
| | | * ä¿ååçæ°æ®æ ¡éª |
| | | */ |
| | | private void validEntityBeforeSave(SysOssConfig entity){ |
| | | if (StringUtils.isNotEmpty(entity.getConfigKey()) |
| | | && UserConstants.NOT_UNIQUE.equals(checkConfigKeyUnique(entity))) { |
| | | throw new ServiceException("æä½é
ç½®'" + entity.getConfigKey() + "'失败, é
ç½®keyå·²åå¨!"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
| | | if(isValid) { |
| | | if (CollUtil.containsAny(ids, CloudConstant.SYSTEM_DATA_IDS)) { |
| | | throw new ServiceException("ç³»ç»å
ç½®, ä¸å¯å é¤!"); |
| | | } |
| | | } |
| | | boolean flag = removeByIds(ids); |
| | | if (flag) { |
| | | for (Long configId : ids) { |
| | | SysOssConfig config = getById(configId); |
| | | redisCache.deleteObject(getCacheKey(config.getConfigKey())); |
| | | } |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | /** |
| | | * 夿configKeyæ¯å¦å¯ä¸ |
| | | */ |
| | | private String checkConfigKeyUnique(SysOssConfig sysOssConfig) { |
| | | long ossConfigId = StringUtils.isNull(sysOssConfig.getOssConfigId()) ? -1L : sysOssConfig.getOssConfigId(); |
| | | SysOssConfig info = getOne(new LambdaQueryWrapper<SysOssConfig>() |
| | | .select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey) |
| | | .eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey())); |
| | | if (StringUtils.isNotNull(info) && info.getOssConfigId() != ossConfigId) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | | } |
| | | |
| | | /** |
| | | * å¯ç¨ç¦ç¨ç¶æ |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int updateOssConfigStatus(SysOssConfigBo bo) { |
| | | SysOssConfig sysOssConfig = BeanUtil.toBean(bo, SysOssConfig.class); |
| | | int row = baseMapper.update(null, new LambdaUpdateWrapper<SysOssConfig>() |
| | | .set(SysOssConfig::getStatus, "1")); |
| | | row += baseMapper.updateById(sysOssConfig); |
| | | if (row > 0) { |
| | | redisCache.setCacheObject(CloudConstant.CACHE_CONFIG_KEY, sysOssConfig.getConfigKey()); |
| | | } |
| | | return row; |
| | | } |
| | | |
| | | /** |
| | | * 设置cache key |
| | | * |
| | | * @param configKey åæ°é® |
| | | * @return ç¼åé®key |
| | | */ |
| | | private String getCacheKey(String configKey) { |
| | | return CloudConstant.SYS_OSS_KEY + configKey; |
| | | } |
| | | |
| | | /** |
| | | * 妿æä½æå åæ´æ°ç¼å |
| | | * @param flag æä½ç¶æ |
| | | * @param config é
ç½® |
| | | * @return è¿åæä½ç¶æ |
| | | */ |
| | | private boolean setConfigCache(boolean flag, SysOssConfig config) { |
| | | if (flag) { |
| | | redisCache.setCacheObject( |
| | | getCacheKey(config.getConfigKey()), |
| | | JsonUtils.toJsonString(config)); |
| | | } |
| | | return flag; |
| | | } |
| | | } |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/system/service/impl/SysOssServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.PagePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.oss.entity.UploadResult; |
| | | import com.ruoyi.oss.factory.OssFactory; |
| | | import com.ruoyi.oss.service.ICloudStorageService; |
| | | import com.ruoyi.system.domain.bo.SysOssBo; |
| | | import com.ruoyi.oss.service.ICloudStorageStrategy; |
| | | import com.ruoyi.system.domain.SysOss; |
| | | import com.ruoyi.system.domain.bo.SysOssBo; |
| | | import com.ruoyi.system.domain.vo.SysOssVo; |
| | | import com.ruoyi.system.mapper.SysOssMapper; |
| | | import com.ruoyi.system.service.ISysOssService; |
| | | import com.ruoyi.system.domain.vo.SysOssVo; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | |
| | | private LambdaQueryWrapper<SysOss> buildQueryWrapper(SysOssBo bo) { |
| | | Map<String, Object> params = bo.getParams(); |
| | | LambdaQueryWrapper<SysOss> lqw = Wrappers.lambdaQuery(); |
| | | lqw.like(StrUtil.isNotBlank(bo.getFileName()), SysOss::getFileName, bo.getFileName()); |
| | | lqw.like(StrUtil.isNotBlank(bo.getOriginalName()), SysOss::getOriginalName, bo.getOriginalName()); |
| | | lqw.eq(StrUtil.isNotBlank(bo.getFileSuffix()), SysOss::getFileSuffix, bo.getFileSuffix()); |
| | | lqw.eq(StrUtil.isNotBlank(bo.getUrl()), SysOss::getUrl, bo.getUrl()); |
| | | lqw.like(StringUtils.isNotBlank(bo.getFileName()), SysOss::getFileName, bo.getFileName()); |
| | | lqw.like(StringUtils.isNotBlank(bo.getOriginalName()), SysOss::getOriginalName, bo.getOriginalName()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getFileSuffix()), SysOss::getFileSuffix, bo.getFileSuffix()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getUrl()), SysOss::getUrl, bo.getUrl()); |
| | | lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null, |
| | | SysOss::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime")); |
| | | lqw.eq(StrUtil.isNotBlank(bo.getCreateBy()), SysOss::getCreateBy, bo.getCreateBy()); |
| | | lqw.eq(StrUtil.isNotBlank(bo.getService()), SysOss::getService, bo.getService()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getCreateBy()), SysOss::getCreateBy, bo.getCreateBy()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getService()), SysOss::getService, bo.getService()); |
| | | return lqw; |
| | | } |
| | | |
| | | @Override |
| | | public SysOss upload(MultipartFile file) { |
| | | String originalfileName = file.getOriginalFilename(); |
| | | String suffix = StrUtil.sub(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length()); |
| | | ICloudStorageService storage = OssFactory.instance(); |
| | | String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length()); |
| | | ICloudStorageStrategy storage = OssFactory.instance(); |
| | | UploadResult uploadResult; |
| | | try { |
| | | uploadResult = storage.uploadSuffix(file.getBytes(), suffix, file.getContentType()); |
| | | } catch (IOException e) { |
| | | throw new CustomException("æä»¶è¯»åå¼å¸¸!!!", e); |
| | | throw new ServiceException(e.getMessage()); |
| | | } |
| | | // ä¿åæä»¶ä¿¡æ¯ |
| | | SysOss oss = new SysOss() |
| | |
| | | } |
| | | List<SysOss> list = listByIds(ids); |
| | | for (SysOss sysOss : list) { |
| | | ICloudStorageService storage = OssFactory.instance(sysOss.getService()); |
| | | ICloudStorageStrategy storage = OssFactory.instance(sysOss.getService()); |
| | | storage.delete(sysOss.getUrl()); |
| | | } |
| | | return removeByIds(ids); |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.SysPost; |
| | | import com.ruoyi.system.domain.SysUserPost; |
| | | import com.ruoyi.system.mapper.SysPostMapper; |
| | |
| | | @Override |
| | | public TableDataInfo<SysPost> selectPagePostList(SysPost post) { |
| | | LambdaQueryWrapper<SysPost> lqw = new LambdaQueryWrapper<SysPost>() |
| | | .like(StrUtil.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode()) |
| | | .eq(StrUtil.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus()) |
| | | .like(StrUtil.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName()); |
| | | .like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode()) |
| | | .eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus()) |
| | | .like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName()); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage(),lqw)); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public List<SysPost> selectPostList(SysPost post) { |
| | | return list(new LambdaQueryWrapper<SysPost>() |
| | | .like(StrUtil.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode()) |
| | | .eq(StrUtil.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus()) |
| | | .like(StrUtil.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName())); |
| | | .like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode()) |
| | | .eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus()) |
| | | .like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName())); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public String checkPostNameUnique(SysPost post) { |
| | | Long postId = Validator.isNull(post.getPostId()) ? -1L : post.getPostId(); |
| | | Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); |
| | | SysPost info = getOne(new LambdaQueryWrapper<SysPost>() |
| | | .eq(SysPost::getPostName, post.getPostName()).last("limit 1")); |
| | | if (Validator.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) { |
| | | if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | */ |
| | | @Override |
| | | public String checkPostCodeUnique(SysPost post) { |
| | | Long postId = Validator.isNull(post.getPostId()) ? -1L : post.getPostId(); |
| | | Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); |
| | | SysPost info = getOne(new LambdaQueryWrapper<SysPost>() |
| | | .eq(SysPost::getPostCode, post.getPostCode()).last("limit 1")); |
| | | if (Validator.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) { |
| | | if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | for (Long postId : postIds) { |
| | | SysPost post = selectPostById(postId); |
| | | if (countUserPostById(postId) > 0) { |
| | | throw new CustomException(String.format("%1$så·²åé
,ä¸è½å é¤", post.getPostName())); |
| | | throw new ServiceException(String.format("%1$så·²åé
,ä¸è½å é¤", post.getPostName())); |
| | | } |
| | | } |
| | | return baseMapper.deleteBatchIds(Arrays.asList(postIds)); |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.system.domain.SysRoleDept; |
| | | import com.ruoyi.system.domain.SysRoleMenu; |
| | |
| | | List<SysRole> perms = baseMapper.selectRolePermissionByUserId(userId); |
| | | Set<String> permsSet = new HashSet<>(); |
| | | for (SysRole perm : perms) { |
| | | if (Validator.isNotNull(perm)) { |
| | | if (StringUtils.isNotNull(perm)) { |
| | | permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); |
| | | } |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public String checkRoleNameUnique(SysRole role) { |
| | | Long roleId = Validator.isNull(role.getRoleId()) ? -1L : role.getRoleId(); |
| | | Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); |
| | | SysRole info = getOne(new LambdaQueryWrapper<SysRole>() |
| | | .eq(SysRole::getRoleName, role.getRoleName()).last("limit 1")); |
| | | if (Validator.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { |
| | | if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | */ |
| | | @Override |
| | | public String checkRoleKeyUnique(SysRole role) { |
| | | Long roleId = Validator.isNull(role.getRoleId()) ? -1L : role.getRoleId(); |
| | | Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); |
| | | SysRole info = getOne(new LambdaQueryWrapper<SysRole>() |
| | | .eq(SysRole::getRoleKey, role.getRoleKey()).last("limit 1")); |
| | | if (Validator.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { |
| | | if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | */ |
| | | @Override |
| | | public void checkRoleAllowed(SysRole role) { |
| | | if (Validator.isNotNull(role.getRoleId()) && role.isAdmin()) { |
| | | throw new CustomException("ä¸å
许æä½è¶
级管çåè§è²"); |
| | | if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) { |
| | | throw new ServiceException("ä¸å
许æä½è¶
级管çåè§è²"); |
| | | } |
| | | } |
| | | |
| | |
| | | checkRoleAllowed(new SysRole(roleId)); |
| | | SysRole role = selectRoleById(roleId); |
| | | if (countUserRoleByRoleId(roleId) > 0) { |
| | | throw new CustomException(String.format("%1$så·²åé
,ä¸è½å é¤", role.getRoleName())); |
| | | throw new ServiceException(String.format("%1$så·²åé
,ä¸è½å é¤", role.getRoleName())); |
| | | } |
| | | } |
| | | List<Long> ids = Arrays.asList(roleIds); |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.SysUserOnline; |
| | | import com.ruoyi.system.service.ISysUserOnlineService; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | */ |
| | | @Override |
| | | public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user) { |
| | | if (StrUtil.equals(ipaddr, user.getIpaddr())) { |
| | | if (StringUtils.equals(ipaddr, user.getIpaddr())) { |
| | | return loginUserToUserOnline(user); |
| | | } |
| | | return null; |
| | |
| | | */ |
| | | @Override |
| | | public SysUserOnline selectOnlineByUserName(String userName, LoginUser user) { |
| | | if (StrUtil.equals(userName, user.getUsername())) { |
| | | if (StringUtils.equals(userName, user.getUsername())) { |
| | | return loginUserToUserOnline(user); |
| | | } |
| | | return null; |
| | |
| | | */ |
| | | @Override |
| | | public SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user) { |
| | | if (StrUtil.equals(ipaddr, user.getIpaddr()) && StrUtil.equals(userName, user.getUsername())) { |
| | | if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) { |
| | | return loginUserToUserOnline(user); |
| | | } |
| | | return null; |
| | |
| | | */ |
| | | @Override |
| | | public SysUserOnline loginUserToUserOnline(LoginUser user) { |
| | | if (Validator.isNull(user) || Validator.isNull(user.getUser())) { |
| | | if (StringUtils.isNull(user) || StringUtils.isNull(user.getUser())) { |
| | | return null; |
| | | } |
| | | SysUserOnline sysUserOnline = new SysUserOnline(); |
| | |
| | | sysUserOnline.setBrowser(user.getBrowser()); |
| | | sysUserOnline.setOs(user.getOs()); |
| | | sysUserOnline.setLoginTime(user.getLoginTime()); |
| | | if (Validator.isNotNull(user.getUser().getDept())) { |
| | | if (StringUtils.isNotNull(user.getUser().getDept())) { |
| | | sysUserOnline.setDeptName(user.getUser().getDept().getDeptName()); |
| | | } |
| | | return sysUserOnline; |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.SysPost; |
| | | import com.ruoyi.system.domain.SysUserPost; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | |
| | | for (SysRole role : list) { |
| | | idsStr.append(role.getRoleName()).append(","); |
| | | } |
| | | if (Validator.isNotEmpty(idsStr.toString())) { |
| | | if (StringUtils.isNotEmpty(idsStr.toString())) { |
| | | return idsStr.substring(0, idsStr.length() - 1); |
| | | } |
| | | return idsStr.toString(); |
| | |
| | | for (SysPost post : list) { |
| | | idsStr.append(post.getPostName()).append(","); |
| | | } |
| | | if (Validator.isNotEmpty(idsStr.toString())) { |
| | | if (StringUtils.isNotEmpty(idsStr.toString())) { |
| | | return idsStr.substring(0, idsStr.length() - 1); |
| | | } |
| | | return idsStr.toString(); |
| | |
| | | */ |
| | | @Override |
| | | public String checkPhoneUnique(SysUser user) { |
| | | Long userId = Validator.isNull(user.getUserId()) ? -1L : user.getUserId(); |
| | | Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); |
| | | SysUser info = getOne(new LambdaQueryWrapper<SysUser>() |
| | | .select(SysUser::getUserId, SysUser::getPhonenumber) |
| | | .eq(SysUser::getPhonenumber, user.getPhonenumber()).last("limit 1")); |
| | | if (Validator.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { |
| | | if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | */ |
| | | @Override |
| | | public String checkEmailUnique(SysUser user) { |
| | | Long userId = Validator.isNull(user.getUserId()) ? -1L : user.getUserId(); |
| | | Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); |
| | | SysUser info = getOne(new LambdaQueryWrapper<SysUser>() |
| | | .select(SysUser::getUserId, SysUser::getEmail) |
| | | .eq(SysUser::getEmail, user.getEmail()).last("limit 1")); |
| | | if (Validator.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { |
| | | if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | */ |
| | | @Override |
| | | public void checkUserAllowed(SysUser user) { |
| | | if (Validator.isNotNull(user.getUserId()) && user.isAdmin()) { |
| | | throw new CustomException("ä¸å
许æä½è¶
级管çåç¨æ·"); |
| | | if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) { |
| | | throw new ServiceException("ä¸å
许æä½è¶
级管çåç¨æ·"); |
| | | } |
| | | } |
| | | |
| | |
| | | // æ°å¢ç¨æ·ä¸è§è²ç®¡ç |
| | | insertUserRole(user); |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | | * 注åç¨æ·ä¿¡æ¯ |
| | | * |
| | | * @param user ç¨æ·ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public boolean registerUser(SysUser user) { |
| | | return baseMapper.insert(user) > 0; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public void insertUserRole(SysUser user) { |
| | | Long[] roles = user.getRoleIds(); |
| | | if (Validator.isNotNull(roles)) { |
| | | if (StringUtils.isNotNull(roles)) { |
| | | // æ°å¢ç¨æ·ä¸è§è²ç®¡ç |
| | | List<SysUserRole> list = new ArrayList<SysUserRole>(); |
| | | for (Long roleId : roles) { |
| | |
| | | */ |
| | | public void insertUserPost(SysUser user) { |
| | | Long[] posts = user.getPostIds(); |
| | | if (Validator.isNotNull(posts)) { |
| | | if (StringUtils.isNotNull(posts)) { |
| | | // æ°å¢ç¨æ·ä¸å²ä½ç®¡ç |
| | | List<SysUserPost> list = new ArrayList<SysUserPost>(); |
| | | for (Long postId : posts) { |
| | |
| | | * @param roleIds è§è²ç» |
| | | */ |
| | | public void insertUserRole(Long userId, Long[] roleIds) { |
| | | if (Validator.isNotNull(roleIds)) { |
| | | if (StringUtils.isNotNull(roleIds)) { |
| | | // æ°å¢ç¨æ·ä¸è§è²ç®¡ç |
| | | List<SysUserRole> list = new ArrayList<SysUserRole>(); |
| | | for (Long roleId : roleIds) { |
| | |
| | | */ |
| | | @Override |
| | | public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) { |
| | | if (Validator.isNull(userList) || userList.size() == 0) { |
| | | throw new CustomException("导å
¥ç¨æ·æ°æ®ä¸è½ä¸ºç©ºï¼"); |
| | | if (StringUtils.isNull(userList) || userList.size() == 0) { |
| | | throw new ServiceException("导å
¥ç¨æ·æ°æ®ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | int successNum = 0; |
| | | int failureNum = 0; |
| | |
| | | try { |
| | | // éªè¯æ¯å¦åå¨è¿ä¸ªç¨æ· |
| | | SysUser u = baseMapper.selectUserByUserName(user.getUserName()); |
| | | if (Validator.isNull(u)) { |
| | | if (StringUtils.isNull(u)) { |
| | | user.setPassword(SecurityUtils.encryptPassword(password)); |
| | | user.setCreateBy(operName); |
| | | this.insertUser(user); |
| | |
| | | } |
| | | if (failureNum > 0) { |
| | | failureMsg.insert(0, "徿±æï¼å¯¼å
¥å¤±è´¥ï¼å
± " + failureNum + " æ¡æ°æ®æ ¼å¼ä¸æ£ç¡®ï¼é误å¦ä¸ï¼"); |
| | | throw new CustomException(failureMsg.toString()); |
| | | throw new ServiceException(failureMsg.toString()); |
| | | } else { |
| | | successMsg.insert(0, "æåæ¨ï¼æ°æ®å·²å
¨é¨å¯¼å
¥æåï¼å
± " + successNum + " æ¡ï¼æ°æ®å¦ä¸ï¼"); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.system.mapper.SysOssConfigMapper"> |
| | | |
| | | <resultMap type="com.ruoyi.system.domain.SysOssConfig" id="SysOssConfigResult"> |
| | | <result property="ossConfigId" column="oss_config_id"/> |
| | | <result property="configKey" column="config_key"/> |
| | | <result property="accessKey" column="access_key"/> |
| | | <result property="secretKey" column="secret_key"/> |
| | | <result property="bucketName" column="bucket_name"/> |
| | | <result property="prefix" column="prefix"/> |
| | | <result property="endpoint" column="endpoint"/> |
| | | <result property="isHttps" column="is_https"/> |
| | | <result property="region" column="region"/> |
| | | <result property="status" column="status"/> |
| | | <result property="ext1" column="ext1"/> |
| | | <result property="createBy" column="create_by"/> |
| | | <result property="createTime" column="create_time"/> |
| | | <result property="updateBy" column="update_by"/> |
| | | <result property="updateTime" column="update_time"/> |
| | | <result property="remark" column="remark"/> |
| | | </resultMap> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | @echo off |
| | | echo. |
| | | echo [ä¿¡æ¯] ä½¿ç¨ Vue è¿è¡ Web å·¥ç¨ã |
| | | echo [��Ϣ] ʹ�� Vue CLI �������� Web ���̡� |
| | | echo. |
| | | |
| | | %~d0 |
| | |
| | | { |
| | | "name": "ruoyi-vue-plus", |
| | | "version": "2.6.0", |
| | | "version": "3.0.0", |
| | | "description": "RuoYi-Vue-Plusåå°ç®¡çç³»ç»", |
| | | "author": "LionLi", |
| | | "license": "MIT", |
| | |
| | | "clipboard": "2.0.6", |
| | | "core-js": "3.8.1", |
| | | "echarts": "4.9.0", |
| | | "element-ui": "2.15.3", |
| | | "element-ui": "2.15.5", |
| | | "file-saver": "2.0.4", |
| | | "fuse.js": "6.4.3", |
| | | "highlight.js": "9.18.5", |
| | |
| | | }) |
| | | } |
| | | |
| | | // å¯¼åºæµè¯å表 |
| | | export function exportDemo(query) { |
| | | return request({ |
| | | url: '/demo/demo/export', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | |
| | | method: 'delete' |
| | | }) |
| | | } |
| | | |
| | | // å¯¼åºæµè¯æ 表 |
| | | export function exportTree(query) { |
| | | return request({ |
| | | url: '/demo/tree/export', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | // æ³¨åæ¹æ³ |
| | | export function register(data) { |
| | | return request({ |
| | | url: '/register', |
| | | headers: { |
| | | isToken: false |
| | | }, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | } |
| | | |
| | | // è·åç¨æ·è¯¦ç»ä¿¡æ¯ |
| | | export function getInfo() { |
| | | return request({ |
| | |
| | | method: 'delete' |
| | | }) |
| | | } |
| | | |
| | | // 导åºè°åº¦æ¥å¿ |
| | | export function exportJobLog(query) { |
| | | return request({ |
| | | url: '/monitor/jobLog/export', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | |
| | | method: 'delete' |
| | | }) |
| | | } |
| | | |
| | | // 导åºç»å½æ¥å¿ |
| | | export function exportLogininfor(query) { |
| | | return request({ |
| | | url: '/monitor/logininfor/export', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | |
| | | method: 'delete' |
| | | }) |
| | | } |
| | | |
| | | // å¯¼åºæä½æ¥å¿ |
| | | export function exportOperlog(query) { |
| | | return request({ |
| | | url: '/monitor/operlog/export', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | // 导åºåæ° |
| | | export function exportConfig(query) { |
| | | return request({ |
| | | url: '/system/config/export', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | |
| | | method: 'delete' |
| | | }) |
| | | } |
| | | |
| | | // 导åºåå
¸æ°æ® |
| | | export function exportData(query) { |
| | | return request({ |
| | | url: '/system/dict/data/export', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | // 导åºåå
¸ç±»å |
| | | export function exportType(query) { |
| | | return request({ |
| | | url: '/system/dict/type/export', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | | |
| | | // è·ååå
¸éæ©æ¡å表 |
| | | export function optionselect() { |
| | | return request({ |
| | |
| | | method: 'delete' |
| | | }) |
| | | } |
| | | |
| | | export function changePreviewListResource(previewListResource) { |
| | | const data = { |
| | | previewListResource |
| | | } |
| | | return request({ |
| | | url: '/system/oss/changePreviewListResource', |
| | | method: 'put', |
| | | data: data |
| | | }) |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import request from '@/utils/request' |
| | | |
| | | // æ¥è¯¢äºåå¨é
ç½®å表 |
| | | export function listOssConfig(query) { |
| | | return request({ |
| | | url: '/system/oss/config/list', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | | |
| | | // æ¥è¯¢äºåå¨é
ç½®è¯¦ç» |
| | | export function getOssConfig(ossConfigId) { |
| | | return request({ |
| | | url: '/system/oss/config/' + ossConfigId, |
| | | method: 'get' |
| | | }) |
| | | } |
| | | |
| | | // æ°å¢äºåå¨é
ç½® |
| | | export function addOssConfig(data) { |
| | | return request({ |
| | | url: '/system/oss/config', |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | } |
| | | |
| | | // ä¿®æ¹äºåå¨é
ç½® |
| | | export function updateOssConfig(data) { |
| | | return request({ |
| | | url: '/system/oss/config', |
| | | method: 'put', |
| | | data: data |
| | | }) |
| | | } |
| | | |
| | | // å é¤äºåå¨é
ç½® |
| | | export function delOssConfig(ossConfigId) { |
| | | return request({ |
| | | url: '/system/oss/config/' + ossConfigId, |
| | | method: 'delete' |
| | | }) |
| | | } |
| | | |
| | | // ç¨æ·ç¶æä¿®æ¹ |
| | | export function changeOssConfigStatus(ossConfigId, status, configKey) { |
| | | const data = { |
| | | ossConfigId, |
| | | status, |
| | | configKey |
| | | } |
| | | return request({ |
| | | url: '/system/oss/config/changeStatus', |
| | | method: 'put', |
| | | data: data |
| | | }) |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | // 导åºè§è² |
| | | export function exportRole(query) { |
| | | return request({ |
| | | url: '/system/role/export', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | | |
| | | |
| | | // æ¥è¯¢è§è²å·²ææç¨æ·å表 |
| | | export function allocatedUserList(query) { |
| | | return request({ |
| | |
| | | }) |
| | | } |
| | | |
| | | // 导åºç¨æ· |
| | | export function exportUser(query) { |
| | | return request({ |
| | | url: '/system/user/export', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | | |
| | | // ç¨æ·å¯ç éç½® |
| | | export function resetUserPwd(userId, password) { |
| | | const data = { |
| | |
| | | url: '/system/user/profile/avatar', |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | } |
| | | |
| | | // ä¸è½½ç¨æ·å¯¼å
¥æ¨¡æ¿ |
| | | export function importTemplate() { |
| | | return request({ |
| | | url: '/system/user/importTemplate', |
| | | method: 'get' |
| | | }) |
| | | } |
| | | |
| | |
| | | if (!name) { |
| | | return false |
| | | } |
| | | return name.trim() === 'é¦é¡µ' |
| | | return name.trim() === 'Index' |
| | | }, |
| | | handleLink(item) { |
| | | const { redirect, path } = item |
| | |
| | | import './permission' // permission control |
| | | import { getDicts } from "@/api/system/dict/data"; |
| | | import { getConfigKey } from "@/api/system/config"; |
| | | import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi"; |
| | | import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/ruoyi"; |
| | | import Pagination from "@/components/Pagination"; |
| | | // èªå®ä¹è¡¨æ ¼å·¥å
·ç»ä»¶ |
| | | import RightToolbar from "@/components/RightToolbar" |
| | |
| | | Vue.prototype.addDateRange = addDateRange |
| | | Vue.prototype.selectDictLabel = selectDictLabel |
| | | Vue.prototype.selectDictLabels = selectDictLabels |
| | | Vue.prototype.download = download |
| | | Vue.prototype.handleTree = handleTree |
| | | |
| | | Vue.prototype.msgSuccess = function (msg) { |
| | |
| | | hidden: true |
| | | }, |
| | | { |
| | | path: '/register', |
| | | component: (resolve) => require(['@/views/register'], resolve), |
| | | hidden: true |
| | | }, |
| | | { |
| | | path: '/404', |
| | | component: (resolve) => require(['@/views/error/404'], resolve), |
| | | hidden: true |
| | |
| | | { |
| | | path: 'index', |
| | | component: (resolve) => require(['@/views/index'], resolve), |
| | | name: 'é¦é¡µ', |
| | | meta: { title: 'é¦é¡µ', icon: 'dashboard', noCache: true, affix: true } |
| | | name: 'Index', |
| | | meta: { title: 'é¦é¡µ', icon: 'dashboard', affix: true } |
| | | } |
| | | ] |
| | | }, |
| | |
| | | ] |
| | | }, |
| | | { |
| | | path: '/system/oss-config', |
| | | component: Layout, |
| | | hidden: true, |
| | | children: [ |
| | | { |
| | | path: 'index', |
| | | component: (resolve) => require(['@/views/system/oss/config'], resolve), |
| | | name: 'OssConfig', |
| | | meta: { title: 'é
置管ç', activeMenu: '/system/oss'} |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | path: '/monitor/job-log', |
| | | component: Layout, |
| | | hidden: true, |
| | |
| | | return new Promise((resolve, reject) => { |
| | | getInfo().then(res => { |
| | | const user = res.data.user |
| | | const avatar = user.avatar == "" ? require("@/assets/images/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar; |
| | | const avatar = user.avatar == "" ? require("@/assets/images/profile.jpg") : user.avatar; |
| | | if (res.data.roles && res.data.roles.length > 0) { // éªè¯è¿åçrolesæ¯å¦æ¯ä¸ä¸ªé空æ°ç» |
| | | commit('SET_ROLES', res.data.roles) |
| | | commit('SET_PERMISSIONS', res.data.permissions) |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import axios from 'axios' |
| | | import { getToken } from '@/utils/auth' |
| | | |
| | | const mimeMap = { |
| | | xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
| | | zip: 'application/zip', |
| | | oss: 'application/octet-stream' |
| | | } |
| | | |
| | | const baseUrl = process.env.VUE_APP_BASE_API |
| | | export function downLoadZip(str, filename) { |
| | | var url = baseUrl + str |
| | | axios({ |
| | | method: 'get', |
| | | url: url, |
| | | responseType: 'blob', |
| | | headers: { 'Authorization': 'Bearer ' + getToken() } |
| | | }).then(res => { |
| | | resolveBlob(res, mimeMap.zip) |
| | | }) |
| | | } |
| | | |
| | | export function downLoadOss(ossId) { |
| | | var url = baseUrl + '/system/oss/download/' + ossId |
| | | axios({ |
| | | method: 'get', |
| | | url: url, |
| | | responseType: 'blob', |
| | | headers: { 'Authorization': 'Bearer ' + getToken() } |
| | | }).then(res => { |
| | | resolveBlob(res, mimeMap.oss) |
| | | }) |
| | | } |
| | | |
| | | export function downLoadExcel(url, params) { |
| | | // getè¯·æ±æ å°paramsåæ° |
| | | if (params) { |
| | | let urlparams = url + '?'; |
| | | for (const propName of Object.keys(params)) { |
| | | const value = params[propName]; |
| | | var part = encodeURIComponent(propName) + "="; |
| | | if (value !== null && typeof(value) !== "undefined") { |
| | | if (typeof value === 'object') { |
| | | for (const key of Object.keys(value)) { |
| | | if (value[key] !== null && typeof (value[key]) !== 'undefined') { |
| | | let params = propName + '[' + key + ']'; |
| | | let subPart = encodeURIComponent(params) + '='; |
| | | urlparams += subPart + encodeURIComponent(value[key]) + '&'; |
| | | } |
| | | } |
| | | } else { |
| | | urlparams += part + encodeURIComponent(value) + "&"; |
| | | } |
| | | } |
| | | } |
| | | urlparams = urlparams.slice(0, -1); |
| | | url = urlparams; |
| | | } |
| | | url = baseUrl + url |
| | | axios({ |
| | | method: 'get', |
| | | url: url, |
| | | responseType: 'blob', |
| | | headers: { 'Authorization': 'Bearer ' + getToken() } |
| | | }).then(res => { |
| | | resolveBlob(res, mimeMap.xlsx) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * è§£æblobååºå
容并ä¸è½½ |
| | | * @param {*} res blobååºå
容 |
| | | * @param {String} mimeType MIMEç±»å |
| | | */ |
| | | export function resolveBlob(res, mimeType) { |
| | | const aLink = document.createElement('a') |
| | | var blob = new Blob([res.data], { type: mimeType }) |
| | | // //ä»responseçheadersä¸è·åfilename, å端response.setHeader("Content-disposition", "attachment; filename=xxxx.docx") 设置çæä»¶å; |
| | | var patt = new RegExp('filename=([^;]+\\.[^\\.;]+);*') |
| | | var contentDisposition = decodeURI(res.headers['content-disposition']) |
| | | var result = patt.exec(contentDisposition) |
| | | var fileName = result[1] |
| | | fileName = fileName.replace(/\"/g, '') |
| | | aLink.style.display = 'none' |
| | | aLink.href = URL.createObjectURL(blob) |
| | | aLink.setAttribute('download', decodeURI(fileName)) // 设置ä¸è½½æä»¶åç§° |
| | | document.body.appendChild(aLink) |
| | | aLink.click() |
| | | URL.revokeObjectURL(aLink.href);//æ¸
é¤å¼ç¨ |
| | | document.body.removeChild(aLink); |
| | | } |
| | |
| | | if (value !== null && typeof(value) !== "undefined") { |
| | | if (typeof value === 'object') { |
| | | for (const key of Object.keys(value)) { |
| | | if (value[key] !== null && typeof (value[key]) !== 'undefined') { |
| | | let params = propName + '[' + key + ']'; |
| | | var subPart = encodeURIComponent(params) + "="; |
| | | url += subPart + encodeURIComponent(value[key]) + "&"; |
| | | let subPart = encodeURIComponent(params) + '='; |
| | | url += subPart + encodeURIComponent(value[key]) + '&'; |
| | | } |
| | | } |
| | | } else { |
| | | url += part + encodeURIComponent(value) + "&"; |
| | |
| | | location.href = '/index'; |
| | | }) |
| | | }).catch(() => {}); |
| | | return Promise.reject('error') |
| | | return Promise.reject('令çéªè¯å¤±è´¥') |
| | | } else if (code === 500) { |
| | | Message({ |
| | | message: msg, |
| | |
| | | |
| | | // æ·»å æ¥æèå´ |
| | | export function addDateRange(params, dateRange, propName) { |
| | | var search = params; |
| | | search.params = {}; |
| | | if (null != dateRange && '' != dateRange) { |
| | | if (typeof (propName) === "undefined") { |
| | | search.params["beginTime"] = dateRange[0]; |
| | | search.params["endTime"] = dateRange[1]; |
| | | let search = params; |
| | | search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {}; |
| | | dateRange = Array.isArray(dateRange) ? dateRange : []; |
| | | if (typeof (propName) === 'undefined') { |
| | | search.params['beginTime'] = dateRange[0]; |
| | | search.params['endTime'] = dateRange[1]; |
| | | } else { |
| | | search.params["begin" + propName] = dateRange[0]; |
| | | search.params["end" + propName] = dateRange[1]; |
| | | } |
| | | search.params['begin' + propName] = dateRange[0]; |
| | | search.params['end' + propName] = dateRange[1]; |
| | | } |
| | | return search; |
| | | } |
| | |
| | | }) |
| | | }) |
| | | return actions.join('').substring(0, actions.join('').length - 1); |
| | | } |
| | | |
| | | // éç¨ä¸è½½æ¹æ³ |
| | | export function download(fileName) { |
| | | window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true; |
| | | } |
| | | |
| | | // åç¬¦ä¸²æ ¼å¼å(%s ) |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { listDemo, pageDemo, getDemo, delDemo, addDemo, updateDemo, exportDemo } from "@/api/demo/demo"; |
| | | import { listDemo, pageDemo, getDemo, delDemo, addDemo, updateDemo } from "@/api/demo/demo"; |
| | | import { downLoadExcel } from "@/utils/download"; |
| | | |
| | | export default { |
| | | name: "Demo", |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | const queryParams = this.queryParams; |
| | | this.$confirm('æ¯å¦ç¡®è®¤å¯¼åºæææµè¯åè¡¨æ°æ®é¡¹?', "è¦å", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.exportLoading = true; |
| | | return exportDemo(queryParams); |
| | | }).then(response => { |
| | | this.download(response.msg); |
| | | this.exportLoading = false; |
| | | }) |
| | | downLoadExcel('/demo/demo/export', this.queryParams); |
| | | } |
| | | } |
| | | }; |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { listTree, getTree, delTree, addTree, updateTree, exportTree } from "@/api/demo/tree"; |
| | | import { listTree, getTree, delTree, addTree, updateTree } from "@/api/demo/tree"; |
| | | import Treeselect from "@riophae/vue-treeselect"; |
| | | import "@riophae/vue-treeselect/dist/vue-treeselect.css"; |
| | | |
| | |
| | | <span>æ´æ°æ¥å¿</span> |
| | | </div> |
| | | <el-collapse accordion> |
| | | <el-collapse-item title="v3.0.0 - 2021-8-18"> |
| | | <ol> |
| | | <li>add [éå¤§æ´æ°]éå OSS 模åç¸å
³å®ç° æ¯æå¨æé
ç½®(页é¢é
ç½®)<li> |
| | | <li>add [éå¤§æ´æ°]å¢å jackson è¶
åº JS æå¤§æ°å¼èªå¨è½¬å符串(éªè±idåºåå)å¤ç<li> |
| | | <li>add [éå¤§æ´æ°]éå é²éæäº¤æ¦æªå¨ æ¯æå
¨å±ä¸æ³¨è§£èªå®ä¹ æ¦æªæ¶é´é
ç½®é
ç½® ä¼åé»è¾<li> |
| | | <li>add [éå¤§æ´æ°]æ°å¢æ¯å¦å¼å¯ç¨æ·æ³¨ååè½<li> |
| | | <li>add [éå¤§æ´æ°]å¢å easyexcel å·¥å
·ç±»<li> |
| | | <li>add [éå¤§æ´æ°]éæ æ§è½åææä»¶ p6spy æ´å¼ºå²ç SQL åæ<li> |
| | | <li>add [éå¤§æ´æ°]å¢å 宿´å½é
åè§£å³æ¹æ¡<li> |
| | | <li>add [éå¤§æ´æ°]æ¯æèªå®ä¹æ³¨è§£å®ç°æ¥å£éæµ<li> |
| | | <li>update feign-okhttp 11.0 => 11.2<li> |
| | | <li>update okhttp 3.19.4 => 4.9.1<li> |
| | | <li>update minio 8.2.0 => 8.3.0<li> |
| | | <li>update hutool 5.7.6 => 5.7.7<li> |
| | | <li>update element-ui 2.15.2 => 2.15.5<li> |
| | | <li>update springboot admin 2.4.3 => 2.5.0 (æ°å¢ Quartz ä¸å±çæ§é¡µ)<li> |
| | | <li>add å¢å admin çæ§å®¢æ·ç«¯å¼å
³<li> |
| | | <li>add å¢å å½é
åæ¼ç¤ºdemo<li> |
| | | <li>update æ´æ°è½¯ä»¶æ¶æå¾<li> |
| | | <li>update ä¼åXSSè·¨ç«èæ¬è¿æ»¤<li> |
| | | <li>update ä¼åBLOBä¸è½½æ¶æ¸
é¤URL对象å¼ç¨<li> |
| | | <li>update æ´æ° é²éæäº¤æ¦æªå¨ demoæ¼ç¤ºæ¡ä¾<li> |
| | | <li>update æ¥å¸¸åç¬¦ä¸²æ ¡éª ç»ä¸éæå° StringUtils 便äºç»´æ¤æ©å±<li> |
| | | <li>update ä¿®æ¹ èªå¨æ³¨å
¥å¨ ç¨æ·æªç»å½å¼å¸¸æ¦æªæåºè¦å è¿åNull<li> |
| | | <li>update éæ ç»ä¸ä½¿ç¨ æµå·¥å
·ä¸è½½<li> |
| | | <li>update éå ææä¸å¡å¯¼åº éé
easyexcelå·¥å
·<li> |
| | | <li>update ç§»å¨æä»¶åå¨ä¸å¡å° system 模å<li> |
| | | <li>update 代ç çææ¨¡æ¿ éé
æ°excel导åº<li> |
| | | <li>update å° Actuator é
ç½® ç§»å¨å°å
¨å±é
ç½®<li> |
| | | <li>update ç»ä¸éåæ¶åºé
ç½® ç§»é¤ä¸»æºæ¶é´æ å°<li> |
| | | <li>update æ´æ¹å¤æ°æ®æºæ¡æ¶æ´æ¸
æ°çä¾èµå<li> |
| | | <li>update æ´æ° é¿éäº mavenæº æ°å°å<li> |
| | | <li>update è¡¥å
¨åºç¡å®ä½ ææ¡£æ³¨è§£<li> |
| | | <li>update 代ç çæææ¡£æ³¨è§£ å¢å å¿
填夿é
ç½®<li> |
| | | <li>update 注å
¥å¨ insert å¢å update åæ®µå¤ç<li> |
| | | <li>update é»è®¤é¦é¡µä½¿ç¨keep-aliveç¼å<li> |
| | | <li>fix ç产minioåæ¾é®é¢<li> |
| | | <li>fix ä¿®å¤è§è²åé
ç¨æ·é¡µé¢æ¥æ¶åæ°ä¸ä¼ éåæ°ç±»åä¸ä¸è´å¯¼è´çé误<li> |
| | | <li>fix ä¿®å¤ä»£ç çæ å 餿鮿¥é loading ä¸åæ¶é®é¢<li> |
| | | <li>fix è§£å³ç»å½åæµè§å¨åå°Breadcrumbç»ä»¶æ¥é<li> |
| | | <li>fix ä¿®å¤DictUtilsæ¹æ³æ¥é<li> |
| | | <li>fix 头åä¸ä¼ æªèµ°OSSåå¨é®é¢<li> |
| | | <li>fix osså表 jpeg ä¸åæ¾é®é¢<li> |
| | | <li>fix ä¿®å¤æä½æ¥å¿æ ¹æ®ç¶ææ¥è¯¢å¼å¸¸é®é¢<li> |
| | | <li>remove ç§»é¤åçexcelå·¥å
·<li> |
| | | <li>remove ç§»é¤éç¨ä¸ä¼ ä¸è½½æ¥å£ä¸é
ç½®<li> |
| | | </ol> |
| | | </el-collapse-item> |
| | | <el-collapse-item title="v2.6.0 - 2021-7-28"> |
| | | <ol> |
| | | <li>add [é大æ°å¢] å¢å OSS 对象å卿¨¡å</li> |
| | |
| | | import config from '../../package.json' |
| | | |
| | | export default { |
| | | name: "index", |
| | | name: "Index", |
| | | data() { |
| | | return { |
| | | // çæ¬å· |
| | |
| | | <span v-if="!loading">ç» å½</span> |
| | | <span v-else>ç» å½ ä¸...</span> |
| | | </el-button> |
| | | <div style="float: right;" v-if="register"> |
| | | <router-link class="link-type" :to="'/register'">ç«å³æ³¨å</router-link> |
| | | </div> |
| | | </el-form-item> |
| | | </el-form> |
| | | <!-- åºé¨ --> |
| | |
| | | }, |
| | | loginRules: { |
| | | username: [ |
| | | { required: true, trigger: "blur", message: "ç¨æ·åä¸è½ä¸ºç©º" } |
| | | { required: true, trigger: "blur", message: "请è¾å
¥æ¨çè´¦å·" } |
| | | ], |
| | | password: [ |
| | | { required: true, trigger: "blur", message: "å¯ç ä¸è½ä¸ºç©º" } |
| | | { required: true, trigger: "blur", message: "请è¾å
¥æ¨çå¯ç " } |
| | | ], |
| | | code: [{ required: true, trigger: "change", message: "éªè¯ç ä¸è½ä¸ºç©º" }] |
| | | code: [{ required: true, trigger: "change", message: "请è¾å
¥éªè¯ç " }] |
| | | }, |
| | | loading: false, |
| | | // éªè¯ç å¼å
³ |
| | | captchaOnOff: true, |
| | | // 注åå¼å
³ |
| | | register: false, |
| | | redirect: undefined |
| | | }; |
| | | }, |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { listJob, getJob, delJob, addJob, updateJob, exportJob, runJob, changeJobStatus } from "@/api/monitor/job"; |
| | | import { listJob, getJob, delJob, addJob, updateJob, runJob, changeJobStatus } from "@/api/monitor/job"; |
| | | import { downLoadExcel } from "@/utils/download"; |
| | | |
| | | export default { |
| | | name: "Job", |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | const queryParams = this.queryParams; |
| | | this.$confirm("æ¯å¦ç¡®è®¤å¯¼åºææå®æ¶ä»»å¡æ°æ®é¡¹?", "è¦å", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.exportLoading = true; |
| | | return exportJob(queryParams); |
| | | }).then(response => { |
| | | this.download(response.msg); |
| | | this.exportLoading = false; |
| | | }).catch(() => {}); |
| | | downLoadExcel('/monitor/job/export', this.queryParams); |
| | | } |
| | | } |
| | | }; |
| | |
| | | |
| | | <script> |
| | | import { getJob} from "@/api/monitor/job"; |
| | | import { listJobLog, delJobLog, exportJobLog, cleanJobLog } from "@/api/monitor/jobLog"; |
| | | import { listJobLog, delJobLog, cleanJobLog } from "@/api/monitor/jobLog"; |
| | | import { downLoadExcel } from "@/utils/download"; |
| | | |
| | | export default { |
| | | name: "JobLog", |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | const queryParams = this.queryParams; |
| | | this.$confirm("æ¯å¦ç¡®è®¤å¯¼åºææè°åº¦æ¥å¿æ°æ®é¡¹?", "è¦å", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.exportLoading = true; |
| | | return exportJobLog(queryParams); |
| | | }).then(response => { |
| | | this.download(response.msg); |
| | | this.exportLoading = false; |
| | | }).catch(() => {}); |
| | | downLoadExcel('/monitor/jobLog/export', this.queryParams); |
| | | } |
| | | } |
| | | }; |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { list, delLogininfor, cleanLogininfor, exportLogininfor } from "@/api/monitor/logininfor"; |
| | | import { list, delLogininfor, cleanLogininfor } from "@/api/monitor/logininfor"; |
| | | import { downLoadExcel } from "@/utils/download"; |
| | | |
| | | export default { |
| | | name: "Logininfor", |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | const queryParams = this.queryParams; |
| | | this.$confirm('æ¯å¦ç¡®è®¤å¯¼åºæææä½æ¥å¿æ°æ®é¡¹?', "è¦å", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.exportLoading = true; |
| | | return exportLogininfor(queryParams); |
| | | }).then(response => { |
| | | this.download(response.msg); |
| | | this.exportLoading = false; |
| | | }).catch(() => {}); |
| | | downLoadExcel('/monitor/logininfor/export', this.queryParams); |
| | | } |
| | | } |
| | | }; |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { list, delOperlog, cleanOperlog, exportOperlog } from "@/api/monitor/operlog"; |
| | | import { list, delOperlog, cleanOperlog } from "@/api/monitor/operlog"; |
| | | import { downLoadExcel } from "@/utils/download"; |
| | | |
| | | export default { |
| | | name: "Operlog", |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | const queryParams = this.queryParams; |
| | | this.$confirm('æ¯å¦ç¡®è®¤å¯¼åºæææä½æ¥å¿æ°æ®é¡¹?', "è¦å", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.exportLoading = true; |
| | | return exportOperlog(queryParams); |
| | | }).then(response => { |
| | | this.download(response.msg); |
| | | this.exportLoading = false; |
| | | }).catch(() => {}); |
| | | downLoadExcel('/monitor/operlog/export', this.queryParams); |
| | | } |
| | | } |
| | | }; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="register"> |
| | | <el-form ref="registerForm" :model="registerForm" :rules="registerRules" class="register-form"> |
| | | <h3 class="title">è¥ä¾åå°ç®¡çç³»ç»</h3> |
| | | <el-form-item prop="username"> |
| | | <el-input v-model="registerForm.username" type="text" auto-complete="off" placeholder="è´¦å·"> |
| | | <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" /> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item prop="password"> |
| | | <el-input |
| | | v-model="registerForm.password" |
| | | type="password" |
| | | auto-complete="off" |
| | | placeholder="å¯ç " |
| | | @keyup.enter.native="handleRegister" |
| | | > |
| | | <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" /> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item prop="confirmPassword"> |
| | | <el-input |
| | | v-model="registerForm.confirmPassword" |
| | | type="password" |
| | | auto-complete="off" |
| | | placeholder="确认å¯ç " |
| | | @keyup.enter.native="handleRegister" |
| | | > |
| | | <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" /> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item prop="code" v-if="captchaOnOff"> |
| | | <el-input |
| | | v-model="registerForm.code" |
| | | auto-complete="off" |
| | | placeholder="éªè¯ç " |
| | | style="width: 63%" |
| | | @keyup.enter.native="handleRegister" |
| | | > |
| | | <svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" /> |
| | | </el-input> |
| | | <div class="register-code"> |
| | | <img :src="codeUrl" @click="getCode" class="register-code-img"/> |
| | | </div> |
| | | </el-form-item> |
| | | <el-form-item style="width:100%;"> |
| | | <el-button |
| | | :loading="loading" |
| | | size="medium" |
| | | type="primary" |
| | | style="width:100%;" |
| | | @click.native.prevent="handleRegister" |
| | | > |
| | | <span v-if="!loading">注 å</span> |
| | | <span v-else>注 å ä¸...</span> |
| | | </el-button> |
| | | <div style="float: right;"> |
| | | <router-link class="link-type" :to="'/login'">使ç¨å·²æè´¦æ·ç»å½</router-link> |
| | | </div> |
| | | </el-form-item> |
| | | </el-form> |
| | | <!-- åºé¨ --> |
| | | <div class="el-register-footer"> |
| | | <span>Copyright © 2018-2021 ruoyi.vip All Rights Reserved.</span> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { getCodeImg, register } from "@/api/login"; |
| | | |
| | | export default { |
| | | name: "Register", |
| | | data() { |
| | | const equalToPassword = (rule, value, callback) => { |
| | | if (this.registerForm.password !== value) { |
| | | callback(new Error("两次è¾å
¥çå¯ç ä¸ä¸è´")); |
| | | } else { |
| | | callback(); |
| | | } |
| | | }; |
| | | return { |
| | | codeUrl: "", |
| | | registerForm: { |
| | | username: "", |
| | | password: "", |
| | | confirmPassword: "", |
| | | code: "", |
| | | uuid: "" |
| | | }, |
| | | registerRules: { |
| | | username: [ |
| | | { required: true, trigger: "blur", message: "请è¾å
¥æ¨çè´¦å·" }, |
| | | { min: 2, max: 20, message: 'ç¨æ·è´¦å·é¿åº¦å¿
é¡»ä»äº 2 å 20 ä¹é´', trigger: 'blur' } |
| | | ], |
| | | password: [ |
| | | { required: true, trigger: "blur", message: "请è¾å
¥æ¨çå¯ç " }, |
| | | { min: 5, max: 20, message: 'ç¨æ·å¯ç é¿åº¦å¿
é¡»ä»äº 5 å 20 ä¹é´', trigger: 'blur' } |
| | | ], |
| | | confirmPassword: [ |
| | | { required: true, trigger: "blur", message: "è¯·åæ¬¡è¾å
¥æ¨çå¯ç " }, |
| | | { required: true, validator: equalToPassword, trigger: "blur" } |
| | | ], |
| | | code: [{ required: true, trigger: "change", message: "请è¾å
¥éªè¯ç " }] |
| | | }, |
| | | loading: false, |
| | | captchaOnOff: true |
| | | }; |
| | | }, |
| | | created() { |
| | | this.getCode(); |
| | | }, |
| | | methods: { |
| | | getCode() { |
| | | getCodeImg().then(res => { |
| | | this.captchaOnOff = res.data.captchaOnOff === undefined ? true : res.data.captchaOnOff; |
| | | if (this.captchaOnOff) { |
| | | this.codeUrl = "data:image/gif;base64," + res.data.img; |
| | | this.registerForm.uuid = res.data.uuid; |
| | | } |
| | | }); |
| | | }, |
| | | handleRegister() { |
| | | this.$refs.registerForm.validate(valid => { |
| | | if (valid) { |
| | | this.loading = true; |
| | | register(this.registerForm).then(res => { |
| | | const username = this.registerForm.username; |
| | | this.$alert("<font color='red'>æåä½ ï¼æ¨çè´¦å· " + username + " 注åæåï¼</font>", 'ç³»ç»æç¤º', { |
| | | dangerouslyUseHTMLString: true |
| | | }).then(() => { |
| | | this.$router.push("/login"); |
| | | }).catch(() => {}); |
| | | }).catch(() => { |
| | | this.loading = false; |
| | | if (this.captchaOnOff) { |
| | | this.getCode(); |
| | | } |
| | | }) |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style rel="stylesheet/scss" lang="scss"> |
| | | .register { |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | height: 100%; |
| | | background-image: url("../assets/images/login-background.jpg"); |
| | | background-size: cover; |
| | | } |
| | | .title { |
| | | margin: 0px auto 30px auto; |
| | | text-align: center; |
| | | color: #707070; |
| | | } |
| | | |
| | | .register-form { |
| | | border-radius: 6px; |
| | | background: #ffffff; |
| | | width: 400px; |
| | | padding: 25px 25px 5px 25px; |
| | | .el-input { |
| | | height: 38px; |
| | | input { |
| | | height: 38px; |
| | | } |
| | | } |
| | | .input-icon { |
| | | height: 39px; |
| | | width: 14px; |
| | | margin-left: 2px; |
| | | } |
| | | } |
| | | .register-tip { |
| | | font-size: 13px; |
| | | text-align: center; |
| | | color: #bfbfbf; |
| | | } |
| | | .register-code { |
| | | width: 33%; |
| | | height: 38px; |
| | | float: right; |
| | | img { |
| | | cursor: pointer; |
| | | vertical-align: middle; |
| | | } |
| | | } |
| | | .el-register-footer { |
| | | height: 40px; |
| | | line-height: 40px; |
| | | position: fixed; |
| | | bottom: 0; |
| | | width: 100%; |
| | | text-align: center; |
| | | color: #fff; |
| | | font-family: Arial; |
| | | font-size: 12px; |
| | | letter-spacing: 1px; |
| | | } |
| | | .register-code-img { |
| | | height: 38px; |
| | | } |
| | | </style> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { listConfig, getConfig, delConfig, addConfig, updateConfig, exportConfig, refreshCache } from "@/api/system/config"; |
| | | import { listConfig, getConfig, delConfig, addConfig, updateConfig, refreshCache } from "@/api/system/config"; |
| | | import { downLoadExcel } from "@/utils/download"; |
| | | |
| | | export default { |
| | | name: "Config", |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | const queryParams = this.queryParams; |
| | | this.$confirm('æ¯å¦ç¡®è®¤å¯¼åºææåæ°æ°æ®é¡¹?', "è¦å", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.exportLoading = true; |
| | | return exportConfig(queryParams); |
| | | }).then(response => { |
| | | this.download(response.msg); |
| | | this.exportLoading = false; |
| | | }).catch(() => {}); |
| | | downLoadExcel('/system/config/export', this.queryParams); |
| | | }, |
| | | /** å·æ°ç¼åæé®æä½ */ |
| | | handleRefreshCache() { |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { listData, getData, delData, addData, updateData, exportData } from "@/api/system/dict/data"; |
| | | import { listData, getData, delData, addData, updateData } from "@/api/system/dict/data"; |
| | | import { listType, getType } from "@/api/system/dict/type"; |
| | | import { downLoadExcel } from "@/utils/download"; |
| | | |
| | | export default { |
| | | name: "Data", |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | const queryParams = this.queryParams; |
| | | this.$confirm('æ¯å¦ç¡®è®¤å¯¼åºæææ°æ®é¡¹?', "è¦å", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.exportLoading = true; |
| | | return exportData(queryParams); |
| | | }).then(response => { |
| | | this.download(response.msg); |
| | | this.exportLoading = false; |
| | | }).catch(() => {}); |
| | | downLoadExcel('/system/dict/data/export', this.queryParams); |
| | | } |
| | | } |
| | | }; |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { listType, getType, delType, addType, updateType, exportType, refreshCache } from "@/api/system/dict/type"; |
| | | import { listType, getType, delType, addType, updateType, refreshCache } from "@/api/system/dict/type"; |
| | | import { downLoadExcel } from "@/utils/download"; |
| | | |
| | | export default { |
| | | name: "Dict", |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | const queryParams = this.queryParams; |
| | | this.$confirm('æ¯å¦ç¡®è®¤å¯¼åºææç±»åæ°æ®é¡¹?', "è¦å", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.exportLoading = true; |
| | | return exportType(queryParams); |
| | | }).then(response => { |
| | | this.download(response.msg); |
| | | this.exportLoading = false; |
| | | }).catch(() => {}); |
| | | downLoadExcel('/system/dict/type/export', this.queryParams); |
| | | }, |
| | | /** å·æ°ç¼åæé®æä½ */ |
| | | handleRefreshCache() { |
| | |
| | | </el-table> |
| | | |
| | | <!-- æ·»å æä¿®æ¹èåå¯¹è¯æ¡ --> |
| | | <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body> |
| | | <el-dialog :title="title" :visible.sync="open" width="680px" append-to-body> |
| | | <el-form ref="form" :model="form" :rules="rules" label-width="100px"> |
| | | <el-row> |
| | | <el-col :span="24"> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> |
| | | <el-form-item label="é
ç½®key" prop="configKey"> |
| | | <el-select v-model="queryParams.configKey" placeholder="è¯·éæ©é
ç½®key" clearable size="small"> |
| | | <el-option |
| | | v-for="configKey in configKeyOptions" |
| | | :key="configKey.configKey" |
| | | :label="configKey.label" |
| | | :value="configKey.configKey" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="æ¡¶åç§°" prop="bucketName"> |
| | | <el-input |
| | | v-model="queryParams.bucketName" |
| | | placeholder="请è¾å
¥æ¡¶åç§°" |
| | | clearable |
| | | size="small" |
| | | @keyup.enter.native="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="ç¶æ" prop="status"> |
| | | <el-select v-model="queryParams.status" placeholder="è¯·éæ©ç¶æ" clearable size="small"> |
| | | <el-option |
| | | v-for="dict in statusOptions" |
| | | :key="dict.dictValue" |
| | | :label="dict.dictLabel" |
| | | :value="dict.dictValue" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">æç´¢</el-button> |
| | | <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">éç½®</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="el-icon-plus" |
| | | size="mini" |
| | | @click="handleAdd" |
| | | v-hasPermi="['system:oss:add']" |
| | | >æ°å¢</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="el-icon-edit" |
| | | size="mini" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | v-hasPermi="['system:oss:edit']" |
| | | >ä¿®æ¹</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="el-icon-delete" |
| | | size="mini" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['system:oss:remove']" |
| | | >å é¤</el-button> |
| | | </el-col> |
| | | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | |
| | | <el-table v-loading="loading" :data="ossConfigList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="主建" align="center" prop="ossConfigId" v-if="false"/> |
| | | <el-table-column label="é
ç½®key" align="center" prop="configKey" /> |
| | | <el-table-column label="访é®ç«ç¹" align="center" prop="endpoint" width="200" /> |
| | | <el-table-column label="æ¡¶åç§°" align="center" prop="bucketName" /> |
| | | <el-table-column label="åç¼" align="center" prop="prefix" /> |
| | | <el-table-column label="å" align="center" prop="region" /> |
| | | <el-table-column label="ç¶æ" align="center" prop="status"> |
| | | <template slot-scope="scope"> |
| | | <el-switch |
| | | v-model="scope.row.status" |
| | | active-value="0" |
| | | inactive-value="1" |
| | | @change="handleStatusChange(scope.row)" |
| | | ></el-switch> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="æä½" align="center" class-name="small-padding fixed-width"> |
| | | <template slot-scope="scope"> |
| | | <el-button |
| | | size="mini" |
| | | type="text" |
| | | icon="el-icon-edit" |
| | | @click="handleUpdate(scope.row)" |
| | | v-hasPermi="['system:oss:edit']" |
| | | >ä¿®æ¹</el-button> |
| | | <el-button |
| | | size="mini" |
| | | type="text" |
| | | icon="el-icon-delete" |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['system:oss:remove']" |
| | | >å é¤</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | :page.sync="queryParams.pageNum" |
| | | :limit.sync="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | |
| | | <!-- æ·»å æä¿®æ¹äºåå¨é
ç½®å¯¹è¯æ¡ --> |
| | | <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body> |
| | | <el-form ref="form" :model="form" :rules="rules" label-width="120px"> |
| | | <el-form-item label="é
ç½®key" prop="configKey"> |
| | | <el-select v-model="form.configKey" placeholder="è¯·éæ©é
ç½®key"> |
| | | <el-option |
| | | v-for="configKey in configKeyOptions" |
| | | :key="configKey.configKey" |
| | | :label="configKey.label" |
| | | :value="configKey.configKey" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="访é®ç«ç¹" prop="endpoint"> |
| | | <el-input v-model="form.endpoint" placeholder="请è¾å
¥è®¿é®ç«ç¹" /> |
| | | </el-form-item> |
| | | <el-form-item label="accessKey" prop="accessKey"> |
| | | <el-input v-model="form.accessKey" placeholder="请è¾å
¥accessKey" /> |
| | | </el-form-item> |
| | | <el-form-item label="secretKey" prop="secretKey"> |
| | | <el-input v-model="form.secretKey" placeholder="请è¾å
¥ç§é¥" /> |
| | | </el-form-item> |
| | | <el-form-item label="æ¡¶åç§°" prop="bucketName"> |
| | | <el-input v-model="form.bucketName" placeholder="请è¾å
¥æ¡¶åç§°" /> |
| | | </el-form-item> |
| | | <el-form-item label="åç¼" prop="prefix"> |
| | | <el-input v-model="form.prefix" placeholder="请è¾å
¥åç¼" /> |
| | | </el-form-item> |
| | | <el-form-item label="æ¯å¦HTTPS"> |
| | | <el-radio-group v-model="form.isHttps"> |
| | | <el-radio |
| | | v-for="dict in isHttpsOptions" |
| | | :key="dict.dictValue" |
| | | :label="dict.dictValue" |
| | | >{{dict.dictLabel}}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="å" prop="region"> |
| | | <el-input v-model="form.region" placeholder="请è¾å
¥å" /> |
| | | </el-form-item> |
| | | <el-form-item label="夿³¨" prop="remark"> |
| | | <el-input v-model="form.remark" type="textarea" placeholder="请è¾å
¥å
容" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button :loading="buttonLoading" type="primary" @click="submitForm">ç¡® å®</el-button> |
| | | <el-button @click="cancel">å æ¶</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | |
| | | import { |
| | | listOssConfig, |
| | | getOssConfig, |
| | | delOssConfig, |
| | | addOssConfig, |
| | | updateOssConfig, |
| | | changeOssConfigStatus |
| | | } from "@/api/system/ossConfig"; |
| | | |
| | | export default { |
| | | name: "OssConfig", |
| | | data() { |
| | | return { |
| | | // æé®loading |
| | | buttonLoading: false, |
| | | // é®ç½©å± |
| | | loading: true, |
| | | // 导åºé®ç½©å± |
| | | exportLoading: false, |
| | | // é䏿°ç» |
| | | ids: [], |
| | | // éå个ç¦ç¨ |
| | | single: true, |
| | | // éå¤ä¸ªç¦ç¨ |
| | | multiple: true, |
| | | // æ¾ç¤ºæç´¢æ¡ä»¶ |
| | | showSearch: true, |
| | | // æ»æ¡æ° |
| | | total: 0, |
| | | // äºåå¨é
ç½®è¡¨æ ¼æ°æ® |
| | | ossConfigList: [], |
| | | // configKeyOptions |
| | | configKeyOptions: [], |
| | | configKeyDatas: [ |
| | | { configKey: "minio", label: "Minio" }, |
| | | { configKey: "qiniu", label: "ä¸çäº" }, |
| | | { configKey: "aliyun", label: "é¿éäº" }, |
| | | { configKey: "qcloud", label: "è
¾è®¯äº" }, |
| | | ], |
| | | // å¼¹åºå±æ é¢ |
| | | title: "", |
| | | // æ¯å¦æ¾ç¤ºå¼¹åºå± |
| | | open: false, |
| | | // æ¯å¦httpsåå
¸ |
| | | isHttpsOptions: [], |
| | | // ç¶æ(0æ£å¸¸ 1åç¨)åå
¸ |
| | | statusOptions: [], |
| | | // æ¥è¯¢åæ° |
| | | queryParams: { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | configKey: undefined, |
| | | bucketName: undefined, |
| | | status: undefined, |
| | | }, |
| | | // 表ååæ° |
| | | form: {}, |
| | | // è¡¨åæ ¡éª |
| | | rules: { |
| | | configKey: [ |
| | | { required: true, message: "configKeyä¸è½ä¸ºç©º", trigger: "blur" }, |
| | | ], |
| | | accessKey: [ |
| | | { required: true, message: "accessKeyä¸è½ä¸ºç©º", trigger: "blur" }, |
| | | { |
| | | min: 2, |
| | | max: 200, |
| | | message: "accessKeyé¿åº¦å¿
é¡»ä»äº 2 å 100 ä¹é´", |
| | | trigger: "blur", |
| | | }, |
| | | ], |
| | | secretKey: [ |
| | | { required: true, message: "secretKeyä¸è½ä¸ºç©º", trigger: "blur" }, |
| | | { |
| | | min: 2, |
| | | max: 100, |
| | | message: "secretKeyé¿åº¦å¿
é¡»ä»äº 2 å 100 ä¹é´", |
| | | trigger: "blur", |
| | | }, |
| | | ], |
| | | bucketName: [ |
| | | { required: true, message: "bucketNameä¸è½ä¸ºç©º", trigger: "blur" }, |
| | | { |
| | | min: 2, |
| | | max: 100, |
| | | message: "bucketNameé¿åº¦å¿
é¡»ä»äº 2 å 100 ä¹é´", |
| | | trigger: "blur", |
| | | }, |
| | | ], |
| | | endpoint: [ |
| | | { required: true, message: "endpointä¸è½ä¸ºç©º", trigger: "blur" }, |
| | | { |
| | | min: 2, |
| | | max: 100, |
| | | message: "endpointåç§°é¿åº¦å¿
é¡»ä»äº 2 å 100 ä¹é´", |
| | | trigger: "blur", |
| | | }, |
| | | ], |
| | | }, |
| | | }; |
| | | }, |
| | | created() { |
| | | this.getList(); |
| | | this.getDicts("sys_yes_no").then(response => { |
| | | this.isHttpsOptions = response.data; |
| | | }); |
| | | this.getDicts("sys_normal_disable").then(response => { |
| | | this.statusOptions = response.data; |
| | | }); |
| | | this.configKeyOptions = this.configKeyDatas; |
| | | }, |
| | | methods: { |
| | | /** æ¥è¯¢äºåå¨é
ç½®å表 */ |
| | | getList() { |
| | | this.loading = true; |
| | | listOssConfig(this.queryParams).then((response) => { |
| | | this.ossConfigList = response.rows; |
| | | this.total = response.total; |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | | // åæ¶æé® |
| | | cancel() { |
| | | this.open = false; |
| | | this.reset(); |
| | | }, |
| | | // 表åéç½® |
| | | reset() { |
| | | this.form = { |
| | | ossConfigId: undefined, |
| | | configKey: undefined, |
| | | accessKey: undefined, |
| | | secretKey: undefined, |
| | | bucketName: undefined, |
| | | prefix: undefined, |
| | | endpoint: undefined, |
| | | isHttps: "N", |
| | | region: undefined, |
| | | status: "1", |
| | | remark: undefined, |
| | | }; |
| | | this.resetForm("form"); |
| | | }, |
| | | /** æç´¢æé®æä½ */ |
| | | handleQuery() { |
| | | this.queryParams.pageNum = 1; |
| | | this.getList(); |
| | | }, |
| | | /** éç½®æé®æä½ */ |
| | | resetQuery() { |
| | | this.resetForm("queryForm"); |
| | | this.handleQuery(); |
| | | }, |
| | | // å¤éæ¡é䏿°æ® |
| | | handleSelectionChange(selection) { |
| | | this.ids = selection.map(item => item.ossConfigId) |
| | | this.single = selection.length!==1 |
| | | this.multiple = !selection.length |
| | | }, |
| | | /** æ°å¢æé®æä½ */ |
| | | handleAdd() { |
| | | this.reset(); |
| | | this.open = true; |
| | | this.title = "æ·»å äºåå¨é
ç½®"; |
| | | }, |
| | | /** ä¿®æ¹æé®æä½ */ |
| | | handleUpdate(row) { |
| | | this.loading = true; |
| | | this.reset(); |
| | | const ossConfigId = row.ossConfigId || this.ids; |
| | | getOssConfig(ossConfigId).then((response) => { |
| | | this.loading = false; |
| | | this.form = response.data; |
| | | this.open = true; |
| | | this.title = "ä¿®æ¹äºåå¨é
ç½®"; |
| | | }); |
| | | }, |
| | | /** æäº¤æé® */ |
| | | submitForm() { |
| | | this.$refs["form"].validate(valid => { |
| | | if (valid) { |
| | | this.buttonLoading = true; |
| | | if (this.form.ossConfigId != null) { |
| | | updateOssConfig(this.form).then(response => { |
| | | this.msgSuccess("ä¿®æ¹æå"); |
| | | this.open = false; |
| | | this.getList(); |
| | | }).finally(() => { |
| | | this.buttonLoading = false; |
| | | }); |
| | | } else { |
| | | addOssConfig(this.form).then(response => { |
| | | this.msgSuccess("æ°å¢æå"); |
| | | this.open = false; |
| | | this.getList(); |
| | | }).finally(() => { |
| | | this.buttonLoading = false; |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | /** å é¤æé®æä½ */ |
| | | handleDelete(row) { |
| | | const ossConfigIds = row.ossConfigId || this.ids; |
| | | this.$confirm('æ¯å¦ç¡®è®¤å é¤äºåå¨é
ç½®ç¼å·ä¸º"' + ossConfigIds + '"çæ°æ®é¡¹?', "è¦å", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.loading = true; |
| | | return delOssConfig(ossConfigIds); |
| | | }).then(() => { |
| | | this.loading = false; |
| | | this.getList(); |
| | | this.msgSuccess("å 餿å"); |
| | | }).finally(() => { |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | | // äºåå¨é
ç½®ç¶æä¿®æ¹ |
| | | handleStatusChange(row) { |
| | | let text = row.status === "0" ? "å¯ç¨" : "åç¨"; |
| | | this.$confirm( |
| | | '确认è¦"' + text + '""' + row.configKey + '"é
ç½®å?', "è¦å", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning", |
| | | }).then(() => { |
| | | return changeOssConfigStatus(row.ossConfigId, row.status, row.configKey); |
| | | }).then(() => { |
| | | this.getList() |
| | | this.msgSuccess(text + "æå"); |
| | | }).catch(() => { |
| | | row.status = row.status === "0" ? "1" : "0"; |
| | | }) |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | |
| | | v-hasPermi="['system:oss:remove']" |
| | | >å é¤</el-button> |
| | | </el-col> |
| | | |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | :type="previewListResource ? 'danger' : 'warning'" |
| | | plain |
| | | size="mini" |
| | | @click="handlePreviewListResource(!previewListResource)" |
| | | v-hasPermi="['system:oss:edit']" |
| | | >é¢è§å¼å
³ : {{previewListResource ? "ç¦ç¨" : "å¯ç¨"}}</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="info" |
| | | plain |
| | | icon="el-icon-s-operation" |
| | | size="mini" |
| | | @click="handleOssConfig" |
| | | v-hasPermi="['system:oss:list']" |
| | | >é
置管ç</el-button> |
| | | </el-col> |
| | | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | |
| | |
| | | <el-table-column label="æä»¶å±ç¤º" align="center" prop="url"> |
| | | <template slot-scope="scope"> |
| | | <el-image |
| | | v-if="previewListResource && scope.row.fileSuffix.indexOf('png','jpg','jpeg') > 0" |
| | | v-if="previewListResource && checkFileSuffix(scope.row.fileSuffix)" |
| | | style="width: 100px; height: 100px;" |
| | | :src="scope.row.url" |
| | | :preview-src-list="[scope.row.url]"/> |
| | | <span v-text="scope.row.url" |
| | | v-if="scope.row.fileSuffix.indexOf('png','jpg','jpeg') < 0 || !previewListResource"/> |
| | | v-if="!checkFileSuffix(scope.row.fileSuffix) || !previewListResource"/> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="å建æ¶é´" align="center" prop="createTime" width="180"> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { listOss, delOss } from "@/api/system/oss"; |
| | | import { downLoadOss } from "@/utils/ossdownload"; |
| | | import { updateConfig } from "@/api/system/config"; |
| | | |
| | | import { listOss, delOss, changePreviewListResource } from "@/api/system/oss"; |
| | | import { downLoadOss } from "@/utils/download"; |
| | | |
| | | export default { |
| | | name: "Oss", |
| | |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | | checkFileSuffix(fileSuffix) { |
| | | let arr = ["png", "jpg", "jpeg"]; |
| | | return arr.some(type => { |
| | | return fileSuffix.indexOf(type) > -1; |
| | | }); |
| | | }, |
| | | // åæ¶æé® |
| | | cancel() { |
| | | this.open = false; |
| | |
| | | this.ids = selection.map(item => item.ossId) |
| | | this.single = selection.length!==1 |
| | | this.multiple = !selection.length |
| | | }, |
| | | /** 任塿¥å¿å表æ¥è¯¢ */ |
| | | handleOssConfig() { |
| | | this.$router.push({ path: '/system/oss-config/index'}) |
| | | }, |
| | | /** æä»¶æé®æä½ */ |
| | | handleFile() { |
| | |
| | | this.loading = false; |
| | | this.getList(); |
| | | this.msgSuccess("å 餿å"); |
| | | }).catch(() => {}); |
| | | }).finally(() => { |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | | // é¢è§å表å¾çç¶æä¿®æ¹ |
| | | handlePreviewListResource(previewListResource) { |
| | | let text = previewListResource ? "å¯ç¨" : "åç¨"; |
| | | this.$confirm( |
| | | '确认è¦"' + text + '""é¢è§å表å¾ç"é
ç½®å?', "è¦å", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning", |
| | | }).then(() => { |
| | | return changePreviewListResource(previewListResource); |
| | | }).then(() => { |
| | | this.getList() |
| | | this.msgSuccess(text + "æå"); |
| | | }).catch(() => { |
| | | this.previewListResource = previewListResource !== true; |
| | | }) |
| | | } |
| | | } |
| | | }; |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { listPost, getPost, delPost, addPost, updatePost, exportPost } from "@/api/system/post"; |
| | | import { listPost, getPost, delPost, addPost, updatePost } from "@/api/system/post"; |
| | | import { downLoadExcel } from "@/utils/download"; |
| | | |
| | | export default { |
| | | name: "Post", |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | const queryParams = this.queryParams; |
| | | this.$confirm('æ¯å¦ç¡®è®¤å¯¼åºææå²ä½æ°æ®é¡¹?', "è¦å", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.exportLoading = true; |
| | | return exportPost(queryParams); |
| | | }).then(response => { |
| | | this.download(response.msg); |
| | | this.exportLoading = false; |
| | | }).catch(() => {}); |
| | | downLoadExcel('/system/post/export', this.queryParams); |
| | | } |
| | | } |
| | | }; |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { listRole, getRole, delRole, addRole, updateRole, exportRole, dataScope, changeRoleStatus } from "@/api/system/role"; |
| | | import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus } from "@/api/system/role"; |
| | | import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu"; |
| | | import { treeselect as deptTreeselect, roleDeptTreeselect } from "@/api/system/dept"; |
| | | import { downLoadExcel } from "@/utils/download"; |
| | | |
| | | export default { |
| | | name: "Role", |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | const queryParams = this.queryParams; |
| | | this.$confirm('æ¯å¦ç¡®è®¤å¯¼åºææè§è²æ°æ®é¡¹?', "è¦å", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.exportLoading = true; |
| | | return exportRole(queryParams); |
| | | }).then(response => { |
| | | this.download(response.msg); |
| | | this.exportLoading = false; |
| | | }).catch(() => {}); |
| | | downLoadExcel('/system/role/export', this.queryParams); |
| | | } |
| | | } |
| | | }; |
| | |
| | | props: {
|
| | | // è§è²ç¼å·
|
| | | roleId: {
|
| | | type: Number
|
| | | type: [Number, String]
|
| | | }
|
| | | },
|
| | | data() {
|
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { listUser, getUser, delUser, addUser, updateUser, exportUser, resetUserPwd, changeUserStatus, importTemplate } from "@/api/system/user"; |
| | | import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus } from "@/api/system/user"; |
| | | import { getToken } from "@/utils/auth"; |
| | | import { treeselect } from "@/api/system/dept"; |
| | | import Treeselect from "@riophae/vue-treeselect"; |
| | | import "@riophae/vue-treeselect/dist/vue-treeselect.css"; |
| | | import { downLoadExcel } from "@/utils/download"; |
| | | |
| | | export default { |
| | | name: "User", |
| | |
| | | // è¡¨åæ ¡éª |
| | | rules: { |
| | | userName: [ |
| | | { required: true, message: "ç¨æ·åç§°ä¸è½ä¸ºç©º", trigger: "blur" } |
| | | { required: true, message: "ç¨æ·åç§°ä¸è½ä¸ºç©º", trigger: "blur" }, |
| | | { min: 2, max: 20, message: 'ç¨æ·åç§°é¿åº¦å¿
é¡»ä»äº 2 å 20 ä¹é´', trigger: 'blur' } |
| | | ], |
| | | nickName: [ |
| | | { required: true, message: "ç¨æ·æµç§°ä¸è½ä¸ºç©º", trigger: "blur" } |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | const queryParams = this.queryParams; |
| | | this.$confirm('æ¯å¦ç¡®è®¤å¯¼åºææç¨æ·æ°æ®é¡¹?', "è¦å", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.exportLoading = true; |
| | | return exportUser(queryParams); |
| | | }).then(response => { |
| | | this.download(response.msg); |
| | | this.exportLoading = false; |
| | | }).catch(() => {}); |
| | | downLoadExcel('/system/user/export', this.queryParams); |
| | | }, |
| | | /** 导å
¥æé®æä½ */ |
| | | handleImport() { |
| | |
| | | }, |
| | | /** ä¸è½½æ¨¡æ¿æä½ */ |
| | | importTemplate() { |
| | | importTemplate().then(response => { |
| | | this.download(response.msg); |
| | | }); |
| | | downLoadExcel('/system/user/importTemplate'); |
| | | }, |
| | | // æä»¶ä¸ä¼ ä¸å¤ç |
| | | handleFileUploadProgress(event, file, fileList) { |
| | |
| | | autoCrop: true, // æ¯å¦é»è®¤çææªå¾æ¡ |
| | | autoCropWidth: 200, // é»è®¤çææªå¾æ¡å®½åº¦ |
| | | autoCropHeight: 200, // é»è®¤çææªå¾æ¡é«åº¦ |
| | | fixedBox: true // åºå®æªå¾æ¡å¤§å° ä¸å
许æ¹å |
| | | fixedBox: true, // åºå®æªå¾æ¡å¤§å° ä¸å
许æ¹å |
| | | filename: '' |
| | | }, |
| | | previews: {} |
| | | }; |
| | |
| | | reader.readAsDataURL(file); |
| | | reader.onload = () => { |
| | | this.options.img = reader.result; |
| | | this.options.filename = file.name; |
| | | }; |
| | | } |
| | | }, |
| | |
| | | uploadImg() { |
| | | this.$refs.cropper.getCropBlob(data => { |
| | | let formData = new FormData(); |
| | | formData.append("avatarfile", data); |
| | | console.log(this.options.filename) |
| | | formData.append("avatarfile", data, this.options.filename); |
| | | uploadAvatar(formData).then(response => { |
| | | this.open = false; |
| | | this.options.img = process.env.VUE_APP_BASE_API + response.data.imgUrl; |
| | | this.options.img = response.data.imgUrl; |
| | | store.commit('SET_AVATAR', this.options.img); |
| | | this.msgSuccess("ä¿®æ¹æå"); |
| | | this.visible = false; |
| | |
| | | <script> |
| | | import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen"; |
| | | import importTable from "./importTable"; |
| | | import { downLoadZip } from "@/utils/zipdownload"; |
| | | import { downLoadZip } from "@/utils/download"; |
| | | import hljs from "highlight.js/lib/highlight"; |
| | | import "highlight.js/styles/github-gist.css"; |
| | | hljs.registerLanguage("java", require("highlight.js/lib/languages/java")); |
| | |
| | | primary key (oss_id) |
| | | ) engine=innodb comment ='OSSäºåå¨è¡¨'; |
| | | |
| | | insert into sys_config values(10, 'OSSäºå卿å¡å', 'sys.oss.cloudStorageService', 'minio', 'Y', 'admin', sysdate(), '', null, 'OSSäºå卿å¡å(qiniu:ä¸çäº, aliyun:é¿éäº, qcloud:è
¾è®¯äº, minio: Minio)'); |
| | | -- ---------------------------- |
| | | -- OSSäºåå¨å¨æé
置表 |
| | | -- ---------------------------- |
| | | drop table if exists sys_oss_config; |
| | | create table sys_oss_config ( |
| | | oss_config_id bigint(20) not null auto_increment comment '主建', |
| | | config_key varchar(255) not null default '' comment 'é
ç½®key', |
| | | access_key varchar(255) default '' comment 'accessKey', |
| | | secret_key varchar(255) default '' comment 'ç§é¥', |
| | | bucket_name varchar(255) default '' comment 'æ¡¶åç§°', |
| | | prefix varchar(255) default '' comment 'åç¼', |
| | | endpoint varchar(255) default '' comment '访é®ç«ç¹', |
| | | is_https char(1) default 'N' comment 'æ¯å¦httpsï¼Y=æ¯,N=å¦ï¼', |
| | | region varchar(255) default '' comment 'å', |
| | | status char(1) default '1' comment 'ç¶æï¼0=æ£å¸¸,1=åç¨ï¼', |
| | | ext1 varchar(255) default '' comment 'æ©å±å段', |
| | | create_by varchar(64) default '' comment 'å建è
', |
| | | create_time datetime default null comment 'å建æ¶é´', |
| | | update_by varchar(64) default '' comment 'æ´æ°è
', |
| | | update_time datetime default null comment 'æ´æ°æ¶é´', |
| | | remark varchar(500) default null comment '夿³¨', |
| | | primary key (oss_config_id) |
| | | ) engine=innodb comment='äºåå¨é
置表'; |
| | | |
| | | insert into sys_config values(11, 'OSSé¢è§åè¡¨èµæºå¼å
³', 'sys.oss.previewListResource', 'true', 'Y', 'admin', sysdate(), '', null, 'true:å¼å¯, false:å
³é'); |
| | | |
| | | insert into sys_menu values('118', 'æä»¶ç®¡ç', '1', '10', 'oss', 'system/oss/index', 1, 0, 'C', '0', '0', 'system:oss:list', 'upload', 'admin', sysdate(), '', null, 'æä»¶ç®¡çèå'); |
| | |
| | | insert into sys_menu values('1601', 'æä»¶ä¸ä¼ ', '118', '2', '#', '', 1, 0, 'F', '0', '0', 'system:oss:upload', '#', 'admin', sysdate(), '', null, ''); |
| | | insert into sys_menu values('1602', 'æä»¶ä¸è½½', '118', '3', '#', '', 1, 0, 'F', '0', '0', 'system:oss:download', '#', 'admin', sysdate(), '', null, ''); |
| | | insert into sys_menu values('1603', 'æä»¶å é¤', '118', '4', '#', '', 1, 0, 'F', '0', '0', 'system:oss:remove', '#', 'admin', sysdate(), '', null, ''); |
| | | insert into sys_menu values('1604', 'é
置添å ', '118', '5', '#', '', 1, 0, 'F', '0', '0', 'system:oss:add', '#', 'admin', sysdate(), '', null, ''); |
| | | insert into sys_menu values('1605', 'é
ç½®ç¼è¾', '118', '6', '#', '', 1, 0, 'F', '0', '0', 'system:oss:edit', '#', 'admin', sysdate(), '', null, ''); |
| | | |
| | | insert into sys_oss_config values (1, 'minio', 'ruoyi', 'ruoyi123', 'ruoyi', '', 'http://localhost:9000', 'N', '', '0', '', 'admin', sysdate(), 'admin', sysdate(), NULL); |
| | | insert into sys_oss_config values (2, 'qiniu', 'XXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXX', 'ruoyi', '', 'http://XXX.XXXX.com', 'N', 'z0', '1', '', 'admin', sysdate(), 'admin', sysdate(), NULL); |
| | | insert into sys_oss_config values (3, 'aliyun', 'XXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXX', 'ruoyi', '', 'http://oss-cn-beijing.aliyuncs.com', 'N', '', '1', '', 'admin', sysdate(), 'admin', sysdate(), NULL); |
| | | insert into sys_oss_config values (4, 'qcloud', 'XXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXX', 'ruoyi-1250000000', '', 'http://cos.ap-beijing.myqcloud.com', 'N', 'ap-beijing', '1', '', 'admin', sysdate(), 'admin', sysdate(), NULL); |
ÎļþÃû´Ó sql/ry_20210713.sql ÐÞ¸Ä |
| | |
| | | insert into sys_config values(1, 'ä¸»æ¡æ¶é¡µ-é»è®¤ç®è¤æ ·å¼åç§°', 'sys.index.skinName', 'skin-blue', 'Y', 'admin', sysdate(), '', null, 'èè² skin-blueãç»¿è² skin-greenãç´«è² skin-purpleãçº¢è² skin-redãé»è² skin-yellow' ); |
| | | insert into sys_config values(2, 'ç¨æ·ç®¡ç-è´¦å·åå§å¯ç ', 'sys.user.initPassword', '123456', 'Y', 'admin', sysdate(), '', null, 'åå§åå¯ç 123456' ); |
| | | insert into sys_config values(3, 'ä¸»æ¡æ¶é¡µ-ä¾§è¾¹æ 主é¢', 'sys.index.sideTheme', 'theme-dark', 'Y', 'admin', sysdate(), '', null, 'æ·±è²ä¸»é¢theme-darkï¼æµ
è²ä¸»é¢theme-light' ); |
| | | insert into sys_config values(4, 'è´¦å·èªå©-éªè¯ç å¼å
³', 'sys.account.captchaOnOff', 'true', 'Y', 'admin', sysdate(), '', null, 'æ¯å¦å¼å¯ç»å½éªè¯ç åè½ï¼trueå¼å¯ï¼falseå
³éï¼'); |
| | | insert into sys_config values(4, 'è´¦å·èªå©-éªè¯ç å¼å
³', 'sys.account.captchaOnOff', 'true', 'Y', 'admin', sysdate(), '', null, 'æ¯å¦å¼å¯éªè¯ç åè½ï¼trueå¼å¯ï¼falseå
³éï¼'); |
| | | insert into sys_config values(5, 'è´¦å·èªå©-æ¯å¦å¼å¯ç¨æ·æ³¨ååè½', 'sys.account.registerUser', 'false', 'Y', 'admin', sysdate(), '', null, 'æ¯å¦å¼å¯æ³¨åç¨æ·åè½ï¼trueå¼å¯ï¼falseå
³éï¼'); |
| | | |
| | | |
| | | -- ---------------------------- |