From 820bc47ff6179fda1fe2ac4164b3fbf9fef006b4 Mon Sep 17 00:00:00 2001 From: liweiyi <190785909@qq.com> Date: Mon, 26 Feb 2024 10:04:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=A8=A1=E6=9D=BF=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E4=BF=9D=E5=AD=98=E5=A4=B1=E8=B4=A5=EF=BC=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=86=85=E5=AE=B9=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../contentcore/controller/CatalogController.java | 4 +++- .../contentcore/controller/ContentController.java | 8 +------- .../contentcore/service/impl/TemplateServiceImpl.java | 2 +- .../contentcore/template/tag/CmsContentRelaTag.java | 2 +- .../cms/search/controller/front/SearchApiController.java | 7 +++++++ .../common/security/exception/SecurityErrorCode.java | 2 +- .../exception/handler/GlobalExceptionHandler.java | 2 +- .../src/main/resources/i18n/messages.properties | 2 +- .../src/main/resources/i18n/messages_en.properties | 2 +- .../src/main/resources/i18n/messages_zh_TW.properties | 2 +- chestnut-ui/src/utils/request.js | 1 + 11 files changed, 19 insertions(+), 15 deletions(-) diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/controller/CatalogController.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/controller/CatalogController.java index 27f568d6..81f51572 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/controller/CatalogController.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/controller/CatalogController.java @@ -47,6 +47,7 @@ import com.chestnut.contentcore.service.ICatalogService; import com.chestnut.contentcore.service.IPublishPipeService; import com.chestnut.contentcore.service.IPublishService; import com.chestnut.contentcore.service.ISiteService; +import com.chestnut.contentcore.util.CmsPrivUtils; import com.chestnut.contentcore.util.ConfigPropertyUtils; import com.chestnut.contentcore.util.InternalUrlUtils; import com.chestnut.contentcore.util.SiteUtils; @@ -70,7 +71,6 @@ import java.util.Map; * @author 兮玥 * @email 190785909@qq.com */ -@Priv(type = AdminUserType.TYPE, value = ContentCorePriv.CatalogView) @RequiredArgsConstructor @RestController @RequestMapping("/cms/catalog") @@ -93,6 +93,7 @@ public class CatalogController extends BaseRestController { /** * 查询栏目数据列表 */ + @Priv(type = AdminUserType.TYPE, value = ContentCorePriv.CatalogView) @GetMapping public R list() { LoginUser loginUser = StpAdminUtil.getLoginUser(); @@ -185,6 +186,7 @@ public class CatalogController extends BaseRestController { /** * 栏目树结构数据 */ + @Priv(type = AdminUserType.TYPE, value = CmsPrivUtils.PRIV_SITE_VIEW_PLACEHOLDER) @GetMapping("/treeData") public R treeData() { CmsSite site = this.siteService.getCurrentSite(ServletUtils.getRequest()); diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/controller/ContentController.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/controller/ContentController.java index 1de2501c..0662a777 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/controller/ContentController.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/controller/ContentController.java @@ -15,7 +15,6 @@ */ package com.chestnut.contentcore.controller; -import cn.dev33.satoken.annotation.SaMode; import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -43,7 +42,6 @@ import com.chestnut.contentcore.domain.vo.ListContentVO; import com.chestnut.contentcore.fixed.dict.ContentAttribute; import com.chestnut.contentcore.listener.event.AfterContentEditorInitEvent; import com.chestnut.contentcore.perms.CatalogPermissionType.CatalogPrivItem; -import com.chestnut.contentcore.perms.ContentCorePriv; import com.chestnut.contentcore.service.ICatalogService; import com.chestnut.contentcore.service.IContentService; import com.chestnut.contentcore.service.IPublishService; @@ -79,11 +77,7 @@ import java.util.Objects; * @author 兮玥 * @email 190785909@qq.com */ -@Priv( - type = AdminUserType.TYPE, - value = { ContentCorePriv.CatalogView, CmsPrivUtils.PRIV_SITE_VIEW_PLACEHOLDER}, - mode = SaMode.AND -) +@Priv(type = AdminUserType.TYPE, value = CmsPrivUtils.PRIV_SITE_VIEW_PLACEHOLDER) @RequiredArgsConstructor @RestController @RequestMapping("/cms/content") diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/TemplateServiceImpl.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/TemplateServiceImpl.java index 37137d6a..49dfd522 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/TemplateServiceImpl.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/TemplateServiceImpl.java @@ -187,7 +187,7 @@ public class TemplateServiceImpl extends ServiceImpl pageResult = contentRelaMapper.selectPage(new Page<>(pageIndex, size, page), new LambdaQueryWrapper().eq(CmsContentRela::getContentId, contentId)); - if (pageResult.getRecords().size() > 0) { + if (!pageResult.getRecords().isEmpty()) { List contentIds = pageResult.getRecords().stream().map(CmsContentRela::getRelaContentId).toList(); List contents = this.contentService.lambdaQuery().in(CmsContent::getContentId, contentIds).list(); List result = contents.stream().map(c -> { diff --git a/chestnut-cms/chestnut-cms-search/src/main/java/com/chestnut/cms/search/controller/front/SearchApiController.java b/chestnut-cms/chestnut-cms-search/src/main/java/com/chestnut/cms/search/controller/front/SearchApiController.java index be7ddc0a..6251e7fe 100644 --- a/chestnut-cms/chestnut-cms-search/src/main/java/com/chestnut/cms/search/controller/front/SearchApiController.java +++ b/chestnut-cms/chestnut-cms-search/src/main/java/com/chestnut/cms/search/controller/front/SearchApiController.java @@ -225,4 +225,11 @@ public class SearchApiController extends BaseRestController { }); return this.bindDataTable(list, Objects.isNull(sr.hits().total()) ? 0 : sr.hits().total().value()); } + + @GetMapping("/suggest") + public R getSuggestWords() { + + + return R.ok(); + } } diff --git a/chestnut-common/chestnut-common-security/src/main/java/com/chestnut/common/security/exception/SecurityErrorCode.java b/chestnut-common/chestnut-common-security/src/main/java/com/chestnut/common/security/exception/SecurityErrorCode.java index c085ac9f..e8018272 100644 --- a/chestnut-common/chestnut-common-security/src/main/java/com/chestnut/common/security/exception/SecurityErrorCode.java +++ b/chestnut-common/chestnut-common-security/src/main/java/com/chestnut/common/security/exception/SecurityErrorCode.java @@ -25,7 +25,7 @@ public enum SecurityErrorCode implements ErrorCode { NOT_LOGIN, /** - * 无访问权限 + * 无访问权限:{0} */ NOT_PERMISSION, diff --git a/chestnut-common/chestnut-common-security/src/main/java/com/chestnut/common/security/exception/handler/GlobalExceptionHandler.java b/chestnut-common/chestnut-common-security/src/main/java/com/chestnut/common/security/exception/handler/GlobalExceptionHandler.java index 18f9ca20..0af7bc9b 100644 --- a/chestnut-common/chestnut-common-security/src/main/java/com/chestnut/common/security/exception/handler/GlobalExceptionHandler.java +++ b/chestnut-common/chestnut-common-security/src/main/java/com/chestnut/common/security/exception/handler/GlobalExceptionHandler.java @@ -73,7 +73,7 @@ public class GlobalExceptionHandler { public R handleSecurityPermissionException(NotPermissionException e, HttpServletRequest request) { String requestURI = request.getRequestURI(); log.error("请求地址'{}',权限校验失败'{}'", requestURI, e.getMessage()); - return R.fail(HttpStatus.FORBIDDEN.value(), I18nUtils.get(SecurityErrorCode.NOT_PERMISSION.value())); + return R.fail(HttpStatus.FORBIDDEN.value(), I18nUtils.get(SecurityErrorCode.NOT_PERMISSION.value(), e.getPermission())); } /** diff --git a/chestnut-common/chestnut-common-security/src/main/resources/i18n/messages.properties b/chestnut-common/chestnut-common-security/src/main/resources/i18n/messages.properties index d57f8ece..1f4e4f68 100644 --- a/chestnut-common/chestnut-common-security/src/main/resources/i18n/messages.properties +++ b/chestnut-common/chestnut-common-security/src/main/resources/i18n/messages.properties @@ -1,5 +1,5 @@ #错误消息 ERRCODE.SECURITY.NOT_LOGIN=未登录 -ERRCODE.SECURITY.NOT_PERMISSION=无访问权限 +ERRCODE.SECURITY.NOT_PERMISSION=无访问权限:{0} ERRCODE.SECURITY.DEMO_EXCEPTION=演示模式不允许操作 ERRCODE.SECURITY.UNKNOWN_USER_TYPE=位置用户类型 \ No newline at end of file diff --git a/chestnut-common/chestnut-common-security/src/main/resources/i18n/messages_en.properties b/chestnut-common/chestnut-common-security/src/main/resources/i18n/messages_en.properties index 4b7f012e..e50e4fe5 100644 --- a/chestnut-common/chestnut-common-security/src/main/resources/i18n/messages_en.properties +++ b/chestnut-common/chestnut-common-security/src/main/resources/i18n/messages_en.properties @@ -1,5 +1,5 @@ #错误消息 ERRCODE.SECURITY.NOT_LOGIN=Not login. -ERRCODE.SECURITY.NOT_PERMISSION=Access denied. +ERRCODE.SECURITY.NOT_PERMISSION=Access denied for `{0}`. ERRCODE.SECURITY.DEMO_EXCEPTION=The operation not allowed in demo mode. ERRCODE.SECURITY.UNKNOWN_USER_TYPE=Unknown user type: {0} \ No newline at end of file diff --git a/chestnut-common/chestnut-common-security/src/main/resources/i18n/messages_zh_TW.properties b/chestnut-common/chestnut-common-security/src/main/resources/i18n/messages_zh_TW.properties index 3c59c3bc..8d8b1da2 100644 --- a/chestnut-common/chestnut-common-security/src/main/resources/i18n/messages_zh_TW.properties +++ b/chestnut-common/chestnut-common-security/src/main/resources/i18n/messages_zh_TW.properties @@ -1,5 +1,5 @@ #錯誤消息 ERRCODE.SECURITY.NOT_LOGIN=未登錄 -ERRCODE.SECURITY.NOT_PERMISSION=無訪問許可權 +ERRCODE.SECURITY.NOT_PERMISSION=無訪問許可權:{0} ERRCODE.SECURITY.DEMO_EXCEPTION=演示模式不允許操作 ERRCODE.SECURITY.UNKNOWN_USER_TYPE=位置用戶類型 diff --git a/chestnut-ui/src/utils/request.js b/chestnut-ui/src/utils/request.js index 46ec607b..3007a631 100644 --- a/chestnut-ui/src/utils/request.js +++ b/chestnut-ui/src/utils/request.js @@ -103,6 +103,7 @@ service.interceptors.response.use(res => { Message({ message: msg, type: 'warning' }) return Promise.reject('error') } else if (code !== 200) { + console.log(res.data) Notification.error({ title: msg }) return Promise.reject('error') } else {