Merge remote-tracking branch 'origin/dev' into satoken
# Conflicts:
# pom.xml
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
# ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java
# ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestDemoController.java
# ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestTreeController.java
# ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java
# ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RepeatSubmitAspect.java
# ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
# ruoyi-framework/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java
# ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java
# ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java
# ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java
# ruoyi-system/src/main/java/com/ruoyi/system/service/PermissionService.java
# ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java
# ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserDetailsServiceImpl.java
已添加18个文件
已重命名8个文件
已删除41个文件
已修改140个文件
| | |
| | | []() |
| | | []() |
| | | |
| | | RuoYi-Vue-Plus æ¯åºäº RuoYi-Vue é对 `åå¸å¼é群` åºæ¯å级(ä¸å
¼å®¹åæ¡æ¶) |
| | | > RuoYi-Vue-Plus æ¯åºäº RuoYi-Vue é对 `åå¸å¼é群` åºæ¯å级(ä¸å
¼å®¹åæ¡æ¶) |
| | | |
| | | > ç³»ç»æ¼ç¤º: [ä¼ éé¨](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/ç³»ç»æ¼ç¤º?sort_id=4836388) |
| | | |
| | | | åè½ä»ç» | ä½¿ç¨ææ¯ | ææ¡£å°å | ç¹æ§æ³¨æäºé¡¹ | |
| | | |---|---|---|---| |
| | | | å½åæ¡æ¶ | RuoYi-Vue-Plus | [RuoYi-Vue-Plusææ¡£](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages) | éåRuoYi-Vueå
¨æ¹ä½å级(ä¸å
¼å®¹åæ¡æ¶) | |
| | | | satoken忝 | RuoYi-Vue-Plus-satoken | [satoken忝å°å](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/satoken/) | 使ç¨satokenéææéé´æ(ä»
ä¾å¦ä¹ 䏿¨èä¸ç产) | |
| | | | satoken忝 | RuoYi-Vue-Plus-satoken | [satoken忝å°å](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/satoken/) | 使ç¨satokenéææéé´æ(å
¬æµ å¯å°è¯ä¸ç产) | |
| | | | åä½åæ¯ | RuoYi-Vue-Plus-fast | [fast忝å°å](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/fast/) | åä½åºç¨ç»æ | |
| | | | åæ¡æ¶ | RuoYi-Vue | [RuoYi-Vueå®ç½](http://ruoyi.vip/) | 宿忥éè¦çåè½ | |
| | | | å端å¼åæ¡æ¶ | VueãElement UI | [Element UIå®ç½](https://element.eleme.cn/#/zh-CN) | | |
| | |
| | | | æ°æ®åºæ¡æ¶ | p6spy | [p6spyå®ç½](https://p6spy.readthedocs.io/) | æ´å¼ºå²ç SQL åæ | |
| | | | 夿°æ®æºæ¡æ¶ | dynamic-datasource | [dynamic-dsææ¡£](https://www.kancloud.cn/tracy5546/dynamic-datasource/content) | æ¯æä¸»ä»ä¸å¤ç§ç±»æ°æ®åºå¼æ | |
| | | | åºååæ¡æ¶ | Jackson | [Jacksonå®ç½](https://github.com/FasterXML/jackson) | ç»ä¸ä½¿ç¨ jackson 髿å¯é | |
| | | | ç½ç»æ¡æ¶ | FeignãOkHttp3 | [Feignå®ç½](https://github.com/OpenFeign/feign) | æ¥å£å管ç HTTP è¯·æ± | |
| | | | Redis客æ·ç«¯ | Redisson | [Redissonææ¡£](https://github.com/redisson/redisson/wiki/%E7%9B%AE%E5%BD%95) | æ¯æåæºãé群é
ç½® | |
| | | | åå¸å¼éæµ | Redisson | [Redissonææ¡£](https://github.com/redisson/redisson/wiki/%E7%9B%AE%E5%BD%95) | å
¨å±ã请æ±IPãé群ID å¤ç§éæµ | |
| | | | åå¸å¼é | Lock4j | [Lock4jå®ç½](https://gitee.com/baomidou/lock4j) | 注解éãå·¥å
·é å¤ç§å¤æ · | |
| | | | åå¸å¼å¹ç | Lock4j | [Lock4jææ¡£](https://gitee.com/baomidou/lock4j) | åºäºåå¸å¼éå®ç° | |
| | | | åå¸å¼å¹ç | Redisson | [Lock4jææ¡£](https://gitee.com/baomidou/lock4j) | æ¦æªéå¤æäº¤ | |
| | | | åå¸å¼æ¥å¿ | TLog | [TLogææ¡£](https://yomahub.com/tlog/docs) | æ¯æè·è¸ªé¾è·¯æ¥å¿è®°å½ãæ§è½åæãé¾è·¯ææ¥ | |
| | | | åå¸å¼ä»»å¡è°åº¦ | Xxl-Job | [Xxl-Jobå®ç½](https://www.xuxueli.com/xxl-job/) | 髿§è½ é«å¯é ææ©å± | |
| | | | æä»¶åå¨ | Minio | [Minioææ¡£](https://docs.min.io/) | æ¬å°åå¨ | |
| | | | æä»¶åå¨ | ä¸çãé¿éãè
¾è®¯ | [OSSä½¿ç¨ææ¡£](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4359146&doc_id=1469725) | äºåå¨ | |
| | | | çæ§æ¡æ¶ | SpringBoot-Admin | [SpringBoot-Adminææ¡£](https://codecentric.github.io/spring-boot-admin/current/) | å
¨æ¹ä½æå¡çæ§ | |
| | | | æ ¡éªæ¡æ¶ | Validation | [Validationææ¡£](https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/) | å¢å¼ºæ¥å£å®å
¨æ§ãä¸¥è°¨æ§ | |
| | | | æ ¡éªæ¡æ¶ | Validation | [Validationææ¡£](https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/) | å¢å¼ºæ¥å£å®å
¨æ§ãä¸¥è°¨æ§ æ¯æå½é
å | |
| | | | Excelæ¡æ¶ | Alibaba EasyExcel | [EasyExcelææ¡£](https://www.yuque.com/easyexcel/doc/easyexcel) | æ§è½ä¼å¼ æ©å±æ§å¼º | |
| | | | ææ¡£æ¡æ¶ | Knife4j | [Knife4jææ¡£](https://doc.xiaominfo.com/knife4j/documentation/) | ç¾åæ¥å£ææ¡£ | |
| | | | å·¥å
·ç±»æ¡æ¶ | HutoolãLombok | [Hutoolææ¡£](https://www.hutool.cn/docs/) | åå°ä»£ç åä½ å¢å å®å
¨æ§ | |
| | |
| | | |
| | | ## è½¯ä»¶æ¶æå¾ |
| | | |
| | |  |
| | | |
| | |  |
| | | ## è´¡ç®ä»£ç |
| | | |
| | | 欢è¿åè·¯è±éè±ªæ° `PR` 代ç 请æäº¤å° `dev` å¼å忝 ç»ä¸æµè¯åç |
| | |
| | | |
| | | <properties> |
| | | <ruoyi-vue-plus.version>3.3.0</ruoyi-vue-plus.version> |
| | | <spring-boot.version>2.5.6</spring-boot.version> |
| | | <spring-boot.version>2.5.7</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> |
| | |
| | | <swagger-annotations.version>1.5.22</swagger-annotations.version> |
| | | <poi.version>4.1.2</poi.version> |
| | | <easyexcel.version>2.2.11</easyexcel.version> |
| | | <velocity.version>1.7</velocity.version> |
| | | <velocity.version>2.3</velocity.version> |
| | | <satoken.version>1.28.0</satoken.version> |
| | | <mybatis-plus.version>3.4.3.4</mybatis-plus.version> |
| | | <p6spy.version>3.9.1</p6spy.version> |
| | | <hutool.version>5.7.15</hutool.version> |
| | | <feign.version>3.0.3</feign.version> |
| | | <feign-okhttp.version>11.6</feign-okhttp.version> |
| | | <okhttp.version>4.9.1</okhttp.version> |
| | | <spring-boot-admin.version>2.5.2</spring-boot-admin.version> |
| | | <redisson.version>3.16.3</redisson.version> |
| | | <hutool.version>5.7.16</hutool.version> |
| | | <okhttp.version>4.9.2</okhttp.version> |
| | | <spring-boot-admin.version>2.5.4</spring-boot-admin.version> |
| | | <redisson.version>3.16.4</redisson.version> |
| | | <lock4j.version>2.2.1</lock4j.version> |
| | | <dynamic-ds.version>3.4.1</dynamic-ds.version> |
| | | <tlog.version>1.3.3</tlog.version> |
| | | <tlog.version>1.3.4</tlog.version> |
| | | <xxl-job.version>2.3.0</xxl-job.version> |
| | | |
| | | <!-- jdk11 缺失ä¾èµ jaxb--> |
| | |
| | | <!-- velocity代ç çæä½¿ç¨æ¨¡æ¿ --> |
| | | <dependency> |
| | | <groupId>org.apache.velocity</groupId> |
| | | <artifactId>velocity</artifactId> |
| | | <artifactId>velocity-engine-core</artifactId> |
| | | <version>${velocity.version}</version> |
| | | </dependency> |
| | | |
| | |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-all</artifactId> |
| | | <version>${hutool.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- @deprecated ç±äºä½¿ç¨äººæ°è¾å° å³å®ä¸ 3.4.0 çæ¬ç§»é¤ --> |
| | | <dependency> |
| | | <groupId>org.springframework.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-openfeign</artifactId> |
| | | <version>${feign.version}</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <artifactId>feign-core</artifactId> |
| | | <groupId>io.github.openfeign</groupId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <!-- @deprecated ç±äºä½¿ç¨äººæ°è¾å° å³å®ä¸ 3.4.0 çæ¬ç§»é¤ --> |
| | | <dependency> |
| | | <groupId>io.github.openfeign</groupId> |
| | | <artifactId>feign-okhttp</artifactId> |
| | | <version>${feign-okhttp.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | |
| | | |
| | | <dependency> |
| | | <groupId>com.yomahub</groupId> |
| | | <artifactId>tlog-feign</artifactId> |
| | | <version>${tlog.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.yomahub</groupId> |
| | | <artifactId>tlog-xxl-job</artifactId> |
| | | <version>${tlog.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- 宿¶ä»»å¡ @deprecated 3.4.0å é¤ è¿ç§»è³xxl-job --> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-quartz</artifactId> |
| | | <version>${ruoyi-vue-plus.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- 宿¶ä»»å¡ --> |
| | |
| | | <module>ruoyi-admin</module> |
| | | <module>ruoyi-framework</module> |
| | | <module>ruoyi-system</module> |
| | | <module>ruoyi-quartz</module> |
| | | <module>ruoyi-job</module> |
| | | <module>ruoyi-generator</module> |
| | | <module>ruoyi-common</module> |
| | |
| | | <!-- ç¯å¢æ è¯ï¼éè¦ä¸é
ç½®æä»¶çåç§°ç¸å¯¹åº --> |
| | | <profiles.active>local</profiles.active> |
| | | <logging.level>debug</logging.level> |
| | | <knife4j.production>false</knife4j.production> |
| | | <endpoints.include>'*'</endpoints.include> |
| | | </properties> |
| | | </profile> |
| | |
| | | <!-- ç¯å¢æ è¯ï¼éè¦ä¸é
ç½®æä»¶çåç§°ç¸å¯¹åº --> |
| | | <profiles.active>dev</profiles.active> |
| | | <logging.level>debug</logging.level> |
| | | <knife4j.production>false</knife4j.production> |
| | | <endpoints.include>'*'</endpoints.include> |
| | | </properties> |
| | | <activation> |
| | |
| | | <properties> |
| | | <profiles.active>prod</profiles.active> |
| | | <logging.level>warn</logging.level> |
| | | <knife4j.production>true</knife4j.production> |
| | | <endpoints.include>health, info, logfile</endpoints.include> |
| | | </properties> |
| | | </profile> |
| | |
| | | |
| | | RUN mkdir -p /ruoyi/server |
| | | RUN mkdir -p /ruoyi/server/logs |
| | | RUN mkdir -p /ruoyi/server/temp |
| | | |
| | | WORKDIR /ruoyi/server |
| | | |
| | |
| | | <artifactId>ruoyi-system</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- 宿¶ä»»å¡ @deprecated 3.4.0å é¤ è¿ç§»è³xxl-job --> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>com.ruoyi</groupId>--> |
| | | <!-- <artifactId>ruoyi-quartz</artifactId>--> |
| | | <!-- </dependency>--> |
| | | |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-job</artifactId> |
| | |
| | | |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup; |
| | | |
| | | /** |
| | | * å¯å¨ç¨åº |
| | |
| | | |
| | | public static void main(String[] args) { |
| | | System.setProperty("spring.devtools.restart.enabled", "false"); |
| | | SpringApplication.run(RuoYiApplication.class, args); |
| | | SpringApplication application = new SpringApplication(RuoYiApplication.class); |
| | | application.setApplicationStartup(new BufferingApplicationStartup(2048)); |
| | | application.run(args); |
| | | System.out.println("(â¥â â¿â )ï¾ï¾ RuoYi-Vue-Pluså¯å¨æå á(´ڡ`á)ï¾"); |
| | | } |
| | | |
| | |
| | | @ApiOperation("导åºç³»ç»è®¿é®è®°å½å表") |
| | | @Log(title = "ç»å½æ¥å¿", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("monitor:logininfor:export") |
| | | @GetMapping("/export") |
| | | @PostMapping("/export") |
| | | public void export(SysLogininfor logininfor, HttpServletResponse response) { |
| | | List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); |
| | | ExcelUtil.exportExcel(list, "ç»å½æ¥å¿", SysLogininfor.class, response); |
| | |
| | | @ApiOperation("å¯¼åºæä½æ¥å¿è®°å½å表") |
| | | @Log(title = "æä½æ¥å¿", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("monitor:operlog:export") |
| | | @GetMapping("/export") |
| | | @PostMapping("/export") |
| | | public void export(SysOperLog operLog, HttpServletResponse response) { |
| | | List<SysOperLog> list = operLogService.selectOperLogList(operLog); |
| | | ExcelUtil.exportExcel(list, "æä½æ¥å¿", SysOperLog.class, response); |
| | |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | @ApiOperation("导åºåæ°é
ç½®å表") |
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:config:export") |
| | | @GetMapping("/export") |
| | | @PostMapping("/export") |
| | | public void export(SysConfig config, HttpServletResponse response) { |
| | | List<SysConfig> list = configService.selectConfigList(config); |
| | | ExcelUtil.exportExcel(list, "åæ°æ°æ®", SysConfig.class, response); |
| | |
| | | @ApiOperation("æ ¹æ®åæ°ç¼å·è·å详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("system:config:query") |
| | | @GetMapping(value = "/{configId}") |
| | | public AjaxResult<SysConfig> getInfo(@PathVariable Long configId) { |
| | | public AjaxResult<SysConfig> getInfo(@ApiParam("åæ°ID") @PathVariable Long configId) { |
| | | return AjaxResult.success(configService.selectConfigById(configId)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @ApiOperation("æ ¹æ®åæ°é®åæ¥è¯¢åæ°å¼") |
| | | @GetMapping(value = "/configKey/{configKey}") |
| | | public AjaxResult<Void> getConfigKey(@PathVariable String configKey) { |
| | | public AjaxResult<Void> getConfigKey(@ApiParam("åæ°Key") @PathVariable String configKey) { |
| | | return AjaxResult.success(configService.selectConfigByKey(configKey)); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("system:config:add") |
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | @RepeatSubmit |
| | | public AjaxResult<Void> add(@Validated @RequestBody SysConfig config) { |
| | | if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) { |
| | | return AjaxResult.error("æ°å¢åæ°'" + config.getConfigName() + "'失败ï¼åæ°é®åå·²åå¨"); |
| | |
| | | @SaCheckPermission("system:config:remove") |
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{configIds}") |
| | | public AjaxResult<Void> remove(@PathVariable Long[] configIds) { |
| | | public AjaxResult<Void> remove(@ApiParam("忰ID䏲") @PathVariable Long[] configIds) { |
| | | configService.deleteConfigByIds(configIds); |
| | | return success(); |
| | | } |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.TreeSelect; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.service.ISysDeptService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | @ApiOperation("æ¥è¯¢é¨é¨åè¡¨ï¼æé¤èç¹ï¼") |
| | | @SaCheckPermission("system:dept:list") |
| | | @GetMapping("/list/exclude/{deptId}") |
| | | public AjaxResult<List<SysDept>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) { |
| | | public AjaxResult<List<SysDept>> excludeChild(@ApiParam("é¨é¨ID") @PathVariable(value = "deptId", required = false) Long deptId) { |
| | | List<SysDept> depts = deptService.selectDeptList(new SysDept()); |
| | | depts.removeIf(d -> d.getDeptId().equals(deptId) |
| | | || ArrayUtil.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); |
| | |
| | | @ApiOperation("æ ¹æ®é¨é¨ç¼å·è·å详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("system:dept:query") |
| | | @GetMapping(value = "/{deptId}") |
| | | public AjaxResult<SysDept> getInfo(@PathVariable Long deptId) { |
| | | public AjaxResult<SysDept> getInfo(@ApiParam("é¨é¨ID") @PathVariable Long deptId) { |
| | | deptService.checkDeptDataScope(deptId); |
| | | return AjaxResult.success(deptService.selectDeptById(deptId)); |
| | | } |
| | |
| | | */ |
| | | @ApiOperation("è·åé¨é¨ä¸ææ å表") |
| | | @GetMapping("/treeselect") |
| | | public AjaxResult<List<TreeSelect>> treeselect(SysDept dept) { |
| | | public AjaxResult<List<Tree<Long>>> treeselect(SysDept dept) { |
| | | List<SysDept> depts = deptService.selectDeptList(dept); |
| | | return AjaxResult.success(deptService.buildDeptTreeSelect(depts)); |
| | | } |
| | |
| | | */ |
| | | @ApiOperation("å 载对åºè§è²é¨é¨å表æ ") |
| | | @GetMapping(value = "/roleDeptTreeselect/{roleId}") |
| | | public AjaxResult<Map<String, Object>> roleDeptTreeselect(@PathVariable("roleId") Long roleId) { |
| | | public AjaxResult<Map<String, Object>> roleDeptTreeselect(@ApiParam("è§è²ID") @PathVariable("roleId") Long roleId) { |
| | | List<SysDept> depts = deptService.selectDeptList(new SysDept()); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); |
| | |
| | | @SaCheckPermission("system:dept:remove") |
| | | @Log(title = "é¨é¨ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{deptId}") |
| | | public AjaxResult<Void> remove(@PathVariable Long deptId) { |
| | | public AjaxResult<Void> remove(@ApiParam("é¨é¨ID串") @PathVariable Long deptId) { |
| | | if (deptService.hasChildByDeptId(deptId)) { |
| | | return AjaxResult.error("åå¨ä¸çº§é¨é¨,ä¸å
许å é¤"); |
| | | } |
| | |
| | | import com.ruoyi.system.service.ISysDictTypeService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | @ApiOperation("导åºåå
¸æ°æ®å表") |
| | | @Log(title = "åå
¸æ°æ®", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:dict:export") |
| | | @GetMapping("/export") |
| | | @PostMapping("/export") |
| | | public void export(SysDictData dictData, HttpServletResponse response) { |
| | | List<SysDictData> list = dictDataService.selectDictDataList(dictData); |
| | | ExcelUtil.exportExcel(list, "åå
¸æ°æ®", SysDictData.class, response); |
| | |
| | | @ApiOperation("æ¥è¯¢åå
¸æ°æ®è¯¦ç»") |
| | | @SaCheckPermission("system:dict:query") |
| | | @GetMapping(value = "/{dictCode}") |
| | | public AjaxResult<SysDictData> getInfo(@PathVariable Long dictCode) { |
| | | public AjaxResult<SysDictData> getInfo(@ApiParam("åå
¸code") @PathVariable Long dictCode) { |
| | | return AjaxResult.success(dictDataService.selectDictDataById(dictCode)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @ApiOperation("æ ¹æ®åå
¸ç±»åæ¥è¯¢åå
¸æ°æ®ä¿¡æ¯") |
| | | @GetMapping(value = "/type/{dictType}") |
| | | public AjaxResult<List<SysDictData>> dictType(@PathVariable String dictType) { |
| | | public AjaxResult<List<SysDictData>> dictType(@ApiParam("åå
¸ç±»å") @PathVariable String dictType) { |
| | | List<SysDictData> data = dictTypeService.selectDictDataByType(dictType); |
| | | if (StringUtils.isNull(data)) { |
| | | data = new ArrayList<>(); |
| | |
| | | @SaCheckPermission("system:dict:remove") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictCodes}") |
| | | public AjaxResult<Void> remove(@PathVariable Long[] dictCodes) { |
| | | public AjaxResult<Void> remove(@ApiParam("åå
¸code串") @PathVariable Long[] dictCodes) { |
| | | dictDataService.deleteDictDataByIds(dictCodes); |
| | | return success(); |
| | | } |
| | |
| | | import com.ruoyi.system.service.ISysDictTypeService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | @ApiOperation("导åºåå
¸ç±»åå表") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:dict:export") |
| | | @GetMapping("/export") |
| | | @PostMapping("/export") |
| | | public void export(SysDictType dictType, HttpServletResponse response) { |
| | | List<SysDictType> list = dictTypeService.selectDictTypeList(dictType); |
| | | ExcelUtil.exportExcel(list, "åå
¸ç±»å", SysDictType.class, response); |
| | |
| | | @ApiOperation("æ¥è¯¢åå
¸ç±»å详ç»") |
| | | @SaCheckPermission("system:dict:query") |
| | | @GetMapping(value = "/{dictId}") |
| | | public AjaxResult<SysDictType> getInfo(@PathVariable Long dictId) { |
| | | public AjaxResult<SysDictType> getInfo(@ApiParam("åå
¸ID") @PathVariable Long dictId) { |
| | | return AjaxResult.success(dictTypeService.selectDictTypeById(dictId)); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("system:dict:remove") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictIds}") |
| | | public AjaxResult<Void> remove(@PathVariable Long[] dictIds) { |
| | | public AjaxResult<Void> remove(@ApiParam("åå
¸ID串") @PathVariable Long[] dictIds) { |
| | | dictTypeService.deleteDictTypeByIds(dictIds); |
| | | return success(); |
| | | } |
| | |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.system.domain.vo.RouterVo; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.service.SysLoginService; |
| | | import com.ruoyi.system.service.SysPermissionService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Api(value = "æ°æ®åå
¸ä¿¡æ¯æ§å¶å¨", tags = {"æ°æ®åå
¸ä¿¡æ¯ç®¡ç"}) |
| | | @Api(value = "ç»å½éªè¯æ§å¶å¨", tags = {"ç»å½éªè¯ç®¡ç"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RestController |
| | | public class SysLoginController { |
| | | |
| | | private final SysLoginService loginService; |
| | | private final ISysMenuService menuService; |
| | | private final ISysUserService userService; |
| | | private final SysPermissionService permissionService; |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.TreeSelect; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | @ApiOperation("æ ¹æ®èåç¼å·è·å详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("system:menu:query") |
| | | @GetMapping(value = "/{menuId}") |
| | | public AjaxResult<SysMenu> getInfo(@PathVariable Long menuId) { |
| | | public AjaxResult<SysMenu> getInfo(@ApiParam("èåID") @PathVariable Long menuId) { |
| | | return AjaxResult.success(menuService.selectMenuById(menuId)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @ApiOperation("è·åèå䏿æ å表") |
| | | @GetMapping("/treeselect") |
| | | public AjaxResult<List<TreeSelect>> treeselect(SysMenu menu) { |
| | | public AjaxResult<List<Tree<Long>>> treeselect(SysMenu menu) { |
| | | List<SysMenu> menus = menuService.selectMenuList(menu, getUserId()); |
| | | return AjaxResult.success(menuService.buildMenuTreeSelect(menus)); |
| | | } |
| | |
| | | */ |
| | | @ApiOperation("å 载对åºè§è²èåå表æ ") |
| | | @GetMapping(value = "/roleMenuTreeselect/{roleId}") |
| | | public AjaxResult<Map<String, Object>> roleMenuTreeselect(@PathVariable("roleId") Long roleId) { |
| | | public AjaxResult<Map<String, Object>> roleMenuTreeselect(@ApiParam("è§è²ID") @PathVariable("roleId") Long roleId) { |
| | | List<SysMenu> menus = menuService.selectMenuList(getUserId()); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); |
| | |
| | | @SaCheckPermission("system:menu:remove") |
| | | @Log(title = "èå管ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{menuId}") |
| | | public AjaxResult<Void> remove(@PathVariable("menuId") Long menuId) { |
| | | public AjaxResult<Void> remove(@ApiParam("èåID") @PathVariable("menuId") Long menuId) { |
| | | if (menuService.hasChildByMenuId(menuId)) { |
| | | return AjaxResult.error("åå¨åèå,ä¸å
许å é¤"); |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | |
| | | /** |
| | |
| | | @ApiOperation("æ ¹æ®éç¥å
¬åç¼å·è·å详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("system:notice:query") |
| | | @GetMapping(value = "/{noticeId}") |
| | | public AjaxResult<SysNotice> getInfo(@PathVariable Long noticeId) { |
| | | public AjaxResult<SysNotice> getInfo(@ApiParam("å
ŒID") @PathVariable Long noticeId) { |
| | | return AjaxResult.success(noticeService.selectNoticeById(noticeId)); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("system:notice:remove") |
| | | @Log(title = "éç¥å
Œ", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{noticeIds}") |
| | | public AjaxResult<Void> remove(@PathVariable Long[] noticeIds) { |
| | | public AjaxResult<Void> remove(@ApiParam("å
¬åID串") @PathVariable Long[] noticeIds) { |
| | | return toAjax(noticeService.deleteNoticeByIds(noticeIds)); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.system.service.ISysOssConfigService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | @ApiOperation("è·å对象åå¨é
置详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("system:oss:query") |
| | | @GetMapping("/{ossConfigId}") |
| | | public AjaxResult<SysOssConfigVo> getInfo(@NotNull(message = "主é®ä¸è½ä¸ºç©º") |
| | | public AjaxResult<SysOssConfigVo> getInfo(@ApiParam("OSSé
ç½®ID") |
| | | @NotNull(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable("ossConfigId") Integer ossConfigId) { |
| | | return AjaxResult.success(iSysOssConfigService.queryById(ossConfigId)); |
| | | } |
| | |
| | | @SaCheckPermission("system:oss:remove") |
| | | @Log(title = "对象åå¨é
ç½®", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ossConfigIds}") |
| | | public AjaxResult<Void> remove(@NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | public AjaxResult<Void> remove(@ApiParam("OSSé
置ID串") |
| | | @NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable Long[] ossConfigIds) { |
| | | return toAjax(iSysOssConfigService.deleteWithValidByIds(Arrays.asList(ossConfigIds), true) ? 1 : 0); |
| | | } |
| | |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | | import com.ruoyi.oss.constant.CloudConstant; |
| | | import com.ruoyi.oss.constant.OssConstant; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.system.domain.SysOss; |
| | | import com.ruoyi.system.domain.bo.SysOssBo; |
| | | import com.ruoyi.system.domain.vo.SysOssVo; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.system.service.ISysOssService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.MediaType; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | |
| | | */ |
| | | @ApiOperation("ä¸ä¼ OSS对象åå¨") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "file", value = "æä»¶", dataType = "java.io.File", required = true), |
| | | @ApiImplicitParam(name = "file", value = "æä»¶", dataTypeClass = File.class, required = true), |
| | | }) |
| | | @SaCheckPermission("system:oss:upload") |
| | | @Log(title = "OSS对象åå¨", businessType = BusinessType.INSERT) |
| | |
| | | @ApiOperation("ä¸è½½OSS对象åå¨") |
| | | @SaCheckPermission("system:oss:download") |
| | | @GetMapping("/download/{ossId}") |
| | | public void download(@PathVariable Long ossId, HttpServletResponse response) throws IOException { |
| | | public void download(@ApiParam("OSS对象ID") @PathVariable Long ossId, HttpServletResponse response) throws IOException { |
| | | SysOss sysOss = iSysOssService.getById(ossId); |
| | | if (ObjectUtil.isNull(sysOss)) { |
| | | throw new ServiceException("æä»¶æ°æ®ä¸åå¨!"); |
| | |
| | | @SaCheckPermission("system:oss:remove") |
| | | @Log(title = "OSS对象åå¨", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ossIds}") |
| | | public AjaxResult<Void> remove(@NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | public AjaxResult<Void> remove(@ApiParam("OSS对象ID串") |
| | | @NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable Long[] ossIds) { |
| | | return toAjax(iSysOssService.deleteWithValidByIds(Arrays.asList(ossIds), true) ? 1 : 0); |
| | | } |
| | |
| | | public AjaxResult<Void> changePreviewListResource(@RequestBody String body) { |
| | | Map<String, Boolean> map = JsonUtils.parseMap(body); |
| | | SysConfig config = iSysConfigService.getOne(new LambdaQueryWrapper<SysConfig>() |
| | | .eq(SysConfig::getConfigKey, CloudConstant.PEREVIEW_LIST_RESOURCE_KEY)); |
| | | .eq(SysConfig::getConfigKey, OssConstant.PEREVIEW_LIST_RESOURCE_KEY)); |
| | | config.setConfigValue(map.get("previewListResource").toString()); |
| | | return toAjax(iSysConfigService.updateConfig(config)); |
| | | } |
| | |
| | | import com.ruoyi.system.service.ISysPostService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | @ApiOperation("导åºå²ä½å表") |
| | | @Log(title = "å²ä½ç®¡ç", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:post:export") |
| | | @GetMapping("/export") |
| | | @PostMapping("/export") |
| | | public void export(SysPost post, HttpServletResponse response) { |
| | | List<SysPost> list = postService.selectPostList(post); |
| | | ExcelUtil.exportExcel(list, "å²ä½æ°æ®", SysPost.class, response); |
| | |
| | | @ApiOperation("æ ¹æ®å²ä½ç¼å·è·å详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("system:post:query") |
| | | @GetMapping(value = "/{postId}") |
| | | public AjaxResult<SysPost> getInfo(@PathVariable Long postId) { |
| | | public AjaxResult<SysPost> getInfo(@ApiParam("å²ä½ID") @PathVariable Long postId) { |
| | | return AjaxResult.success(postService.selectPostById(postId)); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("system:post:remove") |
| | | @Log(title = "å²ä½ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{postIds}") |
| | | public AjaxResult<Void> remove(@PathVariable Long[] postIds) { |
| | | public AjaxResult<Void> remove(@ApiParam("å²ä½ID串") @PathVariable Long[] postIds) { |
| | | return toAjax(postService.deletePostByIds(postIds)); |
| | | } |
| | | |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | |
| | | @GetMapping |
| | | public AjaxResult<Map<String, Object>> profile() { |
| | | SysUser user = userService.getById(getUserId()); |
| | | Map<String,Object> ajax = new HashMap<>(); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | ajax.put("user", user); |
| | | ajax.put("roleGroup", userService.selectUserRoleGroup(user.getUserName())); |
| | | ajax.put("postGroup", userService.selectUserPostGroup(user.getUserName())); |
| | |
| | | return AjaxResult.error("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'失败ï¼é®ç®±è´¦å·å·²åå¨"); |
| | | } |
| | | user.setUserId(getUserId()); |
| | | user.setUserName(null); |
| | | user.setPassword(null); |
| | | if (userService.updateUserProfile(user) > 0) { |
| | | return AjaxResult.success(); |
| | |
| | | * éç½®å¯ç |
| | | */ |
| | | @ApiOperation("éç½®å¯ç ") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "oldPassword", value = "æ§å¯ç ", paramType = "query", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "newPassword", value = "æ°å¯ç ", paramType = "query", dataTypeClass = String.class) |
| | | }) |
| | | @Log(title = "个人信æ¯", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/updatePwd") |
| | | public AjaxResult<Void> updatePwd(String oldPassword, String newPassword) { |
| | |
| | | */ |
| | | @ApiOperation("头åä¸ä¼ ") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "file", value = "ç¨æ·å¤´å", dataType = "java.io.File", required = true), |
| | | @ApiImplicitParam(name = "avatarfile", value = "ç¨æ·å¤´å", dataTypeClass = File.class, required = true), |
| | | }) |
| | | @Log(title = "ç¨æ·å¤´å", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/avatar") |
| | |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | @ApiOperation("导åºè§è²ä¿¡æ¯å表") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:role:export") |
| | | @GetMapping("/export") |
| | | @PostMapping("/export") |
| | | public void export(SysRole role, HttpServletResponse response) { |
| | | List<SysRole> list = roleService.selectRoleList(role); |
| | | ExcelUtil.exportExcel(list, "è§è²æ°æ®", SysRole.class, response); |
| | |
| | | @ApiOperation("æ ¹æ®è§è²ç¼å·è·å详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("system:role:query") |
| | | @GetMapping(value = "/{roleId}") |
| | | public AjaxResult<SysRole> getInfo(@PathVariable Long roleId) { |
| | | public AjaxResult<SysRole> getInfo(@ApiParam("è§è²ID") @PathVariable Long roleId) { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return AjaxResult.success(roleService.selectRoleById(roleId)); |
| | | } |
| | |
| | | @SaCheckPermission("system:role:remove") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{roleIds}") |
| | | public AjaxResult<Void> remove(@PathVariable Long[] roleIds) { |
| | | public AjaxResult<Void> remove(@ApiParam("å²ä½ID串") @PathVariable Long[] roleIds) { |
| | | return toAjax(roleService.deleteRoleByIds(roleIds)); |
| | | } |
| | | |
| | |
| | | * æ¹éåæ¶ææç¨æ· |
| | | */ |
| | | @ApiOperation("æ¹éåæ¶ææç¨æ·") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "roleId", value = "è§è²ID", paramType = "query", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "userIds", value = "ç¨æ·ID串", paramType = "query", dataTypeClass = String.class) |
| | | }) |
| | | @SaCheckPermission("system:role:edit") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/cancelAll") |
| | |
| | | * æ¹ééæ©ç¨æ·ææ |
| | | */ |
| | | @ApiOperation("æ¹ééæ©ç¨æ·ææ") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "roleId", value = "è§è²ID", paramType = "query", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "userIds", value = "ç¨æ·ID串", paramType = "query", dataTypeClass = String.class) |
| | | }) |
| | | @SaCheckPermission("system:role:edit") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/selectAll") |
| | |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.excel.ExcelResult; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.system.domain.vo.SysUserExportVo; |
| | | import com.ruoyi.system.domain.vo.SysUserImportVo; |
| | | import com.ruoyi.system.listener.SysUserImportListener; |
| | | import com.ruoyi.system.service.ISysPostService; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | @ApiOperation("导åºç¨æ·å表") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:user:export") |
| | | @GetMapping("/export") |
| | | @PostMapping("/export") |
| | | public void export(SysUser user, HttpServletResponse response) { |
| | | List<SysUser> list = userService.selectUserList(user); |
| | | List<SysUserExportVo> listVo = BeanUtil.copyToList(list, SysUserExportVo.class); |
| | |
| | | @SaCheckPermission("system:user:import") |
| | | @PostMapping("/importData") |
| | | public AjaxResult<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception { |
| | | List<SysUserImportVo> userListVo = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class); |
| | | List<SysUser> userList = BeanUtil.copyToList(userListVo, SysUser.class); |
| | | String operName = userService.getById(getUserId()).getUserName(); |
| | | String message = userService.importUser(userList, updateSupport, operName); |
| | | return AjaxResult.success(message); |
| | | ExcelResult<SysUserImportVo> result = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class, new SysUserImportListener(updateSupport)); |
| | | return AjaxResult.success(result.getAnalysis()); |
| | | } |
| | | |
| | | @ApiOperation("ä¸è½½å¯¼å
¥æ¨¡æ¿") |
| | | @GetMapping("/importTemplate") |
| | | @PostMapping("/importTemplate") |
| | | public void importTemplate(HttpServletResponse response) { |
| | | ExcelUtil.exportExcel(new ArrayList<>(), "ç¨æ·æ°æ®", SysUserImportVo.class, response); |
| | | } |
| | |
| | | @ApiOperation("æ ¹æ®ç¨æ·ç¼å·è·å详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("system:user:query") |
| | | @GetMapping(value = {"/", "/{userId}" }) |
| | | public AjaxResult<Map<String, Object>> getInfo(@PathVariable(value = "userId", required = false) Long userId) { |
| | | public AjaxResult<Map<String, Object>> getInfo(@ApiParam("ç¨æ·ID") @PathVariable(value = "userId", required = false) Long userId) { |
| | | userService.checkUserDataScope(userId); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | List<SysRole> roles = roleService.selectRoleAll(); |
| | |
| | | @SaCheckPermission("system:user:remove") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{userIds}") |
| | | public AjaxResult<Void> remove(@PathVariable Long[] userIds) { |
| | | public AjaxResult<Void> remove(@ApiParam("è§è²ID串") @PathVariable Long[] userIds) { |
| | | if (ArrayUtil.contains(userIds, getUserId())) { |
| | | return error("å½åç¨æ·ä¸è½å é¤"); |
| | | } |
| | |
| | | @ApiOperation("æ ¹æ®ç¨æ·ç¼å·è·åææè§è²") |
| | | @SaCheckPermission("system:user:query") |
| | | @GetMapping("/authRole/{userId}") |
| | | public AjaxResult<Map<String, Object>> authRole(@PathVariable("userId") Long userId) { |
| | | public AjaxResult<Map<String, Object>> authRole(@ApiParam("ç¨æ·ID") @PathVariable("userId") Long userId) { |
| | | SysUser user = userService.selectUserById(userId); |
| | | List<SysRole> roles = roleService.selectRolesByUserId(userId); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | |
| | | * ç¨æ·ææè§è² |
| | | */ |
| | | @ApiOperation("ç¨æ·ææè§è²") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "userId", value = "ç¨æ·Id", paramType = "query", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "roleIds", value = "è§è²ID串", paramType = "query", dataTypeClass = String.class) |
| | | }) |
| | | @SaCheckPermission("system:user:edit") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authRole") |
| | |
| | | --- # é
置临æ¶è·¯å¾åå¨ |
| | | spring: |
| | | servlet: |
| | | multipart: |
| | | # ä¸´æ¶æä»¶åå¨ä½ç½® é¿å
ä¸´æ¶æä»¶è¢«ç³»ç»æ¸
çæ¥é |
| | | location: /ruoyi/server/temp |
| | | |
| | | --- # çæ§é
ç½® |
| | | spring: |
| | | boot: |
| | |
| | | demoEnabled: true |
| | | # è·åipå°åå¼å
³ |
| | | addressEnabled: true |
| | | # ç¼åæå è½½ |
| | | cacheLazy: true |
| | | |
| | | captcha: |
| | | # é¡µé¢ <åæ°è®¾ç½®> å¯å¼å¯å
³é éªè¯ç æ ¡éª |
| | |
| | | - name: 3.代ç çææ¨¡å |
| | | basePackage: com.ruoyi.generator |
| | | |
| | | knife4j: |
| | | # æ¯å¦å¼å¯Knife4jå¢å¼ºæ¨¡å¼ |
| | | enable: true |
| | | # æ¯å¦å¼å¯ç产ç¯å¢ä¿æ¤çç¥ |
| | | production: @knife4j.production@ |
| | | # å端Uiç个æ§åé
ç½®å±æ§ |
| | | setting: |
| | | # é»è®¤è¯è¨ |
| | | language: zh-CN |
| | | # æ¯å¦æ¾ç¤ºFooter |
| | | enableFooter: false |
| | | # æ¯å¦å¼å¯å¨æåæ°è°è¯åè½ |
| | | enableDynamicParameter: true |
| | | # æ¯å¦å¨æ¯ä¸ªDebugè°è¯æ åæ¾ç¤ºå·æ°åéæé® |
| | | enableReloadCacheParameter: true |
| | | |
| | | # 鲿¢XSSæ»å» |
| | | xss: |
| | | # è¿æ»¤å¼å
³ |
| | |
| | | # DISCARD_POLICY ä¸¢å¼ |
| | | # ABORT_POLICY 䏿¢ |
| | | rejectedExecutionHandler: CALLER_RUNS_POLICY |
| | | |
| | | # feign ç¸å
³é
ç½® |
| | | feign: |
| | | # 䏿¯æå¤å
, 妿éè¦å¯å¨æ³¨è§£é
ç½® æ æåæ«å
ç级 |
| | | # ä¾å¦ com.**.**.feign |
| | | package: com.ruoyi.**.feign |
| | | # å¼å¯å缩 |
| | | compression: |
| | | request: |
| | | enabled: true |
| | | response: |
| | | enabled: true |
| | | okhttp: |
| | | enabled: true |
| | | circuitbreaker: |
| | | enabled: true |
| | | |
| | | --- # redisson ç¼åé
ç½® |
| | | redisson: |
| | |
| | | endpoint: |
| | | logfile: |
| | | external-file: ./logs/sys-console.log |
| | | |
| | | --- # 宿¶ä»»å¡é
ç½® |
| | | spring: |
| | | quartz: |
| | | scheduler-name: RuoyiScheduler |
| | | startup-delay: 1s |
| | | overwrite-existing-jobs: true |
| | | auto-startup: true |
| | | job-store-type: jdbc |
| | | properties: |
| | | org: |
| | | quartz: |
| | | # Scheduler ç¸å
³é
ç½® |
| | | scheduler: |
| | | instanceName: RuoyiScheduler |
| | | instanceId: AUTO |
| | | # çº¿ç¨æ± ç¸å
³é
ç½® |
| | | threadPool: |
| | | class: org.quartz.simpl.SimpleThreadPool |
| | | threadCount: 20 |
| | | threadPriority: 5 |
| | | # JobStore é群é
ç½® |
| | | jobStore: |
| | | class: org.quartz.impl.jdbcjobstore.JobStoreTX |
| | | isClustered: true |
| | | clusterCheckinInterval: 15000 |
| | | txIsolationLevelSerializable: true |
| | | misfireThreshold: 60000 |
| | | tablePrefix: QRTZ_ |
| | | # sqlserver å¯ç¨ |
| | | # selectWithLockSQL: SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ? |
| | |
| | | <level>INFO</level> |
| | | </filter> |
| | | </appender> |
| | | |
| | | |
| | | <!-- ç³»ç»æ¥å¿è¾åº --> |
| | | <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <file>${log.path}/sys-info.log</file> |
| | |
| | | <onMismatch>DENY</onMismatch> |
| | | </filter> |
| | | </appender> |
| | | |
| | | |
| | | <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <file>${log.path}/sys-error.log</file> |
| | | <!-- å¾ªç¯æ¿çï¼åºäºæ¶é´å建æ¥å¿æä»¶ --> |
| | |
| | | <onMismatch>DENY</onMismatch> |
| | | </filter> |
| | | </appender> |
| | | |
| | | <!-- ç¨æ·è®¿é®æ¥å¿è¾åº --> |
| | | <appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <file>${log.path}/sys-user.log</file> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
| | | <!-- æå¤©åæ» daily --> |
| | | <fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern> |
| | | <!-- æ¥å¿æå¤§çåå² 60天 --> |
| | | <maxHistory>60</maxHistory> |
| | | </rollingPolicy> |
| | | <encoder class="com.yomahub.tlog.core.enhance.logback.AspectLogbackEncoder"> |
| | | <pattern>${log.pattern}</pattern> |
| | | </encoder> |
| | | </appender> |
| | | |
| | | |
| | | <!-- ç³»ç»æ¨¡åæ¥å¿çº§å«æ§å¶ --> |
| | | <logger name="com.ruoyi" level="info" /> |
| | | <!-- Springæ¥å¿çº§å«æ§å¶ --> |
| | |
| | | <root level="info"> |
| | | <appender-ref ref="console" /> |
| | | </root> |
| | | |
| | | |
| | | <!--ç³»ç»æä½æ¥å¿--> |
| | | <root level="info"> |
| | | <appender-ref ref="file_info" /> |
| | | <appender-ref ref="file_error" /> |
| | | <appender-ref ref="file_console" /> |
| | | </root> |
| | | |
| | | <!--ç³»ç»ç¨æ·æä½æ¥å¿--> |
| | | <logger name="sys-user" level="info"> |
| | | <appender-ref ref="sys-user"/> |
| | | </logger> |
| | | </configuration> |
| | | |
| | | </configuration> |
| | |
| | | outagedetectioninterval=2 |
| | | # æ¯å¦è¿æ»¤ Log |
| | | filter=true |
| | | # è¿æ»¤ Log æ¶ææé¤ç表åå表ï¼ä»¥éå·åé |
| | | exclude=QRTZ_ |
| | |
| | | <artifactId>jaxb-impl</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- redis ç¼åæä½ --> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-data-redis</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- pool å¯¹è±¡æ± --> |
| | | <dependency> |
| | | <groupId>org.apache.commons</groupId> |
| | | <artifactId>commons-pool2</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- servletå
--> |
| | | <dependency> |
| | | <groupId>javax.servlet</groupId> |
| | |
| | | <dependency> |
| | | <groupId>org.projectlombok</groupId> |
| | | <artifactId>lombok</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- @deprecated ç±äºä½¿ç¨äººæ°è¾å° å³å®ä¸ 3.4.0 çæ¬ç§»é¤ --> |
| | | <dependency> |
| | | <groupId>org.springframework.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-openfeign</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- @deprecated ç±äºä½¿ç¨äººæ°è¾å° å³å®ä¸ 3.4.0 çæ¬ç§»é¤ --> |
| | | <dependency> |
| | | <groupId>io.github.openfeign</groupId> |
| | | <artifactId>feign-okhttp</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | |
| | | <artifactId>tlog-webroot</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.yomahub</groupId> |
| | | <artifactId>tlog-feign</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| | |
| | | private boolean demoEnabled; |
| | | |
| | | /** |
| | | * ç¼åæå è½½ |
| | | */ |
| | | private boolean cacheLazy; |
| | | |
| | | /** |
| | | * è·åå°åå¼å
³ |
| | | */ |
| | | @Getter |
| | |
| | | */ |
| | | public static final String SYS_DICT_KEY = "sys_dict:"; |
| | | |
| | | /** |
| | | * RMI è¿ç¨æ¹æ³è°ç¨ |
| | | */ |
| | | public static final String LOOKUP_RMI = "rmi://"; |
| | | |
| | | /** |
| | | * LDAP è¿ç¨æ¹æ³è°ç¨ |
| | | */ |
| | | public static final String LOOKUP_LDAP = "ldap://"; |
| | | } |
| | |
| | | import com.alibaba.excel.metadata.GlobalConfiguration; |
| | | import com.alibaba.excel.metadata.property.ExcelContentProperty; |
| | | import com.ruoyi.common.annotation.ExcelDictFormat; |
| | | import com.ruoyi.common.core.service.DictService; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.lang.reflect.Field; |
| | |
| | | if (StringUtils.isBlank(type)) { |
| | | value = ExcelUtil.reverseByExp(label, anno.readConverterExp(), anno.separator()); |
| | | } else { |
| | | value = ExcelUtil.reverseDictByExp(label, type, anno.separator()); |
| | | value = SpringUtils.getBean(DictService.class).getDictValue(type, label, anno.separator()); |
| | | } |
| | | return Convert.convert(contentProperty.getField().getType(), value); |
| | | } |
| | |
| | | if (StringUtils.isBlank(type)) { |
| | | label = ExcelUtil.convertByExp(value, anno.readConverterExp(), anno.separator()); |
| | | } else { |
| | | label = ExcelUtil.convertDictByExp(value, type, anno.separator()); |
| | | label = SpringUtils.getBean(DictService.class).getDictLabel(type, value, anno.separator()); |
| | | } |
| | | return new CellData<>(label); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.service; |
| | | |
| | | /** |
| | | * éç¨ åæ°é
ç½®æå¡ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ConfigService { |
| | | |
| | | /** |
| | | * æ ¹æ®åæ° key è·ååæ°å¼ |
| | | * |
| | | * @param configKey åæ° key |
| | | * @return åæ°å¼ |
| | | */ |
| | | String getConfigValue(String configKey); |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.service; |
| | | |
| | | /** |
| | | * éç¨ åå
¸æå¡ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface DictService { |
| | | |
| | | /** |
| | | * åé符 |
| | | */ |
| | | String SEPARATOR = ","; |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸ç±»åååå
¸å¼è·ååå
¸æ ç¾ |
| | | * |
| | | * @param dictType åå
¸ç±»å |
| | | * @param dictValue åå
¸å¼ |
| | | * @return åå
¸æ ç¾ |
| | | */ |
| | | default String getDictLabel(String dictType, String dictValue) { |
| | | return getDictLabel(dictType, dictValue, SEPARATOR); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸ç±»åååå
¸æ ç¾è·ååå
¸å¼ |
| | | * |
| | | * @param dictType åå
¸ç±»å |
| | | * @param dictLabel åå
¸æ ç¾ |
| | | * @return åå
¸å¼ |
| | | */ |
| | | default String getDictValue(String dictType, String dictLabel) { |
| | | return getDictValue(dictType, dictLabel, SEPARATOR); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸ç±»åååå
¸å¼è·ååå
¸æ ç¾ |
| | | * |
| | | * @param dictType åå
¸ç±»å |
| | | * @param dictValue åå
¸å¼ |
| | | * @param separator åé符 |
| | | * @return åå
¸æ ç¾ |
| | | */ |
| | | String getDictLabel(String dictType, String dictValue, String separator); |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸ç±»åååå
¸æ ç¾è·ååå
¸å¼ |
| | | * |
| | | * @param dictType åå
¸ç±»å |
| | | * @param dictLabel åå
¸æ ç¾ |
| | | * @param separator åé符 |
| | | * @return åå
¸å¼ |
| | | */ |
| | | String getDictValue(String dictType, String dictLabel, String separator); |
| | | |
| | | } |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | /** |
| | | * éç¨ ç³»ç»è®¿é®æ¥å¿ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface LogininforService { |
| | | |
| | | void recordLogininfor(String username, String status, String message, |
| | |
| | | import com.ruoyi.common.core.domain.dto.OperLogDTO; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | |
| | | /** |
| | | * éç¨ æä½æ¥å¿ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface OperLogService { |
| | | |
| | | @Async |
| | | void recordOper(OperLogDTO operLogDTO); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.excel; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.alibaba.excel.exception.ExcelAnalysisException; |
| | | import com.alibaba.excel.exception.ExcelDataConvertException; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.ruoyi.common.utils.ValidatorUtils; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import javax.validation.ConstraintViolation; |
| | | import javax.validation.ConstraintViolationException; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Excel 导å
¥çå¬ |
| | | * |
| | | * @author Yjoioooo |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | @NoArgsConstructor |
| | | public class DefaultExcelListener<T> extends AnalysisEventListener<T> implements ExcelListener<T> { |
| | | |
| | | /** |
| | | * æ¯å¦Validatoræ£éªï¼é»è®¤ä¸ºæ¯ |
| | | */ |
| | | private Boolean isValidate = Boolean.TRUE; |
| | | |
| | | /** |
| | | * excel è¡¨å¤´æ°æ® |
| | | */ |
| | | private Map<Integer, String> headMap; |
| | | |
| | | /** |
| | | * 导å
¥åæ§ |
| | | */ |
| | | private ExcelResult<T> excelResult; |
| | | |
| | | public DefaultExcelListener(boolean isValidate) { |
| | | this.excelResult = new DefautExcelResult<>(); |
| | | this.isValidate = isValidate; |
| | | } |
| | | |
| | | /** |
| | | * å¤çå¼å¸¸ |
| | | * |
| | | * @param exception ExcelDataConvertException |
| | | * @param context Excel ä¸ä¸æ |
| | | */ |
| | | @Override |
| | | public void onException(Exception exception, AnalysisContext context) throws Exception { |
| | | String errMsg = null; |
| | | if (exception instanceof ExcelDataConvertException) { |
| | | // å¦ææ¯æä¸ä¸ªåå
æ ¼ç转æ¢å¼å¸¸ è½è·åå°å
·ä½è¡å· |
| | | ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception; |
| | | Integer rowIndex = excelDataConvertException.getRowIndex(); |
| | | Integer columnIndex = excelDataConvertException.getColumnIndex(); |
| | | errMsg = StrUtil.format("第{}è¡-第{}å-表头{}: è§£æå¼å¸¸<br/>", |
| | | rowIndex + 1, columnIndex + 1, headMap.get(columnIndex)); |
| | | if (log.isDebugEnabled()) { |
| | | log.error(errMsg); |
| | | } |
| | | } |
| | | if (exception instanceof ConstraintViolationException) { |
| | | ConstraintViolationException constraintViolationException = (ConstraintViolationException) exception; |
| | | Set<ConstraintViolation<?>> constraintViolations = constraintViolationException.getConstraintViolations(); |
| | | String constraintViolationsMsg = constraintViolations.stream() |
| | | .map(ConstraintViolation::getMessage) |
| | | .collect(Collectors.joining(", ")); |
| | | errMsg = StrUtil.format("第{}è¡æ°æ®æ ¡éªå¼å¸¸: {}", context.readRowHolder().getRowIndex() + 1, constraintViolationsMsg); |
| | | if (log.isDebugEnabled()) { |
| | | log.error(errMsg); |
| | | } |
| | | } |
| | | excelResult.getErrorList().add(errMsg); |
| | | throw new ExcelAnalysisException(errMsg); |
| | | } |
| | | |
| | | @Override |
| | | public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) { |
| | | this.headMap = headMap; |
| | | log.debug("è§£æå°ä¸æ¡è¡¨å¤´æ°æ®: {}", JSON.toJSONString(headMap)); |
| | | } |
| | | |
| | | @Override |
| | | public void invoke(T data, AnalysisContext context) { |
| | | if (isValidate) { |
| | | ValidatorUtils.validate(data); |
| | | } |
| | | excelResult.getList().add(data); |
| | | } |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext context) { |
| | | log.debug("æææ°æ®è§£æå®æï¼"); |
| | | } |
| | | |
| | | @Override |
| | | public ExcelResult<T> getExcelResult() { |
| | | return excelResult; |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.excel; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import lombok.Setter; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * é»è®¤excelè¿å对象 |
| | | * |
| | | * @author Yjoioooo |
| | | * @author Lion Li |
| | | */ |
| | | public class DefautExcelResult<T> implements ExcelResult<T> { |
| | | |
| | | /** |
| | | * æ°æ®å¯¹è±¡list |
| | | */ |
| | | @Setter |
| | | private List<T> list; |
| | | |
| | | /** |
| | | * é误信æ¯å表 |
| | | */ |
| | | @Setter |
| | | private List<String> errorList; |
| | | |
| | | public DefautExcelResult() { |
| | | this.list = new ArrayList<>(); |
| | | this.errorList = new ArrayList<>(); |
| | | } |
| | | |
| | | public DefautExcelResult(List<T> list, List<String> errorList) { |
| | | this.list = list; |
| | | this.errorList = errorList; |
| | | } |
| | | |
| | | public DefautExcelResult(ExcelResult<T> excelResult) { |
| | | this.list = excelResult.getList(); |
| | | this.errorList = excelResult.getErrorList(); |
| | | } |
| | | |
| | | @Override |
| | | public List<T> getList() { |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getErrorList() { |
| | | return errorList; |
| | | } |
| | | |
| | | /** |
| | | * è·å导å
¥åæ§ |
| | | * |
| | | * @return 导å
¥åæ§ |
| | | */ |
| | | @Override |
| | | public String getAnalysis() { |
| | | int successCount = list.size(); |
| | | int errorCount = errorList.size(); |
| | | if (successCount == 0) { |
| | | return "读åå¤±è´¥ï¼æªè§£æå°æ°æ®"; |
| | | } else { |
| | | if (errorCount == 0) { |
| | | return StrUtil.format("æåæ¨ï¼å
¨é¨è¯»åæåï¼å
±{}æ¡", successCount); |
| | | } else { |
| | | return ""; |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.excel; |
| | | |
| | | import com.alibaba.excel.read.listener.ReadListener; |
| | | |
| | | /** |
| | | * Excel 导å
¥çå¬ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ExcelListener<T> extends ReadListener<T> { |
| | | |
| | | ExcelResult<T> getExcelResult(); |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.excel; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * excelè¿å对象 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ExcelResult<T> { |
| | | |
| | | /** |
| | | * 对象å表 |
| | | */ |
| | | List<T> getList(); |
| | | |
| | | /** |
| | | * é误å表 |
| | | */ |
| | | List<String> getErrorList(); |
| | | |
| | | /** |
| | | * 导å
¥åæ§ |
| | | */ |
| | | String getAnalysis(); |
| | | } |
| | |
| | | * åå
¸å·¥å
·ç±» |
| | | * |
| | | * @author ruoyi |
| | | * @deprecated 3.5.0 çæ¬å é¤ è¿ç§»è³ {@link com.ruoyi.common.core.service.DictService} |
| | | */ |
| | | @Deprecated |
| | | public class DictUtils { |
| | | |
| | | /** |
| | |
| | | * @return dictDatas åå
¸æ°æ®å表 |
| | | */ |
| | | public static List<SysDictData> getDictCache(String key) { |
| | | Object cacheObj = RedisUtils.getCacheObject(getCacheKey(key)); |
| | | if (StringUtils.isNotNull(cacheObj)) { |
| | | List<SysDictData> dictDatas = (List<SysDictData>) cacheObj; |
| | | List<SysDictData> dictDatas = RedisUtils.getCacheObject(getCacheKey(key)); |
| | | if (StringUtils.isNotNull(dictDatas)) { |
| | | return dictDatas; |
| | | } |
| | | return null; |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.baomidou.mybatisplus.core.metadata.OrderItem; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | } |
| | | PagePlus<T, K> page = new PagePlus<>(pageNum, pageSize); |
| | | OrderItem orderItem = buildOrderItem(orderByColumn, isAsc); |
| | | page.addOrder(orderItem); |
| | | if (ObjectUtil.isNotNull(orderItem)) { |
| | | page.addOrder(orderItem); |
| | | } |
| | | return page; |
| | | } |
| | | |
| | |
| | | } |
| | | Page<T> page = new Page<>(pageNum, pageSize); |
| | | OrderItem orderItem = buildOrderItem(orderByColumn, isAsc); |
| | | page.addOrder(orderItem); |
| | | if (ObjectUtil.isNotNull(orderItem)) { |
| | | page.addOrder(orderItem); |
| | | } |
| | | return page; |
| | | } |
| | | |
| | |
| | | * @param value ç¼åçå¼ |
| | | */ |
| | | public static <T> void setCacheObject(final String key, final T value) { |
| | | client.getBucket(key).set(value); |
| | | setCacheObject(key, value, false); |
| | | } |
| | | |
| | | /** |
| | | * ç¼ååºæ¬ç对象ï¼ä¿çå½å对象 TTL æææ |
| | | * |
| | | * @param key ç¼åçé®å¼ |
| | | * @param value ç¼åçå¼ |
| | | * @param isSaveTtl æ¯å¦ä¿çTTLæææ(ä¾å¦: setä¹åttlå©ä½90 setä¹åè¿æ¯ä¸º90) |
| | | * @since Redis 6.X 以ä¸ä½¿ç¨ setAndKeepTTL å
¼å®¹ 5.X æ¹æ¡ |
| | | */ |
| | | public static <T> void setCacheObject(final String key, final T value, final boolean isSaveTtl) { |
| | | RBucket<Object> bucket = client.getBucket(key); |
| | | if (isSaveTtl) { |
| | | try { |
| | | bucket.setAndKeepTTL(value); |
| | | } catch (Exception e) { |
| | | long timeToLive = bucket.remainTimeToLive(); |
| | | bucket.set(value); |
| | | bucket.expire(timeToLive, TimeUnit.MILLISECONDS); |
| | | } |
| | | } else { |
| | | bucket.set(value); |
| | | } |
| | | } |
| | | |
| | | /** |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import cn.hutool.core.lang.tree.TreeNodeConfig; |
| | | import cn.hutool.core.lang.tree.TreeUtil; |
| | | import cn.hutool.core.lang.tree.parser.NodeParser; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * æ©å± hutool TreeUtil å°è£
ç³»ç»æ æå»º |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public class TreeBuildUtils extends TreeUtil { |
| | | |
| | | /** |
| | | * æ ¹æ®å端å®å¶å·®å¼ååæ®µ |
| | | */ |
| | | public static final TreeNodeConfig DEFAULT_CONFIG = TreeNodeConfig.DEFAULT_CONFIG.setNameKey("label"); |
| | | |
| | | /** |
| | | * é»è®¤æ ç¶èç¹id |
| | | */ |
| | | public static final Long DEFAULT_PARENT_ID = 0L; |
| | | |
| | | public static <T> List<Tree<Long>> build(List<T> list, NodeParser<T, Long> nodeParser) { |
| | | return TreeUtil.build(list, DEFAULT_PARENT_ID, DEFAULT_CONFIG, nodeParser); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import javax.validation.ConstraintViolation; |
| | | import javax.validation.ConstraintViolationException; |
| | | import javax.validation.Validation; |
| | | import javax.validation.Validator; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * Validator æ ¡éªæ¡æ¶å·¥å
· |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public class ValidatorUtils { |
| | | |
| | | private static final Validator VALID = Validation.buildDefaultValidatorFactory().getValidator(); |
| | | |
| | | public static <T> void validate(T object, Class<?>... groups) { |
| | | Set<ConstraintViolation<T>> validate = VALID.validate(object, groups); |
| | | if (!validate.isEmpty()) { |
| | | throw new ConstraintViolationException("åæ°æ ¡éªå¼å¸¸", validate); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.ruoyi.common.convert.ExcelBigNumberConvert; |
| | | import com.ruoyi.common.utils.DictUtils; |
| | | import com.ruoyi.common.excel.DefaultExcelListener; |
| | | import com.ruoyi.common.excel.ExcelListener; |
| | | import com.ruoyi.common.excel.ExcelResult; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | | |
| | |
| | | */ |
| | | public class ExcelUtil { |
| | | |
| | | /** |
| | | * 对excel表åé»è®¤ç¬¬ä¸ä¸ªç´¢å¼åè½¬æ¢ælistï¼EasyExcelï¼ |
| | | * |
| | | * @param is è¾å
¥æµ |
| | | * @return 转æ¢åéå |
| | | */ |
| | | public static <T> List<T> importExcel(InputStream is, Class<T> clazz) { |
| | | return EasyExcel.read(is).head(clazz).autoCloseStream(false).sheet().doReadSync(); |
| | | } |
| | | /** |
| | | * 忥坼å
¥(éç¨äºå°æ°æ®é) |
| | | * |
| | | * @param is è¾å
¥æµ |
| | | * @return 转æ¢åéå |
| | | */ |
| | | public static <T> List<T> importExcel(InputStream is, Class<T> clazz) { |
| | | return EasyExcel.read(is).head(clazz).autoCloseStream(false).sheet().doReadSync(); |
| | | } |
| | | |
| | | /** |
| | | * 对listæ°æ®æºå°å
¶éé¢çæ°æ®å¯¼å
¥å°excel表åï¼EasyExcelï¼ |
| | | * |
| | | * @param list å¯¼åºæ°æ®éå |
| | | * @param sheetName å·¥ä½è¡¨çåç§° |
| | | * @return ç»æ |
| | | */ |
| | | public static <T> void exportExcel(List<T> list, String sheetName, Class<T> clazz, HttpServletResponse response) { |
| | | try { |
| | | String filename = encodingFilename(sheetName); |
| | | response.reset(); |
| | | FileUtils.setAttachmentResponseHeader(response, filename); |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"); |
| | | ServletOutputStream os = response.getOutputStream(); |
| | | EasyExcel.write(os, clazz) |
| | | .autoCloseStream(false) |
| | | // èªå¨éé
|
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | | // 大æ°å¼èªå¨è½¬æ¢ 鲿¢å¤±ç |
| | | .registerConverter(new ExcelBigNumberConvert()) |
| | | .sheet(sheetName).doWrite(list); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException("导åºExcelå¼å¸¸"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è§£æå¯¼åºå¼ 0=ç·,1=女,2=æªç¥ |
| | | * |
| | | * @param propertyValue åæ°å¼ |
| | | * @param converterExp ç¿»è¯æ³¨è§£ |
| | | * @param separator åé符 |
| | | * @return è§£æåå¼ |
| | | */ |
| | | public static String convertByExp(String propertyValue, String converterExp, String separator) { |
| | | StringBuilder propertyString = new StringBuilder(); |
| | | String[] convertSource = converterExp.split(","); |
| | | for (String item : convertSource) { |
| | | String[] itemArray = item.split("="); |
| | | if (StringUtils.containsAny(separator, propertyValue)) { |
| | | for (String value : propertyValue.split(separator)) { |
| | | if (itemArray[0].equals(value)) { |
| | | propertyString.append(itemArray[1] + separator); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | if (itemArray[0].equals(propertyValue)) { |
| | | return itemArray[1]; |
| | | } |
| | | } |
| | | } |
| | | return StringUtils.stripEnd(propertyString.toString(), separator); |
| | | } |
| | | /** |
| | | * ä½¿ç¨æ ¡éªçå¬å¨ 弿¥å¯¼å
¥ 忥è¿å |
| | | * |
| | | * @param is è¾å
¥æµ |
| | | * @param clazz 对象类å |
| | | * @param isValidate æ¯å¦ Validator æ£éª é»è®¤ä¸ºæ¯ |
| | | * @return 转æ¢åéå |
| | | */ |
| | | public static <T> ExcelResult<T> importExcel(InputStream is, Class<T> clazz, boolean isValidate) { |
| | | DefaultExcelListener<T> listener = new DefaultExcelListener<>(isValidate); |
| | | EasyExcel.read(is, clazz, listener).sheet().doRead(); |
| | | return listener.getExcelResult(); |
| | | } |
| | | |
| | | /** |
| | | * ååè§£æå¼ ç·=0,女=1,æªç¥=2 |
| | | * |
| | | * @param propertyValue åæ°å¼ |
| | | * @param converterExp ç¿»è¯æ³¨è§£ |
| | | * @param separator åé符 |
| | | * @return è§£æåå¼ |
| | | */ |
| | | public static String reverseByExp(String propertyValue, String converterExp, String separator) { |
| | | StringBuilder propertyString = new StringBuilder(); |
| | | String[] convertSource = converterExp.split(","); |
| | | for (String item : convertSource) { |
| | | String[] itemArray = item.split("="); |
| | | if (StringUtils.containsAny(separator, propertyValue)) { |
| | | for (String value : propertyValue.split(separator)) { |
| | | if (itemArray[1].equals(value)) { |
| | | propertyString.append(itemArray[0] + separator); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | if (itemArray[1].equals(propertyValue)) { |
| | | return itemArray[0]; |
| | | } |
| | | } |
| | | } |
| | | return StringUtils.stripEnd(propertyString.toString(), separator); |
| | | } |
| | | /** |
| | | * 使ç¨èªå®ä¹çå¬å¨ 弿¥å¯¼å
¥ èªå®ä¹è¿å |
| | | * |
| | | * @param is è¾å
¥æµ |
| | | * @param clazz 对象类å |
| | | * @param listener èªå®ä¹çå¬å¨ |
| | | * @return 转æ¢åéå |
| | | */ |
| | | public static <T> ExcelResult<T> importExcel(InputStream is, Class<T> clazz, ExcelListener<T> listener) { |
| | | EasyExcel.read(is, clazz, listener).sheet().doRead(); |
| | | return listener.getExcelResult(); |
| | | } |
| | | |
| | | /** |
| | | * è§£æåå
¸å¼ |
| | | * |
| | | * @param dictValue åå
¸å¼ |
| | | * @param dictType åå
¸ç±»å |
| | | * @param separator åé符 |
| | | * @return åå
¸æ ç¾ |
| | | */ |
| | | public static String convertDictByExp(String dictValue, String dictType, String separator) { |
| | | return DictUtils.getDictLabel(dictType, dictValue, separator); |
| | | } |
| | | /** |
| | | * 导åºexcel |
| | | * |
| | | * @param list å¯¼åºæ°æ®éå |
| | | * @param sheetName å·¥ä½è¡¨çåç§° |
| | | * @return ç»æ |
| | | */ |
| | | public static <T> void exportExcel(List<T> list, String sheetName, Class<T> clazz, HttpServletResponse response) { |
| | | try { |
| | | String filename = encodingFilename(sheetName); |
| | | response.reset(); |
| | | FileUtils.setAttachmentResponseHeader(response, filename); |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"); |
| | | ServletOutputStream os = response.getOutputStream(); |
| | | EasyExcel.write(os, clazz) |
| | | .autoCloseStream(false) |
| | | // èªå¨éé
|
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | | // 大æ°å¼èªå¨è½¬æ¢ 鲿¢å¤±ç |
| | | .registerConverter(new ExcelBigNumberConvert()) |
| | | .sheet(sheetName).doWrite(list); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException("导åºExcelå¼å¸¸"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ååè§£æå¼åå
¸å¼ |
| | | * |
| | | * @param dictLabel åå
¸æ ç¾ |
| | | * @param dictType åå
¸ç±»å |
| | | * @param separator åé符 |
| | | * @return åå
¸å¼ |
| | | */ |
| | | public static String reverseDictByExp(String dictLabel, String dictType, String separator) { |
| | | return DictUtils.getDictValue(dictType, dictLabel, separator); |
| | | } |
| | | /** |
| | | * è§£æå¯¼åºå¼ 0=ç·,1=女,2=æªç¥ |
| | | * |
| | | * @param propertyValue åæ°å¼ |
| | | * @param converterExp ç¿»è¯æ³¨è§£ |
| | | * @param separator åé符 |
| | | * @return è§£æåå¼ |
| | | */ |
| | | public static String convertByExp(String propertyValue, String converterExp, String separator) { |
| | | StringBuilder propertyString = new StringBuilder(); |
| | | String[] convertSource = converterExp.split(","); |
| | | for (String item : convertSource) { |
| | | String[] itemArray = item.split("="); |
| | | if (StringUtils.containsAny(separator, propertyValue)) { |
| | | for (String value : propertyValue.split(separator)) { |
| | | if (itemArray[0].equals(value)) { |
| | | propertyString.append(itemArray[1] + separator); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | if (itemArray[0].equals(propertyValue)) { |
| | | return itemArray[1]; |
| | | } |
| | | } |
| | | } |
| | | return StringUtils.stripEnd(propertyString.toString(), separator); |
| | | } |
| | | |
| | | /** |
| | | * ç¼ç æä»¶å |
| | | */ |
| | | public static String encodingFilename(String filename) { |
| | | return IdUtil.fastSimpleUUID() + "_" + filename + ".xlsx"; |
| | | } |
| | | /** |
| | | * ååè§£æå¼ ç·=0,女=1,æªç¥=2 |
| | | * |
| | | * @param propertyValue åæ°å¼ |
| | | * @param converterExp ç¿»è¯æ³¨è§£ |
| | | * @param separator åé符 |
| | | * @return è§£æåå¼ |
| | | */ |
| | | public static String reverseByExp(String propertyValue, String converterExp, String separator) { |
| | | StringBuilder propertyString = new StringBuilder(); |
| | | String[] convertSource = converterExp.split(","); |
| | | for (String item : convertSource) { |
| | | String[] itemArray = item.split("="); |
| | | if (StringUtils.containsAny(separator, propertyValue)) { |
| | | for (String value : propertyValue.split(separator)) { |
| | | if (itemArray[1].equals(value)) { |
| | | propertyString.append(itemArray[0] + separator); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | if (itemArray[1].equals(propertyValue)) { |
| | | return itemArray[0]; |
| | | } |
| | | } |
| | | } |
| | | return StringUtils.stripEnd(propertyString.toString(), separator); |
| | | } |
| | | |
| | | /** |
| | | * ç¼ç æä»¶å |
| | | */ |
| | | public static String encodingFilename(String filename) { |
| | | return IdUtil.fastSimpleUUID() + "_" + filename + ".xlsx"; |
| | | } |
| | | |
| | | } |
| | |
| | | @RequestMapping("/demo/cache") |
| | | public class RedisCacheController { |
| | | |
| | | /** |
| | | * æµè¯ @Cacheable |
| | | * |
| | | * 表示è¿ä¸ªæ¹æ³æäºç¼åçåè½,æ¹æ³çè¿åå¼ä¼è¢«ç¼å䏿¥ |
| | | * ä¸ä¸æ¬¡è°ç¨è¯¥æ¹æ³å,ä¼å»æ£æ¥æ¯å¦ç¼åä¸å·²ç»æå¼ |
| | | * 妿æå°±ç´æ¥è¿å,ä¸è°ç¨æ¹æ³ |
| | | * å¦ææ²¡æ,å°±è°ç¨æ¹æ³,ç¶åæç»æç¼åèµ·æ¥ |
| | | * è¿ä¸ªæ³¨è§£ãä¸è¬ç¨å¨æ¥è¯¢æ¹æ³ä¸ã |
| | | * |
| | | * éç¹è¯´æ: ç¼å注解严谨ä¸å
¶ä»çéæ°æ®åè½ä¸èµ·ä½¿ç¨ |
| | | * ä¾å¦: æ°æ®æé注解 ä¼é æ ç¼åå»ç©¿ ä¸ æ°æ®ä¸ä¸è´é®é¢ |
| | | * |
| | | * cacheNames 为é
ç½®æä»¶å
groupId |
| | | */ |
| | | @ApiOperation("æµè¯ @Cacheable") |
| | | @Cacheable(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null") |
| | | @GetMapping("/test1") |
| | | public AjaxResult<String> test1(String key, String value){ |
| | | return AjaxResult.success("æä½æå", value); |
| | | } |
| | | /** |
| | | * æµè¯ @Cacheable |
| | | * <p> |
| | | * 表示è¿ä¸ªæ¹æ³æäºç¼åçåè½,æ¹æ³çè¿åå¼ä¼è¢«ç¼å䏿¥ |
| | | * ä¸ä¸æ¬¡è°ç¨è¯¥æ¹æ³å,ä¼å»æ£æ¥æ¯å¦ç¼åä¸å·²ç»æå¼ |
| | | * 妿æå°±ç´æ¥è¿å,ä¸è°ç¨æ¹æ³ |
| | | * å¦ææ²¡æ,å°±è°ç¨æ¹æ³,ç¶åæç»æç¼åèµ·æ¥ |
| | | * è¿ä¸ªæ³¨è§£ãä¸è¬ç¨å¨æ¥è¯¢æ¹æ³ä¸ã |
| | | * <p> |
| | | * éç¹è¯´æ: ç¼å注解严谨ä¸å
¶ä»çéæ°æ®åè½ä¸èµ·ä½¿ç¨ |
| | | * ä¾å¦: æ°æ®æé注解 ä¼é æ ç¼åå»ç©¿ ä¸ æ°æ®ä¸ä¸è´é®é¢ |
| | | * <p> |
| | | * cacheNames 为é
ç½®æä»¶å
groupId |
| | | */ |
| | | @ApiOperation("æµè¯ @Cacheable") |
| | | @Cacheable(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null") |
| | | @GetMapping("/test1") |
| | | public AjaxResult<String> test1(String key, String value) { |
| | | return AjaxResult.success("æä½æå", value); |
| | | } |
| | | |
| | | /** |
| | | * æµè¯ @CachePut |
| | | * |
| | | * å äº@CachePutæ³¨è§£çæ¹æ³,ä¼ææ¹æ³çè¿åå¼putå°ç¼åéé¢ç¼åèµ·æ¥,ä¾å
¶å®å°æ¹ä½¿ç¨ |
| | | * å®ãé常ç¨å¨æ°å¢æ¹æ³ä¸ã |
| | | * |
| | | * cacheNames 为 é
ç½®æä»¶å
groupId |
| | | */ |
| | | @ApiOperation("æµè¯ @CachePut") |
| | | @CachePut(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null") |
| | | @GetMapping("/test2") |
| | | public AjaxResult<String> test2(String key, String value){ |
| | | return AjaxResult.success("æä½æå", value); |
| | | } |
| | | /** |
| | | * æµè¯ @CachePut |
| | | * <p> |
| | | * å äº@CachePutæ³¨è§£çæ¹æ³,ä¼ææ¹æ³çè¿åå¼putå°ç¼åéé¢ç¼åèµ·æ¥,ä¾å
¶å®å°æ¹ä½¿ç¨ |
| | | * å®ãé常ç¨å¨æ°å¢æ¹æ³ä¸ã |
| | | * <p> |
| | | * cacheNames 为 é
ç½®æä»¶å
groupId |
| | | */ |
| | | @ApiOperation("æµè¯ @CachePut") |
| | | @CachePut(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null") |
| | | @GetMapping("/test2") |
| | | public AjaxResult<String> test2(String key, String value) { |
| | | return AjaxResult.success("æä½æå", value); |
| | | } |
| | | |
| | | /** |
| | | * æµè¯ @CacheEvict |
| | | * |
| | | * 使ç¨äºCacheEvictæ³¨è§£çæ¹æ³,伿¸
空æå®ç¼å |
| | | * ãä¸è¬ç¨å¨æ´æ°æè
å é¤çæ¹æ³ä¸ã |
| | | * |
| | | * cacheNames 为 é
ç½®æä»¶å
groupId |
| | | */ |
| | | @ApiOperation("æµè¯ @CacheEvict") |
| | | @CacheEvict(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null") |
| | | @GetMapping("/test3") |
| | | public AjaxResult<String> test3(String key, String value){ |
| | | return AjaxResult.success("æä½æå", value); |
| | | } |
| | | /** |
| | | * æµè¯ @CacheEvict |
| | | * <p> |
| | | * 使ç¨äºCacheEvictæ³¨è§£çæ¹æ³,伿¸
空æå®ç¼å |
| | | * ãä¸è¬ç¨å¨æ´æ°æè
å é¤çæ¹æ³ä¸ã |
| | | * <p> |
| | | * cacheNames 为 é
ç½®æä»¶å
groupId |
| | | */ |
| | | @ApiOperation("æµè¯ @CacheEvict") |
| | | @CacheEvict(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null") |
| | | @GetMapping("/test3") |
| | | public AjaxResult<String> test3(String key, String value) { |
| | | return AjaxResult.success("æä½æå", value); |
| | | } |
| | | |
| | | /** |
| | | * æµè¯è®¾ç½®è¿ææ¶é´ |
| | | * æå¨è®¾ç½®è¿ææ¶é´10ç§ |
| | | * 11ç§åè·å 夿æ¯å¦ç¸ç |
| | | */ |
| | | @ApiOperation("æµè¯è®¾ç½®è¿ææ¶é´") |
| | | @GetMapping("/test6") |
| | | public AjaxResult<Boolean> test6(String key, String value){ |
| | | RedisUtils.setCacheObject(key, value); |
| | | boolean flag = RedisUtils.expire(key, 10, TimeUnit.SECONDS); |
| | | System.out.println("***********" + flag); |
| | | try { |
| | | Thread.sleep(11 * 1000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | Object obj = RedisUtils.getCacheObject(key); |
| | | return AjaxResult.success("æä½æå", value.equals(obj)); |
| | | } |
| | | /** |
| | | * æµè¯è®¾ç½®è¿ææ¶é´ |
| | | * æå¨è®¾ç½®è¿ææ¶é´10ç§ |
| | | * 11ç§åè·å 夿æ¯å¦ç¸ç |
| | | */ |
| | | @ApiOperation("æµè¯è®¾ç½®è¿ææ¶é´") |
| | | @GetMapping("/test6") |
| | | public AjaxResult<Boolean> test6(String key, String value) { |
| | | RedisUtils.setCacheObject(key, value); |
| | | boolean flag = RedisUtils.expire(key, 10, TimeUnit.SECONDS); |
| | | System.out.println("***********" + flag); |
| | | try { |
| | | Thread.sleep(11 * 1000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | Object obj = RedisUtils.getCacheObject(key); |
| | | return AjaxResult.success("æä½æå", value.equals(obj)); |
| | | } |
| | | |
| | | } |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | @RequestMapping("/demo/redisLock") |
| | | public class RedisLockController { |
| | | |
| | | @Autowired |
| | | private LockTemplate lockTemplate; |
| | | @Autowired |
| | | private LockTemplate lockTemplate; |
| | | |
| | | /** |
| | | * æµè¯lock4j 注解 |
| | | */ |
| | | @ApiOperation("æµè¯lock4j 注解") |
| | | @Lock4j(keys = {"#key"}) |
| | | @GetMapping("/testLock4j") |
| | | public AjaxResult<String> testLock4j(String key,String value){ |
| | | System.out.println("start:"+key+",time:"+ LocalTime.now().toString()); |
| | | try { |
| | | Thread.sleep(10000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | System.out.println("end :"+key+",time:"+LocalTime.now().toString()); |
| | | return AjaxResult.success("æä½æå",value); |
| | | } |
| | | /** |
| | | * æµè¯lock4j 注解 |
| | | */ |
| | | @ApiOperation("æµè¯lock4j 注解") |
| | | @Lock4j(keys = {"#key"}) |
| | | @GetMapping("/testLock4j") |
| | | public AjaxResult<String> testLock4j(String key, String value) { |
| | | System.out.println("start:" + key + ",time:" + LocalTime.now().toString()); |
| | | try { |
| | | Thread.sleep(10000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | System.out.println("end :" + key + ",time:" + LocalTime.now().toString()); |
| | | return AjaxResult.success("æä½æå", value); |
| | | } |
| | | |
| | | /** |
| | | * æµè¯lock4j å·¥å
· |
| | | */ |
| | | @ApiOperation("æµè¯lock4j å·¥å
·") |
| | | @GetMapping("/testLock4jLockTemaplate") |
| | | public AjaxResult<String> testLock4jLockTemaplate(String key,String value){ |
| | | final LockInfo lockInfo = lockTemplate.lock(key, 30000L, 5000L, RedissonLockExecutor.class); |
| | | if (null == lockInfo) { |
| | | throw new RuntimeException("ä¸å¡å¤çä¸,请ç¨ååè¯"); |
| | | } |
| | | // è·åéæåï¼å¤çä¸å¡ |
| | | try { |
| | | try { |
| | | Thread.sleep(8000); |
| | | } catch (InterruptedException e) { |
| | | // |
| | | } |
| | | System.out.println("æ§è¡ç®åæ¹æ³1 , å½å线ç¨:" + Thread.currentThread().getName()); |
| | | } finally { |
| | | //éæ¾é |
| | | lockTemplate.releaseLock(lockInfo); |
| | | } |
| | | //ç»æ |
| | | return AjaxResult.success("æä½æå",value); |
| | | } |
| | | /** |
| | | * æµè¯lock4j å·¥å
· |
| | | */ |
| | | @ApiOperation("æµè¯lock4j å·¥å
·") |
| | | @GetMapping("/testLock4jLockTemaplate") |
| | | public AjaxResult<String> testLock4jLockTemaplate(String key, String value) { |
| | | final LockInfo lockInfo = lockTemplate.lock(key, 30000L, 5000L, RedissonLockExecutor.class); |
| | | if (null == lockInfo) { |
| | | throw new RuntimeException("ä¸å¡å¤çä¸,请ç¨ååè¯"); |
| | | } |
| | | // è·åéæåï¼å¤çä¸å¡ |
| | | try { |
| | | try { |
| | | Thread.sleep(8000); |
| | | } catch (InterruptedException e) { |
| | | // |
| | | } |
| | | System.out.println("æ§è¡ç®åæ¹æ³1 , å½å线ç¨:" + Thread.currentThread().getName()); |
| | | } finally { |
| | | //éæ¾é |
| | | lockTemplate.releaseLock(lockInfo); |
| | | } |
| | | //ç»æ |
| | | return AjaxResult.success("æä½æå", value); |
| | | } |
| | | |
| | | /** |
| | | * æµè¯spring-cache注解 |
| | | */ |
| | | @ApiOperation("æµè¯spring-cache注解") |
| | | @Cacheable(value = "test", key = "#key") |
| | | @GetMapping("/testCache") |
| | | public AjaxResult<String> testCache(String key) { |
| | | return AjaxResult.success("æä½æå", key); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.utils.RedisUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | @RequestMapping("/demo/redis/pubsub") |
| | | public class RedisPubSubController { |
| | | |
| | | @ApiOperation("å叿¶æ¯") |
| | | @GetMapping("/pub") |
| | | public AjaxResult<Void> pub(String key, String value){ |
| | | RedisUtils.publish(key, value, consumer -> { |
| | | System.out.println("åå¸éé => " + key + ", åéå¼ => " + value); |
| | | }); |
| | | return AjaxResult.success("æä½æå"); |
| | | } |
| | | @ApiOperation("å叿¶æ¯") |
| | | @GetMapping("/pub") |
| | | public AjaxResult<Void> pub(@ApiParam("ééKey") String key, @ApiParam("åéå
容") String value) { |
| | | RedisUtils.publish(key, value, consumer -> { |
| | | System.out.println("åå¸éé => " + key + ", åéå¼ => " + value); |
| | | }); |
| | | return AjaxResult.success("æä½æå"); |
| | | } |
| | | |
| | | @ApiOperation("订é
æ¶æ¯") |
| | | @GetMapping("/sub") |
| | | public AjaxResult<Void> sub(String key){ |
| | | RedisUtils.subscribe(key, String.class, msg -> { |
| | | System.out.println("订é
éé => " + key + ", æ¥æ¶å¼ => " + msg); |
| | | }); |
| | | return AjaxResult.success("æä½æå"); |
| | | } |
| | | @ApiOperation("订é
æ¶æ¯") |
| | | @GetMapping("/sub") |
| | | public AjaxResult<Void> sub(@ApiParam("ééKey") String key) { |
| | | RedisUtils.subscribe(key, String.class, msg -> { |
| | | System.out.println("订é
éé => " + key + ", æ¥æ¶å¼ => " + msg); |
| | | }); |
| | | return AjaxResult.success("æä½æå"); |
| | | } |
| | | |
| | | } |
| | |
| | | @RequestMapping("/demo/rateLimiter") |
| | | public class RedisRateLimiterController { |
| | | |
| | | /** |
| | | * æµè¯å
¨å±éæµ |
| | | * å
¨å±å½±å |
| | | */ |
| | | @ApiOperation("æµè¯å
¨å±éæµ") |
| | | @RateLimiter(count = 2, time = 10) |
| | | @GetMapping("/test") |
| | | public AjaxResult<String> test(String value){ |
| | | return AjaxResult.success("æä½æå",value); |
| | | } |
| | | /** |
| | | * æµè¯å
¨å±éæµ |
| | | * å
¨å±å½±å |
| | | */ |
| | | @ApiOperation("æµè¯å
¨å±éæµ") |
| | | @RateLimiter(count = 2, time = 10) |
| | | @GetMapping("/test") |
| | | public AjaxResult<String> test(String value) { |
| | | return AjaxResult.success("æä½æå", value); |
| | | } |
| | | |
| | | /** |
| | | * æµè¯è¯·æ±IPéæµ |
| | | * åä¸IP请æ±åå½±å |
| | | */ |
| | | @ApiOperation("æµè¯è¯·æ±IPéæµ") |
| | | @RateLimiter(count = 2, time = 10, limitType = LimitType.IP) |
| | | @GetMapping("/testip") |
| | | public AjaxResult<String> testip(String value){ |
| | | return AjaxResult.success("æä½æå",value); |
| | | } |
| | | /** |
| | | * æµè¯è¯·æ±IPéæµ |
| | | * åä¸IP请æ±åå½±å |
| | | */ |
| | | @ApiOperation("æµè¯è¯·æ±IPéæµ") |
| | | @RateLimiter(count = 2, time = 10, limitType = LimitType.IP) |
| | | @GetMapping("/testip") |
| | | public AjaxResult<String> testip(String value) { |
| | | return AjaxResult.success("æä½æå", value); |
| | | } |
| | | |
| | | /** |
| | | * æµè¯é群å®ä¾éæµ |
| | | * å¯å¨ä¸¤ä¸ªå端æå¡äºä¸å½±å |
| | | */ |
| | | @ApiOperation("æµè¯é群å®ä¾éæµ") |
| | | @RateLimiter(count = 2, time = 10, limitType = LimitType.CLUSTER) |
| | | @GetMapping("/testcluster") |
| | | public AjaxResult<String> testcluster(String value){ |
| | | return AjaxResult.success("æä½æå",value); |
| | | } |
| | | /** |
| | | * æµè¯é群å®ä¾éæµ |
| | | * å¯å¨ä¸¤ä¸ªå端æå¡äºä¸å½±å |
| | | */ |
| | | @ApiOperation("æµè¯é群å®ä¾éæµ") |
| | | @RateLimiter(count = 2, time = 10, limitType = LimitType.CLUSTER) |
| | | @GetMapping("/testcluster") |
| | | public AjaxResult<String> testcluster(String value) { |
| | | return AjaxResult.success("æä½æå", value); |
| | | } |
| | | |
| | | } |
| | |
| | | @RequestMapping("/swagger/demo") |
| | | public class Swagger3DemoController { |
| | | |
| | | /** |
| | | * ä¸ä¼ è¯·æ± |
| | | * å¿
é¡»ä½¿ç¨ @RequestPart æ³¨è§£æ æ³¨ä¸ºæä»¶ |
| | | * dataType å¿
须为 "java.io.File" |
| | | */ |
| | | @ApiOperation(value = "éç¨ä¸ä¼ 请æ±") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "file", value = "æä»¶", dataType = "java.io.File", required = true), |
| | | }) |
| | | @PostMapping(value = "/upload") |
| | | public AjaxResult<String> upload(@RequestPart("file") MultipartFile file) { |
| | | return AjaxResult.success("æä½æå", file.getOriginalFilename()); |
| | | } |
| | | /** |
| | | * ä¸ä¼ è¯·æ± |
| | | * å¿
é¡»ä½¿ç¨ @RequestPart æ³¨è§£æ æ³¨ä¸ºæä»¶ |
| | | * dataType å¿
须为 "java.io.File" |
| | | */ |
| | | @ApiOperation(value = "éç¨ä¸ä¼ 请æ±") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "file", value = "æä»¶", dataType = "java.io.File", required = true), |
| | | }) |
| | | @PostMapping(value = "/upload") |
| | | public AjaxResult<String> upload(@RequestPart("file") MultipartFile file) { |
| | | return AjaxResult.success("æä½æå", file.getOriginalFilename()); |
| | | } |
| | | |
| | | } |
| | |
| | | /** |
| | | * æ°å¢æ¹éæ¹æ³ å¯å®ç¾æ¿ä»£ saveBatch ç§çº§æå
¥ä¸ä¸æ°æ® (对mysqlè´è·è¾å¤§) |
| | | */ |
| | | @ApiOperation(value = "æ°å¢æ¹éæ¹æ³") |
| | | @ApiOperation(value = "æ°å¢æ¹éæ¹æ³") |
| | | @PostMapping("/add") |
| | | // @DataSource(DataSourceType.SLAVE) |
| | | public AjaxResult<Void> add() { |
| | | List<TestDemo> list = new ArrayList<>(); |
| | | for (int i = 0; i < 1000; i++) { |
| | | list.add(new TestDemo().setOrderNum(-1L).setTestKey("æ¹éæ°å¢").setValue("æµè¯æ°å¢")); |
| | | } |
| | | List<TestDemo> list = new ArrayList<>(); |
| | | for (int i = 0; i < 1000; i++) { |
| | | list.add(new TestDemo().setOrderNum(-1L).setTestKey("æ¹éæ°å¢").setValue("æµè¯æ°å¢")); |
| | | } |
| | | return toAjax(iTestDemoService.saveAll(list) ? 1 : 0); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢ææ´æ° å¯å®ç¾æ¿ä»£ saveOrUpdateBatch 髿§è½ |
| | | */ |
| | | @ApiOperation(value = "æ°å¢ææ´æ°æ¹éæ¹æ³") |
| | | @PostMapping("/addOrUpdate") |
| | | /** |
| | | * æ°å¢ææ´æ° å¯å®ç¾æ¿ä»£ saveOrUpdateBatch 髿§è½ |
| | | */ |
| | | @ApiOperation(value = "æ°å¢ææ´æ°æ¹éæ¹æ³") |
| | | @PostMapping("/addOrUpdate") |
| | | // @DataSource(DataSourceType.SLAVE) |
| | | public AjaxResult<Void> addOrUpdate() { |
| | | List<TestDemo> list = new ArrayList<>(); |
| | | for (int i = 0; i < 1000; i++) { |
| | | list.add(new TestDemo().setOrderNum(-1L).setTestKey("æ¹éæ°å¢").setValue("æµè¯æ°å¢")); |
| | | } |
| | | iTestDemoService.saveAll(list); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | TestDemo testDemo = list.get(i); |
| | | testDemo.setTestKey("æ¹éæ°å¢æä¿®æ¹").setValue("æ¹éæ°å¢æä¿®æ¹"); |
| | | if (i % 2 == 0) { |
| | | testDemo.setId(null); |
| | | } |
| | | } |
| | | return toAjax(iTestDemoService.saveOrUpdateAll(list) ? 1 : 0); |
| | | } |
| | | public AjaxResult<Void> addOrUpdate() { |
| | | List<TestDemo> list = new ArrayList<>(); |
| | | for (int i = 0; i < 1000; i++) { |
| | | list.add(new TestDemo().setOrderNum(-1L).setTestKey("æ¹éæ°å¢").setValue("æµè¯æ°å¢")); |
| | | } |
| | | iTestDemoService.saveAll(list); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | TestDemo testDemo = list.get(i); |
| | | testDemo.setTestKey("æ¹éæ°å¢æä¿®æ¹").setValue("æ¹éæ°å¢æä¿®æ¹"); |
| | | if (i % 2 == 0) { |
| | | testDemo.setId(null); |
| | | } |
| | | } |
| | | return toAjax(iTestDemoService.saveOrUpdateAll(list) ? 1 : 0); |
| | | } |
| | | |
| | | /** |
| | | * å 餿¹éæ¹æ³ |
| | | */ |
| | | @ApiOperation(value = "å 餿¹éæ¹æ³") |
| | | @ApiOperation(value = "å 餿¹éæ¹æ³") |
| | | @DeleteMapping() |
| | | // @DataSource(DataSourceType.SLAVE) |
| | | public AjaxResult<Void> remove() { |
| | | return toAjax(iTestDemoService.remove(new LambdaQueryWrapper<TestDemo>() |
| | | .eq(TestDemo::getOrderNum, -1L)) ? 1 : 0); |
| | | .eq(TestDemo::getOrderNum, -1L)) ? 1 : 0); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.demo.controller; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | |
| | | import com.ruoyi.common.core.validate.EditGroup; |
| | | import com.ruoyi.common.core.validate.QueryGroup; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.ValidatorUtils; |
| | | import com.ruoyi.common.excel.ExcelResult; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.demo.domain.TestDemo; |
| | | import com.ruoyi.demo.domain.bo.TestDemoBo; |
| | | import com.ruoyi.demo.domain.bo.TestDemoImportVo; |
| | | import com.ruoyi.demo.domain.vo.TestDemoVo; |
| | | import com.ruoyi.demo.service.ITestDemoService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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; |
| | |
| | | return iTestDemoService.customPageList(bo); |
| | | } |
| | | |
| | | /** |
| | | @ApiOperation("导å
¥æµè¯-æ ¡éª") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "file", value = "导å
¥æä»¶", dataType = "java.io.File", required = true), |
| | | }) |
| | | @Log(title = "æµè¯å表", businessType = BusinessType.IMPORT) |
| | | @PreAuthorize("@ss.hasPermi('demo:demo:import')") |
| | | @PostMapping("/importData") |
| | | public AjaxResult<Void> importData(@RequestPart("file") MultipartFile file) throws Exception { |
| | | ExcelResult<TestDemoImportVo> excelResult = ExcelUtil.importExcel(file.getInputStream(), TestDemoImportVo.class, true); |
| | | List<TestDemoImportVo> volist = excelResult.getList(); |
| | | List<TestDemo> list = BeanUtil.copyToList(volist, TestDemo.class); |
| | | iTestDemoService.saveAll(list); |
| | | return AjaxResult.success(excelResult.getAnalysis()); |
| | | } |
| | | |
| | | /** |
| | | * å¯¼åºæµè¯å表å表 |
| | | */ |
| | | @ApiOperation("å¯¼åºæµè¯å表å表") |
| | | @SaCheckPermission("demo:demo:export") |
| | | @Log(title = "æµè¯å表", businessType = BusinessType.EXPORT) |
| | | @GetMapping("/export") |
| | | @PostMapping("/export") |
| | | public void export(@Validated TestDemoBo bo, HttpServletResponse response) { |
| | | List<TestDemoVo> list = iTestDemoService.queryList(bo); |
| | | // æµè¯éªè±idå¯¼åº |
| | | // æµè¯éªè±idå¯¼åº |
| | | // for (TestDemoVo vo : list) { |
| | | // vo.setId(1234567891234567893L); |
| | | // } |
| | | ExcelUtil.exportExcel(list, "æµè¯å表", TestDemoVo.class, response); |
| | | ExcelUtil.exportExcel(list, "æµè¯å表", TestDemoVo.class, response); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("è·åæµè¯å表详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("demo:demo:query") |
| | | @GetMapping("/{id}") |
| | | public AjaxResult<TestDemoVo> getInfo(@NotNull(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable("id") Long id) { |
| | | public AjaxResult<TestDemoVo> getInfo(@ApiParam("æµè¯ID") |
| | | @NotNull(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable("id") Long id) { |
| | | return AjaxResult.success(iTestDemoService.queryById(id)); |
| | | } |
| | | |
| | |
| | | @Log(title = "æµè¯å表", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS, message = "ä¸å
许éå¤æäº¤") |
| | | @PostMapping() |
| | | public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody TestDemoBo bo) { |
| | | public AjaxResult<Void> add(@RequestBody TestDemoBo bo) { |
| | | // ä½¿ç¨æ ¡éªå·¥å
·å¯¹æ @Validated(AddGroup.class) 注解 |
| | | // ç¨äºå¨é Controller çå°æ¹æ ¡éªå¯¹è±¡ |
| | | ValidatorUtils.validate(bo, AddGroup.class); |
| | | return toAjax(iTestDemoService.insertByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("demo:demo:remove") |
| | | @Log(title = "æµè¯å表" , businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult<Void> remove(@NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable Long[] ids) { |
| | | public AjaxResult<Void> remove(@ApiParam("æµè¯ID串") |
| | | @NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable Long[] ids) { |
| | | return toAjax(iTestDemoService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.utils.MessageUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.Data; |
| | | import org.hibernate.validator.constraints.Range; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | |
| | | /** |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Api(value = "æµè¯å½é
åæ§å¶å¨", tags = {"æµè¯å½é
å管ç"}) |
| | | @RestController |
| | | @RequestMapping("/demo/i18n") |
| | |
| | | */ |
| | | @ApiOperation("éè¿codeè·åå½é
åå
容") |
| | | @GetMapping() |
| | | public AjaxResult<Void> get(String code) { |
| | | public AjaxResult<Void> get(@ApiParam("å½é
åcode") String code) { |
| | | return AjaxResult.success(MessageUtils.message(code)); |
| | | } |
| | | |
| | | /** |
| | | * Validator æ ¡éªå½é
å |
| | | * ä¸ä¼ å¼ å嫿¥çå¼å¸¸è¿å |
| | | * |
| | | * æµè¯ä½¿ç¨ not.null |
| | | */ |
| | | @ApiOperation("Validator æ ¡éªå½é
å") |
| | | @GetMapping("/test1") |
| | | public AjaxResult<Void> test1(@NotBlank(message = "{not.null}") String str) { |
| | | return AjaxResult.success(str); |
| | | } |
| | | |
| | | /** |
| | | * Bean æ ¡éªå½é
å |
| | | * ä¸ä¼ å¼ å嫿¥çå¼å¸¸è¿å |
| | | * |
| | | * æµè¯ä½¿ç¨ not.null |
| | | */ |
| | | @ApiOperation("Bean æ ¡éªå½é
å") |
| | | @GetMapping("/test2") |
| | | public AjaxResult<TestI18nBo> test2(@Validated TestI18nBo bo) { |
| | | return AjaxResult.success(bo); |
| | | } |
| | | |
| | | @Data |
| | | public static class TestI18nBo { |
| | | |
| | | @NotBlank(message = "{not.null}") |
| | | private String name; |
| | | |
| | | @NotNull(message = "{not.null}") |
| | | @Range(min = 0, max = 100, message = "{length.not.valid}") |
| | | private Integer age; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.demo.service.ITestTreeService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | @GetMapping("/export") |
| | | public void export(@Validated TestTreeBo bo, HttpServletResponse response) { |
| | | List<TestTreeVo> list = iTestTreeService.queryList(bo); |
| | | ExcelUtil.exportExcel(list, "æµè¯æ 表", TestTreeVo.class, response); |
| | | ExcelUtil.exportExcel(list, "æµè¯æ 表", TestTreeVo.class, response); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("è·åæµè¯æ 表详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("demo:tree:query") |
| | | @GetMapping("/{id}") |
| | | public AjaxResult<TestTreeVo> getInfo(@NotNull(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable("id") Long id) { |
| | | public AjaxResult<TestTreeVo> getInfo(@ApiParam("æµè¯æ ID") |
| | | @NotNull(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable("id") Long id) { |
| | | return AjaxResult.success(iTestTreeService.queryById(id)); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("demo:tree:remove") |
| | | @Log(title = "æµè¯æ 表" , businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult<Void> remove(@NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable Long[] ids) { |
| | | public AjaxResult<Void> remove(@ApiParam("æµè¯æ ID串") |
| | | @NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable Long[] ids) { |
| | | return toAjax(iTestTreeService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.demo.domain.bo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * æµè¯å表ä¸å¡å¯¹è±¡ test_demo |
| | | * |
| | | * @author Lion Li |
| | | * @date 2021-07-26 |
| | | */ |
| | | @Data |
| | | @ApiModel("æµè¯å表ä¸å¡å¯¹è±¡") |
| | | public class TestDemoImportVo { |
| | | |
| | | /** |
| | | * é¨é¨id |
| | | */ |
| | | @ApiModelProperty("é¨é¨id") |
| | | @NotNull(message = "é¨é¨idä¸è½ä¸ºç©º") |
| | | @ExcelProperty(value = "é¨é¨id") |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * ç¨æ·id |
| | | */ |
| | | @ApiModelProperty("ç¨æ·id") |
| | | @NotNull(message = "ç¨æ·idä¸è½ä¸ºç©º") |
| | | @ExcelProperty(value = "ç¨æ·id") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * æåºå· |
| | | */ |
| | | @ApiModelProperty("æåºå·") |
| | | @NotNull(message = "æåºå·ä¸è½ä¸ºç©º") |
| | | @ExcelProperty(value = "æåºå·") |
| | | private Long orderNum; |
| | | |
| | | /** |
| | | * keyé® |
| | | */ |
| | | @ApiModelProperty("keyé®") |
| | | @NotBlank(message = "keyé®ä¸è½ä¸ºç©º") |
| | | @ExcelProperty(value = "keyé®") |
| | | private String testKey; |
| | | |
| | | /** |
| | | * å¼ |
| | | */ |
| | | @ApiModelProperty("å¼") |
| | | @NotBlank(message = "å¼ä¸è½ä¸ºç©º") |
| | | @ExcelProperty(value = "å¼") |
| | | private String value; |
| | | |
| | | } |
| | |
| | | |
| | | 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; |
| | | |
| | | /** |
| | |
| | | * @author Lion Li |
| | | * @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); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | javaå
ä½¿ç¨ `.` åå² resource ç®å½ä½¿ç¨ `/` åå² |
| | | <br> |
| | | æ¤æä»¶ç®ç 鲿¢æä»¶å¤¹ç²è¿æ¾ä¸å° `xml` æä»¶ |
| | |
| | | <groupId>de.codecentric</groupId> |
| | | <artifactId>spring-boot-admin-starter-server</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>de.codecentric</groupId> |
| | | <artifactId>spring-boot-admin-starter-client</artifactId> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | //æäºå¯¹ææéæèµäº§åç»å½é¡µé¢çå
Œ
±è®¿é®æéã |
| | | .antMatchers(adminContextPath + "/assets/**").permitAll() |
| | | .antMatchers(adminContextPath + "/login").permitAll() |
| | | .antMatchers("/actuator").anonymous() |
| | | .antMatchers("/actuator/**").anonymous() |
| | | //å¿
须对æ¯ä¸ªå
¶ä»è¯·æ±è¿è¡èº«ä»½éªè¯ |
| | | .anyRequest().authenticated().and() |
| | | //é
ç½®ç»å½å注é |
¶Ô±ÈÐÂÎļþ |
| | |
| | | --- # çæ§é
ç½® |
| | | spring: |
| | | boot: |
| | | admin: |
| | | # Spring Boot Admin Client 客æ·ç«¯çç¸å
³é
ç½® |
| | | client: |
| | | # å¢å 客æ·ç«¯å¼å
³ |
| | | enabled: true |
| | | # 设置 Spring Boot Admin Server å°å |
| | | url: http://localhost:9090/admin |
| | | instance: |
| | | prefer-ip: true # 注åå®ä¾æ¶ï¼ä¼å
ä½¿ç¨ IP |
| | | username: ruoyi |
| | | password: 123456 |
¶Ô±ÈÐÂÎļþ |
| | |
| | | --- # çæ§é
ç½® |
| | | spring: |
| | | boot: |
| | | admin: |
| | | # Spring Boot Admin Client 客æ·ç«¯çç¸å
³é
ç½® |
| | | client: |
| | | # å¢å 客æ·ç«¯å¼å
³ |
| | | enabled: true |
| | | # 设置 Spring Boot Admin Server å°å |
| | | url: http://172.30.0.90:9090/admin |
| | | instance: |
| | | prefer-ip: true # 注åå®ä¾æ¶ï¼ä¼å
ä½¿ç¨ IP |
| | | username: ruoyi |
| | | password: 123456 |
| | |
| | | server: |
| | | port: 9090 |
| | | spring: |
| | | application: |
| | | name: ruoyi-monitor-admin |
| | | profiles: |
| | | active: @profiles.active@ |
| | | |
| | | --- # çæ§ä¸å¿æå¡ç«¯é
ç½® |
| | | spring: |
| | | security: |
| | | user: |
| | |
| | | boot: |
| | | admin: |
| | | context-path: /admin |
| | | |
| | | --- # Actuator çæ§ç«¯ç¹çé
置项 |
| | | management: |
| | | endpoints: |
| | | web: |
| | | # Actuator æä¾ç API æ¥å£çæ ¹ç®å½ãé»è®¤ä¸º /actuator |
| | | base-path: /actuator |
| | | exposure: |
| | | # éè¦å¼æ¾ç端ç¹ãé»è®¤å¼åªæå¼ health å info 两个端ç¹ãéè¿è®¾ç½® * ï¼å¯ä»¥å¼æ¾ææç«¯ç¹ã |
| | | # ç产ç¯å¢ä¸å»ºè®®æ¾å¼ææ æ ¹æ®é¡¹ç®éæ±æ¾å¼å³å¯ |
| | | include: @endpoints.include@ |
| | | endpoint: |
| | | logfile: |
| | | external-file: ./logs/ruoyi-monitor-admin.log |
| | |
| | | <version>${mysql-connector-java.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>de.codecentric</groupId> |
| | | <artifactId>spring-boot-admin-starter-client</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- xxl-job-core --> |
| | | <dependency> |
| | | <groupId>com.xuxueli</groupId> |
| | |
| | | --- # çæ§é
ç½® |
| | | spring: |
| | | boot: |
| | | admin: |
| | | # Spring Boot Admin Client 客æ·ç«¯çç¸å
³é
ç½® |
| | | client: |
| | | # å¢å 客æ·ç«¯å¼å
³ |
| | | enabled: true |
| | | # 设置 Spring Boot Admin Server å°å |
| | | url: http://localhost:9090/admin |
| | | instance: |
| | | prefer-ip: true # 注åå®ä¾æ¶ï¼ä¼å
ä½¿ç¨ IP |
| | | username: ruoyi |
| | | password: 123456 |
| | | |
| | | --- # æ°æ®åºé
ç½® |
| | | spring: |
| | | datasource: |
| | |
| | | --- # çæ§é
ç½® |
| | | spring: |
| | | boot: |
| | | admin: |
| | | # Spring Boot Admin Client 客æ·ç«¯çç¸å
³é
ç½® |
| | | client: |
| | | # å¢å 客æ·ç«¯å¼å
³ |
| | | enabled: true |
| | | # 设置 Spring Boot Admin Server å°å |
| | | url: http://172.30.0.90:9090/admin |
| | | instance: |
| | | prefer-ip: true # 注åå®ä¾æ¶ï¼ä¼å
ä½¿ç¨ IP |
| | | username: ruoyi |
| | | password: 123456 |
| | | |
| | | --- # æ°æ®åºé
ç½® |
| | | spring: |
| | | datasource: |
| | |
| | | servlet: |
| | | context-path: /xxl-job-admin |
| | | spring: |
| | | application: |
| | | name: ruoyi-xxl-job-admin |
| | | profiles: |
| | | active: @profiles.active@ |
| | | mvc: |
| | |
| | | suffix: .ftl |
| | | templateLoaderPath: classpath:/templates/ |
| | | |
| | | --- # çæ§é
ç½® |
| | | --- # Actuator çæ§ç«¯ç¹çé
置项 |
| | | management: |
| | | health: |
| | | mail: |
| | | enabled: false |
| | | server: |
| | | base-path: /actuator |
| | | endpoints: |
| | | web: |
| | | # Actuator æä¾ç API æ¥å£çæ ¹ç®å½ãé»è®¤ä¸º /actuator |
| | | base-path: /actuator |
| | | exposure: |
| | | # éè¦å¼æ¾ç端ç¹ãé»è®¤å¼åªæå¼ health å info 两个端ç¹ãéè¿è®¾ç½® * ï¼å¯ä»¥å¼æ¾ææç«¯ç¹ã |
| | | # ç产ç¯å¢ä¸å»ºè®®æ¾å¼ææ æ ¹æ®é¡¹ç®éæ±æ¾å¼å³å¯ |
| | | include: @endpoints.include@ |
| | | endpoint: |
| | | logfile: |
| | | external-file: ./logs/ruoyi-xxl-job-admin.log |
| | | |
| | | --- # xxljobç³»ç»é
ç½® |
| | | xxl: |
| | |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.reflect.ReflectUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.annotation.Before; |
| | |
| | | package com.ruoyi.framework.aspectj; |
| | | |
| | | import cn.dev33.satoken.SaManager; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import com.baomidou.lock.LockInfo; |
| | | import com.baomidou.lock.LockTemplate; |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.RedisUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.config.properties.RepeatSubmitProperties; |
| | |
| | | import org.aspectj.lang.annotation.Before; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.Collection; |
| | | import java.util.Map; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * 鲿¢éå¤æäº¤ |
| | |
| | | public class RepeatSubmitAspect { |
| | | |
| | | private final RepeatSubmitProperties repeatSubmitProperties; |
| | | private final LockTemplate lockTemplate; |
| | | |
| | | @Before("@annotation(repeatSubmit)") |
| | | public void doBefore(JoinPoint point, RepeatSubmit repeatSubmit) throws Throwable { |
| | |
| | | throw new ServiceException("éå¤æäº¤é´éæ¶é´ä¸è½å°äº'1'ç§"); |
| | | } |
| | | HttpServletRequest request = ServletUtils.getRequest(); |
| | | String nowParams = StrUtil.join(",", point.getArgs()); |
| | | String nowParams = argsArrayToString(point.getArgs()); |
| | | |
| | | // 请æ±å°åï¼ä½ä¸ºåæ¾cacheçkeyå¼ï¼ |
| | | String url = request.getRequestURI(); |
| | |
| | | submitKey = SecureUtil.md5(submitKey + ":" + nowParams); |
| | | // å¯ä¸æ è¯ï¼æå®key + æ¶æ¯å¤´ï¼ |
| | | String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + submitKey; |
| | | LockInfo lock = lockTemplate.lock(cacheRepeatKey, interval, interval / 2); |
| | | if (lock == null) { |
| | | String key = RedisUtils.getCacheObject(cacheRepeatKey); |
| | | if (key == null) { |
| | | RedisUtils.setCacheObject(cacheRepeatKey, "", interval, TimeUnit.MILLISECONDS); |
| | | } else { |
| | | throw new ServiceException(repeatSubmit.message()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * åæ°æ¼è£
|
| | | */ |
| | | private String argsArrayToString(Object[] paramsArray) { |
| | | StringBuilder params = new StringBuilder(); |
| | | if (paramsArray != null && paramsArray.length > 0) { |
| | | for (Object o : paramsArray) { |
| | | if (StringUtils.isNotNull(o) && !isFilterObject(o)) { |
| | | try { |
| | | params.append(JsonUtils.toJsonString(o)).append(" "); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return params.toString().trim(); |
| | | } |
| | | |
| | | /** |
| | | * 夿æ¯å¦éè¦è¿æ»¤ç对象ã |
| | | * |
| | | * @param o 对象信æ¯ã |
| | | * @return 妿æ¯éè¦è¿æ»¤ç对象ï¼åè¿åtrueï¼å¦åè¿åfalseã |
| | | */ |
| | | @SuppressWarnings("rawtypes") |
| | | public boolean isFilterObject(final Object o) { |
| | | Class<?> clazz = o.getClass(); |
| | | if (clazz.isArray()) { |
| | | return clazz.getComponentType().isAssignableFrom(MultipartFile.class); |
| | | } else if (Collection.class.isAssignableFrom(clazz)) { |
| | | Collection collection = (Collection) o; |
| | | for (Object value : collection) { |
| | | return value instanceof MultipartFile; |
| | | } |
| | | } else if (Map.class.isAssignableFrom(clazz)) { |
| | | Map map = (Map) o; |
| | | for (Object value : map.entrySet()) { |
| | | Map.Entry entry = (Map.Entry) value; |
| | | return entry.getValue() instanceof MultipartFile; |
| | | } |
| | | } |
| | | return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse |
| | | || o instanceof BindingResult; |
| | | } |
| | | |
| | | } |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Configuration |
| | | @ConditionalOnProperty(value = "xss.enabled", havingValue = "true") |
| | | public class FilterConfig { |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @SuppressWarnings({"rawtypes", "unchecked"}) |
| | | @Bean |
| | | @ConditionalOnProperty(value = "xss.enabled", havingValue = "true") |
| | | public FilterRegistrationBean xssFilterRegistration() { |
| | | FilterRegistrationBean registration = new FilterRegistrationBean(); |
| | | registration.setDispatcherTypes(DispatcherType.REQUEST); |
| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.servlet.LocaleResolver; |
| | |
| | | */ |
| | | static class I18nLocaleResolver implements LocaleResolver { |
| | | |
| | | @NotNull |
| | | @Override |
| | | public Locale resolveLocale(HttpServletRequest httpServletRequest) { |
| | | String language = httpServletRequest.getHeader("content-language"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void setLocale(@NotNull HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) { |
| | | public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) { |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | import cn.dev33.satoken.config.SaTokenConfig; |
| | | import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; |
| | | import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.framework.config.properties.SwaggerProperties; |
| | |
| | | @Autowired |
| | | private SaTokenConfig saTokenConfig; |
| | | |
| | | @Autowired |
| | | private OpenApiExtensionResolver openApiExtensionResolver; |
| | | |
| | | /** |
| | | * å建API |
| | | */ |
| | |
| | | // 设置å®å
¨æ¨¡å¼ï¼swaggerå¯ä»¥è®¾ç½®è®¿é®token |
| | | .securitySchemes(securitySchemes()) |
| | | .securityContexts(securityContexts()) |
| | | .extensions(openApiExtensionResolver.buildExtensions(group.getName())) |
| | | .pathMapping(swaggerProperties.getPathMapping()); |
| | | String beanName = StringUtils.substringAfterLast(basePackage, ".") + "Docket"; |
| | | SpringUtils.registerBean(beanName, docket); |
| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import com.yomahub.tlog.core.aop.AspectLogAop; |
| | | import com.yomahub.tlog.feign.filter.TLogFeignFilter; |
| | | import com.yomahub.tlog.spring.TLogPropertyInit; |
| | | import com.yomahub.tlog.spring.TLogSpringAware; |
| | | import com.yomahub.tlog.springboot.property.TLogProperty; |
| | |
| | | @Bean |
| | | public AspectLogAop aspectLogAop() { |
| | | return new AspectLogAop(); |
| | | } |
| | | |
| | | @Bean |
| | | public TLogFeignFilter tLogFeignFilter() { |
| | | return new TLogFeignFilter(); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import org.hibernate.validator.HibernateValidator; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.MessageSource; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; |
| | | |
| | | import javax.validation.Validation; |
| | | import javax.validation.Validator; |
| | | import javax.validation.ValidatorFactory; |
| | | import java.util.Properties; |
| | | |
| | | /** |
| | | * æ ¡éªæ¡æ¶é
置类 |
| | |
| | | @Configuration |
| | | public class ValidatorConfig { |
| | | |
| | | @Autowired |
| | | private MessageSource messageSource; |
| | | |
| | | /** |
| | | * é
ç½®æ ¡éªæ¡æ¶ å¿«éè¿åæ¨¡å¼ |
| | | */ |
| | | @Bean |
| | | public Validator validator() { |
| | | ValidatorFactory validatorFactory = Validation.byProvider(HibernateValidator.class) |
| | | .configure() |
| | | .failFast(true) |
| | | .buildValidatorFactory(); |
| | | return validatorFactory.getValidator(); |
| | | LocalValidatorFactoryBean factoryBean = new LocalValidatorFactoryBean(); |
| | | // å½é
å |
| | | factoryBean.setValidationMessageSource(messageSource); |
| | | // è®¾ç½®ä½¿ç¨ HibernateValidator æ ¡éªå¨ |
| | | factoryBean.setProviderClass(HibernateValidator.class); |
| | | Properties properties = new Properties(); |
| | | // 设置 å¿«éå¼å¸¸è¿å |
| | | properties.setProperty("hibernate.validator.fail_fast", "true"); |
| | | factoryBean.setValidationProperties(properties); |
| | | // å è½½é
ç½® |
| | | factoryBean.afterPropertiesSet(); |
| | | return factoryBean.getValidator(); |
| | | } |
| | | |
| | | } |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j(topic = "sys-user") |
| | | @Slf4j |
| | | @Component |
| | | public class ShutdownManager { |
| | | |
| | |
| | | import org.springframework.web.bind.annotation.RestControllerAdvice; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.validation.ConstraintViolation; |
| | | import javax.validation.ConstraintViolationException; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * å
¨å±å¼å¸¸å¤çå¨ |
| | |
| | | @ExceptionHandler(BindException.class) |
| | | public AjaxResult<Void> handleBindException(BindException e) { |
| | | log.error(e.getMessage(), e); |
| | | String message = e.getAllErrors().get(0).getDefaultMessage(); |
| | | String message = e.getAllErrors().stream() |
| | | .map(DefaultMessageSourceResolvable::getDefaultMessage) |
| | | .collect(Collectors.joining(", ")); |
| | | return AjaxResult.error(message); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler(ConstraintViolationException.class) |
| | | public AjaxResult<Void> constraintViolationException(ConstraintViolationException e) { |
| | | log.error(e.getMessage(), e); |
| | | String message = e.getConstraintViolations().iterator().next().getMessage(); |
| | | String message = e.getConstraintViolations().stream() |
| | | .map(ConstraintViolation::getMessage) |
| | | .collect(Collectors.joining(", ")); |
| | | return AjaxResult.error(message); |
| | | } |
| | | |
| | |
| | | <!--velocity代ç çæä½¿ç¨æ¨¡æ¿ --> |
| | | <dependency> |
| | | <groupId>org.apache.velocity</groupId> |
| | | <artifactId>velocity</artifactId> |
| | | <artifactId>velocity-engine-core</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- éç¨å·¥å
·--> |
| | |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.io.IoUtil; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\""); |
| | | response.addHeader("Content-Length", "" + data.length); |
| | | response.setContentType("application/octet-stream; charset=UTF-8"); |
| | | IOUtils.write(data, response.getOutputStream()); |
| | | IoUtil.write(response.getOutputStream(), false, data); |
| | | } |
| | | } |
| | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.io.IoUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.GenConstants; |
| | |
| | | import com.ruoyi.generator.util.VelocityInitializer; |
| | | import com.ruoyi.generator.util.VelocityUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.poi.util.IOUtils; |
| | | import org.apache.velocity.Template; |
| | | import org.apache.velocity.VelocityContext; |
| | | import org.apache.velocity.app.Velocity; |
| | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.StringWriter; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.zip.ZipEntry; |
| | |
| | | try { |
| | | // æ·»å å°zip |
| | | zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table))); |
| | | IOUtils.write(sw.toString(), zip, Constants.UTF8); |
| | | IOUtils.closeQuietly(sw); |
| | | IoUtil.write(zip, StandardCharsets.UTF_8, false, sw.toString()); |
| | | IoUtil.close(sw); |
| | | zip.flush(); |
| | | zip.closeEntry(); |
| | | } catch (IOException e) { |
| | |
| | | Properties p = new Properties(); |
| | | try { |
| | | // å è½½classpathç®å½ä¸çvmæä»¶ |
| | | p.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); |
| | | p.setProperty("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); |
| | | // å®ä¹å符é |
| | | p.setProperty(Velocity.INPUT_ENCODING, Constants.UTF8); |
| | | p.setProperty(Velocity.OUTPUT_ENCODING, Constants.UTF8); |
| | | // åå§åVelocityå¼æï¼æå®é
ç½®Properties |
| | | Velocity.init(p); |
| | | } catch (Exception e) { |
| | |
| | | List<String> dicts = new ArrayList<String>(); |
| | | for (GenTableColumn column : columns) { |
| | | if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny( |
| | | column.getHtmlType(), new String[]{GenConstants.HTML_SELECT, GenConstants.HTML_RADIO})) { |
| | | column.getHtmlType(), |
| | | new String[] { GenConstants.HTML_SELECT, GenConstants.HTML_RADIO, GenConstants.HTML_CHECKBOX })) { |
| | | dicts.add("'" + column.getDictType() + "'"); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | javaå
ä½¿ç¨ `.` åå² resource ç®å½ä½¿ç¨ `/` åå² |
| | | <br> |
| | | æ¤æä»¶ç®ç 鲿¢æä»¶å¤¹ç²è¿æ¾ä¸å° `xml` æä»¶ |
| | |
| | | #elseif($table.tree) |
| | | #end |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiParam; |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | | /** |
| | |
| | | @ApiOperation("è·å${functionName}详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("${permissionPrefix}:query") |
| | | @GetMapping("/{${pkColumn.javaField}}") |
| | | public AjaxResult<${ClassName}Vo> getInfo(@NotNull(message = "主é®ä¸è½ä¸ºç©º") |
| | | public AjaxResult<${ClassName}Vo> getInfo(@ApiParam("主é®") |
| | | @NotNull(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) { |
| | | return AjaxResult.success(i${ClassName}Service.queryById(${pkColumn.javaField})); |
| | | } |
| | |
| | | @SaCheckPermission("${permissionPrefix}:remove") |
| | | @Log(title = "${functionName}" , businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{${pkColumn.javaField}s}") |
| | | public AjaxResult<Void> remove(@NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | public AjaxResult<Void> remove(@ApiParam("主é®ä¸²") |
| | | @NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) { |
| | | return toAjax(i${ClassName}Service.deleteWithValidByIds(Arrays.asList(${pkColumn.javaField}s), true) ? 1 : 0); |
| | | } |
| | |
| | | #elseif($column.list && $column.dictType && "" != $column.dictType) |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}"> |
| | | <template slot-scope="scope"> |
| | | #if($column.htmlType == "checkbox") |
| | | <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/> |
| | | #else |
| | | <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField}"/> |
| | | #end |
| | | </template> |
| | | </el-table-column> |
| | | #elseif($column.list && "" != $javaField) |
| | |
| | | queryParams: { |
| | | #foreach ($column in $columns) |
| | | #if($column.query) |
| | | $column.javaField: null#if($velocityCount != $columns.size()),#end |
| | | |
| | | $column.javaField: null#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | }, |
| | |
| | | #end |
| | | $column.javaField: [ |
| | | { required: true, message: "$commentä¸è½ä¸ºç©º", trigger: #if($column.htmlType == "select")"change"#else"blur"#end } |
| | | ]#if($velocityCount != $columns.size()),#end |
| | | |
| | | ]#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | } |
| | |
| | | this.form = { |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "radio") |
| | | $column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($velocityCount != $columns.size()),#end |
| | | $column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end |
| | | |
| | | #elseif($column.htmlType == "checkbox") |
| | | $column.javaField: []#if($velocityCount != $columns.size()),#end |
| | | |
| | | $column.javaField: []#if($foreach.count != $columns.size()),#end |
| | | #else |
| | | $column.javaField: null#if($velocityCount != $columns.size()),#end |
| | | |
| | | $column.javaField: null#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | }; |
| | |
| | | plain |
| | | icon="el-icon-download" |
| | | size="mini" |
| | | :loading="exportLoading" |
| | | @click="handleExport" |
| | | v-hasPermi="['${moduleName}:${businessName}:export']" |
| | | >导åº</el-button> |
| | |
| | | #elseif($column.list && $column.dictType && "" != $column.dictType) |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}"> |
| | | <template slot-scope="scope"> |
| | | #if($column.htmlType == "checkbox") |
| | | <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/> |
| | | #else |
| | | <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField}"/> |
| | | #end |
| | | </template> |
| | | </el-table-column> |
| | | #elseif($column.list && "" != $javaField) |
| | |
| | | buttonLoading: false, |
| | | // é®ç½©å± |
| | | loading: true, |
| | | // 导åºé®ç½©å± |
| | | exportLoading: false, |
| | | // é䏿°ç» |
| | | ids: [], |
| | | #if($table.sub) |
| | |
| | | pageSize: 10, |
| | | #foreach ($column in $columns) |
| | | #if($column.query) |
| | | $column.javaField: undefined#if($velocityCount != $columns.size()),#end |
| | | |
| | | $column.javaField: undefined#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | }, |
| | |
| | | #end |
| | | $column.javaField: [ |
| | | { required: true, message: "$commentä¸è½ä¸ºç©º", trigger: #if($column.htmlType == "select")"change"#else"blur"#end } |
| | | ]#if($velocityCount != $columns.size()),#end |
| | | |
| | | ]#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | } |
| | |
| | | this.form = { |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "radio") |
| | | $column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($velocityCount != $columns.size()),#end |
| | | |
| | | $column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end |
| | | #elseif($column.htmlType == "checkbox") |
| | | $column.javaField: []#if($velocityCount != $columns.size()),#end |
| | | |
| | | $column.javaField: []#if($foreach.count != $columns.size()),#end |
| | | #else |
| | | $column.javaField: undefined#if($velocityCount != $columns.size()),#end |
| | | |
| | | $column.javaField: undefined#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | }; |
| | |
| | | #end |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | this.#[[$download]]#.excel('/${moduleName}/${businessName}/export', this.queryParams); |
| | | this.download('${moduleName}/${businessName}/export', { |
| | | ...this.queryParams |
| | | }, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`) |
| | | } |
| | | } |
| | | }; |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/oss/constant/CloudConstant.java ÐÞ¸Ä |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public class CloudConstant { |
| | | public class OssConstant { |
| | | |
| | | /** |
| | | * OSS模åKEY |
| | |
| | | /** |
| | | * 对象åå¨é
ç½®KEY |
| | | */ |
| | | public static final String CLOUD_STORAGE_CONFIG_KEY = "CloudStorageConfig"; |
| | | public static final String OSS_CONFIG_KEY = "OssConfig"; |
| | | |
| | | /** |
| | | * ç¼åé
ç½®KEY |
| | | */ |
| | | public static final String CACHE_CONFIG_KEY = SYS_OSS_KEY + CLOUD_STORAGE_CONFIG_KEY; |
| | | public static final String CACHE_CONFIG_KEY = SYS_OSS_KEY + OSS_CONFIG_KEY; |
| | | |
| | | /** |
| | | * é¢è§åè¡¨èµæºå¼å
³Key |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.oss.enumd; |
| | | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.oss.service.impl.AliyunOssStrategy; |
| | | import com.ruoyi.oss.service.impl.MinioOssStrategy; |
| | | import com.ruoyi.oss.service.impl.QcloudOssStrategy; |
| | | import com.ruoyi.oss.service.impl.QiniuOssStrategy; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 对象å卿å¡åæä¸¾ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum OssEnumd { |
| | | |
| | | /** |
| | | * ä¸çäº |
| | | */ |
| | | QINIU("qiniu", QiniuOssStrategy.class), |
| | | |
| | | /** |
| | | * é¿éäº |
| | | */ |
| | | ALIYUN("aliyun", AliyunOssStrategy.class), |
| | | |
| | | /** |
| | | * è
¾è®¯äº |
| | | */ |
| | | QCLOUD("qcloud", QcloudOssStrategy.class), |
| | | |
| | | /** |
| | | * minio |
| | | */ |
| | | MINIO("minio", MinioOssStrategy.class); |
| | | |
| | | private final String value; |
| | | |
| | | private final Class<?> serviceClass; |
| | | |
| | | public static Class<?> getServiceClass(String value) { |
| | | for (OssEnumd clazz : values()) { |
| | | if (clazz.getValue().equals(value)) { |
| | | return clazz.getServiceClass(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static String getServiceName(String value) { |
| | | for (OssEnumd clazz : values()) { |
| | | if (clazz.getValue().equals(value)) { |
| | | return StringUtils.uncapitalize(clazz.getServiceClass().getSimpleName()); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.ruoyi.oss.factory; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.reflect.ReflectUtils; |
| | | import com.ruoyi.oss.constant.CloudConstant; |
| | | import com.ruoyi.oss.enumd.CloudServiceEnumd; |
| | | import com.ruoyi.oss.constant.OssConstant; |
| | | import com.ruoyi.oss.enumd.OssEnumd; |
| | | import com.ruoyi.oss.exception.OssException; |
| | | import com.ruoyi.oss.properties.CloudStorageProperties; |
| | | import com.ruoyi.oss.service.ICloudStorageStrategy; |
| | | import com.ruoyi.oss.service.abstractd.AbstractCloudStorageStrategy; |
| | | import com.ruoyi.oss.properties.OssProperties; |
| | | import com.ruoyi.oss.service.IOssStrategy; |
| | | import com.ruoyi.oss.service.abstractd.AbstractOssStrategy; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.Map; |
| | |
| | | @Slf4j |
| | | public class OssFactory { |
| | | |
| | | static { |
| | | RedisUtils.subscribe(CloudConstant.CACHE_CONFIG_KEY, String.class, msg -> { |
| | | refreshService(msg); |
| | | log.info("订é
å·æ°OSSé
ç½® => " + msg); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * æå¡å®ä¾ç¼å |
| | | */ |
| | | private static final Map<String, ICloudStorageStrategy> SERVICES = new ConcurrentHashMap<>(); |
| | | private static final Map<String, IOssStrategy> SERVICES = new ConcurrentHashMap<>(); |
| | | |
| | | /** |
| | | * åå§åå·¥å |
| | | */ |
| | | public static void init() { |
| | | log.info("åå§åOSSå·¥å"); |
| | | RedisUtils.subscribe(OssConstant.CACHE_CONFIG_KEY, String.class, type -> { |
| | | // 没æçå®ä¾ä¸å¤ç |
| | | if (SERVICES.containsKey(type)) { |
| | | refreshService(type); |
| | | log.info("订é
å·æ°OSSé
ç½® => " + type); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * è·åé»è®¤å®ä¾ |
| | | */ |
| | | public static ICloudStorageStrategy instance() { |
| | | public static IOssStrategy instance() { |
| | | // è·åredis é»è®¤ç±»å |
| | | String type = Convert.toStr(RedisUtils.getCacheObject(CloudConstant.CACHE_CONFIG_KEY)); |
| | | String type = RedisUtils.getCacheObject(OssConstant.CACHE_CONFIG_KEY); |
| | | if (StringUtils.isEmpty(type)) { |
| | | throw new OssException("æä»¶å卿å¡ç±»åæ æ³æ¾å°!"); |
| | | } |
| | |
| | | /** |
| | | * æ ¹æ®ç±»åè·åå®ä¾ |
| | | */ |
| | | public static ICloudStorageStrategy instance(String type) { |
| | | ICloudStorageStrategy service = SERVICES.get(type); |
| | | public static IOssStrategy instance(String type) { |
| | | IOssStrategy service = SERVICES.get(type); |
| | | if (service == null) { |
| | | refreshService(type); |
| | | service = SERVICES.get(type); |
| | |
| | | } |
| | | |
| | | private static void refreshService(String type) { |
| | | Object json = RedisUtils.getCacheObject(CloudConstant.SYS_OSS_KEY + type); |
| | | CloudStorageProperties properties = JsonUtils.parseObject(json.toString(), CloudStorageProperties.class); |
| | | Object json = RedisUtils.getCacheObject(OssConstant.SYS_OSS_KEY + type); |
| | | OssProperties properties = JsonUtils.parseObject(json.toString(), OssProperties.class); |
| | | if (properties == null) { |
| | | throw new OssException("ç³»ç»å¼å¸¸, '" + type + "'é
置信æ¯ä¸åå¨!"); |
| | | } |
| | | // è·åredisé
ç½®ä¿¡æ¯ å建对象 å¹¶ç¼å |
| | | ICloudStorageStrategy service = (ICloudStorageStrategy) ReflectUtils.newInstance(CloudServiceEnumd.getServiceClass(type)); |
| | | ((AbstractCloudStorageStrategy)service).init(properties); |
| | | IOssStrategy service = (IOssStrategy) ReflectUtils.newInstance(OssEnumd.getServiceClass(type)); |
| | | ((AbstractOssStrategy)service).init(properties); |
| | | SERVICES.put(type, service); |
| | | } |
| | | |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/oss/properties/CloudStorageProperties.java ÐÞ¸Ä |
| | |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * OSS对象åå¨ é
ç½®å±æ§ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | public class CloudStorageProperties { |
| | | public class OssProperties { |
| | | |
| | | /** |
| | | * åå |
| | |
| | | * æ¯å¦httpsï¼Y=æ¯,N=å¦ï¼ |
| | | */ |
| | | private String isHttps; |
| | | |
| | | /** |
| | | * æ´æ°æ¶é´ |
| | | */ |
| | | private Date updateTime; |
| | | |
| | | } |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/oss/service/ICloudStorageStrategy.java ÐÞ¸Ä |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ICloudStorageStrategy { |
| | | public interface IOssStrategy { |
| | | |
| | | void createBucket(); |
| | | |
| | |
| | | * è·åæå¡åç±»å |
| | | */ |
| | | String getServiceType(); |
| | | |
| | | /** |
| | | * æä»¶è·¯å¾ |
| | | * |
| | | * @param prefix åç¼ |
| | | * @param suffix åç¼ |
| | | * @return è¿åä¸ä¼ è·¯å¾ |
| | | */ |
| | | String getPath(String prefix, String suffix); |
| | | |
| | | /** |
| | | * æä»¶ä¸ä¼ |
| | |
| | | */ |
| | | UploadResult uploadSuffix(InputStream inputStream, String suffix, String contentType); |
| | | |
| | | String getEndpointLink(); |
| | | } |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/oss/service/abstractd/AbstractCloudStorageStrategy.java ÐÞ¸Ä |
| | |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.oss.entity.UploadResult; |
| | | import com.ruoyi.oss.properties.CloudStorageProperties; |
| | | import com.ruoyi.oss.service.ICloudStorageStrategy; |
| | | import com.ruoyi.oss.properties.OssProperties; |
| | | import com.ruoyi.oss.service.IOssStrategy; |
| | | |
| | | import java.io.InputStream; |
| | | |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public abstract class AbstractCloudStorageStrategy implements ICloudStorageStrategy { |
| | | public abstract class AbstractOssStrategy implements IOssStrategy { |
| | | |
| | | protected CloudStorageProperties properties; |
| | | protected OssProperties properties; |
| | | |
| | | public abstract void init(CloudStorageProperties properties); |
| | | public abstract void init(OssProperties properties); |
| | | |
| | | @Override |
| | | public abstract void createBucket(); |
| | |
| | | @Override |
| | | public abstract String getServiceType(); |
| | | |
| | | @Override |
| | | public String getPath(String prefix, String suffix) { |
| | | // çæuuid |
| | | String uuid = IdUtil.fastSimpleUUID(); |
| | |
| | | @Override |
| | | public abstract UploadResult uploadSuffix(InputStream inputStream, String suffix, String contentType); |
| | | |
| | | @Override |
| | | public abstract String getEndpointLink(); |
| | | } |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/oss/service/impl/AliyunCloudStorageStrategy.java ÐÞ¸Ä |
| | |
| | | import com.aliyun.oss.model.PutObjectRequest; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.oss.entity.UploadResult; |
| | | import com.ruoyi.oss.enumd.CloudServiceEnumd; |
| | | import com.ruoyi.oss.enumd.OssEnumd; |
| | | import com.ruoyi.oss.exception.OssException; |
| | | import com.ruoyi.oss.properties.CloudStorageProperties; |
| | | import com.ruoyi.oss.service.abstractd.AbstractCloudStorageStrategy; |
| | | import com.ruoyi.oss.properties.OssProperties; |
| | | import com.ruoyi.oss.service.abstractd.AbstractOssStrategy; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.InputStream; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public class AliyunCloudStorageStrategy extends AbstractCloudStorageStrategy { |
| | | public class AliyunOssStrategy extends AbstractOssStrategy { |
| | | |
| | | private OSSClient client; |
| | | |
| | | @Override |
| | | public void init(CloudStorageProperties cloudStorageProperties) { |
| | | public void init(OssProperties cloudStorageProperties) { |
| | | properties = cloudStorageProperties; |
| | | try { |
| | | ClientConfiguration configuration = new ClientConfiguration(); |
| | |
| | | |
| | | @Override |
| | | public String getServiceType() { |
| | | return CloudServiceEnumd.ALIYUN.getValue(); |
| | | return OssEnumd.ALIYUN.getValue(); |
| | | } |
| | | |
| | | @Override |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/oss/service/impl/MinioCloudStorageStrategy.java ÐÞ¸Ä |
| | |
| | | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.oss.entity.UploadResult; |
| | | import com.ruoyi.oss.enumd.CloudServiceEnumd; |
| | | import com.ruoyi.oss.enumd.OssEnumd; |
| | | import com.ruoyi.oss.enumd.PolicyType; |
| | | import com.ruoyi.oss.exception.OssException; |
| | | import com.ruoyi.oss.properties.CloudStorageProperties; |
| | | import com.ruoyi.oss.service.abstractd.AbstractCloudStorageStrategy; |
| | | import com.ruoyi.oss.properties.OssProperties; |
| | | import com.ruoyi.oss.service.abstractd.AbstractOssStrategy; |
| | | import io.minio.*; |
| | | import org.springframework.http.MediaType; |
| | | |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public class MinioCloudStorageStrategy extends AbstractCloudStorageStrategy { |
| | | public class MinioOssStrategy extends AbstractOssStrategy { |
| | | |
| | | private MinioClient minioClient; |
| | | |
| | | @Override |
| | | public void init(CloudStorageProperties cloudStorageProperties) { |
| | | public void init(OssProperties cloudStorageProperties) { |
| | | properties = cloudStorageProperties; |
| | | try { |
| | | minioClient = MinioClient.builder() |
| | |
| | | |
| | | @Override |
| | | public String getServiceType() { |
| | | return CloudServiceEnumd.MINIO.getValue(); |
| | | return OssEnumd.MINIO.getValue(); |
| | | } |
| | | |
| | | @Override |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/oss/service/impl/QcloudCloudStorageStrategy.java ÐÞ¸Ä |
| | |
| | | import com.qcloud.cos.region.Region; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.oss.entity.UploadResult; |
| | | import com.ruoyi.oss.enumd.CloudServiceEnumd; |
| | | import com.ruoyi.oss.enumd.OssEnumd; |
| | | import com.ruoyi.oss.exception.OssException; |
| | | import com.ruoyi.oss.properties.CloudStorageProperties; |
| | | import com.ruoyi.oss.service.abstractd.AbstractCloudStorageStrategy; |
| | | import com.ruoyi.oss.properties.OssProperties; |
| | | import com.ruoyi.oss.service.abstractd.AbstractOssStrategy; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.InputStream; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public class QcloudCloudStorageStrategy extends AbstractCloudStorageStrategy { |
| | | public class QcloudOssStrategy extends AbstractOssStrategy { |
| | | |
| | | private COSClient client; |
| | | |
| | | @Override |
| | | public void init(CloudStorageProperties cloudStorageProperties) { |
| | | public void init(OssProperties cloudStorageProperties) { |
| | | properties = cloudStorageProperties; |
| | | try { |
| | | COSCredentials credentials = new BasicCOSCredentials( |
| | |
| | | |
| | | @Override |
| | | public String getServiceType() { |
| | | return CloudServiceEnumd.QCLOUD.getValue(); |
| | | return OssEnumd.QCLOUD.getValue(); |
| | | } |
| | | |
| | | @Override |
ÎļþÃû´Ó ruoyi-oss/src/main/java/com/ruoyi/oss/service/impl/QiniuCloudStorageStrategy.java ÐÞ¸Ä |
| | |
| | | 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.enumd.OssEnumd; |
| | | import com.ruoyi.oss.exception.OssException; |
| | | import com.ruoyi.oss.properties.CloudStorageProperties; |
| | | import com.ruoyi.oss.service.abstractd.AbstractCloudStorageStrategy; |
| | | import com.ruoyi.oss.properties.OssProperties; |
| | | import com.ruoyi.oss.service.abstractd.AbstractOssStrategy; |
| | | |
| | | import java.io.InputStream; |
| | | |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public class QiniuCloudStorageStrategy extends AbstractCloudStorageStrategy { |
| | | public class QiniuOssStrategy extends AbstractOssStrategy { |
| | | |
| | | private UploadManager uploadManager; |
| | | private BucketManager bucketManager; |
| | | private String token; |
| | | private Auth auth; |
| | | |
| | | @Override |
| | | public void init(CloudStorageProperties cloudStorageProperties) { |
| | | public void init(OssProperties cloudStorageProperties) { |
| | | properties = cloudStorageProperties; |
| | | try { |
| | | Configuration config = new Configuration(getRegion(properties.getRegion())); |
| | |
| | | config.useHttpsDomains = false; |
| | | config.useHttpsDomains = "Y".equals(properties.getIsHttps()); |
| | | uploadManager = new UploadManager(config); |
| | | Auth auth = Auth.create(properties.getAccessKey(), properties.getSecretKey()); |
| | | auth = Auth.create(properties.getAccessKey(), properties.getSecretKey()); |
| | | String bucketName = properties.getBucketName(); |
| | | token = auth.uploadToken(bucketName); |
| | | bucketManager = new BucketManager(auth, config); |
| | | |
| | | if (!ArrayUtil.contains(bucketManager.buckets(), bucketName)) { |
| | |
| | | |
| | | @Override |
| | | public String getServiceType() { |
| | | return CloudServiceEnumd.QINIU.getValue(); |
| | | return OssEnumd.QINIU.getValue(); |
| | | } |
| | | |
| | | @Override |
| | | public UploadResult upload(byte[] data, String path, String contentType) { |
| | | try { |
| | | Response res = uploadManager.put(data, path, token, null, contentType, false); |
| | | String token = auth.uploadToken(properties.getBucketName()); |
| | | Response res = uploadManager.put(data, path, token, null, contentType, false); |
| | | if (!res.isOK()) { |
| | | throw new RuntimeException("ä¸ä¼ ä¸çåºéï¼" + res.toString()); |
| | | throw new RuntimeException("ä¸ä¼ ä¸çåºéï¼" + res.error); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new OssException("ä¸ä¼ æä»¶å¤±è´¥ï¼è¯·æ ¸å¯¹ä¸çé
置信æ¯:[" + e.getMessage() + "]"); |
| | |
| | | path = path.replace(getEndpointLink() + "/", ""); |
| | | Response res = bucketManager.delete(properties.getBucketName(), path); |
| | | if (!res.isOK()) { |
| | | throw new RuntimeException("å é¤ä¸çæä»¶åºéï¼" + res.toString()); |
| | | throw new RuntimeException("å é¤ä¸çæä»¶åºéï¼" + res.error); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new OssException(e.getMessage()); |
| | |
| | | * å¸å·ç¶æï¼0æ£å¸¸ 1åç¨ï¼ |
| | | */ |
| | | @ExcelProperty(value = "å¸å·ç¶æ", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_common_status") |
| | | @ExcelDictFormat(dictType = "sys_normal_disable") |
| | | private String status; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.listener; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.excel.ExcelListener; |
| | | import com.ruoyi.common.excel.ExcelResult; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.system.domain.vo.SysUserImportVo; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ç³»ç»ç¨æ·èªå®ä¹å¯¼å
¥ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | public class SysUserImportListener extends AnalysisEventListener<SysUserImportVo> implements ExcelListener<SysUserImportVo> { |
| | | |
| | | private final ISysUserService userService; |
| | | |
| | | private final String password; |
| | | |
| | | private final Boolean isUpdateSupport; |
| | | |
| | | private final String operName; |
| | | |
| | | private int successNum = 0; |
| | | private int failureNum = 0; |
| | | private final StringBuilder successMsg = new StringBuilder(); |
| | | private final StringBuilder failureMsg = new StringBuilder(); |
| | | |
| | | public SysUserImportListener(Boolean isUpdateSupport) { |
| | | this.userService = SpringUtils.getBean(ISysUserService.class); |
| | | this.password = SpringUtils.getBean(ISysConfigService.class) |
| | | .selectConfigByKey("sys.user.initPassword"); |
| | | this.isUpdateSupport = isUpdateSupport; |
| | | this.operName = SecurityUtils.getUsername(); |
| | | } |
| | | |
| | | @Override |
| | | public void invoke(SysUserImportVo userVo, AnalysisContext context) { |
| | | SysUser user = this.userService.selectUserByUserName(userVo.getUserName()); |
| | | try { |
| | | // éªè¯æ¯å¦åå¨è¿ä¸ªç¨æ· |
| | | if (StringUtils.isNull(user)) { |
| | | user = BeanUtil.toBean(userVo, SysUser.class); |
| | | user.setPassword(SecurityUtils.encryptPassword(password)); |
| | | user.setCreateBy(operName); |
| | | userService.insertUser(user); |
| | | successNum++; |
| | | successMsg.append("<br/>").append(successNum).append("ãè´¦å· ").append(user.getUserName()).append(" 导å
¥æå"); |
| | | } else if (isUpdateSupport) { |
| | | user.setUpdateBy(operName); |
| | | userService.updateUser(user); |
| | | successNum++; |
| | | successMsg.append("<br/>").append(successNum).append("ãè´¦å· ").append(user.getUserName()).append(" æ´æ°æå"); |
| | | } else { |
| | | failureNum++; |
| | | failureMsg.append("<br/>").append(failureNum).append("ãè´¦å· ").append(user.getUserName()).append(" å·²åå¨"); |
| | | } |
| | | } catch (Exception e) { |
| | | failureNum++; |
| | | String msg = "<br/>" + failureNum + "ãè´¦å· " + user.getUserName() + " 导å
¥å¤±è´¥ï¼"; |
| | | failureMsg.append(msg).append(e.getMessage()); |
| | | log.error(msg, e); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext context) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public ExcelResult<SysUserImportVo> getExcelResult() { |
| | | return new ExcelResult<SysUserImportVo>() { |
| | | |
| | | @Override |
| | | public String getAnalysis() { |
| | | if (failureNum > 0) { |
| | | failureMsg.insert(0, "徿±æï¼å¯¼å
¥å¤±è´¥ï¼å
± " + failureNum + " æ¡æ°æ®æ ¼å¼ä¸æ£ç¡®ï¼é误å¦ä¸ï¼"); |
| | | throw new ServiceException(failureMsg.toString()); |
| | | } else { |
| | | successMsg.insert(0, "æåæ¨ï¼æ°æ®å·²å
¨é¨å¯¼å
¥æåï¼å
± " + successNum + " æ¡ï¼æ°æ®å¦ä¸ï¼"); |
| | | } |
| | | return successMsg.toString(); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysUserImportVo> getList() { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getErrorList() { |
| | | return null; |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | * @param menuCheckStrictly èåæ éæ©é¡¹æ¯å¦å
³èæ¾ç¤º |
| | | * @return éä¸èåå表 |
| | | */ |
| | | List<Integer> selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly); |
| | | List<Long> selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly); |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.system.runner; |
| | | |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.system.service.ISysDictTypeService; |
| | | import com.ruoyi.system.service.ISysOssConfigService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.ApplicationArguments; |
| | | import org.springframework.boot.ApplicationRunner; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * åå§å system 模å对åºä¸å¡æ°æ® |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @Component |
| | | public class SystemApplicationRunner implements ApplicationRunner { |
| | | |
| | | private final RuoYiConfig ruoyiConfig; |
| | | private final ISysConfigService configService; |
| | | private final ISysDictTypeService dictTypeService; |
| | | private final ISysOssConfigService ossConfigService; |
| | | |
| | | @Override |
| | | public void run(ApplicationArguments args) throws Exception { |
| | | ossConfigService.init(); |
| | | log.info("åå§åOSSé
ç½®æå"); |
| | | if (ruoyiConfig.isCacheLazy()){ |
| | | return; |
| | | } |
| | | configService.loadingConfigCache(); |
| | | log.info("å è½½åæ°ç¼åæ°æ®æå"); |
| | | dictTypeService.loadingDictCache(); |
| | | log.info("å è½½åå
¸ç¼åæ°æ®æå"); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.domain.TreeSelect; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | |
| | | import java.util.List; |
| | |
| | | List<SysDept> selectDeptList(SysDept dept); |
| | | |
| | | /** |
| | | * æå»ºå端æéè¦æ ç»æ |
| | | * |
| | | * @param depts é¨é¨å表 |
| | | * @return æ ç»æå表 |
| | | */ |
| | | List<SysDept> buildDeptTree(List<SysDept> depts); |
| | | |
| | | /** |
| | | * æå»ºå端æéè¦ä¸ææ ç»æ |
| | | * |
| | | * @param depts é¨é¨å表 |
| | | * @return 䏿æ ç»æå表 |
| | | */ |
| | | List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts); |
| | | List<Tree<Long>> buildDeptTreeSelect(List<SysDept> depts); |
| | | |
| | | /** |
| | | * æ ¹æ®è§è²IDæ¥è¯¢é¨é¨æ ä¿¡æ¯ |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | 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.system.domain.vo.RouterVo; |
| | | |
| | |
| | | * @param roleId è§è²ID |
| | | * @return éä¸èåå表 |
| | | */ |
| | | List<Integer> selectMenuListByRoleId(Long roleId); |
| | | List<Long> selectMenuListByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * æå»ºåç«¯è·¯ç±æéè¦çèå |
| | |
| | | List<RouterVo> buildMenus(List<SysMenu> menus); |
| | | |
| | | /** |
| | | * æå»ºå端æéè¦æ ç»æ |
| | | * |
| | | * @param menus èåå表 |
| | | * @return æ ç»æå表 |
| | | */ |
| | | List<SysMenu> buildMenuTree(List<SysMenu> menus); |
| | | |
| | | /** |
| | | * æå»ºå端æéè¦ä¸ææ ç»æ |
| | | * |
| | | * @param menus èåå表 |
| | | * @return 䏿æ ç»æå表 |
| | | */ |
| | | List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus); |
| | | List<Tree<Long>> buildMenuTreeSelect(List<SysMenu> menus); |
| | | |
| | | /** |
| | | * æ ¹æ®èåIDæ¥è¯¢ä¿¡æ¯ |
| | |
| | | public interface ISysOssConfigService extends IServicePlus<SysOssConfig, SysOssConfigVo> { |
| | | |
| | | /** |
| | | * åå§åOSSé
ç½® |
| | | */ |
| | | void init(); |
| | | |
| | | /** |
| | | * æ¥è¯¢å个 |
| | | */ |
| | | SysOssConfigVo queryById(Integer ossConfigId); |
| | |
| | | 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.service.ConfigService; |
| | | import com.ruoyi.common.enums.DataSourceType; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Service |
| | | public class SysConfigServiceImpl extends ServicePlusImpl<SysConfigMapper, SysConfig, SysConfig> implements ISysConfigService { |
| | | |
| | | /** |
| | | * 项ç®å¯å¨æ¶ï¼åå§ååæ°å°ç¼å |
| | | */ |
| | | @PostConstruct |
| | | public void init() { |
| | | loadingConfigCache(); |
| | | } |
| | | public class SysConfigServiceImpl extends ServicePlusImpl<SysConfigMapper, SysConfig, SysConfig> implements ISysConfigService, ConfigService { |
| | | |
| | | @Override |
| | | public TableDataInfo<SysConfig> selectPageConfigList(SysConfig config) { |
| | | Map<String, Object> params = config.getParams(); |
| | | LambdaQueryWrapper<SysConfig> lqw = new LambdaQueryWrapper<SysConfig>() |
| | | .like(StringUtils.isNotBlank(config.getConfigName()), SysConfig::getConfigName, config.getConfigName()) |
| | | .eq(StringUtils.isNotBlank(config.getConfigType()), SysConfig::getConfigType, config.getConfigType()) |
| | | .like(StringUtils.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime")); |
| | | .like(StringUtils.isNotBlank(config.getConfigName()), SysConfig::getConfigName, config.getConfigName()) |
| | | .eq(StringUtils.isNotBlank(config.getConfigType()), SysConfig::getConfigType, config.getConfigType()) |
| | | .like(StringUtils.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysConfig::getCreateTime, params.get("beginTime"), params.get("endTime")); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public String selectConfigByKey(String configKey) { |
| | | String configValue = Convert.toStr(RedisUtils.getCacheObject(getCacheKey(configKey))); |
| | | String configValue = RedisUtils.getCacheObject(getCacheKey(configKey)); |
| | | if (StringUtils.isNotEmpty(configValue)) { |
| | | return configValue; |
| | | } |
| | | SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>() |
| | | .eq(SysConfig::getConfigKey, configKey)); |
| | | .eq(SysConfig::getConfigKey, configKey)); |
| | | if (StringUtils.isNotNull(retConfig)) { |
| | | RedisUtils.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue()); |
| | | return retConfig.getConfigValue(); |
| | |
| | | public List<SysConfig> selectConfigList(SysConfig config) { |
| | | Map<String, Object> params = config.getParams(); |
| | | LambdaQueryWrapper<SysConfig> lqw = new LambdaQueryWrapper<SysConfig>() |
| | | .like(StringUtils.isNotBlank(config.getConfigName()), SysConfig::getConfigName, config.getConfigName()) |
| | | .eq(StringUtils.isNotBlank(config.getConfigType()), SysConfig::getConfigType, config.getConfigType()) |
| | | .like(StringUtils.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime")); |
| | | .like(StringUtils.isNotBlank(config.getConfigName()), SysConfig::getConfigName, config.getConfigName()) |
| | | .eq(StringUtils.isNotBlank(config.getConfigType()), SysConfig::getConfigType, config.getConfigType()) |
| | | .like(StringUtils.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysConfig::getCreateTime, params.get("beginTime"), params.get("endTime")); |
| | | return baseMapper.selectList(lqw); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®åæ° key è·ååæ°å¼ |
| | | * |
| | | * @param configKey åæ° key |
| | | * @return åæ°å¼ |
| | | */ |
| | | @Override |
| | | public String getConfigValue(String configKey) { |
| | | return selectConfigByKey(configKey); |
| | | } |
| | | |
| | | /** |
| | | * 设置cache key |
| | | * |
| | | * @param configKey åæ°é® |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.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.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.TreeBuildUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMapper; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * é¨é¨ç®¡ç æå¡å®ç° |
| | |
| | | } |
| | | |
| | | /** |
| | | * æå»ºå端æéè¦æ ç»æ |
| | | * |
| | | * @param depts é¨é¨å表 |
| | | * @return æ ç»æå表 |
| | | */ |
| | | @Override |
| | | public List<SysDept> buildDeptTree(List<SysDept> depts) { |
| | | List<SysDept> returnList = new ArrayList<SysDept>(); |
| | | List<Long> tempList = new ArrayList<Long>(); |
| | | for (SysDept dept : depts) { |
| | | tempList.add(dept.getDeptId()); |
| | | } |
| | | for (SysDept dept : depts) { |
| | | // 妿æ¯é¡¶çº§èç¹, éå该ç¶èç¹çææåèç¹ |
| | | if (!tempList.contains(dept.getParentId())) { |
| | | recursionFn(depts, dept); |
| | | returnList.add(dept); |
| | | } |
| | | } |
| | | if (returnList.isEmpty()) { |
| | | returnList = depts; |
| | | } |
| | | return returnList; |
| | | } |
| | | |
| | | /** |
| | | * æå»ºå端æéè¦ä¸ææ ç»æ |
| | | * |
| | | * @param depts é¨é¨å表 |
| | | * @return 䏿æ ç»æå表 |
| | | */ |
| | | @Override |
| | | public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts) { |
| | | List<SysDept> deptTrees = buildDeptTree(depts); |
| | | return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); |
| | | public List<Tree<Long>> buildDeptTreeSelect(List<SysDept> depts) { |
| | | return TreeBuildUtils.build(depts, (dept, tree) -> |
| | | tree.setId(dept.getDeptId()) |
| | | .setParentId(dept.getParentId()) |
| | | .setName(dept.getDeptName()) |
| | | .setWeight(dept.getOrderNum())); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public long selectNormalChildrenDeptById(Long deptId) { |
| | | return count(new LambdaQueryWrapper<SysDept>() |
| | | .eq(SysDept::getStatus, 0) |
| | | .apply("find_in_set({0}, ancestors)", deptId)); |
| | | .eq(SysDept::getStatus, 0) |
| | | .apply("find_in_set({0}, ancestors)", deptId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public boolean hasChildByDeptId(Long deptId) { |
| | | long result = count(new LambdaQueryWrapper<SysDept>() |
| | | .eq(SysDept::getParentId, deptId) |
| | | .last("limit 1")); |
| | | .eq(SysDept::getParentId, deptId)); |
| | | return result > 0; |
| | | } |
| | | |
| | |
| | | @Override |
| | | public boolean checkDeptExistUser(Long deptId) { |
| | | long result = userMapper.selectCount(new LambdaQueryWrapper<SysUser>() |
| | | .eq(SysUser::getDeptId, deptId)); |
| | | .eq(SysUser::getDeptId, deptId)); |
| | | return result > 0; |
| | | } |
| | | |
| | |
| | | @Override |
| | | public String checkDeptNameUnique(SysDept dept) { |
| | | Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); |
| | | SysDept info = getOne(new LambdaQueryWrapper<SysDept>() |
| | | .eq(SysDept::getDeptName, dept.getDeptName()) |
| | | .eq(SysDept::getParentId, dept.getParentId()) |
| | | .last("limit 1")); |
| | | if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) { |
| | | long count = count(new LambdaQueryWrapper<SysDept>() |
| | | .eq(SysDept::getDeptName, dept.getDeptName()) |
| | | .eq(SysDept::getParentId, dept.getParentId()) |
| | | .ne(SysDept::getDeptId, deptId)); |
| | | if (count > 0) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | } |
| | | int result = baseMapper.updateById(dept); |
| | | if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) |
| | | && !StringUtils.equals("0", dept.getAncestors())) { |
| | | && !StringUtils.equals("0", dept.getAncestors())) { |
| | | // å¦æè¯¥é¨é¨æ¯å¯ç¨ç¶æï¼åå¯ç¨è¯¥é¨é¨çææä¸çº§é¨é¨ |
| | | updateParentDeptStatusNormal(dept); |
| | | } |
| | |
| | | String ancestors = dept.getAncestors(); |
| | | Long[] deptIds = Convert.toLongArray(ancestors); |
| | | update(null, new LambdaUpdateWrapper<SysDept>() |
| | | .set(SysDept::getStatus, "0") |
| | | .in(SysDept::getDeptId, Arrays.asList(deptIds))); |
| | | .set(SysDept::getStatus, "0") |
| | | .in(SysDept::getDeptId, Arrays.asList(deptIds))); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) { |
| | | List<SysDept> children = list(new LambdaQueryWrapper<SysDept>() |
| | | .apply("find_in_set({0},ancestors)", deptId)); |
| | | .apply("find_in_set({0},ancestors)", deptId)); |
| | | for (SysDept child : children) { |
| | | child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); |
| | | } |
| | |
| | | return baseMapper.deleteById(deptId); |
| | | } |
| | | |
| | | /** |
| | | * éå½å表 |
| | | */ |
| | | private void recursionFn(List<SysDept> list, SysDept t) { |
| | | // å¾å°åèç¹å表 |
| | | List<SysDept> childList = getChildList(list, t); |
| | | t.setChildren(childList); |
| | | for (SysDept tChild : childList) { |
| | | if (hasChild(list, tChild)) { |
| | | recursionFn(list, tChild); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å¾å°åèç¹å表 |
| | | */ |
| | | private List<SysDept> getChildList(List<SysDept> list, SysDept t) { |
| | | List<SysDept> tlist = new ArrayList<SysDept>(); |
| | | for (SysDept n : list) { |
| | | if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) { |
| | | tlist.add(n); |
| | | } |
| | | } |
| | | return tlist; |
| | | } |
| | | |
| | | /** |
| | | * 夿æ¯å¦æåèç¹ |
| | | */ |
| | | private boolean hasChild(List<SysDept> list, SysDept t) { |
| | | return getChildList(list, t).size() > 0; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.constant.Constants; |
| | | 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.common.utils.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.mapper.SysDictDataMapper; |
| | | import com.ruoyi.system.service.ISysDictDataService; |
| | |
| | | SysDictData data = selectDictDataById(dictCode); |
| | | removeById(dictCode); |
| | | List<SysDictData> dictDatas = baseMapper.selectDictDataByType(data.getDictType()); |
| | | DictUtils.setDictCache(data.getDictType(), dictDatas); |
| | | RedisUtils.setCacheObject(getCacheKey(data.getDictType()), dictDatas); |
| | | } |
| | | } |
| | | |
| | |
| | | int row = baseMapper.insert(data); |
| | | if (row > 0) { |
| | | List<SysDictData> dictDatas = baseMapper.selectDictDataByType(data.getDictType()); |
| | | DictUtils.setDictCache(data.getDictType(), dictDatas); |
| | | RedisUtils.setCacheObject(getCacheKey(data.getDictType()), dictDatas); |
| | | } |
| | | return row; |
| | | } |
| | |
| | | int row = baseMapper.updateById(data); |
| | | if (row > 0) { |
| | | List<SysDictData> dictDatas = baseMapper.selectDictDataByType(data.getDictType()); |
| | | DictUtils.setDictCache(data.getDictType(), dictDatas); |
| | | RedisUtils.setCacheObject(getCacheKey(data.getDictType()), dictDatas); |
| | | } |
| | | return row; |
| | | } |
| | | |
| | | /** |
| | | * 设置cache key |
| | | * |
| | | * @param configKey åæ°é® |
| | | * @return ç¼åé®key |
| | | */ |
| | | String getCacheKey(String configKey) { |
| | | return Constants.SYS_DICT_KEY + configKey; |
| | | } |
| | | } |
| | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.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.core.service.DictService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.DictUtils; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.mapper.SysDictDataMapper; |
| | | import com.ruoyi.system.mapper.SysDictTypeMapper; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Service |
| | | public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, SysDictType, SysDictType> implements ISysDictTypeService { |
| | | public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, SysDictType, SysDictType> implements ISysDictTypeService, DictService { |
| | | |
| | | @Autowired |
| | | private SysDictDataMapper dictDataMapper; |
| | | |
| | | /** |
| | | * 项ç®å¯å¨æ¶ï¼åå§ååå
¸å°ç¼å |
| | | */ |
| | | @PostConstruct |
| | | public void init() { |
| | | loadingDictCache(); |
| | | } |
| | | |
| | | @Override |
| | | public TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType) { |
| | | Map<String, Object> params = dictType.getParams(); |
| | | LambdaQueryWrapper<SysDictType> lqw = new LambdaQueryWrapper<SysDictType>() |
| | | .like(StringUtils.isNotBlank(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName()) |
| | | .eq(StringUtils.isNotBlank(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus()) |
| | | .like(StringUtils.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime")); |
| | | .like(StringUtils.isNotBlank(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName()) |
| | | .eq(StringUtils.isNotBlank(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus()) |
| | | .like(StringUtils.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysDictType::getCreateTime, params.get("beginTime"), params.get("endTime")); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); |
| | | } |
| | | |
| | |
| | | public List<SysDictType> selectDictTypeList(SysDictType dictType) { |
| | | Map<String, Object> params = dictType.getParams(); |
| | | return list(new LambdaQueryWrapper<SysDictType>() |
| | | .like(StringUtils.isNotBlank(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName()) |
| | | .eq(StringUtils.isNotBlank(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus()) |
| | | .like(StringUtils.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime"))); |
| | | .like(StringUtils.isNotBlank(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName()) |
| | | .eq(StringUtils.isNotBlank(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus()) |
| | | .like(StringUtils.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysDictType::getCreateTime, params.get("beginTime"), params.get("endTime"))); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public List<SysDictData> selectDictDataByType(String dictType) { |
| | | List<SysDictData> dictDatas = DictUtils.getDictCache(dictType); |
| | | if (CollUtil.isNotEmpty(dictDatas)) { |
| | | List<SysDictData> dictDatas = RedisUtils.getCacheObject(getCacheKey(dictType)); |
| | | if (StringUtils.isNotEmpty(dictDatas)) { |
| | | return dictDatas; |
| | | } |
| | | dictDatas = dictDataMapper.selectDictDataByType(dictType); |
| | | if (CollUtil.isNotEmpty(dictDatas)) { |
| | | DictUtils.setDictCache(dictType, dictDatas); |
| | | RedisUtils.setCacheObject(getCacheKey(dictType), dictDatas); |
| | | return dictDatas; |
| | | } |
| | | return null; |
| | |
| | | for (Long dictId : dictIds) { |
| | | SysDictType dictType = selectDictTypeById(dictId); |
| | | if (dictDataMapper.selectCount(new LambdaQueryWrapper<SysDictData>() |
| | | .eq(SysDictData::getDictType, dictType.getDictType())) > 0) { |
| | | .eq(SysDictData::getDictType, dictType.getDictType())) > 0) { |
| | | throw new ServiceException(String.format("%1$så·²åé
,ä¸è½å é¤", dictType.getDictName())); |
| | | } |
| | | DictUtils.removeDictCache(dictType.getDictType()); |
| | | RedisUtils.deleteObject(getCacheKey(dictType.getDictType())); |
| | | } |
| | | baseMapper.deleteBatchIds(Arrays.asList(dictIds)); |
| | | } |
| | |
| | | List<SysDictType> dictTypeList = list(); |
| | | for (SysDictType dictType : dictTypeList) { |
| | | List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType()); |
| | | DictUtils.setDictCache(dictType.getDictType(), dictDatas); |
| | | RedisUtils.setCacheObject(getCacheKey(dictType.getDictType()), dictDatas); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void clearDictCache() { |
| | | DictUtils.clearDictCache(); |
| | | Collection<String> keys = RedisUtils.keys(Constants.SYS_DICT_KEY + "*"); |
| | | RedisUtils.deleteObject(keys); |
| | | } |
| | | |
| | | /** |
| | |
| | | public int insertDictType(SysDictType dict) { |
| | | int row = baseMapper.insert(dict); |
| | | if (row > 0) { |
| | | DictUtils.setDictCache(dict.getDictType(), null); |
| | | RedisUtils.setCacheObject(getCacheKey(dict.getDictType()), null); |
| | | } |
| | | return row; |
| | | } |
| | |
| | | public int updateDictType(SysDictType dict) { |
| | | SysDictType oldDict = getById(dict.getDictId()); |
| | | dictDataMapper.update(null, new LambdaUpdateWrapper<SysDictData>() |
| | | .set(SysDictData::getDictType, dict.getDictType()) |
| | | .eq(SysDictData::getDictType, oldDict.getDictType())); |
| | | .set(SysDictData::getDictType, dict.getDictType()) |
| | | .eq(SysDictData::getDictType, oldDict.getDictType())); |
| | | int row = baseMapper.updateById(dict); |
| | | if (row > 0) { |
| | | List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dict.getDictType()); |
| | | DictUtils.setDictCache(dict.getDictType(), dictDatas); |
| | | RedisUtils.setCacheObject(getCacheKey(dict.getDictType()), dictDatas); |
| | | } |
| | | return row; |
| | | } |
| | |
| | | @Override |
| | | public String checkDictTypeUnique(SysDictType dict) { |
| | | Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId(); |
| | | SysDictType dictType = getOne(new LambdaQueryWrapper<SysDictType>() |
| | | .eq(SysDictType::getDictType, dict.getDictType()) |
| | | .last("limit 1")); |
| | | if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) { |
| | | long count = count(new LambdaQueryWrapper<SysDictType>() |
| | | .eq(SysDictType::getDictType, dict.getDictType()) |
| | | .ne(SysDictType::getDictId, dictId)); |
| | | if (count > 0) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸ç±»åååå
¸å¼è·ååå
¸æ ç¾ |
| | | * |
| | | * @param dictType åå
¸ç±»å |
| | | * @param dictValue åå
¸å¼ |
| | | * @param separator åé符 |
| | | * @return åå
¸æ ç¾ |
| | | */ |
| | | @Override |
| | | public String getDictLabel(String dictType, String dictValue, String separator) { |
| | | StringBuilder propertyString = new StringBuilder(); |
| | | List<SysDictData> datas = selectDictDataByType(dictType); |
| | | |
| | | if (StringUtils.containsAny(dictValue, separator) && CollUtil.isNotEmpty(datas)) { |
| | | for (SysDictData dict : datas) { |
| | | for (String value : dictValue.split(separator)) { |
| | | if (value.equals(dict.getDictValue())) { |
| | | propertyString.append(dict.getDictLabel() + separator); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | for (SysDictData dict : datas) { |
| | | if (dictValue.equals(dict.getDictValue())) { |
| | | return dict.getDictLabel(); |
| | | } |
| | | } |
| | | } |
| | | return StringUtils.stripEnd(propertyString.toString(), separator); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®åå
¸ç±»åååå
¸æ ç¾è·ååå
¸å¼ |
| | | * |
| | | * @param dictType åå
¸ç±»å |
| | | * @param dictLabel åå
¸æ ç¾ |
| | | * @param separator åé符 |
| | | * @return åå
¸å¼ |
| | | */ |
| | | @Override |
| | | public String getDictValue(String dictType, String dictLabel, String separator) { |
| | | StringBuilder propertyString = new StringBuilder(); |
| | | List<SysDictData> datas = selectDictDataByType(dictType); |
| | | |
| | | if (StringUtils.containsAny(dictLabel, separator) && CollUtil.isNotEmpty(datas)) { |
| | | for (SysDictData dict : datas) { |
| | | for (String label : dictLabel.split(separator)) { |
| | | if (label.equals(dict.getDictLabel())) { |
| | | propertyString.append(dict.getDictValue() + separator); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | for (SysDictData dict : datas) { |
| | | if (dictLabel.equals(dict.getDictLabel())) { |
| | | return dict.getDictValue(); |
| | | } |
| | | } |
| | | } |
| | | return StringUtils.stripEnd(propertyString.toString(), separator); |
| | | } |
| | | |
| | | /** |
| | | * 设置cache key |
| | | * |
| | | * @param configKey åæ°é® |
| | | * @return ç¼åé®key |
| | | */ |
| | | String getCacheKey(String configKey) { |
| | | return Constants.SYS_DICT_KEY + configKey; |
| | | } |
| | | } |
| | |
| | | public TableDataInfo<SysLogininfor> selectPageLogininforList(SysLogininfor logininfor) { |
| | | Map<String, Object> params = logininfor.getParams(); |
| | | LambdaQueryWrapper<SysLogininfor> lqw = new LambdaQueryWrapper<SysLogininfor>() |
| | | .like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr()) |
| | | .eq(StringUtils.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus()) |
| | | .like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(login_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(login_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime")); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage("info_id","desc"), lqw)); |
| | | .like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr()) |
| | | .eq(StringUtils.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus()) |
| | | .like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysLogininfor::getLoginTime, params.get("beginTime"), params.get("endTime")); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage("info_id", "desc"), lqw)); |
| | | } |
| | | |
| | | /** |
| | |
| | | public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor) { |
| | | Map<String, Object> params = logininfor.getParams(); |
| | | return list(new LambdaQueryWrapper<SysLogininfor>() |
| | | .like(StringUtils.isNotBlank(logininfor.getIpaddr()),SysLogininfor::getIpaddr,logininfor.getIpaddr()) |
| | | .eq(StringUtils.isNotBlank(logininfor.getStatus()),SysLogininfor::getStatus,logininfor.getStatus()) |
| | | .like(StringUtils.isNotBlank(logininfor.getUserName()),SysLogininfor::getUserName,logininfor.getUserName()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(login_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(login_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime")) |
| | | .orderByDesc(SysLogininfor::getInfoId)); |
| | | .like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr()) |
| | | .eq(StringUtils.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus()) |
| | | .like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysLogininfor::getLoginTime, params.get("beginTime"), params.get("endTime")) |
| | | .orderByDesc(SysLogininfor::getInfoId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.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.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.TreeBuildUtils; |
| | | import com.ruoyi.system.domain.SysRoleMenu; |
| | | import com.ruoyi.system.domain.vo.MetaVo; |
| | | import com.ruoyi.system.domain.vo.RouterVo; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * èå ä¸å¡å±å¤ç |
| | |
| | | // 管çåæ¾ç¤ºææèåä¿¡æ¯ |
| | | if (SysUser.isAdmin(userId)) { |
| | | menuList = list(new LambdaQueryWrapper<SysMenu>() |
| | | .like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName()) |
| | | .eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible()) |
| | | .eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus()) |
| | | .orderByAsc(SysMenu::getParentId) |
| | | .orderByAsc(SysMenu::getOrderNum)); |
| | | .like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName()) |
| | | .eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible()) |
| | | .eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus()) |
| | | .orderByAsc(SysMenu::getParentId) |
| | | .orderByAsc(SysMenu::getOrderNum)); |
| | | } else { |
| | | menu.getParams().put("userId", userId); |
| | | menuList = baseMapper.selectMenuListByUserId(menu); |
| | |
| | | * @return éä¸èåå表 |
| | | */ |
| | | @Override |
| | | public List<Integer> selectMenuListByRoleId(Long roleId) { |
| | | public List<Long> selectMenuListByRoleId(Long roleId) { |
| | | SysRole role = roleMapper.selectById(roleId); |
| | | return baseMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly()); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * æå»ºå端æéè¦æ ç»æ |
| | | * |
| | | * @param menus èåå表 |
| | | * @return æ ç»æå表 |
| | | */ |
| | | @Override |
| | | public List<SysMenu> buildMenuTree(List<SysMenu> menus) { |
| | | List<SysMenu> returnList = new ArrayList<SysMenu>(); |
| | | List<Long> tempList = new ArrayList<Long>(); |
| | | for (SysMenu dept : menus) { |
| | | tempList.add(dept.getMenuId()); |
| | | } |
| | | for (SysMenu menu : menus) { |
| | | // 妿æ¯é¡¶çº§èç¹, éå该ç¶èç¹çææåèç¹ |
| | | if (!tempList.contains(menu.getParentId())) { |
| | | recursionFn(menus, menu); |
| | | returnList.add(menu); |
| | | } |
| | | } |
| | | if (returnList.isEmpty()) { |
| | | returnList = menus; |
| | | } |
| | | return returnList; |
| | | } |
| | | |
| | | /** |
| | | * æå»ºå端æéè¦ä¸ææ ç»æ |
| | | * |
| | | * @param menus èåå表 |
| | | * @return 䏿æ ç»æå表 |
| | | */ |
| | | @Override |
| | | public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus) { |
| | | List<SysMenu> menuTrees = buildMenuTree(menus); |
| | | return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); |
| | | public List<Tree<Long>> buildMenuTreeSelect(List<SysMenu> menus) { |
| | | return TreeBuildUtils.build(menus, (menu, tree) -> |
| | | tree.setId(menu.getMenuId()) |
| | | .setParentId(menu.getParentId()) |
| | | .setName(menu.getMenuName()) |
| | | .setWeight(menu.getOrderNum())); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public String checkMenuNameUnique(SysMenu menu) { |
| | | Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); |
| | | SysMenu info = getOne(new LambdaQueryWrapper<SysMenu>() |
| | | .eq(SysMenu::getMenuName, menu.getMenuName()) |
| | | .eq(SysMenu::getParentId, menu.getParentId()) |
| | | .last("limit 1")); |
| | | if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) { |
| | | long count = count(new LambdaQueryWrapper<SysMenu>() |
| | | .eq(SysMenu::getMenuName, menu.getMenuName()) |
| | | .eq(SysMenu::getParentId, menu.getParentId()) |
| | | .ne(SysMenu::getMenuId, menuId)); |
| | | if (count > 0) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | } |
| | | // éå¤é¾å¹¶ä¸æ¯ä¸çº§ç®å½ï¼ç±»å为ç®å½ï¼ |
| | | if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType()) |
| | | && UserConstants.NO_FRAME.equals(menu.getIsFrame())) { |
| | | && UserConstants.NO_FRAME.equals(menu.getIsFrame())) { |
| | | routerPath = "/" + menu.getPath(); |
| | | } |
| | | // éå¤é¾å¹¶ä¸æ¯ä¸çº§ç®å½ï¼ç±»å为èåï¼ |
| | |
| | | */ |
| | | public boolean isMenuFrame(SysMenu menu) { |
| | | return menu.getParentId().intValue() == 0 && UserConstants.TYPE_MENU.equals(menu.getMenuType()) |
| | | && menu.getIsFrame().equals(UserConstants.NO_FRAME); |
| | | && menu.getIsFrame().equals(UserConstants.NO_FRAME); |
| | | } |
| | | |
| | | /** |
| | |
| | | public TableDataInfo<SysOperLog> selectPageOperLogList(SysOperLog operLog) { |
| | | Map<String, Object> params = operLog.getParams(); |
| | | LambdaQueryWrapper<SysOperLog> lqw = new LambdaQueryWrapper<SysOperLog>() |
| | | .like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle()) |
| | | .eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0, |
| | | SysOperLog::getBusinessType, operLog.getBusinessType()) |
| | | .func(f -> { |
| | | if (ArrayUtil.isNotEmpty(operLog.getBusinessTypes())) { |
| | | f.in(SysOperLog::getBusinessType, Arrays.asList(operLog.getBusinessTypes())); |
| | | } |
| | | }) |
| | | .eq(operLog.getStatus() != null, |
| | | SysOperLog::getStatus, operLog.getStatus()) |
| | | .like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(oper_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(oper_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime")); |
| | | .like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle()) |
| | | .eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0, |
| | | SysOperLog::getBusinessType, operLog.getBusinessType()) |
| | | .func(f -> { |
| | | if (ArrayUtil.isNotEmpty(operLog.getBusinessTypes())) { |
| | | f.in(SysOperLog::getBusinessType, Arrays.asList(operLog.getBusinessTypes())); |
| | | } |
| | | }) |
| | | .eq(operLog.getStatus() != null, |
| | | SysOperLog::getStatus, operLog.getStatus()) |
| | | .like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysOperLog::getOperTime, params.get("beginTime"), params.get("endTime")); |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPage("oper_id", "desc"), lqw)); |
| | | } |
| | | |
| | |
| | | public List<SysOperLog> selectOperLogList(SysOperLog operLog) { |
| | | Map<String, Object> params = operLog.getParams(); |
| | | return list(new LambdaQueryWrapper<SysOperLog>() |
| | | .like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle()) |
| | | .eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0, |
| | | SysOperLog::getBusinessType, operLog.getBusinessType()) |
| | | .func(f -> { |
| | | if (ArrayUtil.isNotEmpty(operLog.getBusinessTypes())) { |
| | | f.in(SysOperLog::getBusinessType, Arrays.asList(operLog.getBusinessTypes())); |
| | | } |
| | | }) |
| | | .eq(operLog.getStatus() != null && operLog.getStatus() > 0, |
| | | SysOperLog::getStatus, operLog.getStatus()) |
| | | .like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName()) |
| | | .apply(StringUtils.isNotEmpty(params.get("beginTime")), |
| | | "date_format(oper_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(StringUtils.isNotEmpty(params.get("endTime")), |
| | | "date_format(oper_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime")) |
| | | .orderByDesc(SysOperLog::getOperId)); |
| | | .like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle()) |
| | | .eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0, |
| | | SysOperLog::getBusinessType, operLog.getBusinessType()) |
| | | .func(f -> { |
| | | if (ArrayUtil.isNotEmpty(operLog.getBusinessTypes())) { |
| | | f.in(SysOperLog::getBusinessType, Arrays.asList(operLog.getBusinessTypes())); |
| | | } |
| | | }) |
| | | .eq(operLog.getStatus() != null && operLog.getStatus() > 0, |
| | | SysOperLog::getStatus, operLog.getStatus()) |
| | | .like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysOperLog::getOperTime, params.get("beginTime"), params.get("endTime")) |
| | | .orderByDesc(SysOperLog::getOperId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.oss.constant.CloudConstant; |
| | | import com.ruoyi.oss.constant.OssConstant; |
| | | import com.ruoyi.oss.factory.OssFactory; |
| | | import com.ruoyi.system.domain.SysOssConfig; |
| | | import com.ruoyi.system.domain.bo.SysOssConfigBo; |
| | | import com.ruoyi.system.domain.vo.SysOssConfigVo; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | |
| | | /** |
| | | * 项ç®å¯å¨æ¶ï¼åå§ååæ°å°ç¼åï¼å è½½é
置类 |
| | | */ |
| | | @PostConstruct |
| | | @Override |
| | | public void init() { |
| | | List<SysOssConfig> list = list(); |
| | | // å è½½OSSåå§åé
ç½® |
| | | for (SysOssConfig config : list) { |
| | | String configKey = config.getConfigKey(); |
| | | if ("0".equals(config.getStatus())) { |
| | | RedisUtils.setCacheObject(CloudConstant.CACHE_CONFIG_KEY, configKey); |
| | | RedisUtils.setCacheObject(OssConstant.CACHE_CONFIG_KEY, configKey); |
| | | } |
| | | setConfigCache(true, config); |
| | | } |
| | | // åå§åOSSå·¥å |
| | | OssFactory.init(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
| | | if (isValid) { |
| | | if (CollUtil.containsAny(ids, CloudConstant.SYSTEM_DATA_IDS)) { |
| | | if (CollUtil.containsAny(ids, OssConstant.SYSTEM_DATA_IDS)) { |
| | | throw new ServiceException("ç³»ç»å
ç½®, ä¸å¯å é¤!"); |
| | | } |
| | | } |
| | |
| | | .set(SysOssConfig::getStatus, "1")); |
| | | row += baseMapper.updateById(sysOssConfig); |
| | | if (row > 0) { |
| | | RedisUtils.setCacheObject(CloudConstant.CACHE_CONFIG_KEY, sysOssConfig.getConfigKey()); |
| | | RedisUtils.setCacheObject(OssConstant.CACHE_CONFIG_KEY, sysOssConfig.getConfigKey()); |
| | | } |
| | | return row; |
| | | } |
| | |
| | | * @return ç¼åé®key |
| | | */ |
| | | private String getCacheKey(String configKey) { |
| | | return CloudConstant.SYS_OSS_KEY + configKey; |
| | | return OssConstant.SYS_OSS_KEY + configKey; |
| | | } |
| | | |
| | | /** |
| | |
| | | RedisUtils.setCacheObject( |
| | | getCacheKey(config.getConfigKey()), |
| | | JsonUtils.toJsonString(config)); |
| | | RedisUtils.publish(CloudConstant.CACHE_CONFIG_KEY, config.getConfigKey(), msg -> { |
| | | RedisUtils.publish(OssConstant.CACHE_CONFIG_KEY, config.getConfigKey(), msg -> { |
| | | log.info("åå¸å·æ°OSSé
ç½® => " + msg); |
| | | }); |
| | | } |
| | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.oss.entity.UploadResult; |
| | | import com.ruoyi.oss.factory.OssFactory; |
| | | import com.ruoyi.oss.service.ICloudStorageStrategy; |
| | | import com.ruoyi.oss.service.IOssStrategy; |
| | | import com.ruoyi.system.domain.SysOss; |
| | | import com.ruoyi.system.domain.bo.SysOssBo; |
| | | import com.ruoyi.system.domain.vo.SysOssVo; |
| | |
| | | public SysOss upload(MultipartFile file) { |
| | | String originalfileName = file.getOriginalFilename(); |
| | | String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length()); |
| | | ICloudStorageStrategy storage = OssFactory.instance(); |
| | | IOssStrategy storage = OssFactory.instance(); |
| | | UploadResult uploadResult; |
| | | try { |
| | | uploadResult = storage.uploadSuffix(file.getBytes(), suffix, file.getContentType()); |
| | |
| | | } |
| | | List<SysOss> list = listByIds(ids); |
| | | for (SysOss sysOss : list) { |
| | | ICloudStorageStrategy storage = OssFactory.instance(sysOss.getService()); |
| | | IOssStrategy storage = OssFactory.instance(sysOss.getService()); |
| | | storage.delete(sysOss.getUrl()); |
| | | } |
| | | return removeByIds(ids); |
| | |
| | | @Override |
| | | public String checkPostNameUnique(SysPost post) { |
| | | Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); |
| | | SysPost info = getOne(new LambdaQueryWrapper<SysPost>() |
| | | .eq(SysPost::getPostName, post.getPostName()).last("limit 1")); |
| | | if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) { |
| | | long count = count(new LambdaQueryWrapper<SysPost>() |
| | | .eq(SysPost::getPostName, post.getPostName()) |
| | | .ne(SysPost::getPostId, postId)); |
| | | if (count > 0) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | @Override |
| | | public String checkPostCodeUnique(SysPost post) { |
| | | Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); |
| | | SysPost info = getOne(new LambdaQueryWrapper<SysPost>() |
| | | .eq(SysPost::getPostCode, post.getPostCode()).last("limit 1")); |
| | | if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) { |
| | | long count = count(new LambdaQueryWrapper<SysPost>() |
| | | .eq(SysPost::getPostCode, post.getPostCode()) |
| | | .ne(SysPost::getPostId, postId)); |
| | | if (count > 0) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | @Override |
| | | public String checkRoleNameUnique(SysRole role) { |
| | | Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); |
| | | SysRole info = getOne(new LambdaQueryWrapper<SysRole>() |
| | | .eq(SysRole::getRoleName, role.getRoleName()).last("limit 1")); |
| | | if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { |
| | | long count = count(new LambdaQueryWrapper<SysRole>() |
| | | .eq(SysRole::getRoleName, role.getRoleName()) |
| | | .ne(SysRole::getRoleId, roleId)); |
| | | if (count > 0) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | @Override |
| | | public String checkRoleKeyUnique(SysRole role) { |
| | | Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); |
| | | SysRole info = getOne(new LambdaQueryWrapper<SysRole>() |
| | | .eq(SysRole::getRoleKey, role.getRoleKey()).last("limit 1")); |
| | | if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { |
| | | long count = count(new LambdaQueryWrapper<SysRole>() |
| | | .eq(SysRole::getRoleKey, role.getRoleKey()) |
| | | .ne(SysRole::getRoleId, roleId)); |
| | | if (count > 0) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | 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.core.service.UserService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser, SysUser> implements ISysUserService { |
| | | public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser, SysUser> implements ISysUserService, UserService { |
| | | |
| | | @Autowired |
| | | private SysRoleMapper roleMapper; |
| | |
| | | */ |
| | | @Override |
| | | public String checkUserNameUnique(String userName) { |
| | | long count = count(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, userName).last("limit 1")); |
| | | long count = count(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, userName)); |
| | | if (count > 0) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | |
| | | @Override |
| | | public String checkPhoneUnique(SysUser user) { |
| | | Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); |
| | | SysUser info = getOne(new LambdaQueryWrapper<SysUser>() |
| | | long count = count(new LambdaQueryWrapper<SysUser>() |
| | | .select(SysUser::getUserId, SysUser::getPhonenumber) |
| | | .eq(SysUser::getPhonenumber, user.getPhonenumber()).last("limit 1")); |
| | | if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { |
| | | .eq(SysUser::getPhonenumber, user.getPhonenumber()) |
| | | .ne(SysUser::getUserId, userId)); |
| | | if (count > 0) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | @Override |
| | | public String checkEmailUnique(SysUser user) { |
| | | Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); |
| | | SysUser info = getOne(new LambdaQueryWrapper<SysUser>() |
| | | long count = count(new LambdaQueryWrapper<SysUser>() |
| | | .select(SysUser::getUserId, SysUser::getEmail) |
| | | .eq(SysUser::getEmail, user.getEmail()).last("limit 1")); |
| | | if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { |
| | | .eq(SysUser::getEmail, user.getEmail()) |
| | | .ne(SysUser::getUserId, userId)); |
| | | if (count > 0) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | javaå
ä½¿ç¨ `.` åå² resource ç®å½ä½¿ç¨ `/` åå² |
| | | <br> |
| | | æ¤æä»¶ç®ç 鲿¢æä»¶å¤¹ç²è¿æ¾ä¸å° `xml` æä»¶ |
| | |
| | | order by m.parent_id, m.order_num |
| | | </select> |
| | | |
| | | <select id="selectMenuListByRoleId" resultType="Integer"> |
| | | <select id="selectMenuListByRoleId" resultType="Long"> |
| | | select m.menu_id |
| | | from sys_menu m |
| | | left join sys_role_menu rm on m.menu_id = rm.menu_id |
| | |
| | | and ur.user_id = #{userId} |
| | | </select> |
| | | |
| | | </mapper> |
| | | </mapper> |
| | |
| | | |
| | | <select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult"> |
| | | <include refid="selectUserVo"/> |
| | | where u.user_name = #{userName} |
| | | where u.del_flag = '0' and u.user_name = #{userName} |
| | | </select> |
| | | |
| | | <select id="selectUserById" parameterType="Long" resultMap="SysUserResult"> |
| | | <include refid="selectUserVo"/> |
| | | where u.user_id = #{userId} |
| | | where u.del_flag = '0' and u.user_id = #{userId} |
| | | </select> |
| | | |
| | | |
| | |
| | | # è¥ä¾ç®¡çç³»ç»/å¼åç¯å¢ |
| | | VUE_APP_BASE_API = '/dev-api' |
| | | |
| | | # åºç¨è®¿é®è·¯å¾ ä¾å¦ä½¿ç¨åç¼ /admin/ |
| | | VUE_APP_CONTEXT_PATH = '/' |
| | | |
| | | # çæ§å°å |
| | | VUE_APP_MONITRO_ADMIN = 'http://localhost:9090/admin/login' |
| | | |
| | |
| | | # ç产ç¯å¢é
ç½® |
| | | ENV = 'production' |
| | | |
| | | # åºç¨è®¿é®è·¯å¾ ä¾å¦ä½¿ç¨åç¼ /admin/ |
| | | VUE_APP_CONTEXT_PATH = '/' |
| | | |
| | | # çæ§å°å |
| | | VUE_APP_MONITRO_ADMIN = '/admin/login' |
| | | |
| | |
| | | # æµè¯ç¯å¢é
ç½® |
| | | ENV = 'staging' |
| | | |
| | | # åºç¨è®¿é®è·¯å¾ ä¾å¦ä½¿ç¨åç¼ /admin/ |
| | | VUE_APP_CONTEXT_PATH = '/' |
| | | |
| | | # çæ§å°å |
| | | VUE_APP_MONITRO_ADMIN = '/admin/login' |
| | | |
| | |
| | | }, |
| | | "dependencies": { |
| | | "@riophae/vue-treeselect": "0.4.0", |
| | | "axios": "0.21.0", |
| | | "axios": "0.24.0", |
| | | "clipboard": "2.0.6", |
| | | "core-js": "3.8.1", |
| | | "core-js": "3.19.1", |
| | | "echarts": "4.9.0", |
| | | "element-ui": "2.15.6", |
| | | "file-saver": "2.0.5", |
| | | "fuse.js": "6.4.3", |
| | | "highlight.js": "9.18.5", |
| | | "js-beautify": "1.13.0", |
| | | "js-cookie": "2.2.1", |
| | | "jsencrypt": "3.0.0-rc.1", |
| | | "js-cookie": "3.0.1", |
| | | "jsencrypt": "3.2.1", |
| | | "nprogress": "0.2.0", |
| | | "quill": "1.3.7", |
| | | "screenfull": "5.0.2", |
| | |
| | | "vue": "2.6.12", |
| | | "vue-count-to": "1.0.13", |
| | | "vue-cropper": "0.5.5", |
| | | "vue-meta": "^2.4.0", |
| | | "vue-meta": "2.4.0", |
| | | "vue-router": "3.4.9", |
| | | "vuedraggable": "2.24.3", |
| | | "vuex": "3.6.0" |
| | |
| | | } |
| | | return request({ |
| | | url: '/login', |
| | | headers: { |
| | | isToken: false |
| | | }, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | |
| | | export function getCodeImg() { |
| | | return request({ |
| | | url: '/captchaImage', |
| | | headers: { |
| | | isToken: false |
| | | }, |
| | | method: 'get', |
| | | timeout: 20000 |
| | | }) |
| | | } |
| | | } |
| | |
| | | method: 'delete' |
| | | }) |
| | | } |
| | | |
| | | // 导åºå²ä½ |
| | | export function exportPost(query) { |
| | | return request({ |
| | | url: '/system/post/export', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | |
| | | <el-breadcrumb class="app-breadcrumb" separator="/"> |
| | | <transition-group name="breadcrumb"> |
| | | <el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path"> |
| | | <span v-if="item.redirect==='noRedirect'||index==levelList.length-1" class="no-redirect">{{ item.meta.title }}</span> |
| | | <span v-if="item.redirect === 'noRedirect' || index == levelList.length - 1" class="no-redirect">{{ item.meta.title }}</span> |
| | | <a v-else @click.prevent="handleLink(item)">{{ item.meta.title }}</a> |
| | | </el-breadcrumb-item> |
| | | </transition-group> |
| | |
| | | },
|
| | | // å³ä¾§å表å
ç´ åå
|
| | | dataChange(data) {
|
| | | for (var item in this.columns) {
|
| | | for (let item in this.columns) {
|
| | | const key = this.columns[item].key;
|
| | | this.columns[item].visible = !data.includes(key);
|
| | | }
|
| | |
| | | <template> |
| | | <div> |
| | | <svg-icon icon-class="question" @click="goto"/> |
| | | <svg-icon icon-class="question" @click="goto" /> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | <template> |
| | | <div> |
| | | <svg-icon icon-class="github" @click="goto"/> |
| | | <svg-icon icon-class="github" @click="goto" /> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | </div> |
| | | <el-dropdown-menu slot="dropdown"> |
| | | <el-dropdown-item v-for="item of sizeOptions" :key="item.value" :disabled="size===item.value" :command="item.value"> |
| | | {{ |
| | | item.label }} |
| | | {{ item.label }} |
| | | </el-dropdown-item> |
| | | </el-dropdown-menu> |
| | | </el-dropdown> |
| | |
| | | type: 'warning' |
| | | }).then(() => { |
| | | this.$store.dispatch('LogOut').then(() => { |
| | | location.href = this.$router.options.base + '/index'; |
| | | location.href = process.env.VUE_APP_CONTEXT_PATH + "index"; |
| | | }) |
| | | }).catch(() => {}); |
| | | } |
| | |
| | | variables() { |
| | | return variables; |
| | | }, |
| | | sideTheme() { |
| | | sideTheme() { |
| | | return this.$store.state.settings.sideTheme |
| | | } |
| | | }, |
| | |
| | | }) |
| | | }, |
| | | refreshSelectedTag(view) { |
| | | this.$store.dispatch('tagsView/delCachedView', view).then(() => { |
| | | const { fullPath } = view |
| | | this.$nextTick(() => { |
| | | this.$router.replace({ |
| | | path: '/redirect' + fullPath |
| | | }) |
| | | }) |
| | | }) |
| | | this.$tab.refreshPage(view); |
| | | }, |
| | | closeSelectedTag(view) { |
| | | this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => { |
| | | this.$tab.closePage(view).then(({ visitedViews }) => { |
| | | if (this.isActive(view)) { |
| | | this.toLastView(visitedViews, view) |
| | | } |
| | | }) |
| | | }, |
| | | closeRightTags() { |
| | | this.$store.dispatch('tagsView/delRightTags', this.selectedTag).then(visitedViews => { |
| | | this.$tab.closeRightPage(this.selectedTag).then(visitedViews => { |
| | | if (!visitedViews.find(i => i.fullPath === this.$route.fullPath)) { |
| | | this.toLastView(visitedViews) |
| | | } |
| | | }) |
| | | }, |
| | | closeLeftTags() { |
| | | this.$store.dispatch('tagsView/delLeftTags', this.selectedTag).then(visitedViews => { |
| | | this.$tab.closeLeftPage(this.selectedTag).then(visitedViews => { |
| | | if (!visitedViews.find(i => i.fullPath === this.$route.fullPath)) { |
| | | this.toLastView(visitedViews) |
| | | } |
| | |
| | | }, |
| | | closeOthersTags() { |
| | | this.$router.push(this.selectedTag).catch(()=>{}); |
| | | this.$store.dispatch('tagsView/delOthersViews', this.selectedTag).then(() => { |
| | | this.$tab.closeOtherPage(this.selectedTag).then(() => { |
| | | this.moveToCurrentTag() |
| | | }) |
| | | }, |
| | | closeAllTags(view) { |
| | | this.$store.dispatch('tagsView/delAllViews').then(({ visitedViews }) => { |
| | | this.$tab.closeAllPage().then(({ visitedViews }) => { |
| | | if (this.affixTags.some(tag => tag.path === this.$route.path)) { |
| | | return |
| | | } |
| | |
| | | } |
| | | |
| | | .hideSidebar .fixed-header { |
| | | width: calc(100% - 54px) |
| | | width: calc(100% - 54px); |
| | | } |
| | | |
| | | .mobile .fixed-header { |
| | |
| | | import App from './App' |
| | | import store from './store' |
| | | import router from './router' |
| | | import directive from './directive' //directive |
| | | import directive from './directive' // directive |
| | | import plugins from './plugins' // plugins |
| | | import { download } from '@/utils/request' |
| | | |
| | | import './assets/icons' // icon |
| | | import './permission' // permission control |
| | |
| | | Vue.prototype.addDateRange = addDateRange |
| | | Vue.prototype.selectDictLabel = selectDictLabel |
| | | Vue.prototype.selectDictLabels = selectDictLabels |
| | | Vue.prototype.download = download |
| | | Vue.prototype.handleTree = handleTree |
| | | |
| | | // å
¨å±ç»ä»¶æè½½ |
| | |
| | | import { saveAs } from 'file-saver' |
| | | import axios from 'axios' |
| | | import { getToken } from '@/utils/auth' |
| | | import { Message } from 'element-ui' |
| | | import { saveAs } from 'file-saver' |
| | | import { getToken } from '@/utils/auth' |
| | | import { blobValidate } from "@/utils/ruoyi"; |
| | | |
| | | const baseURL = process.env.VUE_APP_BASE_API |
| | | |
| | | export default { |
| | | excel(url, params) { |
| | | // getè¯·æ±æ å°paramsåæ° |
| | | if (params) { |
| | | let urlparams = url + '?'; |
| | | for (const propName of Object.keys(params)) { |
| | | const value = params[propName]; |
| | | var part = encodeURIComponent(propName) + "="; |
| | | if (value !== null && typeof(value) !== "undefined") { |
| | | if (typeof value === 'object') { |
| | | for (const key of Object.keys(value)) { |
| | | if (value[key] !== null && typeof (value[key]) !== 'undefined') { |
| | | let params = propName + '[' + key + ']'; |
| | | let subPart = encodeURIComponent(params) + '='; |
| | | urlparams += subPart + encodeURIComponent(value[key]) + '&'; |
| | | } |
| | | } |
| | | } else { |
| | | urlparams += part + encodeURIComponent(value) + "&"; |
| | | } |
| | | } |
| | | } |
| | | urlparams = urlparams.slice(0, -1); |
| | | url = urlparams; |
| | | } |
| | | url = baseURL + url |
| | | axios({ |
| | | method: 'get', |
| | | url: url, |
| | | responseType: 'blob', |
| | | headers: { 'Authorization': 'Bearer ' + getToken() } |
| | | }).then(async (res) => { |
| | | const isLogin = await this.blobValidate(res.data); |
| | | if (isLogin) { |
| | | const blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }) |
| | | this.saveAs(blob, decodeURI(res.headers['download-filename'])) |
| | | } else { |
| | | Message.error('æ æçä¼è¯ï¼æè
ä¼è¯å·²è¿æï¼è¯·éæ°ç»å½ã'); |
| | | } |
| | | }) |
| | | }, |
| | | oss(ossId) { |
| | | var url = baseURL + '/system/oss/download/' + ossId |
| | | axios({ |
| | |
| | | responseType: 'blob', |
| | | headers: { 'Authorization': 'Bearer ' + getToken() } |
| | | }).then(async (res) => { |
| | | const isLogin = await this.blobValidate(res.data); |
| | | const isLogin = await blobValidate(res.data); |
| | | if (isLogin) { |
| | | const blob = new Blob([res.data], { type: 'application/octet-stream' }) |
| | | this.saveAs(blob, decodeURI(res.headers['download-filename'])) |
| | |
| | | responseType: 'blob', |
| | | headers: { 'Authorization': 'Bearer ' + getToken() } |
| | | }).then(async (res) => { |
| | | const isLogin = await this.blobValidate(res.data); |
| | | const isLogin = await blobValidate(res.data); |
| | | if (isLogin) { |
| | | const blob = new Blob([res.data], { type: 'application/zip' }) |
| | | this.saveAs(blob, name) |
| | |
| | | }, |
| | | saveAs(text, name, opts) { |
| | | saveAs(text, name, opts); |
| | | }, |
| | | async blobValidate(data) { |
| | | try { |
| | | const text = await data.text(); |
| | | JSON.parse(text); |
| | | return false; |
| | | } catch (error) { |
| | | return true; |
| | | } |
| | | }, |
| | | } |
| | | } |
| | | |
| | |
| | | import tab from './tab'
|
| | | import auth from './auth'
|
| | | import cache from './cache'
|
| | | import modal from './modal'
|
| | |
| | |
|
| | | export default {
|
| | | install(Vue) {
|
| | | // é¡µç¾æä½
|
| | | Vue.prototype.$tab = tab
|
| | | // 认è¯å¯¹è±¡
|
| | | Vue.prototype.$auth = auth
|
| | | // ç¼å对象
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | import store from '@/store'
|
| | | import router from '@/router';
|
| | |
|
| | | export default {
|
| | | // å·æ°å½åtab页ç¾
|
| | | refreshPage(obj) {
|
| | | const { path, matched } = router.currentRoute;
|
| | | if (obj === undefined) {
|
| | | matched.forEach((m) => {
|
| | | if (m.components && m.components.default && m.components.default.name) {
|
| | | if (!['Layout', 'ParentView'].includes(m.components.default.name)) {
|
| | | obj = { name: m.components.default.name, path: path };
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | | return store.dispatch('tagsView/delCachedView', obj).then(() => {
|
| | | const { path } = obj
|
| | | router.replace({
|
| | | path: '/redirect' + path
|
| | | })
|
| | | })
|
| | | },
|
| | | // å
³éå½åtab页ç¾ï¼æå¼æ°é¡µç¾
|
| | | closeOpenPage(obj) {
|
| | | store.dispatch("tagsView/delView", router.currentRoute);
|
| | | if (obj !== undefined) {
|
| | | return router.push(obj);
|
| | | }
|
| | | },
|
| | | // å
³éæå®tab页ç¾
|
| | | closePage(obj) {
|
| | | if (obj === undefined) {
|
| | | return store.dispatch('tagsView/delView', router.currentRoute).then(({ lastPath }) => {
|
| | | return router.push(lastPath || '/');
|
| | | });
|
| | | }
|
| | | return store.dispatch('tagsView/delView', obj);
|
| | | },
|
| | | // å
³éæætab页ç¾
|
| | | closeAllPage() {
|
| | | return store.dispatch('tagsView/delAllViews');
|
| | | },
|
| | | // å
³é左侧tab页ç¾
|
| | | closeLeftPage(obj) {
|
| | | return store.dispatch('tagsView/delLeftTags', obj || router.currentRoute);
|
| | | },
|
| | | // å
³éå³ä¾§tab页ç¾
|
| | | closeRightPage(obj) {
|
| | | return store.dispatch('tagsView/delRightTags', obj || router.currentRoute);
|
| | | },
|
| | | // å
³éå
¶ä»tab页ç¾
|
| | | closeOtherPage(obj) {
|
| | | return store.dispatch('tagsView/delOthersViews', obj || router.currentRoute);
|
| | | },
|
| | | // æ·»å tab页ç¾
|
| | | openPage(title, url) {
|
| | | var obj = { path: url, meta: { title: title } }
|
| | | store.dispatch('tagsView/addView', obj);
|
| | | return router.push(url);
|
| | | },
|
| | | // ä¿®æ¹tab页ç¾
|
| | | updatePage(obj) {
|
| | | return store.dispatch('tagsView/updateVisitedView', obj);
|
| | | }
|
| | | }
|
| | |
| | | path: 'role/:userId(\\d+)', |
| | | component: (resolve) => require(['@/views/system/user/authRole'], resolve), |
| | | name: 'AuthRole', |
| | | meta: { title: 'åé
è§è²', activeMenu: '/system/user'} |
| | | meta: { title: 'åé
è§è²', activeMenu: '/system/user' } |
| | | } |
| | | ] |
| | | }, |
| | |
| | | path: 'user/:roleId(\\d+)', |
| | | component: (resolve) => require(['@/views/system/role/authUser'], resolve), |
| | | name: 'AuthUser', |
| | | meta: { title: 'åé
ç¨æ·', activeMenu: '/system/role'} |
| | | meta: { title: 'åé
ç¨æ·', activeMenu: '/system/role' } |
| | | } |
| | | ] |
| | | }, |
| | |
| | | path: 'index/:dictId(\\d+)', |
| | | component: (resolve) => require(['@/views/system/dict/data'], resolve), |
| | | name: 'Data', |
| | | meta: { title: 'åå
¸æ°æ®', activeMenu: '/system/dict'} |
| | | meta: { title: 'åå
¸æ°æ®', activeMenu: '/system/dict' } |
| | | } |
| | | ] |
| | | }, |
| | |
| | | ] |
| | | }, |
| | | { |
| | | path: '/monitor/job-log', |
| | | component: Layout, |
| | | hidden: true, |
| | | children: [ |
| | | { |
| | | path: 'index', |
| | | component: (resolve) => require(['@/views/monitor/job/log'], resolve), |
| | | name: 'JobLog', |
| | | meta: { title: 'è°åº¦æ¥å¿', activeMenu: '/monitor/job'} |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | path: '/tool/gen-edit', |
| | | component: Layout, |
| | | hidden: true, |
| | |
| | | path: 'index', |
| | | component: (resolve) => require(['@/views/tool/gen/editTable'], resolve), |
| | | name: 'GenEdit', |
| | | meta: { title: 'ä¿®æ¹çæé
ç½®', activeMenu: '/tool/gen'} |
| | | meta: { title: 'ä¿®æ¹çæé
ç½®', activeMenu: '/tool/gen' } |
| | | } |
| | | ] |
| | | } |
| | | ] |
| | | |
| | | export default new Router({ |
| | | base: "", // 项ç®åç¼ ä¸ publicPath 忥 ä¾å¦ /api |
| | | mode: 'history', // 廿urlä¸ç# |
| | | scrollBehavior: () => ({ y: 0 }), |
| | | routes: constantRoutes |
| | |
| | | import { constantRoutes } from '@/router' |
| | | import { getRouters } from '@/api/menu' |
| | | import Layout from '@/layout/index' |
| | | import ParentView from '@/components/ParentView'; |
| | | import ParentView from '@/components/ParentView' |
| | | import InnerLink from '@/layout/components/InnerLink' |
| | | |
| | | const permission = { |
| | |
| | | // é¡¶é¨å¯¼èªèåé»è®¤æ·»å ç»è®¡æ¥è¡¨æ æåé¦é¡µ |
| | | const index = [{ |
| | | path: 'index', |
| | | meta: { title: 'ç»è®¡æ¥è¡¨', icon: 'dashboard'} |
| | | meta: { title: 'ç»è®¡æ¥è¡¨', icon: 'dashboard' } |
| | | }] |
| | | state.topbarRouters = routes.concat(index); |
| | | }, |
| | |
| | | theme: storageSetting.theme || '#409EFF', |
| | | sideTheme: storageSetting.sideTheme || sideTheme, |
| | | showSettings: showSettings, |
| | | topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav, |
| | | topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav, |
| | | tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView, |
| | | fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader, |
| | | sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo, |
| | |
| | | }, |
| | | ADD_CACHED_VIEW: (state, view) => { |
| | | if (state.cachedViews.includes(view.name)) return |
| | | if (!view.meta.noCache) { |
| | | if (view.meta && !view.meta.noCache) { |
| | | state.cachedViews.push(view.name) |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | |
| | | |
| | | DEL_RIGHT_VIEWS: (state, view) => { |
| | | const index = state.visitedViews.findIndex(v => v.path === view.path) |
| | | if (index === -1) { |
| | |
| | | mergeOptions(options)
|
| | | Vue.mixin({
|
| | | data() {
|
| | | if (this.$options.dicts === undefined || this.$options.dicts === null) {
|
| | | if (this.$options === undefined || this.$options.dicts === undefined || this.$options.dicts === null) {
|
| | | return {}
|
| | | }
|
| | | const dict = new Dict()
|
| | |
| | | */ |
| | | export function formatDate(cellValue) { |
| | | if (cellValue == null || cellValue == "") return ""; |
| | | var date = new Date(cellValue) |
| | | var date = new Date(cellValue) |
| | | var year = date.getFullYear() |
| | | var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1 |
| | | var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() |
| | | var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours() |
| | | var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() |
| | | var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() |
| | | var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours() |
| | | var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() |
| | | var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds() |
| | | return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds |
| | | } |
| | |
| | | ? val => map[val.toLowerCase()] |
| | | : val => map[val] |
| | | } |
| | | |
| | | |
| | | export const exportDefault = 'export default ' |
| | | |
| | | export const beautifierConf = { |
| | |
| | | |
| | | // ä¸å转驼峰 |
| | | export function camelCase(str) { |
| | | return str.replace(/-[a-z]/g, str1 => str1.substr(-1).toUpperCase()) |
| | | return str.replace(/_[a-z]/g, str1 => str1.substr(-1).toUpperCase()) |
| | | } |
| | | |
| | | export function isNumberStr(str) { |
| | | return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str) |
| | | } |
| | | |
| | | |
| | |
| | | import axios from 'axios' |
| | | import { Notification, MessageBox, Message } from 'element-ui' |
| | | import { Notification, MessageBox, Message, Loading } from 'element-ui' |
| | | import store from '@/store' |
| | | import { getToken } from '@/utils/auth' |
| | | import errorCode from '@/utils/errorCode' |
| | | import { tansParams, blobValidate } from "@/utils/ruoyi"; |
| | | import { saveAs } from 'file-saver' |
| | | |
| | | let downloadLoadingInstance; |
| | | |
| | | axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' |
| | | // 对åºå½é
åèµæºæä»¶åç¼ |
| | |
| | | // è¶
æ¶ |
| | | timeout: 10000 |
| | | }) |
| | | |
| | | // requestæ¦æªå¨ |
| | | service.interceptors.request.use(config => { |
| | | // æ¯å¦éè¦è®¾ç½® token |
| | |
| | | } |
| | | // getè¯·æ±æ å°paramsåæ° |
| | | if (config.method === 'get' && config.params) { |
| | | let url = config.url + '?'; |
| | | for (const propName of Object.keys(config.params)) { |
| | | const value = config.params[propName]; |
| | | var part = encodeURIComponent(propName) + "="; |
| | | if (value !== null && typeof(value) !== "undefined") { |
| | | if (typeof value === 'object') { |
| | | for (const key of Object.keys(value)) { |
| | | if (value[key] !== null && typeof (value[key]) !== 'undefined') { |
| | | let params = propName + '[' + key + ']'; |
| | | let subPart = encodeURIComponent(params) + '='; |
| | | url += subPart + encodeURIComponent(value[key]) + '&'; |
| | | } |
| | | } |
| | | } else { |
| | | url += part + encodeURIComponent(value) + "&"; |
| | | } |
| | | } |
| | | } |
| | | let url = config.url + '?' + tansParams(config.params); |
| | | url = url.slice(0, -1); |
| | | config.params = {}; |
| | | config.url = url; |
| | |
| | | const code = res.data.code || 200; |
| | | // è·åéè¯¯ä¿¡æ¯ |
| | | const msg = errorCode[code] || res.data.msg || errorCode['default'] |
| | | // äºè¿å¶æ°æ®åç´æ¥è¿å |
| | | if(res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer'){ |
| | | return res.data |
| | | } |
| | | if (code === 401) { |
| | | MessageBox.confirm('ç»å½ç¶æå·²è¿æï¼æ¨å¯ä»¥ç»§ç»çå¨è¯¥é¡µé¢ï¼æè
éæ°ç»å½', 'ç³»ç»æç¤º', { |
| | | confirmButtonText: 'éæ°ç»å½', |
| | |
| | | } |
| | | ).then(() => { |
| | | store.dispatch('LogOut').then(() => { |
| | | location.href = this.$router.options.base + '/index'; |
| | | location.href = process.env.VUE_APP_CONTEXT_PATH + "index"; |
| | | }) |
| | | }).catch(() => {}); |
| | | return Promise.reject('æ æçä¼è¯ï¼æè
ä¼è¯å·²è¿æï¼è¯·éæ°ç»å½ã') |
| | |
| | | } |
| | | ) |
| | | |
| | | // éç¨ä¸è½½æ¹æ³ |
| | | export function download(url, params, filename) { |
| | | downloadLoadingInstance = Loading.service({ text: "æ£å¨ä¸è½½æ°æ®ï¼è¯·ç¨å", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }) |
| | | return service.post(url, params, { |
| | | transformRequest: [(params) => { return tansParams(params) }], |
| | | headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, |
| | | responseType: 'blob' |
| | | }).then(async (data) => { |
| | | const isLogin = await blobValidate(data); |
| | | if (isLogin) { |
| | | const blob = new Blob([data]) |
| | | saveAs(blob, filename) |
| | | } else { |
| | | Message.error('æ æçä¼è¯ï¼æè
ä¼è¯å·²è¿æï¼è¯·éæ°ç»å½ã'); |
| | | } |
| | | downloadLoadingInstance.close(); |
| | | }).catch((r) => { |
| | | console.error(r) |
| | | Message.error('ä¸è½½æä»¶åºç°é误ï¼è¯·è系管çåï¼') |
| | | downloadLoadingInstance.close(); |
| | | }) |
| | | } |
| | | |
| | | export default service |
| | |
| | | var temp = value.split(currentSeparator); |
| | | Object.keys(value.split(currentSeparator)).some((val) => { |
| | | Object.keys(datas).some((key) => { |
| | | if (datas[key].dictValue == ('' + temp[val])) { |
| | | actions.push(datas[key].dictLabel + currentSeparator); |
| | | if (datas[key].value == ('' + temp[val])) { |
| | | actions.push(datas[key].label + currentSeparator); |
| | | } |
| | | }) |
| | | }) |
| | |
| | | } |
| | | return tree; |
| | | } |
| | | |
| | | /** |
| | | * åæ°å¤ç |
| | | * @param {*} params åæ° |
| | | */ |
| | | export function tansParams(params) { |
| | | let result = '' |
| | | for (const propName of Object.keys(params)) { |
| | | const value = params[propName]; |
| | | var part = encodeURIComponent(propName) + "="; |
| | | if (value !== null && typeof (value) !== "undefined") { |
| | | if (typeof value === 'object') { |
| | | for (const key of Object.keys(value)) { |
| | | if (value[key] !== null && typeof (value[key]) !== 'undefined') { |
| | | let params = propName + '[' + key + ']'; |
| | | var subPart = encodeURIComponent(params) + "="; |
| | | result += subPart + encodeURIComponent(value[key]) + "&"; |
| | | } |
| | | } |
| | | } else { |
| | | result += part + encodeURIComponent(value) + "&"; |
| | | } |
| | | } |
| | | } |
| | | return result |
| | | } |
| | | |
| | | // éªè¯æ¯å¦ä¸ºblobæ ¼å¼ |
| | | export async function blobValidate(data) { |
| | | try { |
| | | const text = await data.text(); |
| | | JSON.parse(text); |
| | | return false; |
| | | } catch (error) { |
| | | return true; |
| | | } |
| | | } |
| | |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="info" |
| | | plain |
| | | icon="el-icon-upload2" |
| | | size="mini" |
| | | @click="handleImport" |
| | | v-hasPermi="['demo:demo:import']" |
| | | >导å
¥(æ ¡éª)</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="warning" |
| | | plain |
| | | icon="el-icon-download" |
| | | size="mini" |
| | | :loading="exportLoading" |
| | | @click="handleExport" |
| | | v-hasPermi="['demo:demo:export']" |
| | | >导åº</el-button> |
| | |
| | | <el-button @click="cancel">å æ¶</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!-- ç¨æ·å¯¼å
¥å¯¹è¯æ¡ --> |
| | | <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body> |
| | | <el-upload |
| | | ref="upload" |
| | | :limit="1" |
| | | accept=".xlsx, .xls" |
| | | :headers="upload.headers" |
| | | :action="upload.url + '?updateSupport=' + upload.updateSupport" |
| | | :disabled="upload.isUploading" |
| | | :on-progress="handleFileUploadProgress" |
| | | :on-success="handleFileSuccess" |
| | | :auto-upload="false" |
| | | drag |
| | | > |
| | | <i class="el-icon-upload"></i> |
| | | <div class="el-upload__text">å°æä»¶æå°æ¤å¤ï¼æ<em>ç¹å»ä¸ä¼ </em></div> |
| | | </el-upload> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="primary" @click="submitFileForm">ç¡® å®</el-button> |
| | | <el-button @click="upload.open = false">å æ¶</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { listDemo, pageDemo, getDemo, delDemo, addDemo, updateDemo } from "@/api/demo/demo"; |
| | | import {getToken} from "@/utils/auth"; |
| | | |
| | | export default { |
| | | name: "Demo", |
| | |
| | | buttonLoading: false, |
| | | // é®ç½©å± |
| | | loading: true, |
| | | // 导åºé®ç½©å± |
| | | exportLoading: false, |
| | | // é䏿°ç» |
| | | ids: [], |
| | | // éå个ç¦ç¨ |
| | |
| | | open: false, |
| | | // å建æ¶é´æ¶é´èå´ |
| | | daterangeCreateTime: [], |
| | | // ç¨æ·å¯¼å
¥åæ° |
| | | upload: { |
| | | // æ¯å¦æ¾ç¤ºå¼¹åºå±ï¼ç¨æ·å¯¼å
¥ï¼ |
| | | open: false, |
| | | // å¼¹åºå±æ é¢ï¼ç¨æ·å¯¼å
¥ï¼ |
| | | title: "", |
| | | // æ¯å¦ç¦ç¨ä¸ä¼ |
| | | isUploading: false, |
| | | // 设置ä¸ä¼ ç请æ±å¤´é¨ |
| | | headers: { Authorization: "Bearer " + getToken() }, |
| | | // ä¸ä¼ çå°å |
| | | url: process.env.VUE_APP_BASE_API + "/demo/demo/importData" |
| | | }, |
| | | // æ¥è¯¢åæ° |
| | | queryParams: { |
| | | pageNum: 1, |
| | |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | | /** 导å
¥æé®æä½ */ |
| | | handleImport() { |
| | | this.upload.title = "ç¨æ·å¯¼å
¥"; |
| | | this.upload.open = true; |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | this.$download.excel('/demo/demo/export', this.queryParams); |
| | | this.download('demo/demo/export', { |
| | | ...this.queryParams |
| | | }, `demo_${new Date().getTime()}.xlsx`) |
| | | }, |
| | | // æä»¶ä¸ä¼ ä¸å¤ç |
| | | handleFileUploadProgress(event, file, fileList) { |
| | | this.upload.isUploading = true; |
| | | }, |
| | | // æä»¶ä¸ä¼ æåå¤ç |
| | | handleFileSuccess(response, file, fileList) { |
| | | this.upload.open = false; |
| | | this.upload.isUploading = false; |
| | | this.$refs.upload.clearFiles(); |
| | | this.$alert(response.msg, "导å
¥ç»æ", { dangerouslyUseHTMLString: true }); |
| | | this.getList(); |
| | | }, |
| | | // æäº¤ä¸ä¼ æä»¶ |
| | | submitFileForm() { |
| | | this.$refs.upload.submit(); |
| | | } |
| | | } |
| | | }; |
| | |
| | | <el-col :sm="24" :lg="12" style="padding-left: 20px"> |
| | | <h2>RuoYi-Vue-Plusåå°ç®¡çæ¡æ¶</h2> |
| | | <p> |
| | | åºäº RuoYi-Vue éæ Mybatis-Plus Lombok Hutool ç便æ·å¼åå·¥å
· éé
éåç¸å
³ä¸å¡ 便äºå¼å å®æä¸ RuoYi-Vue 忥 |
| | | RuoYi-Vue-Plus æ¯åºäº RuoYi-Vue é对 åå¸å¼é群 åºæ¯å级(ä¸å
¼å®¹åæ¡æ¶) |
| | | <br/> |
| | | * å端å¼åæ¡æ¶ VueãElement UI<br/> |
| | | * å端å¼åæ¡æ¶ Spring BootãRedis<br/> |
| | | * å端å¼åæ¡æ¶ Spring Boot<br/> |
| | | * 容卿¡æ¶ Undertow åºäº Netty ç髿§è½å®¹å¨<br/> |
| | | * æéè®¤è¯æ¡æ¶ Spring SecurityãJwtï¼æ¯æå¤ç»ç«¯è®¤è¯ç³»ç»<br/> |
| | | * å
³ç³»æ°æ®åº MySQL éé
8.X<br/> |
| | | * ç¼åæ°æ®åº Redis éé
6.X<br/> |
| | | * æ°æ®åºå¼åæ¡æ¶ Mybatis-Plus å¿«é CRUD å¢å å¼åæç æä»¶åæ¯æåç±»éæ±<br/> |
| | | * ç½ç»æ¡æ¶ FeignãOkHttp3 æ¥å£å管ç HTTP 请æ±<br/> |
| | | * å·¥å
·ç±»æ¡æ¶ HutoolãLombok åå°ä»£ç åä½ å¢å å®å
¨æ§<br/> |
| | | * çæ§æ¡æ¶ spring-boot-admin å
¨æ¹ä½æå¡çæ§<br/> |
| | | * æ ¡éªæ¡æ¶ validation å¢å¼ºæ¥å£å®å
¨æ§ 严谨æ§<br/> |
| | | * ææ¡£æ¡æ¶ knife4j ç¾åæ¥å£ææ¡£<br/> |
| | | * 代ç çæå¨ ä¸é®çæåå端代ç <br/> |
| | | * æéè®¤è¯æ¡æ¶ Spring SecurityãJwt æ¯æå¤ç»ç«¯è®¤è¯ç³»ç»<br/> |
| | | * å
³ç³»æ°æ®åº MySQL éé
8.X æä½ 5.7<br/> |
| | | * ç¼åæ°æ®åº Redis éé
6.X æä½ 4.X<br/> |
| | | * æ°æ®åºæ¡æ¶ Mybatis-Plus å¿«é CRUD å¢å å¼åæç<br/> |
| | | * æ°æ®åºæ¡æ¶ p6spy æ´å¼ºå²ç SQL åæ<br/> |
| | | * 夿°æ®æºæ¡æ¶ dynamic-datasource æ¯æä¸»ä»ä¸å¤ç§ç±»æ°æ®åºå¼æ<br/> |
| | | * Redis客æ·ç«¯ éç¨ Redisson æ§è½æ´å¼º<br/> |
| | | * åºååæ¡æ¶ Jackson ç»ä¸ä½¿ç¨ jackson 髿å¯é <br/> |
| | | * Redis客æ·ç«¯ Redisson æ§è½å¼ºå²ãAPI丰å¯<br/> |
| | | * åå¸å¼éæµ Redisson å
¨å±ã请æ±IPãé群ID å¤ç§éæµ<br/> |
| | | * åå¸å¼é Lock4j 注解éãå·¥å
·é å¤ç§å¤æ ·<br/> |
| | | * åå¸å¼å¹ç Lock4j åºäºåå¸å¼éå®ç°<br/> |
| | | * åå¸å¼æ¥å¿ TLog æ¯æè·è¸ªé¾è·¯æ¥å¿è®°å½ãæ§è½åæãé¾è·¯ææ¥<br/> |
| | | * åå¸å¼ä»»å¡è°åº¦ Xxl-Job 髿§è½ é«å¯é ææ©å±<br/> |
| | | * æä»¶åå¨ Minio æ¬å°åå¨<br/> |
| | | * æä»¶åå¨ ä¸çãé¿éãè
¾è®¯ äºåå¨<br/> |
| | | * çæ§æ¡æ¶ SpringBoot-Admin å
¨æ¹ä½æå¡çæ§<br/> |
| | | * æ ¡éªæ¡æ¶ Validation å¢å¼ºæ¥å£å®å
¨æ§ 严谨æ§<br/> |
| | | * Excelæ¡æ¶ Alibaba EasyExcel æ§è½ä¼å¼ æ©å±æ§å¼º<br/> |
| | | * ææ¡£æ¡æ¶ knife4j ç¾åæ¥å£ææ¡£<br/> |
| | | * å·¥å
·ç±»æ¡æ¶ HutoolãLombok åå°ä»£ç åä½ å¢å å®å
¨æ§<br/> |
| | | * 代ç çæå¨ éé
MPãKnife4jè§èå代ç ä¸é®çæåå端代ç <br/> |
| | | * é¨ç½²æ¹å¼ Docker 容å¨ç¼æ ä¸é®é¨ç½²ä¸å¡é群<br/> |
| | | * æä»¶åå¨ OSS 对象å卿¨¡å æ¯æ(Minioãä¸çãé¿éãè
¾è®¯)<br/> |
| | | * å½é
å SpringMessage Springæ åå½é
åæ¹æ¡<br/> |
| | | </p> |
| | | <p> |
| | | <b>å½åçæ¬:</b> <span>v{{ version }}</span> |
| | |
| | | <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form"> |
| | | <h3 class="title">RuoYi-Vue-Plusåå°ç®¡çç³»ç»</h3> |
| | | <el-form-item prop="username"> |
| | | <el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="è´¦å·"> |
| | | <el-input |
| | | v-model="loginForm.username" |
| | | type="text" |
| | | auto-complete="off" |
| | | placeholder="è´¦å·" |
| | | > |
| | | <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" /> |
| | | </el-input> |
| | | </el-form-item> |
| | |
| | | data() { |
| | | return { |
| | | codeUrl: "", |
| | | cookiePassword: "", |
| | | loginForm: { |
| | | username: "admin", |
| | | password: "admin123", |
| | |
| | | v-model="queryParams.ipaddr" |
| | | placeholder="请è¾å
¥ç»å½å°å" |
| | | clearable |
| | | size="small" |
| | | style="width: 240px;" |
| | | size="small" |
| | | @keyup.enter.native="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | |
| | | v-model="queryParams.userName" |
| | | placeholder="请è¾å
¥ç¨æ·åç§°" |
| | | clearable |
| | | size="small" |
| | | style="width: 240px;" |
| | | size="small" |
| | | @keyup.enter.native="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | |
| | | plain |
| | | icon="el-icon-download" |
| | | size="mini" |
| | | :loading="exportLoading" |
| | | @click="handleExport" |
| | | v-hasPermi="['monitor:logininfor:export']" |
| | | >导åº</el-button> |
| | |
| | | return { |
| | | // é®ç½©å± |
| | | loading: true, |
| | | // 导åºé®ç½©å± |
| | | exportLoading: false, |
| | | // é䏿°ç» |
| | | ids: [], |
| | | // éå¤ä¸ªç¦ç¨ |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | this.$download.excel('/monitor/logininfor/export', this.queryParams); |
| | | this.download('monitor/logininfor/export', { |
| | | ...this.queryParams |
| | | }, `logininfor_${new Date().getTime()}.xlsx`) |
| | | } |
| | | } |
| | | }; |
| | |
| | | v-model="queryParams.title" |
| | | placeholder="请è¾å
¥ç³»ç»æ¨¡å" |
| | | clearable |
| | | style="width: 240px;" |
| | | size="small" |
| | | style="width: 240px;" |
| | | @keyup.enter.native="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | |
| | | v-model="queryParams.operName" |
| | | placeholder="请è¾å
¥æä½äººå" |
| | | clearable |
| | | style="width: 240px;" |
| | | size="small" |
| | | style="width: 240px;" |
| | | @keyup.enter.native="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | |
| | | plain |
| | | icon="el-icon-download" |
| | | size="mini" |
| | | :loading="exportLoading" |
| | | @click="handleExport" |
| | | v-hasPermi="['monitor:operlog:export']" |
| | | >导åº</el-button> |
| | |
| | | return { |
| | | // é®ç½©å± |
| | | loading: true, |
| | | // 导åºé®ç½©å± |
| | | exportLoading: false, |
| | | // é䏿°ç» |
| | | ids: [], |
| | | // éå¤ä¸ªç¦ç¨ |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | this.$download.excel('/monitor/operlog/export', this.queryParams); |
| | | this.download('monitor/operlog/export', { |
| | | ...this.queryParams |
| | | }, `operlog_${new Date().getTime()}.xlsx`) |
| | | } |
| | | } |
| | | }; |
| | |
| | | register(this.registerForm).then(res => { |
| | | const username = this.registerForm.username; |
| | | this.$alert("<font color='red'>æåä½ ï¼æ¨çè´¦å· " + username + " 注åæåï¼</font>", 'ç³»ç»æç¤º', { |
| | | dangerouslyUseHTMLString: true |
| | | dangerouslyUseHTMLString: true, |
| | | type: 'success' |
| | | }).then(() => { |
| | | this.$router.push("/login"); |
| | | }).catch(() => {}); |
| | |
| | | plain |
| | | icon="el-icon-download" |
| | | size="mini" |
| | | :loading="exportLoading" |
| | | @click="handleExport" |
| | | v-hasPermi="['system:config:export']" |
| | | >导åº</el-button> |
| | |
| | | return { |
| | | // é®ç½©å± |
| | | loading: true, |
| | | // 导åºé®ç½©å± |
| | | exportLoading: false, |
| | | // é䏿°ç» |
| | | ids: [], |
| | | // éå个ç¦ç¨ |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | this.$download.excel('/system/config/export', this.queryParams); |
| | | this.download('system/config/export', { |
| | | ...this.queryParams |
| | | }, `config_${new Date().getTime()}.xlsx`) |
| | | }, |
| | | /** å·æ°ç¼åæé®æä½ */ |
| | | handleRefreshCache() { |
| | |
| | | isExpandAll: true, |
| | | // éæ°æ¸²æè¡¨æ ¼ç¶æ |
| | | refreshTable: true, |
| | | // æ¯å¦å±å¼ |
| | | expand: false, |
| | | // æ¥è¯¢åæ° |
| | | queryParams: { |
| | | deptName: undefined, |
| | |
| | | this.open = true; |
| | | this.title = "æ·»å é¨é¨"; |
| | | listDept().then(response => { |
| | | this.deptOptions = this.handleTree(response.data, "deptId"); |
| | | this.deptOptions = this.handleTree(response.data, "deptId"); |
| | | }); |
| | | }, |
| | | /** å±å¼/æå æä½ */ |
| | |
| | | this.title = "ä¿®æ¹é¨é¨"; |
| | | }); |
| | | listDeptExcludeChild(row.deptId).then(response => { |
| | | this.deptOptions = this.handleTree(response.data, "deptId"); |
| | | this.deptOptions = this.handleTree(response.data, "deptId"); |
| | | }); |
| | | }, |
| | | /** æäº¤æé® */ |
| | |
| | | plain |
| | | icon="el-icon-download" |
| | | size="mini" |
| | | :loading="exportLoading" |
| | | @click="handleExport" |
| | | v-hasPermi="['system:dict: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> |
| | |
| | | return { |
| | | // é®ç½©å± |
| | | loading: true, |
| | | // 导åºé®ç½©å± |
| | | exportLoading: false, |
| | | // é䏿°ç» |
| | | ids: [], |
| | | // éå个ç¦ç¨ |
| | |
| | | this.queryParams.pageNum = 1; |
| | | this.getList(); |
| | | }, |
| | | /** è¿åæé®æä½ */ |
| | | handleClose() { |
| | | const obj = { path: "/system/dict" }; |
| | | this.$tab.closeOpenPage(obj); |
| | | }, |
| | | /** éç½®æé®æä½ */ |
| | | resetQuery() { |
| | | this.resetForm("queryForm"); |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | this.$download.excel('/system/dict/data/export', this.queryParams); |
| | | this.download('system/dict/data/export', { |
| | | ...this.queryParams |
| | | }, `data_${new Date().getTime()}.xlsx`) |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | </script> |
| | |
| | | plain |
| | | icon="el-icon-download" |
| | | size="mini" |
| | | :loading="exportLoading" |
| | | @click="handleExport" |
| | | v-hasPermi="['system:dict:export']" |
| | | >导åº</el-button> |
| | |
| | | return { |
| | | // é®ç½©å± |
| | | loading: true, |
| | | // 导åºé®ç½©å± |
| | | exportLoading: false, |
| | | // é䏿°ç» |
| | | ids: [], |
| | | // éå个ç¦ç¨ |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | this.$download.excel('/system/dict/type/export', this.queryParams); |
| | | this.download('system/dict/type/export', { |
| | | ...this.queryParams |
| | | }, `type_${new Date().getTime()}.xlsx`) |
| | | }, |
| | | /** å·æ°ç¼åæé®æä½ */ |
| | | handleRefreshCache() { |
| | |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | </script> |
| | |
| | | </el-table-column> |
| | | <el-table-column label="æä½" align="center" class-name="small-padding fixed-width"> |
| | | <template slot-scope="scope"> |
| | | <el-button size="mini" |
| | | <el-button |
| | | size="mini" |
| | | type="text" |
| | | icon="el-icon-edit" |
| | | @click="handleUpdate(scope.row)" |
| | |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item v-if="form.menuType != 'F'" label="èå徿 "> |
| | | <el-col :span="24" v-if="form.menuType != 'F'"> |
| | | <el-form-item label="èå徿 "> |
| | | <el-popover |
| | | placement="bottom-start" |
| | | width="460" |
| | |
| | | <el-input-number v-model="form.orderNum" controls-position="right" :min="0" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.menuType != 'F'"> |
| | | <el-col :span="12" v-if="form.menuType != 'F'"> |
| | | <el-form-item> |
| | | <span slot="label"> |
| | | <el-tooltip content="éæ©æ¯å¤é¾åè·¯ç±å°åéè¦ä»¥`http(s)://`å¼å¤´" placement="top"> |
| | | <i class="el-icon-question"></i> |
| | |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.menuType != 'F'" prop="path"> |
| | | <el-col :span="12" v-if="form.menuType != 'F'"> |
| | | <el-form-item prop="path"> |
| | | <span slot="label"> |
| | | <el-tooltip content="访é®çè·¯ç±å°åï¼å¦ï¼`user`ï¼å¦å¤ç½å°åéå
é¾è®¿é®å以`http(s)://`å¼å¤´" placement="top"> |
| | | <i class="el-icon-question"></i> |
| | |
| | | <el-input v-model="form.component" placeholder="请è¾å
¥ç»ä»¶è·¯å¾" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.menuType != 'M'"> |
| | | <el-col :span="12" v-if="form.menuType != 'M'"> |
| | | <el-form-item> |
| | | <el-input v-model="form.perms" placeholder="请è¾å
¥æéæ è¯" maxlength="100" /> |
| | | <span slot="label"> |
| | | <el-tooltip content="æ§å¶å¨ä¸å®ä¹çæéå符ï¼å¦ï¼@PreAuthorize(`@ss.hasPermi('system:user:list')`)" placement="top"> |
| | |
| | | </span> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.menuType == 'C'"> |
| | | <el-col :span="12" v-if="form.menuType == 'C'"> |
| | | <el-form-item> |
| | | <el-input v-model="form.query" placeholder="请è¾å
¥è·¯ç±åæ°" maxlength="255" /> |
| | | <span slot="label"> |
| | | <el-tooltip content='访é®è·¯ç±çé»è®¤ä¼ éåæ°ï¼å¦ï¼`{"id": 1, "name": "ry"}`' placement="top"> |
| | |
| | | </span> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.menuType == 'C'"> |
| | | <el-col :span="12" v-if="form.menuType == 'C'"> |
| | | <el-form-item> |
| | | <span slot="label"> |
| | | <el-tooltip content="éæ©æ¯åä¼è¢«`keep-alive`ç¼åï¼éè¦å¹é
ç»ä»¶ç`name`åå°åä¿æä¸è´" placement="top"> |
| | | <i class="el-icon-question"></i> |
| | |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.menuType != 'F'"> |
| | | <el-col :span="12" v-if="form.menuType != 'F'"> |
| | | <el-form-item> |
| | | <span slot="label"> |
| | | <el-tooltip content="éæ©éèåè·¯ç±å°ä¸ä¼åºç°å¨ä¾§è¾¹æ ï¼ä½ä»ç¶å¯ä»¥è®¿é®" placement="top"> |
| | | <i class="el-icon-question"></i> |
| | |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.menuType != 'F'"> |
| | | <el-col :span="12" v-if="form.menuType != 'F'"> |
| | | <el-form-item> |
| | | <span slot="label"> |
| | | <el-tooltip content="éæ©åç¨åè·¯ç±å°ä¸ä¼åºç°å¨ä¾§è¾¹æ ï¼ä¹ä¸è½è¢«è®¿é®" placement="top"> |
| | | <i class="el-icon-question"></i> |
| | |
| | | plain |
| | | icon="el-icon-download" |
| | | size="mini" |
| | | :loading="exportLoading" |
| | | @click="handleExport" |
| | | v-hasPermi="['system:post:export']" |
| | | >导åº</el-button> |
| | |
| | | return { |
| | | // é®ç½©å± |
| | | loading: true, |
| | | // 导åºé®ç½©å± |
| | | exportLoading: false, |
| | | // é䏿°ç» |
| | | ids: [], |
| | | // éå个ç¦ç¨ |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | this.$download.excel('/system/post/export', this.queryParams); |
| | | this.download('system/post/export', { |
| | | ...this.queryParams |
| | | }, `post_${new Date().getTime()}.xlsx`) |
| | | } |
| | | } |
| | | }; |
| | |
| | | },
|
| | | // è¿åæé®
|
| | | handleClose() {
|
| | | this.$store.dispatch("tagsView/delView", this.$route);
|
| | | this.$router.push({ path: "/system/role" });
|
| | | const obj = { path: "/system/role" };
|
| | | this.$tab.closeOpenPage(obj);
|
| | | },
|
| | | /** æç´¢æé®æä½ */
|
| | | handleQuery() {
|
| | |
| | | plain |
| | | icon="el-icon-download" |
| | | size="mini" |
| | | :loading="exportLoading" |
| | | @click="handleExport" |
| | | v-hasPermi="['system:role:export']" |
| | | >导åº</el-button> |
| | |
| | | return { |
| | | // é®ç½©å± |
| | | loading: true, |
| | | // 导åºé®ç½©å± |
| | | exportLoading: false, |
| | | // é䏿°ç» |
| | | ids: [], |
| | | // éå个ç¦ç¨ |
| | |
| | | /** æ¥è¯¢è§è²å表 */ |
| | | getList() { |
| | | this.loading = true; |
| | | listRole(this.addDateRange(this.queryParams, this.dateRange)).then( |
| | | response => { |
| | | listRole(this.addDateRange(this.queryParams, this.dateRange)).then(response => { |
| | | this.roleList = response.rows; |
| | | this.total = response.total; |
| | | this.loading = false; |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | this.$download.excel('/system/role/export', this.queryParams); |
| | | this.download('system/role/export', { |
| | | ...this.queryParams |
| | | }, `role_${new Date().getTime()}.xlsx`) |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | </script> |
| | |
| | | handleSelectUser() {
|
| | | const roleId = this.queryParams.roleId;
|
| | | const userIds = this.userIds.join(",");
|
| | | if (userIds == "") {
|
| | | this.$modal.msgError("è¯·éæ©è¦åé
çç¨æ·");
|
| | | return;
|
| | | }
|
| | | authUserSelectAll({ roleId: roleId, userIds: userIds }).then(res => {
|
| | | this.$modal.msgSuccess(res.msg);
|
| | | if (res.code === 200) {
|
| | |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | |
| | | <pagination v-show="total>0" :total="total" :page.sync="pageNum" :limit.sync="pageSize" /> |
| | | |
| | | <el-form label-width="100px"> |
| | |
| | | }, |
| | | /** å
³éæé® */ |
| | | close() { |
| | | this.$store.dispatch("tagsView/delView", this.$route); |
| | | this.$router.push({ path: "/system/user" }); |
| | | const obj = { path: "/system/user" }; |
| | | this.$tab.closeOpenPage(obj); |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | </script> |
| | |
| | | plain |
| | | icon="el-icon-download" |
| | | size="mini" |
| | | :loading="exportLoading" |
| | | @click="handleExport" |
| | | v-hasPermi="['system:user:export']" |
| | | >导åº</el-button> |
| | |
| | | </el-col> |
| | | </el-row> |
| | | |
| | | <!-- æ·»å æä¿®æ¹åæ°é
ç½®å¯¹è¯æ¡ --> |
| | | <!-- æ·»å æä¿®æ¹ç¨æ·é
ç½®å¯¹è¯æ¡ --> |
| | | <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body> |
| | | <el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
| | | <el-row> |
| | |
| | | return { |
| | | // é®ç½©å± |
| | | loading: true, |
| | | // 导åºé®ç½©å± |
| | | exportLoading: false, |
| | | // é䏿°ç» |
| | | ids: [], |
| | | // éå个ç¦ç¨ |
| | |
| | | }, |
| | | /** å¯¼åºæé®æä½ */ |
| | | handleExport() { |
| | | this.$download.excel('/system/user/export', this.queryParams); |
| | | this.download('system/user/export', { |
| | | ...this.queryParams |
| | | }, `user_${new Date().getTime()}.xlsx`) |
| | | }, |
| | | /** 导å
¥æé®æä½ */ |
| | | handleImport() { |
| | |
| | | }, |
| | | /** ä¸è½½æ¨¡æ¿æä½ */ |
| | | importTemplate() { |
| | | this.$download.excel('/system/user/importTemplate'); |
| | | this.download('system/user/importTemplate', { |
| | | }, `user_template_${new Date().getTime()}.xlsx`) |
| | | }, |
| | | // æä»¶ä¸ä¼ ä¸å¤ç |
| | | handleFileUploadProgress(event, file, fileList) { |
| | |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | </script> |
| | |
| | | } |
| | | }; |
| | | return { |
| | | test: "1test", |
| | | user: { |
| | | oldPassword: undefined, |
| | | newPassword: undefined, |
| | |
| | | submit() { |
| | | this.$refs["form"].validate(valid => { |
| | | if (valid) { |
| | | updateUserPwd(this.user.oldPassword, this.user.newPassword).then( |
| | | response => { |
| | | this.$modal.msgSuccess("ä¿®æ¹æå"); |
| | | } |
| | | ); |
| | | updateUserPwd(this.user.oldPassword, this.user.newPassword).then(response => { |
| | | this.$modal.msgSuccess("ä¿®æ¹æå"); |
| | | }); |
| | | } |
| | | }); |
| | | }, |
| | | close() { |
| | | this.$store.dispatch("tagsView/delView", this.$route); |
| | | this.$router.push({ path: "/index" }); |
| | | this.$tab.closePage(); |
| | | } |
| | | } |
| | | }; |
| | |
| | | <template> |
| | | <div> |
| | | <div class="user-info-head" @click="editCropper()"><img v-bind:src="options.img" title="ç¹å»ä¸ä¼ 头å" class="img-circle img-lg" /></div> |
| | | <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @opened="modalOpened" @close="closeDialog()"> |
| | | <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @opened="modalOpened" @close="closeDialog"> |
| | | <el-row> |
| | | <el-col :xs="24" :md="12" :style="{height: '350px'}"> |
| | | <vue-cropper |
| | |
| | | // å
³éçªå£ |
| | | closeDialog() { |
| | | this.options.img = store.getters.avatar |
| | | this.visible = false; |
| | | this.visible = false; |
| | | } |
| | | } |
| | | }; |
| | |
| | | line-height: 110px; |
| | | border-radius: 50%; |
| | | } |
| | | </style> |
| | | </style> |
| | |
| | | <el-form ref="form" :model="user" :rules="rules" label-width="80px"> |
| | | <el-form-item label="ç¨æ·æµç§°" prop="nickName"> |
| | | <el-input v-model="user.nickName" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-form-item> |
| | | <el-form-item label="ææºå·ç " prop="phonenumber"> |
| | | <el-input v-model="user.phonenumber" maxlength="11" /> |
| | | </el-form-item> |
| | |
| | | }); |
| | | }, |
| | | close() { |
| | | this.$store.dispatch("tagsView/delView", this.$route); |
| | | this.$router.push({ path: "/index" }); |
| | | this.$tab.closePage(); |
| | | } |
| | | } |
| | | }; |
| | |
| | | }, |
| | | /** å
³éæé® */ |
| | | close() { |
| | | this.$store.dispatch("tagsView/delView", this.$route); |
| | | this.$router.push({ path: "/tool/gen", query: { t: Date.now(), pageNum: this.$route.query.pageNum } }) |
| | | const obj = { path: "/tool/gen", query: { t: Date.now(), pageNum: this.$route.query.pageNum } }; |
| | | this.$tab.closeOpenPage(obj); |
| | | } |
| | | }, |
| | | mounted() { |
| | |
| | | // é¨ç½²ç产ç¯å¢åå¼åç¯å¢ä¸çURLã |
| | | // é»è®¤æ
åµä¸ï¼Vue CLI ä¼åè®¾ä½ çåºç¨æ¯è¢«é¨ç½²å¨ä¸ä¸ªååçæ ¹è·¯å¾ä¸ |
| | | // ä¾å¦ https://www.ruoyi.vip/ã妿åºç¨è¢«é¨ç½²å¨ä¸ä¸ªåè·¯å¾ä¸ï¼ä½ å°±éè¦ç¨è¿ä¸ªé项æå®è¿ä¸ªåè·¯å¾ãä¾å¦ï¼å¦æä½ çåºç¨è¢«é¨ç½²å¨ https://www.ruoyi.vip/admin/ï¼å设置 baseUrl 为 /admin/ã |
| | | // 设置åºè·¯å¾åèææ¡£: http://doc.ruoyi.vip/ruoyi-vue/document/qdsc.html#åºç¨è·¯å¾ |
| | | publicPath: process.env.NODE_ENV === "production" ? "/" : "/", |
| | | publicPath: process.env.VUE_APP_CONTEXT_PATH, |
| | | // å¨npm run build æ yarn build æ¶ ï¼çææä»¶çç®å½åç§°ï¼è¦åbaseUrlçç产ç¯å¢è·¯å¾ä¸è´ï¼ï¼é»è®¤distï¼ |
| | | outputDir: 'dist', |
| | | // ç¨äºæ¾ç½®çæçéæèµæº (jsãcssãimgãfonts) çï¼ï¼é¡¹ç®æå
ä¹åï¼éæèµæºä¼æ¾å¨è¿ä¸ªæä»¶å¤¹ä¸ï¼ |
| | |
| | | @echo off |
| | | |
| | | rem jarƽ��Ŀ¼ |
| | | rem jar平级ç®å½ |
| | | set AppName=ruoyi-admin.jar |
| | | |
| | | rem JVM���� |
| | | rem JVMåæ° |
| | | set JVM_OPTS="-Dname=%AppName% -Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC" |
| | | |
| | | |
| | | ECHO. |
| | | ECHO. [1] ����%AppName% |
| | | ECHO. [2] �ر�%AppName% |
| | | ECHO. [3] ����%AppName% |
| | | ECHO. [4] ����״̬ %AppName% |
| | | ECHO. [5] �� �� |
| | | ECHO. [1] å¯å¨%AppName% |
| | | ECHO. [2] å
³é%AppName% |
| | | ECHO. [3] éå¯%AppName% |
| | | ECHO. [4] å¯å¨ç¶æ %AppName% |
| | | ECHO. [5] é åº |
| | | ECHO. |
| | | |
| | | ECHO.������ѡ����Ŀ�����: |
| | | ECHO.请è¾å
¥éæ©é¡¹ç®çåºå·: |
| | | set /p ID= |
| | | IF "%id%"=="1" GOTO start |
| | | IF "%id%"=="2" GOTO stop |
| | |
| | | |
| | | start javaw %JAVA_OPTS% -jar %AppName% |
| | | |
| | | echo starting���� |
| | | echo startingâ¦â¦ |
| | | echo Start %AppName% success... |
| | | goto:eof |
| | | |
| | | rem ����stopͨ��jps�������pid���������� |
| | | rem 彿°stopéè¿jpså½ä»¤æ¥æ¾pidå¹¶ç»æè¿ç¨ |
| | | :stop |
| | | for /f "usebackq tokens=1-2" %%a in (`jps -l ^| findstr %AppName%`) do ( |
| | | set pid=%%a |
| | |
| | | if not defined pid (echo process %AppName% does not exists) else ( |
| | | echo prepare to kill %image_name% |
| | | echo start kill %pid% ... |
| | | rem ���ݽ���ID��kill���� |
| | | rem æ ¹æ®è¿ç¨IDï¼killè¿ç¨ |
| | | taskkill /f /pid %pid% |
| | | ) |
| | | goto:eof |
| | |
| | | |
| | | services: |
| | | mysql: |
| | | image: mysql:8.0.24 |
| | | image: mysql:8.0.27 |
| | | container_name: mysql |
| | | environment: |
| | | # æ¶åºä¸æµ· |
| | |
| | | ipv4_address: 172.30.0.36 |
| | | |
| | | nginx-web: |
| | | # 妿éè¦æå®çæ¬ å°±æ latest æ¢æçæ¬å· |
| | | image: nginx:latest |
| | | image: nginx:1.21.3 |
| | | container_name: nginx-web |
| | | environment: |
| | | # æ¶åºä¸æµ· |
| | |
| | | - ruoyi_net |
| | | |
| | | redis: |
| | | image: redis:6.2.1 |
| | | image: redis:6.2.6 |
| | | container_name: redis |
| | | ports: |
| | | - 6379:6379 |
| | |
| | | # é
ç½®æä»¶ |
| | | - /docker/redis/conf:/redis/config:rw |
| | | # æ°æ®æä»¶ |
| | | - /docker/redis/data:/redis/data:rw |
| | | command: "redis-server /redis/config/redis.conf --appendonly yes" |
| | | - /docker/redis/data/:/redis/data/:rw |
| | | command: "redis-server /redis/config/redis.conf" |
| | | privileged: true |
| | | restart: always |
| | | networks: |
| | |
| | | ipv4_address: 172.30.0.48 |
| | | |
| | | minio: |
| | | image: minio/minio:RELEASE.2021-07-08T01-15-01Z |
| | | image: minio/minio:RELEASE.2021-10-27T16-29-42Z |
| | | container_name: minio |
| | | ports: |
| | | # api ç«¯å£ |
| | |
| | | # redis å¯ç |
| | | # requirepass 123456 |
| | | # requirepass ruoyi123 |
| | | |
| | | # é
ç½®æä¹
åæä»¶åå¨è·¯å¾ |
| | | dir /redis/data |
| | | # é
ç½®rdb |
| | | # 15åéå
æè³å°1个keyè¢«æ´æ¹åè¿è¡å¿«ç
§ |
| | | save 900 1 |
| | | # 5åéå
æè³å°10个keyè¢«æ´æ¹åè¿è¡å¿«ç
§ |
| | | save 300 10 |
| | | # 1åéå
æè³å°10000个keyè¢«æ´æ¹åè¿è¡å¿«ç
§ |
| | | save 60 10000 |
| | | # å¼å¯å缩 |
| | | rdbcompression yes |
| | | # rdbæä»¶å ç¨é»è®¤çå³å¯ |
| | | dbfilename dump.rdb |
| | | |
| | | # å¼å¯aof |
| | | appendonly yes |
| | | # æä»¶å |
| | | appendfilename "appendonly.aof" |
| | | # æä¹
åçç¥,no:ä¸åæ¥,everysec:æ¯ç§ä¸æ¬¡,always:æ»æ¯åæ¥,é度æ¯è¾æ
¢ |
| | | # appendfsync always |
| | | appendfsync everysec |
| | | # appendfsync no |
| | |
| | | insert into sys_menu values('107', 'éç¥å
¬å', '1', '8', 'notice', 'system/notice/index', '', 1, 0, 'C', '0', '0', 'system:notice:list', 'message', 'admin', sysdate(), '', null, 'éç¥å
¬åèå'); |
| | | insert into sys_menu values('108', 'æ¥å¿ç®¡ç', '1', '9', 'log', '', '', 1, 0, 'M', '0', '0', '', 'log', 'admin', sysdate(), '', null, 'æ¥å¿ç®¡çèå'); |
| | | insert into sys_menu values('109', 'å¨çº¿ç¨æ·', '2', '1', 'online', 'monitor/online/index', '', 1, 0, 'C', '0', '0', 'monitor:online:list', 'online', 'admin', sysdate(), '', null, 'å¨çº¿ç¨æ·èå'); |
| | | # insert into sys_menu values('110', '宿¶ä»»å¡', '2', '2', 'job', 'monitor/job/index', '', 1, 0, 'C', '0', '0', 'monitor:job:list', 'job', 'admin', sysdate(), '', null, '宿¶ä»»å¡èå'); |
| | | insert into sys_menu values('111', 'æ°æ®çæ§', '2', '3', 'druid', 'monitor/druid/index', '', 1, 0, 'C', '0', '0', 'monitor:druid:list', 'druid', 'admin', sysdate(), '', null, 'æ°æ®çæ§èå'); |
| | | # insert into sys_menu values('112', 'æå¡çæ§', '2', '4', 'server', 'monitor/server/index', '', 1, 0, 'C', '0', '0', 'monitor:server:list', 'server', 'admin', sysdate(), '', null, 'æå¡çæ§èå'); |
| | | insert into sys_menu values('113', 'ç¼åçæ§', '2', '5', 'cache', 'monitor/cache/index', '', 1, 0, 'C', '0', '0', 'monitor:cache:list', 'redis', 'admin', sysdate(), '', null, 'ç¼åçæ§èå'); |
| | | insert into sys_menu values('114', '表åæå»º', '3', '1', 'build', 'tool/build/index', '', 1, 0, 'C', '0', '0', 'tool:build:list', 'build', 'admin', sysdate(), '', null, '表åæå»ºèå'); |
| | | insert into sys_menu values('115', '代ç çæ', '3', '2', 'gen', 'tool/gen/index', '', 1, 0, 'C', '0', '0', 'tool:gen:list', 'code', 'admin', sysdate(), '', null, '代ç çæèå'); |
| | |
| | | insert into sys_menu values('1046', 'å¨çº¿æ¥è¯¢', '109', '1', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:online:query', '#', 'admin', sysdate(), '', null, ''); |
| | | insert into sys_menu values('1047', 'æ¹é强é', '109', '2', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:online:batchLogout', '#', 'admin', sysdate(), '', null, ''); |
| | | insert into sys_menu values('1048', 'åæ¡å¼ºé', '109', '3', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:online:forceLogout', '#', 'admin', sysdate(), '', null, ''); |
| | | -- 宿¶ä»»å¡æé® |
| | | # insert into sys_menu values('1049', '任塿¥è¯¢', '110', '1', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:query', '#', 'admin', sysdate(), '', null, ''); |
| | | # insert into sys_menu values('1050', '任塿°å¢', '110', '2', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:add', '#', 'admin', sysdate(), '', null, ''); |
| | | # insert into sys_menu values('1051', 'ä»»å¡ä¿®æ¹', '110', '3', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:edit', '#', 'admin', sysdate(), '', null, ''); |
| | | # insert into sys_menu values('1052', 'ä»»å¡å é¤', '110', '4', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:remove', '#', 'admin', sysdate(), '', null, ''); |
| | | # insert into sys_menu values('1053', 'ç¶æä¿®æ¹', '110', '5', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:changeStatus', '#', 'admin', sysdate(), '', null, ''); |
| | | # insert into sys_menu values('1054', 'ä»»å¡å¯¼åº', '110', '7', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:export', '#', 'admin', sysdate(), '', null, ''); |
| | | -- 代ç çææé® |
| | | insert into sys_menu values('1055', 'çææ¥è¯¢', '115', '1', '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:query', '#', 'admin', sysdate(), '', null, ''); |
| | | insert into sys_menu values('1056', 'çæä¿®æ¹', '115', '2', '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:edit', '#', 'admin', sysdate(), '', null, ''); |
| | |
| | | insert into sys_role_menu values ('2', '1046'); |
| | | insert into sys_role_menu values ('2', '1047'); |
| | | insert into sys_role_menu values ('2', '1048'); |
| | | insert into sys_role_menu values ('2', '1049'); |
| | | insert into sys_role_menu values ('2', '1050'); |
| | | insert into sys_role_menu values ('2', '1051'); |
| | | insert into sys_role_menu values ('2', '1052'); |
| | | insert into sys_role_menu values ('2', '1053'); |
| | | insert into sys_role_menu values ('2', '1054'); |
| | | insert into sys_role_menu values ('2', '1055'); |
| | | insert into sys_role_menu values ('2', '1056'); |
| | | insert into sys_role_menu values ('2', '1057'); |
| | |
| | | insert into sys_dict_type values(1, 'ç¨æ·æ§å«', 'sys_user_sex', '0', 'admin', sysdate(), '', null, 'ç¨æ·æ§å«å表'); |
| | | insert into sys_dict_type values(2, 'èåç¶æ', 'sys_show_hide', '0', 'admin', sysdate(), '', null, 'èåç¶æå表'); |
| | | insert into sys_dict_type values(3, 'ç³»ç»å¼å
³', 'sys_normal_disable', '0', 'admin', sysdate(), '', null, 'ç³»ç»å¼å
³å表'); |
| | | insert into sys_dict_type values(4, 'ä»»å¡ç¶æ', 'sys_job_status', '0', 'admin', sysdate(), '', null, 'ä»»å¡ç¶æå表'); |
| | | insert into sys_dict_type values(5, 'ä»»å¡åç»', 'sys_job_group', '0', 'admin', sysdate(), '', null, 'ä»»å¡åç»å表'); |
| | | insert into sys_dict_type values(6, 'ç³»ç»æ¯å¦', 'sys_yes_no', '0', 'admin', sysdate(), '', null, 'ç³»ç»æ¯å¦å表'); |
| | | insert into sys_dict_type values(7, 'éç¥ç±»å', 'sys_notice_type', '0', 'admin', sysdate(), '', null, 'éç¥ç±»åå表'); |
| | | insert into sys_dict_type values(8, 'éç¥ç¶æ', 'sys_notice_status', '0', 'admin', sysdate(), '', null, 'éç¥ç¶æå表'); |
| | |
| | | insert into sys_dict_data values(5, 2, 'éè', '1', 'sys_show_hide', '', 'danger', 'N', '0', 'admin', sysdate(), '', null, 'éèèå'); |
| | | insert into sys_dict_data values(6, 1, 'æ£å¸¸', '0', 'sys_normal_disable', '', 'primary', 'Y', '0', 'admin', sysdate(), '', null, 'æ£å¸¸ç¶æ'); |
| | | insert into sys_dict_data values(7, 2, 'åç¨', '1', 'sys_normal_disable', '', 'danger', 'N', '0', 'admin', sysdate(), '', null, 'åç¨ç¶æ'); |
| | | insert into sys_dict_data values(8, 1, 'æ£å¸¸', '0', 'sys_job_status', '', 'primary', 'Y', '0', 'admin', sysdate(), '', null, 'æ£å¸¸ç¶æ'); |
| | | insert into sys_dict_data values(9, 2, 'æå', '1', 'sys_job_status', '', 'danger', 'N', '0', 'admin', sysdate(), '', null, 'åç¨ç¶æ'); |
| | | insert into sys_dict_data values(10, 1, 'é»è®¤', 'DEFAULT', 'sys_job_group', '', '', 'Y', '0', 'admin', sysdate(), '', null, 'é»è®¤åç»'); |
| | | insert into sys_dict_data values(11, 2, 'ç³»ç»', 'SYSTEM', 'sys_job_group', '', '', 'N', '0', 'admin', sysdate(), '', null, 'ç³»ç»åç»'); |
| | | insert into sys_dict_data values(12, 1, 'æ¯', 'Y', 'sys_yes_no', '', 'primary', 'Y', '0', 'admin', sysdate(), '', null, 'ç³»ç»é»è®¤æ¯'); |
| | | insert into sys_dict_data values(13, 2, 'å¦', 'N', 'sys_yes_no', '', 'danger', 'N', '0', 'admin', sysdate(), '', null, 'ç³»ç»é»è®¤å¦'); |
| | | insert into sys_dict_data values(14, 1, 'éç¥', '1', 'sys_notice_type', '', 'warning', 'Y', '0', 'admin', sysdate(), '', null, 'éç¥'); |
| | |
| | | |
| | | |
| | | -- ---------------------------- |
| | | -- 15ã宿¶ä»»å¡è°åº¦è¡¨ |
| | | -- ---------------------------- |
| | | drop table if exists sys_job; |
| | | create table sys_job ( |
| | | job_id bigint(20) not null auto_increment comment 'ä»»å¡ID', |
| | | job_name varchar(64) default '' comment 'ä»»å¡åç§°', |
| | | job_group varchar(64) default 'DEFAULT' comment 'ä»»å¡ç»å', |
| | | invoke_target varchar(500) not null comment 'è°ç¨ç®æ å符串', |
| | | cron_expression varchar(255) default '' comment 'cronæ§è¡è¡¨è¾¾å¼', |
| | | misfire_policy varchar(20) default '3' comment 'è®¡åæ§è¡é误çç¥ï¼1ç«å³æ§è¡ 2æ§è¡ä¸æ¬¡ 3æ¾å¼æ§è¡ï¼', |
| | | concurrent char(1) default '1' comment 'æ¯å¦å¹¶åæ§è¡ï¼0å
许 1ç¦æ¢ï¼', |
| | | status char(1) default '0' comment 'ç¶æï¼0æ£å¸¸ 1æåï¼', |
| | | create_by varchar(64) default '' comment 'å建è
', |
| | | create_time datetime comment 'å建æ¶é´', |
| | | update_by varchar(64) default '' comment 'æ´æ°è
', |
| | | update_time datetime comment 'æ´æ°æ¶é´', |
| | | remark varchar(500) default '' comment '夿³¨ä¿¡æ¯', |
| | | primary key (job_id, job_name, job_group) |
| | | ) engine=innodb auto_increment=100 comment = '宿¶ä»»å¡è°åº¦è¡¨'; |
| | | |
| | | insert into sys_job values(1, 'ç³»ç»é»è®¤ï¼æ åï¼', 'DEFAULT', 'ryTask.ryNoParams', '0/10 * * * * ?', '3', '1', '1', 'admin', sysdate(), '', null, ''); |
| | | insert into sys_job values(2, 'ç³»ç»é»è®¤ï¼æåï¼', 'DEFAULT', 'ryTask.ryParams(\'ry\')', '0/15 * * * * ?', '3', '1', '1', 'admin', sysdate(), '', null, ''); |
| | | insert into sys_job values(3, 'ç³»ç»é»è®¤ï¼å¤åï¼', 'DEFAULT', 'ryTask.ryMultipleParams(\'ry\', true, 2000L, 316.50D, 100)', '0/20 * * * * ?', '3', '1', '1', 'admin', sysdate(), '', null, ''); |
| | | |
| | | |
| | | -- ---------------------------- |
| | | -- 16ã宿¶ä»»å¡è°åº¦æ¥å¿è¡¨ |
| | | -- ---------------------------- |
| | | drop table if exists sys_job_log; |
| | | create table sys_job_log ( |
| | | job_log_id bigint(20) not null auto_increment comment '任塿¥å¿ID', |
| | | job_name varchar(64) not null comment 'ä»»å¡åç§°', |
| | | job_group varchar(64) not null comment 'ä»»å¡ç»å', |
| | | invoke_target varchar(500) not null comment 'è°ç¨ç®æ å符串', |
| | | job_message varchar(500) comment 'æ¥å¿ä¿¡æ¯', |
| | | status char(1) default '0' comment 'æ§è¡ç¶æï¼0æ£å¸¸ 1失败ï¼', |
| | | exception_info varchar(2000) default '' comment 'å¼å¸¸ä¿¡æ¯', |
| | | create_time datetime comment 'å建æ¶é´', |
| | | primary key (job_log_id) |
| | | ) engine=innodb comment = '宿¶ä»»å¡è°åº¦æ¥å¿è¡¨'; |
| | | |
| | | |
| | | -- ---------------------------- |
| | | -- 17ãéç¥å
¬å表 |
| | | -- ---------------------------- |
| | | drop table if exists sys_notice; |
| | |
| | | -- ---------------------------- |
| | | -- åå§å-å
¬åä¿¡æ¯è¡¨æ°æ® |
| | | -- ---------------------------- |
| | | insert into sys_notice values('1', '温馨æéï¼2018-07-01 è¥ä¾æ°çæ¬åå¸å¦', '2', 'æ°çæ¬å
容', '0', 'admin', sysdate(), '', null, '管çå'); |
| | | insert into sys_notice values('2', 'ç»´æ¤éç¥ï¼2018-07-01 è¥ä¾ç³»ç»åæ¨ç»´æ¤', '1', 'ç»´æ¤å
容', '0', 'admin', sysdate(), '', null, '管çå'); |
| | | insert into sys_notice values('1', '温馨æéï¼2018-07-01 æ°çæ¬åå¸å¦', '2', 'æ°çæ¬å
容', '0', 'admin', sysdate(), '', null, '管çå'); |
| | | insert into sys_notice values('2', 'ç»´æ¤éç¥ï¼2018-07-01 ç³»ç»åæ¨ç»´æ¤', '1', 'ç»´æ¤å
容', '0', 'admin', sysdate(), '', null, '管çå'); |
| | | |
| | | |
| | | -- ---------------------------- |