赞
踩
基于RuoYi-Cloud 3.6.3 版本集成
先贴一下开源地址: https://gitee.com/wxjstudy/jove-fast
DataRoom开源地址: https://gitee.com/gcpaas/DataRoom
增加注解扫描,以及配置分页插件
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import com.gccloud.common.constant.CommonConst; import com.gccloud.dashboard.core.constant.DashboardConst; import com.gccloud.dataroom.core.constant.DataRoomConst; import com.gccloud.dataset.constant.DatasetConstant; import com.jovefast.common.security.annotation.EnableCustomConfig; import com.jovefast.common.security.annotation.EnableFastFeignClients; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; /** * 可视化管理模块 * * @author Acechengui */ @EnableCustomConfig @EnableFastFeignClients @SpringBootApplication(scanBasePackages = {DataRoomConst.ScanPackage.COMPONENT,DatasetConstant.ScanPackage.COMPONENT, CommonConst.ScanPackage.COMPONENT,"com.jovefast"}) @MapperScan(value = {DataRoomConst.ScanPackage.DAO,DatasetConstant.ScanPackage.DAO}) public class JoveDataRoomApplication { public static void main(String[] args) { SpringApplication.run(JoveDataRoomApplication.class, args); System.out.println("(♥◠‿◠)ノ゙ 可视化管理模块启动成功 ლ(´ڡ`ლ)゙ "); System.out.println("STARTING SUCCESS"); } /** * 分页插件 * * @return PaginationInterceptor */ @Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); return interceptor; } }
注意:scanBasePackages中除了大屏的相关包路径,还加上了 “com.jovefast” 的路径扫描,这是为了扫描到自己项目包的一些配置,比如跨域配置,不加的话,可能会影响自身接口的访问
点击查询最新版本号
<properties> <json.version>20220320</json.version> <dataroom.core.version>2.0.0.RELEASE</dataroom.core.version> </properties> <!-- SpringCloud Alibaba Nacos --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency> <!-- SpringCloud Alibaba Nacos Config --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> </dependency> <!-- SpringCloud Alibaba Sentinel --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> </dependency> <!-- SpringBoot Actuator --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <!-- Mysql Connector --> <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> </dependency> <!-- Common Log --> <dependency> <groupId>com.jovefast</groupId> <artifactId>jovefast-common-log</artifactId> </dependency> <!-- Common core --> <dependency> <groupId>com.jovefast</groupId> <artifactId>jovefast-common-core</artifactId> </dependency> <!-- jovefast Common DataSource --> <dependency> <groupId>com.jovefast</groupId> <artifactId>jovefast-common-datasource</artifactId> </dependency> <!-- 大屏设计器 --> <dependency> <groupId>com.gccloud</groupId> <artifactId>dataroom-core</artifactId> <version>${dataroom.core.version}</version> </dependency> <!-- jackson --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> </dependency> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>${json.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-json-org</artifactId> </dependency>
以上依赖中,jovefast 就是若依的包名,原本应是ruoyi
bootstrap.yml与logback.xml怎么配置这里就不叙述了,跟若依一样的,注意端口号就行
配置管理–>配置列表,新增配置(对应命名空间),比如这里
Data Id命名为 jove-dataroom-dev.yml
Group为默认的 DEFAULT_GROUP
具体参考配置如下:
# spring配置 spring: groovy: template: check-template-location: false servlet: multipart: max-file-size: 100MB max-request-size: 100MB redis: host: 127.0.0.1 port: 6379 password: 123456 database: 1 resources: static-locations: classpath:/static/,classpath:/META-INF/resources/,classpath:/META-INF/resources/webjars/,file:${gc.starter.file.basePath} # 静态资源配置 mvc: throw-exception-if-no-handler-found: true # 静态资源访问接口前缀 static-path-pattern: /static/** view: prefix: classpath:/static/ suffix: .html datasource: druid: stat-view-servlet: enabled: true loginUsername: admin loginPassword: 123456 dynamic: druid: initial-size: 5 min-idle: 5 maxActive: 20 maxWait: 300000 timeBetweenEvictionRunsMillis: 300000 minEvictableIdleTimeMillis: 300000 maxEvictableIdleTimeMillis: 600000 idleConnectionTestPeriod: 120 testConnectionOnCheckout: false testConnectionOnCheckin: true validationQuery: SELECT 1 testWhileIdle: true testOnBorrow: false testOnReturn: false usePingMethod: false poolPreparedStatements: true maxPoolPreparedStatementPerConnectionSize: 20 filters: stat,slf4j connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 datasource: # 主库数据源 master: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://127.0.0.1:3306/dataroom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&autoReconnect=true&failOverReadOnly=false&serverTimezone=GMT%2B8 username: root password: 123456 # mybatis配置 mybatis-plus: # mybatis plus xml配置文件扫描,多个通过分号隔开 mapper-locations: classpath*:mapper/**/*.xml # xml中别名文件扫描,多个通过逗号隔开 type-handlers-package: com.jovefast,com.gccloud gc: starter: dataroom: component: DataRoomGlobalExceptionHandler: false file: # minio服务提供的文件访问地址 urlPrefix: http://192.168.20.98:9000/ # 切换文件服务类型为minio type: minio minio: url: http://192.168.20.98:9000 # minio服务设置的accessKey accessKey: admin # minio服务设置的secretKey secretKey: 123456 # 存储到minio的桶 bucketName: dataroom
spring:
cloud:
gateway:
discovery:
locator:
lowerCaseServiceId: true
enabled: true
routes:
# 大屏服务
- id: jove-dataroom-dev
uri: lb://jove-dataroom-dev
filters:
- StripPrefix=1
predicates:
- Path=/dataroom/**
:::info
**注意:**仪表盘和大屏的接口权限控制是通用的,如果已经实现过仪表盘的了,那么就不需要再次实现,直接若依的菜单管理中把大屏相关的权限标识添加上就行,并且关于数据集和数据源部分的权限标识也是通用的,即dataset和datasource开头的权限标识,无需再次添加
:::
为了能够控制大屏相关接口的授权与访问,我们可以参考 自定义大屏接口权限 来实现大屏权限对接
如图,我们创建一个类 PermissionServiceImpl ,并实现大屏提供的 IApiPermissionService 接口,在 **verifyApiPermission **方法中,我们通过若依提供的 SecurityUtils 获取当前登录用户的权限列表,并进行判断即可
代码参考如下
@Service public class PermissionServiceImpl implements IApiPermissionService { @Override public boolean verifyApiPermission(HttpServletRequest request, String... permission) { // 获取当前用户的权限 LoginUser loginUser = SecurityUtils.getLoginUser(); Set<String> permissions = loginUser.getPermissions(); if (permissions.contains("*:*:*")) { // 若依的全部权限标识 return true; } // 判断当前用户是否拥有对应的权限 for (String s : permission) { if (!permissions.contains(s)) { return false; } } // 返回值true标识校验通过 return true; } }
当然,这只是完成了后端的校验,我们还需要将大屏相关的接口权限标识添加到若依系统中,这时就可以到若依的菜单管理中,将大屏提供的权限标识全部添加为 按钮 权限,大屏提供的权限标识如下所示
新增权限参考如下:
screen:view | 大屏页面的详情、列表接口权限 |
---|---|
screen:add | 大屏页面的新增接口权限 |
screen:update | 大屏页面的修改接口权限 |
screen:delete | 大屏页面的删除接口权限 |
datasource:view | 数据源的详情、列表接口权限 |
datasource:add | 数据源的新增接口权限 |
datasource:update | 数据源的编辑接口权限 |
file:view | 文件的查询接口权限 |
file:upload | 文件的上传接口权限 |
file:download | 文件的下载接口权限 |
file:delete | 文件的删除接口权限 |
component:view | 组件的查询接口权限 |
component:add | 组件的新增接口权限 |
component:update | 组件的编辑接口权限 |
component:delete | 组件的删除接口权限 |
map:view | 地图数据的查询接口权限 |
map:add | 地图数据的新增接口权限 |
map:update | 地图数据的编辑接口权限 |
map:delete | 地图数据的删除接口权限 |
datasource:delete | 数据源的删除接口权限 |
datasource:test | 数据源的测试接口权限 |
dataset:view | 数据集的详情、列表接口权限 |
dataset:add | 数据集的新增接口权限 |
dataset:update | 数据集的编辑接口权限 |
dataset:delete | 数据集的删除接口权限 |
dataset:execute | 数据集的数据获取接口权限 |
dataset:category | 数据集的分类树相关查询接口权限 |
dataset:category:edit | 数据集的分类树相关操作接口权限(增删改) |
dataset:label | 数据集标签相关查询接口权限 |
dataset 声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/爱喝兽奶帝天荒/article/detail/743052 推荐阅读 相关标签 Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。 |