diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/ReportShareController.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/ReportShareController.java index af4305dc..2d030428 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/ReportShareController.java +++ b/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 { -// -// @Autowired -// private ReportShareService reportShareService; -// -// @Override -// public GaeaBaseService 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 { + + @Autowired + private ReportShareService reportShareService; + + @Override + public GaeaBaseService 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(); + } + +} 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 b808765e..70b3cb51 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 @@ -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 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 diff --git a/report-core/src/main/resources/bootstrap.yml b/report-core/src/main/resources/bootstrap.yml index e3dd9190..e4157d82 100644 --- a/report-core/src/main/resources/bootstrap.yml +++ b/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: diff --git a/report-ui/src/api/bigscreen.js b/report-ui/src/api/bigscreen.js index 06347b6e..79217efb 100644 --- a/report-ui/src/api/bigscreen.js +++ b/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, }) } diff --git a/report-ui/src/api/reportShare.js b/report-ui/src/api/reportShare.js index 68cb9d65..9967c31f 100644 --- a/report-ui/src/api/reportShare.js +++ b/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 } diff --git a/report-ui/src/permission.js b/report-ui/src/permission.js index cf27aebf..928e8037 100644 --- a/report-ui/src/permission.js +++ b/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(); + } } + } }) diff --git a/report-ui/src/router/index.js b/report-ui/src/router/index.js index 9ed5c16e..41070f3c 100644 --- a/report-ui/src/router/index.js +++ b/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: [ diff --git a/report-ui/src/store/modules/user.js b/report-ui/src/store/modules/user.js index 67f63262..b8f7591d 100644 --- a/report-ui/src/store/modules/user.js +++ b/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() }) diff --git a/report-ui/src/utils/auth.js b/report-ui/src/utils/auth.js index d151159d..4e3dae80 100644 --- a/report-ui/src/utils/auth.js +++ b/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) diff --git a/report-ui/src/views/report/aj/index.vue b/report-ui/src/views/report/aj/index.vue new file mode 100644 index 00000000..8474facb --- /dev/null +++ b/report-ui/src/views/report/aj/index.vue @@ -0,0 +1,50 @@ + + +