Merge remote-tracking branch 'origin/dev'
# Conflicts:
# README.md
# docker/docker-compose.yml
# pom.xml
# ruoyi-admin/pom.xml
# ruoyi-admin/src/main/resources/application-dev.yml
# ruoyi-admin/src/main/resources/application-prod.yml
# ruoyi-common/pom.xml
# ruoyi-demo/pom.xml
# ruoyi-extend/pom.xml
# ruoyi-extend/ruoyi-monitor-admin/pom.xml
# ruoyi-framework/pom.xml
# ruoyi-generator/pom.xml
# ruoyi-generator/src/main/resources/vm/java/editBo.java.vm
# ruoyi-generator/src/main/resources/vm/java/queryBo.java.vm
# ruoyi-quartz/pom.xml
# ruoyi-system/pom.xml
# ruoyi-ui/package.json
# ruoyi-ui/src/views/index.vue
已修改86个文件
已添加32个文件
已重命名2个文件
已删除9个文件
| | |
| | | [](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) |
| | | []() |
| | | []() |
| | | []() |
| | | |
| | | RuoYi-Vue-Plus æ¯åºäº RuoYi-Vue é对 `åå¸å¼é群` åºæ¯å级 å®æä¸ RuoYi-Vue 忥 |
| | | |
| | | éæ Lock4j dynamic-datasource çåå¸å¼åºæ¯è§£å³æ¹æ¡ |
| | | éæ Lock4j dynamic-datasource OSSåå¨ çåå¸å¼åºæ¯è§£å³æ¹æ¡ |
| | | |
| | | éæ Mybatis-Plus Lombok Hutool ç便æ·å¼åå·¥å
· éé
éåç¸å
³ä¸å¡ 便äºå¼å |
| | | |
| | |
| | | * Redis客æ·ç«¯ éç¨ Redisson æ§è½æ´å¼º |
| | | * åå¸å¼é Lock4j 注解éãå·¥å
·é å¤ç§å¤æ · |
| | | * é¨ç½²æ¹å¼ Docker 容å¨ç¼æ ä¸é®é¨ç½²ä¸å¡é群 |
| | | * æä»¶åå¨ OSS 对象å卿¨¡å æ¯æ(Minioãä¸çãé¿éãè
¾è®¯) |
| | | |
| | | ## åèææ¡£ |
| | | |
| | |
| | | * éæ dynamic-datasource 夿°æ®æº(é»è®¤æ¯æMySQL,å
¶ä»ç§ç±»éèªè¡éé
) |
| | | * éæ Lock4j å®ç°åå¸å¼ 注解éãå·¥å
·é å¤ç§å¤æ · |
| | | * å¢å Docker 容å¨ç¼æ æå
æä»¶ä¸é¨ç½²èæ¬ |
| | | * ç§»é¤ æ¬å°æä»¶ä¸ä¼ æ¹ä¸º OSS对象åå¨ æ¯æ(Minioãä¸çãé¿éãè
¾è®¯) |
| | | |
| | | ### ä»£ç æ¹å¨ |
| | | |
| | | * ææåçåè½ä½¿ç¨ Mybatis-Plus ä¸ Lombok éå |
| | | * å¢å IServicePlus ä¸ BaseMapperPlus å¯èªå®ä¹éç¨æ¹æ³ |
| | | * 代ç çææ¨¡æ¿ æ¹ä¸ºéé
Mybatis-Plus ç代ç |
| | | * 代ç çææ¨¡æ¿ æååº Vo,QueryBo,AddBo,EditBo çé¢å对象 |
| | | * 代ç çææ¨¡æ¿ æ ¹æ® Alibaba 代ç è§çº¦ æååº VOãBO çé¢å对象 |
| | | * 代ç çææ¨¡æ¿ å¢å ææ¡£æ³¨è§£ ä¸ æ ¡éªæ³¨è§£ ç®åéç¨æä½ |
| | | * 项ç®ä¿®æ¹ä¸º mavenå¤ç¯å¢é
ç½® |
| | | * 项ç®é
置修æ¹ä¸º application.yml ç»ä¸ç®¡ç |
| | |
| | | exit 1 |
| | | } |
| | | |
| | | #å¼å¯æéç«¯å£ |
| | | #å¼å¯æé端å£(ç产ç¯å¢ä¸æ¨èå¼å¯) |
| | | port(){ |
| | | # mysql ç«¯å£ |
| | | firewall-cmd --add-port=3306/tcp --permanent |
| | | # redis ç«¯å£ |
| | | firewall-cmd --add-port=6379/tcp --permanent |
| | | # minio api ç«¯å£ |
| | | firewall-cmd --add-port=9000/tcp --permanent |
| | | # minio æ§å¶å°ç«¯å£ |
| | | firewall-cmd --add-port=9001/tcp --permanent |
| | | # éå¯é²ç«å¢ |
| | | service firewalld restart |
| | | } |
| | | |
| | |
| | | |
| | | #å¯å¨åºç¡æ¨¡å |
| | | base(){ |
| | | docker-compose up -d mysql nginx-web redis |
| | | docker-compose up -d mysql nginx-web redis minio |
| | | } |
| | | |
| | | #å¯å¨åºç¡æ¨¡å |
| | |
| | | - /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 |
| | |
| | | - /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 |
| | |
| | | ruoyi_net: |
| | | ipv4_address: 172.30.0.48 |
| | | |
| | | minio: |
| | | image: minio/minio:RELEASE.2021-07-08T01-15-01Z |
| | | hostname: "minio" |
| | | ports: |
| | | # api ç«¯å£ |
| | | - 9000:9000 |
| | | # æ§å¶å°ç«¯å£ |
| | | - 9001:9001 |
| | | environment: |
| | | # 管çåå°ç¨æ·å |
| | | MINIO_ACCESS_KEY: ruoyi |
| | | # 管çåå°å¯ç ï¼æå°8个å符 |
| | | MINIO_SECRET_KEY: ruoyi123 |
| | | volumes: |
| | | # æ å°å½åç®å½ä¸çdataç®å½è³å®¹å¨å
/dataç®å½ |
| | | - /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 |
| | | networks: |
| | | ruoyi_net: |
| | | ipv4_address: 172.30.0.54 |
| | | |
| | | ruoyi-server1: |
| | | image: "ruoyi/ruoyi-server:2.5.2" |
| | | image: "ruoyi/ruoyi-server:2.6.0" |
| | | environment: |
| | | - TZ=Asia/Shanghai |
| | | volumes: |
| | |
| | | ipv4_address: 172.30.0.60 |
| | | |
| | | ruoyi-server2: |
| | | image: "ruoyi/ruoyi-server:2.5.2" |
| | | image: "ruoyi/ruoyi-server:2.6.0" |
| | | environment: |
| | | - TZ=Asia/Shanghai |
| | | volumes: |
| | |
| | | ipv4_address: 172.30.0.61 |
| | | |
| | | ruoyi-monitor-admin: |
| | | image: "ruoyi/ruoyi-monitor-admin:2.5.2" |
| | | image: "ruoyi/ruoyi-monitor-admin:2.6.0" |
| | | environment: |
| | | - TZ=Asia/Shanghai |
| | | privileged: true |
| | |
| | | |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <version>2.5.2</version> |
| | | <version>2.6.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.5.2</ruoyi-vue-plus.version> |
| | | <spring-boot.version>2.4.8</spring-boot.version> |
| | | <ruoyi-vue-plus.version>2.6.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> |
| | | <java.version>1.8</java.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.4</hutool.version> |
| | | <hutool.version>5.7.6</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> |
| | | <redisson.version>3.16.0</redisson.version> |
| | | <redisson.version>3.16.1</redisson.version> |
| | | <lock4j.version>2.2.1</lock4j.version> |
| | | <datasource.version>3.4.0</datasource.version> |
| | | <datasource.version>3.4.1</datasource.version> |
| | | |
| | | <!-- OSS é
ç½® --> |
| | | <qiniu.version>7.8.0</qiniu.version> |
| | | <aliyun.oss.version>3.13.0</aliyun.oss.version> |
| | | <qcloud.cos.version>5.6.47</qcloud.cos.version> |
| | | <minio.version>8.3.0</minio.version> |
| | | |
| | | <!-- docker é
ç½® --> |
| | | <docker.registry.url>localhost</docker.registry.url> |
| | | <docker.registry.host>http://${docker.registry.url}:2375</docker.registry.host> |
| | | <docker.namespace>ruoyi</docker.namespace> |
| | | <docker.plugin.version>1.2.0</docker.plugin.version> |
| | | <docker.plugin.version>1.2.2</docker.plugin.version> |
| | | </properties> |
| | | |
| | | <!-- ä¾èµå£°æ --> |
| | |
| | | <!-- demo模å --> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-oss</artifactId> |
| | | <version>${ruoyi-vue-plus.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- demo模å --> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-demo</artifactId> |
| | | <version>${ruoyi-vue-plus.version}</version> |
| | | </dependency> |
| | |
| | | <module>ruoyi-common</module> |
| | | <module>ruoyi-demo</module> |
| | | <module>ruoyi-extend</module> |
| | | <module>ruoyi-oss</module> |
| | | </modules> |
| | | <packaging>pom</packaging> |
| | | |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.5.2</version> |
| | | <version>2.6.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <packaging>jar</packaging> |
| | |
| | | <artifactId>ruoyi-quartz</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-oss</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- 代ç çæ--> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.file.FileUploadUtils; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | | import com.ruoyi.framework.config.ServerConfig; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * éç¨è¯·æ±å¤ç |
| | |
| | | public class CommonController |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(CommonController.class); |
| | | |
| | | @Autowired |
| | | private ServerConfig serverConfig; |
| | | |
| | | /** |
| | | * éç¨ä¸è½½è¯·æ± |
| | |
| | | catch (Exception e) |
| | | { |
| | | log.error("ä¸è½½æä»¶å¤±è´¥", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * éç¨ä¸ä¼ è¯·æ± |
| | | */ |
| | | @PostMapping("/common/upload") |
| | | public AjaxResult uploadFile(MultipartFile file) throws Exception |
| | | { |
| | | try |
| | | { |
| | | // ä¸ä¼ æä»¶è·¯å¾ |
| | | String filePath = RuoYiConfig.getUploadPath(); |
| | | // ä¸ä¼ å¹¶è¿åæ°æä»¶åç§° |
| | | String fileName = FileUploadUtils.upload(filePath, file); |
| | | String url = serverConfig.getUrl() + fileName; |
| | | Map<String,Object> ajax = new HashMap<>(); |
| | | ajax.put("fileName", fileName); |
| | | ajax.put("url", url); |
| | | return AjaxResult.success(ajax); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | return AjaxResult.error("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'失败ï¼é®ç®±è´¦å·å·²åå¨"); |
| | | } |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | SysUser sysUser = loginUser.getUser(); |
| | | user.setUserId(sysUser.getUserId()); |
| | | user.setPassword(null); |
| | | if (userService.updateUserProfile(user) > 0) |
| | | { |
| | | LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); |
| | | // æ´æ°ç¼åç¨æ·ä¿¡æ¯ |
| | | loginUser.getUser().setNickName(user.getNickName()); |
| | | loginUser.getUser().setPhonenumber(user.getPhonenumber()); |
| | |
| | | testOnReturn: false |
| | | # 注æè¿ä¸ªå¼ådruidåçä¸ä¸è´ï¼é»è®¤å¯å¨äºstat |
| | | filters: stat |
| | | |
| | | --- # druid é
ç½® |
| | | spring: |
| | | datasource: |
| | | druid: |
| | | webStatFilter: |
| | | enabled: true |
| | |
| | | wall: |
| | | config: |
| | | multi-statement-allow: true |
| | | # redis é
ç½® |
| | | |
| | | --- # redis é
ç½® |
| | | spring: |
| | | redis: |
| | | # å°å |
| | | host: localhost |
| | |
| | | # æ¯å¦å¼å¯ssl |
| | | ssl: false |
| | | |
| | | --- # redisson 客æ·ç«¯é
ç½® |
| | | redisson: |
| | | # çº¿ç¨æ± æ°é |
| | | threads: 16 |
| | |
| | | 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 |
| | |
| | | testOnReturn: false |
| | | # 注æè¿ä¸ªå¼ådruidåçä¸ä¸è´ï¼é»è®¤å¯å¨äºstat |
| | | filters: stat |
| | | |
| | | --- # druid é
ç½® |
| | | spring: |
| | | datasource: |
| | | druid: |
| | | webStatFilter: |
| | | enabled: true |
| | |
| | | wall: |
| | | config: |
| | | multi-statement-allow: true |
| | | # redis é
ç½® |
| | | |
| | | --- # redis é
ç½® |
| | | spring: |
| | | redis: |
| | | # å°å |
| | | host: 172.30.0.48 |
| | |
| | | # æ¯å¦å¼å¯ssl |
| | | ssl: false |
| | | |
| | | --- # redisson 客æ·ç«¯é
ç½® |
| | | redisson: |
| | | # çº¿ç¨æ± æ°é |
| | | threads: 16 |
| | |
| | | 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 |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.5.2</version> |
| | | <version>2.6.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | |
| | | package com.ruoyi.common.core.mybatisplus.core; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * èªå®ä¹ Service æ¥å£, å®ç° æ°æ®åºå®ä½ä¸ vo 对象转æ¢è¿å |
| | |
| | | * @author Lion Li |
| | | * @since 2021-05-13 |
| | | */ |
| | | public interface IServicePlus<T> extends IService<T> { |
| | | public interface IServicePlus<T, K> extends IService<T> { |
| | | |
| | | /** |
| | | * æ ¹æ® ID æ¥è¯¢ |
| | | * |
| | | * @param kClass voç±»å |
| | | * @param id 主é®ID |
| | | */ |
| | | default <K> K getVoById(Serializable id, Class<K> kClass) { |
| | | T t = getBaseMapper().selectById(id); |
| | | return BeanUtil.toBean(t, kClass); |
| | | } |
| | | /** |
| | | * @param id 主é®id |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @return K对象 |
| | | */ |
| | | K getVoById(Serializable id, CopyOptions copyOptions); |
| | | |
| | | /** |
| | | * æ ¹æ® ID æ¥è¯¢ |
| | | * |
| | | * @param id 主é®ID |
| | | * @param convertor 转æ¢å½æ° |
| | | * @param <K> voç±»å |
| | | */ |
| | | default <K> K getVoById(Serializable id, Function<T, K> convertor) { |
| | | T t = getBaseMapper().selectById(id); |
| | | return convertor.apply(t); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ï¼æ ¹æ®ID æ¹éæ¥è¯¢ï¼ |
| | | * |
| | | * @param kClass voç±»å |
| | | * @param idList 主é®IDå表 |
| | | */ |
| | | default <K> List<K> listVoByIds(Collection<? extends Serializable> idList, Class<K> kClass) { |
| | | List<T> list = getBaseMapper().selectBatchIds(idList); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return list.stream() |
| | | .map(any -> BeanUtil.toBean(any, kClass)) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ï¼æ ¹æ®ID æ¹éæ¥è¯¢ï¼ |
| | | * |
| | | * @param convertor 转æ¢å½æ° |
| | | * @param idList 主é®IDå表 |
| | | */ |
| | | default <K> List<K> listVoByIds(Collection<? extends Serializable> idList, |
| | | Function<Collection<T>, List<K>> convertor) { |
| | | List<T> list = getBaseMapper().selectBatchIds(idList); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return convertor.apply(list); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ï¼æ ¹æ® columnMap æ¡ä»¶ï¼ |
| | | * |
| | | * @param kClass voç±»å |
| | | * @param columnMap è¡¨åæ®µ map 对象 |
| | | */ |
| | | default <K> List<K> listVoByMap(Map<String, Object> columnMap, Class<K> kClass) { |
| | | List<T> list = getBaseMapper().selectByMap(columnMap); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return list.stream() |
| | | .map(any -> BeanUtil.toBean(any, kClass)) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ï¼æ ¹æ® columnMap æ¡ä»¶ï¼ |
| | | * |
| | | * @param convertor 转æ¢å½æ° |
| | | * @param columnMap è¡¨åæ®µ map 对象 |
| | | */ |
| | | default <K> List<K> listVoByMap(Map<String, Object> columnMap, |
| | | Function<Collection<T>, List<K>> convertor) { |
| | | List<T> list = getBaseMapper().selectByMap(columnMap); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return convertor.apply(list); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ® Wrapperï¼æ¥è¯¢ä¸æ¡è®°å½ <br/> |
| | | * <p>ç»æéï¼å¦ææ¯å¤ä¸ªä¼æåºå¼å¸¸ï¼éæºå䏿¡å ä¸éå¶æ¡ä»¶ wrapper.last("LIMIT 1")</p> |
| | | * |
| | | * @param kClass voç±»å |
| | | * @param queryWrapper å®ä½å¯¹è±¡å°è£
æä½ç±» {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper} |
| | | */ |
| | | default <K> K getVoOne(Wrapper<T> queryWrapper, Class<K> kClass) { |
| | | return BeanUtil.toBean(getOne(queryWrapper, true), kClass); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ® Wrapperï¼æ¥è¯¢ä¸æ¡è®°å½ <br/> |
| | | * <p>ç»æéï¼å¦ææ¯å¤ä¸ªä¼æåºå¼å¸¸ï¼éæºå䏿¡å ä¸éå¶æ¡ä»¶ wrapper.last("LIMIT 1")</p> |
| | | * |
| | | * @param convertor 转æ¢å½æ° |
| | | * @param queryWrapper å®ä½å¯¹è±¡å°è£
æä½ç±» {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper} |
| | | */ |
| | | default <K> K getVoOne(Wrapper<T> queryWrapper, Function<T, K> convertor) { |
| | | return convertor.apply(getOne(queryWrapper, true)); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢å表 |
| | | * |
| | | * @param kClass voç±»å |
| | | * @param queryWrapper å®ä½å¯¹è±¡å°è£
æä½ç±» {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper} |
| | | */ |
| | | default <K> List<K> listVo(Wrapper<T> queryWrapper, Class<K> kClass) { |
| | | List<T> list = getBaseMapper().selectList(queryWrapper); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return list.stream() |
| | | .map(any -> BeanUtil.toBean(any, kClass)) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢å表 |
| | | * |
| | | * @param convertor 转æ¢å½æ° |
| | | * @param queryWrapper å®ä½å¯¹è±¡å°è£
æä½ç±» {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper} |
| | | */ |
| | | default <K> List<K> listVo(Wrapper<T> queryWrapper, Function<Collection<T>, List<K>> convertor) { |
| | | List<T> list = getBaseMapper().selectList(queryWrapper); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return convertor.apply(list); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ææ |
| | | * |
| | | * @param kClass voç±»å |
| | | * @see Wrappers#emptyWrapper() |
| | | */ |
| | | default <K> List<K> listVo(Class<K> kClass) { |
| | | return listVo(Wrappers.emptyWrapper(), kClass); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ææ |
| | | * |
| | | * @param convertor 转æ¢å½æ° |
| | | * @see Wrappers#emptyWrapper() |
| | | */ |
| | | default <K> List<K> listVo(Function<Collection<T>, List<K>> convertor) { |
| | | return listVo(Wrappers.emptyWrapper(), convertor); |
| | | } |
| | | |
| | | /** |
| | | * 翻页æ¥è¯¢ |
| | | * |
| | | * @param page 翻页对象 |
| | | * @param queryWrapper å®ä½å¯¹è±¡å°è£
æä½ç±» |
| | | */ |
| | | default <K> PagePlus<T, K> pageVo(PagePlus<T, K> page, Wrapper<T> queryWrapper, Class<K> kClass) { |
| | | PagePlus<T, K> result = getBaseMapper().selectPage(page, queryWrapper); |
| | | List<K> volist = result.getRecords().stream() |
| | | .map(any -> BeanUtil.toBean(any, kClass)) |
| | | .collect(Collectors.toList()); |
| | | result.setRecordsVo(volist); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 翻页æ¥è¯¢ |
| | | * |
| | | * @param page 翻页对象 |
| | | * @param queryWrapper å®ä½å¯¹è±¡å°è£
æä½ç±» |
| | | * @param convertor 转æ¢å½æ° |
| | | */ |
| | | default <K> PagePlus<T, K> pageVo(PagePlus<T, K> page, Wrapper<T> queryWrapper, |
| | | Function<Collection<T>, List<K>> convertor) { |
| | | PagePlus<T, K> result = getBaseMapper().selectPage(page, queryWrapper); |
| | | return result.setRecordsVo(convertor.apply(result.getRecords())); |
| | | } |
| | | |
| | | /** |
| | | * æ æ¡ä»¶ç¿»é¡µæ¥è¯¢ |
| | | * |
| | | * @param page 翻页对象 |
| | | */ |
| | | default <K> PagePlus<T, K> pageVo(PagePlus<T, K> page, Class<K> kClass) { |
| | | return pageVo(page, Wrappers.emptyWrapper(), kClass); |
| | | } |
| | | |
| | | /** |
| | | * æ æ¡ä»¶ç¿»é¡µæ¥è¯¢ |
| | | * |
| | | * @param page 翻页对象 |
| | | * @param convertor 转æ¢å½æ° |
| | | */ |
| | | default <K> PagePlus<T, K> pageVo(PagePlus<T, K> page, Function<Collection<T>, List<K>> convertor) { |
| | | return pageVo(page, Wrappers.emptyWrapper(), convertor); |
| | | } |
| | | |
| | | @Override |
| | | default boolean saveBatch(Collection<T> entityList) { |
| | | return saveBatch(entityList, DEFAULT_BATCH_SIZE); |
| | | default K getVoById(Serializable id) { |
| | | return getVoById(id, new CopyOptions()); |
| | | } |
| | | |
| | | @Override |
| | | default boolean saveOrUpdateBatch(Collection<T> entityList) { |
| | | return saveOrUpdateBatch(entityList, DEFAULT_BATCH_SIZE); |
| | | /** |
| | | * @param convertor èªå®ä¹è½¬æ¢å¨ |
| | | */ |
| | | default K getVoById(Serializable id, Function<T, K> convertor) { |
| | | return convertor.apply(getById(id)); |
| | | } |
| | | |
| | | @Override |
| | | default boolean updateBatchById(Collection<T> entityList) { |
| | | return updateBatchById(entityList, DEFAULT_BATCH_SIZE); |
| | | /** |
| | | * @param idList idå表 |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @return K对象 |
| | | */ |
| | | List<K> listVoByIds(Collection<? extends Serializable> idList, CopyOptions copyOptions); |
| | | |
| | | default List<K> listVoByIds(Collection<? extends Serializable> idList) { |
| | | return listVoByIds(idList, new CopyOptions()); |
| | | } |
| | | |
| | | /** |
| | | * @param convertor èªå®ä¹è½¬æ¢å¨ |
| | | */ |
| | | default List<K> listVoByIds(Collection<? extends Serializable> idList, |
| | | Function<Collection<T>, List<K>> convertor) { |
| | | List<T> list = getBaseMapper().selectBatchIds(idList); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return convertor.apply(list); |
| | | } |
| | | |
| | | /** |
| | | * @param columnMap è¡¨åæ®µ map 对象 |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @return K对象 |
| | | */ |
| | | List<K> listVoByMap(Map<String, Object> columnMap, CopyOptions copyOptions); |
| | | |
| | | default List<K> listVoByMap(Map<String, Object> columnMap) { |
| | | return listVoByMap(columnMap, new CopyOptions()); |
| | | } |
| | | |
| | | /** |
| | | * @param convertor èªå®ä¹è½¬æ¢å¨ |
| | | */ |
| | | default List<K> listVoByMap(Map<String, Object> columnMap, |
| | | Function<Collection<T>, List<K>> convertor) { |
| | | List<T> list = getBaseMapper().selectByMap(columnMap); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return convertor.apply(list); |
| | | } |
| | | |
| | | /** |
| | | * @param queryWrapper æ¥è¯¢æ¡ä»¶ |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @return K对象 |
| | | */ |
| | | K getVoOne(Wrapper<T> queryWrapper, CopyOptions copyOptions); |
| | | |
| | | default K getVoOne(Wrapper<T> queryWrapper) { |
| | | return getVoOne(queryWrapper, new CopyOptions()); |
| | | } |
| | | |
| | | /** |
| | | * @param convertor èªå®ä¹è½¬æ¢å¨ |
| | | */ |
| | | default K getVoOne(Wrapper<T> queryWrapper, Function<T, K> convertor) { |
| | | return convertor.apply(getOne(queryWrapper, true)); |
| | | } |
| | | |
| | | /** |
| | | * @param queryWrapper æ¥è¯¢æ¡ä»¶ |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @return K对象 |
| | | */ |
| | | List<K> listVo(Wrapper<T> queryWrapper, CopyOptions copyOptions); |
| | | |
| | | default List<K> listVo(Wrapper<T> queryWrapper) { |
| | | return listVo(queryWrapper, new CopyOptions()); |
| | | } |
| | | |
| | | /** |
| | | * @param convertor èªå®ä¹è½¬æ¢å¨ |
| | | */ |
| | | default List<K> listVo(Wrapper<T> queryWrapper, Function<Collection<T>, List<K>> convertor) { |
| | | List<T> list = getBaseMapper().selectList(queryWrapper); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return convertor.apply(list); |
| | | } |
| | | |
| | | default List<K> listVo() { |
| | | return listVo(Wrappers.emptyWrapper()); |
| | | } |
| | | |
| | | /** |
| | | * @param convertor èªå®ä¹è½¬æ¢å¨ |
| | | */ |
| | | default List<K> listVo(Function<Collection<T>, List<K>> convertor) { |
| | | return listVo(Wrappers.emptyWrapper(), convertor); |
| | | } |
| | | |
| | | /** |
| | | * @param page å页对象 |
| | | * @param queryWrapper æ¥è¯¢æ¡ä»¶ |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @return K对象 |
| | | */ |
| | | PagePlus<T, K> pageVo(PagePlus<T, K> page, Wrapper<T> queryWrapper, CopyOptions copyOptions); |
| | | |
| | | default PagePlus<T, K> pageVo(PagePlus<T, K> page, Wrapper<T> queryWrapper) { |
| | | return pageVo(page, queryWrapper, new CopyOptions()); |
| | | } |
| | | |
| | | /** |
| | | * @param convertor èªå®ä¹è½¬æ¢å¨ |
| | | */ |
| | | default PagePlus<T, K> pageVo(PagePlus<T, K> page, Wrapper<T> queryWrapper, |
| | | Function<Collection<T>, List<K>> convertor) { |
| | | PagePlus<T, K> result = getBaseMapper().selectPage(page, queryWrapper); |
| | | return result.setRecordsVo(convertor.apply(result.getRecords())); |
| | | } |
| | | |
| | | default PagePlus<T, K> pageVo(PagePlus<T, K> page) { |
| | | return pageVo(page, Wrappers.emptyWrapper()); |
| | | } |
| | | |
| | | /** |
| | | * @param convertor èªå®ä¹è½¬æ¢å¨ |
| | | */ |
| | | default PagePlus<T, K> pageVo(PagePlus<T, K> page, Function<Collection<T>, List<K>> convertor) { |
| | | return pageVo(page, Wrappers.emptyWrapper(), convertor); |
| | | } |
| | | |
| | | boolean saveAll(Collection<T> entityList); |
| | |
| | | package com.ruoyi.common.core.mybatisplus.core; |
| | | |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.ClassUtils; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.page.PagePlus; |
| | | import com.ruoyi.common.utils.BeanCopyUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.ResolvableType; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * IServicePlus å®ç°ç±» |
| | |
| | | */ |
| | | @Slf4j |
| | | @SuppressWarnings("unchecked") |
| | | public class ServicePlusImpl<M extends BaseMapperPlus<T>, T> extends ServiceImpl<M, T> implements IServicePlus<T> { |
| | | public class ServicePlusImpl<M extends BaseMapperPlus<T>, T, K> extends ServiceImpl<M, T> implements IServicePlus<T, K> { |
| | | |
| | | @Autowired |
| | | protected M baseMapper; |
| | |
| | | |
| | | protected Class<T> mapperClass = currentMapperClass(); |
| | | |
| | | protected Class<K> voClass = currentVoClass(); |
| | | |
| | | public Class<K> getVoClass() { |
| | | return voClass; |
| | | } |
| | | |
| | | @Override |
| | | protected Class<T> currentMapperClass() { |
| | | return (Class<T>) this.getResolvableType().as(ServicePlusImpl.class).getGeneric(0).getType(); |
| | |
| | | @Override |
| | | protected Class<T> currentModelClass() { |
| | | return (Class<T>) this.getResolvableType().as(ServicePlusImpl.class).getGeneric(1).getType(); |
| | | } |
| | | |
| | | protected Class<K> currentVoClass() { |
| | | return (Class<K>) this.getResolvableType().as(ServicePlusImpl.class).getGeneric(2).getType(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | * éç¨äºæ èæå
¥ |
| | | */ |
| | | @Override |
| | | public boolean saveBatch(Collection<T> entityList) { |
| | | return saveBatch(entityList, DEFAULT_BATCH_SIZE); |
| | | } |
| | | |
| | | @Override |
| | | public boolean saveOrUpdateBatch(Collection<T> entityList) { |
| | | return saveOrUpdateBatch(entityList, DEFAULT_BATCH_SIZE); |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateBatchById(Collection<T> entityList) { |
| | | return updateBatchById(entityList, DEFAULT_BATCH_SIZE); |
| | | } |
| | | |
| | | /** |
| | | * åsqlæ¹éæå
¥( å
¨éå¡«å
æ è§æ°æ®åºé»è®¤å¼ ) |
| | | * éç¨äºæ èæå
¥ |
| | | */ |
| | | @Override |
| | | public boolean saveAll(Collection<T> entityList) { |
| | | return baseMapper.insertAll(entityList) == entityList.size(); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ® ID æ¥è¯¢ |
| | | * |
| | | * @param id 主é®ID |
| | | */ |
| | | @Override |
| | | public K getVoById(Serializable id, CopyOptions copyOptions) { |
| | | T t = getBaseMapper().selectById(id); |
| | | return BeanCopyUtils.oneCopy(t, copyOptions, voClass); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ï¼æ ¹æ®ID æ¹éæ¥è¯¢ï¼ |
| | | * |
| | | * @param idList 主é®IDå表 |
| | | */ |
| | | @Override |
| | | public List<K> listVoByIds(Collection<? extends Serializable> idList, CopyOptions copyOptions) { |
| | | List<T> list = getBaseMapper().selectBatchIds(idList); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return BeanCopyUtils.listCopy(list, copyOptions, voClass); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ï¼æ ¹æ® columnMap æ¡ä»¶ï¼ |
| | | * |
| | | * @param columnMap è¡¨åæ®µ map 对象 |
| | | */ |
| | | @Override |
| | | public List<K> listVoByMap(Map<String, Object> columnMap, CopyOptions copyOptions) { |
| | | List<T> list = getBaseMapper().selectByMap(columnMap); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return BeanCopyUtils.listCopy(list, copyOptions, voClass); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ® Wrapperï¼æ¥è¯¢ä¸æ¡è®°å½ <br/> |
| | | * <p>ç»æéï¼å¦ææ¯å¤ä¸ªä¼æåºå¼å¸¸ï¼éæºå䏿¡å ä¸éå¶æ¡ä»¶ wrapper.last("LIMIT 1")</p> |
| | | * |
| | | * @param queryWrapper å®ä½å¯¹è±¡å°è£
æä½ç±» {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper} |
| | | */ |
| | | @Override |
| | | public K getVoOne(Wrapper<T> queryWrapper, CopyOptions copyOptions) { |
| | | T t = getOne(queryWrapper, true); |
| | | return BeanCopyUtils.oneCopy(t, copyOptions, voClass); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢å表 |
| | | * |
| | | * @param queryWrapper å®ä½å¯¹è±¡å°è£
æä½ç±» {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper} |
| | | */ |
| | | @Override |
| | | public List<K> listVo(Wrapper<T> queryWrapper, CopyOptions copyOptions) { |
| | | List<T> list = getBaseMapper().selectList(queryWrapper); |
| | | if (list == null) { |
| | | return null; |
| | | } |
| | | return BeanCopyUtils.listCopy(list, copyOptions, voClass); |
| | | } |
| | | |
| | | /** |
| | | * 翻页æ¥è¯¢ |
| | | * |
| | | * @param page 翻页对象 |
| | | * @param queryWrapper å®ä½å¯¹è±¡å°è£
æä½ç±» |
| | | */ |
| | | @Override |
| | | public PagePlus<T, K> pageVo(PagePlus<T, K> page, Wrapper<T> queryWrapper, CopyOptions copyOptions) { |
| | | PagePlus<T, K> result = getBaseMapper().selectPage(page, queryWrapper); |
| | | List<K> volist = BeanCopyUtils.listCopy(result.getRecords(), copyOptions, voClass); |
| | | result.setRecordsVo(volist); |
| | | return result; |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.validate; |
| | | |
| | | /** |
| | | * æ ¡éªåç» add |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface AddGroup { |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.validate; |
| | | |
| | | /** |
| | | * æ ¡éªåç» edit |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface EditGroup { |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import cn.hutool.core.bean.copier.BeanCopier; |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import cn.hutool.core.util.ReflectUtil; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * beanæ·±æ·è´å·¥å
· |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public class BeanCopyUtils { |
| | | |
| | | /** |
| | | * å对象åºäºclasså建æ·è´ |
| | | * |
| | | * @param source æ°æ®æ¥æºå®ä½ |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @param desc æè¿°å¯¹è±¡ 转æ¢åç对象 |
| | | * @return desc |
| | | */ |
| | | public static <T, V> V oneCopy(T source, CopyOptions copyOptions, Class<V> desc) { |
| | | V v = ReflectUtil.newInstanceIfPossible(desc); |
| | | return oneCopy(source, copyOptions, v); |
| | | } |
| | | |
| | | /** |
| | | * å对象åºäºå¯¹è±¡å建æ·è´ |
| | | * |
| | | * @param source æ°æ®æ¥æºå®ä½ |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @param desc 转æ¢åç对象 |
| | | * @return desc |
| | | */ |
| | | public static <T, V> V oneCopy(T source, CopyOptions copyOptions, V desc) { |
| | | return BeanCopier.create(source, desc, copyOptions).copy(); |
| | | } |
| | | |
| | | /** |
| | | * å表对象åºäºclasså建æ·è´ |
| | | * |
| | | * @param sourceList æ°æ®æ¥æºå®ä½å表 |
| | | * @param copyOptions copyæ¡ä»¶ |
| | | * @param desc æè¿°å¯¹è±¡ 转æ¢åç对象 |
| | | * @return desc |
| | | */ |
| | | public static <T, V> List<V> listCopy(List<T> sourceList, CopyOptions copyOptions, Class<V> desc) { |
| | | return sourceList.stream() |
| | | .map(source -> oneCopy(source, copyOptions, desc)) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | } |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.5.2</version> |
| | | <version>2.6.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | |
| | | package com.ruoyi.demo.controller; |
| | | |
| | | 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.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.demo.bo.TestDemoAddBo; |
| | | import com.ruoyi.demo.bo.TestDemoEditBo; |
| | | import com.ruoyi.demo.bo.TestDemoQueryBo; |
| | | import com.ruoyi.demo.domain.bo.TestDemoBo; |
| | | import com.ruoyi.demo.domain.vo.TestDemoVo; |
| | | import com.ruoyi.demo.service.ITestDemoService; |
| | | import com.ruoyi.demo.vo.TestDemoVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | * æµè¯å表Controller |
| | | * |
| | | * @author Lion Li |
| | | * @date 2021-05-30 |
| | | * @date 2021-07-26 |
| | | */ |
| | | @Validated |
| | | @Api(value = "æµè¯å表æ§å¶å¨", tags = {"æµè¯å表管ç"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RestController |
| | |
| | | @ApiOperation("æ¥è¯¢æµè¯å表å表") |
| | | @PreAuthorize("@ss.hasPermi('demo:demo:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<TestDemoVo> list(@Validated TestDemoQueryBo bo) { |
| | | public TableDataInfo<TestDemoVo> list(@Validated TestDemoBo bo) { |
| | | return iTestDemoService.queryPageList(bo); |
| | | } |
| | | |
| | | /** |
| | | /** |
| | | * èªå®ä¹å页æ¥è¯¢ |
| | | */ |
| | | @ApiOperation("èªå®ä¹å页æ¥è¯¢") |
| | | @PreAuthorize("@ss.hasPermi('demo:demo:list')") |
| | | @GetMapping("/page") |
| | | public TableDataInfo<TestDemoVo> page(@Validated TestDemoBo bo) { |
| | | return iTestDemoService.customPageList(bo); |
| | | } |
| | | |
| | | /** |
| | | * å¯¼åºæµè¯å表å表 |
| | | */ |
| | | @ApiOperation("å¯¼åºæµè¯å表å表") |
| | | @PreAuthorize("@ss.hasPermi('demo:demo:export')") |
| | | @Log(title = "æµè¯å表", businessType = BusinessType.EXPORT) |
| | | @GetMapping("/export") |
| | | public AjaxResult<TestDemoVo> export(@Validated TestDemoQueryBo bo) { |
| | | public AjaxResult<TestDemoVo> export(@Validated TestDemoBo bo) { |
| | | List<TestDemoVo> list = iTestDemoService.queryList(bo); |
| | | ExcelUtil<TestDemoVo> util = new ExcelUtil<TestDemoVo>(TestDemoVo.class); |
| | | return util.exportExcel(list, "æµè¯å表"); |
| | |
| | | @ApiOperation("æ°å¢æµè¯å表") |
| | | @PreAuthorize("@ss.hasPermi('demo:demo:add')") |
| | | @Log(title = "æµè¯å表", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit |
| | | @PostMapping() |
| | | public AjaxResult<Void> add(@Validated @RequestBody TestDemoAddBo bo) { |
| | | return toAjax(iTestDemoService.insertByAddBo(bo) ? 1 : 0); |
| | | public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody TestDemoBo bo) { |
| | | return toAjax(iTestDemoService.insertByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("ä¿®æ¹æµè¯å表") |
| | | @PreAuthorize("@ss.hasPermi('demo:demo:edit')") |
| | | @Log(title = "æµè¯å表", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit |
| | | @PutMapping() |
| | | public AjaxResult<Void> edit(@Validated @RequestBody TestDemoEditBo bo) { |
| | | return toAjax(iTestDemoService.updateByEditBo(bo) ? 1 : 0); |
| | | public AjaxResult<Void> edit(@Validated(EditGroup.class) @RequestBody TestDemoBo bo) { |
| | | return toAjax(iTestDemoService.updateByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.demo.controller; |
| | | |
| | | 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.validate.AddGroup; |
| | | import com.ruoyi.common.core.validate.EditGroup; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.demo.bo.TestTreeAddBo; |
| | | import com.ruoyi.demo.bo.TestTreeEditBo; |
| | | import com.ruoyi.demo.bo.TestTreeQueryBo; |
| | | import com.ruoyi.demo.domain.bo.TestTreeBo; |
| | | import com.ruoyi.demo.domain.vo.TestTreeVo; |
| | | import com.ruoyi.demo.service.ITestTreeService; |
| | | import com.ruoyi.demo.vo.TestTreeVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | * æµè¯æ 表Controller |
| | | * |
| | | * @author Lion Li |
| | | * @date 2021-05-30 |
| | | * @date 2021-07-26 |
| | | */ |
| | | @Validated |
| | | @Api(value = "æµè¯æ 表æ§å¶å¨", tags = {"æµè¯æ 表管ç"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RestController |
| | |
| | | @ApiOperation("æ¥è¯¢æµè¯æ 表å表") |
| | | @PreAuthorize("@ss.hasPermi('demo:tree:list')") |
| | | @GetMapping("/list") |
| | | public AjaxResult<List<TestTreeVo>> list(@Validated TestTreeQueryBo bo) { |
| | | return AjaxResult.success(iTestTreeService.queryList(bo)); |
| | | public AjaxResult<List<TestTreeVo>> list(@Validated TestTreeBo bo) { |
| | | List<TestTreeVo> list = iTestTreeService.queryList(bo); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PreAuthorize("@ss.hasPermi('demo:tree:export')") |
| | | @Log(title = "æµè¯æ 表", businessType = BusinessType.EXPORT) |
| | | @GetMapping("/export") |
| | | public AjaxResult<TestTreeVo> export(@Validated TestTreeQueryBo bo) { |
| | | public AjaxResult<TestTreeVo> export(@Validated TestTreeBo bo) { |
| | | List<TestTreeVo> list = iTestTreeService.queryList(bo); |
| | | ExcelUtil<TestTreeVo> util = new ExcelUtil<TestTreeVo>(TestTreeVo.class); |
| | | return util.exportExcel(list, "æµè¯æ 表"); |
| | |
| | | @ApiOperation("æ°å¢æµè¯æ 表") |
| | | @PreAuthorize("@ss.hasPermi('demo:tree:add')") |
| | | @Log(title = "æµè¯æ 表", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit |
| | | @PostMapping() |
| | | public AjaxResult<Void> add(@Validated @RequestBody TestTreeAddBo bo) { |
| | | return toAjax(iTestTreeService.insertByAddBo(bo) ? 1 : 0); |
| | | public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody TestTreeBo bo) { |
| | | return toAjax(iTestTreeService.insertByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("ä¿®æ¹æµè¯æ 表") |
| | | @PreAuthorize("@ss.hasPermi('demo:tree:edit')") |
| | | @Log(title = "æµè¯æ 表", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit |
| | | @PutMapping() |
| | | public AjaxResult<Void> edit(@Validated @RequestBody TestTreeEditBo bo) { |
| | | return toAjax(iTestTreeService.updateByEditBo(bo) ? 1 : 0); |
| | | public AjaxResult<Void> edit(@Validated(EditGroup.class) @RequestBody TestTreeBo bo) { |
| | | return toAjax(iTestTreeService.updateByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | * æµè¯å表对象 test_demo |
| | | * |
| | | * @author Lion Li |
| | | * @date 2021-05-30 |
| | | * @date 2021-07-26 |
| | | */ |
| | | @Data |
| | | @NoArgsConstructor |
| | |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** é¨é¨id */ |
| | | /** |
| | | * é¨é¨id |
| | | */ |
| | | private Long deptId; |
| | | |
| | | /** ç¨æ·id */ |
| | | /** |
| | | * ç¨æ·id |
| | | */ |
| | | private Long userId; |
| | | |
| | | /** æåºå· */ |
| | | @OrderBy(isDesc = false, sort = 1) |
| | | /** |
| | | * æåºå· |
| | | */ |
| | | @OrderBy(isDesc = false, sort = 1) |
| | | private Long orderNum; |
| | | |
| | | /** keyé® */ |
| | | /** |
| | | * keyé® |
| | | */ |
| | | private String testKey; |
| | | |
| | | /** å¼ */ |
| | | /** |
| | | * å¼ |
| | | */ |
| | | private String value; |
| | | |
| | | /** çæ¬ */ |
| | | /** |
| | | * çæ¬ |
| | | */ |
| | | @Version |
| | | private Long version; |
| | | |
| | | /** å建æ¶é´ */ |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Date createTime; |
| | | |
| | | /** å建人 */ |
| | | /** |
| | | * å建人 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | /** æ´æ°æ¶é´ */ |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Date updateTime; |
| | | |
| | | /** æ´æ°äºº */ |
| | | /** |
| | | * æ´æ°äºº |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | /** å 餿 å¿ */ |
| | | /** |
| | | * å 餿 å¿ |
| | | */ |
| | | @TableLogic |
| | | private Long delFlag; |
| | | |
| | | } |
| | |
| | | package com.ruoyi.demo.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | |
| | | * æµè¯æ 表对象 test_tree |
| | | * |
| | | * @author Lion Li |
| | | * @date 2021-05-30 |
| | | * @date 2021-07-26 |
| | | */ |
| | | @Data |
| | | @NoArgsConstructor |
| | |
| | | private static final long serialVersionUID=1L; |
| | | |
| | | |
| | | /** ä¸»é® */ |
| | | /** |
| | | * ä¸»é® |
| | | */ |
| | | @TableId(value = "id") |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** ç¶id */ |
| | | /** |
| | | * ç¶id |
| | | */ |
| | | private Long parentId; |
| | | |
| | | /** é¨é¨id */ |
| | | /** |
| | | * é¨é¨id |
| | | */ |
| | | private Long deptId; |
| | | |
| | | /** ç¨æ·id */ |
| | | /** |
| | | * ç¨æ·id |
| | | */ |
| | | private Long userId; |
| | | |
| | | /** æ èç¹å */ |
| | | /** |
| | | * æ èç¹å |
| | | */ |
| | | private String treeName; |
| | | |
| | | /** çæ¬ */ |
| | | /** |
| | | * çæ¬ |
| | | */ |
| | | @Version |
| | | private Long version; |
| | | |
| | | /** å建æ¶é´ */ |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Date createTime; |
| | | |
| | | /** å建人 */ |
| | | /** |
| | | * å建人 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | /** æ´æ°æ¶é´ */ |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Date updateTime; |
| | | |
| | | /** æ´æ°äºº */ |
| | | /** |
| | | * æ´æ°äºº |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | /** å 餿 å¿ */ |
| | | /** |
| | | * å 餿 å¿ |
| | | */ |
| | | @TableLogic |
| | | private Long delFlag; |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.demo.domain.bo; |
| | | |
| | | 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.*; |
| | | |
| | | import java.util.Date; |
| | | |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | |
| | | /** |
| | | * æµè¯å表ä¸å¡å¯¹è±¡ test_demo |
| | | * |
| | | * @author Lion Li |
| | | * @date 2021-07-26 |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel("æµè¯å表ä¸å¡å¯¹è±¡") |
| | | public class TestDemoBo extends BaseEntity { |
| | | |
| | | /** |
| | | * ä¸»é® |
| | | */ |
| | | @ApiModelProperty("主é®") |
| | | @NotNull(message = "主é®ä¸è½ä¸ºç©º", groups = { EditGroup.class }) |
| | | private Long id; |
| | | |
| | | /** |
| | | * é¨é¨id |
| | | */ |
| | | @ApiModelProperty("é¨é¨id") |
| | | @NotNull(message = "é¨é¨idä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * ç¨æ·id |
| | | */ |
| | | @ApiModelProperty("ç¨æ·id") |
| | | @NotNull(message = "ç¨æ·idä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private Long userId; |
| | | |
| | | /** |
| | | * æåºå· |
| | | */ |
| | | @ApiModelProperty("æåºå·") |
| | | @NotNull(message = "æåºå·ä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private Long orderNum; |
| | | |
| | | /** |
| | | * keyé® |
| | | */ |
| | | @ApiModelProperty("keyé®") |
| | | @NotBlank(message = "keyé®ä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private String testKey; |
| | | |
| | | /** |
| | | * å¼ |
| | | */ |
| | | @ApiModelProperty("å¼") |
| | | @NotBlank(message = "å¼ä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private String value; |
| | | |
| | | |
| | | /** |
| | | * åé¡µå¤§å° |
| | | */ |
| | | @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.demo.domain.bo; |
| | | |
| | | import com.ruoyi.common.core.domain.TreeEntity; |
| | | 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; |
| | | |
| | | /** |
| | | * æµè¯æ 表ä¸å¡å¯¹è±¡ test_tree |
| | | * |
| | | * @author Lion Li |
| | | * @date 2021-07-26 |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel("æµè¯æ 表ä¸å¡å¯¹è±¡") |
| | | public class TestTreeBo extends TreeEntity { |
| | | |
| | | /** |
| | | * ä¸»é® |
| | | */ |
| | | @ApiModelProperty("主é®") |
| | | @NotNull(message = "主é®ä¸è½ä¸ºç©º", groups = { EditGroup.class }) |
| | | private Long id; |
| | | |
| | | /** |
| | | * é¨é¨id |
| | | */ |
| | | @ApiModelProperty("é¨é¨id") |
| | | @NotNull(message = "é¨é¨idä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * ç¨æ·id |
| | | */ |
| | | @ApiModelProperty("ç¨æ·id") |
| | | @NotNull(message = "ç¨æ·idä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private Long userId; |
| | | |
| | | /** |
| | | * æ èç¹å |
| | | */ |
| | | @ApiModelProperty("æ èç¹å") |
| | | @NotBlank(message = "æ èç¹åä¸è½ä¸ºç©º", groups = { AddGroup.class, EditGroup.class }) |
| | | private String treeName; |
| | | |
| | | |
| | | /** |
| | | * åé¡µå¤§å° |
| | | */ |
| | | @ApiModelProperty("å页大å°") |
| | | private Integer pageSize; |
| | | |
| | | /** |
| | | * å½åé¡µæ° |
| | | */ |
| | | @ApiModelProperty("å½å页æ°") |
| | | private Integer pageNum; |
| | | |
| | | /** |
| | | * æåºå |
| | | */ |
| | | @ApiModelProperty("æåºå") |
| | | private String orderByColumn; |
| | | |
| | | /** |
| | | * æåºçæ¹ådescæè
asc |
| | | */ |
| | | @ApiModelProperty(value = "æåºçæ¹å", example = "asc,desc") |
| | | private String isAsc; |
| | | |
| | | } |
ÎļþÃû´Ó ruoyi-demo/src/main/java/com/ruoyi/demo/vo/TestDemoVo.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.demo.vo; |
| | | package com.ruoyi.demo.domain.vo; |
| | | |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | |
| | |
| | | * æµè¯å表è§å¾å¯¹è±¡ test_demo |
| | | * |
| | | * @author Lion Li |
| | | * @date 2021-05-30 |
| | | * @date 2021-07-26 |
| | | */ |
| | | @Data |
| | | @ApiModel("æµè¯å表è§å¾å¯¹è±¡") |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ä¸»é® |
| | | * 妿æ¯èªå®ä¹id æè
éªè±id |
| | | * éè¦å¢å åºåå为å符串注解 å 为Longå°å端ä¼å¤±ç |
| | | */ |
| | | * ä¸»é® |
| | | */ |
| | | @ApiModelProperty("主é®") |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** é¨é¨id */ |
| | | /** |
| | | * é¨é¨id |
| | | */ |
| | | @Excel(name = "é¨é¨id") |
| | | @ApiModelProperty("é¨é¨id") |
| | | private Long deptId; |
| | | |
| | | /** ç¨æ·id */ |
| | | /** |
| | | * ç¨æ·id |
| | | */ |
| | | @Excel(name = "ç¨æ·id") |
| | | @ApiModelProperty("ç¨æ·id") |
| | | private Long userId; |
| | | |
| | | /** æåºå· */ |
| | | /** |
| | | * æåºå· |
| | | */ |
| | | @Excel(name = "æåºå·") |
| | | @ApiModelProperty("æåºå·") |
| | | private Long orderNum; |
| | | |
| | | /** keyé® */ |
| | | /** |
| | | * keyé® |
| | | */ |
| | | @Excel(name = "keyé®") |
| | | @ApiModelProperty("keyé®") |
| | | private String testKey; |
| | | |
| | | /** å¼ */ |
| | | /** |
| | | * å¼ |
| | | */ |
| | | @Excel(name = "å¼") |
| | | @ApiModelProperty("å¼") |
| | | private String value; |
| | | |
| | | /** å建æ¶é´ */ |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @Excel(name = "å建æ¶é´" , width = 30, dateFormat = "yyyy-MM-dd") |
| | | // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty("å建æ¶é´") |
| | | private Date createTime; |
| | | |
| | | /** å建人 */ |
| | | /** |
| | | * å建人 |
| | | */ |
| | | @Excel(name = "å建人") |
| | | @ApiModelProperty("å建人") |
| | | private String createBy; |
| | | |
| | | /** æ´æ°æ¶é´ */ |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @Excel(name = "æ´æ°æ¶é´" , width = 30, dateFormat = "yyyy-MM-dd") |
| | | // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty("æ´æ°æ¶é´") |
| | | private Date updateTime; |
| | | |
| | | /** æ´æ°äºº */ |
| | | /** |
| | | * æ´æ°äºº |
| | | */ |
| | | @Excel(name = "æ´æ°äºº") |
| | | @ApiModelProperty("æ´æ°äºº") |
| | | private String updateBy; |
ÎļþÃû´Ó ruoyi-demo/src/main/java/com/ruoyi/demo/vo/TestTreeVo.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.demo.vo; |
| | | package com.ruoyi.demo.domain.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | |
| | |
| | | * æµè¯æ 表è§å¾å¯¹è±¡ test_tree |
| | | * |
| | | * @author Lion Li |
| | | * @date 2021-05-30 |
| | | * @date 2021-07-26 |
| | | */ |
| | | @Data |
| | | @ApiModel("æµè¯æ 表è§å¾å¯¹è±¡") |
| | |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** ä¸»é® */ |
| | | /** |
| | | * ä¸»é® |
| | | */ |
| | | @ApiModelProperty("主é®") |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | /** ç¶id */ |
| | | /** |
| | | * ç¶id |
| | | */ |
| | | @Excel(name = "ç¶id") |
| | | @ApiModelProperty("ç¶id") |
| | | private Long parentId; |
| | | |
| | | /** é¨é¨id */ |
| | | /** |
| | | * é¨é¨id |
| | | */ |
| | | @Excel(name = "é¨é¨id") |
| | | @ApiModelProperty("é¨é¨id") |
| | | private Long deptId; |
| | | |
| | | /** ç¨æ·id */ |
| | | /** |
| | | * ç¨æ·id |
| | | */ |
| | | @Excel(name = "ç¨æ·id") |
| | | @ApiModelProperty("ç¨æ·id") |
| | | private Long userId; |
| | | |
| | | /** æ èç¹å */ |
| | | /** |
| | | * æ èç¹å |
| | | */ |
| | | @Excel(name = "æ èç¹å") |
| | | @ApiModelProperty("æ èç¹å") |
| | | private String treeName; |
| | | |
| | | /** å建æ¶é´ */ |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @Excel(name = "å建æ¶é´" , width = 30, dateFormat = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty("å建æ¶é´") |
| | | private Date createTime; |
| | | |
| | |
| | | package com.ruoyi.demo.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.mybatisplus.cache.MybatisPlusRedisCache; |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.demo.domain.TestDemo; |
| | | import com.ruoyi.demo.domain.vo.TestDemoVo; |
| | | import org.apache.ibatis.annotations.CacheNamespace; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * æµè¯å表Mapperæ¥å£ |
| | | * |
| | | * @author Lion Li |
| | | * @date 2021-05-30 |
| | | * @date 2021-07-26 |
| | | */ |
| | | // å¦ä½¿éåæ¢æ°æ®æº 请å¿ä½¿ç¨ç¼å ä¼é ææ°æ®ä¸ä¸è´ç°è±¡ |
| | | @CacheNamespace(implementation = MybatisPlusRedisCache.class, eviction = MybatisPlusRedisCache.class) |
| | | public interface TestDemoMapper extends BaseMapperPlus<TestDemo> { |
| | | |
| | | Page<TestDemoVo> customPageList(@Param("page") Page<TestDemo> page, @Param("ew") Wrapper<TestDemo> wrapper); |
| | | |
| | | } |
| | |
| | | * æµè¯æ 表Mapperæ¥å£ |
| | | * |
| | | * @author Lion Li |
| | | * @date 2021-05-30 |
| | | * @date 2021-07-26 |
| | | */ |
| | | //@CacheNamespace(implementation = MybatisPlusRedisCache.class, eviction = MybatisPlusRedisCache.class) |
| | | public interface TestTreeMapper extends BaseMapperPlus<TestTree> { |
| | | |
| | | } |
| | |
| | | package com.ruoyi.demo.service; |
| | | |
| | | import com.ruoyi.demo.domain.TestDemo; |
| | | import com.ruoyi.demo.vo.TestDemoVo; |
| | | import com.ruoyi.demo.bo.TestDemoQueryBo; |
| | | import com.ruoyi.demo.bo.TestDemoAddBo; |
| | | import com.ruoyi.demo.bo.TestDemoEditBo; |
| | | import com.ruoyi.demo.domain.vo.TestDemoVo; |
| | | import com.ruoyi.demo.domain.bo.TestDemoBo; |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | |
| | |
| | | * æµè¯å表Serviceæ¥å£ |
| | | * |
| | | * @author Lion Li |
| | | * @date 2021-05-30 |
| | | * @date 2021-07-26 |
| | | */ |
| | | public interface ITestDemoService extends IServicePlus<TestDemo> { |
| | | public interface ITestDemoService extends IServicePlus<TestDemo, TestDemoVo> { |
| | | |
| | | /** |
| | | * æ¥è¯¢å个 |
| | |
| | | /** |
| | | * æ¥è¯¢å表 |
| | | */ |
| | | TableDataInfo<TestDemoVo> queryPageList(TestDemoQueryBo bo); |
| | | TableDataInfo<TestDemoVo> queryPageList(TestDemoBo bo); |
| | | |
| | | /** |
| | | * èªå®ä¹å页æ¥è¯¢ |
| | | */ |
| | | TableDataInfo<TestDemoVo> customPageList(TestDemoBo bo); |
| | | |
| | | /** |
| | | * æ¥è¯¢å表 |
| | | */ |
| | | List<TestDemoVo> queryList(TestDemoQueryBo bo); |
| | | List<TestDemoVo> queryList(TestDemoBo bo); |
| | | |
| | | /** |
| | | * æ ¹æ®æ°å¢ä¸å¡å¯¹è±¡æå
¥æµè¯å表 |
| | | * @param bo æµè¯å表æ°å¢ä¸å¡å¯¹è±¡ |
| | | * @return |
| | | */ |
| | | Boolean insertByAddBo(TestDemoAddBo bo); |
| | | Boolean insertByBo(TestDemoBo bo); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¼è¾ä¸å¡å¯¹è±¡ä¿®æ¹æµè¯å表 |
| | | * @param bo æµè¯å表ç¼è¾ä¸å¡å¯¹è±¡ |
| | | * @return |
| | | */ |
| | | Boolean updateByEditBo(TestDemoEditBo bo); |
| | | Boolean updateByBo(TestDemoBo bo); |
| | | |
| | | /** |
| | | * æ ¡éªå¹¶å 餿°æ® |
| | |
| | | package com.ruoyi.demo.service; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.ruoyi.demo.bo.TestTreeAddBo; |
| | | import com.ruoyi.demo.bo.TestTreeEditBo; |
| | | import com.ruoyi.demo.bo.TestTreeQueryBo; |
| | | import com.ruoyi.demo.domain.TestTree; |
| | | import com.ruoyi.demo.vo.TestTreeVo; |
| | | import com.ruoyi.demo.domain.vo.TestTreeVo; |
| | | import com.ruoyi.demo.domain.bo.TestTreeBo; |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | |
| | | * æµè¯æ 表Serviceæ¥å£ |
| | | * |
| | | * @author Lion Li |
| | | * @date 2021-05-30 |
| | | * @date 2021-07-26 |
| | | */ |
| | | public interface ITestTreeService extends IServicePlus<TestTree> { |
| | | public interface ITestTreeService extends IServicePlus<TestTree, TestTreeVo> { |
| | | /** |
| | | * æ¥è¯¢å个 |
| | | * @return |
| | |
| | | /** |
| | | * æ¥è¯¢å表 |
| | | */ |
| | | List<TestTreeVo> queryList(TestTreeQueryBo bo); |
| | | List<TestTreeVo> queryList(TestTreeBo bo); |
| | | |
| | | /** |
| | | * æ ¹æ®æ°å¢ä¸å¡å¯¹è±¡æå
¥æµè¯æ 表 |
| | | * @param bo æµè¯æ 表æ°å¢ä¸å¡å¯¹è±¡ |
| | | * @return |
| | | */ |
| | | Boolean insertByAddBo(TestTreeAddBo bo); |
| | | Boolean insertByBo(TestTreeBo bo); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¼è¾ä¸å¡å¯¹è±¡ä¿®æ¹æµè¯æ 表 |
| | | * @param bo æµè¯æ 表ç¼è¾ä¸å¡å¯¹è±¡ |
| | | * @return |
| | | */ |
| | | Boolean updateByEditBo(TestTreeEditBo bo); |
| | | Boolean updateByBo(TestTreeBo bo); |
| | | |
| | | /** |
| | | * æ ¡éªå¹¶å 餿°æ® |
| | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | 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.utils.PageUtils; |
| | | import com.ruoyi.demo.bo.TestDemoAddBo; |
| | | import com.ruoyi.demo.bo.TestDemoEditBo; |
| | | import com.ruoyi.demo.bo.TestDemoQueryBo; |
| | | import com.ruoyi.demo.domain.TestDemo; |
| | | import com.ruoyi.demo.domain.bo.TestDemoBo; |
| | | import com.ruoyi.demo.domain.vo.TestDemoVo; |
| | | import com.ruoyi.demo.mapper.TestDemoMapper; |
| | | import com.ruoyi.demo.service.ITestDemoService; |
| | | import com.ruoyi.demo.vo.TestDemoVo; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Collection; |
| | |
| | | * æµè¯å表Serviceä¸å¡å±å¤ç |
| | | * |
| | | * @author Lion Li |
| | | * @date 2021-05-30 |
| | | * @date 2021-07-26 |
| | | */ |
| | | @Service |
| | | public class TestDemoServiceImpl extends ServicePlusImpl<TestDemoMapper, TestDemo> implements ITestDemoService { |
| | | public class TestDemoServiceImpl extends ServicePlusImpl<TestDemoMapper, TestDemo, TestDemoVo> implements ITestDemoService { |
| | | |
| | | @Override |
| | | public TestDemoVo queryById(Long id) { |
| | | return getVoById(id, TestDemoVo.class); |
| | | return getVoById(id); |
| | | } |
| | | |
| | | @DataScope(isUser = true) |
| | | @Override |
| | | public TableDataInfo<TestDemoVo> queryPageList(TestDemoQueryBo bo) { |
| | | PagePlus<TestDemo, TestDemoVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo), TestDemoVo.class); |
| | | public TableDataInfo<TestDemoVo> queryPageList(TestDemoBo bo) { |
| | | PagePlus<TestDemo, TestDemoVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo)); |
| | | return PageUtils.buildDataInfo(result); |
| | | } |
| | | |
| | | /** |
| | | * èªå®ä¹å页æ¥è¯¢ |
| | | */ |
| | | @DataScope(isUser = true) |
| | | @Override |
| | | public TableDataInfo<TestDemoVo> customPageList(TestDemoBo bo) { |
| | | Page<TestDemoVo> result = baseMapper.customPageList(PageUtils.buildPage(), buildQueryWrapper(bo)); |
| | | return PageUtils.buildDataInfo(result); |
| | | } |
| | | |
| | | @DataScope(isUser = true) |
| | | @Override |
| | | public List<TestDemoVo> queryList(TestDemoQueryBo bo) { |
| | | return listVo(buildQueryWrapper(bo), TestDemoVo.class); |
| | | public List<TestDemoVo> queryList(TestDemoBo bo) { |
| | | return listVo(buildQueryWrapper(bo)); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<TestDemo> buildQueryWrapper(TestDemoQueryBo bo) { |
| | | private LambdaQueryWrapper<TestDemo> buildQueryWrapper(TestDemoBo bo) { |
| | | Map<String, Object> params = bo.getParams(); |
| | | Object dataScope = params.get("dataScope"); |
| | | LambdaQueryWrapper<TestDemo> lqw = Wrappers.lambdaQuery(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Boolean insertByAddBo(TestDemoAddBo bo) { |
| | | public Boolean insertByBo(TestDemoBo bo) { |
| | | TestDemo add = BeanUtil.toBean(bo, TestDemo.class); |
| | | validEntityBeforeSave(add); |
| | | return save(add); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean updateByEditBo(TestDemoEditBo bo) { |
| | | public Boolean updateByBo(TestDemoBo bo) { |
| | | TestDemo update = BeanUtil.toBean(bo, TestDemo.class); |
| | | validEntityBeforeSave(update); |
| | | return updateById(update); |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.demo.bo.TestTreeAddBo; |
| | | import com.ruoyi.demo.bo.TestTreeEditBo; |
| | | import com.ruoyi.demo.bo.TestTreeQueryBo; |
| | | import com.ruoyi.demo.domain.TestTree; |
| | | import com.ruoyi.demo.domain.bo.TestTreeBo; |
| | | import com.ruoyi.demo.domain.vo.TestTreeVo; |
| | | import com.ruoyi.demo.mapper.TestTreeMapper; |
| | | import com.ruoyi.demo.service.ITestTreeService; |
| | | import com.ruoyi.demo.vo.TestTreeVo; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Collection; |
| | |
| | | * æµè¯æ 表Serviceä¸å¡å±å¤ç |
| | | * |
| | | * @author Lion Li |
| | | * @date 2021-05-30 |
| | | * @date 2021-07-26 |
| | | */ |
| | | @Service |
| | | public class TestTreeServiceImpl extends ServicePlusImpl<TestTreeMapper, TestTree> implements ITestTreeService { |
| | | public class TestTreeServiceImpl extends ServicePlusImpl<TestTreeMapper, TestTree, TestTreeVo> implements ITestTreeService { |
| | | |
| | | @Override |
| | | public TestTreeVo queryById(Long id) { |
| | | return getVoById(id, TestTreeVo.class); |
| | | return getVoById(id); |
| | | } |
| | | |
| | | // @DataSource(DataSourceType.SLAVE) // 忢ä»åºæ¥è¯¢ |
| | | @DataScope(isUser = true) |
| | | @Override |
| | | public List<TestTreeVo> queryList(TestTreeQueryBo bo) { |
| | | return listVo(buildQueryWrapper(bo), TestTreeVo.class); |
| | | public List<TestTreeVo> queryList(TestTreeBo bo) { |
| | | return listVo(buildQueryWrapper(bo)); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<TestTree> buildQueryWrapper(TestTreeQueryBo bo) { |
| | | private LambdaQueryWrapper<TestTree> buildQueryWrapper(TestTreeBo bo) { |
| | | Map<String, Object> params = bo.getParams(); |
| | | Object dataScope = params.get("dataScope"); |
| | | LambdaQueryWrapper<TestTree> lqw = Wrappers.lambdaQuery(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Boolean insertByAddBo(TestTreeAddBo bo) { |
| | | public Boolean insertByBo(TestTreeBo bo) { |
| | | TestTree add = BeanUtil.toBean(bo, TestTree.class); |
| | | validEntityBeforeSave(add); |
| | | return save(add); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean updateByEditBo(TestTreeEditBo bo) { |
| | | public Boolean updateByBo(TestTreeBo bo) { |
| | | TestTree update = BeanUtil.toBean(bo, TestTree.class); |
| | | validEntityBeforeSave(update); |
| | | return updateById(update); |
| | |
| | | <result property="updateBy" column="update_by"/> |
| | | <result property="delFlag" column="del_flag"/> |
| | | </resultMap> |
| | | <select id="customPageList" resultType="com.ruoyi.demo.domain.vo.TestDemoVo"> |
| | | SELECT * FROM test_demo ${ew.customSqlSegment} |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
| | | </mapper> |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.5.2</version> |
| | | <version>2.6.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <artifactId>ruoyi-extend</artifactId> |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-extend</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.5.2</version> |
| | | <version>2.6.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <packaging>jar</packaging> |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.5.2</version> |
| | | <version>2.6.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | |
| | | // éªè¯ç å¼å
³ |
| | | if (captchaOnOff) |
| | | { |
| | | validateCapcha(username, code, uuid, request); |
| | | validateCaptcha(username, code, uuid, request); |
| | | } |
| | | // ç¨æ·éªè¯ |
| | | Authentication authentication = null; |
| | |
| | | * @param uuid å¯ä¸æ è¯ |
| | | * @return ç»æ |
| | | */ |
| | | public void validateCapcha(String username, String code, String uuid, HttpServletRequest request) { |
| | | public void validateCaptcha(String username, String code, String uuid, HttpServletRequest request) { |
| | | String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; |
| | | String captcha = redisCache.getCacheObject(verifyKey); |
| | | redisCache.deleteObject(verifyKey); |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.5.2</version> |
| | | <version>2.6.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | |
| | | package com.ruoyi.generator.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.generator.domain.GenTableColumn; |
| | | import com.ruoyi.generator.mapper.GenTableColumnMapper; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class GenTableColumnServiceImpl extends ServicePlusImpl<GenTableColumnMapper, GenTableColumn> implements IGenTableColumnService { |
| | | public class GenTableColumnServiceImpl extends ServiceImpl<GenTableColumnMapper, GenTableColumn> implements IGenTableColumnService { |
| | | |
| | | /** |
| | | * æ¥è¯¢ä¸å¡å段å表 |
| | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | 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.utils.JsonUtils; |
| | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.StringWriter; |
| | | import java.util.*; |
| | | import java.util.Arrays; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import java.util.zip.ZipEntry; |
| | | import java.util.zip.ZipOutputStream; |
| | |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTable> implements IGenTableService { |
| | | public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> implements IGenTableService { |
| | | |
| | | @Autowired |
| | | private GenTableColumnMapper genTableColumnMapper; |
| | |
| | | package com.ruoyi.generator.service; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.generator.domain.GenTableColumn; |
| | | |
| | | import java.util.List; |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface IGenTableColumnService extends IServicePlus<GenTableColumn> { |
| | | public interface IGenTableColumnService extends IService<GenTableColumn> { |
| | | /** |
| | | * æ¥è¯¢ä¸å¡å段å表 |
| | | * |
| | |
| | | package com.ruoyi.generator.service; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.generator.domain.GenTable; |
| | | |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface IGenTableService extends IServicePlus<GenTable> { |
| | | public interface IGenTableService extends IService<GenTable> { |
| | | |
| | | |
| | | TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable); |
| | |
| | | List<String> templates = new ArrayList<String>(); |
| | | templates.add("vm/java/domain.java.vm"); |
| | | templates.add("vm/java/vo.java.vm"); |
| | | templates.add("vm/java/queryBo.java.vm"); |
| | | templates.add("vm/java/addBo.java.vm"); |
| | | templates.add("vm/java/editBo.java.vm"); |
| | | templates.add("vm/java/bo.java.vm"); |
| | | templates.add("vm/java/mapper.java.vm"); |
| | | templates.add("vm/java/service.java.vm"); |
| | | templates.add("vm/java/serviceImpl.java.vm"); |
| | |
| | | } |
| | | if (template.contains("vo.java.vm")) |
| | | { |
| | | fileName = StrUtil.format("{}/vo/{}Vo.java", javaPath, className); |
| | | fileName = StrUtil.format("{}/domain/vo/{}Vo.java", javaPath, className); |
| | | } |
| | | if (template.contains("queryBo.java.vm")) |
| | | { |
| | | fileName = StrUtil.format("{}/bo/{}QueryBo.java", javaPath, className); |
| | | } |
| | | if (template.contains("addBo.java.vm")) |
| | | { |
| | | fileName = StrUtil.format("{}/bo/{}AddBo.java", javaPath, className); |
| | | } |
| | | if (template.contains("editBo.java.vm")) |
| | | { |
| | | fileName = StrUtil.format("{}/bo/{}EditBo.java", javaPath, className); |
| | | } |
| | | if (template.contains("bo.java.vm")) |
| | | { |
| | | fileName = StrUtil.format("{}/domain/bo/{}Bo.java", javaPath, className); |
| | | } |
| | | if (template.contains("sub-domain.java.vm") && StrUtil.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) |
| | | { |
| | | fileName = StrUtil.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName()); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package ${packageName}.domain.bo; |
| | | |
| | | 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.*; |
| | | |
| | | import java.util.Date; |
| | | |
| | | #foreach ($import in $importList) |
| | | import ${import}; |
| | | #end |
| | | #if($table.crud || $table.sub) |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | #elseif($table.tree) |
| | | import com.ruoyi.common.core.domain.TreeEntity; |
| | | #end |
| | | |
| | | /** |
| | | * ${functionName}ä¸å¡å¯¹è±¡ ${tableName} |
| | | * |
| | | * @author ${author} |
| | | * @date ${datetime} |
| | | */ |
| | | #if($table.crud || $table.sub) |
| | | #set($Entity="BaseEntity") |
| | | #elseif($table.tree) |
| | | #set($Entity="TreeEntity") |
| | | #end |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel("${functionName}ä¸å¡å¯¹è±¡") |
| | | public class ${ClassName}Bo extends ${Entity} { |
| | | |
| | | #foreach ($column in $columns) |
| | | #if(!$table.isSuperColumn($column.javaField) && ($column.query || $column.isInsert || $column.isEdit)) |
| | | /** |
| | | * $column.columnComment |
| | | */ |
| | | @ApiModelProperty("$column.columnComment") |
| | | #if($column.isInsert && $column.isEdit) |
| | | #set($Group="AddGroup.class, EditGroup.class") |
| | | #elseif($column.isInsert) |
| | | #set($Group="AddGroup.class") |
| | | #elseif($column.isEdit) |
| | | #set($Group="EditGroup.class") |
| | | #end |
| | | #if($column.isRequired == 1) |
| | | #if($column.javaType == 'String') |
| | | @NotBlank(message = "$column.columnCommentä¸è½ä¸ºç©º", groups = { $Group }) |
| | | #else |
| | | @NotNull(message = "$column.columnCommentä¸è½ä¸ºç©º", groups = { $Group }) |
| | | #end |
| | | #end |
| | | private $column.javaType $column.javaField; |
| | | |
| | | #end |
| | | #end |
| | | |
| | | /** |
| | | * åé¡µå¤§å° |
| | | */ |
| | | @ApiModelProperty("å页大å°") |
| | | private Integer pageSize; |
| | | |
| | | /** |
| | | * å½åé¡µæ° |
| | | */ |
| | | @ApiModelProperty("å½å页æ°") |
| | | private Integer pageNum; |
| | | |
| | | /** |
| | | * æåºå |
| | | */ |
| | | @ApiModelProperty("æåºå") |
| | | private String orderByColumn; |
| | | |
| | | /** |
| | | * æåºçæ¹ådescæè
asc |
| | | */ |
| | | @ApiModelProperty(value = "æåºçæ¹å", example = "asc,desc") |
| | | private String isAsc; |
| | | |
| | | } |
| | |
| | | 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.validate.AddGroup; |
| | | import com.ruoyi.common.core.validate.EditGroup; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import ${packageName}.vo.${ClassName}Vo; |
| | | import ${packageName}.bo.${ClassName}QueryBo; |
| | | import ${packageName}.bo.${ClassName}AddBo; |
| | | import ${packageName}.bo.${ClassName}EditBo; |
| | | 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) |
| | |
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") |
| | | @GetMapping("/list") |
| | | #if($table.crud || $table.sub) |
| | | public TableDataInfo<${ClassName}Vo> list(@Validated ${ClassName}QueryBo bo) { |
| | | public TableDataInfo<${ClassName}Vo> list(@Validated ${ClassName}Bo bo) { |
| | | return i${ClassName}Service.queryPageList(bo); |
| | | } |
| | | #elseif($table.tree) |
| | | public AjaxResult<List<${ClassName}Vo>> list(@Validated ${ClassName}QueryBo bo) { |
| | | public AjaxResult<List<${ClassName}Vo>> list(@Validated ${ClassName}Bo bo) { |
| | | List<${ClassName}Vo> list = i${ClassName}Service.queryList(bo); |
| | | return AjaxResult.success(list); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')") |
| | | @Log(title = "${functionName}", businessType = BusinessType.EXPORT) |
| | | @GetMapping("/export") |
| | | public AjaxResult<${ClassName}Vo> export(@Validated ${ClassName}QueryBo bo) { |
| | | public AjaxResult<${ClassName}Vo> export(@Validated ${ClassName}Bo bo) { |
| | | 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}"); |
| | |
| | | @Log(title = "${functionName}", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit |
| | | @PostMapping() |
| | | public AjaxResult<Void> add(@Validated @RequestBody ${ClassName}AddBo bo) { |
| | | return toAjax(i${ClassName}Service.insertByAddBo(bo) ? 1 : 0); |
| | | public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody ${ClassName}Bo bo) { |
| | | return toAjax(i${ClassName}Service.insertByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Log(title = "${functionName}", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit |
| | | @PutMapping() |
| | | public AjaxResult<Void> edit(@Validated @RequestBody ${ClassName}EditBo bo) { |
| | | return toAjax(i${ClassName}Service.updateByEditBo(bo) ? 1 : 0); |
| | | public AjaxResult<Void> edit(@Validated(EditGroup.class) @RequestBody ${ClassName}Bo bo) { |
| | | return toAjax(i${ClassName}Service.updateByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | package ${packageName}.service; |
| | | |
| | | import ${packageName}.domain.${ClassName}; |
| | | import ${packageName}.vo.${ClassName}Vo; |
| | | import ${packageName}.bo.${ClassName}QueryBo; |
| | | import ${packageName}.bo.${ClassName}AddBo; |
| | | import ${packageName}.bo.${ClassName}EditBo; |
| | | import ${packageName}.domain.vo.${ClassName}Vo; |
| | | import ${packageName}.domain.bo.${ClassName}Bo; |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | #if($table.crud || $table.sub) |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | |
| | | * @author ${author} |
| | | * @date ${datetime} |
| | | */ |
| | | public interface I${ClassName}Service extends IServicePlus<${ClassName}> { |
| | | public interface I${ClassName}Service extends IServicePlus<${ClassName}, ${ClassName}Vo> { |
| | | /** |
| | | * æ¥è¯¢å个 |
| | | * @return |
| | |
| | | /** |
| | | * æ¥è¯¢å表 |
| | | */ |
| | | TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}QueryBo bo); |
| | | TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}Bo bo); |
| | | #end |
| | | |
| | | /** |
| | | * æ¥è¯¢å表 |
| | | */ |
| | | List<${ClassName}Vo> queryList(${ClassName}QueryBo bo); |
| | | List<${ClassName}Vo> queryList(${ClassName}Bo bo); |
| | | |
| | | /** |
| | | * æ ¹æ®æ°å¢ä¸å¡å¯¹è±¡æå
¥${functionName} |
| | | * @param bo ${functionName}æ°å¢ä¸å¡å¯¹è±¡ |
| | | * @return |
| | | */ |
| | | Boolean insertByAddBo(${ClassName}AddBo bo); |
| | | Boolean insertByBo(${ClassName}Bo bo); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¼è¾ä¸å¡å¯¹è±¡ä¿®æ¹${functionName} |
| | | * @param bo ${functionName}ç¼è¾ä¸å¡å¯¹è±¡ |
| | | * @return |
| | | */ |
| | | Boolean updateByEditBo(${ClassName}EditBo bo); |
| | | Boolean updateByBo(${ClassName}Bo bo); |
| | | |
| | | /** |
| | | * æ ¡éªå¹¶å 餿°æ® |
| | |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import ${packageName}.bo.${ClassName}AddBo; |
| | | import ${packageName}.bo.${ClassName}QueryBo; |
| | | import ${packageName}.bo.${ClassName}EditBo; |
| | | import ${packageName}.domain.bo.${ClassName}Bo; |
| | | import ${packageName}.domain.vo.${ClassName}Vo; |
| | | import ${packageName}.domain.${ClassName}; |
| | | import ${packageName}.mapper.${ClassName}Mapper; |
| | | import ${packageName}.vo.${ClassName}Vo; |
| | | import ${packageName}.service.I${ClassName}Service; |
| | | |
| | | import java.util.List; |
| | |
| | | * @date ${datetime} |
| | | */ |
| | | @Service |
| | | public class ${ClassName}ServiceImpl extends ServicePlusImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service { |
| | | public class ${ClassName}ServiceImpl extends ServicePlusImpl<${ClassName}Mapper, ${ClassName}, ${ClassName}Vo> implements I${ClassName}Service { |
| | | |
| | | @Override |
| | | public ${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField}){ |
| | | return getVoById(${pkColumn.javaField}, ${ClassName}Vo.class); |
| | | return getVoById(${pkColumn.javaField}); |
| | | } |
| | | |
| | | #if($table.crud || $table.sub) |
| | | @Override |
| | | public TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}QueryBo bo) { |
| | | PagePlus<${ClassName}, ${ClassName}Vo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo), ${ClassName}Vo.class); |
| | | public TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}Bo bo) { |
| | | PagePlus<${ClassName}, ${ClassName}Vo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo)); |
| | | return PageUtils.buildDataInfo(result); |
| | | } |
| | | #end |
| | | |
| | | @Override |
| | | public List<${ClassName}Vo> queryList(${ClassName}QueryBo bo) { |
| | | return listVo(buildQueryWrapper(bo), ${ClassName}Vo.class); |
| | | public List<${ClassName}Vo> queryList(${ClassName}Bo bo) { |
| | | return listVo(buildQueryWrapper(bo)); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<${ClassName}> buildQueryWrapper(${ClassName}QueryBo bo) { |
| | | private LambdaQueryWrapper<${ClassName}> buildQueryWrapper(${ClassName}Bo bo) { |
| | | Map<String, Object> params = bo.getParams(); |
| | | LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery(); |
| | | #foreach($column in $columns) |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Boolean insertByAddBo(${ClassName}AddBo bo) { |
| | | public Boolean insertByBo(${ClassName}Bo bo) { |
| | | ${ClassName} add = BeanUtil.toBean(bo, ${ClassName}.class); |
| | | validEntityBeforeSave(add); |
| | | return save(add); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean updateByEditBo(${ClassName}EditBo bo) { |
| | | public Boolean updateByBo(${ClassName}Bo bo) { |
| | | ${ClassName} update = BeanUtil.toBean(bo, ${ClassName}.class); |
| | | validEntityBeforeSave(update); |
| | | return updateById(update); |
| | |
| | | package ${packageName}.vo; |
| | | package ${packageName}.domain.vo; |
| | | |
| | | import com.ruoyi.common.annotation.Excel; |
| | | #foreach ($import in $importList) |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.6.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>ruoyi-oss</artifactId> |
| | | |
| | | <description> |
| | | OSS对象å卿¨¡å |
| | | </description> |
| | | |
| | | <dependencies> |
| | | |
| | | <!-- éç¨å·¥å
·--> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-common</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-system</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.qiniu</groupId> |
| | | <artifactId>qiniu-java-sdk</artifactId> |
| | | <version>${qiniu.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.aliyun.oss</groupId> |
| | | <artifactId>aliyun-sdk-oss</artifactId> |
| | | <version>${aliyun.oss.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.qcloud</groupId> |
| | | <artifactId>cos_api</artifactId> |
| | | <version>${qcloud.cos.version}</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-log4j12</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>io.minio</groupId> |
| | | <artifactId>minio</artifactId> |
| | | <version>${minio.version}</version> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | </project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.oss.constant; |
| | | |
| | | /** |
| | | * äºåå¨å¸¸é |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public class CloudConstant { |
| | | |
| | | /** |
| | | * äºåå¨é
ç½®KEY |
| | | */ |
| | | public final static String CLOUD_STORAGE_CONFIG_KEY = "sys.oss.cloudStorageService"; |
| | | |
| | | /** |
| | | * é¢è§åè¡¨èµæºå¼å
³Key |
| | | */ |
| | | public final static String PEREVIEW_LIST_RESOURCE_KEY = "sys.oss.previewListResource"; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.oss.entity; |
| | | |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | /** |
| | | * ä¸ä¼ è¿åä½ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | public class UploadResult { |
| | | |
| | | /** |
| | | * æä»¶è·¯å¾ |
| | | */ |
| | | private String url; |
| | | |
| | | /** |
| | | * æä»¶å |
| | | */ |
| | | private String filename; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * äºå卿å¡åæä¸¾ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum CloudServiceEnumd { |
| | | |
| | | /** |
| | | * ä¸çäº |
| | | */ |
| | | QINIU("qiniu", QiniuCloudStorageServiceImpl.class), |
| | | |
| | | /** |
| | | * é¿éäº |
| | | */ |
| | | ALIYUN("aliyun", AliyunCloudStorageServiceImpl.class), |
| | | |
| | | /** |
| | | * è
¾è®¯äº |
| | | */ |
| | | QCLOUD("qcloud", QcloudCloudStorageServiceImpl.class), |
| | | |
| | | /** |
| | | * minio |
| | | */ |
| | | MINIO("minio", MinioCloudStorageServiceImpl.class); |
| | | |
| | | private final String value; |
| | | |
| | | private final Class<?> serviceClass; |
| | | |
| | | public static Class<?> getServiceClass(String value) { |
| | | for (CloudServiceEnumd clazz : values()) { |
| | | if (clazz.getValue().equals(value)) { |
| | | return clazz.getServiceClass(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill åºéª (smallchill@163.com) |
| | | */ |
| | | package com.ruoyi.oss.enumd; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * minioçç¥é
ç½® |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum PolicyType { |
| | | |
| | | /** |
| | | * åªè¯» |
| | | */ |
| | | READ("read-only"), |
| | | |
| | | /** |
| | | * åªå |
| | | */ |
| | | WRITE("write-only"), |
| | | |
| | | /** |
| | | * 读å |
| | | */ |
| | | READ_WRITE("read-write"); |
| | | |
| | | /** |
| | | * ç±»å |
| | | */ |
| | | private final String type; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.oss.exception; |
| | | |
| | | /** |
| | | * OSSå¼å¸¸ç±» |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public class OssException extends RuntimeException { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public OssException(String msg) { |
| | | super(msg); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.oss.factory; |
| | | |
| | | import cn.hutool.core.lang.Assert; |
| | | 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 java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | * æä»¶ä¸ä¼ Factory |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public class OssFactory { |
| | | |
| | | private static ISysConfigService sysConfigService; |
| | | |
| | | static { |
| | | OssFactory.sysConfigService = SpringUtils.getBean(ISysConfigService.class); |
| | | } |
| | | |
| | | private static final Map<String, ICloudStorageService> SERVICES = new ConcurrentHashMap<>(); |
| | | |
| | | public static ICloudStorageService instance() { |
| | | String type = sysConfigService.selectConfigByKey(CloudConstant.CLOUD_STORAGE_CONFIG_KEY); |
| | | return instance(type); |
| | | } |
| | | |
| | | public static ICloudStorageService instance(String type) { |
| | | ICloudStorageService service = SERVICES.get(type); |
| | | if (service == null) { |
| | | service = (ICloudStorageService) SpringUtils.getBean(CloudServiceEnumd.getServiceClass(type)); |
| | | } |
| | | 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; |
| | | |
| | | /** |
| | | * 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 |
| | | */ |
| | | private String accessKey; |
| | | |
| | | /** |
| | | * minio 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 |
| | | */ |
| | | private Boolean isHttps; |
| | | |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.oss.service; |
| | | |
| | | import com.ruoyi.oss.entity.UploadResult; |
| | | |
| | | import java.io.InputStream; |
| | | |
| | | /** |
| | | * äºå卿塿¥å£ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ICloudStorageService { |
| | | |
| | | void createBucket(); |
| | | |
| | | /** |
| | | * è·åæå¡åç±»å |
| | | */ |
| | | String getServiceType(); |
| | | |
| | | /** |
| | | * æä»¶è·¯å¾ |
| | | * |
| | | * @param prefix åç¼ |
| | | * @param suffix åç¼ |
| | | * @return è¿åä¸ä¼ è·¯å¾ |
| | | */ |
| | | String getPath(String prefix, String suffix); |
| | | |
| | | /** |
| | | * æä»¶ä¸ä¼ |
| | | * |
| | | * @param data æä»¶åèæ°ç» |
| | | * @param path æä»¶è·¯å¾ï¼å
嫿件å |
| | | * @return è¿åhttpå°å |
| | | */ |
| | | UploadResult upload(byte[] data, String path, String contentType); |
| | | |
| | | /** |
| | | * æä»¶å é¤ |
| | | * |
| | | * @param path æä»¶è·¯å¾ï¼å
嫿件å |
| | | */ |
| | | void delete(String path); |
| | | |
| | | /** |
| | | * æä»¶ä¸ä¼ |
| | | * |
| | | * @param data æä»¶åèæ°ç» |
| | | * @param suffix åç¼ |
| | | * @return è¿åhttpå°å |
| | | */ |
| | | UploadResult uploadSuffix(byte[] data, String suffix, String contentType); |
| | | |
| | | /** |
| | | * æä»¶ä¸ä¼ |
| | | * |
| | | * @param inputStream åèæµ |
| | | * @param path æä»¶è·¯å¾ï¼å
嫿件å |
| | | * @return è¿åhttpå°å |
| | | */ |
| | | UploadResult upload(InputStream inputStream, String path, String contentType); |
| | | |
| | | /** |
| | | * æä»¶ä¸ä¼ |
| | | * |
| | | * @param inputStream åèæµ |
| | | * @param suffix åç¼ |
| | | * @return è¿åhttpå°å |
| | | */ |
| | | UploadResult uploadSuffix(InputStream inputStream, String suffix, String contentType); |
| | | |
| | | String getEndpointLink(); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.oss.service.abstractd; |
| | | |
| | | 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.oss.entity.UploadResult; |
| | | import com.ruoyi.oss.service.ICloudStorageService; |
| | | import org.springframework.beans.factory.InitializingBean; |
| | | |
| | | import java.io.InputStream; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * äºåå¨(æ¯æä¸çãé¿éäºãè
¾è®¯äºãminio) |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public abstract class AbstractCloudStorageService implements ICloudStorageService, InitializingBean { |
| | | |
| | | @Override |
| | | public abstract void createBucket(); |
| | | |
| | | @Override |
| | | public abstract String getServiceType(); |
| | | |
| | | @Override |
| | | public String getPath(String prefix, String suffix) { |
| | | // çæuuid |
| | | String uuid = IdUtil.fastSimpleUUID(); |
| | | // æä»¶è·¯å¾ |
| | | String path = DateUtil.format(new Date(), "yyyyMMdd") + "/" + uuid; |
| | | if (StrUtil.isNotBlank(prefix)) { |
| | | path = prefix + "/" + path; |
| | | } |
| | | return path + suffix; |
| | | } |
| | | |
| | | @Override |
| | | public abstract UploadResult upload(byte[] data, String path, String contentType); |
| | | |
| | | @Override |
| | | public abstract void delete(String path); |
| | | |
| | | @Override |
| | | public UploadResult upload(InputStream inputStream, String path, String contentType) { |
| | | byte[] data = IoUtil.readBytes(inputStream); |
| | | return this.upload(data, path, contentType); |
| | | } |
| | | |
| | | @Override |
| | | public abstract UploadResult uploadSuffix(byte[] data, String suffix, String contentType); |
| | | |
| | | @Override |
| | | public abstract UploadResult uploadSuffix(InputStream inputStream, String suffix, String contentType); |
| | | |
| | | @Override |
| | | public abstract void afterPropertiesSet() throws Exception; |
| | | |
| | | @Override |
| | | public abstract String getEndpointLink(); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.CannedAccessControlList; |
| | | import com.aliyun.oss.model.CreateBucketRequest; |
| | | import com.aliyun.oss.model.ObjectMetadata; |
| | | import com.aliyun.oss.model.PutObjectRequest; |
| | | 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 java.io.ByteArrayInputStream; |
| | | import java.io.InputStream; |
| | | |
| | | /** |
| | | * é¿éäºåå¨ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Lazy |
| | | @Service |
| | | public class AliyunCloudStorageServiceImpl extends AbstractCloudStorageService implements InitializingBean { |
| | | |
| | | private final OSSClient client; |
| | | private final AliyunProperties properties; |
| | | |
| | | @Autowired |
| | | public AliyunCloudStorageServiceImpl(CloudStorageProperties properties) { |
| | | this.properties = properties.getAliyun(); |
| | | try { |
| | | ClientConfiguration configuration = new ClientConfiguration(); |
| | | DefaultCredentialProvider credentialProvider = new DefaultCredentialProvider( |
| | | this.properties.getAccessKeyId(), |
| | | this.properties.getAccessKeySecret()); |
| | | client = new OSSClient(this.properties.getEndpoint(), credentialProvider, configuration); |
| | | createBucket(); |
| | | } catch (Exception e) { |
| | | throw new IllegalArgumentException("é¿éäºåå¨é
ç½®é误! è¯·æ£æ¥ç³»ç»é
ç½®!"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void createBucket() { |
| | | try { |
| | | String bucketName = properties.getBucketName(); |
| | | if (client.doesBucketExist(bucketName)) { |
| | | return; |
| | | } |
| | | CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName); |
| | | createBucketRequest.setCannedACL(CannedAccessControlList.PublicRead); |
| | | client.createBucket(createBucketRequest); |
| | | } catch (Exception e) { |
| | | throw new OssException("å建Bucket失败, è¯·æ ¸å¯¹é¿éäºé
置信æ¯"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String getServiceType() { |
| | | return CloudServiceEnumd.ALIYUN.getValue(); |
| | | } |
| | | |
| | | @Override |
| | | public UploadResult upload(byte[] data, String path, String contentType) { |
| | | return upload(new ByteArrayInputStream(data), path, contentType); |
| | | } |
| | | |
| | | @Override |
| | | public UploadResult upload(InputStream inputStream, String path, String contentType) { |
| | | try { |
| | | ObjectMetadata metadata = new ObjectMetadata(); |
| | | metadata.setContentType(contentType); |
| | | client.putObject(new PutObjectRequest(properties.getBucketName(), path, inputStream, metadata)); |
| | | } catch (Exception e) { |
| | | throw new OssException("ä¸ä¼ æä»¶å¤±è´¥ï¼è¯·æ£æ¥é¿éäºé
置信æ¯"); |
| | | } |
| | | return new UploadResult().setUrl(getEndpointLink() + "/" + path).setFilename(path); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(String path) { |
| | | path = path.replace(getEndpointLink() + "/", ""); |
| | | try { |
| | | client.deleteObject(properties.getBucketName(), path); |
| | | } catch (Exception e) { |
| | | throw new OssException("ä¸ä¼ æä»¶å¤±è´¥ï¼è¯·æ£æ¥é¿éäºé
置信æ¯"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public UploadResult uploadSuffix(byte[] data, String suffix, String contentType) { |
| | | return upload(data, getPath(properties.getPrefix(), suffix), contentType); |
| | | } |
| | | |
| | | @Override |
| | | public UploadResult uploadSuffix(InputStream inputStream, String suffix, String contentType) { |
| | | return upload(inputStream, getPath(properties.getPrefix(), suffix), contentType); |
| | | } |
| | | |
| | | @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://")) { |
| | | sb.insert(7, properties.getBucketName() + "."); |
| | | } else if (StrUtil.containsAnyIgnoreCase(endpoint, "https://")) { |
| | | sb.insert(8, properties.getBucketName() + "."); |
| | | } else { |
| | | throw new OssException("Endpointé
ç½®é误"); |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.oss.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | 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 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åå¨ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Lazy |
| | | @Service |
| | | public class MinioCloudStorageServiceImpl extends AbstractCloudStorageService implements InitializingBean { |
| | | |
| | | private final MinioClient minioClient; |
| | | private final MinioProperties properties; |
| | | |
| | | @Autowired |
| | | public MinioCloudStorageServiceImpl(CloudStorageProperties properties) { |
| | | this.properties = properties.getMinio(); |
| | | try { |
| | | minioClient = MinioClient.builder() |
| | | .endpoint(this.properties.getEndpoint()) |
| | | .credentials(this.properties.getAccessKey(), this.properties.getSecretKey()) |
| | | .build(); |
| | | createBucket(); |
| | | } catch (Exception e) { |
| | | throw new IllegalArgumentException("Minioåå¨é
ç½®é误! è¯·æ£æ¥ç³»ç»é
ç½®!"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void createBucket() { |
| | | try { |
| | | String bucketName = properties.getBucketName(); |
| | | boolean exists = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build()); |
| | | if (exists) { |
| | | return; |
| | | } |
| | | // ä¸åå¨å°±å建桶 |
| | | minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build()); |
| | | minioClient.setBucketPolicy(SetBucketPolicyArgs.builder() |
| | | .bucket(bucketName) |
| | | .config(getPolicy(bucketName, PolicyType.READ)) |
| | | .build()); |
| | | } catch (Exception e) { |
| | | throw new OssException("å建Bucket失败, è¯·æ ¸å¯¹Minioé
置信æ¯"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String getServiceType() { |
| | | return CloudServiceEnumd.MINIO.getValue(); |
| | | } |
| | | |
| | | @Override |
| | | public UploadResult upload(byte[] data, String path, String contentType) { |
| | | return upload(new ByteArrayInputStream(data), path, contentType); |
| | | } |
| | | |
| | | @Override |
| | | public UploadResult upload(InputStream inputStream, String path, String contentType) { |
| | | try { |
| | | minioClient.putObject(PutObjectArgs.builder() |
| | | .bucket(properties.getBucketName()) |
| | | .object(path) |
| | | .contentType(StrUtil.blankToDefault(contentType, MediaType.APPLICATION_OCTET_STREAM_VALUE)) |
| | | .stream(inputStream, inputStream.available(), -1) |
| | | .build()); |
| | | } catch (Exception e) { |
| | | throw new OssException("ä¸ä¼ æä»¶å¤±è´¥ï¼è¯·æ ¸å¯¹Minioé
置信æ¯"); |
| | | } |
| | | return new UploadResult().setUrl(getEndpointLink() + "/" + path).setFilename(path); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(String path) { |
| | | path = path.replace(getEndpointLink() + "/", ""); |
| | | try { |
| | | minioClient.removeObject(RemoveObjectArgs.builder() |
| | | .bucket(properties.getBucketName()) |
| | | .object(path) |
| | | .build()); |
| | | } catch (Exception e) { |
| | | throw new OssException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public UploadResult uploadSuffix(byte[] data, String suffix, String contentType) { |
| | | return upload(data, getPath("", suffix), contentType); |
| | | } |
| | | |
| | | @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 |
| | | public String getEndpointLink() { |
| | | return properties.getEndpoint() + "/" + properties.getBucketName(); |
| | | } |
| | | |
| | | private String getPolicy(String bucketName, PolicyType policyType) { |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.append("{\n"); |
| | | builder.append(" \"Statement\": [\n"); |
| | | builder.append(" {\n"); |
| | | builder.append(" \"Action\": [\n"); |
| | | if (policyType == PolicyType.WRITE) { |
| | | builder.append(" \"s3:GetBucketLocation\",\n"); |
| | | builder.append(" \"s3:ListBucketMultipartUploads\"\n"); |
| | | } else if (policyType == PolicyType.READ_WRITE) { |
| | | builder.append(" \"s3:GetBucketLocation\",\n"); |
| | | builder.append(" \"s3:ListBucket\",\n"); |
| | | builder.append(" \"s3:ListBucketMultipartUploads\"\n"); |
| | | } else { |
| | | builder.append(" \"s3:GetBucketLocation\"\n"); |
| | | } |
| | | builder.append(" ],\n"); |
| | | builder.append(" \"Effect\": \"Allow\",\n"); |
| | | builder.append(" \"Principal\": \"*\",\n"); |
| | | builder.append(" \"Resource\": \"arn:aws:s3:::"); |
| | | builder.append(bucketName); |
| | | builder.append("\"\n"); |
| | | builder.append(" },\n"); |
| | | if (PolicyType.READ.equals(policyType)) { |
| | | builder.append(" {\n"); |
| | | builder.append(" \"Action\": [\n"); |
| | | builder.append(" \"s3:ListBucket\"\n"); |
| | | builder.append(" ],\n"); |
| | | builder.append(" \"Effect\": \"Deny\",\n"); |
| | | builder.append(" \"Principal\": \"*\",\n"); |
| | | builder.append(" \"Resource\": \"arn:aws:s3:::"); |
| | | builder.append(bucketName); |
| | | builder.append("\"\n"); |
| | | builder.append(" },\n"); |
| | | } |
| | | builder.append(" {\n"); |
| | | builder.append(" \"Action\": "); |
| | | switch (policyType) { |
| | | case WRITE: |
| | | builder.append("[\n"); |
| | | builder.append(" \"s3:AbortMultipartUpload\",\n"); |
| | | builder.append(" \"s3:DeleteObject\",\n"); |
| | | builder.append(" \"s3:ListMultipartUploadParts\",\n"); |
| | | builder.append(" \"s3:PutObject\"\n"); |
| | | builder.append(" ],\n"); |
| | | break; |
| | | case READ_WRITE: |
| | | builder.append("[\n"); |
| | | builder.append(" \"s3:AbortMultipartUpload\",\n"); |
| | | builder.append(" \"s3:DeleteObject\",\n"); |
| | | builder.append(" \"s3:GetObject\",\n"); |
| | | builder.append(" \"s3:ListMultipartUploadParts\",\n"); |
| | | builder.append(" \"s3:PutObject\"\n"); |
| | | builder.append(" ],\n"); |
| | | break; |
| | | default: |
| | | builder.append("\"s3:GetObject\",\n"); |
| | | break; |
| | | } |
| | | builder.append(" \"Effect\": \"Allow\",\n"); |
| | | builder.append(" \"Principal\": \"*\",\n"); |
| | | builder.append(" \"Resource\": \"arn:aws:s3:::"); |
| | | builder.append(bucketName); |
| | | builder.append("/*\"\n"); |
| | | builder.append(" }\n"); |
| | | builder.append(" ],\n"); |
| | | builder.append(" \"Version\": \"2012-10-17\"\n"); |
| | | builder.append("}\n"); |
| | | return builder.toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.auth.COSCredentials; |
| | | import com.qcloud.cos.http.HttpProtocol; |
| | | import com.qcloud.cos.model.*; |
| | | import com.qcloud.cos.region.Region; |
| | | 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 java.io.ByteArrayInputStream; |
| | | import java.io.InputStream; |
| | | |
| | | /** |
| | | * è
¾è®¯äºåå¨ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Lazy |
| | | @Service |
| | | public class QcloudCloudStorageServiceImpl extends AbstractCloudStorageService implements InitializingBean { |
| | | |
| | | private final COSClient client; |
| | | private final QcloudProperties properties; |
| | | |
| | | @Autowired |
| | | public QcloudCloudStorageServiceImpl(CloudStorageProperties properties) { |
| | | this.properties = properties.getQcloud(); |
| | | try { |
| | | COSCredentials credentials = new BasicCOSCredentials( |
| | | this.properties.getSecretId(), |
| | | this.properties.getSecretKey()); |
| | | // åå§å客æ·ç«¯é
ç½® |
| | | ClientConfig clientConfig = new ClientConfig(); |
| | | // 设置bucketæå¨çåºåï¼ååï¼gz ååï¼tj åä¸ï¼sh |
| | | clientConfig.setRegion(new Region(this.properties.getRegion())); |
| | | if (this.properties.getIsHttps()) { |
| | | clientConfig.setHttpProtocol(HttpProtocol.https); |
| | | } else { |
| | | clientConfig.setHttpProtocol(HttpProtocol.http); |
| | | } |
| | | client = new COSClient(credentials, clientConfig); |
| | | createBucket(); |
| | | } catch (Exception e) { |
| | | throw new IllegalArgumentException("è
¾è®¯äºåå¨é
ç½®é误! è¯·æ£æ¥ç³»ç»é
ç½®!"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void createBucket() { |
| | | try { |
| | | String bucketName = properties.getBucketName(); |
| | | if (client.doesBucketExist(bucketName)) { |
| | | return; |
| | | } |
| | | CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName); |
| | | createBucketRequest.setCannedAcl(CannedAccessControlList.PublicRead); |
| | | client.createBucket(createBucketRequest); |
| | | } catch (Exception e) { |
| | | throw new OssException("å建Bucket失败, è¯·æ ¸å¯¹è
¾è®¯äºé
置信æ¯"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String getServiceType() { |
| | | return CloudServiceEnumd.QCLOUD.getValue(); |
| | | } |
| | | |
| | | @Override |
| | | public UploadResult upload(byte[] data, String path, String contentType) { |
| | | return upload(new ByteArrayInputStream(data), path, contentType); |
| | | } |
| | | |
| | | @Override |
| | | public UploadResult upload(InputStream inputStream, String path, String contentType) { |
| | | try { |
| | | ObjectMetadata metadata = new ObjectMetadata(); |
| | | metadata.setContentType(contentType); |
| | | client.putObject(new PutObjectRequest(properties.getBucketName(), path, inputStream, metadata)); |
| | | } catch (Exception e) { |
| | | throw new OssException("ä¸ä¼ æä»¶å¤±è´¥ï¼è¯·æ£æ¥è
¾è®¯äºé
置信æ¯"); |
| | | } |
| | | return new UploadResult().setUrl(getEndpointLink() + "/" + path).setFilename(path); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(String path) { |
| | | path = path.replace(getEndpointLink() + "/", ""); |
| | | try { |
| | | client.deleteObject(new DeleteObjectRequest(properties.getBucketName(), path)); |
| | | } catch (Exception e) { |
| | | throw new OssException("ä¸ä¼ æä»¶å¤±è´¥ï¼è¯·æ£è
¾è®¯äºæ¥é
置信æ¯"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public UploadResult uploadSuffix(byte[] data, String suffix, String contentType) { |
| | | return upload(data, getPath(properties.getPrefix(), suffix), contentType); |
| | | } |
| | | |
| | | @Override |
| | | public UploadResult uploadSuffix(InputStream inputStream, String suffix, String contentType) { |
| | | return upload(inputStream, getPath(properties.getPrefix(), suffix), contentType); |
| | | } |
| | | |
| | | @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://")) { |
| | | sb.insert(7, properties.getBucketName() + "."); |
| | | } else if (StrUtil.containsAnyIgnoreCase(endpoint, "https://")) { |
| | | sb.insert(8, properties.getBucketName() + "."); |
| | | } else { |
| | | throw new OssException("Endpointé
ç½®é误"); |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.oss.service.impl; |
| | | |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import com.qiniu.http.Response; |
| | | import com.qiniu.storage.BucketManager; |
| | | import com.qiniu.storage.Configuration; |
| | | import com.qiniu.storage.Region; |
| | | import com.qiniu.storage.UploadManager; |
| | | import com.qiniu.util.Auth; |
| | | 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 java.io.InputStream; |
| | | |
| | | /** |
| | | * ä¸çäºåå¨ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Lazy |
| | | @Service |
| | | public class QiniuCloudStorageServiceImpl extends AbstractCloudStorageService implements InitializingBean { |
| | | |
| | | 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(); |
| | | try { |
| | | Configuration config = new Configuration(getRegion(this.properties.getRegion())); |
| | | // https设置 |
| | | config.useHttpsDomains = false; |
| | | if (this.properties.getIsHttps() != null) { |
| | | config.useHttpsDomains = this.properties.getIsHttps(); |
| | | } |
| | | uploadManager = new UploadManager(config); |
| | | Auth auth = Auth.create( |
| | | this.properties.getAccessKey(), |
| | | this.properties.getSecretKey()); |
| | | String bucketName = this.properties.getBucketName(); |
| | | token = auth.uploadToken(bucketName); |
| | | bucketManager = new BucketManager(auth, config); |
| | | |
| | | if (!ArrayUtil.contains(bucketManager.buckets(), bucketName)) { |
| | | bucketManager.createBucket(bucketName, this.properties.getRegion()); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new IllegalArgumentException("ä¸çäºåå¨é
ç½®é误! è¯·æ£æ¥ç³»ç»é
ç½®!"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void createBucket() { |
| | | try { |
| | | String bucketName = properties.getBucketName(); |
| | | if (ArrayUtil.contains(bucketManager.buckets(), bucketName)) { |
| | | return; |
| | | } |
| | | bucketManager.createBucket(bucketName, properties.getRegion()); |
| | | } catch (Exception e) { |
| | | throw new OssException("å建Bucket失败, è¯·æ ¸å¯¹ä¸çäºé
置信æ¯"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String getServiceType() { |
| | | return CloudServiceEnumd.QINIU.getValue(); |
| | | } |
| | | |
| | | @Override |
| | | public UploadResult upload(byte[] data, String path, String contentType) { |
| | | try { |
| | | Response res = uploadManager.put(data, path, token, null, contentType, false); |
| | | if (!res.isOK()) { |
| | | throw new RuntimeException("ä¸ä¼ ä¸çåºéï¼" + res.toString()); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new OssException("ä¸ä¼ æä»¶å¤±è´¥ï¼è¯·æ ¸å¯¹ä¸çé
置信æ¯"); |
| | | } |
| | | return new UploadResult().setUrl(getEndpointLink() + "/" + path).setFilename(path); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(String path) { |
| | | try { |
| | | path = path.replace(getEndpointLink() + "/", ""); |
| | | Response res = bucketManager.delete(properties.getBucketName(), path); |
| | | if (!res.isOK()) { |
| | | throw new RuntimeException("å é¤ä¸çæä»¶åºéï¼" + res.toString()); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new OssException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public UploadResult uploadSuffix(byte[] data, String suffix, String contentType) { |
| | | return upload(data, getPath(properties.getPrefix(), suffix), contentType); |
| | | } |
| | | |
| | | @Override |
| | | public UploadResult uploadSuffix(InputStream inputStream, String suffix, String contentType) { |
| | | return upload(inputStream, getPath(properties.getPrefix(), suffix), contentType); |
| | | } |
| | | |
| | | @Override |
| | | public void afterPropertiesSet() throws Exception { |
| | | OssFactory.register(getServiceType(),this); |
| | | } |
| | | |
| | | @Override |
| | | public String getEndpointLink() { |
| | | return properties.getDomain(); |
| | | } |
| | | |
| | | private Region getRegion(String region) { |
| | | switch (region) { |
| | | case "z0": |
| | | return Region.region0(); |
| | | case "z1": |
| | | return Region.region1(); |
| | | case "z2": |
| | | return Region.region2(); |
| | | case "na0": |
| | | return Region.regionNa0(); |
| | | case "as0": |
| | | return Region.regionAs0(); |
| | | default: |
| | | return Region.autoRegion(); |
| | | } |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.controller; |
| | | |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.http.HttpUtil; |
| | | 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.utils.file.FileUtils; |
| | | import com.ruoyi.system.domain.bo.SysOssBo; |
| | | import com.ruoyi.system.domain.SysOss; |
| | | import com.ruoyi.system.service.ISysOssService; |
| | | import com.ruoyi.system.domain.vo.SysOssVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * æä»¶ä¸ä¼ æ§å¶å± |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Api(value = "OSSäºå卿§å¶å¨", tags = {"OSSäºåå¨ç®¡ç"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RestController |
| | | @RequestMapping("/system/oss") |
| | | public class SysOssController extends BaseController { |
| | | |
| | | private final ISysOssService iSysOssService; |
| | | |
| | | /** |
| | | * æ¥è¯¢OSSäºåå¨å表 |
| | | */ |
| | | @ApiOperation("æ¥è¯¢OSSäºåå¨å表") |
| | | @PreAuthorize("@ss.hasPermi('system:oss:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysOssVo> list(@Validated SysOssBo bo) { |
| | | return iSysOssService.queryPageList(bo); |
| | | } |
| | | |
| | | /** |
| | | * ä¸ä¼ OSSäºåå¨ |
| | | */ |
| | | @ApiOperation("ä¸ä¼ OSSäºåå¨") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "file", value = "æä»¶", dataType = "java.io.File", required = true), |
| | | }) |
| | | @PreAuthorize("@ss.hasPermi('system:oss:upload')") |
| | | @Log(title = "OSSäºåå¨", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit |
| | | @PostMapping("/upload") |
| | | public AjaxResult<Map<String, String>> upload(@RequestPart("file") MultipartFile file) { |
| | | if (file.isEmpty()) { |
| | | throw new CustomException("ä¸ä¼ æä»¶ä¸è½ä¸ºç©º"); |
| | | } |
| | | SysOss oss = iSysOssService.upload(file); |
| | | Map<String, String> map = new HashMap<>(2); |
| | | map.put("url", oss.getUrl()); |
| | | map.put("fileName", oss.getFileName()); |
| | | return AjaxResult.success(map); |
| | | } |
| | | |
| | | @ApiOperation("ä¸è½½OSSäºåå¨") |
| | | @PreAuthorize("@ss.hasPermi('system:oss:download')") |
| | | @GetMapping("/download/{ossId}") |
| | | public void download(@PathVariable Long ossId, HttpServletResponse response) throws IOException { |
| | | SysOss sysOss = iSysOssService.getById(ossId); |
| | | if (sysOss == null) { |
| | | throw new CustomException("æä»¶æ°æ®ä¸åå¨!"); |
| | | } |
| | | response.reset(); |
| | | response.addHeader("Access-Control-Allow-Origin", "*"); |
| | | response.addHeader("Access-Control-Expose-Headers", "Content-Disposition"); |
| | | FileUtils.setAttachmentResponseHeader(response, URLEncoder.encode(sysOss.getOriginalName(), StandardCharsets.UTF_8)); |
| | | response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8"); |
| | | long data = HttpUtil.download(sysOss.getUrl(), response.getOutputStream(), false); |
| | | response.setContentLength(Convert.toInt(data)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤OSSäºåå¨ |
| | | */ |
| | | @ApiOperation("å é¤OSSäºåå¨") |
| | | @PreAuthorize("@ss.hasPermi('system:oss:remove')") |
| | | @Log(title = "OSSäºåå¨" , businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ossIds}") |
| | | public AjaxResult<Void> remove(@NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable Long[] ossIds) { |
| | | return toAjax(iSysOssService.deleteWithValidByIds(Arrays.asList(ossIds), true) ? 1 : 0); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | |
| | | /** |
| | | * OSSäºåå¨å¯¹è±¡ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @NoArgsConstructor |
| | | @Accessors(chain = true) |
| | | @TableName("sys_oss") |
| | | public class SysOss implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | |
| | | /** |
| | | * äºåå¨ä¸»é® |
| | | */ |
| | | @TableId(value = "oss_id", type = IdType.AUTO) |
| | | private Long ossId; |
| | | |
| | | /** |
| | | * æä»¶å |
| | | */ |
| | | private String fileName; |
| | | |
| | | /** |
| | | * åå |
| | | */ |
| | | private String originalName; |
| | | |
| | | /** |
| | | * æä»¶åç¼å |
| | | */ |
| | | private String fileSuffix; |
| | | |
| | | /** |
| | | * URLå°å |
| | | */ |
| | | private String url; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * ä¸ä¼ 人 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * æ´æ°äºº |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | /** |
| | | * æå¡å |
| | | */ |
| | | private String service; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.domain.bo; |
| | | |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * OSSäºåå¨å页æ¥è¯¢å¯¹è±¡ sys_oss |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel("OSSäºåå¨å页æ¥è¯¢å¯¹è±¡") |
| | | public class SysOssBo extends BaseEntity { |
| | | |
| | | /** |
| | | * åé¡µå¤§å° |
| | | */ |
| | | @ApiModelProperty("å页大å°") |
| | | private Integer pageSize; |
| | | /** |
| | | * å½åé¡µæ° |
| | | */ |
| | | @ApiModelProperty("å½å页æ°") |
| | | private Integer pageNum; |
| | | /** |
| | | * æåºå |
| | | */ |
| | | @ApiModelProperty("æåºå") |
| | | private String orderByColumn; |
| | | /** |
| | | * æåºçæ¹ådescæè
asc |
| | | */ |
| | | @ApiModelProperty(value = "æåºçæ¹å", example = "asc,desc") |
| | | private String isAsc; |
| | | |
| | | |
| | | /** |
| | | * æä»¶å |
| | | */ |
| | | @ApiModelProperty("æä»¶å") |
| | | private String fileName; |
| | | /** |
| | | * åå |
| | | */ |
| | | @ApiModelProperty("åå") |
| | | private String originalName; |
| | | /** |
| | | * æä»¶åç¼å |
| | | */ |
| | | @ApiModelProperty("æä»¶åç¼å") |
| | | private String fileSuffix; |
| | | /** |
| | | * URLå°å |
| | | */ |
| | | @ApiModelProperty("URLå°å") |
| | | private String url; |
| | | /** |
| | | * æå¡å |
| | | */ |
| | | @ApiModelProperty("æå¡å") |
| | | private String service; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.domain.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * OSSäºåå¨è§å¾å¯¹è±¡ sys_oss |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @ApiModel("OSSäºåå¨è§å¾å¯¹è±¡") |
| | | public class SysOssVo { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * äºåå¨ä¸»é® |
| | | */ |
| | | @ApiModelProperty("äºåå¨ä¸»é®") |
| | | private Long ossId; |
| | | |
| | | /** |
| | | * æä»¶å |
| | | */ |
| | | @ApiModelProperty("æä»¶å") |
| | | private String fileName; |
| | | |
| | | /** |
| | | * åå |
| | | */ |
| | | @ApiModelProperty("åå") |
| | | private String originalName; |
| | | |
| | | /** |
| | | * æä»¶åç¼å |
| | | */ |
| | | @ApiModelProperty("æä»¶åç¼å") |
| | | private String fileSuffix; |
| | | |
| | | /** |
| | | * URLå°å |
| | | */ |
| | | @ApiModelProperty("URLå°å") |
| | | private String url; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @ApiModelProperty("å建æ¶é´") |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * ä¸ä¼ 人 |
| | | */ |
| | | @ApiModelProperty("ä¸ä¼ 人") |
| | | private String createBy; |
| | | |
| | | /** |
| | | * æå¡å |
| | | */ |
| | | @ApiModelProperty("æå¡å") |
| | | private String service; |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysOss; |
| | | |
| | | /** |
| | | * æä»¶ä¸ä¼ æ°æ®å± |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysOssMapper extends BaseMapperPlus<SysOss> { |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.bo.SysOssBo; |
| | | import com.ruoyi.system.domain.SysOss; |
| | | import com.ruoyi.system.domain.vo.SysOssVo; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.Collection; |
| | | |
| | | /** |
| | | * æä»¶ä¸ä¼ æå¡å± |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysOssService extends IServicePlus<SysOss, SysOssVo> { |
| | | |
| | | TableDataInfo<SysOssVo> queryPageList(SysOssBo sysOss); |
| | | |
| | | SysOss upload(MultipartFile file); |
| | | |
| | | Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.utils.PageUtils; |
| | | 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.system.domain.SysOss; |
| | | 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; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * æä»¶ä¸ä¼ æå¡å±å®ç° |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Service |
| | | public class SysOssServiceImpl extends ServicePlusImpl<SysOssMapper, SysOss, SysOssVo> implements ISysOssService { |
| | | |
| | | @Override |
| | | public TableDataInfo<SysOssVo> queryPageList(SysOssBo bo) { |
| | | PagePlus<SysOss, SysOssVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo)); |
| | | return PageUtils.buildDataInfo(result); |
| | | } |
| | | |
| | | 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.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()); |
| | | 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(); |
| | | UploadResult uploadResult; |
| | | try { |
| | | uploadResult = storage.uploadSuffix(file.getBytes(), suffix, file.getContentType()); |
| | | } catch (IOException e) { |
| | | throw new CustomException("æä»¶è¯»åå¼å¸¸!!!", e); |
| | | } |
| | | // ä¿åæä»¶ä¿¡æ¯ |
| | | SysOss oss = new SysOss() |
| | | .setUrl(uploadResult.getUrl()) |
| | | .setFileSuffix(suffix) |
| | | .setFileName(uploadResult.getFilename()) |
| | | .setOriginalName(originalfileName) |
| | | .setService(storage.getServiceType()); |
| | | save(oss); |
| | | return oss; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
| | | if (isValid) { |
| | | // åä¸äºä¸å¡ä¸çæ ¡éª,夿æ¯å¦éè¦æ ¡éª |
| | | } |
| | | List<SysOss> list = listByIds(ids); |
| | | for (SysOss sysOss : list) { |
| | | ICloudStorageService storage = OssFactory.instance(sysOss.getService()); |
| | | storage.delete(sysOss.getUrl()); |
| | | } |
| | | return removeByIds(ids); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.SysOssMapper"> |
| | | |
| | | <resultMap type="com.ruoyi.system.domain.SysOss" id="SysOssResult"> |
| | | <result property="ossId" column="oss_id"/> |
| | | <result property="fileName" column="file_name"/> |
| | | <result property="fileSuffix" column="file_suffix"/> |
| | | <result property="url" column="url"/> |
| | | <result property="createTime" column="create_time"/> |
| | | <result property="createBy" column="create_by"/> |
| | | <result property="updateTime" column="update_time"/> |
| | | <result property="updateBy" column="update_by"/> |
| | | <result property="service" column="service"/> |
| | | </resultMap> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.5.2</version> |
| | | <version>2.6.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | |
| | | package com.ruoyi.quartz.service; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.quartz.domain.SysJobLog; |
| | | |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysJobLogService extends IServicePlus<SysJobLog> { |
| | | public interface ISysJobLogService extends IService<SysJobLog> { |
| | | |
| | | |
| | | TableDataInfo<SysJobLog> selectPageJobLogList(SysJobLog jobLog); |
| | |
| | | package com.ruoyi.quartz.service; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.job.TaskException; |
| | | import com.ruoyi.quartz.domain.SysJob; |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysJobService extends IServicePlus<SysJob> { |
| | | public interface ISysJobService extends IService<SysJob> { |
| | | /** |
| | | * è·åquartzè°åº¦å¨ç计åä»»å¡ |
| | | * |
| | |
| | | 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.quartz.domain.SysJobLog; |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysJobLogServiceImpl extends ServicePlusImpl<SysJobLogMapper, SysJobLog> implements ISysJobLogService { |
| | | public class SysJobLogServiceImpl extends ServiceImpl<SysJobLogMapper, SysJobLog> implements ISysJobLogService { |
| | | |
| | | @Override |
| | | public TableDataInfo<SysJobLog> selectPageJobLogList(SysJobLog jobLog) { |
| | |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.constant.ScheduleConstants; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.job.TaskException; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysJobServiceImpl extends ServicePlusImpl<SysJobMapper, SysJob> implements ISysJobService { |
| | | public class SysJobServiceImpl extends ServiceImpl<SysJobMapper, SysJob> implements ISysJobService { |
| | | @Autowired |
| | | private Scheduler scheduler; |
| | | |
| | |
| | | <parent> |
| | | <artifactId>ruoyi-vue-plus</artifactId> |
| | | <groupId>com.ruoyi</groupId> |
| | | <version>2.5.2</version> |
| | | <version>2.6.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysConfigService extends IServicePlus<SysConfig> { |
| | | public interface ISysConfigService extends IService<SysConfig> { |
| | | |
| | | |
| | | TableDataInfo<SysConfig> selectPageConfigList(SysConfig config); |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.TreeSelect; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysDeptService extends IServicePlus<SysDept> { |
| | | public interface ISysDeptService extends IService<SysDept> { |
| | | /** |
| | | * æ¥è¯¢é¨é¨ç®¡çæ°æ® |
| | | * |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | |
| | | import java.util.List; |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysDictDataService extends IServicePlus<SysDictData> { |
| | | public interface ISysDictDataService extends IService<SysDictData> { |
| | | |
| | | |
| | | TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData); |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.domain.entity.SysDictType; |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | |
| | | import java.util.List; |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysDictTypeService extends IServicePlus<SysDictType> { |
| | | public interface ISysDictTypeService extends IService<SysDictType> { |
| | | |
| | | |
| | | TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType); |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysLogininfor; |
| | | |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysLogininforService extends IServicePlus<SysLogininfor> { |
| | | public interface ISysLogininforService extends IService<SysLogininfor> { |
| | | |
| | | |
| | | TableDataInfo<SysLogininfor> selectPageLogininforList(SysLogininfor logininfor); |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.TreeSelect; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.ruoyi.system.domain.vo.RouterVo; |
| | | |
| | | import java.util.List; |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysMenuService extends IServicePlus<SysMenu> { |
| | | public interface ISysMenuService extends IService<SysMenu> { |
| | | /** |
| | | * æ ¹æ®ç¨æ·æ¥è¯¢ç³»ç»èåå表 |
| | | * |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysNotice; |
| | | |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysNoticeService extends IServicePlus<SysNotice> { |
| | | public interface ISysNoticeService extends IService<SysNotice> { |
| | | |
| | | |
| | | TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice); |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysOperLog; |
| | | |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysOperLogService extends IServicePlus<SysOperLog> { |
| | | public interface ISysOperLogService extends IService<SysOperLog> { |
| | | |
| | | TableDataInfo<SysOperLog> selectPageOperLogList(SysOperLog operLog); |
| | | |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.SysPost; |
| | | |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysPostService extends IServicePlus<SysPost> { |
| | | public interface ISysPostService extends IService<SysPost> { |
| | | |
| | | |
| | | TableDataInfo<SysPost> selectPagePostList(SysPost post); |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | |
| | | import java.util.List; |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysRoleService extends IServicePlus<SysRole> { |
| | | public interface ISysRoleService extends IService<SysRole> { |
| | | |
| | | |
| | | TableDataInfo<SysRole> selectPageRoleList(SysRole role); |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.mybatisplus.core.IServicePlus; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | |
| | | import java.util.List; |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysUserService extends IServicePlus<SysUser> { |
| | | public interface ISysUserService extends IService<SysUser> { |
| | | |
| | | |
| | | TableDataInfo<SysUser> selectPageUserList(SysUser user); |
| | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.annotation.DataSource; |
| | | import com.ruoyi.common.constant.Constants; |
| | | 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.core.redis.RedisCache; |
| | | import com.ruoyi.common.enums.DataSourceType; |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysConfigServiceImpl extends ServicePlusImpl<SysConfigMapper, SysConfig> implements ISysConfigService { |
| | | public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements ISysConfigService { |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | |
| | | * |
| | | * @return trueå¼å¯ï¼falseå
³é |
| | | */ |
| | | @Override |
| | | public boolean selectCaptchaOnOff() { |
| | | String captchaOnOff = selectConfigByKey("sys.account.captchaOnOff"); |
| | | if (StrUtil.isEmpty(captchaOnOff)) { |
| | |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.TreeSelect; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.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.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMapper; |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept> implements ISysDeptService { |
| | | public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements ISysDeptService { |
| | | |
| | | @Autowired |
| | | private SysRoleMapper roleMapper; |
| | |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.DictUtils; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | |
| | | import com.ruoyi.system.service.ISysDictDataService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysDictDataServiceImpl extends ServicePlusImpl<SysDictDataMapper, SysDictData> implements ISysDictDataService { |
| | | public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDictData> implements ISysDictDataService { |
| | | |
| | | @Override |
| | | public TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData) { |
| | |
| | | public void deleteDictDataByIds(Long[] dictCodes) { |
| | | for (Long dictCode : dictCodes) { |
| | | SysDictData data = selectDictDataById(dictCode); |
| | | removeById(dictCode); |
| | | List<SysDictData> dictDatas = baseMapper.selectDictDataByType(data.getDictType()); |
| | | DictUtils.setDictCache(data.getDictType(), dictDatas); |
| | | } |
| | | baseMapper.deleteBatchIds(Arrays.asList(dictCodes)); |
| | | } |
| | | |
| | | /** |
| | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.domain.entity.SysDictType; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.utils.DictUtils; |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, SysDictType> implements ISysDictTypeService { |
| | | public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements ISysDictTypeService { |
| | | |
| | | @Autowired |
| | | private SysDictDataMapper dictDataMapper; |
| | |
| | | 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.system.domain.SysLogininfor; |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysLogininforServiceImpl extends ServicePlusImpl<SysLogininforMapper, SysLogininfor> implements ISysLogininforService { |
| | | public class SysLogininforServiceImpl extends ServiceImpl<SysLogininforMapper, SysLogininfor> implements ISysLogininforService { |
| | | |
| | | @Override |
| | | public TableDataInfo<SysLogininfor> selectPageLogininforList(SysLogininfor logininfor) { |
| | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.TreeSelect; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | 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.system.domain.SysRoleMenu; |
| | | import com.ruoyi.system.domain.vo.MetaVo; |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu> implements ISysMenuService { |
| | | public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService { |
| | | public static final String PREMISSION_STRING = "perms[\"{0}\"]"; |
| | | |
| | | @Autowired |
| | |
| | | childrenList.add(children); |
| | | router.setChildren(childrenList); |
| | | } else if (menu.getParentId().intValue() == 0 && isInnerLink(menu)) { |
| | | router.setMeta(null); |
| | | router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon())); |
| | | router.setPath("/inner"); |
| | | List<RouterVo> childrenList = new ArrayList<RouterVo>(); |
| | | RouterVo children = new RouterVo(); |
| | | String routerPath = StringUtils.replaceEach(menu.getPath(), new String[] { Constants.HTTP, Constants.HTTPS }, new String[] { "", "" }); |
| | | children.setPath(routerPath); |
| | | children.setComponent(UserConstants.INNER_LINK); |
| | | children.setName(StringUtils.capitalize(routerPath)); |
| | | children.setName(StrUtil.upperFirst(routerPath)); |
| | | children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.getPath())); |
| | | childrenList.add(children); |
| | | router.setChildren(childrenList); |
| | |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.system.domain.SysNotice; |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysNoticeServiceImpl extends ServicePlusImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService { |
| | | public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService { |
| | | |
| | | @Override |
| | | public TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice) { |
| | |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.system.domain.SysOperLog; |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysOperLogServiceImpl extends ServicePlusImpl<SysOperLogMapper, SysOperLog> implements ISysOperLogService { |
| | | public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOperLog> implements ISysOperLogService { |
| | | |
| | | @Override |
| | | public TableDataInfo<SysOperLog> selectPageOperLogList(SysOperLog operLog) { |
| | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | 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.utils.PageUtils; |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost> implements ISysPostService { |
| | | public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> implements ISysPostService { |
| | | |
| | | @Autowired |
| | | private SysUserPostMapper userPostMapper; |
| | |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | 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.utils.PageUtils; |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole> implements ISysRoleService { |
| | | public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService { |
| | | |
| | | @Autowired |
| | | private SysRoleMenuMapper roleMenuMapper; |
| | |
| | | @Override |
| | | public int insertAuthUsers(Long roleId, Long[] userIds) { |
| | | // æ°å¢ç¨æ·ä¸è§è²ç®¡ç |
| | | List<SysUserRole> list = new ArrayList<SysUserRole>(); |
| | | int rows = 1; |
| | | List<SysUserRole> list = new ArrayList<SysUserRole>(); |
| | | for (Long userId : userIds) { |
| | | SysUserRole ur = new SysUserRole(); |
| | | ur.setUserId(userId); |
| | | ur.setRoleId(roleId); |
| | | list.add(ur); |
| | | } |
| | | return userRoleMapper.insertAll(list); |
| | | if (list.size() > 0) { |
| | | rows = userRoleMapper.insertAll(list); |
| | | } |
| | | return rows; |
| | | } |
| | | } |
| | |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.CustomException; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser> implements ISysUserService { |
| | | public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService { |
| | | |
| | | @Autowired |
| | | private SysRoleMapper roleMapper; |
| | |
| | | { |
| | | "name": "ruoyi-vue-plus", |
| | | "version": "2.5.2", |
| | | "version": "2.6.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.2", |
| | | "element-ui": "2.15.3", |
| | | "file-saver": "2.0.4", |
| | | "fuse.js": "6.4.3", |
| | | "highlight.js": "9.18.5", |
| | |
| | | }) |
| | | } |
| | | |
| | | // èªå®ä¹å页æ¥å£ |
| | | export function pageDemo(query) { |
| | | return request({ |
| | | url: '/demo/demo/page', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | | |
| | | // æ¥è¯¢æµè¯åè¡¨è¯¦ç» |
| | | export function getDemo(id) { |
| | | return request({ |
| | |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import request from '@/utils/request' |
| | | |
| | | // æ¥è¯¢OSSäºåå¨å表 |
| | | export function listOss(query) { |
| | | return request({ |
| | | url: '/system/oss/list', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | | |
| | | // å é¤OSSäºåå¨ |
| | | export function delOss(ossId) { |
| | | return request({ |
| | | url: '/system/oss/' + ossId, |
| | | method: 'delete' |
| | | }) |
| | | } |
| | |
| | | <div> |
| | | <el-upload |
| | | :action="uploadUrl" |
| | | :before-upload="handleBeforeUpload" |
| | | :on-success="handleUploadSuccess" |
| | | :on-error="handleUploadError" |
| | | name="file" |
| | |
| | | type: Boolean, |
| | | default: false, |
| | | }, |
| | | // ä¸ä¼ æä»¶å¤§å°éå¶(MB) |
| | | fileSize: { |
| | | type: Number, |
| | | default: 5, |
| | | }, |
| | | /* ç±»åï¼base64æ ¼å¼ãurlæ ¼å¼ï¼ */ |
| | | type: { |
| | | type: String, |
| | |
| | | }, |
| | | data() { |
| | | return { |
| | | uploadUrl: process.env.VUE_APP_BASE_API + "/common/upload", // ä¸ä¼ çå¾çæå¡å¨å°å |
| | | uploadUrl: process.env.VUE_APP_BASE_API + "/system/oss/upload", // ä¸ä¼ çå¾çæå¡å¨å°å |
| | | headers: { |
| | | Authorization: "Bearer " + getToken() |
| | | }, |
| | |
| | | this.quill.format("image", false); |
| | | } |
| | | }); |
| | | // toolbar.addHandler("video", (value) => { |
| | | // this.uploadType = "video"; |
| | | // if (value) { |
| | | // this.$refs.upload.$children[0].$refs.input.click(); |
| | | // } else { |
| | | // this.quill.format("video", false); |
| | | // } |
| | | // }); |
| | | } |
| | | this.Quill.pasteHTML(this.currentValue); |
| | | this.Quill.on("text-change", (delta, oldDelta, source) => { |
| | |
| | | this.$emit("on-editor-change", eventName, ...args); |
| | | }); |
| | | }, |
| | | // ä¸ä¼ åæ ¡æ£æ ¼å¼åå¤§å° |
| | | handleBeforeUpload(file) { |
| | | // æ ¡æ£æä»¶å¤§å° |
| | | if (this.fileSize) { |
| | | const isLt = file.size / 1024 / 1024 < this.fileSize; |
| | | if (!isLt) { |
| | | this.$message.error(`ä¸ä¼ æä»¶å¤§å°ä¸è½è¶
è¿ ${this.fileSize} MB!`); |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | }, |
| | | handleUploadSuccess(res, file) { |
| | | // è·å坿æ¬ç»ä»¶å®ä¾ |
| | | let quill = this.Quill; |
| | |
| | | <!-- æä»¶å表 --> |
| | | <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul"> |
| | | <li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList"> |
| | | <el-link :href="`${baseUrl}${file.url}`" :underline="false" target="_blank"> |
| | | <el-link :href="`${file.url}`" :underline="false" target="_blank"> |
| | | <span class="el-icon-document"> {{ getFileName(file.name) }} </span> |
| | | </el-link> |
| | | <div class="ele-upload-list__item-content-action"> |
| | |
| | | data() { |
| | | return { |
| | | baseUrl: process.env.VUE_APP_BASE_API, |
| | | uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // ä¸ä¼ çå¾çæå¡å¨å°å |
| | | uploadFileUrl: process.env.VUE_APP_BASE_API + "/system/oss/upload", // ä¸ä¼ çå¾çæå¡å¨å°å |
| | | headers: { |
| | | Authorization: "Bearer " + getToken(), |
| | | }, |
| | |
| | | dialogVisible: false, |
| | | hideUpload: false, |
| | | baseUrl: process.env.VUE_APP_BASE_API, |
| | | uploadImgUrl: process.env.VUE_APP_BASE_API + "/common/upload", // ä¸ä¼ çå¾çæå¡å¨å°å |
| | | uploadImgUrl: process.env.VUE_APP_BASE_API + "/system/oss/upload", // ä¸ä¼ çå¾çæå¡å¨å°å |
| | | headers: { |
| | | Authorization: "Bearer " + getToken(), |
| | | }, |
| | |
| | | // ç¶åå°æ°ç»è½¬ä¸ºå¯¹è±¡æ°ç» |
| | | this.fileList = list.map(item => { |
| | | if (typeof item === "string") { |
| | | if (item.indexOf(this.baseUrl) === -1) { |
| | | item = { name: this.baseUrl + item, url: this.baseUrl + item }; |
| | | } else { |
| | | item = { name: item, url: item }; |
| | | } |
| | | item = { name: item, url: item }; |
| | | } |
| | | return item; |
| | | }); |
| | |
| | | }, |
| | | // ä¸ä¼ æååè° |
| | | handleUploadSuccess(res) { |
| | | this.fileList.push({ name: res.data.fileName, url: res.data.fileName }); |
| | | this.fileList.push({ name: res.data.fileName, url: res.data.url }); |
| | | this.$emit("input", this.listToString(this.fileList)); |
| | | this.loading.close(); |
| | | }, |
| | |
| | | <template>
|
| | | <div>
|
| | | <svg-icon icon-class="question" @click="goto"/>
|
| | | </div>
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | export default {
|
| | | name: 'RuoYiDoc',
|
| | | data() {
|
| | | return {
|
| | | url: 'http://doc.ruoyi.vip/ruoyi-vue'
|
| | | }
|
| | | },
|
| | | methods: {
|
| | | goto() {
|
| | | window.open(this.url)
|
| | | }
|
| | | }
|
| | | }
|
| | | </script> |
| | | <template> |
| | | <div> |
| | | <svg-icon icon-class="question" @click="goto"/> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | name: 'RuoYiDoc', |
| | | data() { |
| | | return { |
| | | url: 'https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages' |
| | | } |
| | | }, |
| | | methods: { |
| | | goto() { |
| | | window.open(this.url) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | |
| | | name: 'RuoYiGit', |
| | | data() { |
| | | return { |
| | | url: 'https://gitee.com/y_project/RuoYi-Vue' |
| | | url: 'https://gitee.com/JavaLionLi/RuoYi-Vue-Plus' |
| | | } |
| | | }, |
| | | methods: { |
| | |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | </script> |
| | |
| | | </template> |
| | | |
| | | <!-- é¡¶é¨èåè¶
åºæ°éæå --> |
| | | <el-submenu index="more" v-if="topMenus.length > visibleNumber"> |
| | | <el-submenu :style="{'--theme': theme}" index="more" v-if="topMenus.length > visibleNumber"> |
| | | <template slot="title">æ´å¤èå</template> |
| | | <template v-for="(item, index) in topMenus"> |
| | | <el-menu-item |
| | |
| | | // é»è®¤æ¿æ´»çèå |
| | | activeMenu() { |
| | | const path = this.$route.path; |
| | | let activePath = this.routers[0].path; |
| | | let activePath = this.defaultRouter(); |
| | | if (path.lastIndexOf("/") > 0) { |
| | | const tmpPath = path.substring(1, path.length); |
| | | activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/")); |
| | |
| | | } |
| | | var routes = this.activeRoutes(activePath); |
| | | if (routes.length === 0) { |
| | | activePath = this.currentIndex || this.routers[0].path |
| | | activePath = this.currentIndex || this.defaultRouter() |
| | | this.activeRoutes(activePath); |
| | | } |
| | | return activePath; |
| | |
| | | setVisibleNumber() { |
| | | const width = document.body.getBoundingClientRect().width / 3; |
| | | this.visibleNumber = parseInt(width / 85); |
| | | }, |
| | | // é»è®¤æ¿æ´»çè·¯ç± |
| | | defaultRouter() { |
| | | let router; |
| | | Object.keys(this.routers).some((key) => { |
| | | if (!this.routers[key].hidden) { |
| | | router = this.routers[key].path; |
| | | return true; |
| | | } |
| | | }); |
| | | return router; |
| | | }, |
| | | // èåéæ©äºä»¶ |
| | | handleSelect(key, keyPath) { |
| | |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | .el-menu--horizontal > .el-menu-item { |
| | | .topmenu-container.el-menu--horizontal > .el-menu-item { |
| | | float: left; |
| | | height: 50px; |
| | | line-height: 50px; |
| | | margin: 0; |
| | | border-bottom: 3px solid transparent; |
| | | color: #999093; |
| | | padding: 0 5px; |
| | | margin: 0 10px; |
| | | height: 50px !important; |
| | | line-height: 50px !important; |
| | | color: #999093 !important; |
| | | padding: 0 5px !important; |
| | | margin: 0 10px !important; |
| | | } |
| | | |
| | | .el-menu--horizontal > .el-menu-item.is-active { |
| | | border-bottom: 3px solid #{'var(--theme)'}; |
| | | .topmenu-container.el-menu--horizontal > .el-menu-item.is-active, .el-menu--horizontal > .el-submenu.is-active .el-submenu__title { |
| | | border-bottom: 2px solid #{'var(--theme)'} !important; |
| | | color: #303133; |
| | | } |
| | | |
| | | /* submenu item */ |
| | | .el-menu--horizontal > .el-submenu .el-submenu__title { |
| | | height: 50px !important; |
| | | line-height: 50px !important; |
| | | .topmenu-container.el-menu--horizontal > .el-submenu .el-submenu__title { |
| | | float: left; |
| | | height: 50px !important; |
| | | line-height: 50px !important; |
| | | color: #999093 !important; |
| | | padding: 0 5px !important; |
| | | margin: 0 10px !important; |
| | | } |
| | | </style> |
| | |
| | | |
| | | /* Layout */ |
| | | import Layout from '@/layout' |
| | | import ParentView from '@/components/ParentView'; |
| | | import InnerLink from '@/layout/components/InnerLink' |
| | | |
| | | /** |
| | | * Note: è·¯ç±é
置项 |
| | |
| | | title: 'title' // 设置该路ç±å¨ä¾§è¾¹æ åé¢å
å±ä¸å±ç¤ºçåå |
| | | icon: 'svg-name' // 设置该路ç±ç徿 ï¼å¯¹åºè·¯å¾src/assets/icons/svg |
| | | breadcrumb: false // å¦æè®¾ç½®ä¸ºfalseï¼åä¸ä¼å¨breadcrumbé¢å
å±ä¸æ¾ç¤º |
| | | activeMenu: '/system/user' // å½è·¯ç±è®¾ç½®äºè¯¥å±æ§ï¼åä¼é«äº®ç¸å¯¹åºçä¾§è¾¹æ ã |
| | | } |
| | | */ |
| | | |
| | |
| | | ] |
| | | }, |
| | | { |
| | | path: '/auth', |
| | | path: '/system/user-auth', |
| | | component: Layout, |
| | | hidden: true, |
| | | children: [ |
| | |
| | | path: 'role/:userId(\\d+)', |
| | | component: (resolve) => require(['@/views/system/user/authRole'], resolve), |
| | | name: 'AuthRole', |
| | | meta: { title: 'åé
è§è²'} |
| | | meta: { title: 'åé
è§è²', activeMenu: '/system/user'} |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | path: '/auth', |
| | | path: '/system/role-auth', |
| | | component: Layout, |
| | | hidden: true, |
| | | children: [ |
| | |
| | | path: 'user/:roleId(\\d+)', |
| | | component: (resolve) => require(['@/views/system/role/authUser'], resolve), |
| | | name: 'AuthUser', |
| | | meta: { title: 'åé
ç¨æ·'} |
| | | meta: { title: 'åé
ç¨æ·', activeMenu: '/system/role'} |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | path: '/dict', |
| | | path: '/system/dict-data', |
| | | component: Layout, |
| | | hidden: true, |
| | | children: [ |
| | | { |
| | | path: 'type/data/:dictId(\\d+)', |
| | | path: 'index/:dictId(\\d+)', |
| | | component: (resolve) => require(['@/views/system/dict/data'], resolve), |
| | | name: 'Data', |
| | | meta: { title: 'åå
¸æ°æ®', icon: '' } |
| | | meta: { title: 'åå
¸æ°æ®', activeMenu: '/system/dict'} |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | path: '/job', |
| | | path: '/monitor/job-log', |
| | | component: Layout, |
| | | hidden: true, |
| | | children: [ |
| | | { |
| | | path: 'log', |
| | | path: 'index', |
| | | component: (resolve) => require(['@/views/monitor/job/log'], resolve), |
| | | name: 'JobLog', |
| | | meta: { title: 'è°åº¦æ¥å¿' } |
| | | meta: { title: 'è°åº¦æ¥å¿', activeMenu: '/monitor/job'} |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | path: '/gen', |
| | | path: '/tool/gen-edit', |
| | | component: Layout, |
| | | hidden: true, |
| | | children: [ |
| | | { |
| | | path: 'edit/:tableId(\\d+)', |
| | | path: 'index/:tableId(\\d+)', |
| | | component: (resolve) => require(['@/views/tool/gen/editTable'], resolve), |
| | | name: 'GenEdit', |
| | | meta: { title: 'ä¿®æ¹çæé
ç½®' } |
| | | meta: { title: 'ä¿®æ¹çæé
ç½®', activeMenu: '/tool/gen'} |
| | | } |
| | | ] |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import axios from 'axios' |
| | | import { getToken } from '@/utils/auth' |
| | | |
| | | const mimeMap = { |
| | | oss: 'application/octet-stream' |
| | | } |
| | | |
| | | const baseUrl = process.env.VUE_APP_BASE_API |
| | | 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) |
| | | }) |
| | | } |
| | | /** |
| | | * è§£æ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.href = URL.createObjectURL(blob) |
| | | aLink.setAttribute('download', decodeURI(fileName)) // 设置ä¸è½½æä»¶åç§° |
| | | document.body.appendChild(aLink) |
| | | aLink.click() |
| | | document.body.removeChild(aLink); |
| | | } |
| | |
| | | location.href = '/index'; |
| | | }) |
| | | }).catch(() => {}); |
| | | return Promise.reject('error') |
| | | } else if (code === 500) { |
| | | Message({ |
| | | message: msg, |
| | |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">æç´¢</el-button> |
| | | <el-button type="primary" icon="el-icon-search" size="mini" @click="handlePage">æç´¢(èªå®ä¹å页æ¥å£)</el-button> |
| | | <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">éç½®</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { listDemo, getDemo, delDemo, addDemo, updateDemo, exportDemo } from "@/api/demo/demo"; |
| | | import { listDemo, pageDemo, getDemo, delDemo, addDemo, updateDemo, exportDemo } from "@/api/demo/demo"; |
| | | |
| | | export default { |
| | | name: "Demo", |
| | |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | | /** èªå®ä¹å页æ¥è¯¢ */ |
| | | getPage() { |
| | | this.loading = true; |
| | | this.queryParams.params = {}; |
| | | if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) { |
| | | this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0]; |
| | | this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1]; |
| | | } |
| | | pageDemo(this.queryParams).then(response => { |
| | | this.demoList = response.rows; |
| | | this.total = response.total; |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | | // åæ¶æé® |
| | | cancel() { |
| | | this.open = false; |
| | |
| | | this.queryParams.pageNum = 1; |
| | | this.getList(); |
| | | }, |
| | | /** æç´¢æé®æä½ */ |
| | | handlePage() { |
| | | this.queryParams.pageNum = 1; |
| | | this.getPage(); |
| | | }, |
| | | /** éç½®æé®æä½ */ |
| | | resetQuery() { |
| | | this.daterangeCreateTime = []; |
| | |
| | | * 夿°æ®æºæ¡æ¶ dynamic-datasource æ¯æä¸»ä»ä¸å¤ç§ç±»æ°æ®åºå¼æ<br/> |
| | | * Redis客æ·ç«¯ éç¨ Redisson æ§è½æ´å¼º<br/> |
| | | * åå¸å¼é Lock4j 注解éãå·¥å
·é å¤ç§å¤æ ·<br/> |
| | | * é¨ç½²æ¹å¼ Docker 容å¨ç¼æ ä¸é®é¨ç½²ä¸å¡é群<br/> |
| | | * æä»¶åå¨ OSS 对象å卿¨¡å æ¯æ(Minioãä¸çãé¿éãè
¾è®¯)<br/> |
| | | </p> |
| | | <p> |
| | | <b>å½åçæ¬:</b> <span>v{{ version }}</span> |
| | |
| | | <span>æ´æ°æ¥å¿</span> |
| | | </div> |
| | | <el-collapse accordion> |
| | | <el-collapse-item title="v2.6.0 - 2021-7-28"> |
| | | <ol> |
| | | <li>add [é大æ°å¢] å¢å OSS 对象å卿¨¡å</li> |
| | | <li>remove [é大æ¹å¨] å é¤ èªå¸¦éç¨ä¸ä¼ æ¥å£ 使ç¨OSSæ¨¡åæ¿æ¢<li> |
| | | <li>update [é大æ¹å¨] éåVOè½¬æ¢ æ¯ææ·±æ·è´ å°VOç±»æ½è±¡å° ServicePlus æ³åå¤ç<li> |
| | | <li>update [é大æ¹å¨] å¤BOåå¹¶ 使ç¨åç»æ ¡éª çæBO代ç <li> |
| | | <li>update [é大æ¹å¨] éæ IServicePlus åè½ å¢å BeanCopyUtils æ·±æ·è´å·¥å
·<li> |
| | | <li>update springboot 2.4.9 => 2.5.3<li> |
| | | <li>update hutool 5.7.4 => 5.7.6<li> |
| | | <li>update minio 8.2.2 => 8.3.0<li> |
| | | <li>update docker plugin 1.2.0 => 1.2.2<li> |
| | | <li>update redisson 3.16.0 => 3.16.1<li> |
| | | <li>update datasource 3.4.0 => 3.4.1<li> |
| | | <li>update element-ui 2.15.2 => 2.15.3<li> |
| | | <li>add æ¼ç¤ºDemoå¢å èªå®ä¹å页æ¥å£æ¡ä¾</li> |
| | | <li>add è§è²&èåæ°å¢åæ®µå±æ§æç¤ºä¿¡æ¯</li> |
| | | <li>update æ´æ°druidé
ç½® ç¬ç«é
ç½®æ´ææ¾</li> |
| | | <li>update é¡¶é¨èåæé¤éèçé»è®¤è·¯ç±</li> |
| | | <li>update å¯ææ¬æ°å¢ä¸ä¼ æä»¶å¤§å°éå¶</li> |
| | | <li>update 导å
¥ç¨æ·æ ·å¼è°æ´</li> |
| | | <li>update é¡¶é¨èåæ ·å¼è°æ´</li> |
| | | <li>update å¯ç æ¡æ°å¢æ¾ç¤ºåæ¢å¯ç 徿 </li> |
| | | <li>update å
é¾è®¾ç½®metaä¿¡æ¯</li> |
| | | <li>update 跳转路ç±é«äº®ç¸å¯¹åºçèåæ </li> |
| | | <li>fix ä¿®å¤å¤æ°æ®æºdruidå
¨å±é
置缩è¿é误 å¼èµ·æ æé
ç½®é®é¢</li> |
| | | <li>fix ä¿®å¤å®æ¶ä»»å¡æ¥å¿æ§è¡ç¶ææ¾ç¤º</li> |
| | | <li>fix ä¿®å¤ ææè§è²ç©ºæ°æ®é®é¢</li> |
| | | <li>fix ä¿®å¤ DictData å é¤é»è¾é®é¢</li> |
| | | <li>fix ä¿®å¤ä»»æè´¦æ·è¶ææ¼æ´</li> |
| | | </ol> |
| | | </el-collapse-item> |
| | | <el-collapse-item title="v2.5.2 - 2021-7-19"> |
| | | <ol> |
| | | <li>update ä¼å代ç çæå¨æ³¨éæ ¼å¼</li> |
| | |
| | | <el-button |
| | | size="mini" |
| | | type="text" |
| | | icon="el-icon-caret-right" |
| | | @click="handleRun(scope.row)" |
| | | v-hasPermi="['monitor:job:changeStatus']" |
| | | >æ§è¡ä¸æ¬¡</el-button> |
| | | icon="el-icon-edit" |
| | | @click="handleUpdate(scope.row)" |
| | | v-hasPermi="['monitor:job:edit']" |
| | | >ä¿®æ¹</el-button> |
| | | <el-button |
| | | size="mini" |
| | | type="text" |
| | | icon="el-icon-view" |
| | | @click="handleView(scope.row)" |
| | | v-hasPermi="['monitor:job:query']" |
| | | >详ç»</el-button> |
| | | icon="el-icon-delete" |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['monitor:job:remove']" |
| | | >å é¤</el-button> |
| | | <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['monitor:job:changeStatus', 'monitor:job:query']"> |
| | | <span class="el-dropdown-link"> |
| | | <i class="el-icon-d-arrow-right el-icon--right"></i>æ´å¤ |
| | | </span> |
| | | <el-dropdown-menu slot="dropdown"> |
| | | <el-dropdown-item command="handleRun" icon="el-icon-caret-right" |
| | | v-hasPermi="['monitor:job:changeStatus']">æ§è¡ä¸æ¬¡</el-dropdown-item> |
| | | <el-dropdown-item command="handleView" icon="el-icon-view" |
| | | v-hasPermi="['monitor:job:query']">ä»»å¡è¯¦ç»</el-dropdown-item> |
| | | <el-dropdown-item command="handleJobLog" icon="el-icon-s-operation" |
| | | v-hasPermi="['monitor:job:query']">è°åº¦æ¥å¿</el-dropdown-item> |
| | | </el-dropdown-menu> |
| | | </el-dropdown> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | |
| | | this.single = selection.length != 1; |
| | | this.multiple = !selection.length; |
| | | }, |
| | | // æ´å¤æä½è§¦å |
| | | handleCommand(command, row) { |
| | | switch (command) { |
| | | case "handleRun": |
| | | this.handleRun(row); |
| | | break; |
| | | case "handleView": |
| | | this.handleView(row); |
| | | break; |
| | | case "handleJobLog": |
| | | this.handleJobLog(row); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }, |
| | | // ä»»å¡ç¶æä¿®æ¹ |
| | | handleStatusChange(row) { |
| | | let text = row.status === "0" ? "å¯ç¨" : "åç¨"; |
| | |
| | | }); |
| | | }, |
| | | /** 任塿¥å¿å表æ¥è¯¢ */ |
| | | handleJobLog() { |
| | | this.$router.push("/job/log"); |
| | | handleJobLog(row) { |
| | | const jobId = row.jobId || 0; |
| | | this.$router.push({ path: '/monitor/job-log/index', query: { jobId: jobId } }) |
| | | }, |
| | | /** æ°å¢æé®æä½ */ |
| | | handleAdd() { |
| | |
| | | v-hasPermi="['monitor:job:export']" |
| | | >导åº</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="warning" |
| | | plain |
| | | icon="el-icon-close" |
| | | size="mini" |
| | | @click="handleClose" |
| | | >å
³é</el-button> |
| | | </el-col> |
| | | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { getJob} from "@/api/monitor/job"; |
| | | import { listJobLog, delJobLog, exportJobLog, cleanJobLog } from "@/api/monitor/jobLog"; |
| | | |
| | | export default { |
| | |
| | | }; |
| | | }, |
| | | created() { |
| | | this.getList(); |
| | | this.getDicts("sys_job_status").then(response => { |
| | | const jobId = this.$route.query.jobId; |
| | | if (jobId !== undefined && jobId != 0) { |
| | | getJob(jobId).then(response => { |
| | | this.queryParams.jobName = response.data.jobName; |
| | | this.queryParams.jobGroup = response.data.jobGroup; |
| | | this.getList(); |
| | | }); |
| | | } else { |
| | | this.getList(); |
| | | } |
| | | this.getDicts("sys_common_status").then(response => { |
| | | this.statusOptions = response.data; |
| | | }); |
| | | this.getDicts("sys_job_group").then(response => { |
| | |
| | | jobGroupFormat(row, column) { |
| | | return this.selectDictLabel(this.jobGroupOptions, row.jobGroup); |
| | | }, |
| | | // è¿åæé® |
| | | handleClose() { |
| | | this.$store.dispatch("tagsView/delView", this.$route); |
| | | this.$router.push({ path: "/monitor/job" }); |
| | | }, |
| | | /** æç´¢æé®æä½ */ |
| | | handleQuery() { |
| | | this.queryParams.pageNum = 1; |
| | |
| | | <el-table-column label="åå
¸åç§°" align="center" prop="dictName" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="åå
¸ç±»å" align="center" :show-overflow-tooltip="true"> |
| | | <template slot-scope="scope"> |
| | | <router-link :to="'/dict/type/data/' + scope.row.dictId" class="link-type"> |
| | | <router-link :to="'/system/dict-data/index/' + scope.row.dictId" class="link-type"> |
| | | <span>{{ scope.row.dictType }}</span> |
| | | </router-link> |
| | | </template> |
| | |
| | | |
| | | <!-- æ·»å æä¿®æ¹èåå¯¹è¯æ¡ --> |
| | | <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body> |
| | | <el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
| | | <el-form ref="form" :model="form" :rules="rules" label-width="100px"> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <el-form-item label="ä¸çº§èå"> |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.menuType != 'F'" label="æ¯å¦å¤é¾"> |
| | | <el-form-item v-if="form.menuType != 'F'"> |
| | | <span slot="label"> |
| | | <el-tooltip content="éæ©æ¯å¤é¾åè·¯ç±å°åéè¦ä»¥`http(s)://`å¼å¤´" placement="top"> |
| | | <i class="el-icon-question"></i> |
| | | </el-tooltip> |
| | | æ¯å¦å¤é¾ |
| | | </span> |
| | | <el-radio-group v-model="form.isFrame"> |
| | | <el-radio label="0">æ¯</el-radio> |
| | | <el-radio label="1">å¦</el-radio> |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.menuType != 'F'" label="è·¯ç±å°å" prop="path"> |
| | | <el-form-item v-if="form.menuType != 'F'" prop="path"> |
| | | <span slot="label"> |
| | | <el-tooltip content="访é®çè·¯ç±å°åï¼å¦ï¼`user`ï¼å¦å¤ç½å°åéå
é¾è®¿é®å以`http(s)://`å¼å¤´" placement="top"> |
| | | <i class="el-icon-question"></i> |
| | | </el-tooltip> |
| | | è·¯ç±å°å |
| | | </span> |
| | | <el-input v-model="form.path" placeholder="请è¾å
¥è·¯ç±å°å" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.menuType == 'C'"> |
| | | <el-form-item label="ç»ä»¶è·¯å¾" prop="component"> |
| | | <el-form-item prop="component"> |
| | | <span slot="label"> |
| | | <el-tooltip content="访é®çç»ä»¶è·¯å¾ï¼å¦ï¼`system/user/index`ï¼é»è®¤å¨`views`ç®å½ä¸" placement="top"> |
| | | <i class="el-icon-question"></i> |
| | | </el-tooltip> |
| | | ç»ä»¶è·¯å¾ |
| | | </span> |
| | | <el-input v-model="form.component" placeholder="请è¾å
¥ç»ä»¶è·¯å¾" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.menuType != 'M'" label="æéæ è¯"> |
| | | <el-form-item v-if="form.menuType != 'M'"> |
| | | <el-input v-model="form.perms" placeholder="请è¾å
¥æéæ è¯" maxlength="100" /> |
| | | <span slot="label"> |
| | | <el-tooltip content="æ§å¶å¨ä¸å®ä¹çæéå符ï¼å¦ï¼@PreAuthorize(`@ss.hasPermi('system:user:list')`)" placement="top"> |
| | | <i class="el-icon-question"></i> |
| | | </el-tooltip> |
| | | æéå符 |
| | | </span> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.menuType != 'F'" label="æ¾ç¤ºç¶æ"> |
| | | <el-form-item v-if="form.menuType != 'F'"> |
| | | <span slot="label"> |
| | | <el-tooltip content="éæ©éèåè·¯ç±å°ä¸ä¼åºç°å¨ä¾§è¾¹æ ï¼ä½ä»ç¶å¯ä»¥è®¿é®" placement="top"> |
| | | <i class="el-icon-question"></i> |
| | | </el-tooltip> |
| | | æ¾ç¤ºç¶æ |
| | | </span> |
| | | <el-radio-group v-model="form.visible"> |
| | | <el-radio |
| | | v-for="dict in visibleOptions" |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.menuType != 'F'" label="èåç¶æ"> |
| | | <el-form-item v-if="form.menuType != 'F'"> |
| | | <span slot="label"> |
| | | <el-tooltip content="éæ©åç¨åè·¯ç±å°ä¸ä¼åºç°å¨ä¾§è¾¹æ ï¼ä¹ä¸è½è¢«è®¿é®" placement="top"> |
| | | <i class="el-icon-question"></i> |
| | | </el-tooltip> |
| | | èåç¶æ |
| | | </span> |
| | | <el-radio-group v-model="form.status"> |
| | | <el-radio |
| | | v-for="dict in statusOptions" |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.menuType == 'C'" label="æ¯å¦ç¼å"> |
| | | <el-form-item v-if="form.menuType == 'C'"> |
| | | <span slot="label"> |
| | | <el-tooltip content="éæ©æ¯åä¼è¢«`keep-alive`ç¼åï¼éè¦å¹é
ç»ä»¶ç`name`åå°åä¿æä¸è´" placement="top"> |
| | | <i class="el-icon-question"></i> |
| | | </el-tooltip> |
| | | æ¯å¦ç¼å |
| | | </span> |
| | | <el-radio-group v-model="form.isCache"> |
| | | <el-radio label="0">ç¼å</el-radio> |
| | | <el-radio label="1">ä¸ç¼å</el-radio> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> |
| | | <el-form-item label="æä»¶å" prop="fileName"> |
| | | <el-input |
| | | v-model="queryParams.fileName" |
| | | placeholder="请è¾å
¥æä»¶å" |
| | | clearable |
| | | size="small" |
| | | @keyup.enter.native="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="åå" prop="originalName"> |
| | | <el-input |
| | | v-model="queryParams.originalName" |
| | | placeholder="请è¾å
¥åå" |
| | | clearable |
| | | size="small" |
| | | @keyup.enter.native="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="æä»¶åç¼" prop="fileSuffix"> |
| | | <el-input |
| | | v-model="queryParams.fileSuffix" |
| | | placeholder="请è¾å
¥æä»¶åç¼" |
| | | clearable |
| | | size="small" |
| | | @keyup.enter.native="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="å建æ¶é´"> |
| | | <el-date-picker |
| | | v-model="daterangeCreateTime" |
| | | size="small" |
| | | style="width: 240px" |
| | | value-format="yyyy-MM-dd" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="å¼å§æ¥æ" |
| | | end-placeholder="ç»ææ¥æ" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item label="ä¸ä¼ 人" prop="createBy"> |
| | | <el-input |
| | | v-model="queryParams.createBy" |
| | | placeholder="请è¾å
¥ä¸ä¼ 人" |
| | | clearable |
| | | size="small" |
| | | @keyup.enter.native="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="æå¡å" prop="service"> |
| | | <el-input |
| | | v-model="queryParams.service" |
| | | placeholder="请è¾å
¥æå¡å" |
| | | clearable |
| | | size="small" |
| | | @keyup.enter.native="handleQuery" |
| | | /> |
| | | </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="handleFile" |
| | | v-hasPermi="['system:oss:upload']" |
| | | >ä¸ä¼ æä»¶</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="el-icon-plus" |
| | | size="mini" |
| | | @click="handleImage" |
| | | v-hasPermi="['system:oss:upload']" |
| | | >ä¸ä¼ å¾ç</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="ossList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="äºåå¨ä¸»é®" align="center" prop="ossId" v-if="false"/> |
| | | <el-table-column label="æä»¶å" align="center" prop="fileName" /> |
| | | <el-table-column label="åå" align="center" prop="originalName" /> |
| | | <el-table-column label="æä»¶åç¼" align="center" prop="fileSuffix" /> |
| | | <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" |
| | | 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"/> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="å建æ¶é´" align="center" prop="createTime" width="180"> |
| | | <template slot-scope="scope"> |
| | | <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="ä¸ä¼ 人" align="center" prop="createBy" /> |
| | | <el-table-column label="æå¡å" align="center" prop="service" /> |
| | | <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="handleDownload(scope.row)" |
| | | v-hasPermi="['system:oss:download']" |
| | | >ä¸è½½</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" |
| | | /> |
| | | |
| | | <!-- æ·»å æä¿®æ¹OSSäºåå¨å¯¹è¯æ¡ --> |
| | | <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> |
| | | <el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
| | | <el-form-item label="æä»¶å"> |
| | | <fileUpload v-model="form.file" v-if="type === 0"/> |
| | | <imageUpload v-model="form.file" v-if="type === 1"/> |
| | | </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 { listOss, delOss } from "@/api/system/oss"; |
| | | import { downLoadOss } from "@/utils/ossdownload"; |
| | | import { updateConfig } from "@/api/system/config"; |
| | | |
| | | |
| | | export default { |
| | | name: "Oss", |
| | | data() { |
| | | return { |
| | | // æé®loading |
| | | buttonLoading: false, |
| | | // é®ç½©å± |
| | | loading: true, |
| | | // 导åºé®ç½©å± |
| | | exportLoading: false, |
| | | // é䏿°ç» |
| | | ids: [], |
| | | // éå个ç¦ç¨ |
| | | single: true, |
| | | // éå¤ä¸ªç¦ç¨ |
| | | multiple: true, |
| | | // æ¾ç¤ºæç´¢æ¡ä»¶ |
| | | showSearch: true, |
| | | // æ»æ¡æ° |
| | | total: 0, |
| | | // OSSäºåå¨è¡¨æ ¼æ°æ® |
| | | ossList: [], |
| | | // å¼¹åºå±æ é¢ |
| | | title: "", |
| | | // å¼¹åºå±æ é¢ |
| | | type: 0, |
| | | // æ¯å¦æ¾ç¤ºå¼¹åºå± |
| | | open: false, |
| | | // é¢è§å表å¾ç |
| | | previewListResource: true, |
| | | // å建æ¶é´æ¶é´èå´ |
| | | daterangeCreateTime: [], |
| | | // æ¥è¯¢åæ° |
| | | queryParams: { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | fileName: undefined, |
| | | originalName: undefined, |
| | | fileSuffix: undefined, |
| | | url: undefined, |
| | | createTime: undefined, |
| | | createBy: undefined, |
| | | service: undefined |
| | | }, |
| | | // 表ååæ° |
| | | form: {}, |
| | | // è¡¨åæ ¡éª |
| | | rules: { |
| | | file: [ |
| | | { required: true, message: "æä»¶ä¸è½ä¸ºç©º", trigger: "blur" } |
| | | ] |
| | | } |
| | | }; |
| | | }, |
| | | created() { |
| | | this.getList(); |
| | | }, |
| | | methods: { |
| | | /** æ¥è¯¢OSSäºåå¨å表 */ |
| | | getList() { |
| | | this.loading = true; |
| | | this.queryParams.params = {}; |
| | | if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) { |
| | | this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0]; |
| | | this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1]; |
| | | } |
| | | this.getConfigKey("sys.oss.previewListResource").then(response => { |
| | | this.previewListResource = response.msg === undefined ? true : response.msg === 'true'; |
| | | }); |
| | | listOss(this.queryParams).then(response => { |
| | | this.ossList = response.rows; |
| | | this.total = response.total; |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | | // åæ¶æé® |
| | | cancel() { |
| | | this.open = false; |
| | | this.reset(); |
| | | }, |
| | | // 表åéç½® |
| | | reset() { |
| | | this.form = { |
| | | file: undefined, |
| | | }; |
| | | this.resetForm("form"); |
| | | }, |
| | | /** æç´¢æé®æä½ */ |
| | | handleQuery() { |
| | | this.queryParams.pageNum = 1; |
| | | this.getList(); |
| | | }, |
| | | /** éç½®æé®æä½ */ |
| | | resetQuery() { |
| | | this.daterangeCreateTime = []; |
| | | this.resetForm("queryForm"); |
| | | this.handleQuery(); |
| | | }, |
| | | // å¤éæ¡é䏿°æ® |
| | | handleSelectionChange(selection) { |
| | | this.ids = selection.map(item => item.ossId) |
| | | this.single = selection.length!==1 |
| | | this.multiple = !selection.length |
| | | }, |
| | | /** æä»¶æé®æä½ */ |
| | | handleFile() { |
| | | this.reset(); |
| | | this.open = true; |
| | | this.title = "ä¸ä¼ æä»¶"; |
| | | this.type = 0; |
| | | }, |
| | | /** å¾çæé®æä½ */ |
| | | handleImage() { |
| | | this.reset(); |
| | | this.open = true; |
| | | this.title = "ä¸ä¼ å¾ç"; |
| | | this.type = 1; |
| | | }, |
| | | /** æäº¤æé® */ |
| | | submitForm() { |
| | | this.open = false; |
| | | this.getList(); |
| | | }, |
| | | /** ä¸è½½æé®æä½ */ |
| | | handleDownload(row) { |
| | | downLoadOss(row.ossId) |
| | | }, |
| | | /** å é¤æé®æä½ */ |
| | | handleDelete(row) { |
| | | const ossIds = row.ossId || this.ids; |
| | | this.$confirm('æ¯å¦ç¡®è®¤å é¤OSSäºåå¨ç¼å·ä¸º"' + ossIds + '"çæ°æ®é¡¹?', "è¦å", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.loading = true; |
| | | return delOss(ossIds); |
| | | }).then(() => { |
| | | this.loading = false; |
| | | this.getList(); |
| | | this.msgSuccess("å 餿å"); |
| | | }).catch(() => {}); |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['system:role:remove']" |
| | | >å é¤</el-button> |
| | | <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)"> |
| | | <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['system:role:edit']"> |
| | | <span class="el-dropdown-link"> |
| | | <i class="el-icon-d-arrow-right el-icon--right"></i>æ´å¤ |
| | | </span> |
| | |
| | | |
| | | <!-- æ·»å æä¿®æ¹è§è²é
ç½®å¯¹è¯æ¡ --> |
| | | <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> |
| | | <el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
| | | <el-form ref="form" :model="form" :rules="rules" label-width="100px"> |
| | | <el-form-item label="è§è²åç§°" prop="roleName"> |
| | | <el-input v-model="form.roleName" placeholder="请è¾å
¥è§è²åç§°" /> |
| | | </el-form-item> |
| | | <el-form-item label="æéå符" prop="roleKey"> |
| | | <el-form-item prop="roleKey"> |
| | | <span slot="label"> |
| | | <el-tooltip content="æ§å¶å¨ä¸å®ä¹çæéå符ï¼å¦ï¼@PreAuthorize(`@ss.hasRole('admin')`)" placement="top"> |
| | | <i class="el-icon-question"></i> |
| | | </el-tooltip> |
| | | æéå符 |
| | | </span> |
| | | <el-input v-model="form.roleKey" placeholder="请è¾å
¥æéå符" /> |
| | | </el-form-item> |
| | | <el-form-item label="è§è²é¡ºåº" prop="roleSort"> |
| | |
| | | /** åé
ç¨æ·æä½ */ |
| | | handleAuthUser: function(row) { |
| | | const roleId = row.roleId; |
| | | this.$router.push("/auth/user/" + roleId); |
| | | this.$router.push("/system/role-auth/user/" + roleId); |
| | | }, |
| | | /** æäº¤æé® */ |
| | | submitForm: function() { |
| | |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['system:user:remove']" |
| | | >å é¤</el-button> |
| | | <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)"> |
| | | <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['system:user:resetPwd', 'system:user:edit']"> |
| | | <span class="el-dropdown-link"> |
| | | <i class="el-icon-d-arrow-right el-icon--right"></i>æ´å¤ |
| | | </span> |
| | |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.userId == undefined" label="ç¨æ·å¯ç " prop="password"> |
| | | <el-input v-model="form.password" placeholder="请è¾å
¥ç¨æ·å¯ç " type="password" maxlength="20" /> |
| | | <el-input v-model="form.password" placeholder="请è¾å
¥ç¨æ·å¯ç " type="password" maxlength="20" show-password/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | drag |
| | | > |
| | | <i class="el-icon-upload"></i> |
| | | <div class="el-upload__text"> |
| | | å°æä»¶æå°æ¤å¤ï¼æ |
| | | <em>ç¹å»ä¸ä¼ </em> |
| | | <div class="el-upload__text">å°æä»¶æå°æ¤å¤ï¼æ<em>ç¹å»ä¸ä¼ </em></div> |
| | | <div class="el-upload__tip text-center" slot="tip"> |
| | | <div class="el-upload__tip" slot="tip"> |
| | | <el-checkbox v-model="upload.updateSupport" /> æ¯å¦æ´æ°å·²ç»åå¨çç¨æ·æ°æ® |
| | | </div> |
| | | <span>ä»
å
许导å
¥xlsãxlsxæ ¼å¼æä»¶ã</span> |
| | | <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">ä¸è½½æ¨¡æ¿</el-link> |
| | | </div> |
| | | <div class="el-upload__tip" slot="tip"> |
| | | <el-checkbox v-model="upload.updateSupport" />æ¯å¦æ´æ°å·²ç»åå¨çç¨æ·æ°æ® |
| | | <el-link type="info" style="font-size:12px" @click="importTemplate">ä¸è½½æ¨¡æ¿</el-link> |
| | | </div> |
| | | <div class="el-upload__tip" style="color:red" slot="tip">æç¤ºï¼ä»
å
许导å
¥âxlsâæâxlsxâæ ¼å¼æä»¶ï¼</div> |
| | | </el-upload> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="primary" @click="submitFileForm">ç¡® å®</el-button> |
| | |
| | | /** åé
è§è²æä½ */ |
| | | handleAuthRole: function(row) { |
| | | const userId = row.userId; |
| | | this.$router.push("/auth/role/" + userId); |
| | | this.$router.push("/system/user-auth/role/" + userId); |
| | | }, |
| | | /** æäº¤æé® */ |
| | | submitForm: function() { |
| | |
| | | <template> |
| | | <el-form ref="form" :model="user" :rules="rules" label-width="80px"> |
| | | <el-form-item label="æ§å¯ç " prop="oldPassword"> |
| | | <el-input v-model="user.oldPassword" placeholder="请è¾å
¥æ§å¯ç " type="password" /> |
| | | <el-input v-model="user.oldPassword" placeholder="请è¾å
¥æ§å¯ç " type="password" show-password/> |
| | | </el-form-item> |
| | | <el-form-item label="æ°å¯ç " prop="newPassword"> |
| | | <el-input v-model="user.newPassword" placeholder="请è¾å
¥æ°å¯ç " type="password" /> |
| | | <el-input v-model="user.newPassword" placeholder="请è¾å
¥æ°å¯ç " type="password" show-password/> |
| | | </el-form-item> |
| | | <el-form-item label="确认å¯ç " prop="confirmPassword"> |
| | | <el-input v-model="user.confirmPassword" placeholder="请确认å¯ç " type="password" /> |
| | | <el-input v-model="user.confirmPassword" placeholder="请确认å¯ç " type="password" show-password/> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" size="mini" @click="submit">ä¿å</el-button> |
| | |
| | | /** ä¿®æ¹æé®æä½ */ |
| | | handleEditTable(row) { |
| | | const tableId = row.tableId || this.ids[0]; |
| | | this.$router.push("/gen/edit/" + tableId); |
| | | this.$router.push("/tool/gen-edit/index/" + tableId); |
| | | }, |
| | | /** å é¤æé®æä½ */ |
| | | handleDelete(row) { |
¶Ô±ÈÐÂÎļþ |
| | |
| | | -- ---------------------------- |
| | | -- OSSäºåå¨è¡¨ |
| | | -- ---------------------------- |
| | | drop table if exists sys_oss; |
| | | create table sys_oss ( |
| | | oss_id bigint(20) not null auto_increment comment 'äºåå¨ä¸»é®', |
| | | file_name varchar(64) not null default '' comment 'æä»¶å', |
| | | original_name varchar(64) not null default '' comment 'åå', |
| | | file_suffix varchar(10) not null default '' comment 'æä»¶åç¼å', |
| | | url varchar(200) not null comment 'URLå°å', |
| | | create_time datetime default null comment 'å建æ¶é´', |
| | | create_by varchar(64) default '' comment 'ä¸ä¼ 人', |
| | | update_time datetime default null comment 'æ´æ°æ¶é´', |
| | | update_by varchar(64) default '' comment 'æ´æ°äºº', |
| | | service varchar(10) not null default 'minio' comment 'æå¡å', |
| | | 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)'); |
| | | 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('1600', 'æä»¶æ¥è¯¢', '118', '1', '#', '', 1, 0, 'F', '0', '0', 'system:oss:query', '#', '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, ''); |