新增:网站后台管理功能模块

This commit is contained in:
gxwebsoft
2024-03-07 23:54:56 +08:00
parent 06f349c833
commit a2eb1e45c1
5 changed files with 47 additions and 4 deletions
@@ -2,9 +2,11 @@ package com.gxwebsoft.cms.controller;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.Navigation;
import com.gxwebsoft.cms.entity.Website; import com.gxwebsoft.cms.entity.Website;
import com.gxwebsoft.cms.param.ArticleCategoryParam; 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.WebsiteFieldService;
import com.gxwebsoft.cms.service.WebsiteService; import com.gxwebsoft.cms.service.WebsiteService;
import com.gxwebsoft.common.core.security.JwtUtil; import com.gxwebsoft.common.core.security.JwtUtil;
import com.gxwebsoft.common.core.utils.RedisUtil;
import com.gxwebsoft.common.core.web.*; import com.gxwebsoft.common.core.web.*;
import com.gxwebsoft.common.system.entity.User; import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.oa.entity.Company; import com.gxwebsoft.oa.entity.Company;
@@ -44,11 +47,22 @@ public class WebsiteController extends BaseController {
private NavigationService navigationService; private NavigationService navigationService;
@Resource @Resource
private ArticleCategoryService articleCategoryService; private ArticleCategoryService articleCategoryService;
@Resource
private RedisUtil redisUtil;
@ApiOperation("获取网站信息") @ApiOperation("获取网站信息")
@GetMapping("/getSiteInfo") @GetMapping("/getSiteInfo")
public ApiResult<Website> getSiteInfo(HttpServletRequest request) { public ApiResult<Website> getSiteInfo(HttpServletRequest request) {
final Integer tenantId = getTenantId(); 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(); final WebsiteParam websiteParam = new WebsiteParam();
if (websiteService.count() == 0) { if (websiteService.count() == 0) {
// 请求主服务器获取租户信息 // 请求主服务器获取租户信息
@@ -63,6 +77,7 @@ public class WebsiteController extends BaseController {
JSONObject jsonObject = JSONObject.parseObject(result); JSONObject jsonObject = JSONObject.parseObject(result);
final String data = jsonObject.getString("data"); final String data = jsonObject.getString("data");
final Company company = JSONObject.parseObject(data, Company.class); final Company company = JSONObject.parseObject(data, Company.class);
// 创建网站记录
final Website website = new Website(); final Website website = new Website();
website.setTenantId(company.getTenantId()); website.setTenantId(company.getTenantId());
website.setWebsiteName(company.getShortName()); website.setWebsiteName(company.getShortName());
@@ -79,6 +94,24 @@ public class WebsiteController extends BaseController {
website.setKeywords(company.getCompanyName()); website.setKeywords(company.getCompanyName());
website.setUserId(company.getUserId()); website.setUserId(company.getUserId());
websiteService.save(website); 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("week",week);
serverTime.put("nextWeek",nextWeek); serverTime.put("nextWeek",nextWeek);
website.setServerTime(serverTime); website.setServerTime(serverTime);
redisUtil.set(key,website);
return success(website); return success(website);
} }
@@ -27,6 +27,9 @@ public class ArticleCategory implements Serializable {
@TableId(value = "category_id", type = IdType.AUTO) @TableId(value = "category_id", type = IdType.AUTO)
private Integer categoryId; private Integer categoryId;
@ApiModelProperty(value = "分类标识")
private String categoryCode;
@ApiModelProperty(value = "类型 0列表 1页面 2外链") @ApiModelProperty(value = "类型 0列表 1页面 2外链")
private Integer type; private Integer type;
@@ -42,6 +45,9 @@ public class ArticleCategory implements Serializable {
@ApiModelProperty(value = "路由/链接地址") @ApiModelProperty(value = "路由/链接地址")
private String path; private String path;
@ApiModelProperty("导航组件地址")
private String component;
@ApiModelProperty(value = "绑定的页面ID") @ApiModelProperty(value = "绑定的页面ID")
private Integer pageId; private Integer pageId;
@@ -32,7 +32,7 @@ public class Design implements Serializable {
private Integer parentId; private Integer parentId;
@ApiModelProperty(value = "页面标题") @ApiModelProperty(value = "页面标题")
private String title; private String name;
@ApiModelProperty(value = "页面关键词") @ApiModelProperty(value = "页面关键词")
private String keywords; private String keywords;
@@ -46,6 +46,9 @@ public class Design implements Serializable {
@ApiModelProperty(value = "缩列图") @ApiModelProperty(value = "缩列图")
private String photo; private String photo;
@ApiModelProperty(value = "页面内容")
private String content;
@ApiModelProperty(value = "用户ID") @ApiModelProperty(value = "用户ID")
private Integer userId; private Integer userId;
@@ -4,7 +4,7 @@
<!-- 关联查询sql --> <!-- 关联查询sql -->
<sql id="selectSql"> <sql id="selectSql">
SELECT a.*,b.title as pageName SELECT a.*,b.name as pageName
FROM cms_article_category a FROM cms_article_category a
LEFT JOIN cms_design b ON a.page_id = b.page_id LEFT JOIN cms_design b ON a.page_id = b.page_id
<where> <where>
@@ -13,8 +13,8 @@
<if test="param.parentId != null"> <if test="param.parentId != null">
AND a.parent_id = #{param.parentId} AND a.parent_id = #{param.parentId}
</if> </if>
<if test="param.title != null"> <if test="param.name != null">
AND a.title LIKE CONCAT('%', #{param.title}, '%') AND a.name LIKE CONCAT('%', #{param.name}, '%')
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND a.keywords LIKE CONCAT('%', #{param.keywords}, '%') AND a.keywords LIKE CONCAT('%', #{param.keywords}, '%')