瀏覽代碼

报表分享跳转问题

Raod 4 年之前
父節點
當前提交
ee077aad7d

+ 69 - 71
report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/ReportShareController.java

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

+ 8 - 2
report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/service/impl/ReportShareServiceImpl.java

@@ -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.curd.mapper.GaeaBaseMapper;
 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.modules.reportshare.controller.dto.ReportShareDto;
 import com.anjiplus.template.gaea.business.modules.reportshare.dao.ReportShareMapper;
@@ -63,8 +65,12 @@ public class ReportShareServiceImpl implements ReportShareService {
     public ReportShare detailByCode(String shareCode) {
         LambdaQueryWrapper<ReportShare> wrapper = Wrappers.lambdaQuery();
         wrapper.eq(ReportShare::getShareCode, shareCode);
-        wrapper.eq(ReportShare::getEnableFlag, EnableFlagEnum.ENABLE.getCodeDesc());
-        return selectOne(wrapper);
+        wrapper.eq(ReportShare::getEnableFlag, EnableFlagEnum.ENABLE.getCodeValue());
+        ReportShare reportShare = selectOne(wrapper);
+        if (null == reportShare) {
+            throw BusinessExceptionBuilder.build(ResponseCode.REPORT_SHARE_LINK_INVALID);
+        }
+        return reportShare;
     }
 
     @Override

+ 1 - 1
report-core/src/main/resources/bootstrap.yml

@@ -73,7 +73,7 @@ customer:
     downloadPath: http://10.108.26.197:9095/file/download
 
   # 跳过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:
     ##新增用户默认密码
     default:

+ 4 - 0
report-ui/src/api/bigscreen.js

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

+ 8 - 0
report-ui/src/api/reportShare.js

@@ -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 }

+ 15 - 9
report-ui/src/permission.js

@@ -4,14 +4,14 @@ import NProgress from 'nprogress' // Progress 进度条
 import 'nprogress/nprogress.css'// Progress 进度条样式
 import { getToken, getAccessUser } from "@/utils/auth";
 export default router
-var whiteList = ['/login']
+var whiteList = ['/login', '/aj/**', '/bigscreen/viewer']
 //  判断是否需要登录权限 以及是否登录
 router.beforeEach((to, from, next) => {
-  
+
   NProgress.start()
-  var token = getToken(); 
+  var token = getToken();
   var gaeaUser = getAccessUser();
-  // 如果有token 
+  // 如果有token
   if (token) {
     if (to.path == '/login') {
       next('/index')
@@ -20,13 +20,19 @@ router.beforeEach((to, from, 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 {
+    console.log(to.path)
+    if (whiteList.includes(to.path)) {
       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();
+      }
     }
+
   }
 })
 

+ 1 - 0
report-ui/src/router/index.js

@@ -27,6 +27,7 @@ import Layout from '../views/layout/Layout'
 **/
 export const constantRouterMap = [
   { 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' },
     children: [

+ 3 - 1
report-ui/src/store/modules/user.js

@@ -1,5 +1,5 @@
 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 = {
   state: {
@@ -51,6 +51,7 @@ const user = {
           commit('SET_TOKEN', '')
           commit('SET_ACCESSUSER', {})
           delToken()
+          delShareToken()
           delAccessUser()
           resolve()
         }).catch(error => {
@@ -65,6 +66,7 @@ const user = {
         commit('SET_TOKEN', '')
         commit('SET_ACCESSUSER', {})
         delToken()
+        delShareToken()
         delAccessUser()
         resolve()
       })

+ 10 - 0
report-ui/src/utils/auth.js

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

+ 50 - 0
report-ui/src/views/report/aj/index.vue

@@ -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>