Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
njgzx
dataease
Commits
3f20e23b
提交
3f20e23b
authored
2月 15, 2022
作者:
fit2cloud-chenyw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 公共链接使用8位随机字符后缀,兼容老版本数字后缀
上级
e00785a3
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
162 行增加
和
10 行删除
+162
-10
PanelLinkMapping.java
...c/main/java/io/dataease/base/domain/PanelLinkMapping.java
+3
-0
PanelLinkMappingExample.java
...java/io/dataease/base/domain/PanelLinkMappingExample.java
+70
-0
PanelLinkMappingMapper.xml
...n/java/io/dataease/base/mapper/PanelLinkMappingMapper.xml
+23
-7
CodingUtil.java
...d/src/main/java/io/dataease/commons/utils/CodingUtil.java
+30
-0
IndexController.java
...src/main/java/io/dataease/controller/IndexController.java
+10
-2
PanelLinkService.java
...main/java/io/dataease/service/panel/PanelLinkService.java
+23
-1
V32__1.8.sql
backend/src/main/resources/db/migration/V32__1.8.sql
+3
-0
没有找到文件。
backend/src/main/java/io/dataease/base/domain/PanelLinkMapping.java
浏览文件 @
3f20e23b
...
@@ -11,5 +11,7 @@ public class PanelLinkMapping implements Serializable {
...
@@ -11,5 +11,7 @@ public class PanelLinkMapping implements Serializable {
private
Long
userId
;
private
Long
userId
;
private
String
uuid
;
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
}
}
\ No newline at end of file
backend/src/main/java/io/dataease/base/domain/PanelLinkMappingExample.java
浏览文件 @
3f20e23b
...
@@ -293,6 +293,76 @@ public class PanelLinkMappingExample {
...
@@ -293,6 +293,76 @@ public class PanelLinkMappingExample {
addCriterion
(
"user_id not between"
,
value1
,
value2
,
"userId"
);
addCriterion
(
"user_id not between"
,
value1
,
value2
,
"userId"
);
return
(
Criteria
)
this
;
return
(
Criteria
)
this
;
}
}
public
Criteria
andUuidIsNull
()
{
addCriterion
(
"uuid is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUuidIsNotNull
()
{
addCriterion
(
"uuid is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUuidEqualTo
(
String
value
)
{
addCriterion
(
"uuid ="
,
value
,
"uuid"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUuidNotEqualTo
(
String
value
)
{
addCriterion
(
"uuid <>"
,
value
,
"uuid"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUuidGreaterThan
(
String
value
)
{
addCriterion
(
"uuid >"
,
value
,
"uuid"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUuidGreaterThanOrEqualTo
(
String
value
)
{
addCriterion
(
"uuid >="
,
value
,
"uuid"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUuidLessThan
(
String
value
)
{
addCriterion
(
"uuid <"
,
value
,
"uuid"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUuidLessThanOrEqualTo
(
String
value
)
{
addCriterion
(
"uuid <="
,
value
,
"uuid"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUuidLike
(
String
value
)
{
addCriterion
(
"uuid like"
,
value
,
"uuid"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUuidNotLike
(
String
value
)
{
addCriterion
(
"uuid not like"
,
value
,
"uuid"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUuidIn
(
List
<
String
>
values
)
{
addCriterion
(
"uuid in"
,
values
,
"uuid"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUuidNotIn
(
List
<
String
>
values
)
{
addCriterion
(
"uuid not in"
,
values
,
"uuid"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUuidBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"uuid between"
,
value1
,
value2
,
"uuid"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUuidNotBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"uuid not between"
,
value1
,
value2
,
"uuid"
);
return
(
Criteria
)
this
;
}
}
}
public
static
class
Criteria
extends
GeneratedCriteria
{
public
static
class
Criteria
extends
GeneratedCriteria
{
...
...
backend/src/main/java/io/dataease/base/mapper/PanelLinkMappingMapper.xml
浏览文件 @
3f20e23b
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"resource_id"
jdbcType=
"VARCHAR"
property=
"resourceId"
/>
<result
column=
"resource_id"
jdbcType=
"VARCHAR"
property=
"resourceId"
/>
<result
column=
"user_id"
jdbcType=
"BIGINT"
property=
"userId"
/>
<result
column=
"user_id"
jdbcType=
"BIGINT"
property=
"userId"
/>
<result
column=
"uuid"
jdbcType=
"VARCHAR"
property=
"uuid"
/>
</resultMap>
</resultMap>
<sql
id=
"Example_Where_Clause"
>
<sql
id=
"Example_Where_Clause"
>
<where>
<where>
...
@@ -65,7 +66,7 @@
...
@@ -65,7 +66,7 @@
</where>
</where>
</sql>
</sql>
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
id, resource_id, user_id
id, resource_id, user_id
, uuid
</sql>
</sql>
<select
id=
"selectByExample"
parameterType=
"io.dataease.base.domain.PanelLinkMappingExample"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByExample"
parameterType=
"io.dataease.base.domain.PanelLinkMappingExample"
resultMap=
"BaseResultMap"
>
select
select
...
@@ -98,10 +99,10 @@
...
@@ -98,10 +99,10 @@
</if>
</if>
</delete>
</delete>
<insert
id=
"insert"
parameterType=
"io.dataease.base.domain.PanelLinkMapping"
>
<insert
id=
"insert"
parameterType=
"io.dataease.base.domain.PanelLinkMapping"
>
insert into panel_link_mapping (id, resource_id, user_id
insert into panel_link_mapping (id, resource_id, user_id
,
)
uuid
)
values (#{id,jdbcType=BIGINT}, #{resourceId,jdbcType=VARCHAR}, #{userId,jdbcType=BIGINT}
values (#{id,jdbcType=BIGINT}, #{resourceId,jdbcType=VARCHAR}, #{userId,jdbcType=BIGINT}
,
)
#{uuid,jdbcType=VARCHAR}
)
</insert>
</insert>
<insert
id=
"insertSelective"
parameterType=
"io.dataease.base.domain.PanelLinkMapping"
>
<insert
id=
"insertSelective"
parameterType=
"io.dataease.base.domain.PanelLinkMapping"
>
insert into panel_link_mapping
insert into panel_link_mapping
...
@@ -115,6 +116,9 @@
...
@@ -115,6 +116,9 @@
<if
test=
"userId != null"
>
<if
test=
"userId != null"
>
user_id,
user_id,
</if>
</if>
<if
test=
"uuid != null"
>
uuid,
</if>
</trim>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
<if
test=
"id != null"
>
...
@@ -126,6 +130,9 @@
...
@@ -126,6 +130,9 @@
<if
test=
"userId != null"
>
<if
test=
"userId != null"
>
#{userId,jdbcType=BIGINT},
#{userId,jdbcType=BIGINT},
</if>
</if>
<if
test=
"uuid != null"
>
#{uuid,jdbcType=VARCHAR},
</if>
</trim>
</trim>
</insert>
</insert>
<select
id=
"countByExample"
parameterType=
"io.dataease.base.domain.PanelLinkMappingExample"
resultType=
"java.lang.Long"
>
<select
id=
"countByExample"
parameterType=
"io.dataease.base.domain.PanelLinkMappingExample"
resultType=
"java.lang.Long"
>
...
@@ -146,6 +153,9 @@
...
@@ -146,6 +153,9 @@
<if
test=
"record.userId != null"
>
<if
test=
"record.userId != null"
>
user_id = #{record.userId,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
</if>
</if>
<if
test=
"record.uuid != null"
>
uuid = #{record.uuid,jdbcType=VARCHAR},
</if>
</set>
</set>
<if
test=
"_parameter != null"
>
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
<include
refid=
"Update_By_Example_Where_Clause"
/>
...
@@ -155,7 +165,8 @@
...
@@ -155,7 +165,8 @@
update panel_link_mapping
update panel_link_mapping
set id = #{record.id,jdbcType=BIGINT},
set id = #{record.id,jdbcType=BIGINT},
resource_id = #{record.resourceId,jdbcType=VARCHAR},
resource_id = #{record.resourceId,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=BIGINT}
user_id = #{record.userId,jdbcType=BIGINT},
uuid = #{record.uuid,jdbcType=VARCHAR}
<if
test=
"_parameter != null"
>
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
</if>
...
@@ -169,13 +180,17 @@
...
@@ -169,13 +180,17 @@
<if
test=
"userId != null"
>
<if
test=
"userId != null"
>
user_id = #{userId,jdbcType=BIGINT},
user_id = #{userId,jdbcType=BIGINT},
</if>
</if>
<if
test=
"uuid != null"
>
uuid = #{uuid,jdbcType=VARCHAR},
</if>
</set>
</set>
where id = #{id,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"io.dataease.base.domain.PanelLinkMapping"
>
<update
id=
"updateByPrimaryKey"
parameterType=
"io.dataease.base.domain.PanelLinkMapping"
>
update panel_link_mapping
update panel_link_mapping
set resource_id = #{resourceId,jdbcType=VARCHAR},
set resource_id = #{resourceId,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=BIGINT}
user_id = #{userId,jdbcType=BIGINT},
uuid = #{uuid,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
</update>
</mapper>
</mapper>
\ No newline at end of file
backend/src/main/java/io/dataease/commons/utils/CodingUtil.java
浏览文件 @
3f20e23b
...
@@ -7,6 +7,7 @@ import javax.crypto.*;
...
@@ -7,6 +7,7 @@ import javax.crypto.*;
import
javax.crypto.spec.IvParameterSpec
;
import
javax.crypto.spec.IvParameterSpec
;
import
javax.crypto.spec.SecretKeySpec
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.security.MessageDigest
;
import
java.security.MessageDigest
;
import
java.util.UUID
;
/**
/**
* 加密解密工具
* 加密解密工具
...
@@ -19,6 +20,13 @@ public class CodingUtil {
...
@@ -19,6 +20,13 @@ public class CodingUtil {
private
static
final
char
[]
HEX_DIGITS
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
private
static
final
char
[]
HEX_DIGITS
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
public
static
String
[]
chars
=
new
String
[]
{
"a"
,
"b"
,
"c"
,
"d"
,
"e"
,
"f"
,
"g"
,
"h"
,
"i"
,
"j"
,
"k"
,
"l"
,
"m"
,
"n"
,
"o"
,
"p"
,
"q"
,
"r"
,
"s"
,
"t"
,
"u"
,
"v"
,
"w"
,
"x"
,
"y"
,
"z"
,
"0"
,
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"A"
,
"B"
,
"C"
,
"D"
,
"E"
,
"F"
,
"G"
,
"H"
,
"I"
,
"J"
,
"K"
,
"L"
,
"M"
,
"N"
,
"O"
,
"P"
,
"Q"
,
"R"
,
"S"
,
"T"
,
"U"
,
"V"
,
"W"
,
"X"
,
"Y"
,
"Z"
};
/**
/**
* MD5加密
* MD5加密
*
*
...
@@ -165,4 +173,26 @@ public class CodingUtil {
...
@@ -165,4 +173,26 @@ public class CodingUtil {
}
}
}
}
public
static
boolean
isNumeric
(
String
str
){
for
(
int
i
=
str
.
length
();--
i
>=
0
;){
if
(!
Character
.
isDigit
(
str
.
charAt
(
i
))){
return
false
;
}
}
return
true
;
}
public
static
String
shortUuid
()
{
StringBuffer
shortBuffer
=
new
StringBuffer
();
String
uuid
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
for
(
int
i
=
0
;
i
<
8
;
i
++)
{
String
str
=
uuid
.
substring
(
i
*
4
,
i
*
4
+
4
);
int
x
=
Integer
.
parseInt
(
str
,
16
);
shortBuffer
.
append
(
chars
[
x
%
0x3E
]);
}
return
shortBuffer
.
toString
();
}
}
}
backend/src/main/java/io/dataease/controller/IndexController.java
浏览文件 @
3f20e23b
...
@@ -3,6 +3,7 @@ package io.dataease.controller;
...
@@ -3,6 +3,7 @@ package io.dataease.controller;
import
io.dataease.commons.exception.DEException
;
import
io.dataease.commons.exception.DEException
;
import
io.dataease.commons.license.DefaultLicenseService
;
import
io.dataease.commons.license.DefaultLicenseService
;
import
io.dataease.commons.license.F2CLicenseResponse
;
import
io.dataease.commons.license.F2CLicenseResponse
;
import
io.dataease.commons.utils.CodingUtil
;
import
io.dataease.commons.utils.LogUtil
;
import
io.dataease.commons.utils.LogUtil
;
import
io.dataease.commons.utils.ServletUtils
;
import
io.dataease.commons.utils.ServletUtils
;
import
io.dataease.service.panel.PanelLinkService
;
import
io.dataease.service.panel.PanelLinkService
;
...
@@ -48,8 +49,13 @@ public class IndexController {
...
@@ -48,8 +49,13 @@ public class IndexController {
}
}
@GetMapping
(
"/link/{index}"
)
@GetMapping
(
"/link/{index}"
)
public
void
link
(
@PathVariable
(
value
=
"index"
,
required
=
true
)
Long
index
)
{
public
void
link
(
@PathVariable
(
value
=
"index"
,
required
=
true
)
String
index
)
{
String
url
=
panelLinkService
.
getUrlByIndex
(
index
);
String
url
;
if
(
CodingUtil
.
isNumeric
(
index
))
{
url
=
panelLinkService
.
getUrlByIndex
(
Long
.
parseLong
(
index
));
}
else
{
url
=
panelLinkService
.
getUrlByUuid
(
index
);
}
HttpServletResponse
response
=
ServletUtils
.
response
();
HttpServletResponse
response
=
ServletUtils
.
response
();
try
{
try
{
response
.
sendRedirect
(
url
);
response
.
sendRedirect
(
url
);
...
@@ -59,6 +65,8 @@ public class IndexController {
...
@@ -59,6 +65,8 @@ public class IndexController {
}
}
}
}
@GetMapping
(
"/tempMobileLink/{id}/{token}"
)
@GetMapping
(
"/tempMobileLink/{id}/{token}"
)
public
void
tempMobileLink
(
@PathVariable
(
"id"
)
String
id
,
@PathVariable
(
"token"
)
String
token
)
{
public
void
tempMobileLink
(
@PathVariable
(
"id"
)
String
id
,
@PathVariable
(
"token"
)
String
token
)
{
String
url
=
"/#preview/"
+
id
;
String
url
=
"/#preview/"
+
id
;
...
...
backend/src/main/java/io/dataease/service/panel/PanelLinkService.java
浏览文件 @
3f20e23b
...
@@ -8,7 +8,9 @@ import io.dataease.base.mapper.PanelGroupMapper;
...
@@ -8,7 +8,9 @@ import io.dataease.base.mapper.PanelGroupMapper;
import
io.dataease.base.mapper.PanelLinkMapper
;
import
io.dataease.base.mapper.PanelLinkMapper
;
import
io.dataease.base.mapper.PanelLinkMappingMapper
;
import
io.dataease.base.mapper.PanelLinkMappingMapper
;
import
io.dataease.base.mapper.ext.ExtPanelLinkMapper
;
import
io.dataease.base.mapper.ext.ExtPanelLinkMapper
;
import
io.dataease.commons.exception.DEException
;
import
io.dataease.commons.utils.AuthUtils
;
import
io.dataease.commons.utils.AuthUtils
;
import
io.dataease.commons.utils.CodingUtil
;
import
io.dataease.commons.utils.ServletUtils
;
import
io.dataease.commons.utils.ServletUtils
;
import
io.dataease.controller.request.panel.link.EnablePwdRequest
;
import
io.dataease.controller.request.panel.link.EnablePwdRequest
;
import
io.dataease.controller.request.panel.link.LinkRequest
;
import
io.dataease.controller.request.panel.link.LinkRequest
;
...
@@ -114,7 +116,13 @@ public class PanelLinkService {
...
@@ -114,7 +116,13 @@ public class PanelLinkService {
PanelLinkMapping
mapping
=
new
PanelLinkMapping
();
PanelLinkMapping
mapping
=
new
PanelLinkMapping
();
mapping
.
setResourceId
(
resourceId
);
mapping
.
setResourceId
(
resourceId
);
mapping
.
setUserId
(
AuthUtils
.
getUser
().
getUserId
());
mapping
.
setUserId
(
AuthUtils
.
getUser
().
getUserId
());
mapping
.
setUuid
(
CodingUtil
.
shortUuid
());
panelLinkMappingMapper
.
insert
(
mapping
);
panelLinkMappingMapper
.
insert
(
mapping
);
}
else
{
mappings
.
stream
().
filter
(
mapping
->
StringUtils
.
isBlank
(
mapping
.
getUuid
())).
forEach
(
item
->
{
item
.
setUuid
(
CodingUtil
.
shortUuid
());
panelLinkMappingMapper
.
updateByPrimaryKey
(
item
);
});
}
}
return
convertDto
(
one
);
return
convertDto
(
one
);
}
}
...
@@ -206,7 +214,7 @@ public class PanelLinkService {
...
@@ -206,7 +214,7 @@ public class PanelLinkService {
example
.
createCriteria
().
andResourceIdEqualTo
(
resourceId
).
andUserIdEqualTo
(
AuthUtils
.
getUser
().
getUserId
());
example
.
createCriteria
().
andResourceIdEqualTo
(
resourceId
).
andUserIdEqualTo
(
AuthUtils
.
getUser
().
getUserId
());
List
<
PanelLinkMapping
>
mappings
=
panelLinkMappingMapper
.
selectByExample
(
example
);
List
<
PanelLinkMapping
>
mappings
=
panelLinkMappingMapper
.
selectByExample
(
example
);
PanelLinkMapping
mapping
=
mappings
.
get
(
0
);
PanelLinkMapping
mapping
=
mappings
.
get
(
0
);
return
SHORT_URL_PREFIX
+
mapping
.
get
I
d
();
return
SHORT_URL_PREFIX
+
mapping
.
get
Uui
d
();
}
}
public
String
getUrlByIndex
(
Long
index
)
{
public
String
getUrlByIndex
(
Long
index
)
{
...
@@ -216,4 +224,18 @@ public class PanelLinkService {
...
@@ -216,4 +224,18 @@ public class PanelLinkService {
PanelLink
one
=
findOne
(
resourceId
,
userId
);
PanelLink
one
=
findOne
(
resourceId
,
userId
);
return
convertDto
(
one
).
getUri
();
return
convertDto
(
one
).
getUri
();
}
}
public
String
getUrlByUuid
(
String
uuid
)
{
PanelLinkMappingExample
example
=
new
PanelLinkMappingExample
();
example
.
createCriteria
().
andUuidEqualTo
(
uuid
);
List
<
PanelLinkMapping
>
mappings
=
panelLinkMappingMapper
.
selectByExample
(
example
);
if
(
CollectionUtils
.
isEmpty
(
mappings
))
{
DEException
.
throwException
(
"link is not exist"
);
}
PanelLinkMapping
mapping
=
mappings
.
get
(
0
);
String
resourceId
=
mapping
.
getResourceId
();
Long
userId
=
mapping
.
getUserId
();
PanelLink
one
=
findOne
(
resourceId
,
userId
);
return
convertDto
(
one
).
getUri
();
}
}
}
backend/src/main/resources/db/migration/V32__1.8.sql
浏览文件 @
3f20e23b
...
@@ -197,3 +197,6 @@ SELECT
...
@@ -197,3 +197,6 @@ SELECT
`plugin_sys_menu`
.
`i_frame`
<>
1
`plugin_sys_menu`
.
`i_frame`
<>
1
)
)
OR
isnull
(
`plugin_sys_menu`
.
`i_frame`
));
OR
isnull
(
`plugin_sys_menu`
.
`i_frame`
));
ALTER
TABLE
`panel_link_mapping`
ADD
COLUMN
`uuid`
varchar
(
8
)
NULL
COMMENT
'uuid'
AFTER
`user_id`
;
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论