diff --git a/README.md b/README.md index 3d98fe48..300c9f11 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ChestnutCMS v1.4.2 +# ChestnutCMS v1.4.3 ### 系统简介 @@ -12,8 +12,6 @@ ChestnutCMS是前后端分离的企业级内容管理系统。项目基于[RuoYi 企业站演示地址: -> 企业演示站的静态资源已提交到仓库[chestnut-cms-wwwroot](https://gitee.com/liweiyi/chestnut-cms-wwwroot)。 - 资讯站演示地址:(会员演示账号:xxx333@126.com / a123456) 图片站演示地址:PC端: 移动端: @@ -27,6 +25,7 @@ ChestnutCMS是前后端分离的企业级内容管理系统。项目基于[RuoYi - Maven 3.8+ - MySQL 8.0+ - Redis 5.x+ +- NodeJS 16.20.2 ### 主要技术框架 diff --git a/chestnut-admin/pom.xml b/chestnut-admin/pom.xml index 377669be..612b8115 100644 --- a/chestnut-admin/pom.xml +++ b/chestnut-admin/pom.xml @@ -3,7 +3,7 @@ chestnut com.chestnut - 1.4.2 + 1.4.3 4.0.0 jar diff --git a/chestnut-admin/src/main/resources/application-dev.yml b/chestnut-admin/src/main/resources/application-dev.yml index fcfb4da8..b746a905 100644 --- a/chestnut-admin/src/main/resources/application-dev.yml +++ b/chestnut-admin/src/main/resources/application-dev.yml @@ -5,7 +5,7 @@ chestnut: # 代号 alias: ChestnutCMS # 版本 - version: 1.4.2 + version: 1.4.3 # 版权年份 copyrightYear: 2022-2024 system: diff --git a/chestnut-admin/src/main/resources/application-prod.yml b/chestnut-admin/src/main/resources/application-prod.yml index a470c805..ad699471 100644 --- a/chestnut-admin/src/main/resources/application-prod.yml +++ b/chestnut-admin/src/main/resources/application-prod.yml @@ -5,7 +5,7 @@ chestnut: # 代号 alias: ChestnutCMS # 版本 - version: 1.4.2 + version: 1.4.3 # 版权年份 copyrightYear: 2022-2024 system: diff --git a/chestnut-admin/src/main/resources/application-test.yml b/chestnut-admin/src/main/resources/application-test.yml index fa051efa..7120479d 100644 --- a/chestnut-admin/src/main/resources/application-test.yml +++ b/chestnut-admin/src/main/resources/application-test.yml @@ -5,7 +5,7 @@ chestnut: # 代号 alias: ChestnutCMS # 版本 - version: 1.4.2 + version: 1.4.3 # 版权年份 copyrightYear: 2022-2024 system: diff --git a/chestnut-admin/src/main/resources/db/migration/mysql/V1.3.25__update.sql b/chestnut-admin/src/main/resources/db/migration/mysql/V1.3.25__update.sql index c8a46f9a..20b03d15 100644 --- a/chestnut-admin/src/main/resources/db/migration/mysql/V1.3.25__update.sql +++ b/chestnut-admin/src/main/resources/db/migration/mysql/V1.3.25__update.sql @@ -9,4 +9,6 @@ UPDATE cc_tag_word_group SET word_total = (SELECT count(*) FROM cc_tag_word WHER ALTER TABLE cc_hot_word_group ADD COLUMN owner VARCHAR(100); ALTER TABLE cc_hot_word_group ADD COLUMN word_total bigint DEFAULT 0; ALTER TABLE cc_hot_word ADD COLUMN owner VARCHAR(100); -UPDATE cc_hot_word_group SET word_total = (SELECT count(*) FROM cc_hot_word WHERE cc_hot_word.group_id=cc_hot_word_group.group_id); \ No newline at end of file +UPDATE cc_hot_word_group SET word_total = (SELECT count(*) FROM cc_hot_word WHERE cc_hot_word.group_id=cc_hot_word_group.group_id); + +UPDATE sys_memu set component = 'cms/word/word' WHERE menu_id = '2039'; \ No newline at end of file diff --git a/chestnut-cms/chestnut-cms-advertisement/pom.xml b/chestnut-cms/chestnut-cms-advertisement/pom.xml index 91dc4025..457a7355 100644 --- a/chestnut-cms/chestnut-cms-advertisement/pom.xml +++ b/chestnut-cms/chestnut-cms-advertisement/pom.xml @@ -7,7 +7,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-advertisement diff --git a/chestnut-cms/chestnut-cms-article/pom.xml b/chestnut-cms/chestnut-cms-article/pom.xml index f5ad68e7..9c8a2904 100644 --- a/chestnut-cms/chestnut-cms-article/pom.xml +++ b/chestnut-cms/chestnut-cms-article/pom.xml @@ -7,7 +7,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-article diff --git a/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/ArticleContent.java b/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/ArticleContent.java index 1b5530ca..b02c72a4 100644 --- a/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/ArticleContent.java +++ b/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/ArticleContent.java @@ -131,6 +131,9 @@ public class ArticleContent extends AbstractContent { @Override public String getFullText() { + if (this.getContentEntity().isLinkContent()) { + return super.getFullText(); + } return super.getFullText() + StringUtils.SPACE + HtmlUtils.clean(this.getExtendEntity().getContentHtml()); } diff --git a/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/PublishPipeProp_ArticleDetailTemplate.java b/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/PublishPipeProp_ArticleDetailTemplate.java index 6cac3c8b..96fcb618 100644 --- a/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/PublishPipeProp_ArticleDetailTemplate.java +++ b/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/PublishPipeProp_ArticleDetailTemplate.java @@ -15,13 +15,12 @@ */ package com.chestnut.article; -import java.util.List; - +import com.chestnut.contentcore.core.IPublishPipeProp; import org.springframework.stereotype.Component; -import com.chestnut.contentcore.core.IPublishPipeProp; +import java.util.List; -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_ArticleDetailTemplate.KEY) public class PublishPipeProp_ArticleDetailTemplate implements IPublishPipeProp { public static final String KEY = DetailTemplatePropPrefix + ArticleContentType.ID; diff --git a/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/PublishPipeProp_DefaultArticleDetailTemplate.java b/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/PublishPipeProp_DefaultArticleDetailTemplate.java index ab1b4a5e..9cff812a 100644 --- a/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/PublishPipeProp_DefaultArticleDetailTemplate.java +++ b/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/PublishPipeProp_DefaultArticleDetailTemplate.java @@ -15,13 +15,12 @@ */ package com.chestnut.article; -import java.util.List; - +import com.chestnut.contentcore.core.IPublishPipeProp; import org.springframework.stereotype.Component; -import com.chestnut.contentcore.core.IPublishPipeProp; +import java.util.List; -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_DefaultArticleDetailTemplate.KEY) public class PublishPipeProp_DefaultArticleDetailTemplate implements IPublishPipeProp { public static final String KEY = DefaultDetailTemplatePropPrefix + ArticleContentType.ID; diff --git a/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/PublishPipeProp_UEditorCss.java b/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/PublishPipeProp_UEditorCss.java new file mode 100644 index 00000000..d7ab52c0 --- /dev/null +++ b/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/PublishPipeProp_UEditorCss.java @@ -0,0 +1,67 @@ +/* + * Copyright 2022-2024 兮玥(190785909@qq.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.chestnut.article; + +import com.alibaba.excel.util.StringUtils; +import com.chestnut.contentcore.core.IPublishPipeProp; +import org.apache.commons.collections4.MapUtils; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * 发布通道属性:文章编辑器自定义样式文件 + * + * @author 兮玥 + * @email 190785909@qq.com + */ +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_UEditorCss.KEY) +public class PublishPipeProp_UEditorCss implements IPublishPipeProp { + + public static final String KEY = "ueditorCss"; + + @Override + public String getKey() { + return KEY; + } + + @Override + public String getName() { + return "文章编辑器自定义样式"; + } + + @Override + public List getUseTypes() { + return List.of(PublishPipePropUseType.Site, PublishPipePropUseType.Catalog); + } + + public static String getValue( + String publishPipeCode, + Map> firstPublishPipeProps, + Map> secondPublishPipeProps + ) { + String v = StringUtils.EMPTY; + if (Objects.nonNull(firstPublishPipeProps)) { + v = MapUtils.getString(firstPublishPipeProps.get(publishPipeCode), KEY, StringUtils.EMPTY); + if (StringUtils.isEmpty(v) && Objects.nonNull(secondPublishPipeProps)) { + v = MapUtils.getString(secondPublishPipeProps.get(publishPipeCode), KEY, StringUtils.EMPTY); + } + } + return v; + } +} diff --git a/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/controller/ArticleController.java b/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/controller/ArticleController.java index 18452911..a2fe122d 100644 --- a/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/controller/ArticleController.java +++ b/chestnut-cms/chestnut-cms-article/src/main/java/com/chestnut/article/controller/ArticleController.java @@ -16,15 +16,30 @@ package com.chestnut.article.controller; +import com.chestnut.article.PublishPipeProp_UEditorCss; +import com.chestnut.common.domain.R; import com.chestnut.common.security.anno.Priv; import com.chestnut.common.security.web.BaseRestController; +import com.chestnut.common.utils.StringUtils; +import com.chestnut.contentcore.config.CMSConfig; +import com.chestnut.contentcore.domain.CmsCatalog; +import com.chestnut.contentcore.domain.CmsSite; +import com.chestnut.contentcore.service.ICatalogService; +import com.chestnut.contentcore.service.IPublishPipeService; +import com.chestnut.contentcore.service.ISiteService; import com.chestnut.system.security.AdminUserType; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.HashMap; +import java.util.Map; + /** *

- * 前端控制器 + * 文章前端控制器 *

