From a2eb1e45c1cdccb6eeb47395666b85fda502d834 Mon Sep 17 00:00:00 2001 From: gxwebsoft Date: Thu, 7 Mar 2024 23:54:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E7=BD=91=E7=AB=99?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cms/controller/WebsiteController.java | 34 +++++++++++++++++++ .../gxwebsoft/cms/entity/ArticleCategory.java | 6 ++++ .../java/com/gxwebsoft/cms/entity/Design.java | 5 ++- .../cms/mapper/xml/ArticleCategoryMapper.xml | 2 +- .../gxwebsoft/cms/mapper/xml/DesignMapper.xml | 4 +-- 5 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gxwebsoft/cms/controller/WebsiteController.java b/src/main/java/com/gxwebsoft/cms/controller/WebsiteController.java index 79846ab..de4c267 100644 --- a/src/main/java/com/gxwebsoft/cms/controller/WebsiteController.java +++ b/src/main/java/com/gxwebsoft/cms/controller/WebsiteController.java @@ -2,9 +2,11 @@ package com.gxwebsoft.cms.controller; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpRequest; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.gxwebsoft.cms.entity.ArticleCategory; import com.gxwebsoft.cms.entity.Navigation; import com.gxwebsoft.cms.entity.Website; import com.gxwebsoft.cms.param.ArticleCategoryParam; @@ -14,6 +16,7 @@ import com.gxwebsoft.cms.service.NavigationService; import com.gxwebsoft.cms.service.WebsiteFieldService; import com.gxwebsoft.cms.service.WebsiteService; import com.gxwebsoft.common.core.security.JwtUtil; +import com.gxwebsoft.common.core.utils.RedisUtil; import com.gxwebsoft.common.core.web.*; import com.gxwebsoft.common.system.entity.User; import com.gxwebsoft.oa.entity.Company; @@ -44,11 +47,22 @@ public class WebsiteController extends BaseController { private NavigationService navigationService; @Resource private ArticleCategoryService articleCategoryService; + @Resource + private RedisUtil redisUtil; @ApiOperation("获取网站信息") @GetMapping("/getSiteInfo") public ApiResult getSiteInfo(HttpServletRequest request) { final Integer tenantId = getTenantId(); + String key = "SiteInfo:" + tenantId; + final String siteInfo = redisUtil.get(key); + + // 从缓存读取信息 + if(StrUtil.isNotBlank(siteInfo)){ + return success(JSONObject.parseObject(siteInfo,Website.class)); + } + + // 获取站点信息 final WebsiteParam websiteParam = new WebsiteParam(); if (websiteService.count() == 0) { // 请求主服务器获取租户信息 @@ -63,6 +77,7 @@ public class WebsiteController extends BaseController { JSONObject jsonObject = JSONObject.parseObject(result); final String data = jsonObject.getString("data"); final Company company = JSONObject.parseObject(data, Company.class); + // 创建网站记录 final Website website = new Website(); website.setTenantId(company.getTenantId()); website.setWebsiteName(company.getShortName()); @@ -79,6 +94,24 @@ public class WebsiteController extends BaseController { website.setKeywords(company.getCompanyName()); website.setUserId(company.getUserId()); websiteService.save(website); + // 创建默认导航栏 + final ArticleCategory category = new ArticleCategory(); + category.setTitle("首页"); + category.setPath("/home"); + category.setComponent("/index"); + articleCategoryService.save(category); + category.setTitle("关于我们"); + category.setPath("/about"); + category.setComponent("/about/index"); + articleCategoryService.save(category); + category.setTitle("新闻动态"); + category.setPath("/news"); + category.setComponent("/article/index"); + articleCategoryService.save(category); + category.setTitle("联系我们"); + category.setPath("/contact"); + category.setComponent("/contact/index"); + articleCategoryService.save(category); } // 获取站点信息 @@ -124,6 +157,7 @@ public class WebsiteController extends BaseController { serverTime.put("week",week); serverTime.put("nextWeek",nextWeek); website.setServerTime(serverTime); + redisUtil.set(key,website); return success(website); } diff --git a/src/main/java/com/gxwebsoft/cms/entity/ArticleCategory.java b/src/main/java/com/gxwebsoft/cms/entity/ArticleCategory.java index d5c8889..b9197d9 100644 --- a/src/main/java/com/gxwebsoft/cms/entity/ArticleCategory.java +++ b/src/main/java/com/gxwebsoft/cms/entity/ArticleCategory.java @@ -27,6 +27,9 @@ public class ArticleCategory implements Serializable { @TableId(value = "category_id", type = IdType.AUTO) private Integer categoryId; + @ApiModelProperty(value = "分类标识") + private String categoryCode; + @ApiModelProperty(value = "类型 0列表 1页面 2外链") private Integer type; @@ -42,6 +45,9 @@ public class ArticleCategory implements Serializable { @ApiModelProperty(value = "路由/链接地址") private String path; + @ApiModelProperty("导航组件地址") + private String component; + @ApiModelProperty(value = "绑定的页面ID") private Integer pageId; diff --git a/src/main/java/com/gxwebsoft/cms/entity/Design.java b/src/main/java/com/gxwebsoft/cms/entity/Design.java index af88e3d..5420002 100644 --- a/src/main/java/com/gxwebsoft/cms/entity/Design.java +++ b/src/main/java/com/gxwebsoft/cms/entity/Design.java @@ -32,7 +32,7 @@ public class Design implements Serializable { private Integer parentId; @ApiModelProperty(value = "页面标题") - private String title; + private String name; @ApiModelProperty(value = "页面关键词") private String keywords; @@ -46,6 +46,9 @@ public class Design implements Serializable { @ApiModelProperty(value = "缩列图") private String photo; + @ApiModelProperty(value = "页面内容") + private String content; + @ApiModelProperty(value = "用户ID") private Integer userId; diff --git a/src/main/java/com/gxwebsoft/cms/mapper/xml/ArticleCategoryMapper.xml b/src/main/java/com/gxwebsoft/cms/mapper/xml/ArticleCategoryMapper.xml index 2cb0218..c0ad8b2 100644 --- a/src/main/java/com/gxwebsoft/cms/mapper/xml/ArticleCategoryMapper.xml +++ b/src/main/java/com/gxwebsoft/cms/mapper/xml/ArticleCategoryMapper.xml @@ -4,7 +4,7 @@ - SELECT a.*,b.title as pageName + SELECT a.*,b.name as pageName FROM cms_article_category a LEFT JOIN cms_design b ON a.page_id = b.page_id diff --git a/src/main/java/com/gxwebsoft/cms/mapper/xml/DesignMapper.xml b/src/main/java/com/gxwebsoft/cms/mapper/xml/DesignMapper.xml index e392a03..234d363 100644 --- a/src/main/java/com/gxwebsoft/cms/mapper/xml/DesignMapper.xml +++ b/src/main/java/com/gxwebsoft/cms/mapper/xml/DesignMapper.xml @@ -13,8 +13,8 @@ AND a.parent_id = #{param.parentId} - - AND a.title LIKE CONCAT('%', #{param.title}, '%') + + AND a.name LIKE CONCAT('%', #{param.name}, '%') AND a.keywords LIKE CONCAT('%', #{param.keywords}, '%')