From 3b26eccaa8950d5d394bd523ed0ac4d0280f4b74 Mon Sep 17 00:00:00 2001 From: wangxy <1481820854@qq.com> Date: Mon, 6 Jan 2025 15:14:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/home/HomeController.java | 4 +- .../web/controller/home/LawController.java | 99 +++++++++++++++++++ .../ruoyi/framework/config/ShiroConfig.java | 1 + .../com/ruoyi/system/domain/SysColumnVO.java | 43 ++++++++ .../mapper/system/SysSpecialMapper.xml | 5 +- 5 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/home/LawController.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/SysColumnVO.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/home/HomeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/home/HomeController.java index 421ec63..390bb79 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/home/HomeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/home/HomeController.java @@ -2,6 +2,7 @@ package com.ruoyi.web.controller.home; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.github.pagehelper.PageInfo; import com.github.pagehelper.page.PageMethod; @@ -18,7 +19,9 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -343,5 +346,4 @@ public class HomeController { } - } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/home/LawController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/home/LawController.java new file mode 100644 index 0000000..5abfe5c --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/home/LawController.java @@ -0,0 +1,99 @@ +package com.ruoyi.web.controller.home; + +import cn.hutool.core.convert.Convert; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.github.pagehelper.PageInfo; +import com.github.pagehelper.page.PageMethod; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.system.domain.SysColumn; +import com.ruoyi.system.domain.SysColumnVO; +import com.ruoyi.system.domain.SysSpecial; +import com.ruoyi.system.service.ISysColumnService; +import com.ruoyi.system.service.ISysSpecialService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; + +/** + * ClassName: LawController + * Package: com.ruoyi.web.controller.home + * Description: + * + * @Author wangxy + * @Create 2025/1/6 14:35 + * @Version 1.0 + */ +@Api("法律法规") +@RestController +@RequestMapping("/law") +public class LawController extends BaseController { + + public static final String PAGE_SIZE = "15"; + + + public static final String STATUS = "0"; + + + @Autowired + private ISysColumnService columnService; + + @Autowired + private ISysSpecialService specialService; + + + @ApiOperation("类别树") + @GetMapping("/getTree") + public List getTree(@RequestParam(required = false, defaultValue = "0") String parentId) { + LambdaQueryWrapper tagWrapper = new LambdaQueryWrapper<>(); + tagWrapper.eq(SysColumn::getParentId, parentId); + List datas = columnService.list(tagWrapper); + List tagTreeVOList = new ArrayList<>(Convert.toList(SysColumnVO.class, datas)); + tagTreeVOList.forEach(this::buildChildren); + return tagTreeVOList; + } + + /** + * 构建子节点 + * + * @param pNode 父级 + */ + private void buildChildren(SysColumnVO pNode) { + // 获取子节点 + LambdaQueryWrapper tagWrapper = new LambdaQueryWrapper<>(); + tagWrapper.eq(SysColumn::getParentId, pNode.getColumnId()); + List dataTags = columnService.list(tagWrapper); + List children = Convert.toList(SysColumnVO.class, dataTags); + // 递归获取子节点 + children.forEach(this::buildChildren); + pNode.setChildren(children); + } + + @ApiOperation("专题活动") + @GetMapping("/special") + public R> special(@RequestParam(required = false, defaultValue = "1", value = "p") Integer pageNum, + @RequestParam(required = false, defaultValue = PAGE_SIZE, value = "ps") Integer pageSize, + @RequestParam(required = false) String columnId, + @RequestParam(required = false) String specialTitle) { + PageMethod.startPage(pageNum, pageSize); + SysSpecial sysSpecial = new SysSpecial(); + sysSpecial.setStatus(STATUS); + sysSpecial.setColumnId(columnId); + sysSpecial.setSpecialTitle(specialTitle); + List specialList = specialService.selectSysSpecialList(sysSpecial); + PageInfo page = new PageInfo<>(specialList, pageSize); + return R.ok(page); + } + + @ApiOperation("详细") + @GetMapping("/view/{specialId}") + public R getUser(@PathVariable String specialId) { + return R.ok(specialService.selectSysSpecialById(specialId)); + } + + +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java index e882047..348a2c3 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java @@ -314,6 +314,7 @@ public class ShiroConfig filterChainDefinitionMap.put("/public_view.html", "anon"); filterChainDefinitionMap.put("/profile/**", "anon"); filterChainDefinitionMap.put("/search", "anon"); + filterChainDefinitionMap.put("/law/**", "anon"); // 系统权限列表 // filterChainDefinitionMap.putAll(SpringUtils.getBean(IMenuService.class).selectPermsAll()); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysColumnVO.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysColumnVO.java new file mode 100644 index 0000000..1d331da --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysColumnVO.java @@ -0,0 +1,43 @@ +package com.ruoyi.system.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * 菜单权限表 sys_menu + * + * @author ruoyi + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class SysColumnVO implements Serializable { + private static final long serialVersionUID = 1L; + + + private String columnId; + + /** 菜单名称 */ + private String columnName; + + + private String columnCode; + + + /** 父菜单ID */ + private String parentId; + + + private List children ; + + +} diff --git a/ruoyi-system/src/main/resources/mapper/system/SysSpecialMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysSpecialMapper.xml index 77ecc4a..5a3e171 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysSpecialMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysSpecialMapper.xml @@ -33,7 +33,8 @@