* * @author 兮玥 @@ -32,8 +47,31 @@ import org.springframework.web.bind.annotation.RestController; */ @Priv(type = AdminUserType.TYPE) @RestController +@RequiredArgsConstructor @RequestMapping("/cms/article") public class ArticleController extends BaseRestController { - + + private final ISiteService siteService; + + private final ICatalogService catalogService; + + private final IPublishPipeService publishPipeService; + + @GetMapping("/ueditor_css") + public R getUEditorCss(@RequestParam Long catalogId) { + CmsCatalog catalog = catalogService.getCatalog(catalogId); + CmsSite site = siteService.getSite(catalog.getSiteId()); + + Map data = new HashMap<>(); + publishPipeService.getPublishPipes(site.getSiteId()).forEach(pp -> { + String value = PublishPipeProp_UEditorCss.getValue(pp.getCode(), + catalog.getPublishPipeProps(), site.getPublishPipeProps()); + if (StringUtils.isNotEmpty(value)) { + value = CMSConfig.getResourcePreviewPrefix() + value; + } + data.put(pp.getCode(), value); + }); + return R.ok(data); + } } diff --git a/chestnut-cms/chestnut-cms-block/pom.xml b/chestnut-cms/chestnut-cms-block/pom.xml index 471490b8..2262f28c 100644 --- a/chestnut-cms/chestnut-cms-block/pom.xml +++ b/chestnut-cms/chestnut-cms-block/pom.xml @@ -7,7 +7,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-block diff --git a/chestnut-cms/chestnut-cms-comment/pom.xml b/chestnut-cms/chestnut-cms-comment/pom.xml index a36d69d9..b69ddcc8 100644 --- a/chestnut-cms/chestnut-cms-comment/pom.xml +++ b/chestnut-cms/chestnut-cms-comment/pom.xml @@ -6,7 +6,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-comment diff --git a/chestnut-cms/chestnut-cms-contentcore/pom.xml b/chestnut-cms/chestnut-cms-contentcore/pom.xml index eb1833d6..a2446946 100644 --- a/chestnut-cms/chestnut-cms-contentcore/pom.xml +++ b/chestnut-cms/chestnut-cms-contentcore/pom.xml @@ -7,7 +7,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-contentcore diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/controller/CmsPermissionController.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/controller/CmsPermissionController.java index 105c99ee..6991c085 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/controller/CmsPermissionController.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/controller/CmsPermissionController.java @@ -21,7 +21,6 @@ import com.chestnut.common.security.anno.Priv; import com.chestnut.common.security.web.BaseRestController; import com.chestnut.common.utils.Assert; import com.chestnut.common.utils.IdUtils; -import com.chestnut.common.utils.ServletUtils; import com.chestnut.common.utils.StringUtils; import com.chestnut.contentcore.domain.CmsCatalog; import com.chestnut.contentcore.domain.CmsPageWidget; @@ -41,7 +40,6 @@ import com.chestnut.contentcore.perms.SitePermissionType.SitePrivItem; import com.chestnut.contentcore.service.ICatalogService; import com.chestnut.contentcore.service.IPageWidgetService; import com.chestnut.contentcore.service.ISiteService; -import com.chestnut.contentcore.util.CmsPrivUtils; import com.chestnut.system.domain.SysPermission; import com.chestnut.system.security.AdminUserType; import com.chestnut.system.security.StpAdminUtil; @@ -130,20 +128,21 @@ public class CmsPermissionController extends BaseRestController { @GetMapping("/site/options") public R getSiteOptions(@RequestParam String ownerType, @RequestParam String owner) { - SysPermission permissions = this.permissionService.getPermission(ownerType, owner); - Set sitePermissionKeys = sitePermissionType.deserialize(permissions.getPermissions().get(sitePermissionType.getId())); + List list = this.siteService.lambdaQuery() + .select(List.of(CmsSite::getSiteId, CmsSite::getName)) + .list(); + Set permissionKeys = this.permissionService.getPermissionKeys(ownerType, owner, SitePermissionType.ID); Set inheritedPermissionKeys = this.permissionService.getInheritedPermissionKeys(ownerType, owner, SitePermissionType.ID); - sitePermissionKeys.addAll(inheritedPermissionKeys); - List> list = this.siteService.lambdaQuery().select(List.of(CmsSite::getSiteId, CmsSite::getName)) - .list().stream() - .filter(site -> sitePermissionKeys.contains(SitePrivItem.View.getPermissionKey(site.getSiteId()))) + permissionKeys.addAll(inheritedPermissionKeys); + List> data = list.stream() + .filter(site -> permissionKeys.contains(SitePrivItem.View.getPermissionKey(site.getSiteId()))) .map(site -> { Map map = new HashMap<>(); map.put("id", site.getSiteId()); map.put("name", site.getName()); return map; }).toList(); - return this.bindDataTable(list); + return this.bindDataTable(data); } @GetMapping("/catalog") 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 0662a777..0f10e127 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 @@ -66,6 +66,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.io.IOException; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -97,10 +98,12 @@ public class ContentController extends BaseRestController { * 内容列表 */ @GetMapping("/list") - public R listData(@RequestParam(name = "catalogId", required = false) Long catalogId, - @RequestParam(name = "title", required = false, defaultValue = "") String title, - @RequestParam(name = "contentType", required = false, defaultValue = "") String contentType, - @RequestParam(name = "status", required = false) String status) { + public R listData(@RequestParam(required = false) Long catalogId, + @RequestParam(required = false) String title, + @RequestParam(required = false) String contentType, + @RequestParam(required = false) String status, + @RequestParam(required = false) LocalDateTime beginTime, + @RequestParam(required = false) LocalDateTime endTime) { LoginUser loginUser = StpAdminUtil.getLoginUser(); if (!IdUtils.validate(catalogId) || !loginUser.hasPermission(CatalogPrivItem.View.getPermissionKey(catalogId))) { @@ -114,7 +117,9 @@ public class ContentController extends BaseRestController { .eq(CmsContent::getSiteId, site.getSiteId()) .eq(StringUtils.isNotEmpty(contentType), CmsContent::getContentType, contentType) .like(StringUtils.isNotEmpty(title), CmsContent::getTitle, title) - .eq(StringUtils.isNotEmpty(status), CmsContent::getStatus, status); + .eq(StringUtils.isNotEmpty(status), CmsContent::getStatus, status) + .ge(Objects.nonNull(beginTime), CmsContent::getCreateTime, beginTime) + .le(Objects.nonNull(endTime), CmsContent::getCreateTime, endTime); if (includeChild) { CmsCatalog catalog = this.catalogService.getCatalog(catalogId); q.like(CmsContent::getCatalogAncestors, catalog.getAncestors()); diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/controller/FileController.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/controller/FileController.java index 1188c6da..cc7a65d6 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/controller/FileController.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/controller/FileController.java @@ -15,22 +15,7 @@ */ package com.chestnut.contentcore.controller; -import java.io.IOException; -import java.util.List; -import java.util.Map; - import cn.dev33.satoken.annotation.SaMode; -import com.chestnut.contentcore.config.CMSConfig; -import com.chestnut.contentcore.util.CmsPrivUtils; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - import com.chestnut.common.domain.R; import com.chestnut.common.domain.TreeNode; import com.chestnut.common.exception.CommonErrorCode; @@ -40,16 +25,24 @@ import com.chestnut.common.security.anno.Priv; import com.chestnut.common.security.web.BaseRestController; import com.chestnut.common.utils.Assert; import com.chestnut.common.utils.ServletUtils; +import com.chestnut.contentcore.config.CMSConfig; import com.chestnut.contentcore.domain.CmsSite; import com.chestnut.contentcore.domain.dto.FileAddDTO; import com.chestnut.contentcore.domain.dto.FileOperateDTO; import com.chestnut.contentcore.perms.ContentCorePriv; import com.chestnut.contentcore.service.IFileService; import com.chestnut.contentcore.service.ISiteService; +import com.chestnut.contentcore.util.CmsPrivUtils; import com.chestnut.system.security.AdminUserType; - import jakarta.validation.constraints.NotEmpty; import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.List; +import java.util.Map; /** * 文件管理 @@ -74,21 +67,18 @@ public class FileController extends BaseRestController { /** * 查询文件列表 * - * @param filePath - * @param filename - * @return + * @param filePath 文件目录路径 + * @param fileName 文件名 */ @GetMapping("/list") - public R getFileList(@RequestParam("filePath") @NotEmpty String filePath, - @RequestParam("fileName") String filename) { + public R getFileList(@RequestParam @NotEmpty String filePath, + @RequestParam(required = false, defaultValue = "") String fileName) { CmsSite site = this.siteService.getCurrentSite(ServletUtils.getRequest()); - return this.fileService.getSiteFileList(site, filePath, filename); + return this.fileService.getSiteFileList(site, filePath, fileName); } /** * 获取目录树数据 - * - * @return */ @GetMapping("/directoryTreeData") public R getDirectoryTree() { @@ -151,7 +141,7 @@ public class FileController extends BaseRestController { * @return * @throws IOException */ - @Log(title = "读取文", businessType = BusinessType.OTHER) + @Log(title = "读取文件", businessType = BusinessType.OTHER) @PostMapping("/read") public R readFile(@RequestBody @Validated FileOperateDTO dto) throws IOException { CmsSite site = this.siteService.getCurrentSite(ServletUtils.getRequest()); diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/IPublishPipeProp.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/IPublishPipeProp.java index 3674b9d7..c8af8abe 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/IPublishPipeProp.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/IPublishPipeProp.java @@ -26,6 +26,8 @@ import com.chestnut.common.utils.StringUtils; * @email 190785909@qq.com */ public interface IPublishPipeProp { + + String BEAN_PREFIX = "PublishPipeProp_"; String DetailTemplatePropPrefix = "detailTemplate_"; diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_ContentExTemplate.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_ContentExTemplate.java index 15540b7f..b19b215d 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_ContentExTemplate.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_ContentExTemplate.java @@ -35,7 +35,7 @@ import java.util.Objects; * @author 兮玥 * @email 190785909@qq.com */ -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_ContentExTemplate.KEY) public class PublishPipeProp_ContentExTemplate implements IPublishPipeProp { public static final String KEY = "contentExTemplate"; diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_ContentTemplate.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_ContentTemplate.java index 739ccc09..ae5cd52b 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_ContentTemplate.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_ContentTemplate.java @@ -15,14 +15,13 @@ */ package com.chestnut.contentcore.core.impl; -import java.util.List; -import java.util.Map; -import java.util.Objects; - +import com.chestnut.contentcore.core.IPublishPipeProp; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Component; -import com.chestnut.contentcore.core.IPublishPipeProp; +import java.util.List; +import java.util.Map; +import java.util.Objects; /** * 发布通道属性:内容自定义模板 @@ -30,7 +29,7 @@ import com.chestnut.contentcore.core.IPublishPipeProp; * @author 兮玥 * @email 190785909@qq.com */ -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_ContentTemplate.KEY) public class PublishPipeProp_ContentTemplate implements IPublishPipeProp { public static final String KEY = "template"; diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_DefaultListTemplate.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_DefaultListTemplate.java index 0b4217e0..f1abf72a 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_DefaultListTemplate.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_DefaultListTemplate.java @@ -15,14 +15,13 @@ */ package com.chestnut.contentcore.core.impl; -import java.util.List; -import java.util.Map; -import java.util.Objects; - +import com.chestnut.contentcore.core.IPublishPipeProp; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Component; -import com.chestnut.contentcore.core.IPublishPipeProp; +import java.util.List; +import java.util.Map; +import java.util.Objects; /** * 发布通道属性:栏目列表页默认模板 @@ -30,7 +29,7 @@ import com.chestnut.contentcore.core.IPublishPipeProp; * @author 兮玥 * @email 190785909@qq.com */ -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_DefaultListTemplate.KEY) public class PublishPipeProp_DefaultListTemplate implements IPublishPipeProp { public static final String KEY = "defaultListTemplate"; diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_IndexTemplate.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_IndexTemplate.java index ab0ac833..1cac4983 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_IndexTemplate.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_IndexTemplate.java @@ -15,14 +15,13 @@ */ package com.chestnut.contentcore.core.impl; -import java.util.List; -import java.util.Map; -import java.util.Objects; - +import com.chestnut.contentcore.core.IPublishPipeProp; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Component; -import com.chestnut.contentcore.core.IPublishPipeProp; +import java.util.List; +import java.util.Map; +import java.util.Objects; /** * 发布通道属性:首页模板 @@ -30,7 +29,7 @@ import com.chestnut.contentcore.core.IPublishPipeProp; * @author 兮玥 * @email 190785909@qq.com */ -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_IndexTemplate.KEY) public class PublishPipeProp_IndexTemplate implements IPublishPipeProp { public static final String KEY = "indexTemplate"; diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_ListTemplate.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_ListTemplate.java index f4d8697c..65b84242 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_ListTemplate.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_ListTemplate.java @@ -15,14 +15,13 @@ */ package com.chestnut.contentcore.core.impl; -import java.util.List; -import java.util.Map; -import java.util.Objects; - +import com.chestnut.contentcore.core.IPublishPipeProp; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Component; -import com.chestnut.contentcore.core.IPublishPipeProp; +import java.util.List; +import java.util.Map; +import java.util.Objects; /** * 发布通道属性:栏目列表页模板 @@ -30,7 +29,7 @@ import com.chestnut.contentcore.core.IPublishPipeProp; * @author 兮玥 * @email 190785909@qq.com */ -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_ListTemplate.KEY) public class PublishPipeProp_ListTemplate implements IPublishPipeProp { public static final String KEY = "listTemplate"; diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_SiteUrl.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_SiteUrl.java index 666a7ef4..17172cd5 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_SiteUrl.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_SiteUrl.java @@ -15,14 +15,13 @@ */ package com.chestnut.contentcore.core.impl; -import java.util.List; -import java.util.Map; -import java.util.Objects; - +import com.chestnut.contentcore.core.IPublishPipeProp; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Component; -import com.chestnut.contentcore.core.IPublishPipeProp; +import java.util.List; +import java.util.Map; +import java.util.Objects; /** * 发布通道属性:站点域名 @@ -30,7 +29,7 @@ import com.chestnut.contentcore.core.IPublishPipeProp; * @author 兮玥 * @email 190785909@qq.com */ -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_SiteUrl.KEY) public class PublishPipeProp_SiteUrl implements IPublishPipeProp { public static final String KEY = "url"; diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_StaticSuffix.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_StaticSuffix.java index 468e95d2..54de96d5 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_StaticSuffix.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/core/impl/PublishPipeProp_StaticSuffix.java @@ -15,15 +15,14 @@ */ package com.chestnut.contentcore.core.impl; -import java.util.List; -import java.util.Map; -import java.util.Objects; - +import com.chestnut.contentcore.core.IPublishPipeProp; +import com.chestnut.contentcore.fixed.dict.StaticSuffix; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Component; -import com.chestnut.contentcore.core.IPublishPipeProp; -import com.chestnut.contentcore.fixed.dict.StaticSuffix; +import java.util.List; +import java.util.Map; +import java.util.Objects; /** * 发布通道属性:静态文件类型 @@ -31,7 +30,7 @@ import com.chestnut.contentcore.fixed.dict.StaticSuffix; * @author 兮玥 * @email 190785909@qq.com */ -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_StaticSuffix.KEY) public class PublishPipeProp_StaticSuffix implements IPublishPipeProp { public static final String KEY = "staticSuffix"; diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/domain/dto/ContentDTO.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/domain/dto/ContentDTO.java index 0fe22466..8fda0bde 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/domain/dto/ContentDTO.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/domain/dto/ContentDTO.java @@ -221,6 +221,26 @@ public class ContentDTO { private Map params; private String status; + + /** + * 备用字段1 + */ + private String prop1; + + /** + * 备用字段2 + */ + private String prop2; + + /** + * 备用字段3 + */ + private String prop3; + + /** + * 备用字段4 + */ + private String prop4; public static ContentDTO newInstance(CmsContent cmsContent) { ContentDTO dto = new ContentDTO(); diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/IPublishPipeService.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/IPublishPipeService.java index 465422d3..3e5e9822 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/IPublishPipeService.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/IPublishPipeService.java @@ -15,71 +15,69 @@ */ package com.chestnut.contentcore.service; -import java.io.IOException; -import java.util.List; -import java.util.Map; - import com.baomidou.mybatisplus.extension.service.IService; import com.chestnut.contentcore.core.IPublishPipeProp.PublishPipePropUseType; import com.chestnut.contentcore.domain.CmsPublishPipe; import com.chestnut.contentcore.domain.CmsSite; import com.chestnut.contentcore.domain.dto.PublishPipeProp; +import java.io.IOException; +import java.util.List; +import java.util.Map; + public interface IPublishPipeService extends IService { /** * 新增发布通道数据 * - * @param publishPipe - * @throws IOException + * @param publishPipe 发布通道信息 */ - public void addPublishPipe(CmsPublishPipe publishPipe) throws IOException; + void addPublishPipe(CmsPublishPipe publishPipe) throws IOException; /** * 修改发布通道数据 * - * @param publishPipe - * @throws IOException + * @param publishPipe 发布通道信息 */ - public void savePublishPipe(CmsPublishPipe publishPipe) throws IOException; + void savePublishPipe(CmsPublishPipe publishPipe) throws IOException; /** * 删除发布通道 * - * @param publishPipeId - * @throws IOException + * @param publishPipeId 发布通道ID */ - public void deletePublishPipe(List publishPipeId); + void deletePublishPipe(List publishPipeId); /** * 删除指定站点发布通道 * - * @param site - * @throws IOException + * @param site 站点信息 */ - public void deletePublishPipeBySite(CmsSite site); + void deletePublishPipeBySite(CmsSite site); /** - * 获取指定站点可用发布通道 - * - * @param siteId - */ - public List getPublishPipes(Long siteId); + * 获取指定站点可用发布通道 + * + * @param siteId 站点ID + * @return 结果列表 + */ + List getPublishPipes(Long siteId); /** * 获取指定站点所有发布通道 * - * @param siteId + * @param siteId 站点ID + * @return 结果列表 */ - public List getAllPublishPipes(Long siteId); + List getAllPublishPipes(Long siteId); /** * 获取站点下指定使用场景的发布通道数据列表 * - * @param siteId - * @param useType - * @param props - * @return + * @param siteId 站点ID + * @param useType 使用方式 + * @param props 数据集合 + * @return 结果列表 */ List getPublishPipeProps(Long siteId, PublishPipePropUseType useType, Map> props); @@ -87,10 +85,10 @@ public interface IPublishPipeService extends IService { /** * 获取发布通道属性值 * - * @param propKey - * @param publishPipeCode - * @param props - * @return + * @param propKey 发布通道属性唯一标识 + * @param publishPipeCode 发布通道编码 + * @param props 数据集合 + * @return 属性值 */ String getPublishPipePropValue(String propKey, String publishPipeCode, Map> props); } diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/PublishPipeServiceImpl.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/PublishPipeServiceImpl.java index 4ac08413..c5c48ade 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/PublishPipeServiceImpl.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/PublishPipeServiceImpl.java @@ -65,16 +65,17 @@ public class PublishPipeServiceImpl extends ServiceImpl getPublishPipeProps(Long siteId, PublishPipePropUseType useType, Map> props) { - List list = this.publishPipeProps.stream().filter(p -> p.getUseTypes().contains(useType)) + List list = this.publishPipeProps.stream() + .filter(p -> p.getUseTypes().contains(useType)) .toList(); return this.getPublishPipes(siteId).stream().map(pp -> { PublishPipeProp prop = PublishPipeProp.newInstance(pp.getCode(), pp.getName(), @@ -98,7 +99,8 @@ public class PublishPipeServiceImpl extends ServiceImpl opt = this.publishPipeProps.stream().filter(p -> p.getKey().equals(propKey)).findFirst(); + Optional opt = this.publishPipeProps.stream() + .filter(p -> p.getKey().equals(propKey)).findFirst(); if (opt.isPresent()) { return opt.get().getDefaultValue(); } else { @@ -128,7 +130,7 @@ public class PublishPipeServiceImpl extends ServiceImpl - + ${Site.name} @@ -136,7 +138,7 @@ public class PublishPipeServiceImpl extends ServiceImpl${Site.createTime!} - """; + """; @Override public void addPublishPipe(CmsPublishPipe publishPipe) throws IOException { diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/PublishServiceImpl.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/PublishServiceImpl.java index d4ceedaf..481ecbc8 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/PublishServiceImpl.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/PublishServiceImpl.java @@ -89,7 +89,19 @@ public class PublishServiceImpl implements IPublishService, ApplicationContextAw @Override public String getSitePageData(CmsSite site, String publishPipeCode, boolean isPreview) throws IOException, TemplateException { - TemplateContext context = this.generateSiteTemplateContext(site, publishPipeCode, isPreview); + String indexTemplate = site.getIndexTemplate(publishPipeCode); + File templateFile = this.templateService.findTemplateFile(site, indexTemplate, publishPipeCode); + if (Objects.isNull(templateFile)) { + throw ContentCoreErrorCode.TEMPLATE_EMPTY.exception(publishPipeCode, indexTemplate); + } + // 模板ID = 通道:站点目录:模板文件名 + String templateKey = SiteUtils.getTemplateKey(site, publishPipeCode, indexTemplate); + TemplateContext context = new TemplateContext(templateKey, isPreview, publishPipeCode); + // init template datamode + TemplateUtils.initGlobalVariables(site, context); + // init templateType data to datamode + ITemplateType templateType = templateService.getTemplateType(SiteTemplateType.TypeId); + templateType.initTemplateData(site.getSiteId(), context); long s = System.currentTimeMillis(); try (StringWriter writer = new StringWriter()) { @@ -201,12 +213,27 @@ public class PublishServiceImpl implements IPublishService, ApplicationContextAw try { AsyncTaskManager .setTaskMessage(StringUtils.messageFormat("[{0}]正在发布站点首页:{1}", publishPipeCode, site.getName())); - TemplateContext templateContext = this.generateSiteTemplateContext(site, publishPipeCode, false); + + String indexTemplate = site.getIndexTemplate(publishPipeCode); + File templateFile = this.templateService.findTemplateFile(site, indexTemplate, publishPipeCode); + if (Objects.isNull(templateFile)) { + logger.warn(AsyncTaskManager.addErrMessage(StringUtils.messageFormat("[{0}]站点首页模板未配置或不存在:{1}", + publishPipeCode, site.getSiteId() + "#" + site.getName()))); + return; + } + // 模板ID = 通道:站点目录:模板文件名 + String templateKey = SiteUtils.getTemplateKey(site, publishPipeCode, indexTemplate); + TemplateContext context = new TemplateContext(templateKey, false, publishPipeCode); + // init template datamode + TemplateUtils.initGlobalVariables(site, context); + // init templateType data to datamode + ITemplateType templateType = templateService.getTemplateType(SiteTemplateType.TypeId); + templateType.initTemplateData(site.getSiteId(), context); long s = System.currentTimeMillis(); - templateContext.setDirectory(SiteUtils.getSiteRoot(site, publishPipeCode)); - templateContext.setFirstFileName("index" + StringUtils.DOT + site.getStaticSuffix(publishPipeCode)); - this.staticizeService.process(templateContext); + context.setDirectory(SiteUtils.getSiteRoot(site, publishPipeCode)); + context.setFirstFileName("index" + StringUtils.DOT + site.getStaticSuffix(publishPipeCode)); + this.staticizeService.process(context); logger.debug("[{}]首页模板解析:{},耗时:{}ms", publishPipeCode, site.getName(), (System.currentTimeMillis() - s)); } catch (Exception e) { logger.error(AsyncTaskManager.addErrMessage(StringUtils.messageFormat("[{0}][{1}]站点首页解析失败:{2}", @@ -214,23 +241,6 @@ public class PublishServiceImpl implements IPublishService, ApplicationContextAw } } - private TemplateContext generateSiteTemplateContext(CmsSite site, String publishPipeCode, boolean isPreview) { - String indexTemplate = site.getIndexTemplate(publishPipeCode); - File templateFile = this.templateService.findTemplateFile(site, indexTemplate, publishPipeCode); - Assert.notNull(templateFile, - () -> ContentCoreErrorCode.TEMPLATE_EMPTY.exception(publishPipeCode, indexTemplate)); - - // 模板ID = 通道:站点目录:模板文件名 - String templateKey = SiteUtils.getTemplateKey(site, publishPipeCode, indexTemplate); - TemplateContext templateContext = new TemplateContext(templateKey, isPreview, publishPipeCode); - // init template datamode - TemplateUtils.initGlobalVariables(site, templateContext); - // init templateType data to datamode - ITemplateType templateType = templateService.getTemplateType(SiteTemplateType.TypeId); - templateType.initTemplateData(site.getSiteId(), templateContext); - return templateContext; - } - @Override public String getCatalogPageData(CmsCatalog catalog, int pageIndex, boolean listFlag, String publishPipeCode, boolean isPreview) throws IOException, TemplateException { @@ -712,7 +722,7 @@ public class PublishServiceImpl implements IPublishService, ApplicationContextAw } File templateFile = this.templateService.findTemplateFile(site, exTemplate, publishPipeCode); if (templateFile == null) { - logger.warn("[{}]栏目[{}#{}]扩展模板未设置或文件不存在", publishPipeCode, catalog.getName(), content.getTitle()); + logger.warn("[{}]内容[{}#{}]扩展模板未设置或文件不存在", publishPipeCode, catalog.getName(), content.getTitle()); return; } try { @@ -775,8 +785,10 @@ public class PublishServiceImpl implements IPublishService, ApplicationContextAw CmsPageWidget pw = pageWidget.getPageWidgetEntity(); CmsSite site = this.siteService.getSite(pw.getSiteId()); File templateFile = this.templateService.findTemplateFile(site, pw.getTemplate(), pw.getPublishPipeCode()); - Assert.notNull(templateFile, () -> new RuntimeException( - StringUtils.messageFormat("页面部件【{0}%s#{1}%s】模板未配置或文件不存在", pw.getName(), pw.getCode()))); + if (Objects.isNull(templateFile)) { + logger.warn(StringUtils.messageFormat("页面部件【{0}%s#{1}%s】模板未配置或文件不存在", pw.getName(), pw.getCode())); + return; + } try { // 静态化目录 String dirPath = SiteUtils.getSiteRoot(site, pw.getPublishPipeCode()) + pw.getPath(); diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/SiteServiceImpl.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/SiteServiceImpl.java index 64916f73..48c204c0 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/SiteServiceImpl.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/service/impl/SiteServiceImpl.java @@ -25,6 +25,7 @@ import com.chestnut.common.utils.file.FileExUtils; import com.chestnut.contentcore.ContentCoreConsts; import com.chestnut.contentcore.config.CMSConfig; import com.chestnut.contentcore.core.IProperty; +import com.chestnut.contentcore.core.IPublishPipeProp; import com.chestnut.contentcore.domain.CmsSite; import com.chestnut.contentcore.domain.dto.PublishPipeProp; import com.chestnut.contentcore.domain.dto.SiteDTO; @@ -69,6 +70,8 @@ public class SiteServiceImpl extends ServiceImpl impleme private final ISysPermissionService permissionService; + private final Map publishPipeProps; + private final RedisCache redisCache; @Override @@ -146,6 +149,9 @@ public class SiteServiceImpl extends ServiceImpl impleme site.setResourceUrl(site.getResourceUrl() + "/"); } // 发布通道数据处理 + dto.getPublishPipeDatas().forEach(prop -> { + prop.getProps().entrySet().removeIf(e -> !publishPipeProps.containsKey(IPublishPipeProp.BEAN_PREFIX + e.getKey())); + }); Map> publishPipeProps = dto.getPublishPipeDatas().stream() .collect(Collectors.toMap(PublishPipeProp::getPipeCode, PublishPipeProp::getProps)); site.setPublishPipeProps(publishPipeProps); diff --git a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/template/func/InternalUrlFunction.java b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/template/func/InternalUrlFunction.java index b9a117db..2a28874b 100644 --- a/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/template/func/InternalUrlFunction.java +++ b/chestnut-cms/chestnut-cms-contentcore/src/main/java/com/chestnut/contentcore/template/func/InternalUrlFunction.java @@ -69,4 +69,9 @@ public class InternalUrlFunction extends AbstractFunc { public List getFuncArgs() { return List.of(new FuncArg("内部链接", FuncArgType.String, true, null)); } + + @Override + public List getAliases() { + return List.of("iurl"); + } } diff --git a/chestnut-cms/chestnut-cms-customform/pom.xml b/chestnut-cms/chestnut-cms-customform/pom.xml index abf3cbb0..c13e9e5f 100644 --- a/chestnut-cms/chestnut-cms-customform/pom.xml +++ b/chestnut-cms/chestnut-cms-customform/pom.xml @@ -7,7 +7,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-customform diff --git a/chestnut-cms/chestnut-cms-customform/src/main/java/com/chestnut/customform/publishpipe/PublishPipeProp_CustomFormTemplate.java b/chestnut-cms/chestnut-cms-customform/src/main/java/com/chestnut/customform/publishpipe/PublishPipeProp_CustomFormTemplate.java index ec42e6bf..8a448e72 100644 --- a/chestnut-cms/chestnut-cms-customform/src/main/java/com/chestnut/customform/publishpipe/PublishPipeProp_CustomFormTemplate.java +++ b/chestnut-cms/chestnut-cms-customform/src/main/java/com/chestnut/customform/publishpipe/PublishPipeProp_CustomFormTemplate.java @@ -29,7 +29,7 @@ import java.util.Objects; * @author 兮玥 * @email 190785909@qq.com */ -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_CustomFormTemplate.KEY) public class PublishPipeProp_CustomFormTemplate implements IPublishPipeProp { public static final String KEY = "defaultCustomFormTemplate"; diff --git a/chestnut-cms/chestnut-cms-dynamic/pom.xml b/chestnut-cms/chestnut-cms-dynamic/pom.xml index 70d1eaf7..9547dda4 100644 --- a/chestnut-cms/chestnut-cms-dynamic/pom.xml +++ b/chestnut-cms/chestnut-cms-dynamic/pom.xml @@ -7,7 +7,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-dynamic diff --git a/chestnut-cms/chestnut-cms-exmodel/pom.xml b/chestnut-cms/chestnut-cms-exmodel/pom.xml index f7a3d8d7..4269b9c9 100644 --- a/chestnut-cms/chestnut-cms-exmodel/pom.xml +++ b/chestnut-cms/chestnut-cms-exmodel/pom.xml @@ -7,7 +7,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-exmodel diff --git a/chestnut-cms/chestnut-cms-image/pom.xml b/chestnut-cms/chestnut-cms-image/pom.xml index ffee28c3..151a302c 100644 --- a/chestnut-cms/chestnut-cms-image/pom.xml +++ b/chestnut-cms/chestnut-cms-image/pom.xml @@ -7,7 +7,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-image diff --git a/chestnut-cms/chestnut-cms-image/src/main/java/com/chestnut/cms/image/PublishPipeProp_DefaultImageDetailTemplate.java b/chestnut-cms/chestnut-cms-image/src/main/java/com/chestnut/cms/image/PublishPipeProp_DefaultImageDetailTemplate.java index 4f1b8722..251f5332 100644 --- a/chestnut-cms/chestnut-cms-image/src/main/java/com/chestnut/cms/image/PublishPipeProp_DefaultImageDetailTemplate.java +++ b/chestnut-cms/chestnut-cms-image/src/main/java/com/chestnut/cms/image/PublishPipeProp_DefaultImageDetailTemplate.java @@ -15,13 +15,12 @@ */ package com.chestnut.cms.image; -import java.util.List; - +import com.chestnut.contentcore.core.IPublishPipeProp; import org.springframework.stereotype.Component; -import com.chestnut.contentcore.core.IPublishPipeProp; +import java.util.List; -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_DefaultImageDetailTemplate.KEY) public class PublishPipeProp_DefaultImageDetailTemplate implements IPublishPipeProp { public static final String KEY = DefaultDetailTemplatePropPrefix + ImageContentType.ID; diff --git a/chestnut-cms/chestnut-cms-image/src/main/java/com/chestnut/cms/image/PublishPipeProp_ImageDetailTemplate.java b/chestnut-cms/chestnut-cms-image/src/main/java/com/chestnut/cms/image/PublishPipeProp_ImageDetailTemplate.java index 2df92f68..0ca999a6 100644 --- a/chestnut-cms/chestnut-cms-image/src/main/java/com/chestnut/cms/image/PublishPipeProp_ImageDetailTemplate.java +++ b/chestnut-cms/chestnut-cms-image/src/main/java/com/chestnut/cms/image/PublishPipeProp_ImageDetailTemplate.java @@ -15,13 +15,12 @@ */ package com.chestnut.cms.image; -import java.util.List; - +import com.chestnut.contentcore.core.IPublishPipeProp; import org.springframework.stereotype.Component; -import com.chestnut.contentcore.core.IPublishPipeProp; +import java.util.List; -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_ImageDetailTemplate.KEY) public class PublishPipeProp_ImageDetailTemplate implements IPublishPipeProp { public static final String KEY = DetailTemplatePropPrefix + ImageContentType.ID; diff --git a/chestnut-cms/chestnut-cms-link/pom.xml b/chestnut-cms/chestnut-cms-link/pom.xml index 1efbc6d6..44fba508 100644 --- a/chestnut-cms/chestnut-cms-link/pom.xml +++ b/chestnut-cms/chestnut-cms-link/pom.xml @@ -7,7 +7,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-link diff --git a/chestnut-cms/chestnut-cms-media/pom.xml b/chestnut-cms/chestnut-cms-media/pom.xml index 1f7c92e4..4b99497c 100644 --- a/chestnut-cms/chestnut-cms-media/pom.xml +++ b/chestnut-cms/chestnut-cms-media/pom.xml @@ -7,7 +7,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-media diff --git a/chestnut-cms/chestnut-cms-media/src/main/java/com/chestnut/media/publishpipe/prop/PublishPipeProp_AudioDetailTemplate.java b/chestnut-cms/chestnut-cms-media/src/main/java/com/chestnut/media/publishpipe/prop/PublishPipeProp_AudioDetailTemplate.java index 45ef397c..56d283aa 100644 --- a/chestnut-cms/chestnut-cms-media/src/main/java/com/chestnut/media/publishpipe/prop/PublishPipeProp_AudioDetailTemplate.java +++ b/chestnut-cms/chestnut-cms-media/src/main/java/com/chestnut/media/publishpipe/prop/PublishPipeProp_AudioDetailTemplate.java @@ -15,14 +15,13 @@ */ package com.chestnut.media.publishpipe.prop; -import java.util.List; - -import org.springframework.stereotype.Component; - import com.chestnut.contentcore.core.IPublishPipeProp; import com.chestnut.media.AudioContentType; +import org.springframework.stereotype.Component; -@Component +import java.util.List; + +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_AudioDetailTemplate.KEY) public class PublishPipeProp_AudioDetailTemplate implements IPublishPipeProp { public static final String KEY = DetailTemplatePropPrefix + AudioContentType.ID; diff --git a/chestnut-cms/chestnut-cms-media/src/main/java/com/chestnut/media/publishpipe/prop/PublishPipeProp_DefaultAudioDetailTemplate.java b/chestnut-cms/chestnut-cms-media/src/main/java/com/chestnut/media/publishpipe/prop/PublishPipeProp_DefaultAudioDetailTemplate.java index 12619b54..07ababca 100644 --- a/chestnut-cms/chestnut-cms-media/src/main/java/com/chestnut/media/publishpipe/prop/PublishPipeProp_DefaultAudioDetailTemplate.java +++ b/chestnut-cms/chestnut-cms-media/src/main/java/com/chestnut/media/publishpipe/prop/PublishPipeProp_DefaultAudioDetailTemplate.java @@ -15,14 +15,13 @@ */ package com.chestnut.media.publishpipe.prop; -import java.util.List; - -import org.springframework.stereotype.Component; - import com.chestnut.contentcore.core.IPublishPipeProp; import com.chestnut.media.AudioContentType; +import org.springframework.stereotype.Component; -@Component +import java.util.List; + +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_DefaultAudioDetailTemplate.KEY) public class PublishPipeProp_DefaultAudioDetailTemplate implements IPublishPipeProp { public static final String KEY = DefaultDetailTemplatePropPrefix + AudioContentType.ID; diff --git a/chestnut-cms/chestnut-cms-media/src/main/java/com/chestnut/media/publishpipe/prop/PublishPipeProp_DefaultVideoDetailTemplate.java b/chestnut-cms/chestnut-cms-media/src/main/java/com/chestnut/media/publishpipe/prop/PublishPipeProp_DefaultVideoDetailTemplate.java index 4d928bef..2073886c 100644 --- a/chestnut-cms/chestnut-cms-media/src/main/java/com/chestnut/media/publishpipe/prop/PublishPipeProp_DefaultVideoDetailTemplate.java +++ b/chestnut-cms/chestnut-cms-media/src/main/java/com/chestnut/media/publishpipe/prop/PublishPipeProp_DefaultVideoDetailTemplate.java @@ -15,14 +15,13 @@ */ package com.chestnut.media.publishpipe.prop; -import java.util.List; - -import org.springframework.stereotype.Component; - import com.chestnut.contentcore.core.IPublishPipeProp; import com.chestnut.media.VideoContentType; +import org.springframework.stereotype.Component; -@Component +import java.util.List; + +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_DefaultVideoDetailTemplate.KEY) public class PublishPipeProp_DefaultVideoDetailTemplate implements IPublishPipeProp { public static final String KEY = DefaultDetailTemplatePropPrefix + VideoContentType.ID; diff --git a/chestnut-cms/chestnut-cms-media/src/main/java/com/chestnut/media/publishpipe/prop/PublishPipeProp_VideoDetailTemplate.java b/chestnut-cms/chestnut-cms-media/src/main/java/com/chestnut/media/publishpipe/prop/PublishPipeProp_VideoDetailTemplate.java index 352d69e0..13268920 100644 --- a/chestnut-cms/chestnut-cms-media/src/main/java/com/chestnut/media/publishpipe/prop/PublishPipeProp_VideoDetailTemplate.java +++ b/chestnut-cms/chestnut-cms-media/src/main/java/com/chestnut/media/publishpipe/prop/PublishPipeProp_VideoDetailTemplate.java @@ -15,14 +15,13 @@ */ package com.chestnut.media.publishpipe.prop; -import java.util.List; - -import org.springframework.stereotype.Component; - import com.chestnut.contentcore.core.IPublishPipeProp; import com.chestnut.media.VideoContentType; +import org.springframework.stereotype.Component; -@Component +import java.util.List; + +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_VideoDetailTemplate.KEY) public class PublishPipeProp_VideoDetailTemplate implements IPublishPipeProp { public static final String KEY = DetailTemplatePropPrefix + VideoContentType.ID; diff --git a/chestnut-cms/chestnut-cms-member/pom.xml b/chestnut-cms/chestnut-cms-member/pom.xml index 8168e827..af25a720 100644 --- a/chestnut-cms/chestnut-cms-member/pom.xml +++ b/chestnut-cms/chestnut-cms-member/pom.xml @@ -6,7 +6,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-member diff --git a/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_AccountCentreTemplate.java b/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_AccountCentreTemplate.java index ddb28c72..3c9e1c63 100644 --- a/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_AccountCentreTemplate.java +++ b/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_AccountCentreTemplate.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_AccountCentreTemplate.KEY) public class PublishPipeProp_AccountCentreTemplate implements IPublishPipeProp { public static final String KEY = "accountCentreTemplate"; diff --git a/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberBindEmailTemplate.java b/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberBindEmailTemplate.java index fb5d1a76..bc29c7af 100644 --- a/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberBindEmailTemplate.java +++ b/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberBindEmailTemplate.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_MemberBindEmailTemplate.KEY) public class PublishPipeProp_MemberBindEmailTemplate implements IPublishPipeProp { public static final String KEY = "memberBindEmailTemplate"; diff --git a/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberContributeTemplate.java b/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberContributeTemplate.java index 930b8f13..5eca5d8f 100644 --- a/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberContributeTemplate.java +++ b/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberContributeTemplate.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_MemberContributeTemplate.KEY) public class PublishPipeProp_MemberContributeTemplate implements IPublishPipeProp { public static final String KEY = "memberContributeTemplate"; diff --git a/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberForgetPasswordTemplate.java b/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberForgetPasswordTemplate.java index e3ebb109..26d451a3 100644 --- a/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberForgetPasswordTemplate.java +++ b/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberForgetPasswordTemplate.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_MemberForgetPasswordTemplate.KEY) public class PublishPipeProp_MemberForgetPasswordTemplate implements IPublishPipeProp { public static final String KEY = "memberForgetPasswordTemplate"; diff --git a/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberLoginTemplate.java b/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberLoginTemplate.java index 6deea514..0d4ddf3b 100644 --- a/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberLoginTemplate.java +++ b/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberLoginTemplate.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_MemberLoginTemplate.KEY) public class PublishPipeProp_MemberLoginTemplate implements IPublishPipeProp { public static final String KEY = "memberLoginTemplate"; diff --git a/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberPasswordTemplate.java b/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberPasswordTemplate.java index 79c013ba..67ebfef8 100644 --- a/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberPasswordTemplate.java +++ b/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberPasswordTemplate.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_MemberPasswordTemplate.KEY) public class PublishPipeProp_MemberPasswordTemplate implements IPublishPipeProp { public static final String KEY = "memberPasswordTemplate"; diff --git a/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberRegisterTemplate.java b/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberRegisterTemplate.java index 5f2334b8..279544c0 100644 --- a/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberRegisterTemplate.java +++ b/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberRegisterTemplate.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_MemberRegisterTemplate.KEY) public class PublishPipeProp_MemberRegisterTemplate implements IPublishPipeProp { public static final String KEY = "memberRegisterTemplate"; diff --git a/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberSettingTemplate.java b/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberSettingTemplate.java index 39464d9f..fed913f7 100644 --- a/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberSettingTemplate.java +++ b/chestnut-cms/chestnut-cms-member/src/main/java/com/chestnut/cms/member/publishpipe/PublishPipeProp_MemberSettingTemplate.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_MemberSettingTemplate.KEY) public class PublishPipeProp_MemberSettingTemplate implements IPublishPipeProp { public static final String KEY = "memberSettingTemplate"; diff --git a/chestnut-cms/chestnut-cms-search/pom.xml b/chestnut-cms/chestnut-cms-search/pom.xml index 6e46b448..992d3336 100644 --- a/chestnut-cms/chestnut-cms-search/pom.xml +++ b/chestnut-cms/chestnut-cms-search/pom.xml @@ -7,7 +7,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-search diff --git a/chestnut-cms/chestnut-cms-search/src/main/java/com/chestnut/cms/search/controller/ContentIndexController.java b/chestnut-cms/chestnut-cms-search/src/main/java/com/chestnut/cms/search/controller/ContentIndexController.java index b50047f6..303a512f 100644 --- a/chestnut-cms/chestnut-cms-search/src/main/java/com/chestnut/cms/search/controller/ContentIndexController.java +++ b/chestnut-cms/chestnut-cms-search/src/main/java/com/chestnut/cms/search/controller/ContentIndexController.java @@ -48,6 +48,7 @@ import com.chestnut.search.SearchConsts; import com.chestnut.search.exception.SearchErrorCode; import com.chestnut.system.security.AdminUserType; import com.chestnut.system.validator.LongId; +import com.chestnut.xmodel.core.IMetaModelType; import com.fasterxml.jackson.databind.node.ObjectNode; import jakarta.validation.constraints.NotEmpty; import lombok.RequiredArgsConstructor; @@ -131,6 +132,11 @@ public class ContentIndexController extends BaseRestController { List list = sr.hits().hits().stream().map(hit -> { ObjectNode source = hit.source(); ESContentVO vo = JacksonUtils.getObjectMapper().convertValue(source, ESContentVO.class); + source.fieldNames().forEachRemaining(fieldName -> { + if (fieldName.startsWith(IMetaModelType.DATA_FIELD_PREFIX)) { + vo.getExtendData().put(fieldName, source.get(fieldName).asText()); + } + }); vo.setHitScore(hit.score()); vo.setPublishDateInstance(LocalDateTime.ofEpochSecond(vo.getPublishDate(), 0, ZoneOffset.UTC)); vo.setCreateTimeInstance(LocalDateTime.ofEpochSecond(vo.getCreateTime(), 0, ZoneOffset.UTC)); @@ -138,13 +144,13 @@ public class ContentIndexController extends BaseRestController { if (Objects.nonNull(catalog)) { vo.setCatalogName(catalog.getName()); } - hit.highlight().entrySet().forEach(e -> { - if (e.getKey().equals("fullText")) { - vo.setFullText(StringUtils.join(e.getValue().toArray(String[]::new))); - } else if (e.getKey().equals("title")) { - vo.setTitle(StringUtils.join(e.getValue().toArray(String[]::new))); - } - }); + hit.highlight().forEach((key, value) -> { + if (key.equals("fullText")) { + vo.setFullText(StringUtils.join(value.toArray(String[]::new))); + } else if (key.equals("title")) { + vo.setTitle(StringUtils.join(value.toArray(String[]::new))); + } + }); return vo; }).toList(); return this.bindDataTable(list, sr.hits().total().value()); 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 2e88566b..011fd1fc 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 @@ -128,6 +128,8 @@ public class SearchApiController extends BaseRestController { if (Objects.nonNull(catalog)) { vo.setCatalogName(catalog.getName()); } + vo.setLink(InternalUrlUtils.getActualUrl(vo.getLink(), publishPipeCode, preview)); + vo.setLogo(InternalUrlUtils.getActualUrl(vo.getLogo(), publishPipeCode, preview)); hit.highlight().forEach((key, value) -> { try { if (key.equals("fullText")) { @@ -135,8 +137,6 @@ public class SearchApiController extends BaseRestController { } else if (key.equals("title")) { vo.setTitle(StringUtils.join(value.toArray(String[]::new))); } - vo.setLink(InternalUrlUtils.getActualUrl(vo.getLink(), publishPipeCode, preview)); - vo.setLogo(InternalUrlUtils.getActualUrl(vo.getLogo(), publishPipeCode, preview)); } catch (Exception ex) { log.warn("Search api row parse failed: ", ex); } diff --git a/chestnut-cms/chestnut-cms-search/src/main/java/com/chestnut/cms/search/publishpipe/PublishPipeProp_SearchTemplate.java b/chestnut-cms/chestnut-cms-search/src/main/java/com/chestnut/cms/search/publishpipe/PublishPipeProp_SearchTemplate.java index 01fc1440..31aa0cdd 100644 --- a/chestnut-cms/chestnut-cms-search/src/main/java/com/chestnut/cms/search/publishpipe/PublishPipeProp_SearchTemplate.java +++ b/chestnut-cms/chestnut-cms-search/src/main/java/com/chestnut/cms/search/publishpipe/PublishPipeProp_SearchTemplate.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_SearchTemplate.KEY) public class PublishPipeProp_SearchTemplate implements IPublishPipeProp { public static final String KEY = "searchTemplate"; diff --git a/chestnut-cms/chestnut-cms-seo/pom.xml b/chestnut-cms/chestnut-cms-seo/pom.xml index b07daf1e..232070f3 100644 --- a/chestnut-cms/chestnut-cms-seo/pom.xml +++ b/chestnut-cms/chestnut-cms-seo/pom.xml @@ -7,7 +7,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-seo diff --git a/chestnut-cms/chestnut-cms-seo/src/main/java/com/chestnut/seo/publishpipe/PublishPipeProp_EnableSitemap.java b/chestnut-cms/chestnut-cms-seo/src/main/java/com/chestnut/seo/publishpipe/PublishPipeProp_EnableSitemap.java index 60535bb4..318dd955 100644 --- a/chestnut-cms/chestnut-cms-seo/src/main/java/com/chestnut/seo/publishpipe/PublishPipeProp_EnableSitemap.java +++ b/chestnut-cms/chestnut-cms-seo/src/main/java/com/chestnut/seo/publishpipe/PublishPipeProp_EnableSitemap.java @@ -30,7 +30,7 @@ import java.util.Objects; * @author 兮玥 * @email 190785909@qq.com */ -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_EnableSitemap.KEY) public class PublishPipeProp_EnableSitemap implements IPublishPipeProp { public static final String KEY = "enableSitemap"; diff --git a/chestnut-cms/chestnut-cms-seo/src/main/java/com/chestnut/seo/publishpipe/PublishPipeProp_SitemapPageType.java b/chestnut-cms/chestnut-cms-seo/src/main/java/com/chestnut/seo/publishpipe/PublishPipeProp_SitemapPageType.java index bfbc3afa..9bc9587c 100644 --- a/chestnut-cms/chestnut-cms-seo/src/main/java/com/chestnut/seo/publishpipe/PublishPipeProp_SitemapPageType.java +++ b/chestnut-cms/chestnut-cms-seo/src/main/java/com/chestnut/seo/publishpipe/PublishPipeProp_SitemapPageType.java @@ -30,7 +30,7 @@ import java.util.Objects; * @author 兮玥 * @email 190785909@qq.com */ -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_SitemapPageType.KEY) public class PublishPipeProp_SitemapPageType implements IPublishPipeProp { public static final String KEY = "sitemapPageType"; diff --git a/chestnut-cms/chestnut-cms-seo/src/main/java/com/chestnut/seo/publishpipe/PublishPipeProp_SitemapUrlLimit.java b/chestnut-cms/chestnut-cms-seo/src/main/java/com/chestnut/seo/publishpipe/PublishPipeProp_SitemapUrlLimit.java index 80ea4ada..cadff6f0 100644 --- a/chestnut-cms/chestnut-cms-seo/src/main/java/com/chestnut/seo/publishpipe/PublishPipeProp_SitemapUrlLimit.java +++ b/chestnut-cms/chestnut-cms-seo/src/main/java/com/chestnut/seo/publishpipe/PublishPipeProp_SitemapUrlLimit.java @@ -30,7 +30,7 @@ import java.util.Objects; * @author 兮玥 * @email 190785909@qq.com */ -@Component +@Component(IPublishPipeProp.BEAN_PREFIX + PublishPipeProp_SitemapUrlLimit.KEY) public class PublishPipeProp_SitemapUrlLimit implements IPublishPipeProp { public static final String KEY = "sitemapUrlLimit"; diff --git a/chestnut-cms/chestnut-cms-seo/src/main/java/com/chestnut/seo/service/BaiduPushService.java b/chestnut-cms/chestnut-cms-seo/src/main/java/com/chestnut/seo/service/BaiduPushService.java index 5053045b..ec60b22b 100644 --- a/chestnut-cms/chestnut-cms-seo/src/main/java/com/chestnut/seo/service/BaiduPushService.java +++ b/chestnut-cms/chestnut-cms-seo/src/main/java/com/chestnut/seo/service/BaiduPushService.java @@ -15,6 +15,8 @@ */ package com.chestnut.seo.service; +import com.chestnut.common.exception.GlobalException; +import com.chestnut.common.utils.Assert; import com.chestnut.common.utils.HttpUtils; import com.chestnut.common.utils.JacksonUtils; import com.chestnut.common.utils.StringUtils; @@ -52,9 +54,8 @@ public class BaiduPushService { public List pushContents(CmsSite site, List contentIds) { String secret = BaiduPushAccessSecretProperty.getValue(site.getConfigProps()); - if (StringUtils.isEmpty(secret)) { - return List.of(); - } + Assert.notEmpty(secret, () -> new GlobalException("Baidu push access secret not configured.")); + List publishPipes = publishPipeService.getPublishPipes(site.getSiteId()); List results = new ArrayList<>(publishPipes.size()); publishPipes.forEach(pp -> { diff --git a/chestnut-cms/chestnut-cms-stat/pom.xml b/chestnut-cms/chestnut-cms-stat/pom.xml index af16f274..09a0e503 100644 --- a/chestnut-cms/chestnut-cms-stat/pom.xml +++ b/chestnut-cms/chestnut-cms-stat/pom.xml @@ -7,7 +7,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-stat diff --git a/chestnut-cms/chestnut-cms-vote/pom.xml b/chestnut-cms/chestnut-cms-vote/pom.xml index a8d844d0..18874669 100644 --- a/chestnut-cms/chestnut-cms-vote/pom.xml +++ b/chestnut-cms/chestnut-cms-vote/pom.xml @@ -7,7 +7,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-vote diff --git a/chestnut-cms/chestnut-cms-word/pom.xml b/chestnut-cms/chestnut-cms-word/pom.xml index daeea65b..04804183 100644 --- a/chestnut-cms/chestnut-cms-word/pom.xml +++ b/chestnut-cms/chestnut-cms-word/pom.xml @@ -7,7 +7,7 @@ com.chestnut chestnut-cms - 1.4.2 + 1.4.3 chestnut-cms-word diff --git a/chestnut-cms/pom.xml b/chestnut-cms/pom.xml index f8403947..a26aa2f1 100644 --- a/chestnut-cms/pom.xml +++ b/chestnut-cms/pom.xml @@ -5,7 +5,7 @@ com.chestnut chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-common/chestnut-common-core/pom.xml b/chestnut-common/chestnut-common-core/pom.xml index a0d71294..fe612499 100644 --- a/chestnut-common/chestnut-common-core/pom.xml +++ b/chestnut-common/chestnut-common-core/pom.xml @@ -5,7 +5,7 @@ chestnut-common com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-common/chestnut-common-core/src/main/java/com/chestnut/common/utils/ObjectUtils.java b/chestnut-common/chestnut-common-core/src/main/java/com/chestnut/common/utils/ObjectUtils.java index feef9439..644db967 100644 --- a/chestnut-common/chestnut-common-core/src/main/java/com/chestnut/common/utils/ObjectUtils.java +++ b/chestnut-common/chestnut-common-core/src/main/java/com/chestnut/common/utils/ObjectUtils.java @@ -50,4 +50,14 @@ public class ObjectUtils { } return Objects.nonNull(objects[index]); } + + /** + * 指定对象是否为null或者转成string后为空字符串 + * + * @param obj + * @return + */ + public static boolean isNullOrEmptyStr(Object obj) { + return Objects.isNull(obj) || StringUtils.isEmpty(obj.toString()); + } } diff --git a/chestnut-common/chestnut-common-datasource/pom.xml b/chestnut-common/chestnut-common-datasource/pom.xml index 3d75a747..46eb591d 100644 --- a/chestnut-common/chestnut-common-datasource/pom.xml +++ b/chestnut-common/chestnut-common-datasource/pom.xml @@ -5,7 +5,7 @@ chestnut-common com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-common/chestnut-common-extend/pom.xml b/chestnut-common/chestnut-common-extend/pom.xml index a2babca9..0648308d 100644 --- a/chestnut-common/chestnut-common-extend/pom.xml +++ b/chestnut-common/chestnut-common-extend/pom.xml @@ -5,7 +5,7 @@ chestnut-common com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-common/chestnut-common-log/pom.xml b/chestnut-common/chestnut-common-log/pom.xml index 604dec9c..6fd69df1 100644 --- a/chestnut-common/chestnut-common-log/pom.xml +++ b/chestnut-common/chestnut-common-log/pom.xml @@ -5,7 +5,7 @@ chestnut-common com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-common/chestnut-common-redis/pom.xml b/chestnut-common/chestnut-common-redis/pom.xml index 7c17633b..47b1d1d6 100644 --- a/chestnut-common/chestnut-common-redis/pom.xml +++ b/chestnut-common/chestnut-common-redis/pom.xml @@ -5,7 +5,7 @@ chestnut-common com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-common/chestnut-common-security/pom.xml b/chestnut-common/chestnut-common-security/pom.xml index 37d07033..d903f13a 100644 --- a/chestnut-common/chestnut-common-security/pom.xml +++ b/chestnut-common/chestnut-common-security/pom.xml @@ -5,7 +5,7 @@ chestnut-common com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-common/chestnut-common-staticize/pom.xml b/chestnut-common/chestnut-common-staticize/pom.xml index 5f0b5adc..f7488c1c 100644 --- a/chestnut-common/chestnut-common-staticize/pom.xml +++ b/chestnut-common/chestnut-common-staticize/pom.xml @@ -5,7 +5,7 @@ chestnut-common com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/StaticizeService.java b/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/StaticizeService.java index 50aa2020..f9892ca6 100644 --- a/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/StaticizeService.java +++ b/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/StaticizeService.java @@ -136,6 +136,13 @@ public class StaticizeService { Assert.isNull(cfg.getSharedVariable(func.getFuncName()), () -> new IllegalArgumentException("Freemarker function conflict: " + func.getFuncName())); cfg.setSharedVariable(func.getFuncName(), func); + if (!func.getAliases().isEmpty()) { + for (String alias : func.getAliases()) { + Assert.isNull(cfg.getSharedVariable(alias), + () -> new IllegalArgumentException("Freemarker function alias conflict: " + alias)); + cfg.setSharedVariable(alias, func); + } + } } catch (TemplateModelException e) { log.error("Freemarker function '{}' register failed.", func.getFuncName()); throw new IllegalArgumentException(e); diff --git a/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/func/IFunction.java b/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/func/IFunction.java index a17cd36c..2ac0c5f9 100644 --- a/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/func/IFunction.java +++ b/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/func/IFunction.java @@ -28,28 +28,35 @@ public interface IFunction { * * @return */ - public String getFuncName(); + String getFuncName(); /** * 描述 * * @return */ - public String getDesc(); + String getDesc(); /** * 获取函数参数定义列表 * * @return */ - public List getFuncArgs(); + List getFuncArgs(); + + /** + * 函数别名 + */ + default List getAliases() { + return List.of(); + } /** * 模板函数参数 */ @Getter @Setter - public class FuncArg { + class FuncArg { private String name; @@ -67,7 +74,7 @@ public interface IFunction { } } - public enum FuncArgType { + enum FuncArgType { String, Int, Long, Float, Double, DateTime, Boolean } } diff --git a/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/func/impl/MaxFunction.java b/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/func/impl/MaxFunction.java index 21fd3187..60220e95 100644 --- a/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/func/impl/MaxFunction.java +++ b/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/func/impl/MaxFunction.java @@ -17,11 +17,12 @@ package com.chestnut.common.staticize.func.impl; import com.chestnut.common.staticize.func.AbstractFunc; import com.chestnut.common.utils.StringUtils; -import freemarker.template.SimpleNumber; import freemarker.template.TemplateModelException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; +import java.util.Collections; +import java.util.Comparator; import java.util.List; /** @@ -50,14 +51,8 @@ public class MaxFunction extends AbstractFunc { if (StringUtils.isEmpty(args)) { return StringUtils.EMPTY; } - SimpleNumber max = (SimpleNumber) args[0]; - for (int i = 1; i < args.length; i++) { - SimpleNumber simpleNumber = (SimpleNumber) args[i]; - if (simpleNumber.getAsNumber().doubleValue() > max.getAsNumber().doubleValue()) { - max = simpleNumber; - } - } - return max; + List numbers = MinFunction.readNumbers(args); + return Collections.max(numbers, Comparator.comparing(Number::doubleValue)); } @Override diff --git a/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/func/impl/MinFunction.java b/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/func/impl/MinFunction.java index 479032d7..77941cfc 100644 --- a/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/func/impl/MinFunction.java +++ b/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/func/impl/MinFunction.java @@ -17,11 +17,13 @@ package com.chestnut.common.staticize.func.impl; import com.chestnut.common.staticize.func.AbstractFunc; import com.chestnut.common.utils.StringUtils; -import freemarker.template.SimpleNumber; -import freemarker.template.TemplateModelException; +import freemarker.template.*; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; /** @@ -50,14 +52,32 @@ public class MinFunction extends AbstractFunc { if (StringUtils.isEmpty(args)) { return StringUtils.EMPTY; } - SimpleNumber min = (SimpleNumber) args[0]; - for (int i = 1; i < args.length; i++) { - SimpleNumber simpleNumber = (SimpleNumber) args[i]; - if (simpleNumber.getAsNumber().doubleValue() < min.getAsNumber().doubleValue()) { - min = simpleNumber; - } - } - return min; + List numbers = readNumbers(args); + return Collections.min(numbers, Comparator.comparing(Number::doubleValue)); + } + + static List readNumbers(Object... args) throws TemplateModelException { + ArrayList numbers = new ArrayList<>(); + for (Object arg : args) { + if (arg instanceof SimpleNumber simpleNumber) { + numbers.add(simpleNumber.getAsNumber()); + } else if (arg instanceof SimpleSequence simpleSequence) { + for (int j = 0; j < simpleSequence.size(); j++) { + if (simpleSequence.get(j) instanceof SimpleNumber simpleNumber) { + numbers.add(simpleNumber.getAsNumber()); + } + } + } else if (arg instanceof SimpleCollection simpleCollection) { + TemplateModelIterator iterator = simpleCollection.iterator(); + while (iterator.hasNext()) { + TemplateModel next = iterator.next(); + if (next instanceof SimpleNumber simpleNumber) { + numbers.add(simpleNumber.getAsNumber()); + } + } + } + } + return numbers; } @Override diff --git a/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/tag/ITag.java b/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/tag/ITag.java index 78a10b8a..8164c6e3 100644 --- a/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/tag/ITag.java +++ b/chestnut-common/chestnut-common-staticize/src/main/java/com/chestnut/common/staticize/tag/ITag.java @@ -24,24 +24,24 @@ public interface ITag { * * <@value> */ - public String getTagName(); + String getTagName(); /** * 标签名称 */ - public String getName(); + String getName(); /** * 标签描述 */ - default public String getDescription() { + default String getDescription() { return ""; } /** * 标签属性定义 */ - default public List getTagAttrs() { + default List getTagAttrs() { return null; } } diff --git a/chestnut-common/chestnut-common-storage/pom.xml b/chestnut-common/chestnut-common-storage/pom.xml index be7b392e..855e65dd 100644 --- a/chestnut-common/chestnut-common-storage/pom.xml +++ b/chestnut-common/chestnut-common-storage/pom.xml @@ -5,7 +5,7 @@ chestnut-common com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-common/pom.xml b/chestnut-common/pom.xml index 8c6d0a09..4b138e90 100644 --- a/chestnut-common/pom.xml +++ b/chestnut-common/pom.xml @@ -5,7 +5,7 @@ com.chestnut chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-modules/chestnut-comment/pom.xml b/chestnut-modules/chestnut-comment/pom.xml index 3ddcc6ad..bb3ac415 100644 --- a/chestnut-modules/chestnut-comment/pom.xml +++ b/chestnut-modules/chestnut-comment/pom.xml @@ -3,7 +3,7 @@ chestnut-modules com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-modules/chestnut-generator/pom.xml b/chestnut-modules/chestnut-generator/pom.xml index bb29e32d..62479284 100644 --- a/chestnut-modules/chestnut-generator/pom.xml +++ b/chestnut-modules/chestnut-generator/pom.xml @@ -5,7 +5,7 @@ chestnut-modules com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-modules/chestnut-generator/src/main/resources/vm/java/controller.java.vm b/chestnut-modules/chestnut-generator/src/main/resources/vm/java/controller.java.vm index 75374cbd..cb706781 100644 --- a/chestnut-modules/chestnut-generator/src/main/resources/vm/java/controller.java.vm +++ b/chestnut-modules/chestnut-generator/src/main/resources/vm/java/controller.java.vm @@ -1,8 +1,12 @@ package ${packageName}.controller; +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import java.util.List; import javax.servlet.http.HttpServletResponse; import org.springframework.security.access.prepost.PreAuthorize; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.chestnut.common.security.web.PageRequest; +import com.chestnut.common.utils.IdUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -12,104 +16,133 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.chestnut.common.annotation.Log; -import com.chestnut.common.core.controller.BaseController; -import com.chestnut.common.core.domain.AjaxResult; -import com.chestnut.common.enums.BusinessType; +import com.chestnut.common.security.web.BaseRestController; import ${packageName}.domain.${ClassName}; import ${packageName}.service.I${ClassName}Service; -import com.chestnut.common.utils.poi.ExcelUtil; -#if($table.crud || $table.sub) -import com.chestnut.common.core.page.TableDataInfo; -#elseif($table.tree) -#end +import com.chestnut.common.security.anno.Priv; +import com.chestnut.system.security.AdminUserType; +import lombok.RequiredArgsConstructor; +import com.chestnut.common.domain.R; /** * ${functionName}Controller - * + * * @author ${author} * @date ${datetime} */ +@RequiredArgsConstructor @RestController @RequestMapping("/${moduleName}/${businessName}") -public class ${ClassName}Controller extends BaseController -{ +public class ${ClassName}Controller extends BaseRestController { + @Autowired private I${ClassName}Service ${className}Service; /** * 查询${functionName}列表 */ - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") + @Priv @GetMapping("/list") #if($table.crud || $table.sub) - public TableDataInfo list(${ClassName} ${className}) + public R list(${ClassName} ${className}) { - startPage(); - List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); - return getDataTable(list); + PageRequest pr = this.getPageRequest(); + LambdaQueryChainWrapper wrapper = this.ccProductsService.lambdaQuery(); + #foreach($column in $columns) + #set($queryType=$column.queryType) + #set($javaField=$column.javaField) + #set($javaType=$column.javaType) + #set($columnName=$column.columnName) + #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + #if($column.query) + #if($column.queryType == "EQ") + if (${className}.get${AttrName}() != null) { + wrapper.eq(${ClassName}::get${AttrName},${className}.get${AttrName}()); + } + #elseif($queryType == "NE") + if (${className}.get${AttrName}() != null) { + wrapper.ne(${ClassName}::get${AttrName},${className}.get${AttrName}()); + } + #elseif($queryType == "GT") + if (${className}.get${AttrName}() != null) { + wrapper.gt(${ClassName}::get${AttrName},${className}.get${AttrName}()); + } + #elseif($queryType == "GTE") + if (${className}.get${AttrName}() != null) { + wrapper.gte(${ClassName}::get${AttrName},${className}.get${AttrName}()); + } + #elseif($queryType == "LT") + if (${className}.get${AttrName}() != null) { + wrapper.lt(${ClassName}::get${AttrName},${className}.get${AttrName}()); + } + #elseif($queryType == "LTE") + if (${className}.get${AttrName}() != null) { + wrapper.lte(${ClassName}::get${AttrName},${className}.get${AttrName}()); + } + #elseif($queryType == "LIKE") + if (${className}.get${AttrName}() != null) { + wrapper.like(${ClassName}::get${AttrName},${className}.get${AttrName}()); + } + #end + #end + #end + + Page page = wrapper + .page(new Page<>(pr.getPageNumber(), pr.getPageSize(), true)); + + return this.bindDataTable(page); } #elseif($table.tree) - public AjaxResult list(${ClassName} ${className}) + public R list(${ClassName} ${className}) { List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); - return success(list); + return R.ok(list); } #end - /** - * 导出${functionName}列表 - */ - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')") - @Log(title = "${functionName}", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, ${ClassName} ${className}) - { - List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); - ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class); - util.exportExcel(response, list, "${functionName}数据"); - } - /** * 获取${functionName}详细信息 */ @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')") @GetMapping(value = "/{${pkColumn.javaField}}") - public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) + public R getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) { - return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField})); + return R.ok(this.${className}Service.getById(id)); } /** * 新增${functionName} */ - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')") + @Priv @Log(title = "${functionName}", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody ${ClassName} ${className}) + public R add(@RequestBody ${ClassName} ${className}) { - return toAjax(${className}Service.insert${ClassName}(${className})); + this.${className}Service.save(${className}); + return R.ok(); } /** * 修改${functionName} */ - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')") + @Priv @Log(title = "${functionName}", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody ${ClassName} ${className}) + public R edit(@RequestBody ${ClassName} ${className}) { - return toAjax(${className}Service.update${ClassName}(${className})); + this.${className}Service.updateById(${className}); + return R.ok(); } /** * 删除${functionName} */ - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')") + @Priv @Log(title = "${functionName}", businessType = BusinessType.DELETE) @DeleteMapping("/{${pkColumn.javaField}s}") - public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) + public R remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) { - return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s)); + this.${className}Service.removeBatchByIds(List.of(${pkColumn.javaField}s)); + return R.ok(); } } diff --git a/chestnut-modules/chestnut-generator/src/main/resources/vm/java/domain.java.vm b/chestnut-modules/chestnut-generator/src/main/resources/vm/java/domain.java.vm index 423cae01..e303152f 100644 --- a/chestnut-modules/chestnut-generator/src/main/resources/vm/java/domain.java.vm +++ b/chestnut-modules/chestnut-generator/src/main/resources/vm/java/domain.java.vm @@ -3,14 +3,10 @@ package ${packageName}.domain; #foreach ($import in $importList) import ${import}; #end -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.chestnut.common.annotation.Excel; -#if($table.crud || $table.sub) -import com.chestnut.common.core.domain.BaseEntity; -#elseif($table.tree) -import com.chestnut.common.core.domain.TreeEntity; -#end +import java.io.Serializable; +import lombok.Getter; +import lombok.Setter; +import com.baomidou.mybatisplus.annotation.TableName; /** * ${functionName}对象 ${tableName} @@ -23,10 +19,15 @@ import com.chestnut.common.core.domain.TreeEntity; #elseif($table.tree) #set($Entity="TreeEntity") #end -public class ${ClassName} extends ${Entity} -{ +@Getter +@Setter +@TableName(value = ${ClassName}.TABLE_NAME) +public class ${ClassName} implements Serializable { + private static final long serialVersionUID = 1L; + public static final String TABLE_NAME = "${tableName}"; + #foreach ($column in $columns) #if(!$table.isSuperColumn($column.javaField)) /** $column.columnComment */ @@ -38,12 +39,8 @@ public class ${ClassName} extends ${Entity} #set($comment=$column.columnComment) #end #if($parentheseIndex != -1) - @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") #elseif($column.javaType == 'Date') @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") -#else - @Excel(name = "${comment}") #end #end private $column.javaType $column.javaField; @@ -55,24 +52,6 @@ public class ${ClassName} extends ${Entity} private List<${subClassName}> ${subclassName}List; #end -#foreach ($column in $columns) -#if(!$table.isSuperColumn($column.javaField)) -#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) -#set($AttrName=$column.javaField) -#else -#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) -#end - public void set${AttrName}($column.javaType $column.javaField) - { - this.$column.javaField = $column.javaField; - } - - public $column.javaType get${AttrName}() - { - return $column.javaField; - } -#end -#end #if($table.sub) public List<${subClassName}> get${subClassName}List() @@ -84,22 +63,5 @@ public class ${ClassName} extends ${Entity} { this.${subclassName}List = ${subclassName}List; } - #end - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) -#foreach ($column in $columns) -#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) -#set($AttrName=$column.javaField) -#else -#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) -#end - .append("${column.javaField}", get${AttrName}()) -#end -#if($table.sub) - .append("${subclassName}List", get${subClassName}List()) -#end - .toString(); - } } diff --git a/chestnut-modules/chestnut-generator/src/main/resources/vm/java/mapper.java.vm b/chestnut-modules/chestnut-generator/src/main/resources/vm/java/mapper.java.vm index 7e7d7c26..e1815299 100644 --- a/chestnut-modules/chestnut-generator/src/main/resources/vm/java/mapper.java.vm +++ b/chestnut-modules/chestnut-generator/src/main/resources/vm/java/mapper.java.vm @@ -1,10 +1,7 @@ package ${packageName}.mapper; -import java.util.List; import ${packageName}.domain.${ClassName}; -#if($table.sub) -import ${packageName}.domain.${subClassName}; -#end +import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** * ${functionName}Mapper接口 @@ -12,80 +9,5 @@ import ${packageName}.domain.${subClassName}; * @author ${author} * @date ${datetime} */ -public interface ${ClassName}Mapper -{ - /** - * 查询${functionName} - * - * @param ${pkColumn.javaField} ${functionName}主键 - * @return ${functionName} - */ - public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); - - /** - * 查询${functionName}列表 - * - * @param ${className} ${functionName} - * @return ${functionName}集合 - */ - public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); - - /** - * 新增${functionName} - * - * @param ${className} ${functionName} - * @return 结果 - */ - public int insert${ClassName}(${ClassName} ${className}); - - /** - * 修改${functionName} - * - * @param ${className} ${functionName} - * @return 结果 - */ - public int update${ClassName}(${ClassName} ${className}); - - /** - * 删除${functionName} - * - * @param ${pkColumn.javaField} ${functionName}主键 - * @return 结果 - */ - public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); - - /** - * 批量删除${functionName} - * - * @param ${pkColumn.javaField}s 需要删除的数据主键集合 - * @return 结果 - */ - public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); -#if($table.sub) - - /** - * 批量删除${subTable.functionName} - * - * @param ${pkColumn.javaField}s 需要删除的数据主键集合 - * @return 结果 - */ - public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); - - /** - * 批量新增${subTable.functionName} - * - * @param ${subclassName}List ${subTable.functionName}列表 - * @return 结果 - */ - public int batch${subClassName}(List<${subClassName}> ${subclassName}List); - - - /** - * 通过${functionName}主键删除${subTable.functionName}信息 - * - * @param ${pkColumn.javaField} ${functionName}ID - * @return 结果 - */ - public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField}); -#end +public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> { } diff --git a/chestnut-modules/chestnut-generator/src/main/resources/vm/java/service.java.vm b/chestnut-modules/chestnut-generator/src/main/resources/vm/java/service.java.vm index 264882b2..b5b3be0b 100644 --- a/chestnut-modules/chestnut-generator/src/main/resources/vm/java/service.java.vm +++ b/chestnut-modules/chestnut-generator/src/main/resources/vm/java/service.java.vm @@ -1,6 +1,6 @@ package ${packageName}.service; -import java.util.List; +import com.baomidou.mybatisplus.extension.service.IService; import ${packageName}.domain.${ClassName}; /** @@ -9,53 +9,5 @@ import ${packageName}.domain.${ClassName}; * @author ${author} * @date ${datetime} */ -public interface I${ClassName}Service -{ - /** - * 查询${functionName} - * - * @param ${pkColumn.javaField} ${functionName}主键 - * @return ${functionName} - */ - public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); - - /** - * 查询${functionName}列表 - * - * @param ${className} ${functionName} - * @return ${functionName}集合 - */ - public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); - - /** - * 新增${functionName} - * - * @param ${className} ${functionName} - * @return 结果 - */ - public int insert${ClassName}(${ClassName} ${className}); - - /** - * 修改${functionName} - * - * @param ${className} ${functionName} - * @return 结果 - */ - public int update${ClassName}(${ClassName} ${className}); - - /** - * 批量删除${functionName} - * - * @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合 - * @return 结果 - */ - public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); - - /** - * 删除${functionName}信息 - * - * @param ${pkColumn.javaField} ${functionName}主键 - * @return 结果 - */ - public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); +public interface I${ClassName}Service extends IService<${ClassName}> { } diff --git a/chestnut-modules/chestnut-generator/src/main/resources/vm/java/serviceImpl.java.vm b/chestnut-modules/chestnut-generator/src/main/resources/vm/java/serviceImpl.java.vm index caff3be0..523428a7 100644 --- a/chestnut-modules/chestnut-generator/src/main/resources/vm/java/serviceImpl.java.vm +++ b/chestnut-modules/chestnut-generator/src/main/resources/vm/java/serviceImpl.java.vm @@ -1,6 +1,6 @@ package ${packageName}.service.impl; -import java.util.List; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; #foreach ($column in $columns) #if($column.javaField == 'createTime' || $column.javaField == 'updateTime') import com.chestnut.common.utils.DateUtils; @@ -26,144 +26,9 @@ import ${packageName}.service.I${ClassName}Service; * @date ${datetime} */ @Service -public class ${ClassName}ServiceImpl implements I${ClassName}Service -{ +public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service { + @Autowired private ${ClassName}Mapper ${className}Mapper; - /** - * 查询${functionName} - * - * @param ${pkColumn.javaField} ${functionName}主键 - * @return ${functionName} - */ - @Override - public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) - { - return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}); - } - - /** - * 查询${functionName}列表 - * - * @param ${className} ${functionName} - * @return ${functionName} - */ - @Override - public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) - { - return ${className}Mapper.select${ClassName}List(${className}); - } - - /** - * 新增${functionName} - * - * @param ${className} ${functionName} - * @return 结果 - */ -#if($table.sub) - @Transactional -#end - @Override - public int insert${ClassName}(${ClassName} ${className}) - { -#foreach ($column in $columns) -#if($column.javaField == 'createTime') - ${className}.setCreateTime(DateUtils.getNowDate()); -#end -#end -#if($table.sub) - int rows = ${className}Mapper.insert${ClassName}(${className}); - insert${subClassName}(${className}); - return rows; -#else - return ${className}Mapper.insert${ClassName}(${className}); -#end - } - - /** - * 修改${functionName} - * - * @param ${className} ${functionName} - * @return 结果 - */ -#if($table.sub) - @Transactional -#end - @Override - public int update${ClassName}(${ClassName} ${className}) - { -#foreach ($column in $columns) -#if($column.javaField == 'updateTime') - ${className}.setUpdateTime(DateUtils.getNowDate()); -#end -#end -#if($table.sub) - ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}()); - insert${subClassName}(${className}); -#end - return ${className}Mapper.update${ClassName}(${className}); - } - - /** - * 批量删除${functionName} - * - * @param ${pkColumn.javaField}s 需要删除的${functionName}主键 - * @return 结果 - */ -#if($table.sub) - @Transactional -#end - @Override - public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s) - { -#if($table.sub) - ${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s); -#end - return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s); - } - - /** - * 删除${functionName}信息 - * - * @param ${pkColumn.javaField} ${functionName}主键 - * @return 结果 - */ -#if($table.sub) - @Transactional -#end - @Override - public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) - { -#if($table.sub) - ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField}); -#end - return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}); - } -#if($table.sub) - - /** - * 新增${subTable.functionName}信息 - * - * @param ${className} ${functionName}对象 - */ - public void insert${subClassName}(${ClassName} ${className}) - { - List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List(); - ${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}(); - if (StringUtils.isNotNull(${subclassName}List)) - { - List<${subClassName}> list = new ArrayList<${subClassName}>(); - for (${subClassName} ${subclassName} : ${subclassName}List) - { - ${subclassName}.set${subTableFkClassName}(${pkColumn.javaField}); - list.add(${subclassName}); - } - if (list.size() > 0) - { - ${className}Mapper.batch${subClassName}(list); - } - } - } -#end } diff --git a/chestnut-modules/chestnut-generator/src/main/resources/vm/sql/sql.vm b/chestnut-modules/chestnut-generator/src/main/resources/vm/sql/sql.vm index 05755835..16bc2d51 100644 --- a/chestnut-modules/chestnut-generator/src/main/resources/vm/sql/sql.vm +++ b/chestnut-modules/chestnut-generator/src/main/resources/vm/sql/sql.vm @@ -1,6 +1,6 @@ -- 菜单 SQL insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) -values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单'); +values('${functionName}', '0', '1', '${businessName}', '${moduleName}/${businessName}/index', 'N', 'Y', 'C', 'Y', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单'); -- 按钮父菜单ID SELECT @parentId := LAST_INSERT_ID(); diff --git a/chestnut-modules/chestnut-generator/src/main/resources/vm/vue/index.vue.vm b/chestnut-modules/chestnut-generator/src/main/resources/vm/vue/index.vue.vm index e9a1fae1..acb92357 100644 --- a/chestnut-modules/chestnut-generator/src/main/resources/vm/vue/index.vue.vm +++ b/chestnut-modules/chestnut-generator/src/main/resources/vm/vue/index.vue.vm @@ -442,8 +442,8 @@ export default { #end #end list${BusinessName}(this.queryParams).then(response => { - this.${businessName}List = response.rows; - this.total = response.total; + this.${businessName}List = response.data.rows; + this.total = response.data.total; this.loading = false; }); }, diff --git a/chestnut-modules/chestnut-member/pom.xml b/chestnut-modules/chestnut-member/pom.xml index b32b31ef..d276ada6 100644 --- a/chestnut-modules/chestnut-member/pom.xml +++ b/chestnut-modules/chestnut-member/pom.xml @@ -3,7 +3,7 @@ chestnut-modules com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-modules/chestnut-meta/pom.xml b/chestnut-modules/chestnut-meta/pom.xml index 250713ce..6c47137b 100644 --- a/chestnut-modules/chestnut-meta/pom.xml +++ b/chestnut-modules/chestnut-meta/pom.xml @@ -6,7 +6,7 @@ chestnut-modules com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaControlType_Date.java b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaControlType_Date.java index 6a185c50..75b0ab38 100644 --- a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaControlType_Date.java +++ b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaControlType_Date.java @@ -15,9 +15,14 @@ */ package com.chestnut.xmodel.core.impl; +import com.chestnut.common.utils.DateUtils; import com.chestnut.xmodel.core.IMetaControlType; +import com.chestnut.xmodel.dto.XModelFieldDataDTO; import org.springframework.stereotype.Component; +import java.time.LocalDateTime; +import java.util.Objects; + /** * 元数据模型字段类型:日期选择框 * @@ -38,4 +43,12 @@ public class MetaControlType_Date implements IMetaControlType { public String getName() { return "{META.CONTROL_TYPE." + TYPE + "}"; } + + @Override + public void parseFieldValue(XModelFieldDataDTO fieldData) { + Object value = fieldData.getValue(); + if (Objects.nonNull(value) && value instanceof LocalDateTime ldt) { + fieldData.setValue(ldt.format(DateUtils.FORMAT_YYYY_MM_DD)); + } + } } diff --git a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaControlType_Time.java b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaControlType_Time.java index 6be0bccc..2ece92c2 100644 --- a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaControlType_Time.java +++ b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaControlType_Time.java @@ -16,8 +16,13 @@ package com.chestnut.xmodel.core.impl; import com.chestnut.xmodel.core.IMetaControlType; +import com.chestnut.xmodel.dto.XModelFieldDataDTO; import org.springframework.stereotype.Component; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Objects; + /** * 元数据模型字段类型:时间选择框 * @@ -29,6 +34,8 @@ public class MetaControlType_Time implements IMetaControlType { public static final String TYPE = "time"; + public static DateTimeFormatter HH_MM_SS = DateTimeFormatter.ofPattern("HH:mm:ss"); + @Override public String getType() { return TYPE; @@ -38,4 +45,12 @@ public class MetaControlType_Time implements IMetaControlType { public String getName() { return "{META.CONTROL_TYPE." + TYPE + "}"; } + + @Override + public void parseFieldValue(XModelFieldDataDTO fieldData) { + Object value = fieldData.getValue(); + if (Objects.nonNull(value) && value instanceof LocalDateTime ldt) { + fieldData.setValue(ldt.format(HH_MM_SS)); + } + } } diff --git a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Date.java b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Date.java index 48b2ece6..230deb68 100644 --- a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Date.java +++ b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Date.java @@ -15,6 +15,7 @@ */ package com.chestnut.xmodel.core.impl; +import com.chestnut.common.utils.ObjectUtils; import com.chestnut.xmodel.core.IMetaFieldValidation; import org.springframework.stereotype.Component; @@ -42,7 +43,7 @@ public class MetaFieldValidation_Date implements IMetaFieldValidation { } public boolean validate(Object fieldValue, Map args) { - if (fieldValue == null) { + if (ObjectUtils.isNullOrEmptyStr(fieldValue)) { return true; } try { diff --git a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_DateTime.java b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_DateTime.java index ddf1cbdb..6efd4973 100644 --- a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_DateTime.java +++ b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_DateTime.java @@ -15,6 +15,7 @@ */ package com.chestnut.xmodel.core.impl; +import com.chestnut.common.utils.ObjectUtils; import com.chestnut.xmodel.core.IMetaFieldValidation; import org.springframework.stereotype.Component; @@ -43,7 +44,7 @@ public class MetaFieldValidation_DateTime implements IMetaFieldValidation { @Override public boolean validate(Object fieldValue, Map args) { - if (fieldValue == null) { + if (ObjectUtils.isNullOrEmptyStr(fieldValue)) { return true; } try { diff --git a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Email.java b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Email.java index 3d4d89ae..42ee3eef 100644 --- a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Email.java +++ b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Email.java @@ -15,6 +15,7 @@ */ package com.chestnut.xmodel.core.impl; +import com.chestnut.common.utils.ObjectUtils; import com.chestnut.xmodel.core.IMetaFieldValidation; import org.springframework.stereotype.Component; @@ -41,7 +42,7 @@ public class MetaFieldValidation_Email implements IMetaFieldValidation { @Override public boolean validate(Object fieldValue, Map args) { - if (fieldValue == null) { + if (ObjectUtils.isNullOrEmptyStr(fieldValue)) { return true; } return Pattern.matches(EmailPattern, fieldValue.toString()); diff --git a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Int.java b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Int.java index be6b8f13..a2705713 100644 --- a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Int.java +++ b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Int.java @@ -16,11 +16,11 @@ package com.chestnut.xmodel.core.impl; import com.chestnut.common.utils.NumberUtils; +import com.chestnut.common.utils.ObjectUtils; import com.chestnut.xmodel.core.IMetaFieldValidation; import org.springframework.stereotype.Component; import java.util.Map; -import java.util.Objects; /** * 整数校验 @@ -40,6 +40,6 @@ public class MetaFieldValidation_Int implements IMetaFieldValidation { @Override public boolean validate(Object fieldValue, Map args) { - return Objects.isNull(fieldValue) || NumberUtils.isDigits(fieldValue.toString()); + return ObjectUtils.isNullOrEmptyStr(fieldValue) || NumberUtils.isDigits(fieldValue.toString()); } } diff --git a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_NotEmpty.java b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_NotEmpty.java index 6afd87d1..3c65b718 100644 --- a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_NotEmpty.java +++ b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_NotEmpty.java @@ -15,11 +15,11 @@ */ package com.chestnut.xmodel.core.impl; +import com.chestnut.common.utils.ObjectUtils; import com.chestnut.xmodel.core.IMetaFieldValidation; import org.springframework.stereotype.Component; import java.util.Map; -import java.util.Objects; /** * 非空判断 @@ -39,6 +39,6 @@ public class MetaFieldValidation_NotEmpty implements IMetaFieldValidation { @Override public boolean validate(Object fieldValue, Map args) { - return Objects.nonNull(fieldValue) && !fieldValue.toString().isBlank(); + return !ObjectUtils.isNullOrEmptyStr(fieldValue); } } diff --git a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Number.java b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Number.java index 6e7a9889..02f36c3f 100644 --- a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Number.java +++ b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Number.java @@ -16,11 +16,11 @@ package com.chestnut.xmodel.core.impl; import com.chestnut.common.utils.NumberUtils; +import com.chestnut.common.utils.ObjectUtils; import com.chestnut.xmodel.core.IMetaFieldValidation; import org.springframework.stereotype.Component; import java.util.Map; -import java.util.Objects; /** * 数字校验 @@ -40,6 +40,6 @@ public class MetaFieldValidation_Number implements IMetaFieldValidation { @Override public boolean validate(Object fieldValue, Map args) { - return Objects.isNull(fieldValue) || NumberUtils.isCreatable(fieldValue.toString()); + return ObjectUtils.isNullOrEmptyStr(fieldValue) || NumberUtils.isCreatable(fieldValue.toString()); } } diff --git a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_PhoneNumber.java b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_PhoneNumber.java index df3b90a2..8f5f6d25 100644 --- a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_PhoneNumber.java +++ b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_PhoneNumber.java @@ -15,6 +15,7 @@ */ package com.chestnut.xmodel.core.impl; +import com.chestnut.common.utils.ObjectUtils; import com.chestnut.xmodel.core.IMetaFieldValidation; import org.springframework.stereotype.Component; @@ -41,7 +42,7 @@ public class MetaFieldValidation_PhoneNumber implements IMetaFieldValidation { @Override public boolean validate(Object fieldValue, Map args) { - if (fieldValue == null) { + if (ObjectUtils.isNullOrEmptyStr(fieldValue)) { return true; } return Pattern.matches(PhoneNumberPattern, fieldValue.toString()); diff --git a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Regex.java b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Regex.java index c28c71d5..98b6e6e3 100644 --- a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Regex.java +++ b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Regex.java @@ -42,8 +42,11 @@ public class MetaFieldValidation_Regex implements IMetaFieldValidation { @Override public boolean validate(Object fieldValue, Map args) { + if (ObjectUtils.isNullOrEmptyStr(fieldValue)) { + return true; + } String regex = MapUtils.getString(args, "regex"); - if (ObjectUtils.isAnyNull(fieldValue) || StringUtils.isEmpty(regex)) { + if (StringUtils.isEmpty(regex)) { return true; } return Pattern.matches(regex, fieldValue.toString()); diff --git a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Time.java b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Time.java index 4dc6fa58..2b6ec422 100644 --- a/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Time.java +++ b/chestnut-modules/chestnut-meta/src/main/java/com/chestnut/xmodel/core/impl/MetaFieldValidation_Time.java @@ -15,6 +15,7 @@ */ package com.chestnut.xmodel.core.impl; +import com.chestnut.common.utils.ObjectUtils; import com.chestnut.xmodel.core.IMetaFieldValidation; import org.springframework.stereotype.Component; @@ -43,7 +44,7 @@ public class MetaFieldValidation_Time implements IMetaFieldValidation { @Override public boolean validate(Object fieldValue, Map args) { - if (fieldValue == null) { + if (ObjectUtils.isNullOrEmptyStr(fieldValue)) { return true; } try { diff --git a/chestnut-modules/chestnut-monitor/pom.xml b/chestnut-modules/chestnut-monitor/pom.xml index cb65fc56..ec3452a7 100644 --- a/chestnut-modules/chestnut-monitor/pom.xml +++ b/chestnut-modules/chestnut-monitor/pom.xml @@ -6,7 +6,7 @@ com.chestnut chestnut-modules - 1.4.2 + 1.4.3 chestnut-monitor diff --git a/chestnut-modules/chestnut-search/pom.xml b/chestnut-modules/chestnut-search/pom.xml index d62189a1..028e7153 100644 --- a/chestnut-modules/chestnut-search/pom.xml +++ b/chestnut-modules/chestnut-search/pom.xml @@ -3,7 +3,7 @@ chestnut-modules com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-modules/chestnut-stat/pom.xml b/chestnut-modules/chestnut-stat/pom.xml index 25b0cd44..8256d9f9 100644 --- a/chestnut-modules/chestnut-stat/pom.xml +++ b/chestnut-modules/chestnut-stat/pom.xml @@ -6,7 +6,7 @@ chestnut-modules com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-modules/chestnut-system/pom.xml b/chestnut-modules/chestnut-system/pom.xml index e68e261f..73c2e017 100644 --- a/chestnut-modules/chestnut-system/pom.xml +++ b/chestnut-modules/chestnut-system/pom.xml @@ -5,7 +5,7 @@ chestnut-modules com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/controller/SysScheduledTaskController.java b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/controller/SysScheduledTaskController.java index 73b04cee..8461ca73 100644 --- a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/controller/SysScheduledTaskController.java +++ b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/controller/SysScheduledTaskController.java @@ -25,6 +25,7 @@ import com.chestnut.common.security.web.BaseRestController; import com.chestnut.common.security.web.PageRequest; import com.chestnut.common.utils.Assert; import com.chestnut.common.utils.IdUtils; +import com.chestnut.common.utils.JacksonUtils; import com.chestnut.common.utils.StringUtils; import com.chestnut.system.domain.SysScheduledTask; import com.chestnut.system.domain.SysScheduledTaskLog; @@ -33,10 +34,12 @@ import com.chestnut.system.domain.vo.ScheduledTaskVO; import com.chestnut.system.mapper.SysScheduledTaskLogMapper; import com.chestnut.system.schedule.IScheduledHandler; import com.chestnut.system.schedule.ScheduledTask; +import com.chestnut.system.schedule.ScheduledTaskTriggerType; import com.chestnut.system.security.AdminUserType; import com.chestnut.system.security.StpAdminUtil; import com.chestnut.system.service.ISysScheduledTaskService; import com.chestnut.system.validator.LongId; +import com.fasterxml.jackson.databind.JsonNode; import jakarta.validation.constraints.NotEmpty; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; @@ -96,8 +99,7 @@ public class SysScheduledTaskController extends BaseRestController { public R getInfo(@PathVariable Long taskId) { SysScheduledTask task = this.taskService.getById(taskId); Assert.notNull(task, () -> CommonErrorCode.DATA_NOT_FOUND_BY_ID.exception("taskId", taskId)); - - + task.setData(JacksonUtils.parse(task.getTriggerArgs())); return R.ok(task); } diff --git a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/domain/SysScheduledTask.java b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/domain/SysScheduledTask.java index 8a37f4a5..a0c907ec 100644 --- a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/domain/SysScheduledTask.java +++ b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/domain/SysScheduledTask.java @@ -16,13 +16,19 @@ package com.chestnut.system.domain; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.chestnut.common.db.domain.BaseEntity; - +import com.chestnut.common.utils.JacksonUtils; +import com.chestnut.system.exception.SysErrorCode; +import com.chestnut.system.schedule.ScheduledTaskTriggerType; +import com.fasterxml.jackson.databind.JsonNode; import lombok.Getter; import lombok.Setter; +import java.util.Objects; + /** * 定时任务配置表 sys_scheduled_task */ @@ -57,4 +63,22 @@ public class SysScheduledTask extends BaseEntity { * 触发器配置(JSON格式) */ private String triggerArgs; + + @TableField(exist = false) + private Object data; + + public void writeTriggerArgsFromJson(JsonNode json) { + if (Objects.isNull(json)) { + return; + } + if (ScheduledTaskTriggerType.isCron(this.getTaskTrigger())) { + ScheduledTaskTriggerType.CronTriggerArgs args = ScheduledTaskTriggerType.CronTriggerArgs.fromJson(json); + this.setTriggerArgs(JacksonUtils.to(args)); + } else if (ScheduledTaskTriggerType.isPeriodic(this.getTaskTrigger())) { + ScheduledTaskTriggerType.PeriodicTriggerArgs args = ScheduledTaskTriggerType.PeriodicTriggerArgs.fromJson(json); + this.setTriggerArgs(JacksonUtils.to(args)); + } else { + throw SysErrorCode.SCHEDULED_TASK_TRIGGER_ERR.exception(this.getTaskTrigger()); + } + } } diff --git a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/domain/dto/ScheduledTaskDTO.java b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/domain/dto/ScheduledTaskDTO.java index bbd49d4a..87added5 100644 --- a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/domain/dto/ScheduledTaskDTO.java +++ b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/domain/dto/ScheduledTaskDTO.java @@ -17,6 +17,7 @@ package com.chestnut.system.domain.dto; import com.chestnut.common.security.domain.BaseDTO; +import com.fasterxml.jackson.databind.JsonNode; import lombok.Getter; import lombok.Setter; @@ -29,14 +30,8 @@ public class ScheduledTaskDTO extends BaseDTO { private String taskType; private String taskTrigger; - - private String cron; - - private String fixedRate; - - private Long seconds; - - private Long delaySeconds; + + private JsonNode data; private String status; diff --git a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/exception/SysErrorCode.java b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/exception/SysErrorCode.java index 36267cdc..d88f18fc 100644 --- a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/exception/SysErrorCode.java +++ b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/exception/SysErrorCode.java @@ -202,7 +202,12 @@ public enum SysErrorCode implements ErrorCode { /** * 任务正在运行中 */ - SCHEDULED_TASK_RUNNING; + SCHEDULED_TASK_RUNNING, + + /** + * 不支持的定时任务触发器类型:{0} + */ + SCHEDULED_TASK_UNSUPPORTED_TRIGGER; @Override public String value() { diff --git a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/schedule/ScheduledTask.java b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/schedule/ScheduledTask.java index 772b93aa..6ae5dc4c 100644 --- a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/schedule/ScheduledTask.java +++ b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/schedule/ScheduledTask.java @@ -22,8 +22,7 @@ import com.chestnut.system.service.ISysScheduledTaskService; import lombok.extern.slf4j.Slf4j; import org.springframework.context.i18n.LocaleContextHolder; -import java.time.Duration; -import java.time.LocalDateTime; +import java.time.*; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ScheduledFuture; @@ -92,7 +91,7 @@ public abstract class ScheduledTask implements Runnable { private ScheduledFuture future; - private ISysScheduledTaskService taskService; + private final ISysScheduledTaskService taskService; public ScheduledTask(ISysScheduledTaskService taskService) { this.taskService = taskService; @@ -131,7 +130,7 @@ public abstract class ScheduledTask implements Runnable { * 提交到线程池时执行 */ public void ready() { - log.debug("[{}]ScheduledTask ready: {}", Thread.currentThread().getName(), this.getTaskId()); + log.debug("[{}]ScheduledTask ready: {}[{}]", Thread.currentThread().getName(), this.getType(), this.getTaskId()); this.status = ScheduledTaskStatus.READY; this.readyTime = LocalDateTime.now(); } @@ -140,7 +139,7 @@ public abstract class ScheduledTask implements Runnable { * 任务开始执行 */ void start() { - log.debug("[{}]ScheduledTask start: {}", Thread.currentThread().getName(), this.getTaskId()); + log.debug("[{}]ScheduledTask start: {}[{}]", Thread.currentThread().getName(), this.getType(), this.getTaskId()); this.status = ScheduledTaskStatus.RUNNING; this.startTime = LocalDateTime.now(); } @@ -152,7 +151,8 @@ public abstract class ScheduledTask implements Runnable { if (this.getStatus() == ScheduledTaskStatus.INTERRUPTED) { return; } - log.debug("[{}]ScheduledTask completed: {}", Thread.currentThread().getName(), this.getTaskId()); + long cost = LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli() - this.getStartTime().toInstant(ZoneOffset.UTC).toEpochMilli(); + log.debug("[{}]ScheduledTask completed: {}[{}], cost: {}ms", Thread.currentThread().getName(), this.getType(), this.getTaskId(), cost); this.setStatus(ScheduledTaskStatus.SUCCESS); this.setEndTime(LocalDateTime.now()); this.setPercent(100); @@ -162,7 +162,7 @@ public abstract class ScheduledTask implements Runnable { * 执行中断,设置中断标识 */ public void interrupt() { - log.debug("[{}]ScheduledTask interrupted: {}", Thread.currentThread().getName(), this.getTaskId()); + log.debug("[{}]ScheduledTask interrupted: {}[{}]", Thread.currentThread().getName(), this.getType(), this.getTaskId()); if (this.interrupt) { return; } diff --git a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/schedule/ScheduledTaskTriggerType.java b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/schedule/ScheduledTaskTriggerType.java index bdf2544e..060f53c0 100644 --- a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/schedule/ScheduledTaskTriggerType.java +++ b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/schedule/ScheduledTaskTriggerType.java @@ -15,8 +15,11 @@ */ package com.chestnut.system.schedule; +import com.chestnut.system.fixed.dict.YesOrNo; +import com.fasterxml.jackson.databind.JsonNode; import lombok.Getter; import lombok.Setter; +import org.springframework.scheduling.support.CronExpression; public enum ScheduledTaskTriggerType { @@ -35,6 +38,14 @@ public enum ScheduledTaskTriggerType { public static class CronTriggerArgs { private String cron; + + public static CronTriggerArgs fromJson(JsonNode json) { + CronTriggerArgs args = new CronTriggerArgs(); + // 尝试解析cron表达式 + CronExpression expr = CronExpression.parse(json.required("cron").asText()); + args.setCron(expr.toString()); + return args; + } } @Getter @@ -44,7 +55,7 @@ public enum ScheduledTaskTriggerType { /** * 是否固定间隔执行 */ - private Boolean fixedRate = false; + private String fixedRate = YesOrNo.NO; /** * 执行周期 fixedRate = true: 两次任务开始时间之间间隔指定时长 fixedRate = false: @@ -56,5 +67,13 @@ public enum ScheduledTaskTriggerType { * 延时delay秒后开始执行 */ private Long delaySeconds; + + public static PeriodicTriggerArgs fromJson(JsonNode json) { + PeriodicTriggerArgs args = new PeriodicTriggerArgs(); + args.setFixedRate(json.required("fixedRate").asText()); + args.setSeconds(json.required("seconds").asLong()); + args.setDelaySeconds(json.required("delaySeconds").asLong()); + return args; + } } } \ No newline at end of file diff --git a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/service/ISysPermissionService.java b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/service/ISysPermissionService.java index d4152357..8037e290 100644 --- a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/service/ISysPermissionService.java +++ b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/service/ISysPermissionService.java @@ -61,6 +61,16 @@ public interface ISysPermissionService extends IService { */ void saveMenuPermissions(SysPermissionDTO dto); + /** + * 获取指定类型权限列表 + * + * @param ownerType + * @param owner + * @param permissionType + * @return + */ + Set getPermissionKeys(String ownerType, String owner, String permissionType); + /** * 获取用户权限列表 * diff --git a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/service/ISysScheduledTaskService.java b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/service/ISysScheduledTaskService.java index 5be71066..06e2930d 100644 --- a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/service/ISysScheduledTaskService.java +++ b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/service/ISysScheduledTaskService.java @@ -37,33 +37,33 @@ public interface ISysScheduledTaskService extends IService { * * @param task */ - public void insertTask(ScheduledTaskDTO task); + void insertTask(ScheduledTaskDTO task); /** * 编辑定时任务信息 * * @param task */ - public void updateTask(ScheduledTaskDTO task); + void updateTask(ScheduledTaskDTO task); /** * 删除定时任务 * * @param taskIds */ - public void deleteTasks(List taskIds); + void deleteTasks(List taskIds); /** * 立即执行一次 */ - public void execOnceImmediately(Long taskId); + void execOnceImmediately(Long taskId); /** * 添加任务执行日志 * * @param scheduledTask */ - public void addTaskLog(ScheduledTask scheduledTask); + void addTaskLog(ScheduledTask scheduledTask); /** * 启用定时任务 diff --git a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/service/impl/SysPermissionServiceImpl.java b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/service/impl/SysPermissionServiceImpl.java index 1e588f9a..a31411b7 100644 --- a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/service/impl/SysPermissionServiceImpl.java +++ b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/service/impl/SysPermissionServiceImpl.java @@ -75,6 +75,24 @@ public class SysPermissionServiceImpl extends ServiceImpl getPermissionKeys(String ownerType, String owner, String permissionType) { + Set permissionKeys = new HashSet<>(); + // 权限 + SysPermission userPermission = this.getPermission(ownerType, owner); + if (Objects.nonNull(userPermission)) { + this.permissionTypes.values().forEach(pt -> { + if (StringUtils.isEmpty(permissionType) || pt.getId().equals(permissionType)) { + String json = userPermission.getPermissions().get(pt.getId()); + if (StringUtils.isNotEmpty(json)) { + permissionKeys.addAll(pt.deserialize(json)); + } + } + }); + } + return permissionKeys; + } + @Override public Set getUserPermissions(Long userId, @Nullable String permissionType) { Set permissions = new HashSet<>(); @@ -82,32 +100,13 @@ public class SysPermissionServiceImpl extends ServiceImpl { - if (StringUtils.isEmpty(permissionType) || pt.getId().equals(permissionType)) { - String json = userPermission.getPermissions().get(pt.getId()); - if (StringUtils.isNotEmpty(json)) { - permissions.addAll(pt.deserialize(json)); - } - } - }); - } + Set permissionKeys = getPermissionKeys(PermissionOwnerType.User.name(), userId.toString(), permissionType); + permissions.addAll(permissionKeys); // 角色权限 List roles = this.roleMapper.selectRolesByUserId(userId); roles.forEach(r -> { - SysPermission permission = this.getPermission(PermissionOwnerType.Role.name(), - r.getRoleId().toString()); - if (permission != null) { - this.permissionTypes.values().forEach(pt -> { - if (StringUtils.isEmpty(permissionType) || pt.getId().equals(permissionType)) { - String json = permission.getPermissions().get(pt.getId()); - if (StringUtils.isNotEmpty(json)) { - permissions.addAll(pt.deserialize(json)); - } - } - }); - } + Set keys = getPermissionKeys(PermissionOwnerType.Role.name(), r.getRoleId().toString(), permissionType); + permissions.addAll(keys); }); } return permissions; diff --git a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/service/impl/SysScheduledTaskServiceImpl.java b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/service/impl/SysScheduledTaskServiceImpl.java index 00a38f66..d2db5a6d 100644 --- a/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/service/impl/SysScheduledTaskServiceImpl.java +++ b/chestnut-modules/chestnut-system/src/main/java/com/chestnut/system/service/impl/SysScheduledTaskServiceImpl.java @@ -83,7 +83,7 @@ public class SysScheduledTaskServiceImpl extends ServiceImpl 0) { periodicTrigger.setInitialDelay(Duration.ofSeconds(args.getDelaySeconds())); } @@ -161,17 +161,7 @@ public class SysScheduledTaskServiceImpl extends ServiceImpl chestnut-modules com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-modules/chestnut-word/pom.xml b/chestnut-modules/chestnut-word/pom.xml index c38c22d4..afdb63b9 100644 --- a/chestnut-modules/chestnut-word/pom.xml +++ b/chestnut-modules/chestnut-word/pom.xml @@ -6,7 +6,7 @@ chestnut-modules com.chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-modules/pom.xml b/chestnut-modules/pom.xml index cb33d41b..82ea2e82 100644 --- a/chestnut-modules/pom.xml +++ b/chestnut-modules/pom.xml @@ -5,7 +5,7 @@ com.chestnut chestnut - 1.4.2 + 1.4.3 4.0.0 diff --git a/chestnut-ui/package.json b/chestnut-ui/package.json index 8834d08c..78cbec9f 100644 --- a/chestnut-ui/package.json +++ b/chestnut-ui/package.json @@ -1,6 +1,6 @@ { "name": "ChestnutCMS", - "version": "1.4.2", + "version": "1.4.3", "description": "ChestnutCMS[栗子内容管理系统]", "author": "", "license": "Apache-2.0", diff --git a/chestnut-ui/src/api/contentcore/article.js b/chestnut-ui/src/api/contentcore/article.js new file mode 100644 index 00000000..f19f334d --- /dev/null +++ b/chestnut-ui/src/api/contentcore/article.js @@ -0,0 +1,9 @@ +import request from '@/utils/request' + +export function getUEditorCSS(params) { + return request({ + url: '/cms/article/ueditor_css', + method: 'get', + params: params + }) +} \ No newline at end of file diff --git a/chestnut-ui/src/api/contentcore/file.js b/chestnut-ui/src/api/contentcore/file.js index 63a3237d..09895ad6 100644 --- a/chestnut-ui/src/api/contentcore/file.js +++ b/chestnut-ui/src/api/contentcore/file.js @@ -9,10 +9,11 @@ export function getDirectoryTreeData() { } // 获取指定目录下文件 -export function getFileList(filePath, fileName) { +export function getFileList(params) { return request({ - url: '/cms/file/list?filePath=' + filePath + '&fileName=' + fileName, - method: 'get' + url: '/cms/file/list', + method: 'get', + params: params }) } diff --git a/chestnut-ui/src/api/contentcore/publishpipe.js b/chestnut-ui/src/api/contentcore/publishpipe.js index f1dc2101..69d09b80 100644 --- a/chestnut-ui/src/api/contentcore/publishpipe.js +++ b/chestnut-ui/src/api/contentcore/publishpipe.js @@ -52,3 +52,12 @@ export function delPublishPipe(publishPipeIds) { data: publishPipeIds }) } + + +export function getPublishPipePropValue(params) { + return request({ + url: '/cms/publishpipe/prop_value', + method: 'get', + params: params + }) +} diff --git a/chestnut-ui/src/i18n/lang/en.js b/chestnut-ui/src/i18n/lang/en.js index 534cef08..9c984416 100644 --- a/chestnut-ui/src/i18n/lang/en.js +++ b/chestnut-ui/src/i18n/lang/en.js @@ -896,6 +896,8 @@ export default { SitemapUrlLimit: "Sitemap Url Limit", GenSitemap: "Generate Sitemap", SitemapProgressTitle: "Generate sitemap task", + Domain: "URL", + UEditorCss: "UEditor CSS", Tab: { Basic: "Basic Information", Extend: "Extend Config", @@ -1036,6 +1038,9 @@ export default { CopyContentTip: "Depe Copy: independently of the source.", MappingContent: "Mapping", MappingContentTip: "Mapping: only basic content, the extend content is from source.", + SortUp: "MoveUp", + SortDown: "MoveDown", + NoSitePermissions: "No site permissions.", RuleTips: { Name: "Cannot be empty", Alias: "Cannot be empty and only [A-Za-z0-9_]+", @@ -1046,6 +1051,8 @@ export default { PublishProgressTitle: "Publish catalog task", DeleteProgressTitle: "Delete catalog task", MoveProgressTitle: "Move catalog task", + TemplateConfig: "Template Configuration", + OtherConfig: "Other Configuration", Extend: { Basic: "Basic", CatalogPageSize: "Page list Size", @@ -1138,7 +1145,8 @@ export default { LikeCount: "Likes", CommentCount: "Comments", RelaContent: "Related contents", - PushToBaidu: "Push To Baidu" + PushToBaidu: "Push To Baidu", + ImportCSSTip: "Import site/catalog publish-pipe prop 'UEditor CSS'.", }, Image: { Title: "Title", diff --git a/chestnut-ui/src/i18n/lang/zh-CN.js b/chestnut-ui/src/i18n/lang/zh-CN.js index c6d4dd2b..e9d27a51 100644 --- a/chestnut-ui/src/i18n/lang/zh-CN.js +++ b/chestnut-ui/src/i18n/lang/zh-CN.js @@ -896,6 +896,8 @@ export default { SitemapUrlLimit: "Sitemap链接数量", GenSitemap: "生成Sitemap", SitemapProgressTitle: "生成Sitemap任务", + Domain: "站点域名", + UEditorCss: "文章编辑器CSS", Tab: { Basic: "基础信息", Extend: "扩展配置", @@ -1036,6 +1038,9 @@ export default { CopyContentTip: "拷贝副本:完整复制内容,独立于来源自由修改。", MappingContent: "映射内容", MappingContentTip: "映射内容:仅生成基础信息,独立页面,扩展内容共享自源内容。", + SortUp: "上移", + SortDown: "下移", + NoSitePermissions: "无任何站点权限", RuleTips: { Name: "栏目名称不能为空", Alias: "不能为空且只能使用字母、数字和下划线", @@ -1046,6 +1051,8 @@ export default { PublishProgressTitle: "发布栏目", DeleteProgressTitle: "删除栏目", MoveProgressTitle: "转移栏目", + TemplateConfig: "模板配置", + OtherConfig: "其他配置", Extend: { Basic: "基础配置", CatalogPageSize: "分页列表大小", @@ -1138,7 +1145,8 @@ export default { LikeCount: "点赞数", CommentCount: "评论数", RelaContent: "相关内容", - PushToBaidu: "推送到百度" + PushToBaidu: "推送到百度", + ImportCSSTip: "应用站点/栏目发布通道设置的文章编辑器CSS", }, Image: { Title: "标题", diff --git a/chestnut-ui/src/i18n/lang/zh-TW.js b/chestnut-ui/src/i18n/lang/zh-TW.js index d0f1f26f..6714b9fa 100644 --- a/chestnut-ui/src/i18n/lang/zh-TW.js +++ b/chestnut-ui/src/i18n/lang/zh-TW.js @@ -896,6 +896,8 @@ export default { SitemapUrlLimit: "Sitemap連結數量", GenSitemap: "生成Sitemap", SitemapProgressTitle: "生成Sitemap任務", + Domain: "站點域名", + UEditorCss: "文章編輯器CSS", Tab: { Basic: "基礎資訊", Extend: "擴展配置", @@ -1036,6 +1038,9 @@ export default { CopyContentTip: "拷貝副本:完整複製內容,獨立於來源自由修改。", MappingContent: "映射內容", MappingContentTip: "映射內容:僅生成基礎資訊,獨立頁面,擴展內容共用自源內容。", + SortUp: "上移", + SortDown: "下移", + NoSitePermissions: "無任何站點權限", RuleTips: { Name: "欄目名稱不能為空", Alias: "不能為空且只能使用字母、數字和下劃線", @@ -1046,6 +1051,8 @@ export default { PublishProgressTitle: "發布欄目", DeleteProgressTitle: "刪除欄目", MoveProgressTitle: "轉移欄目", + TemplateConfig: "模板配置", + OtherConfig: "其他配置", Extend: { Basic: "基礎配置", CatalogPageSize: "分頁列表大小", @@ -1138,7 +1145,8 @@ export default { LikeCount: "點贊數", CommentCount: "評論數", RelaContent: "相關內容", - PushToBaidu: "推送到百度" + PushToBaidu: "推送到百度", + ImportCSSTip: "應用站點/欄目發佈通道設置的文章編輯器CSS", }, Image: { Title: "標題", diff --git a/chestnut-ui/src/views/cms/components/EXModelEditor/index.vue b/chestnut-ui/src/views/cms/components/EXModelEditor/index.vue index 75c86e88..f3b22f93 100644 --- a/chestnut-ui/src/views/cms/components/EXModelEditor/index.vue +++ b/chestnut-ui/src/views/cms/components/EXModelEditor/index.vue @@ -37,11 +37,10 @@ type="date" value-format="yyyy-MM-dd"> - - + +
+ + + +
+ +
/
+ + {{item}} +
/
+
+
+
+
+ + + + + + + + + + +
+
+ + + \ No newline at end of file diff --git a/chestnut-ui/src/views/cms/contentcore/catalogInfo.vue b/chestnut-ui/src/views/cms/contentcore/catalogInfo.vue index ea683781..d36b25e6 100644 --- a/chestnut-ui/src/views/cms/contentcore/catalogInfo.vue +++ b/chestnut-ui/src/views/cms/contentcore/catalogInfo.vue @@ -171,6 +171,7 @@ :command="pp" :name="pp.pipeCode" :label="pp.pipeName"> + 模板配置 {{ $t('CMS.Catalog.ApplyToChildren') }} + 其他配置 + + + {{ $t("Common.Select") }} + + @@ -293,6 +304,8 @@ :open="openContentSelector" @ok="handleContentSelectorOk" @close="handleContentSelectorClose"> + + @@ -305,6 +318,7 @@ import CMSTemplateSelector from '@/views/cms/contentcore/templateSelector'; import CMSProgress from '@/views/components/Progress'; import CMSLogoView from '@/views/cms/components/LogoView'; import CMSEXModelEditor from '@/views/cms/components/EXModelEditor'; +import CMSFileSelector from '@/views/cms/components/FileSelector'; export default { name: "CMSCatalogInfo", @@ -314,7 +328,8 @@ export default { 'cms-catalog-selector': CMSCatalogSelector, 'cms-content-selector': CMSContentSelector, 'cms-progress': CMSProgress, - "cms-logo-view": CMSLogoView + "cms-logo-view": CMSLogoView, + "cms-file-selector": CMSFileSelector }, dicts: ['CMSStaticSuffix', 'CMSContentStatus'], props: { @@ -375,7 +390,8 @@ export default { catalogType: [ { required: true, message: this.$t('CMS.Catalog.RuleTips.CatalogType'), trigger: "blur" } ] - } + }, + openFileSelector: false, }; }, created() { @@ -577,6 +593,19 @@ export default { handleSortCatalogCancel() { this.showSortPop = false; this.sortValue = 0; + }, + handleSelectFile() { + this.openFileSelector = true; + }, + handleSetUEditorStyle(files) { + if (files.length > 0) { + this.form_info.publishPipeDatas.map(item => { + if (item.pipeCode == this.publishPipeActiveName) { + item.props.ueditorCss = files[0].filePath; + } + }); + } + this.openFileSelector = false; } } }; diff --git a/chestnut-ui/src/views/cms/contentcore/catalogPerms.vue b/chestnut-ui/src/views/cms/contentcore/catalogPerms.vue index 80b90e31..247aefe7 100644 --- a/chestnut-ui/src/views/cms/contentcore/catalogPerms.vue +++ b/chestnut-ui/src/views/cms/contentcore/catalogPerms.vue @@ -21,6 +21,7 @@ +
+ {{ $t("CMS.Catalog.NoSitePermissions") }} +
@@ -85,7 +89,7 @@ export default { }, data() { return { - loading: true, + loading: false, tableHeight: 600, tableMaxHeight: 900, selectAll: false, diff --git a/chestnut-ui/src/views/cms/contentcore/catalogTree.vue b/chestnut-ui/src/views/cms/contentcore/catalogTree.vue index f1c9efc5..736767c5 100644 --- a/chestnut-ui/src/views/cms/contentcore/catalogTree.vue +++ b/chestnut-ui/src/views/cms/contentcore/catalogTree.vue @@ -35,13 +35,15 @@ {{ node.label }} - - - + + + + {{ $t('CMS.ContentCore.Preview') }} + {{ $t('CMS.ContentCore.Publish') }} + {{ $t('CMS.Catalog.SortUp') }} + {{ $t('CMS.Catalog.SortDown') }} + + @@ -85,17 +87,37 @@ {{ $t("Common.Cancel") }} + + +
+

{{ $t('Common.Tips') }}

+

{{ $t('CMS.Catalog.PublishTips') }}

+ {{ $t('CMS.Catalog.ContainsChildren') }} +
+ + {{ $t("Common.Cancel") }} + {{ $t("Common.Confirm") }} + +
+ + diff --git a/chestnut-ui/src/views/cms/contentcore/contentEditor.vue b/chestnut-ui/src/views/cms/contentcore/contentEditor.vue index 0a5f26b8..bdab40b4 100644 --- a/chestnut-ui/src/views/cms/contentcore/contentEditor.vue +++ b/chestnut-ui/src/views/cms/contentcore/contentEditor.vue @@ -86,18 +86,35 @@ - - - - {{ $t('CMS.Content.DownloadImageTip') }} - - + + + + + {{ $t('CMS.Content.DownloadImageTip') }} + + + + + + + + + + {{ pp.pipeName }} + + + +
- +
@@ -238,6 +255,7 @@