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

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.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<Website> 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);
}
@@ -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;
@@ -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;
@@ -4,7 +4,7 @@
<!-- 关联查询sql -->
<sql id="selectSql">
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
<where>
@@ -13,8 +13,8 @@
<if test="param.parentId != null">
AND a.parent_id = #{param.parentId}
</if>
<if test="param.title != null">
AND a.title LIKE CONCAT('%', #{param.title}, '%')
<if test="param.name != null">
AND a.name LIKE CONCAT('%', #{param.name}, '%')
</if>
<if test="param.keywords != null">
AND a.keywords LIKE CONCAT('%', #{param.keywords}, '%')