com.didiglobal.logi.security.dao.impl.DeptDaoImpl Maven / Gradle / Ivy
The newest version!
package com.didiglobal.logi.security.dao.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.didiglobal.logi.security.common.entity.dept.Dept;
import com.didiglobal.logi.security.common.entity.dept.DeptBrief;
import com.didiglobal.logi.security.common.po.DeptPO;
import com.didiglobal.logi.security.dao.DeptDao;
import com.didiglobal.logi.security.dao.mapper.DeptMapper;
import com.didiglobal.logi.security.util.CopyBeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author cjm
*/
@Component
public class DeptDaoImpl extends BaseDaoImpl implements DeptDao {
@Autowired
private DeptMapper deptMapper;
private QueryWrapper wrapBriefQuery() {
QueryWrapper queryWrapper = getQueryWrapper();
queryWrapper.select(
FieldConstant.ID, FieldConstant.DEPT_NAME,
FieldConstant.LEAF, FieldConstant.LEVEL, FieldConstant.PARENT_ID
);
return queryWrapper;
}
@Override
public List selectAllAndAscOrderByLevel() {
QueryWrapper queryWrapper = getQueryWrapper();
queryWrapper.orderByAsc(FieldConstant.LEVEL);
return CopyBeanUtil.copyList(deptMapper.selectList(queryWrapper), Dept.class);
}
@Override
public List selectIdListByLikeDeptName(String deptName) {
QueryWrapper queryWrapper = getQueryWrapper();
queryWrapper
.select(FieldConstant.ID)
.like(!StringUtils.isEmpty(deptName), FieldConstant.DEPT_NAME, deptName);
List