diff --git a/src/main/java/com/jsnjfz/manage/modular/system/controller/CategoryController.java b/src/main/java/com/jsnjfz/manage/modular/system/controller/CategoryController.java index 763527c..4574a45 100644 --- a/src/main/java/com/jsnjfz/manage/modular/system/controller/CategoryController.java +++ b/src/main/java/com/jsnjfz/manage/modular/system/controller/CategoryController.java @@ -6,6 +6,8 @@ import cn.stylefeng.roses.kernel.model.exception.ServiceException; import com.jsnjfz.manage.core.common.exception.BizExceptionEnum; import com.jsnjfz.manage.core.common.node.ZTreeNode; +import com.jsnjfz.manage.core.shiro.ShiroKit; +import com.jsnjfz.manage.core.shiro.ShiroUser; import com.jsnjfz.manage.modular.system.model.Category; import com.jsnjfz.manage.modular.system.service.impl.CategoryServiceImpl; import org.springframework.beans.factory.annotation.Autowired; @@ -19,6 +21,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; /** * @Author fz @@ -51,6 +54,10 @@ public String index() { public Object list(@RequestParam(required = false) String title) { Map map = new HashMap(); map.put("title", title); + ShiroUser shiroUser = ShiroKit.getUser(); + if (Objects.nonNull(shiroUser)){ + map.put("userId", shiroUser.getId()); + } List> mapList = categoryService.getCatogry(map); return super.warpObject(new BaseControllerWrapper(mapList) { @Override diff --git a/src/main/java/com/jsnjfz/manage/modular/system/controller/IndexController.java b/src/main/java/com/jsnjfz/manage/modular/system/controller/IndexController.java index 1f982b3..feefba3 100644 --- a/src/main/java/com/jsnjfz/manage/modular/system/controller/IndexController.java +++ b/src/main/java/com/jsnjfz/manage/modular/system/controller/IndexController.java @@ -17,6 +17,8 @@ import cn.stylefeng.roses.core.base.controller.BaseController; import com.jsnjfz.manage.core.common.node.MenuNode; +import com.jsnjfz.manage.core.shiro.ShiroKit; +import com.jsnjfz.manage.core.shiro.ShiroUser; import com.jsnjfz.manage.modular.system.model.Category; import com.jsnjfz.manage.modular.system.service.IOperationLogService; import com.jsnjfz.manage.modular.system.service.impl.CategoryServiceImpl; @@ -27,6 +29,8 @@ import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Objects; /** @@ -45,9 +49,14 @@ public class IndexController extends BaseController { */ @RequestMapping("/") public String index(Model model) { - List menus = categoryService.getCatogryNode(new HashMap<>()); + ShiroUser shiroUser = ShiroKit.getUser(); + Map params = new HashMap<>(); + if (Objects.nonNull(shiroUser)){ + params.put("userId", shiroUser.getId()); + } + List menus = categoryService.getCatogryNode(params); List titles = MenuNode.buildTitle(menus); - List categorySiteList = categoryService.getCatogrySite(null); + List categorySiteList = categoryService.getCatogrySite(params); model.addAttribute("categorySiteList", categorySiteList); model.addAttribute("titles", titles); System.out.println(titles); diff --git a/src/main/java/com/jsnjfz/manage/modular/system/dao/UserCategoryRelationMapper.java b/src/main/java/com/jsnjfz/manage/modular/system/dao/UserCategoryRelationMapper.java new file mode 100644 index 0000000..8b7548d --- /dev/null +++ b/src/main/java/com/jsnjfz/manage/modular/system/dao/UserCategoryRelationMapper.java @@ -0,0 +1,17 @@ +package com.jsnjfz.manage.modular.system.dao; + +import com.jsnjfz.manage.modular.system.model.UserCategoryRelation; + +/** +* @author Administrator +* @description 针对表【user_category_relation】的数据库操作Mapper +* @createDate 2024-07-02 16:52:21 +* @Entity com.jsnjfz.manage.modular.system.model.UserCategoryRelation +*/ +public interface UserCategoryRelationMapper extends BaseDao { + +} + + + + diff --git a/src/main/java/com/jsnjfz/manage/modular/system/dao/mapping/CategoryMapper.xml b/src/main/java/com/jsnjfz/manage/modular/system/dao/mapping/CategoryMapper.xml index 1b38828..98c9650 100644 --- a/src/main/java/com/jsnjfz/manage/modular/system/dao/mapping/CategoryMapper.xml +++ b/src/main/java/com/jsnjfz/manage/modular/system/dao/mapping/CategoryMapper.xml @@ -19,8 +19,11 @@ select - id,title,sort,icon,create_time createTime,parent_id parentId,levels - from category - order by sort + c.id,c.title,c.sort,c.icon,c.create_time createTime,c.parent_id parentId,c.levels + from category c left join user_category_relation ur on c.id = ur.category_id + where 1=1 + + and ur.user_id = #{userId} + + order by c.sort @@ -76,10 +83,23 @@ diff --git a/src/main/java/com/jsnjfz/manage/modular/system/dao/mapping/SiteMapper.xml b/src/main/java/com/jsnjfz/manage/modular/system/dao/mapping/SiteMapper.xml index 7f3306e..e45be91 100644 --- a/src/main/java/com/jsnjfz/manage/modular/system/dao/mapping/SiteMapper.xml +++ b/src/main/java/com/jsnjfz/manage/modular/system/dao/mapping/SiteMapper.xml @@ -13,7 +13,11 @@