From c0aa455761cf317d75508348194fbbd0ef823bf3 Mon Sep 17 00:00:00 2001
From: Raod <1130305001@qq.com>
Date: Thu, 23 Sep 2021 10:18:22 +0800
Subject: [PATCH 1/6] =?UTF-8?q?=E7=BC=96=E7=A0=81=E8=BE=93=E5=85=A5?=
=?UTF-8?q?=E9=99=90=E5=88=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
report-ui/src/utils/validate.js | 14 ++++++++++++++
.../datasource/components/EditDataSource.vue | 2 ++
report-ui/src/views/report/report/index.vue | 4 +++-
.../report/resultset/components/EditDataSet.vue | 4 +++-
4 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/report-ui/src/utils/validate.js b/report-ui/src/utils/validate.js
index e1103104..aa056196 100644
--- a/report-ui/src/utils/validate.js
+++ b/report-ui/src/utils/validate.js
@@ -30,3 +30,17 @@ export function validatAlphabets(str) {
const reg = /^[A-Za-z]+$/
return reg.test(str)
}
+
+/*验证内容是否英文数字以及下划线*/
+export function validateEngOrNum(rule, value, callback) {
+ const reg =/^[_a-zA-Z0-9]+$/;
+ if(value==''||value==undefined||value==null){
+ callback();
+ } else {
+ if (!reg.test(value)){
+ callback(new Error('英文字母、数字或下划线'));
+ } else {
+ callback();
+ }
+ }
+}
diff --git a/report-ui/src/views/report/datasource/components/EditDataSource.vue b/report-ui/src/views/report/datasource/components/EditDataSource.vue
index 7a307f16..0267f240 100644
--- a/report-ui/src/views/report/datasource/components/EditDataSource.vue
+++ b/report-ui/src/views/report/datasource/components/EditDataSource.vue
@@ -44,6 +44,7 @@
import { testConnection, reportDataSourceDetail, reportDataSourceAdd, reportDataSourceUpdate } from '@/api/reportDataSource'
import { getDictList } from '@/api/dict-data' // 获取数据字典
import Dictionary from '@/components/Dictionary/index'
+import {validateEngOrNum} from "@/utils/validate";
export default {
name: 'Support',
components: { Dictionary },
@@ -97,6 +98,7 @@ export default {
],
sourceCode: [
{ required: true, message: '数据集编码必填', trigger: 'blur' },
+ { validator: validateEngOrNum, trigger: 'blur' },
],
sourceName: [
{ required: true, message: '数据源名称必选', trigger: 'blur' },
diff --git a/report-ui/src/views/report/report/index.vue b/report-ui/src/views/report/report/index.vue
index b5636902..4c27c037 100644
--- a/report-ui/src/views/report/report/index.vue
+++ b/report-ui/src/views/report/report/index.vue
@@ -46,6 +46,7 @@ import {
reportDetail
} from "@/api/reportmanage";
import Share from "@/views/report/report/components/share";
+import {validateEngOrNum} from "@/utils/validate";
export default {
name: "Report",
components: {
@@ -131,7 +132,8 @@ export default {
editField: "reportCode",
inputType: "input",
rules: [
- { min: 1, max: 100, message: "不超过100个字符", trigger: "blur" }
+ { min: 1, max: 100, message: "不超过100个字符", trigger: "blur" },
+ { validator: validateEngOrNum, trigger: 'blur' },
],
disabled: "disableOnEdit"
},
diff --git a/report-ui/src/views/report/resultset/components/EditDataSet.vue b/report-ui/src/views/report/resultset/components/EditDataSet.vue
index 5aaf1099..17520511 100644
--- a/report-ui/src/views/report/resultset/components/EditDataSet.vue
+++ b/report-ui/src/views/report/resultset/components/EditDataSet.vue
@@ -383,6 +383,7 @@ import "codemirror/lib/codemirror.css"; // 核心样式
import "codemirror/theme/cobalt.css"; // 引入主题后还需要在 options 中指定主题才会生效
import vueJsonEditor from "vue-json-editor";
import MonacoEditor from "./MonacoEditor.vue";
+import {validateEngOrNum} from "@/utils/validate";
export default {
name: "Support",
components: { Dictionary, codemirror, vueJsonEditor, MonacoEditor },
@@ -469,7 +470,8 @@ export default {
{ required: true, message: "数据集名称必填", trigger: "blur" }
],
setCode: [
- { required: true, message: "数据集编码必填", trigger: "blur" }
+ { required: true, message: "数据集编码必填", trigger: "blur" },
+ { validator: validateEngOrNum, trigger: 'blur' },
],
sourceCode: [
{ required: true, message: "数据源必选", trigger: "change" }
From 7259593066809bedf29fe2c174c50310ef10c64a Mon Sep 17 00:00:00 2001
From: Raod <1130305001@qq.com>
Date: Thu, 23 Sep 2021 14:50:50 +0800
Subject: [PATCH 2/6] =?UTF-8?q?=E5=88=86=E4=BA=AB=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../controller/dto/ReportShareDto.java | 5 ++
.../reportshare/dao/entity/ReportShare.java | 13 ++++-
.../service/impl/ReportShareServiceImpl.java | 17 +++++-
.../template/gaea/business/util/JwtUtil.java | 17 ++++++
.../template/gaea/business/util/UuidUtil.java | 23 +++++++-
report-ui/src/views/report/aj/index.vue | 56 +++++++++++++++++--
.../views/report/report/components/share.vue | 54 ++++++++++++++----
7 files changed, 163 insertions(+), 22 deletions(-)
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/dto/ReportShareDto.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/dto/ReportShareDto.java
index 0b139d01..14690975 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/dto/ReportShareDto.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/dto/ReportShareDto.java
@@ -53,4 +53,9 @@ public class ReportShareDto extends GaeaBaseDTO implements Serializable {
@ApiModelProperty(value = "0--未删除 1--已删除 DIC_NAME=DELETE_FLAG")
private Integer deleteFlag;
+ /** 分享码 */
+ private String sharePassword;
+
+ private boolean sharePasswordFlag = false;
+
}
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/dao/entity/ReportShare.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/dao/entity/ReportShare.java
index 59bd466d..b2d06a52 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/dao/entity/ReportShare.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/dao/entity/ReportShare.java
@@ -1,11 +1,11 @@
package com.anjiplus.template.gaea.business.modules.reportshare.dao.entity;
-import lombok.Data;
-import io.swagger.annotations.ApiModelProperty;
import com.anji.plus.gaea.curd.entity.GaeaBaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
-import javax.validation.constraints.*;
+import lombok.Data;
+
import java.util.Date;
/**
* @description 报表分享 entity
@@ -39,5 +39,12 @@ public class ReportShare extends GaeaBaseEntity {
/** 0--未删除 1--已删除 DIC_NAME=DELETE_FLAG */
private Integer deleteFlag;
+ /** 分享码 */
+ @TableField(exist = false)
+ private String sharePassword;
+
+ @TableField(exist = false)
+ private boolean sharePasswordFlag;
+
}
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/service/impl/ReportShareServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/service/impl/ReportShareServiceImpl.java
index 60e165c8..5a1b9819 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/service/impl/ReportShareServiceImpl.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/service/impl/ReportShareServiceImpl.java
@@ -13,9 +13,11 @@ import com.anjiplus.template.gaea.business.modules.reportshare.dao.entity.Report
import com.anjiplus.template.gaea.business.modules.reportshare.service.ReportShareService;
import com.anjiplus.template.gaea.business.util.DateUtil;
import com.anjiplus.template.gaea.business.util.JwtUtil;
+import com.anjiplus.template.gaea.business.util.MD5Util;
import com.anjiplus.template.gaea.business.util.UuidUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -51,12 +53,18 @@ public class ReportShareServiceImpl implements ReportShareService {
@Override
public ReportShareDto insertShare(ReportShareDto dto) {
+ //设置分享码
+ if (dto.isSharePasswordFlag()) {
+ dto.setSharePassword(UuidUtil.getRandomPwd(4));
+ }
+
ReportShareDto reportShareDto = new ReportShareDto();
ReportShare entity = new ReportShare();
BeanUtils.copyProperties(dto, entity);
insert(entity);
//将分享链接返回
reportShareDto.setShareUrl(entity.getShareUrl());
+ reportShareDto.setSharePassword(dto.getSharePassword());
return reportShareDto;
}
@@ -69,6 +77,12 @@ public class ReportShareServiceImpl implements ReportShareService {
if (null == reportShare) {
throw BusinessExceptionBuilder.build(ResponseCode.REPORT_SHARE_LINK_INVALID);
}
+ //解析jwt token,获取密码
+ String password = JwtUtil.getPassword(reportShare.getShareToken());
+ if (StringUtils.isNotBlank(password)) {
+ //md5加密返回
+ reportShare.setSharePassword(MD5Util.encrypt(password));
+ }
return reportShare;
}
@@ -101,7 +115,8 @@ public class ReportShareServiceImpl implements ReportShareService {
} else {
entity.setShareUrl(entity.getShareUrl() + SHARE_FLAG + shareCode);
}
+
entity.setShareValidTime(DateUtil.getFutureDateTmdHms(entity.getShareValidType()));
- entity.setShareToken(JwtUtil.createToken(entity.getReportCode(), shareCode, entity.getShareValidTime()));
+ entity.setShareToken(JwtUtil.createToken(entity.getReportCode(), shareCode, entity.getSharePassword(), entity.getShareValidTime()));
}
}
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/util/JwtUtil.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/util/JwtUtil.java
index c2867eb6..753f4def 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/util/JwtUtil.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/util/JwtUtil.java
@@ -7,6 +7,7 @@ import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.Claim;
import com.auth0.jwt.interfaces.DecodedJWT;
+import org.apache.commons.lang3.StringUtils;
import java.util.Date;
import java.util.Map;
@@ -19,11 +20,16 @@ public class JwtUtil {
private static final String JWT_SECRET = "aj-report";
public static String createToken(String reportCode, String shareCode, Date expires) {
+ return createToken(reportCode, shareCode, null, expires);
+ }
+
+ public static String createToken(String reportCode, String shareCode, String password, Date expires) {
String token = JWT.create()
.withIssuedAt(new Date())
.withExpiresAt(expires)
.withClaim("reportCode", reportCode)
.withClaim("shareCode", shareCode)
+ .withClaim("sharePassword", password)
.sign(Algorithm.HMAC256(JWT_SECRET));
return token;
}
@@ -55,4 +61,15 @@ public class JwtUtil {
return claim.asString();
}
+ public static String getPassword(String token) {
+ Claim claim = getClaim(token).get("sharePassword");
+ if (null == claim) {
+ return null;
+ }
+ if (StringUtils.isNotBlank(claim.asString())) {
+ return claim.asString();
+ }
+ return null;
+ }
+
}
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/util/UuidUtil.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/util/UuidUtil.java
index b152ea75..40031aab 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/util/UuidUtil.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/util/UuidUtil.java
@@ -1,5 +1,6 @@
package com.anjiplus.template.gaea.business.util;
+import java.security.SecureRandom;
import java.util.UUID;
/**
@@ -31,6 +32,24 @@ public class UuidUtil {
}
+ /**
+ * 获取随机小写密码
+ * @param num
+ * @return
+ */
+ public static String getRandomPwd(int num) {
+ StringBuilder builder = new StringBuilder();
+ // 因为已经把 4 种字符放进list了,所以 i 取值从 4开始
+ // 产生随机数用于随机调用生成字符的函数
+ for (int i = 0; i < num; i++) {
+ SecureRandom random = new SecureRandom();
+ int funNum = random.nextInt(chars.length);
+ builder.append(chars[funNum]);
+ }
+
+ return builder.toString().toLowerCase();
+ }
+
public static String generateUuid() {
return UUID.randomUUID().toString().replace("-", "");
@@ -38,7 +57,9 @@ public class UuidUtil {
public static void main(String[] args) {
for (int i = 0; i < 100; i++) {
- System.out.println(generateShortUuid());
+// System.out.println(generateShortUuid());
+ System.out.println(getRandomPwd(4));
}
+
}
}
diff --git a/report-ui/src/views/report/aj/index.vue b/report-ui/src/views/report/aj/index.vue
index 8474facb..369f9e62 100644
--- a/report-ui/src/views/report/aj/index.vue
+++ b/report-ui/src/views/report/aj/index.vue
@@ -6,6 +6,18 @@
!-->
+
+
+
+
@@ -18,7 +30,11 @@ export default {
},
data() {
return {
-
+ password: '',
+ sharePassword: '',
+ dialogVisible: false,
+ reportCode: '',
+ shareToken: ''
};
},
@@ -33,18 +49,46 @@ export default {
const {code, data} = await reportShareDetailByCode(shareCode)
if (code != '200') return
- setShareToken(data.shareToken)
- //将shareToken缓存在浏览器
- //跳转至大屏预览页面
+ console.log(data)
+ this.reportCode = data.reportCode
+ this.sharePassword = data.sharePassword
+ this.shareToken = data.shareToken
+ if (this.sharePassword) {
+ console.log(this.sharePassword)
+ this.dialogVisible = true
+ }else {
+ this.pushAj()
+ }
+ },
+ checkPassword(){
+ const md5 = require('js-md5')
+ const inputPassword = md5(this.password);
+ console.log(this.password +'--------------'+inputPassword + "--------" + this.sharePassword)
+ if (inputPassword == this.sharePassword) {
+ this.pushAj()
+ }else {
+ this.$message.error('分享码输入不正确')
+ }
+
+ },
+ pushAj(){
+ setShareToken(this.shareToken)
this.$router.push({
path: '/bigscreen/viewer',
query: {
- reportCode: data.reportCode
+ reportCode: this.reportCode
},
})
-
},
+ handleClose(done) {
+ this.$confirm('确认关闭?')
+ .then(_ => {
+ done();
+ })
+ .catch(_ => {});
+ }
}
+
};
diff --git a/report-ui/src/views/report/report/components/share.vue b/report-ui/src/views/report/report/components/share.vue
index f61335b3..430a67f7 100644
--- a/report-ui/src/views/report/report/components/share.vue
+++ b/report-ui/src/views/report/report/components/share.vue
@@ -11,19 +11,40 @@
+
+
+
+
+
+
+
+
+
创建链接
-
-
-
-
-
-
- 复制链接
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 复制链接
+ 复制链接和分享码
-
+
@@ -71,6 +92,8 @@ export default {
reportCode: '',
shareUrl: '',
shareCode: '',
+ sharePassword: '',
+ sharePasswordFlag: false,
},
shareLinkFlag1: true,
rules: {
@@ -103,24 +126,33 @@ export default {
if (code != '200') return
this.shareValidTypeOptions = data
this.dialogForm.shareValidType = this.shareValidTypeOptions[0].id
+ this.dialogForm.sharePasswordFlag = false
+ this.dialogForm.sharePassword = ''
},
async createShare() {
this.dialogForm.reportCode = this.reportCode
this.dialogForm.shareUrl = window.location.href
- console.log(this.dialogForm)
+ // console.log(this.dialogForm)
const {code, data} = await reportShareAdd(this.dialogForm)
if (code != '200') return
- console.log(data)
+ // console.log(data)
this.shareLinkFlag1 = false
this.$message({
message: '创建链接成功!',
type: 'success',
})
this.reportShareUrl = data.shareUrl
+ this.dialogForm.sharePassword = data.sharePassword
},
copyShare(){
- this.copyToClip(this.reportShareUrl)
+ let content = ''
+ if (this.dialogForm.sharePassword == '') {
+ content = 'AJ-Report分享链接:' + this.reportShareUrl
+ }else {
+ content = 'AJ-Report分享链接:' + this.reportShareUrl + ' 分享码:' + this.dialogForm.sharePassword;
+ }
+ this.copyToClip(content)
this.$message({
message: '复制链接成功!',
type: 'success',
From 95a137a36a765ba13b9a1e5c11ad4841af3222a5 Mon Sep 17 00:00:00 2001
From: Raod <1130305001@qq.com>
Date: Thu, 23 Sep 2021 14:56:19 +0800
Subject: [PATCH 3/6] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E7=82=B9?=
=?UTF-8?q?=E5=87=BB=E4=BA=8B=E4=BB=B6=E9=97=AE=E9=A2=98(=E7=82=B9?=
=?UTF-8?q?=E5=87=BB=E7=BC=96=E8=BE=91=E4=BC=9A=E5=87=BA=E7=8E=B0=E7=BC=96?=
=?UTF-8?q?=E8=BE=91=E5=92=8C=E9=A2=84=E8=A7=88=E7=9A=84=E5=BC=B9=E6=A1=86?=
=?UTF-8?q?)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
report-ui/src/views/report/resultset/components/DataView.vue | 2 ++
report-ui/src/views/report/resultset/components/EditDataSet.vue | 2 ++
2 files changed, 4 insertions(+)
diff --git a/report-ui/src/views/report/resultset/components/DataView.vue b/report-ui/src/views/report/resultset/components/DataView.vue
index a812de14..2469a64f 100644
--- a/report-ui/src/views/report/resultset/components/DataView.vue
+++ b/report-ui/src/views/report/resultset/components/DataView.vue
@@ -1,8 +1,10 @@
From 5c95d34006eb88138c92d3043efc3a0f8fd94147 Mon Sep 17 00:00:00 2001
From: Raod <1130305001@qq.com>
Date: Fri, 24 Sep 2021 16:15:28 +0800
Subject: [PATCH 4/6] =?UTF-8?q?oracle.sql.TIMESTAMP=20=E8=A7=A3=E6=9E=90?=
=?UTF-8?q?=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../service/impl/DataSourceServiceImpl.java | 30 +++++++++++++++----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasource/service/impl/DataSourceServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasource/service/impl/DataSourceServiceImpl.java
index 77b53950..92af651a 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasource/service/impl/DataSourceServiceImpl.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasource/service/impl/DataSourceServiceImpl.java
@@ -33,11 +33,9 @@ import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
+import java.sql.*;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -243,7 +241,9 @@ public class DataSourceServiceImpl implements DataSourceService {
columns.forEach(t -> {
try {
Object value = rs.getObject(t);
- jo.put(t, value);
+ //数据类型转换
+ Object result = dealResult(value);
+ jo.put(t, result);
} catch (SQLException throwable) {
log.error("error",throwable);
throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_SQL_ERROR, throwable.getMessage());
@@ -267,6 +267,26 @@ public class DataSourceServiceImpl implements DataSourceService {
}
}
+ /**
+ * 解决sql返回值 类型问题
+ * (through reference chain: java.util.HashMap["pageData"]->java.util.ArrayList[0]->java.util.HashMap["UPDATE_TIME"]->oracle.sql.TIMESTAMP["stream"])
+ * @param result
+ * @return
+ * @throws SQLException
+ */
+ private Object dealResult(Object result) throws SQLException {
+ if (null == result) {
+ return result;
+ }
+ String type = result.getClass().getName();
+ if ("oracle.sql.TIMESTAMP".equals(type)) {
+ //oracle.sql.TIMESTAMP处理逻辑
+ return new Date((Long) JSONObject.toJSON(result));
+ }
+
+ return result;
+ }
+
/**
* http 执行获取数据
*
From 6f1d0287fafda3f7a9b79725c19bd535d34485c7 Mon Sep 17 00:00:00 2001
From: Raod <1130305001@qq.com>
Date: Sun, 26 Sep 2021 10:05:40 +0800
Subject: [PATCH 5/6] =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=BC=80=E5=90=AFflyway?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../business/config/DatabaseInitializer.java | 2 ++
.../dao/entity/AccessAuthority.java | 4 +--
.../accessrole/dao/entity/AccessRole.java | 4 +--
.../dao/entity/AccessRoleAuthority.java | 2 +-
.../service/impl/AccessRoleServiceImpl.java | 12 ++++++--
.../accessuser/dao/entity/AccessUser.java | 4 +--
.../accessuser/dao/entity/AccessUserRole.java | 4 +--
.../service/impl/AccessUserServiceImpl.java | 29 +++++++++++++++----
.../dashboard/dao/entity/ReportDashboard.java | 2 +-
.../dao/entity/ReportDashboardWidget.java | 2 +-
.../modules/dataset/dao/entity/DataSet.java | 2 +-
.../datasetparam/dao/entity/DataSetParam.java | 2 +-
.../dao/entity/DataSetTransform.java | 2 +-
.../datasource/dao/entity/DataSource.java | 2 +-
.../modules/dict/dao/entity/GaeaDict.java | 2 +-
.../modules/dict/dao/entity/GaeaDictItem.java | 2 +-
.../modules/file/entity/GaeaFile.java | 2 +-
.../modules/report/dao/entity/Report.java | 2 +-
.../reportshare/dao/entity/ReportShare.java | 2 +-
report-core/src/main/resources/bootstrap.yml | 1 +
20 files changed, 57 insertions(+), 27 deletions(-)
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/config/DatabaseInitializer.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/config/DatabaseInitializer.java
index be4afc9f..129c42dd 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/config/DatabaseInitializer.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/config/DatabaseInitializer.java
@@ -3,6 +3,7 @@ package com.anjiplus.template.gaea.business.config;
import com.zaxxer.hikari.HikariDataSource;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.flyway.FlywayProperties;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.stereotype.Component;
@@ -18,6 +19,7 @@ import java.sql.Statement;
@Slf4j
@Component
@AllArgsConstructor
+@ConditionalOnProperty(value = {"spring.flyway.enabled"})
public class DatabaseInitializer {
private final FlywayProperties flywayProperties;
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessauthority/dao/entity/AccessAuthority.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessauthority/dao/entity/AccessAuthority.java
index 54e08689..1d04d89f 100755
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessauthority/dao/entity/AccessAuthority.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessauthority/dao/entity/AccessAuthority.java
@@ -12,7 +12,7 @@ import java.util.Date;
* @author 木子李·De
* @date 2019-02-17 08:50:10.009
**/
-@TableName(value="access_authority")
+@TableName(keepGlobalPrefix=true, value="access_authority")
@Data
public class AccessAuthority extends GaeaBaseEntity {
/** 父菜单代码 */
@@ -40,4 +40,4 @@ public class AccessAuthority extends GaeaBaseEntity {
-}
\ No newline at end of file
+}
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/dao/entity/AccessRole.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/dao/entity/AccessRole.java
index 36254f06..e8e7b1ae 100755
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/dao/entity/AccessRole.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/dao/entity/AccessRole.java
@@ -11,7 +11,7 @@ import java.util.Date;
* @author 木子李·De
* @date 2019-02-17 08:50:14.136
**/
-@TableName(value="access_role")
+@TableName(keepGlobalPrefix=true, value="access_role")
@Data
public class AccessRole extends GaeaBaseEntity {
@@ -27,4 +27,4 @@ public class AccessRole extends GaeaBaseEntity {
/** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */
private Integer enableFlag;
-}
\ No newline at end of file
+}
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/dao/entity/AccessRoleAuthority.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/dao/entity/AccessRoleAuthority.java
index a32d04e7..cb20a8f2 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/dao/entity/AccessRoleAuthority.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/dao/entity/AccessRoleAuthority.java
@@ -14,7 +14,7 @@ import java.util.Date;
* @author 木子李·De
* @date 2019-02-17 08:50:14.136
**/
-@TableName(value="access_role_authority")
+@TableName(keepGlobalPrefix=true, value="access_role_authority")
@Data
public class AccessRoleAuthority extends GaeaBaseEntity {
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/service/impl/AccessRoleServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/service/impl/AccessRoleServiceImpl.java
index 0d93b0ec..dea1b15a 100755
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/service/impl/AccessRoleServiceImpl.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/service/impl/AccessRoleServiceImpl.java
@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
/**
* @desc AccessRole 角色管理服务实现
@@ -52,7 +53,14 @@ public class AccessRoleServiceImpl implements AccessRoleService {
List treeData = accessAuthorityService.getAuthorityTree(operator, true);
// 该角色已选中的菜单及按钮
- List checkedKeys = accessRoleMapper.checkedAuthoritys(roleCode);
+// List checkedKeys = accessRoleMapper.checkedAuthoritys(roleCode);
+
+ LambdaQueryWrapper accessRoleAuthorityWrapper = Wrappers.lambdaQuery();
+ accessRoleAuthorityWrapper.select(AccessRoleAuthority::getTarget, AccessRoleAuthority::getAction);
+ accessRoleAuthorityWrapper.eq(AccessRoleAuthority::getRoleCode, roleCode);
+ List accessRoleAuthorities = accessRoleAuthorityMapper.selectList(accessRoleAuthorityWrapper);
+ List checkedKeys = accessRoleAuthorities.stream()
+ .map(accessRoleAuthority -> accessRoleAuthority.getTarget().concat("_").concat(accessRoleAuthority.getAction())).distinct().collect(Collectors.toList());
result.put("treeData", treeData);
result.put("checkedKeys", checkedKeys);
@@ -90,4 +98,4 @@ public class AccessRoleServiceImpl implements AccessRoleService {
});
return true;
}
-}
\ No newline at end of file
+}
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/dao/entity/AccessUser.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/dao/entity/AccessUser.java
index 26e706a4..5cd38158 100755
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/dao/entity/AccessUser.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/dao/entity/AccessUser.java
@@ -11,7 +11,7 @@ import java.util.Date;
* @author 木子李·De
* @date 2019-02-17 08:50:11.902
**/
-@TableName(value="access_user")
+@TableName(keepGlobalPrefix=true, value="access_user")
@Data
public class AccessUser extends GaeaBaseEntity {
@@ -45,4 +45,4 @@ public class AccessUser extends GaeaBaseEntity {
/** 最后一次登陆时间 */
private Date lastLoginTime;
-}
\ No newline at end of file
+}
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/dao/entity/AccessUserRole.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/dao/entity/AccessUserRole.java
index b43af5b5..a56be7ab 100755
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/dao/entity/AccessUserRole.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/dao/entity/AccessUserRole.java
@@ -13,7 +13,7 @@ import java.util.Date;
* @author 木子李·De
* @date 2019-02-17 08:50:11.902
**/
-@TableName(value="access_user_role")
+@TableName(keepGlobalPrefix=true, value="access_user_role")
@Data
public class AccessUserRole extends GaeaBaseEntity {
@@ -37,4 +37,4 @@ public class AccessUserRole extends GaeaBaseEntity {
@TableField(exist = false)
private Integer version;
-}
\ No newline at end of file
+}
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/service/impl/AccessUserServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/service/impl/AccessUserServiceImpl.java
index d066a3a5..33523b33 100755
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/service/impl/AccessUserServiceImpl.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/service/impl/AccessUserServiceImpl.java
@@ -13,8 +13,10 @@ import com.anji.plus.gaea.utils.GaeaUtils;
import com.anji.plus.gaea.utils.JwtBean;
import com.anjiplus.template.gaea.business.code.ResponseCode;
import com.anjiplus.template.gaea.business.constant.BusinessConstant;
+import com.anjiplus.template.gaea.business.modules.accessrole.dao.AccessRoleAuthorityMapper;
import com.anjiplus.template.gaea.business.modules.accessrole.dao.AccessRoleMapper;
import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRole;
+import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRoleAuthority;
import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.AccessUserDto;
import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.GaeaUserDto;
import com.anjiplus.template.gaea.business.modules.accessuser.controller.dto.UpdatePasswordDto;
@@ -31,10 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -54,6 +53,9 @@ public class AccessUserServiceImpl implements AccessUserService {
@Autowired
private AccessUserRoleMapper accessUserRoleMapper;
+ @Autowired
+ private AccessRoleAuthorityMapper accessRoleAuthorityMapper;
+
@Value("${customer.user.default.password:'123456'}")
private String defaultPassword;
@@ -168,7 +170,24 @@ public class AccessUserServiceImpl implements AccessUserService {
// 4.读取用户最新人权限主信息
String userKey = String.format(BusinessConstant.GAEA_SECURITY_LOGIN_USER, loginName);
- List authorities = accessUserMapper.queryAuthoritiesByLoginName(loginName);
+ //为了兼容底层其他数据库,不再写自定义sql
+// List authorities = accessUserMapper.queryAuthoritiesByLoginName(loginName);
+
+ //当前用户的roleCode集合
+ LambdaQueryWrapper accessUserWrapper = Wrappers.lambdaQuery();
+ accessUserWrapper.select(AccessUserRole::getRoleCode);
+ accessUserWrapper.eq(AccessUserRole::getLoginName, loginName);
+ List accessUserRoles = accessUserRoleMapper.selectList(accessUserWrapper);
+ Set roleCodeSet = accessUserRoles.stream().map(AccessUserRole::getRoleCode).collect(Collectors.toSet());
+
+ LambdaQueryWrapper accessRoleAuthorityWrapper = Wrappers.lambdaQuery();
+ accessRoleAuthorityWrapper.select(AccessRoleAuthority::getTarget, AccessRoleAuthority::getAction);
+ accessRoleAuthorityWrapper.in(AccessRoleAuthority::getRoleCode, roleCodeSet);
+ List accessRoleAuthorities = accessRoleAuthorityMapper.selectList(accessRoleAuthorityWrapper);
+ List authorities = accessRoleAuthorities.stream()
+ .map(accessRoleAuthority -> accessRoleAuthority.getTarget().concat(":").concat(accessRoleAuthority.getAction())).distinct().collect(Collectors.toList());
+
+
gaeaUser.setLoginName(loginName);
gaeaUser.setRealName(accessUser.getRealName());
gaeaUser.setToken(token);
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/dao/entity/ReportDashboard.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/dao/entity/ReportDashboard.java
index bf89396e..76ad6cb6 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/dao/entity/ReportDashboard.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/dao/entity/ReportDashboard.java
@@ -13,7 +13,7 @@ import lombok.Data;
* @author Raod
* @date 2021-04-12 14:52:21.761
**/
-@TableName(value="gaea_report_dashboard")
+@TableName(keepGlobalPrefix=true, value="gaea_report_dashboard")
@Data
public class ReportDashboard extends GaeaBaseEntity {
@ApiModelProperty(value = "报表编码")
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboardwidget/dao/entity/ReportDashboardWidget.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboardwidget/dao/entity/ReportDashboardWidget.java
index 671da4f3..2631236b 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboardwidget/dao/entity/ReportDashboardWidget.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboardwidget/dao/entity/ReportDashboardWidget.java
@@ -11,7 +11,7 @@ import lombok.Data;
* @author Raod
* @date 2021-04-12 15:12:43.724
**/
-@TableName(value="gaea_report_dashboard_widget")
+@TableName(keepGlobalPrefix=true, value="gaea_report_dashboard_widget")
@Data
public class ReportDashboardWidget extends GaeaBaseEntity {
@ApiModelProperty(value = "报表编码")
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataset/dao/entity/DataSet.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataset/dao/entity/DataSet.java
index 5a62b1a4..dfebbb07 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataset/dao/entity/DataSet.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataset/dao/entity/DataSet.java
@@ -13,7 +13,7 @@ import lombok.Data;
* @author Raod
* @date 2021-03-18 12:11:31.150755900
**/
-@TableName(value="gaea_report_data_set")
+@TableName(keepGlobalPrefix=true, value="gaea_report_data_set")
@Data
public class DataSet extends GaeaBaseEntity {
@ApiModelProperty(value = "数据集编码")
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasetparam/dao/entity/DataSetParam.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasetparam/dao/entity/DataSetParam.java
index 52a7e07b..96a1648f 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasetparam/dao/entity/DataSetParam.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasetparam/dao/entity/DataSetParam.java
@@ -11,7 +11,7 @@ import lombok.Data;
* @author Raod
* @date 2021-03-18 12:12:33.108033200
**/
-@TableName(value="gaea_report_data_set_param")
+@TableName(keepGlobalPrefix=true, value="gaea_report_data_set_param")
@Data
public class DataSetParam extends GaeaBaseEntity {
@ApiModelProperty(value = "数据集编码")
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasettransform/dao/entity/DataSetTransform.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasettransform/dao/entity/DataSetTransform.java
index 4ed3af3f..e81ad293 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasettransform/dao/entity/DataSetTransform.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasettransform/dao/entity/DataSetTransform.java
@@ -11,7 +11,7 @@ import lombok.Data;
* @author Raod
* @date 2021-03-18 12:13:15.591309400
**/
-@TableName(value="gaea_report_data_set_transform")
+@TableName(keepGlobalPrefix=true, value="gaea_report_data_set_transform")
@Data
public class DataSetTransform extends GaeaBaseEntity {
@ApiModelProperty(value = "数据集编码")
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasource/dao/entity/DataSource.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasource/dao/entity/DataSource.java
index d4939cc4..79f1e5b3 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasource/dao/entity/DataSource.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasource/dao/entity/DataSource.java
@@ -13,7 +13,7 @@ import lombok.Data;
* @author Raod
* @date 2021-03-18 12:09:57.728203200
**/
-@TableName(value="gaea_report_data_source")
+@TableName(keepGlobalPrefix=true, value="gaea_report_data_source")
@Data
public class DataSource extends GaeaBaseEntity {
@ApiModelProperty(value = "数据源编码")
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dict/dao/entity/GaeaDict.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dict/dao/entity/GaeaDict.java
index a2c68e9a..0bae6902 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dict/dao/entity/GaeaDict.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dict/dao/entity/GaeaDict.java
@@ -13,7 +13,7 @@ import java.io.Serializable;
* @author lr
* @since 2021-02-23 10:01:02
*/
-@TableName("gaea_dict")
+@TableName(keepGlobalPrefix=true, value = "gaea_dict")
public class GaeaDict extends GaeaBaseEntity implements Serializable {
/**
* 字典名称
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dict/dao/entity/GaeaDictItem.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dict/dao/entity/GaeaDictItem.java
index 49bfa5ea..37f75c2c 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dict/dao/entity/GaeaDictItem.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dict/dao/entity/GaeaDictItem.java
@@ -15,7 +15,7 @@ import java.io.Serializable;
* @author lirui
* @since 2021-03-09 15:52:41
*/
-@TableName("gaea_dict_item")
+@TableName(keepGlobalPrefix=true,value = "gaea_dict_item")
@UnionUniqueCode(group = BusinessConstant.DICT_ITEM_EXIST_GROUP, code = ResponseCode.DICT_ITEM_REPEAT)
public class GaeaDictItem extends GaeaBaseEntity implements Serializable {
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/entity/GaeaFile.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/entity/GaeaFile.java
index 13747600..49a97343 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/entity/GaeaFile.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/entity/GaeaFile.java
@@ -13,7 +13,7 @@ import java.io.Serializable;
* @author peiyanni
* @since 2021-02-18 14:48:20
*/
-@TableName("gaea_file")
+@TableName(keepGlobalPrefix=true, value = "gaea_file")
@Data
public class GaeaFile extends GaeaBaseEntity implements Serializable {
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/dao/entity/Report.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/dao/entity/Report.java
index 32951b84..628255c8 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/dao/entity/Report.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/dao/entity/Report.java
@@ -13,7 +13,7 @@ import lombok.Data;
* @author chenkening
* @date 2021/3/26 10:20
*/
-@TableName(value="gaea_report")
+@TableName(keepGlobalPrefix=true, value="gaea_report")
@Data
public class Report extends GaeaBaseEntity {
diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/dao/entity/ReportShare.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/dao/entity/ReportShare.java
index b2d06a52..88b4d748 100644
--- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/dao/entity/ReportShare.java
+++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/dao/entity/ReportShare.java
@@ -12,7 +12,7 @@ import java.util.Date;
* @author Raod
* @date 2021-08-18 13:37:26.663
**/
-@TableName(value="gaea_report_share")
+@TableName(keepGlobalPrefix=true, value="gaea_report_share")
@Data
public class ReportShare extends GaeaBaseEntity {
/** 分享编码,系统生成,默认UUID */
diff --git a/report-core/src/main/resources/bootstrap.yml b/report-core/src/main/resources/bootstrap.yml
index e4157d82..7192afc6 100644
--- a/report-core/src/main/resources/bootstrap.yml
+++ b/report-core/src/main/resources/bootstrap.yml
@@ -37,6 +37,7 @@ spring:
breakAfterAcquireFailure: true # 数据库服务宕机自动重连机制
timeBetweenConnectErrorMillis: 300000 # 连接出错后重试时间间隔
flyway:
+ enabled: true #是否开启flyway,默认true.
baseline-on-migrate: true
#数据库连接配置
url: ${spring.datasource.url}
From db706de36ce32c248a823d02d7e6292277a559a0 Mon Sep 17 00:00:00 2001
From: Raod <1130305001@qq.com>
Date: Sun, 26 Sep 2021 10:16:36 +0800
Subject: [PATCH 6/6] =?UTF-8?q?=E6=B3=A8=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
report-core/src/main/resources/bootstrap.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/report-core/src/main/resources/bootstrap.yml b/report-core/src/main/resources/bootstrap.yml
index 7192afc6..639edde1 100644
--- a/report-core/src/main/resources/bootstrap.yml
+++ b/report-core/src/main/resources/bootstrap.yml
@@ -49,7 +49,7 @@ spring:
mybatis-plus:
configuration:
- log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+ log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启sql打印
call-setters-on-nulls: true
mapperLocations:
- classpath*:/mapper/**/*.xml