diff --git a/src/main/java/com/gxwebsoft/cms/controller/NavigationController.java b/src/main/java/com/gxwebsoft/cms/controller/NavigationController.java index 15999cb..f4865f9 100644 --- a/src/main/java/com/gxwebsoft/cms/controller/NavigationController.java +++ b/src/main/java/com/gxwebsoft/cms/controller/NavigationController.java @@ -116,7 +116,11 @@ public class NavigationController extends BaseController { @ApiOperation("检查分类是否存在") @GetMapping("/existence") public ApiResult existence(ExistenceParam param) { - if (navigationService.count(new LambdaQueryWrapper().eq(Navigation::getPath, param.getValue()).ne(Navigation::getNavigationId,param.getId()))> 0) { + if (navigationService.count(new LambdaQueryWrapper() + .eq(Navigation::getPath, param.getValue()) + .ne(Navigation::getNavigationId,param.getId()) + .ne(Navigation::getType,9) + )> 0) { return success(param.getValue() + "已存在"); } return fail(param.getValue() + "不存在"); diff --git a/src/main/java/com/gxwebsoft/cms/controller/WebsiteController.java b/src/main/java/com/gxwebsoft/cms/controller/WebsiteController.java index ae28bb5..0b26dbe 100644 --- a/src/main/java/com/gxwebsoft/cms/controller/WebsiteController.java +++ b/src/main/java/com/gxwebsoft/cms/controller/WebsiteController.java @@ -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().like(Ad::getName,"幻灯片").last("limit 10"))); + website.setAds(adService.list(new LambdaQueryWrapper().like(Ad::getAdType,"幻灯片").last("limit 1"))); + + // 首页布局 + final Design design = designService.getOne(new LambdaQueryWrapper().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 config = new HashMap<>(); - config.put("LICENSE_CODE", "dk9mcwJyetRWQlxWRiojIzJCLi8mcQ5Wa4ojI0NWZqJWd6ICZpJCL0kjNwl1NnhENahnIvl2cyVmdiwiIiATMuEjI6IibQf0NW=="); - config.put("MAP_KEY", "8191620da39a742c6f18f010c084c772"); + config.put("LICENSE_CODE", ""); + config.put("MAP_KEY", ""); website.setConfig(config); // 服务器时间 diff --git a/src/main/java/com/gxwebsoft/cms/entity/Design.java b/src/main/java/com/gxwebsoft/cms/entity/Design.java index 2f27c77..cfafb7d 100644 --- a/src/main/java/com/gxwebsoft/cms/entity/Design.java +++ b/src/main/java/com/gxwebsoft/cms/entity/Design.java @@ -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; diff --git a/src/main/java/com/gxwebsoft/cms/entity/Navigation.java b/src/main/java/com/gxwebsoft/cms/entity/Navigation.java index 3e5474c..ff9ef61 100644 --- a/src/main/java/com/gxwebsoft/cms/entity/Navigation.java +++ b/src/main/java/com/gxwebsoft/cms/entity/Navigation.java @@ -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; diff --git a/src/main/java/com/gxwebsoft/cms/entity/Website.java b/src/main/java/com/gxwebsoft/cms/entity/Website.java index 1a36fa1..e9cdfee 100644 --- a/src/main/java/com/gxwebsoft/cms/entity/Website.java +++ b/src/main/java/com/gxwebsoft/cms/entity/Website.java @@ -141,6 +141,10 @@ public class Website implements Serializable { @TableField(exist = false) private List ads; + @ApiModelProperty(value = "首页布局") + @TableField(exist = false) + private String layout; + @ApiModelProperty(value = "文章分类") @TableField(exist = false) private List categoryList; 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 9732300..dfe89f4 100644 --- a/src/main/java/com/gxwebsoft/cms/mapper/xml/DesignMapper.xml +++ b/src/main/java/com/gxwebsoft/cms/mapper/xml/DesignMapper.xml @@ -13,6 +13,9 @@ AND a.parent_id = #{param.parentId} + + AND a.home = #{param.home} + AND a.name LIKE CONCAT('%', #{param.name}, '%') diff --git a/src/main/java/com/gxwebsoft/cms/mapper/xml/NavigationMapper.xml b/src/main/java/com/gxwebsoft/cms/mapper/xml/NavigationMapper.xml index 0d9fb35..7b86b15 100644 --- a/src/main/java/com/gxwebsoft/cms/mapper/xml/NavigationMapper.xml +++ b/src/main/java/com/gxwebsoft/cms/mapper/xml/NavigationMapper.xml @@ -50,6 +50,9 @@ AND a.user_id = #{param.userId} + + AND a.home = #{param.home} + AND a.sort_number = #{param.sortNumber} diff --git a/src/main/java/com/gxwebsoft/cms/param/DesignParam.java b/src/main/java/com/gxwebsoft/cms/param/DesignParam.java index 7bd0329..5e20af3 100644 --- a/src/main/java/com/gxwebsoft/cms/param/DesignParam.java +++ b/src/main/java/com/gxwebsoft/cms/param/DesignParam.java @@ -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; diff --git a/src/main/java/com/gxwebsoft/cms/param/NavigationParam.java b/src/main/java/com/gxwebsoft/cms/param/NavigationParam.java index f50f170..6418e1e 100644 --- a/src/main/java/com/gxwebsoft/cms/param/NavigationParam.java +++ b/src/main/java/com/gxwebsoft/cms/param/NavigationParam.java @@ -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; diff --git a/src/main/java/com/gxwebsoft/cms/service/impl/DesignServiceImpl.java b/src/main/java/com/gxwebsoft/cms/service/impl/DesignServiceImpl.java index e7a2ed0..15af7da 100644 --- a/src/main/java/com/gxwebsoft/cms/service/impl/DesignServiceImpl.java +++ b/src/main/java/com/gxwebsoft/cms/service/impl/DesignServiceImpl.java @@ -33,7 +33,7 @@ public class DesignServiceImpl extends ServiceImpl impleme List list = baseMapper.selectListRel(param); // 排序 PageParam page = new PageParam<>(); - //page.setDefaultOrder("create_time desc"); + page.setDefaultOrder("sort_number asc,create_time asc"); return page.sortRecords(list); }