feat(消息模块与部门模块): 修改了消息模块的bug并从新建消息接口中独立出添加附件接口,部门模块新添加了部门树返回接口
This commit is contained in:
parent
8d6fa0b244
commit
8706f58ebb
@ -1,69 +0,0 @@
|
|||||||
package com.zsc.edu.gateway.framework;
|
|
||||||
|
|
||||||
import com.zsc.edu.gateway.modules.system.entity.Dept;
|
|
||||||
import com.zsc.edu.gateway.modules.system.entity.User;
|
|
||||||
import com.zsc.edu.gateway.modules.system.vo.DeptTree;
|
|
||||||
import com.zsc.edu.gateway.modules.system.vo.UserTree;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
import java.util.function.BiFunction;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author zhuang
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class DeptTreeUtil {
|
|
||||||
|
|
||||||
public static <E> List<E> makeTree(List<E> list, Predicate<E> rootCheck, BiFunction<E, E, Boolean> parentCheck, BiConsumer<E, List<E>> setSubChildren) {
|
|
||||||
return list.stream()
|
|
||||||
.filter(rootCheck)
|
|
||||||
.peek(x -> setSubChildren.accept(x, makeChildren(x, list, parentCheck, setSubChildren)))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <E> List<E> makeChildren(E parent, List<E> allData, BiFunction<E, E, Boolean> parentCheck, BiConsumer<E, List<E>> setSubChildren) {
|
|
||||||
return allData.stream()
|
|
||||||
.filter(x -> parentCheck.apply(parent, x))
|
|
||||||
.peek(x -> setSubChildren.accept(x, makeChildren(x, allData, parentCheck, setSubChildren)))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<DeptTree> buildDeptTree(List<Dept> depots, Map<Long, List<User>> userMap) {
|
|
||||||
List<DeptTree> deptTrees = depots.stream()
|
|
||||||
.map(DeptTreeUtil::convertToDeptTree)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
deptTrees.forEach(deptTree -> {
|
|
||||||
List<User> users = userMap.getOrDefault(deptTree.getId(), Collections.emptyList());
|
|
||||||
deptTree.setMembers(users.stream()
|
|
||||||
.map(DeptTreeUtil::convertToUserTree)
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
});
|
|
||||||
|
|
||||||
return makeTree(
|
|
||||||
deptTrees,
|
|
||||||
deptTree -> deptTree.getPid() == null || deptTree.getPid() == 0L,
|
|
||||||
(parent, child) -> parent.getId().equals(child.getPid()),
|
|
||||||
DeptTree::setChildren
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static DeptTree convertToDeptTree(Dept dept) {
|
|
||||||
DeptTree deptTree = new DeptTree();
|
|
||||||
deptTree.setId(dept.getId());
|
|
||||||
deptTree.setPid(dept.getPid());
|
|
||||||
deptTree.setName(dept.getName());
|
|
||||||
return deptTree;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static UserTree convertToUserTree(User user) {
|
|
||||||
UserTree userTree = new UserTree();
|
|
||||||
userTree.setId(user.getId());
|
|
||||||
userTree.setName(user.getName());
|
|
||||||
return userTree;
|
|
||||||
}
|
|
||||||
}
|
|
130
src/main/java/com/zsc/edu/gateway/framework/TreeUtil.java
Normal file
130
src/main/java/com/zsc/edu/gateway/framework/TreeUtil.java
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
package com.zsc.edu.gateway.framework;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 树操作方法工具类
|
||||||
|
* @Copyright: Copyright (c) 赵侠客
|
||||||
|
* @Date: 2024-07-22 10:42
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public class TreeUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将list合成树
|
||||||
|
*
|
||||||
|
* @param list 需要合成树的List
|
||||||
|
* @param rootCheck 判断E中为根节点的条件,如:x->x.getPId()==-1L , x->x.getParentId()==null,x->x.getParentMenuId()==0
|
||||||
|
* @param parentCheck 判断E中为父节点条件,如:(x,y)->x.getId().equals(y.getPId())
|
||||||
|
* @param setSubChildren E中设置下级数据方法,如:Menu::setSubMenus
|
||||||
|
* @param <E> 泛型实体对象
|
||||||
|
* @return 合成好的树
|
||||||
|
*/
|
||||||
|
public static <E> List<E> makeTree(List<E> list, Predicate<E> rootCheck, BiFunction<E, E, Boolean> parentCheck, BiConsumer<E, List<E>> setSubChildren) {
|
||||||
|
return list.stream().filter(rootCheck).peek(x -> setSubChildren.accept(x, makeChildren(x, list, parentCheck, setSubChildren))).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将树打平成tree
|
||||||
|
*
|
||||||
|
* @param tree 需要打平的树
|
||||||
|
* @param getSubChildren 设置下级数据方法,如:Menu::getSubMenus,x->x.setSubMenus(null)
|
||||||
|
* @param setSubChildren 将下级数据置空方法,如:x->x.setSubMenus(null)
|
||||||
|
* @param <E> 泛型实体对象
|
||||||
|
* @return 打平后的数据
|
||||||
|
*/
|
||||||
|
public static <E> List<E> flat(List<E> tree, Function<E, List<E>> getSubChildren, Consumer<E> setSubChildren) {
|
||||||
|
List<E> res = new ArrayList<>();
|
||||||
|
forPostOrder(tree, item -> {
|
||||||
|
setSubChildren.accept(item);
|
||||||
|
res.add(item);
|
||||||
|
}, getSubChildren);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前序遍历
|
||||||
|
*
|
||||||
|
* @param tree 需要遍历的树
|
||||||
|
* @param consumer 遍历后对单个元素的处理方法,如:x-> System.out.println(x)、 System.out::println打印元素
|
||||||
|
* @param setSubChildren 设置下级数据方法,如:Menu::getSubMenus,x->x.setSubMenus(null)
|
||||||
|
* @param <E> 泛型实体对象
|
||||||
|
*/
|
||||||
|
public static <E> void forPreOrder(List<E> tree, Consumer<E> consumer, Function<E, List<E>> setSubChildren) {
|
||||||
|
for (E l : tree) {
|
||||||
|
consumer.accept(l);
|
||||||
|
List<E> es = setSubChildren.apply(l);
|
||||||
|
if (es != null && es.size() > 0) {
|
||||||
|
forPreOrder(es, consumer, setSubChildren);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 层序遍历
|
||||||
|
*
|
||||||
|
* @param tree 需要遍历的树
|
||||||
|
* @param consumer 遍历后对单个元素的处理方法,如:x-> System.out.println(x)、 System.out::println打印元素
|
||||||
|
* @param setSubChildren 设置下级数据方法,如:Menu::getSubMenus,x->x.setSubMenus(null)
|
||||||
|
* @param <E> 泛型实体对象
|
||||||
|
*/
|
||||||
|
public static <E> void forLevelOrder(List<E> tree, Consumer<E> consumer, Function<E, List<E>> setSubChildren) {
|
||||||
|
Queue<E> queue = new LinkedList<>(tree);
|
||||||
|
while (!queue.isEmpty()) {
|
||||||
|
E item = queue.poll();
|
||||||
|
consumer.accept(item);
|
||||||
|
List<E> childList = setSubChildren.apply(item);
|
||||||
|
if (childList != null && !childList.isEmpty()) {
|
||||||
|
queue.addAll(childList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后序遍历
|
||||||
|
*
|
||||||
|
* @param tree 需要遍历的树
|
||||||
|
* @param consumer 遍历后对单个元素的处理方法,如:x-> System.out.println(x)、 System.out::println打印元素
|
||||||
|
* @param setSubChildren 设置下级数据方法,如:Menu::getSubMenus,x->x.setSubMenus(null)
|
||||||
|
* @param <E> 泛型实体对象
|
||||||
|
*/
|
||||||
|
public static <E> void forPostOrder(List<E> tree, Consumer<E> consumer, Function<E, List<E>> setSubChildren) {
|
||||||
|
for (E item : tree) {
|
||||||
|
List<E> childList = setSubChildren.apply(item);
|
||||||
|
if (childList != null && !childList.isEmpty()) {
|
||||||
|
forPostOrder(childList, consumer, setSubChildren);
|
||||||
|
}
|
||||||
|
consumer.accept(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对树所有子节点按comparator排序
|
||||||
|
*
|
||||||
|
* @param tree 需要排序的树
|
||||||
|
* @param comparator 排序规则Comparator,如:Comparator.comparing(MenuVo::getRank)按Rank正序 ,(x,y)->y.getRank().compareTo(x.getRank()),按Rank倒序
|
||||||
|
* @param getChildren 获取下级数据方法,如:MenuVo::getSubMenus
|
||||||
|
* @param <E> 泛型实体对象
|
||||||
|
* @return 排序好的树
|
||||||
|
*/
|
||||||
|
public static <E> List<E> sort(List<E> tree, Comparator<? super E> comparator, Function<E, List<E>> getChildren) {
|
||||||
|
for (E item : tree) {
|
||||||
|
List<E> childList = getChildren.apply(item);
|
||||||
|
if (childList != null && !childList.isEmpty()) {
|
||||||
|
sort(childList, comparator, getChildren);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tree.sort(comparator);
|
||||||
|
return tree;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <E> List<E> makeChildren(E parent, List<E> allData, BiFunction<E, E, Boolean> parentCheck, BiConsumer<E, List<E>> children) {
|
||||||
|
return allData.stream().filter(x -> parentCheck.apply(parent, x)).peek(x -> children.accept(x, makeChildren(x, allData, parentCheck, children))).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
@ -116,17 +116,17 @@ public class UserMessageController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理员为消息添加附件
|
// * 管理员为消息添加附件
|
||||||
*
|
// *
|
||||||
* @param messageId 消息ID
|
// * @param messageId 消息ID
|
||||||
* @param attachmentIds 附件ID集合
|
// * @param attachmentIds 附件ID集合
|
||||||
* @return 消息列表
|
// * @return 消息列表
|
||||||
*/
|
// */
|
||||||
@PostMapping("/attachment/{messageId}")
|
// @PostMapping("/attachment/{messageId}")
|
||||||
@PreAuthorize("hasAuthority('MESSAGE_CREATE')")
|
// @PreAuthorize("hasAuthority('MESSAGE_CREATE')")
|
||||||
public Boolean insertInto(@PathVariable("messageId") Long messageId, @RequestBody List<String> attachmentIds) {
|
// public Boolean insertInto(@PathVariable("messageId") Long messageId, @RequestBody List<String> attachmentIds) {
|
||||||
return service.insertInto(messageId, attachmentIds);
|
// return service.insertInto(messageId, attachmentIds);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取消息推送方式
|
* 获取消息推送方式
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
package com.zsc.edu.gateway.modules.system.controller;
|
package com.zsc.edu.gateway.modules.system.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.zsc.edu.gateway.exception.ConstraintException;
|
import com.zsc.edu.gateway.exception.ConstraintException;
|
||||||
import com.zsc.edu.gateway.modules.system.dto.DeptDto;
|
import com.zsc.edu.gateway.modules.system.dto.DeptDto;
|
||||||
import com.zsc.edu.gateway.modules.system.entity.Dept;
|
import com.zsc.edu.gateway.modules.system.entity.Dept;
|
||||||
import com.zsc.edu.gateway.modules.system.entity.User;
|
import com.zsc.edu.gateway.modules.system.entity.User;
|
||||||
import com.zsc.edu.gateway.modules.system.query.DeptQuery;
|
|
||||||
import com.zsc.edu.gateway.modules.system.service.DeptService;
|
import com.zsc.edu.gateway.modules.system.service.DeptService;
|
||||||
import com.zsc.edu.gateway.modules.system.service.UserService;
|
import com.zsc.edu.gateway.modules.system.service.UserService;
|
||||||
import com.zsc.edu.gateway.modules.system.vo.DeptTree;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -35,7 +32,7 @@ public class DeptController {
|
|||||||
* @return 部门列表
|
* @return 部门列表
|
||||||
*/
|
*/
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public List<DeptTree> getDeptTree() {
|
public List<Dept> getDeptTree() {
|
||||||
return service.getDeptTree();
|
return service.getDeptTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,4 @@ public class Dept extends BaseEntity {
|
|||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
public List<Dept> children = new ArrayList<>(0);
|
public List<Dept> children = new ArrayList<>(0);
|
||||||
|
|
||||||
@TableField(exist = false)
|
|
||||||
public List<User> members = new ArrayList<>(0);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,6 @@ package com.zsc.edu.gateway.modules.system.repo;
|
|||||||
|
|
||||||
import com.zsc.edu.gateway.modules.system.entity.Dept;
|
import com.zsc.edu.gateway.modules.system.entity.Dept;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.zsc.edu.gateway.modules.system.entity.User;
|
|
||||||
import org.apache.ibatis.annotations.Many;
|
|
||||||
import org.apache.ibatis.annotations.Result;
|
|
||||||
import org.apache.ibatis.annotations.Results;
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -19,6 +14,5 @@ import java.util.List;
|
|||||||
* @since 2023-04-06
|
* @since 2023-04-06
|
||||||
*/
|
*/
|
||||||
public interface DeptRepository extends BaseMapper<Dept> {
|
public interface DeptRepository extends BaseMapper<Dept> {
|
||||||
@Select("SELECT d.*, u.* FROM sys_dept d LEFT JOIN sys_user u ON d.id = u.dept_id")
|
List<Dept> selectDeptTree();
|
||||||
List<Dept> selectAllWithMembers();
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package com.zsc.edu.gateway.modules.system.service;
|
|||||||
import com.zsc.edu.gateway.modules.system.dto.DeptDto;
|
import com.zsc.edu.gateway.modules.system.dto.DeptDto;
|
||||||
import com.zsc.edu.gateway.modules.system.entity.Dept;
|
import com.zsc.edu.gateway.modules.system.entity.Dept;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.zsc.edu.gateway.modules.system.vo.DeptTree;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -31,13 +30,11 @@ public interface DeptService extends IService<Dept> {
|
|||||||
Boolean edit(DeptDto dto, Long id);
|
Boolean edit(DeptDto dto, Long id);
|
||||||
|
|
||||||
Boolean toggle(Long id);
|
Boolean toggle(Long id);
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 生成部门树结构
|
|
||||||
// * @param id
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
//// Dept listTree(Long id);
|
|
||||||
|
|
||||||
List<DeptTree> getDeptTree();
|
/**
|
||||||
|
* 生成部门树结构
|
||||||
|
*
|
||||||
|
* @return Dept
|
||||||
|
*/
|
||||||
|
List<Dept> getDeptTree();
|
||||||
}
|
}
|
||||||
|
@ -2,23 +2,17 @@ package com.zsc.edu.gateway.modules.system.service.impl;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.zsc.edu.gateway.exception.ConstraintException;
|
import com.zsc.edu.gateway.exception.ConstraintException;
|
||||||
import com.zsc.edu.gateway.framework.DeptTreeUtil;
|
import com.zsc.edu.gateway.framework.TreeUtil;
|
||||||
import com.zsc.edu.gateway.modules.system.dto.DeptDto;
|
import com.zsc.edu.gateway.modules.system.dto.DeptDto;
|
||||||
import com.zsc.edu.gateway.modules.system.entity.Dept;
|
import com.zsc.edu.gateway.modules.system.entity.Dept;
|
||||||
import com.zsc.edu.gateway.modules.system.entity.User;
|
|
||||||
import com.zsc.edu.gateway.modules.system.mapper.DeptMapper;
|
import com.zsc.edu.gateway.modules.system.mapper.DeptMapper;
|
||||||
import com.zsc.edu.gateway.modules.system.repo.DeptRepository;
|
import com.zsc.edu.gateway.modules.system.repo.DeptRepository;
|
||||||
import com.zsc.edu.gateway.modules.system.repo.UserRepository;
|
|
||||||
import com.zsc.edu.gateway.modules.system.service.DeptService;
|
import com.zsc.edu.gateway.modules.system.service.DeptService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.zsc.edu.gateway.modules.system.vo.DeptTree;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -34,7 +28,6 @@ public class DeptServiceImpl extends ServiceImpl<DeptRepository, Dept> implement
|
|||||||
|
|
||||||
private final DeptMapper mapper;
|
private final DeptMapper mapper;
|
||||||
private final DeptRepository repo;
|
private final DeptRepository repo;
|
||||||
private final UserRepository userRepository;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dept create(DeptDto dto) {
|
public Dept create(DeptDto dto) {
|
||||||
@ -64,14 +57,14 @@ public class DeptServiceImpl extends ServiceImpl<DeptRepository, Dept> implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DeptTree> getDeptTree() {
|
public List<Dept> getDeptTree() {
|
||||||
List<Dept> depots = repo.selectList(null);
|
List<Dept> deptTrees = repo.selectDeptTree();
|
||||||
List<User> users = userRepository.selectList(null);
|
return TreeUtil.makeTree(
|
||||||
Map<Long, List<User>> userMap = new HashMap<>();
|
deptTrees,
|
||||||
for (User user : users) {
|
department -> department.getPid() == null || department.getPid() == -1L,
|
||||||
userMap.computeIfAbsent(user.getDeptId(), k -> new ArrayList<>()).add(user);
|
(parent, child) -> parent.getId().equals(child.getPid()),
|
||||||
}
|
Dept::setChildren
|
||||||
return DeptTreeUtil.buildDeptTree(depots, userMap);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
package com.zsc.edu.gateway.modules.system.vo;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.zsc.edu.gateway.modules.system.entity.User;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author zhuang
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class DeptTree {
|
|
||||||
|
|
||||||
private Long id;
|
|
||||||
@JsonIgnore
|
|
||||||
private Long pid;
|
|
||||||
private String name;
|
|
||||||
List<DeptTree> children = new ArrayList<>();
|
|
||||||
List<UserTree> members = new ArrayList<>();
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package com.zsc.edu.gateway.modules.system.vo;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author zhuang
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class UserTree {
|
|
||||||
private Long id;
|
|
||||||
private String name;
|
|
||||||
}
|
|
@ -1,9 +1,37 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.zsc.edu.gateway.modules.system.repo.DeptRepository">
|
<mapper namespace="com.zsc.edu.gateway.modules.system.repo.DeptRepository">
|
||||||
<select id="selectAllWithMembers" resultType="com.zsc.edu.gateway.modules.system.entity.Dept">
|
|
||||||
SELECT d.*, u.*
|
<resultMap id="deptMap" type="com.zsc.edu.gateway.modules.system.entity.Dept">
|
||||||
FROM sys_dept d
|
<id column="id" property="id"/>
|
||||||
LEFT JOIN sys_user u ON d.id = u.dept_id
|
<result column="sub_count" property="subCount"/>
|
||||||
|
<result column="pid" property="pid"/>
|
||||||
|
<result column="name" property="name"/>
|
||||||
|
<result column="dept_sort" property="deptSort"/>
|
||||||
|
<result column="enabled" property="enabled"/>
|
||||||
|
<result column="create_by" property="createBy"/>
|
||||||
|
<result column="update_by" property="updateBy"/>
|
||||||
|
<result column="create_time" property="createTime"/>
|
||||||
|
<result column="update_time" property="updateTime"/>
|
||||||
|
<result column="remark" property="remark"/>
|
||||||
|
<collection property="children" ofType="com.zsc.edu.gateway.modules.system.entity.Dept">
|
||||||
|
<id column="id" property="id"/>
|
||||||
|
<result column="sub_count" property="subCount"/>
|
||||||
|
<result column="pid" property="pid"/>
|
||||||
|
<result column="name" property="name"/>
|
||||||
|
<result column="dept_sort" property="deptSort"/>
|
||||||
|
<result column="enabled" property="enabled"/>
|
||||||
|
<result column="create_by" property="createBy"/>
|
||||||
|
<result column="update_by" property="updateBy"/>
|
||||||
|
<result column="create_time" property="createTime"/>
|
||||||
|
<result column="update_time" property="updateTime"/>
|
||||||
|
<result column="remark" property="remark"/>
|
||||||
|
</collection>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="selectDeptTree" resultMap="deptMap">
|
||||||
|
SELECT sd.*
|
||||||
|
FROM sys_dept sd
|
||||||
|
left join sys_dept d on sd.id = d.pid
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user