报表分享跳转问题

Raod 3 years ago
parent d235f9c329
commit ee077aad7d

@ -1,71 +1,69 @@
//
//package com.anjiplus.template.gaea.business.modules.reportshare.controller; package com.anjiplus.template.gaea.business.modules.reportshare.controller;
//
//import com.anji.plus.gaea.annotation.AccessKey; import com.anji.plus.gaea.annotation.AccessKey;
//import com.anji.plus.gaea.annotation.Permission; import com.anji.plus.gaea.annotation.Permission;
//import com.anji.plus.gaea.annotation.log.GaeaAuditLog; import com.anji.plus.gaea.bean.ResponseBean;
//import com.anji.plus.gaea.bean.ResponseBean; import com.anji.plus.gaea.curd.controller.GaeaBaseController;
//import com.anji.plus.gaea.curd.controller.GaeaBaseController; import com.anji.plus.gaea.curd.service.GaeaBaseService;
//import com.anji.plus.gaea.curd.service.GaeaBaseService; import com.anji.plus.gaea.utils.GaeaBeanUtils;
//import com.anji.plus.gaea.utils.GaeaBeanUtils; import com.anji.plus.gaea.utils.GaeaUtils;
//import com.anji.plus.gaea.utils.GaeaUtils; import com.anjiplus.template.gaea.business.modules.reportshare.controller.dto.ReportShareDto;
//import com.anjiplus.template.gaea.business.modules.reportshare.controller.dto.ReportShareDto; import com.anjiplus.template.gaea.business.modules.reportshare.controller.param.ReportShareParam;
//import com.anjiplus.template.gaea.business.modules.reportshare.controller.param.ReportShareParam; import com.anjiplus.template.gaea.business.modules.reportshare.dao.entity.ReportShare;
//import com.anjiplus.template.gaea.business.modules.reportshare.dao.entity.ReportShare; import com.anjiplus.template.gaea.business.modules.reportshare.service.ReportShareService;
//import com.anjiplus.template.gaea.business.modules.reportshare.service.ReportShareService; import io.swagger.annotations.Api;
//import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*;
//import org.springframework.validation.annotation.Validated;
//import org.springframework.web.bind.annotation.*; /**
// * @author Raod
///** * @desc controller
// * @author Raod * @date 2021-08-18 13:37:26.663
// * @desc 报表分享 controller **/
// * @date 2021-08-18 13:37:26.663 @RestController
// **/ @Api(tags = "报表分享管理")
//@RestController @RequestMapping("/reportShare")
//@Api(tags = "报表分享管理") @Permission(code = "reportShareManage", name = "报表分享管理")
//@RequestMapping("/reportShare") public class ReportShareController extends GaeaBaseController<ReportShareParam, ReportShare, ReportShareDto> {
//@Permission(code = "reportShareManage", name = "报表分享管理")
//public class ReportShareController extends GaeaBaseController<ReportShareParam, ReportShare, ReportShareDto> { @Autowired
// private ReportShareService reportShareService;
// @Autowired
// private ReportShareService reportShareService; @Override
// public GaeaBaseService<ReportShareParam, ReportShare> getService() {
// @Override return reportShareService;
// public GaeaBaseService<ReportShareParam, ReportShare> getService() { }
// return reportShareService;
// } @Override
// public ReportShare getEntity() {
// @Override return new ReportShare();
// public ReportShare getEntity() { }
// return new ReportShare();
// } @Override
// public ReportShareDto getDTO() {
// @Override return new ReportShareDto();
// public ReportShareDto getDTO() { }
// return new ReportShareDto();
// }
// @GetMapping({"/{id}"})
// @AccessKey
// @GetMapping({"/{id}"}) @Override
// @AccessKey @Permission(code = "detail", name = "明细")
// @Override public ResponseBean detail(@PathVariable("id") Long id) {
// @Permission(code = "detail", name = "明细") this.logger.info("{}根据ID查询服务开始id为{}", this.getClass().getSimpleName(), id);
// public ResponseBean detail(@PathVariable("id") Long id) { ReportShare result = reportShareService.getDetail(id);
// this.logger.info("{}根据ID查询服务开始id为{}", this.getClass().getSimpleName(), id); ReportShareDto dto = this.getDTO();
// ReportShare result = reportShareService.getDetail(id); GaeaBeanUtils.copyAndFormatter(result, dto);
// ReportShareDto dto = this.getDTO(); ResponseBean responseBean = this.responseSuccessWithData(this.resultDtoHandle(dto));
// GaeaBeanUtils.copyAndFormatter(result, dto); this.logger.info("{}根据ID查询结束结果{}", this.getClass().getSimpleName(), GaeaUtils.toJSONString(responseBean));
// ResponseBean responseBean = this.responseSuccessWithData(this.resultDtoHandle(dto)); return responseBean;
// this.logger.info("{}根据ID查询结束结果{}", this.getClass().getSimpleName(), GaeaUtils.toJSONString(responseBean)); }
// return responseBean;
// } @GetMapping({"/detailByCode"})
// @Permission(code = "detail", name = "明细")
// @GetMapping({"/detailByCode"}) public ResponseBean detailByCode(@RequestParam("shareCode") String shareCode) {
// @Permission(code = "detail", name = "明细") return ResponseBean.builder().data(reportShareService.detailByCode(shareCode)).build();
// public ResponseBean detailByCode(@RequestParam("shareCode") String shareCode) { }
// return ResponseBean.builder().data(reportShareService.detailByCode(shareCode)).build();
// } }
//
//}

