Skip to content

Commit

Permalink
feat: 查询部门 tree 支持过滤部门名
Browse files Browse the repository at this point in the history
  • Loading branch information
cadecode committed Nov 26, 2023
1 parent 4657039 commit 87dd2b1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
*/
public class SysDeptVo {

@Data
public static class SysDeptTreeReqVo {
private String deptName;
}

@Data
public static class SysDeptTreeResVo {
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat;
import com.github.cadecode.uniboot.framework.svc.bean.po.SysDept;
import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDeptVo.SysDeptAddReqVo;
import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDeptVo.SysDeptQueryResVo;
import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDeptVo.SysDeptTreeResVo;
import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDeptVo.SysDeptUpdateReqVo;
import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDeptVo.*;
import com.github.cadecode.uniboot.framework.svc.convert.SysDeptConvert;
import com.github.cadecode.uniboot.framework.svc.service.SysDeptService;
import io.swagger.annotations.Api;
Expand Down Expand Up @@ -44,8 +41,8 @@ public class SysDeptController {

@ApiOperation("查询部门列表(树状)")
@PostMapping("list_tree_vo")
public List<SysDeptTreeResVo> listTreeVo() {
return sysDeptService.listTreeVo();
public List<SysDeptTreeResVo> listTreeVo(@RequestBody @Valid SysDeptTreeReqVo reqVo) {
return sysDeptService.listTreeVo(reqVo);
}

@ApiOperation("更新部门")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.baomidou.mybatisplus.extension.service.IService;
import com.github.cadecode.uniboot.framework.svc.bean.po.SysDept;
import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDeptVo.SysDeptTreeReqVo;
import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDeptVo.SysDeptTreeResVo;

import java.util.List;
Expand All @@ -14,5 +15,5 @@
*/
public interface SysDeptService extends IService<SysDept> {

List<SysDeptTreeResVo> listTreeVo();
List<SysDeptTreeResVo> listTreeVo(SysDeptTreeReqVo reqVo);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cn.hutool.core.util.ObjUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.cadecode.uniboot.framework.svc.bean.po.SysDept;
import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDeptVo.SysDeptTreeReqVo;
import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDeptVo.SysDeptTreeResVo;
import com.github.cadecode.uniboot.framework.svc.convert.SysDeptConvert;
import com.github.cadecode.uniboot.framework.svc.mapper.SysDeptMapper;
Expand All @@ -22,8 +23,11 @@
@Service
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptService {
@Override
public List<SysDeptTreeResVo> listTreeVo() {
List<SysDept> poList = list().stream()
public List<SysDeptTreeResVo> listTreeVo(SysDeptTreeReqVo reqVo) {
List<SysDept> poList = lambdaQuery()
.likeRight(ObjUtil.isNotEmpty(reqVo.getDeptName()), SysDept::getDeptName, reqVo.getDeptName())
.list()
.stream()
.sorted(Comparator.comparing(SysDept::getOrderNum))
.collect(Collectors.toList());
List<SysDeptTreeResVo> treeResVoList = SysDeptConvert.INSTANCE.poToTreeResVo(poList);
Expand Down

0 comments on commit 87dd2b1

Please sign in to comment.