diff --git a/src/main/java/com/gxwebsoft/cms/controller/ArticleCategoryController.java b/src/main/java/com/gxwebsoft/cms/controller/ArticleCategoryController.java index 4cebe3e..fa28793 100644 --- a/src/main/java/com/gxwebsoft/cms/controller/ArticleCategoryController.java +++ b/src/main/java/com/gxwebsoft/cms/controller/ArticleCategoryController.java @@ -1,5 +1,6 @@ package com.gxwebsoft.cms.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.gxwebsoft.cms.entity.Article; import com.gxwebsoft.cms.entity.ArticleCategory; import com.gxwebsoft.cms.param.ArticleCategoryParam; @@ -67,9 +68,11 @@ public class ArticleCategoryController extends BaseController { public ApiResult get(@PathVariable("id") Integer id) { // 使用关联查询 ArticleCategory category = articleCategoryService.getByIdRel(id); - if (!category.getParentId().equals(0)) { - final ArticleCategory parentCategory = articleCategoryService.getById(category.getParentId()); - category.setParentName(parentCategory.getTitle()); + if(category != null){ + if (!category.getParentId().equals(0)) { + final ArticleCategory parentCategory = articleCategoryService.getById(category.getParentId()); + category.setParentName(parentCategory.getTitle()); + } } return success(category); } @@ -100,6 +103,9 @@ public class ArticleCategoryController extends BaseController { @ApiOperation("删除文章分类表") @DeleteMapping("/{id}") public ApiResult remove(@PathVariable("id") Integer id) { + if (articleService.count(new LambdaQueryWrapper
().eq(Article::getCategoryId,id)) > 0) { + return fail("请先删除栏目下的文章"); + } if (articleCategoryService.removeById(id)) { return success("删除成功"); } @@ -127,10 +133,22 @@ public class ArticleCategoryController extends BaseController { @ApiOperation("批量删除文章分类表") @DeleteMapping("/batch") public ApiResult removeBatch(@RequestBody List ids) { + final int count = articleService.count(new LambdaQueryWrapper
().in(Article::getCategoryId, ids)); + System.out.println("count = " + count); + if (articleService.count(new LambdaQueryWrapper
().in(Article::getCategoryId,ids)) > 0) { + return fail("请先删除栏目下的文章"); + } if (articleCategoryService.removeByIds(ids)) { return success("删除成功"); } return fail("删除失败"); } - + @ApiOperation("检查分类是否存在") + @GetMapping("/existence") + public ApiResult existence(ExistenceParam param) { + if (param.isExistence(articleCategoryService, ArticleCategory::getUserId)) { + return success(param.getValue() + "已存在"); + } + return fail(param.getValue() + "不存在"); + } } diff --git a/src/main/java/com/gxwebsoft/cms/controller/DesignController.java b/src/main/java/com/gxwebsoft/cms/controller/DesignController.java index 5fd9ade..d1f30b4 100644 --- a/src/main/java/com/gxwebsoft/cms/controller/DesignController.java +++ b/src/main/java/com/gxwebsoft/cms/controller/DesignController.java @@ -1,5 +1,6 @@ package com.gxwebsoft.cms.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.gxwebsoft.cms.entity.Design; import com.gxwebsoft.cms.param.DesignParam; import com.gxwebsoft.cms.service.DesignService; @@ -54,6 +55,9 @@ public class DesignController extends BaseController { if (loginUser != null) { design.setUserId(loginUser.getUserId()); } + if (designService.count(new LambdaQueryWrapper().eq(Design::getPath,design.getPath())) > 0) { + return fail("路由地址已存在"); + } if (designService.save(design)) { return success("添加成功"); } diff --git a/src/main/java/com/gxwebsoft/cms/controller/NavigationController.java b/src/main/java/com/gxwebsoft/cms/controller/NavigationController.java index 3bfdd54..15999cb 100644 --- a/src/main/java/com/gxwebsoft/cms/controller/NavigationController.java +++ b/src/main/java/com/gxwebsoft/cms/controller/NavigationController.java @@ -1,5 +1,6 @@ package com.gxwebsoft.cms.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.gxwebsoft.cms.entity.Navigation; import com.gxwebsoft.cms.param.NavigationParam; import com.gxwebsoft.cms.service.NavigationService; @@ -55,6 +56,9 @@ public class NavigationController extends BaseController { if (loginUser != null) { navigation.setUserId(loginUser.getUserId()); } + if (navigationService.count(new LambdaQueryWrapper().eq(Navigation::getPath,navigation.getPath())) > 0) { + return fail("路由地址已存在"); + } if (navigationService.save(navigation)) { return success("添加成功"); } @@ -64,6 +68,9 @@ public class NavigationController extends BaseController { @ApiOperation("修改网站导航记录表") @PutMapping() public ApiResult update(@RequestBody Navigation navigation) { + if (navigationService.count(new LambdaQueryWrapper().ne(Navigation::getNavigationId,navigation.getNavigationId()).eq(Navigation::getPath,navigation.getPath())) > 0) { + return fail("路由地址已存在"); + } if (navigationService.updateById(navigation)) { return success("修改成功"); } @@ -106,4 +113,12 @@ public class NavigationController extends BaseController { return fail("删除失败"); } + @ApiOperation("检查分类是否存在") + @GetMapping("/existence") + public ApiResult existence(ExistenceParam param) { + if (navigationService.count(new LambdaQueryWrapper().eq(Navigation::getPath, param.getValue()).ne(Navigation::getNavigationId,param.getId()))> 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 a54f58e..ae28bb5 100644 --- a/src/main/java/com/gxwebsoft/cms/controller/WebsiteController.java +++ b/src/main/java/com/gxwebsoft/cms/controller/WebsiteController.java @@ -6,15 +6,13 @@ 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.Navigation; import com.gxwebsoft.cms.entity.Website; import com.gxwebsoft.cms.param.ArticleCategoryParam; +import com.gxwebsoft.cms.param.NavigationParam; import com.gxwebsoft.cms.param.WebsiteParam; -import com.gxwebsoft.cms.service.ArticleCategoryService; -import com.gxwebsoft.cms.service.NavigationService; -import com.gxwebsoft.cms.service.WebsiteFieldService; -import com.gxwebsoft.cms.service.WebsiteService; +import com.gxwebsoft.cms.service.*; import com.gxwebsoft.common.core.security.JwtUtil; import com.gxwebsoft.common.core.utils.RedisUtil; import com.gxwebsoft.common.core.web.*; @@ -48,6 +46,8 @@ public class WebsiteController extends BaseController { @Resource private NavigationService navigationService; @Resource + private AdService adService; + @Resource private ArticleCategoryService articleCategoryService; @Resource private LinkService linkService; @@ -62,9 +62,9 @@ public class WebsiteController extends BaseController { final String siteInfo = redisUtil.get(key); // 从缓存读取信息 - if(StrUtil.isNotBlank(siteInfo)){ - return success(JSONObject.parseObject(siteInfo,Website.class)); - } +// if(StrUtil.isNotBlank(siteInfo)){ +// return success(JSONObject.parseObject(siteInfo,Website.class)); +// } // 获取站点信息 final WebsiteParam websiteParam = new WebsiteParam(); @@ -129,7 +129,12 @@ public class WebsiteController extends BaseController { website.setFields(websiteFieldService.list()); // 附加自定义导航 - website.setNavigations(navigationService.list(new LambdaQueryWrapper().eq(Navigation::getStatus,0))); + final NavigationParam navigationParam = new NavigationParam(); + navigationParam.setHide(0); + website.setNavigations(navigationService.listRel(navigationParam)); + + // 读取幻灯片广告 + website.setAds(adService.list(new LambdaQueryWrapper().like(Ad::getName,"幻灯片").last("limit 10"))); // 提取文章分类作为网站导航 final ArticleCategoryParam param = new ArticleCategoryParam(); diff --git a/src/main/java/com/gxwebsoft/cms/entity/ArticleCategory.java b/src/main/java/com/gxwebsoft/cms/entity/ArticleCategory.java index b9197d9..5973c49 100644 --- a/src/main/java/com/gxwebsoft/cms/entity/ArticleCategory.java +++ b/src/main/java/com/gxwebsoft/cms/entity/ArticleCategory.java @@ -58,6 +58,9 @@ public class ArticleCategory implements Serializable { @ApiModelProperty(value = "用户ID") private Integer userId; + @ApiModelProperty(value = "文章数量") + private Integer count; + @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 b47c212..3e5474c 100644 --- a/src/main/java/com/gxwebsoft/cms/entity/Navigation.java +++ b/src/main/java/com/gxwebsoft/cms/entity/Navigation.java @@ -1,6 +1,7 @@ package com.gxwebsoft.cms.entity; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; @@ -28,6 +29,9 @@ public class Navigation implements Serializable { @TableId(value = "navigation_id", type = IdType.AUTO) private Integer navigationId; + @ApiModelProperty(value = "类型 0菜单 1单页内容 2外部链接") + private Integer type; + @ApiModelProperty(value = "上级id, 0是顶级") private Integer parentId; @@ -52,12 +56,24 @@ public class Navigation implements Serializable { @ApiModelProperty(value = "是否隐藏, 0否, 1是(仅注册路由不显示在左侧菜单)") private Integer hide; + @ApiModelProperty(value = "位置 0不限 1顶部 2底部") + private Integer position; + @ApiModelProperty(value = "菜单侧栏选中的path") private String active; @ApiModelProperty(value = "其它路由元信息") private String meta; + @ApiModelProperty(value = "页面ID") + private Integer pageId; + + @ApiModelProperty(value = "文章分类ID") + private Integer articleCategoryId; + + @ApiModelProperty(value = "文章分类ID") + private Integer articleId; + @ApiModelProperty(value = "用户ID") private Integer userId; @@ -76,4 +92,8 @@ public class Navigation implements Serializable { @ApiModelProperty(value = "注册时间") private Date createTime; + @ApiModelProperty(value = "页面名称") + @TableField(exist = false) + private String pageName; + } diff --git a/src/main/java/com/gxwebsoft/cms/entity/Website.java b/src/main/java/com/gxwebsoft/cms/entity/Website.java index 178fe5c..1a36fa1 100644 --- a/src/main/java/com/gxwebsoft/cms/entity/Website.java +++ b/src/main/java/com/gxwebsoft/cms/entity/Website.java @@ -137,6 +137,10 @@ public class Website implements Serializable { @TableField(exist = false) private List navigations; + @ApiModelProperty(value = "站点广告") + @TableField(exist = false) + private List ads; + @ApiModelProperty(value = "文章分类") @TableField(exist = false) private List categoryList; diff --git a/src/main/java/com/gxwebsoft/cms/mapper/xml/ArticleMapper.xml b/src/main/java/com/gxwebsoft/cms/mapper/xml/ArticleMapper.xml index e6f2882..b0fc76b 100644 --- a/src/main/java/com/gxwebsoft/cms/mapper/xml/ArticleMapper.xml +++ b/src/main/java/com/gxwebsoft/cms/mapper/xml/ArticleMapper.xml @@ -101,6 +101,10 @@ AND a.create_time <= #{param.createTimeEnd} + + AND (a.title LIKE CONCAT('%', #{param.keywords}, '%') + ) + 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 244b7fe..0d9fb35 100644 --- a/src/main/java/com/gxwebsoft/cms/mapper/xml/NavigationMapper.xml +++ b/src/main/java/com/gxwebsoft/cms/mapper/xml/NavigationMapper.xml @@ -4,8 +4,9 @@ - SELECT a.* + SELECT a.*,b.name as pageName FROM cms_navigation a + LEFT JOIN cms_design b ON a.page_id = b.page_id AND a.navigation_id = #{param.navigationId} @@ -17,7 +18,7 @@ AND a.title LIKE CONCAT('%', #{param.title}, '%') - AND a.path LIKE CONCAT('%', #{param.path}, '%') + AND a.path = #{param.path} AND a.component LIKE CONCAT('%', #{param.component}, '%') @@ -34,6 +35,12 @@ AND a.hide = #{param.hide} + + AND a.position = #{param.position} + + + AND a.page_id = #{param.pageId} + AND a.active LIKE CONCAT('%', #{param.active}, '%') diff --git a/src/main/java/com/gxwebsoft/cms/param/NavigationParam.java b/src/main/java/com/gxwebsoft/cms/param/NavigationParam.java index b3463f8..f50f170 100644 --- a/src/main/java/com/gxwebsoft/cms/param/NavigationParam.java +++ b/src/main/java/com/gxwebsoft/cms/param/NavigationParam.java @@ -34,6 +34,7 @@ public class NavigationParam extends BaseParam { private String title; @ApiModelProperty(value = "菜单路由地址") + @QueryField(type = QueryType.EQ) private String path; @ApiModelProperty(value = "菜单组件地址, 目录可为空") @@ -52,6 +53,10 @@ public class NavigationParam extends BaseParam { @QueryField(type = QueryType.EQ) private Integer hide; + @ApiModelProperty(value = "位置, 0不限, 1顶部 2底部") + @QueryField(type = QueryType.EQ) + private Integer position; + @ApiModelProperty(value = "菜单侧栏选中的path") private String active; @@ -73,4 +78,8 @@ public class NavigationParam extends BaseParam { @QueryField(type = QueryType.EQ) private Integer status; + @ApiModelProperty(value = "页面ID") + @QueryField(type = QueryType.EQ) + private Integer pageId; + } diff --git a/src/main/java/com/gxwebsoft/cms/service/impl/NavigationServiceImpl.java b/src/main/java/com/gxwebsoft/cms/service/impl/NavigationServiceImpl.java index 92e9b92..a96da3b 100644 --- a/src/main/java/com/gxwebsoft/cms/service/impl/NavigationServiceImpl.java +++ b/src/main/java/com/gxwebsoft/cms/service/impl/NavigationServiceImpl.java @@ -23,7 +23,7 @@ public class NavigationServiceImpl extends ServiceImpl pageRel(NavigationParam param) { PageParam page = new PageParam<>(param); - page.setDefaultOrder("sort_number desc,create_time desc"); + page.setDefaultOrder("sort_number asc,navigation_id asc"); List list = baseMapper.selectPageRel(page, param); return new PageResult<>(list, page.getTotal()); } @@ -33,7 +33,7 @@ public class NavigationServiceImpl extends ServiceImpl list = baseMapper.selectListRel(param); // 排序 PageParam page = new PageParam<>(); - page.setDefaultOrder("sort_number desc,create_time desc"); + page.setDefaultOrder("sort_number asc,navigation_id asc"); return page.sortRecords(list); } diff --git a/src/main/java/com/gxwebsoft/oa/controller/AppController.java b/src/main/java/com/gxwebsoft/oa/controller/AppController.java index 718855a..b927e79 100644 --- a/src/main/java/com/gxwebsoft/oa/controller/AppController.java +++ b/src/main/java/com/gxwebsoft/oa/controller/AppController.java @@ -46,8 +46,7 @@ public class AppController extends BaseController { public ApiResult> data() { Map data = new HashMap<>(); Integer totalNum = appService.count( - new LambdaQueryWrapper() - .ne(App::getAppStatus, "已下架") + new LambdaQueryWrapper<>() ); Integer totalNum2 = appService.count( new LambdaQueryWrapper()