@ -4,6 +4,8 @@ package com.anjiplus.template.gaea.business.modules.reportshare.service.impl;
import com.anji.plus.gaea.constant.BaseOperationEnum; import com.anji.plus.gaea.constant.BaseOperationEnum;
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
import com.anji.plus.gaea.exception.BusinessException; import com.anji.plus.gaea.exception.BusinessException;
import com.anji.plus.gaea.exception.BusinessExceptionBuilder;
import com.anjiplus.template.gaea.business.code.ResponseCode;
import com.anjiplus.template.gaea.business.enums.EnableFlagEnum; import com.anjiplus.template.gaea.business.enums.EnableFlagEnum;
import com.anjiplus.template.gaea.business.modules.reportshare.controller.dto.ReportShareDto; import com.anjiplus.template.gaea.business.modules.reportshare.controller.dto.ReportShareDto;
import com.anjiplus.template.gaea.business.modules.reportshare.dao.ReportShareMapper; import com.anjiplus.template.gaea.business.modules.reportshare.dao.ReportShareMapper;
@ -63,8 +65,12 @@ public class ReportShareServiceImpl implements ReportShareService {
public ReportShare detailByCode(String shareCode) { public ReportShare detailByCode(String shareCode) {
LambdaQueryWrapper<ReportShare> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<ReportShare> wrapper = Wrappers.lambdaQuery();
wrapper.eq(ReportShare::getShareCode, shareCode); wrapper.eq(ReportShare::getShareCode, shareCode);
wrapper.eq(ReportShare::getEnableFlag, EnableFlagEnum.ENABLE.getCodeDesc()); wrapper.eq(ReportShare::getEnableFlag, EnableFlagEnum.ENABLE.getCodeValue());
return selectOne(wrapper); ReportShare reportShare = selectOne(wrapper);
if (null == reportShare) {
throw BusinessExceptionBuilder.build(ResponseCode.REPORT_SHARE_LINK_INVALID);
}
return reportShare;
} }
@Override @Override

@ -73,7 +73,7 @@ customer:
downloadPath: http://10.108.26.197:9095/file/download downloadPath: http://10.108.26.197:9095/file/download
# 跳过token验证和权限验证的url清单 # 跳过token验证和权限验证的url清单
skip-authenticate-urls: /gaeaDict/all, /login, /static, /file/download/, /index.html, /favicon.ico skip-authenticate-urls: /gaeaDict/all, /login, /static, /file/download/, /index.html, /favicon.ico, /reportShare/detailByCode
user: user:
##新增用户默认密码 ##新增用户默认密码
default: default:

@ -1,4 +1,5 @@
import request from '@/utils/request' import request from '@/utils/request'
import { getShareToken, getToken } from "@/utils/auth";
// 保存大屏设计 // 保存大屏设计
export function insertDashboard(data) { export function insertDashboard(data) {
@ -13,6 +14,7 @@ export function insertDashboard(data) {
export function detailDashboard(data) { export function detailDashboard(data) {
return request({ return request({
url: 'reportDashboard/' + data, url: 'reportDashboard/' + data,
headers: { 'Share-Token': getShareToken(), 'Authorization': getToken() },
method: 'get', method: 'get',
}) })
} }
@ -22,6 +24,7 @@ export function queryAllDataSet(data) {
return request({ return request({
url: 'dataSet/queryAllDataSet', url: 'dataSet/queryAllDataSet',
method: 'get', method: 'get',
}) })
} }
@ -38,6 +41,7 @@ export function getData(data) {
return request({ return request({
url: 'reportDashboard/getData', url: 'reportDashboard/getData',
method: 'post', method: 'post',
headers: { 'Share-Token': getShareToken(), 'Authorization': getToken() },
data, data,
}) })
} }

@ -39,4 +39,12 @@ export function reportShareDetail(data) {
}) })
} }
export function reportShareDetailByCode(data) {
return request({
url: 'reportShare/detailByCode',
method: 'get',
params: { shareCode: data }
})
}
export default { reportShareList, reportShareAdd, reportShareDeleteBatch, reportShareUpdate, reportShareDetail } export default { reportShareList, reportShareAdd, reportShareDeleteBatch, reportShareUpdate, reportShareDetail }

