From 142ff835ca165cf4fd262ccfba9c3333bc44145a Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Thu, 9 Dec 2021 12:47:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A7=BB=E5=8A=A8=E7=AB=AF=E6=94=B6?= =?UTF-8?q?=E8=97=8F=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/controller/panel/api/StoreApi.java | 9 +++++++-- .../io/dataease/controller/panel/server/StoreServer.java | 5 +++++ .../java/io/dataease/service/panel/StoreService.java | 7 +++++++ frontend/src/api/panel/enshrine.js | 7 +++++++ frontend/src/views/panel/list/PanelViewShow.vue | 7 +++---- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/io/dataease/controller/panel/api/StoreApi.java b/backend/src/main/java/io/dataease/controller/panel/api/StoreApi.java index 5f1f3d8ec4..68456fed8f 100644 --- a/backend/src/main/java/io/dataease/controller/panel/api/StoreApi.java +++ b/backend/src/main/java/io/dataease/controller/panel/api/StoreApi.java @@ -32,7 +32,12 @@ public interface StoreApi { @ApiOperation("移除收藏") - @PostMapping("/remove/{storeId}") - void remove(@PathVariable("storeId") String storeId); + @PostMapping("/remove/{panelId}") + void remove(@PathVariable("panelId") String panelId); + + @ApiOperation("收藏状态") + @PostMapping("/status/{id}") + Boolean hasStar(@PathVariable("id") String id); + } diff --git a/backend/src/main/java/io/dataease/controller/panel/server/StoreServer.java b/backend/src/main/java/io/dataease/controller/panel/server/StoreServer.java index 24073a2b52..4ca86f0113 100644 --- a/backend/src/main/java/io/dataease/controller/panel/server/StoreServer.java +++ b/backend/src/main/java/io/dataease/controller/panel/server/StoreServer.java @@ -29,4 +29,9 @@ public class StoreServer implements StoreApi { public void remove(String panelId) { storeService.removeByPanelId(panelId); } + + @Override + public Boolean hasStar(String id) { + return storeService.count(id) > 0L; + } } diff --git a/backend/src/main/java/io/dataease/service/panel/StoreService.java b/backend/src/main/java/io/dataease/service/panel/StoreService.java index 078d1ef0dd..39640fefe7 100644 --- a/backend/src/main/java/io/dataease/service/panel/StoreService.java +++ b/backend/src/main/java/io/dataease/service/panel/StoreService.java @@ -53,4 +53,11 @@ public class StoreService { return extPanelStoreMapper.query(example); } + public Long count(String panelId) { + PanelStoreExample example = new PanelStoreExample(); + example.createCriteria().andUserIdEqualTo(AuthUtils.getUser().getUserId()).andPanelGroupIdEqualTo(panelId); + return panelStoreMapper.countByExample(example); + } + + } diff --git a/frontend/src/api/panel/enshrine.js b/frontend/src/api/panel/enshrine.js index d04787633b..4be99e1bdc 100644 --- a/frontend/src/api/panel/enshrine.js +++ b/frontend/src/api/panel/enshrine.js @@ -25,3 +25,10 @@ export function enshrineList(data) { }) } +export function starStatus(panelId) { + return request({ + url: '/api/store/status/' + panelId, + method: 'post', + loading: true + }) +} diff --git a/frontend/src/views/panel/list/PanelViewShow.vue b/frontend/src/views/panel/list/PanelViewShow.vue index 093d01d1ee..7acb3533e6 100644 --- a/frontend/src/views/panel/list/PanelViewShow.vue +++ b/frontend/src/views/panel/list/PanelViewShow.vue @@ -125,7 +125,7 @@ import SaveToTemplate from '@/views/panel/list/SaveToTemplate' import { mapState } from 'vuex' import html2canvas from 'html2canvasde' import FileSaver from 'file-saver' -import { enshrineList, saveEnshrine, deleteEnshrine } from '@/api/panel/enshrine' +import { starStatus, saveEnshrine, deleteEnshrine } from '@/api/panel/enshrine' import bus from '@/utils/bus' import { queryAll } from '@/api/panel/pdfTemplate' import ShareHead from '@/views/panel/GrantAuth/ShareHead' @@ -294,9 +294,8 @@ export default { }) }, initHasStar() { - const param = {} - enshrineList(param).then(res => { - this.hasStar = res.data && res.data.some(item => item.panelGroupId === this.panelInfo.id) + starStatus(this.panelInfo.id).then(res => { + this.hasStar = res.data }) }, refreshStarList(isStar) {