1、页面管理新增设为首页字段home;2、改造默认网站生成规则
This commit is contained in:
@@ -116,7 +116,11 @@ public class NavigationController extends BaseController {
|
||||
@ApiOperation("检查分类是否存在")
|
||||
@GetMapping("/existence")
|
||||
public ApiResult<?> existence(ExistenceParam<Navigation> param) {
|
||||
if (navigationService.count(new LambdaQueryWrapper<Navigation>().eq(Navigation::getPath, param.getValue()).ne(Navigation::getNavigationId,param.getId()))> 0) {
|
||||
if (navigationService.count(new LambdaQueryWrapper<Navigation>()
|
||||
.eq(Navigation::getPath, param.getValue())
|
||||
.ne(Navigation::getNavigationId,param.getId())
|
||||
.ne(Navigation::getType,9)
|
||||
)> 0) {
|
||||
return success(param.getValue() + "已存在");
|
||||
}
|
||||
return fail(param.getValue() + "不存在");
|
||||
|
||||
@@ -6,9 +6,7 @@ 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.Ad;
|
||||
import com.gxwebsoft.cms.entity.ArticleCategory;
|
||||
import com.gxwebsoft.cms.entity.Website;
|
||||
import com.gxwebsoft.cms.entity.*;
|
||||
import com.gxwebsoft.cms.param.ArticleCategoryParam;
|
||||
import com.gxwebsoft.cms.param.NavigationParam;
|
||||
import com.gxwebsoft.cms.param.WebsiteParam;
|
||||
@@ -44,10 +42,14 @@ public class WebsiteController extends BaseController {
|
||||
@Resource
|
||||
private WebsiteFieldService websiteFieldService;
|
||||
@Resource
|
||||
private DesignService designService;
|
||||
@Resource
|
||||
private NavigationService navigationService;
|
||||
@Resource
|
||||
private AdService adService;
|
||||
@Resource
|
||||
private FormService formService;
|
||||
@Resource
|
||||
private ArticleCategoryService articleCategoryService;
|
||||
@Resource
|
||||
private LinkService linkService;
|
||||
@@ -101,24 +103,82 @@ 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);
|
||||
|
||||
// 创建默认页面及导航
|
||||
final Navigation navigation = new Navigation();
|
||||
final Design design = new Design();
|
||||
// 1.首页
|
||||
design.setName("首页");
|
||||
design.setHome(1);
|
||||
design.setPath("/");
|
||||
design.setComponent("/index");
|
||||
design.setSortNumber(0);
|
||||
designService.save(design);
|
||||
navigation.setTitle(design.getName());
|
||||
navigation.setPath(design.getPath());
|
||||
navigation.setComponent(design.getComponent());
|
||||
navigation.setHome(design.getHome());
|
||||
navigation.setPageId(design.getPageId());
|
||||
navigation.setSortNumber(0);
|
||||
navigationService.save(navigation);
|
||||
// 2.关于我们
|
||||
design.setName("关于我们");
|
||||
design.setPath("/about");
|
||||
design.setComponent("/about/index");
|
||||
design.setSortNumber(1);
|
||||
designService.save(design);
|
||||
navigation.setTitle(design.getName());
|
||||
navigation.setPath(design.getPath());
|
||||
navigation.setComponent(design.getComponent());
|
||||
navigation.setPageId(design.getPageId());
|
||||
navigation.setSortNumber(1);
|
||||
navigationService.save(navigation);
|
||||
// 3.产品展示
|
||||
final ArticleCategory articleCategory = new ArticleCategory();
|
||||
articleCategory.setTitle("产品展示");
|
||||
articleCategory.setPath("/product/" + articleCategory.getCategoryId());
|
||||
articleCategory.setComponent("/article/photo");
|
||||
articleCategory.setSortNumber(2);
|
||||
articleCategoryService.save(articleCategory);
|
||||
navigation.setTitle(articleCategory.getTitle());
|
||||
navigation.setPath(articleCategory.getPath());
|
||||
navigation.setComponent(articleCategory.getComponent());
|
||||
navigation.setArticleCategoryId(articleCategory.getCategoryId());
|
||||
navigation.setSortNumber(2);
|
||||
navigationService.save(navigation);
|
||||
// 4.新闻资讯
|
||||
articleCategory.setTitle("新闻资讯");
|
||||
articleCategoryService.save(articleCategory);
|
||||
navigation.setTitle(articleCategory.getTitle());
|
||||
navigation.setPath("/article/" + articleCategory.getCategoryId());
|
||||
navigation.setComponent("/article/index");
|
||||
navigation.setArticleCategoryId(articleCategory.getCategoryId());
|
||||
navigation.setSortNumber(3);
|
||||
navigationService.save(navigation);
|
||||
// 5.表单页面
|
||||
final Form form = new Form();
|
||||
form.setName("业务咨询");
|
||||
form.setLayout("[{\"id\":\"vhEB\",\"type\":\"text\",\"name\":\"姓名\",\"checked\":true},{\"id\":\"Hg7v\",\"type\":\"phone\",\"name\":\"手机号码\",\"checked\":true},{\"id\":\"byBy\",\"type\":\"textarea\",\"name\":\"需求描述\",\"checked\":false}]");
|
||||
form.setComments("简单描述您的需求,我们会尽快联系您");
|
||||
formService.save(form);
|
||||
navigation.setTitle(form.getName());
|
||||
navigation.setPath("/form/" + form.getFormId());
|
||||
navigation.setComponent("/form/index");
|
||||
navigation.setFormId(form.getFormId());
|
||||
navigation.setSortNumber(4);
|
||||
navigationService.save(navigation);
|
||||
// 6.联系我们
|
||||
design.setName("联系我们");
|
||||
design.setPath("/contact");
|
||||
design.setComponent("/contact/index");
|
||||
design.setSortNumber(5);
|
||||
designService.save(design);
|
||||
navigation.setTitle(design.getName());
|
||||
navigation.setPath(design.getPath());
|
||||
navigation.setComponent(design.getComponent());
|
||||
navigation.setPageId(design.getPageId());
|
||||
navigation.setSortNumber(5);
|
||||
navigationService.save(navigation);
|
||||
}
|
||||
|
||||
// 获取站点信息
|
||||
@@ -134,7 +194,13 @@ public class WebsiteController extends BaseController {
|
||||
website.setNavigations(navigationService.listRel(navigationParam));
|
||||
|
||||
// 读取幻灯片广告
|
||||
website.setAds(adService.list(new LambdaQueryWrapper<Ad>().like(Ad::getName,"幻灯片").last("limit 10")));
|
||||
website.setAds(adService.list(new LambdaQueryWrapper<Ad>().like(Ad::getAdType,"幻灯片").last("limit 1")));
|
||||
|
||||
// 首页布局
|
||||
final Design design = designService.getOne(new LambdaQueryWrapper<Design>().eq(Design::getHome, 1).last("limit 1"));
|
||||
if (design != null) {
|
||||
website.setLayout(design.getLayout());
|
||||
}
|
||||
|
||||
// 提取文章分类作为网站导航
|
||||
final ArticleCategoryParam param = new ArticleCategoryParam();
|
||||
@@ -148,8 +214,8 @@ public class WebsiteController extends BaseController {
|
||||
|
||||
// 授权信息
|
||||
HashMap<String, Object> config = new HashMap<>();
|
||||
config.put("LICENSE_CODE", "dk9mcwJyetRWQlxWRiojIzJCLi8mcQ5Wa4ojI0NWZqJWd6ICZpJCL0kjNwl1NnhENahnIvl2cyVmdiwiIiATMuEjI6IibQf0NW==");
|
||||
config.put("MAP_KEY", "8191620da39a742c6f18f010c084c772");
|
||||
config.put("LICENSE_CODE", "");
|
||||
config.put("MAP_KEY", "");
|
||||
website.setConfig(config);
|
||||
|
||||
// 服务器时间
|
||||
|
||||
@@ -59,6 +59,9 @@ public class Design implements Serializable {
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "设为首页")
|
||||
private Integer home;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
private Integer sortNumber;
|
||||
|
||||
|
||||
@@ -74,9 +74,15 @@ public class Navigation implements Serializable {
|
||||
@ApiModelProperty(value = "文章分类ID")
|
||||
private Integer articleId;
|
||||
|
||||
@ApiModelProperty(value = "表单ID")
|
||||
private Integer formId;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "设为首页")
|
||||
private Integer home;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
private Integer sortNumber;
|
||||
|
||||
|
||||
@@ -141,6 +141,10 @@ public class Website implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private List<Ad> ads;
|
||||
|
||||
@ApiModelProperty(value = "首页布局")
|
||||
@TableField(exist = false)
|
||||
private String layout;
|
||||
|
||||
@ApiModelProperty(value = "文章分类")
|
||||
@TableField(exist = false)
|
||||
private List<ArticleCategory> categoryList;
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
<if test="param.parentId != null">
|
||||
AND a.parent_id = #{param.parentId}
|
||||
</if>
|
||||
<if test="param.home != null">
|
||||
AND a.home = #{param.home}
|
||||
</if>
|
||||
<if test="param.name != null">
|
||||
AND a.name LIKE CONCAT('%', #{param.name}, '%')
|
||||
</if>
|
||||
|
||||
@@ -50,6 +50,9 @@
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.home != null">
|
||||
AND a.home = #{param.home}
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.gxwebsoft.cms.param;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -49,6 +49,10 @@ public class DesignParam extends BaseParam {
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "设为首页")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer home;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@@ -67,6 +67,10 @@ public class NavigationParam extends BaseParam {
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "设为首页")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer home;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
List<Design> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<Design, DesignParam> page = new PageParam<>();
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
page.setDefaultOrder("sort_number asc,create_time asc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user