forked from github/dataease
perf: 公共链接ticket机制页面优化
This commit is contained in:
parent
07640c4bf7
commit
760b4cf812
@ -71,6 +71,10 @@ public class IndexController {
|
||||
if (StringUtils.isNotEmpty(fromLink)) {
|
||||
url = url + "&fromLink=" + fromLink;
|
||||
}
|
||||
String ticket = request.getParameter("ticket");
|
||||
if (StringUtils.isNotEmpty(ticket)) {
|
||||
url = url + "&ticket=" + ticket;
|
||||
}
|
||||
response.sendRedirect(url);
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e.getMessage());
|
||||
|
@ -84,4 +84,8 @@ public interface LinkApi {
|
||||
@ApiOperation("删除ticket")
|
||||
@PostMapping("/delTicket")
|
||||
void deleteTicket(@RequestBody TicketDelRequest request);
|
||||
|
||||
@ApiOperation("切换是否必填ticket")
|
||||
@PostMapping("/enableTicket")
|
||||
void switchRequire(@RequestBody TicketSwitchRequest request);
|
||||
}
|
||||
|
@ -9,9 +9,11 @@ import io.dataease.controller.panel.api.LinkApi;
|
||||
import io.dataease.controller.request.chart.ChartExtRequest;
|
||||
import io.dataease.controller.request.panel.link.*;
|
||||
import io.dataease.dto.panel.link.GenerateDto;
|
||||
import io.dataease.dto.panel.link.TicketDto;
|
||||
import io.dataease.dto.panel.link.ValidateDto;
|
||||
import io.dataease.plugins.common.base.domain.PanelGroupWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.PanelLink;
|
||||
import io.dataease.plugins.common.base.domain.PanelLinkMapping;
|
||||
import io.dataease.plugins.common.base.domain.PanelLinkTicket;
|
||||
import io.dataease.service.chart.ChartViewService;
|
||||
import io.dataease.service.panel.PanelLinkService;
|
||||
@ -95,7 +97,8 @@ public class LinkServer implements LinkApi {
|
||||
dto.setValid(false);
|
||||
return dto;
|
||||
}
|
||||
String mappingUuid = panelLinkService.getMappingUuid(one);
|
||||
PanelLinkMapping mapping = panelLinkService.getMapping(one);
|
||||
String mappingUuid = mapping.getUuid();
|
||||
if (!StringUtils.equals(uuid, mappingUuid)) {
|
||||
dto.setValid(false);
|
||||
return dto;
|
||||
@ -104,6 +107,10 @@ public class LinkServer implements LinkApi {
|
||||
dto.setEnablePwd(one.getEnablePwd());
|
||||
dto.setPassPwd(panelLinkService.validateHeads(one));
|
||||
dto.setExpire(panelLinkService.isExpire(one));
|
||||
|
||||
String ticketText = request.getTicket();
|
||||
TicketDto ticketDto = panelLinkService.validateTicket(ticketText, mapping);
|
||||
dto.setTicket(ticketDto);
|
||||
return dto;
|
||||
}
|
||||
|
||||
@ -158,4 +165,9 @@ public class LinkServer implements LinkApi {
|
||||
public void deleteTicket(TicketDelRequest request) {
|
||||
panelLinkService.deleteTicket(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchRequire(TicketSwitchRequest request) {
|
||||
panelLinkService.switchRequire(request);
|
||||
}
|
||||
}
|
||||
|
@ -9,4 +9,5 @@ public class LinkValidateRequest implements Serializable {
|
||||
|
||||
private String link;
|
||||
private String user;
|
||||
private String ticket;
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package io.dataease.controller.request.panel.link;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class TicketSwitchRequest implements Serializable {
|
||||
|
||||
private String resourceId;
|
||||
|
||||
private Boolean require = false;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package io.dataease.dto.panel.link;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class TicketDto implements Serializable {
|
||||
|
||||
private boolean ticketValid;
|
||||
|
||||
private boolean ticketExp;
|
||||
|
||||
private String args;
|
||||
}
|
@ -19,4 +19,6 @@ public class ValidateDto {
|
||||
private String resourceId;
|
||||
@ApiModelProperty("用户ID")
|
||||
private String userId;
|
||||
|
||||
private TicketDto ticket;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.controller.request.panel.link.*;
|
||||
import io.dataease.dto.panel.PanelGroupDTO;
|
||||
import io.dataease.dto.panel.link.GenerateDto;
|
||||
import io.dataease.dto.panel.link.TicketDto;
|
||||
import io.dataease.ext.ExtPanelGroupMapper;
|
||||
import io.dataease.ext.ExtPanelLinkMapper;
|
||||
import io.dataease.plugins.common.base.domain.*;
|
||||
@ -128,13 +129,13 @@ public class PanelLinkService {
|
||||
}
|
||||
}
|
||||
|
||||
public String getMappingUuid(PanelLink link) {
|
||||
public PanelLinkMapping getMapping(PanelLink link) {
|
||||
String resourceId = link.getResourceId();
|
||||
Long userId = link.getUserId();
|
||||
PanelLinkMappingExample example = new PanelLinkMappingExample();
|
||||
example.createCriteria().andResourceIdEqualTo(resourceId).andUserIdEqualTo(userId);
|
||||
List<PanelLinkMapping> mappings = panelLinkMappingMapper.selectByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(mappings)) return mappings.get(0).getUuid();
|
||||
if (CollectionUtils.isNotEmpty(mappings)) return mappings.get(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -291,8 +292,12 @@ public class PanelLinkService {
|
||||
PanelLinkTicketExample example = new PanelLinkTicketExample();
|
||||
example.createCriteria().andTicketEqualTo(ticket);
|
||||
if (creator.isGenerateNew()) {
|
||||
ticketEntity.setAccessTime(null);
|
||||
ticketEntity.setTicket(CodingUtil.shortUuid());
|
||||
}
|
||||
ticketEntity.setArgs(creator.getArgs());
|
||||
ticketEntity.setExp(creator.getExp());
|
||||
ticketEntity.setUuid(creator.getUuid());
|
||||
panelLinkTicketMapper.updateByExample(ticketEntity, example);
|
||||
return ticketEntity.getTicket();
|
||||
}
|
||||
@ -317,7 +322,15 @@ public class PanelLinkService {
|
||||
panelLinkTicketMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
|
||||
public void switchRequire(TicketSwitchRequest request) {
|
||||
String resourceId = request.getResourceId();
|
||||
Boolean require = request.getRequire();
|
||||
PanelLinkMappingExample example = new PanelLinkMappingExample();
|
||||
example.createCriteria().andResourceIdEqualTo(resourceId).andUserIdEqualTo(AuthUtils.getUser().getUserId());
|
||||
PanelLinkMapping mapping = new PanelLinkMapping();
|
||||
mapping.setRequireTicket(require);
|
||||
panelLinkMappingMapper.updateByExampleSelective(mapping, example);
|
||||
}
|
||||
|
||||
public PanelLinkTicket getByTicket(String ticket) {
|
||||
PanelLinkTicketExample example = new PanelLinkTicketExample();
|
||||
@ -354,4 +367,37 @@ public class PanelLinkService {
|
||||
PanelLink one = findOne(resourceId, userId);
|
||||
return convertDto(one, uuid, mapping.getRequireTicket()).getUri();
|
||||
}
|
||||
|
||||
public TicketDto validateTicket(String ticket, PanelLinkMapping mapping) {
|
||||
String uuid = mapping.getUuid();
|
||||
TicketDto ticketDto = new TicketDto();
|
||||
if (StringUtils.isBlank(ticket)) {
|
||||
ticketDto.setTicketValid(!mapping.getRequireTicket());
|
||||
return ticketDto;
|
||||
}
|
||||
PanelLinkTicketExample example = new PanelLinkTicketExample();
|
||||
example.createCriteria().andTicketEqualTo(ticket).andUuidEqualTo(uuid);
|
||||
List<PanelLinkTicket> tickets = panelLinkTicketMapper.selectByExample(example);
|
||||
if (CollectionUtils.isEmpty(tickets)) {
|
||||
ticketDto.setTicketValid(false);
|
||||
return ticketDto;
|
||||
}
|
||||
PanelLinkTicket linkTicket = tickets.get(0);
|
||||
ticketDto.setTicketValid(true);
|
||||
ticketDto.setArgs(linkTicket.getArgs());
|
||||
Long accessTime = linkTicket.getAccessTime();
|
||||
long now = System.currentTimeMillis();
|
||||
if (ObjectUtils.isEmpty(accessTime)) {
|
||||
accessTime = now;
|
||||
ticketDto.setTicketExp(false);
|
||||
linkTicket.setAccessTime(accessTime);
|
||||
panelLinkTicketMapper.updateByPrimaryKey(linkTicket);
|
||||
return ticketDto;
|
||||
}
|
||||
Long exp = linkTicket.getExp();
|
||||
long expTime = exp * 60L * 1000L;
|
||||
long time = now - accessTime;
|
||||
ticketDto.setTicketExp(time > expTime);
|
||||
return ticketDto;
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,12 @@
|
||||
DROP TABLE IF EXISTS `panel_link_ticket`;
|
||||
CREATE TABLE `panel_link_ticket`
|
||||
(
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`uuid` varchar(255) NOT NULL,
|
||||
`ticket` varchar(255) NOT NULL,
|
||||
`exp` bigint DEFAULT NULL,
|
||||
`args` varchar(255) DEFAULT NULL,
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`uuid` varchar(255) NOT NULL,
|
||||
`ticket` varchar(255) NOT NULL,
|
||||
`exp` bigint DEFAULT NULL,
|
||||
`args` varchar(255) DEFAULT NULL,
|
||||
`access_time` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
AUTO_INCREMENT = 1;
|
||||
|
@ -34,6 +34,7 @@
|
||||
const terminal = getQueryVariable('terminal')
|
||||
const attachParams = getQueryVariable('attachParams')
|
||||
const fromLink = getQueryVariable('fromLink')
|
||||
const ticket = getQueryVariable('ticket')
|
||||
const baseUrl = window.location.pathname.replace('link.html', '')
|
||||
let url = baseUrl + "#/delink?link=" + encodeURIComponent(link)
|
||||
if (terminal) {
|
||||
@ -48,6 +49,9 @@
|
||||
if (fromLink) {
|
||||
url += '&fromLink=' + fromLink
|
||||
}
|
||||
if (ticket) {
|
||||
url += '&ticket=' + ticket
|
||||
}
|
||||
window.location.href = url
|
||||
</script>
|
||||
|
||||
|
@ -50,6 +50,14 @@ export function switchEnablePwd(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function switchEnableTicket(data) {
|
||||
return request({
|
||||
url: 'api/link/enableTicket',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function viewLinkLog(data) {
|
||||
return request({
|
||||
url: 'api/link/viewLog',
|
||||
|
@ -127,19 +127,37 @@
|
||||
class="ticket"
|
||||
>
|
||||
<div class="ticket-model">
|
||||
<el-checkbox v-model="requireTicket" />
|
||||
<el-checkbox
|
||||
v-model="requireTicket"
|
||||
@change="requireTicketChange"
|
||||
/>
|
||||
<span>ticket必选</span>
|
||||
<el-tooltip
|
||||
class="item"
|
||||
effect="dark"
|
||||
content="选择后原始公共链接无效,必须携带ticket参数"
|
||||
placement="top"
|
||||
>
|
||||
<span class="check-tips"><i class="el-icon-warning" /></span>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<div
|
||||
class="ticket-table"
|
||||
>
|
||||
<div class="add-ticket">
|
||||
<span>
|
||||
<i
|
||||
class="el-icon-circle-plus-outline"
|
||||
@click="addRow()"
|
||||
/>
|
||||
</span>
|
||||
<el-tooltip
|
||||
class="item"
|
||||
effect="dark"
|
||||
content="创建"
|
||||
placement="top"
|
||||
>
|
||||
<span>
|
||||
<i
|
||||
class="el-icon-circle-plus-outline"
|
||||
@click="addRow()"
|
||||
/>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<el-table
|
||||
:data="tableData"
|
||||
@ -149,51 +167,83 @@
|
||||
<el-table-column
|
||||
prop="ticket"
|
||||
label="ticket"
|
||||
width="120"
|
||||
width="100"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<div class="ticket-row">
|
||||
<span>{{ scope.row.ticket }}</span>
|
||||
<span class="refresh-i">
|
||||
<i
|
||||
class="el-icon-refresh"
|
||||
@click="refreshTicket(scope.row)"
|
||||
/>
|
||||
</span>
|
||||
<el-tooltip
|
||||
class="item"
|
||||
effect="dark"
|
||||
content="刷新ticket"
|
||||
placement="top"
|
||||
>
|
||||
<span class="refresh-i">
|
||||
<i
|
||||
class="el-icon-refresh"
|
||||
@click="refreshTicket(scope.row)"
|
||||
/>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="exp"
|
||||
label="有效期(分钟)"
|
||||
label="有效期"
|
||||
width="100"
|
||||
>
|
||||
<template slot="header">
|
||||
<span>有效期</span>
|
||||
<el-tooltip
|
||||
class="item"
|
||||
effect="dark"
|
||||
content="单位: 分钟,范围: [0-1440],0代表无期限,自首次使用ticket访问开始"
|
||||
placement="top"
|
||||
>
|
||||
<span class="check-tips"><i class="el-icon-warning" /></span>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-if="scope.row.isEdit"
|
||||
:ref="setExpRef(scope.$index)"
|
||||
v-model="scope.row.exp"
|
||||
type="number"
|
||||
placeholder="请输入内容"
|
||||
min="0"
|
||||
max="1440"
|
||||
size="mini"
|
||||
@change="val => validateExp(val, scope.$index)"
|
||||
/>
|
||||
<span v-else>
|
||||
{{ scope.row.exp }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="args"
|
||||
label="参数"
|
||||
>
|
||||
<el-table-column prop="args">
|
||||
<template slot="header">
|
||||
<span>参数</span>
|
||||
<el-tooltip
|
||||
class="item"
|
||||
effect="dark"
|
||||
content="最大长度200,配合仪表板外部参数使用,必须是json格式,例如: {"arg1": "value1"}"
|
||||
placement="top"
|
||||
>
|
||||
<span class="check-tips"><i class="el-icon-warning" /></span>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-if="scope.row.isEdit"
|
||||
:ref="setArgRef(scope.$index)"
|
||||
v-model="scope.row.args"
|
||||
type="text"
|
||||
placeholder="请输入内容"
|
||||
maxlength="100"
|
||||
maxlength="200"
|
||||
size="mini"
|
||||
@change="val => validateArgs(val, scope.$index)"
|
||||
/>
|
||||
<span v-else>
|
||||
{{ scope.row.args }}
|
||||
@ -206,24 +256,38 @@
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<div class="ticket-op">
|
||||
<span>
|
||||
<i
|
||||
class="el-icon-delete"
|
||||
@click="deleteTicket(scope.row, scope.$idnex)"
|
||||
/>
|
||||
</span>
|
||||
<span>
|
||||
<i
|
||||
v-if="!scope.row.isEdit"
|
||||
class="el-icon-edit"
|
||||
@click="editRow(scope.row)"
|
||||
/>
|
||||
<i
|
||||
v-else
|
||||
class="el-icon-circle-check"
|
||||
@click="saveRow(scope.row)"
|
||||
/>
|
||||
</span>
|
||||
<el-tooltip
|
||||
class="item"
|
||||
effect="dark"
|
||||
content="删除"
|
||||
placement="top"
|
||||
>
|
||||
<span>
|
||||
<i
|
||||
class="el-icon-delete"
|
||||
@click="deleteTicket(scope.row, scope.$idnex)"
|
||||
/>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
<el-tooltip
|
||||
class="item"
|
||||
effect="dark"
|
||||
:content="scope.row.isEdit ? '保存' : '编辑'"
|
||||
placement="top"
|
||||
>
|
||||
<span>
|
||||
<i
|
||||
v-if="!scope.row.isEdit"
|
||||
class="el-icon-edit"
|
||||
@click="editRow(scope.row)"
|
||||
/>
|
||||
<i
|
||||
v-else
|
||||
class="el-icon-circle-check"
|
||||
@click="saveRow(scope.row, scope.$index)"
|
||||
/>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -241,6 +305,7 @@ import {
|
||||
setPwd,
|
||||
switchValid,
|
||||
switchEnablePwd,
|
||||
switchEnableTicket,
|
||||
shortUrl,
|
||||
setOverTime
|
||||
} from '@/api/link'
|
||||
@ -326,13 +391,70 @@ export default {
|
||||
this.currentGenerate()
|
||||
},
|
||||
methods: {
|
||||
setExpRef(index) {
|
||||
return `expRef-${index}`
|
||||
},
|
||||
setArgRef(index) {
|
||||
return `argRef-${index}`
|
||||
},
|
||||
validateExp(val, index) {
|
||||
const refName = this.setExpRef(index)
|
||||
const e = this.$refs[refName].$refs.input
|
||||
if (val === null || val === '' || typeof val === 'undefined') {
|
||||
this.tableData[index]['exp'] = 0
|
||||
return true
|
||||
}
|
||||
if (val > 1440 || val < 0) {
|
||||
e.style.color = 'red'
|
||||
e.style.borderColor = 'red'
|
||||
return false
|
||||
} else {
|
||||
e.style.color = null
|
||||
e.style.borderColor = null
|
||||
return true
|
||||
}
|
||||
},
|
||||
validateArgs(val, index) {
|
||||
const refName = this.setArgRef(index)
|
||||
const e = this.$refs[refName].$refs.input
|
||||
if (val === null || val === '' || typeof val === 'undefined') {
|
||||
return true
|
||||
}
|
||||
try {
|
||||
JSON.parse(val)
|
||||
e.style.color = null
|
||||
e.style.borderColor = null
|
||||
const child = this.$refs[refName].$el.querySelector('.error-msg')
|
||||
if (child) {
|
||||
this.$refs[refName].$el.removeChild(child)
|
||||
}
|
||||
return true
|
||||
} catch (error) {
|
||||
e.style.color = 'red'
|
||||
e.style.borderColor = 'red'
|
||||
const child = this.$refs[refName].$el.querySelector('.error-msg')
|
||||
if (!child) {
|
||||
const errorDom = document.createElement('div')
|
||||
errorDom.className = 'error-msg'
|
||||
errorDom.innerText = '格式错误'
|
||||
this.$refs[refName].$el.appendChild(errorDom)
|
||||
}
|
||||
return false
|
||||
}
|
||||
},
|
||||
requireTicketChange(val) {
|
||||
const param = {
|
||||
resourceId: this.resourceId,
|
||||
require: val
|
||||
}
|
||||
switchEnableTicket(param)
|
||||
},
|
||||
refreshTicket(row) {
|
||||
const param = JSON.parse(JSON.stringify(row))
|
||||
param['generateNew'] = true
|
||||
saveTicketApi(param).then(res => {
|
||||
row.ticket = res.data
|
||||
})
|
||||
console.log(row.ticket)
|
||||
},
|
||||
deleteTicket(row, index) {
|
||||
const param = { ticket: row.ticket }
|
||||
@ -343,8 +465,8 @@ export default {
|
||||
editRow(row) {
|
||||
row.isEdit = true
|
||||
},
|
||||
saveRow(row) {
|
||||
saveTicketApi(row).then(res => {
|
||||
saveRow(row, index) {
|
||||
this.validateExp(row.exp, index) && this.validateArgs(row.args, index) && saveTicketApi(row).then(() => {
|
||||
row.isEdit = false
|
||||
})
|
||||
},
|
||||
@ -368,11 +490,13 @@ export default {
|
||||
enablePwd,
|
||||
pwd,
|
||||
uri,
|
||||
overTime
|
||||
overTime,
|
||||
requireTicket
|
||||
} = res.data
|
||||
this.valid = valid
|
||||
this.form.enablePwd = enablePwd
|
||||
this.form.uri = uri ? (this.origin + uri) : uri
|
||||
this.requireTicket = requireTicket
|
||||
// 返回的密码是共钥加密后的 所以展示需要私钥解密一波
|
||||
pwd && (this.form.pwd = pwd)
|
||||
|
||||
@ -535,10 +659,14 @@ export default {
|
||||
.ticket {
|
||||
padding: 0 20px !important;
|
||||
.ticket-model {
|
||||
padding: 8px 10px;
|
||||
display: flex;
|
||||
padding: 8px 0px 8px 10px;
|
||||
label {
|
||||
margin-right: 8px;
|
||||
}
|
||||
.check-tips {
|
||||
margin: 0 16px 0 4px;
|
||||
}
|
||||
}
|
||||
.ticket-table {
|
||||
padding: 10px 0 10px 8px;
|
||||
@ -565,6 +693,13 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
::v-deep .error-msg {
|
||||
color: red;
|
||||
position: fixed;
|
||||
z-index: 9;
|
||||
font-size: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -602,10 +737,9 @@ export default {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
.refresh-i {
|
||||
margin-left: 5px;
|
||||
height: 16px;
|
||||
height: 17px;
|
||||
width: 16px;
|
||||
line-height: 16px;
|
||||
line-height: 13px;
|
||||
padding: 2px;
|
||||
&:hover {
|
||||
background-color: rgba(51, 112, 255, .1);
|
||||
|
@ -14,12 +14,17 @@
|
||||
v-if="showIndex===2"
|
||||
:resource-id="resourceId"
|
||||
:user="userId"
|
||||
:ticket-args="ticketArgs"
|
||||
/>
|
||||
<link-expire
|
||||
v-if="showIndex===3"
|
||||
:resource-id="resourceId"
|
||||
:user="userId"
|
||||
/>
|
||||
<ticket-error
|
||||
v-if="showIndex === 4 || showIndex === 5"
|
||||
:show-index="showIndex"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
@ -29,9 +34,10 @@ import LinkView from './view'
|
||||
import LinkError from './error'
|
||||
import LinkPwd from './pwd'
|
||||
import LinkExpire from './overtime'
|
||||
import TicketError from './ticket'
|
||||
export default {
|
||||
components: {
|
||||
LinkError, LinkPwd, LinkView, LinkExpire
|
||||
LinkError, LinkPwd, LinkView, LinkExpire, TicketError
|
||||
},
|
||||
|
||||
data() {
|
||||
@ -41,7 +47,9 @@ export default {
|
||||
PARAMKEY: 'link',
|
||||
link: null,
|
||||
user: null,
|
||||
showIndex: -1
|
||||
showIndex: -1,
|
||||
ticket: null,
|
||||
ticketArgs: null
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@ -53,6 +61,7 @@ export default {
|
||||
this.$store.commit('setPublicLinkStatus', true)
|
||||
this.link = this.$route.query.link
|
||||
this.user = this.$route.query.user
|
||||
this.ticket = this.$route.query.ticket
|
||||
if (!this.link) {
|
||||
this.link = getQueryVariable(this.PARAMKEY)
|
||||
}
|
||||
@ -64,10 +73,16 @@ export default {
|
||||
return
|
||||
}
|
||||
const params = this.user ? { link: encodeURIComponent(this.link), user: encodeURIComponent(this.user) } : { link: encodeURIComponent(this.link) }
|
||||
if (this.ticket) {
|
||||
params['ticket'] = this.ticket
|
||||
}
|
||||
this.ticketArgs = null
|
||||
validate(params).then(res => {
|
||||
const { resourceId, valid, enablePwd, passPwd, expire, userId } = res.data
|
||||
const ticketDto = res.data.ticket
|
||||
this.resourceId = resourceId
|
||||
this.userId = userId
|
||||
this.ticketArgs = ticketDto?.args
|
||||
// 如果链接无效 直接显示无效页面
|
||||
if (!valid || !resourceId) {
|
||||
this.showError()
|
||||
@ -84,6 +99,15 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
if (!ticketDto?.ticketValid) {
|
||||
this.showTicketError()
|
||||
return
|
||||
}
|
||||
if (ticketDto?.ticketExp) {
|
||||
this.showTicketExpire()
|
||||
return
|
||||
}
|
||||
|
||||
this.showView()
|
||||
}).catch(() => {
|
||||
this.showError()
|
||||
@ -107,6 +131,12 @@ export default {
|
||||
},
|
||||
showExpire() {
|
||||
this.showIndex = 3
|
||||
},
|
||||
showTicketError() {
|
||||
this.showIndex = 4
|
||||
},
|
||||
showTicketExpire() {
|
||||
this.showIndex = 5
|
||||
}
|
||||
}
|
||||
}
|
||||
|
21
core/frontend/src/views/link/ticket/index.vue
Normal file
21
core/frontend/src/views/link/ticket/index.vue
Normal file
@ -0,0 +1,21 @@
|
||||
<template>
|
||||
<el-empty :description="showIndex === 4 ? errorTips : expTips" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'TicketError',
|
||||
props: {
|
||||
showIndex: {
|
||||
type: Number,
|
||||
default: 4
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
errorTips: 'ticket参数错误',
|
||||
expTips: 'ticket已过期'
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -39,6 +39,10 @@ export default {
|
||||
user: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
ticketArgs: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@ -125,17 +129,35 @@ export default {
|
||||
tempParam && loadingCount++
|
||||
attachParamsEncode && loadingCount++
|
||||
|
||||
if (attachParamsEncode) {
|
||||
let argsObject = null
|
||||
const args = this.ticketArgs
|
||||
try {
|
||||
console.log(args)
|
||||
argsObject = JSON.parse(this.ticketArgs)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
const hasArgs = argsObject && Object.keys(argsObject)
|
||||
if (attachParamsEncode || hasArgs) {
|
||||
try {
|
||||
const Base64 = require('js-base64').Base64
|
||||
const attachParam = JSON.parse(decodeURIComponent(Base64.decode(attachParamsEncode)))
|
||||
getOuterParamsInfo(this.resourceId).then(rsp => {
|
||||
if (--loadingCount === 0) {
|
||||
this.show = true
|
||||
}
|
||||
this.$store.commit('setNowPanelOuterParamsInfo', rsp.data)
|
||||
this.$store.commit('addOuterParamsFilter', attachParam)
|
||||
})
|
||||
let attachParam = null
|
||||
if (attachParamsEncode) {
|
||||
const Base64 = require('js-base64').Base64
|
||||
attachParam = JSON.parse(decodeURIComponent(Base64.decode(attachParamsEncode)))
|
||||
}
|
||||
if (hasArgs) {
|
||||
attachParam = Object.assign({}, attachParam, argsObject)
|
||||
}
|
||||
const hasAttachParam = attachParam && Object.keys(attachParam)
|
||||
if (hasAttachParam) {
|
||||
getOuterParamsInfo(this.resourceId).then(rsp => {
|
||||
if (--loadingCount === 0) {
|
||||
this.show = true
|
||||
}
|
||||
this.$store.commit('setNowPanelOuterParamsInfo', rsp.data)
|
||||
this.$store.commit('addOuterParamsFilter', attachParam)
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
if (--loadingCount === 0) {
|
||||
this.show = true
|
||||
|
@ -15,5 +15,7 @@ public class PanelLinkTicket implements Serializable {
|
||||
|
||||
private String args;
|
||||
|
||||
private Long accessTime;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -433,6 +433,66 @@ public class PanelLinkTicketExample {
|
||||
addCriterion("args not between", value1, value2, "args");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAccessTimeIsNull() {
|
||||
addCriterion("access_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAccessTimeIsNotNull() {
|
||||
addCriterion("access_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAccessTimeEqualTo(Long value) {
|
||||
addCriterion("access_time =", value, "accessTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAccessTimeNotEqualTo(Long value) {
|
||||
addCriterion("access_time <>", value, "accessTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAccessTimeGreaterThan(Long value) {
|
||||
addCriterion("access_time >", value, "accessTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAccessTimeGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("access_time >=", value, "accessTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAccessTimeLessThan(Long value) {
|
||||
addCriterion("access_time <", value, "accessTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAccessTimeLessThanOrEqualTo(Long value) {
|
||||
addCriterion("access_time <=", value, "accessTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAccessTimeIn(List<Long> values) {
|
||||
addCriterion("access_time in", values, "accessTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAccessTimeNotIn(List<Long> values) {
|
||||
addCriterion("access_time not in", values, "accessTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAccessTimeBetween(Long value1, Long value2) {
|
||||
addCriterion("access_time between", value1, value2, "accessTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAccessTimeNotBetween(Long value1, Long value2) {
|
||||
addCriterion("access_time not between", value1, value2, "accessTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
@ -7,6 +7,7 @@
|
||||
<result column="ticket" jdbcType="VARCHAR" property="ticket" />
|
||||
<result column="exp" jdbcType="BIGINT" property="exp" />
|
||||
<result column="args" jdbcType="VARCHAR" property="args" />
|
||||
<result column="access_time" jdbcType="BIGINT" property="accessTime" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
@ -67,7 +68,7 @@
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, uuid, ticket, `exp`, args
|
||||
id, uuid, ticket, `exp`, args, access_time
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.dataease.plugins.common.base.domain.PanelLinkTicketExample" resultMap="BaseResultMap">
|
||||
select
|
||||
@ -101,9 +102,11 @@
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.dataease.plugins.common.base.domain.PanelLinkTicket">
|
||||
insert into panel_link_ticket (id, uuid, ticket,
|
||||
`exp`, args)
|
||||
`exp`, args, access_time
|
||||
)
|
||||
values (#{id,jdbcType=BIGINT}, #{uuid,jdbcType=VARCHAR}, #{ticket,jdbcType=VARCHAR},
|
||||
#{exp,jdbcType=BIGINT}, #{args,jdbcType=VARCHAR})
|
||||
#{exp,jdbcType=BIGINT}, #{args,jdbcType=VARCHAR}, #{accessTime,jdbcType=BIGINT}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.dataease.plugins.common.base.domain.PanelLinkTicket">
|
||||
insert into panel_link_ticket
|
||||
@ -123,6 +126,9 @@
|
||||
<if test="args != null">
|
||||
args,
|
||||
</if>
|
||||
<if test="accessTime != null">
|
||||
access_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
@ -140,6 +146,9 @@
|
||||
<if test="args != null">
|
||||
#{args,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="accessTime != null">
|
||||
#{accessTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.dataease.plugins.common.base.domain.PanelLinkTicketExample" resultType="java.lang.Long">
|
||||
@ -166,6 +175,9 @@
|
||||
<if test="record.args != null">
|
||||
args = #{record.args,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.accessTime != null">
|
||||
access_time = #{record.accessTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
@ -177,7 +189,8 @@
|
||||
uuid = #{record.uuid,jdbcType=VARCHAR},
|
||||
ticket = #{record.ticket,jdbcType=VARCHAR},
|
||||
`exp` = #{record.exp,jdbcType=BIGINT},
|
||||
args = #{record.args,jdbcType=VARCHAR}
|
||||
args = #{record.args,jdbcType=VARCHAR},
|
||||
access_time = #{record.accessTime,jdbcType=BIGINT}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
@ -197,6 +210,9 @@
|
||||
<if test="args != null">
|
||||
args = #{args,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="accessTime != null">
|
||||
access_time = #{accessTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
@ -205,7 +221,8 @@
|
||||
set uuid = #{uuid,jdbcType=VARCHAR},
|
||||
ticket = #{ticket,jdbcType=VARCHAR},
|
||||
`exp` = #{exp,jdbcType=BIGINT},
|
||||
args = #{args,jdbcType=VARCHAR}
|
||||
args = #{args,jdbcType=VARCHAR},
|
||||
access_time = #{accessTime,jdbcType=BIGINT}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
</mapper>
|
@ -63,7 +63,7 @@
|
||||
|
||||
|
||||
|
||||
<table tableName="chart_view">
|
||||
<table tableName="panel_link_ticket">
|
||||
|
||||
</table>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user