@ -4,7 +4,7 @@ import NProgress from 'nprogress' // Progress 进度条
import 'nprogress/nprogress.css'// Progress 进度条样式 import 'nprogress/nprogress.css'// Progress 进度条样式
import { getToken, getAccessUser } from "@/utils/auth"; import { getToken, getAccessUser } from "@/utils/auth";
export default router export default router
var whiteList = ['/login'] var whiteList = ['/login', '/aj/**', '/bigscreen/viewer']
// 判断是否需要登录权限 以及是否登录 // 判断是否需要登录权限 以及是否登录
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
@ -20,13 +20,19 @@ router.beforeEach((to, from, next) => {
next() next()
} }
}else { }else {
// 如果没有token console.log(to.path)
if ((token == null || token == '' || token ==undefined || gaeaUser == {}) && (to.meta != null && to.meta.requireAuth == true)) { // 在免登录白名单,直接进入 if (whiteList.includes(to.path)) {
next(`/login?redirect=${to.path}`) // 否则全部重定向到登录页
NProgress.done()
} else {
next() next()
}else {
// 如果没有token
if ((token == null || token == '' || token ==undefined || gaeaUser == {}) && (to.meta != null && to.meta.requireAuth == true)) {// 在免登录白名单,直接进入
next(`/login?redirect=${to.path}`); // 否则全部重定向到登录页
NProgress.done();
} else {
next();
}
} }
} }
}) })

@ -27,6 +27,7 @@ import Layout from '../views/layout/Layout'
**/ **/
export const constantRouterMap = [ export const constantRouterMap = [
{ path: '/login', component: () => import('@/views/login'), hidden: true }, { path: '/login', component: () => import('@/views/login'), hidden: true },
{ path: '/aj/**', component: () => import('@/views/report/aj'), hidden: true },
{ {
path: '/index', component: Layout, name: 'index', meta: { title: '首页', icon: 'iconhome2' }, path: '/index', component: Layout, name: 'index', meta: { title: '首页', icon: 'iconhome2' },
children: [ children: [

@ -1,5 +1,5 @@
import { login, logout } from '@/api/login' import { login, logout } from '@/api/login'
import { setToken, delToken, setAccessUser, delAccessUser } from '@/utils/auth' import {setToken, delToken, setAccessUser, delAccessUser, delShareToken} from '@/utils/auth'
const user = { const user = {
state: { state: {
@ -51,6 +51,7 @@ const user = {
commit('SET_TOKEN', '') commit('SET_TOKEN', '')
commit('SET_ACCESSUSER', {}) commit('SET_ACCESSUSER', {})
delToken() delToken()
delShareToken()
delAccessUser() delAccessUser()
resolve() resolve()
}).catch(error => { }).catch(error => {
@ -65,6 +66,7 @@ const user = {
commit('SET_TOKEN', '') commit('SET_TOKEN', '')
commit('SET_ACCESSUSER', {}) commit('SET_ACCESSUSER', {})
delToken() delToken()
delShareToken()
delAccessUser() delAccessUser()
resolve() resolve()
}) })

@ -1,17 +1,27 @@
import { getStorageItem, setStorageItem, delStorageItem } from '@/utils/storage' import { getStorageItem, setStorageItem, delStorageItem } from '@/utils/storage'
const TokenKey = 'token' const TokenKey = 'token'
const ShareTokenKey = 'shareToken'
const AccessUserKey = 'gaeaUser' const AccessUserKey = 'gaeaUser'
export function getToken() { export function getToken() {
return getStorageItem(TokenKey) return getStorageItem(TokenKey)
} }
export function getShareToken() {
return getStorageItem(ShareTokenKey) == null ? '' : getStorageItem(ShareTokenKey);
}
export function setToken(token) { export function setToken(token) {
return setStorageItem(TokenKey, token) return setStorageItem(TokenKey, token)
} }
export function setShareToken(shareToken) {
return setStorageItem(ShareTokenKey, shareToken)
}
export function delToken() { export function delToken() {
return delStorageItem(TokenKey) return delStorageItem(TokenKey)
} }
export function delShareToken() {
return delStorageItem(ShareTokenKey)
}
export function getAccessUser() { export function getAccessUser() {
return getStorageItem(AccessUserKey) return getStorageItem(AccessUserKey)

@ -0,0 +1,50 @@
<!--
* @Author: lide1202@hotmail.com
* @Date: 2021-3-13 11:04:24
* @Last Modified by: lide1202@hotmail.com
* @Last Modified time: 2021-3-13 11:04:24
!-->
<template>
<div>
</div>
</template>
<script>
import { reportShareDetailByCode} from '@/api/reportShare'
import { setShareToken } from '@/utils/auth'
export default {
name: "Report",
components: {
},
data() {
return {
};
},
created() {
this.handleOpen()
},
methods: {
async handleOpen() {
const url = window.location.href
const shareCode = url.substring(url.lastIndexOf("/") + 1);
console.log(shareCode)
const {code, data} = await reportShareDetailByCode(shareCode)
if (code != '200') return
setShareToken(data.shareToken)
//shareToken
//
this.$router.push({
path: '/bigscreen/viewer',
query: {
reportCode: data.reportCode
},
})
},
}
};
</script>
Loading…
Cancel
Save