1、先建一个数据表实体类
java
package com.qilaike.system.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.qilaike.common.annotation.Excel;
public class SysDept
{
private static final long serialVersionUID = 1L;
/** 用户ID */
private Long technicianId;
/** 门店ID */
private Long deptId;
@Excel(name = "门店")
private String deptName;
/** 用户账号 */
@Excel(name = "用户账号")
private String userName;
/** 用户昵称 */
@Excel(name = "用户昵称")
private String nickName;
/** 姓名 */
@Excel(name = "姓名")
private String idName;
}
2、service目录下新建接口IDeptService,然后扩展mp的IService
java
package com.qilaike.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qilaike.common.core.domain.entity.SysDept;
public interface IDeptService extends IService<SysDept>{
}
3、service目录的impl目录下新建类 DeptServiceImpl,扩展mp的ServiceImpl,实现接口IDeptService,然后注册@Service 注解
java
package com.qilaike.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qilaike.common.core.domain.entity.SysDept;
import com.qilaike.system.mapper.DeptMapper;
import com.qilaike.system.service.IDeptService;
import org.springframework.stereotype.Service;
@Service
public class DeptServiceImpl extends ServiceImpl<DeptMapper, SysDept> implements IDeptService {
}
4、DeptMapper 接口需要扩展mp的BaseMapper接口
java
public interface SysDeptMapper extends BaseMapper<SysDept>
{
}
5、调试一下看看是否可以使用
java
// 部门
LambdaQueryWrapper<SysDept> departmentsLambdaQueryWrapper=new LambdaQueryWrapper<>();
departmentsLambdaQueryWrapper.eq(SysDept::getParentId, deptId);
List<OrgTreeVo> orgTreeVos = new LinkedList<>();
deptService.list(departmentsLambdaQueryWrapper).forEach(dept -> {
orgTreeVos.add(OrgTreeVo.builder()
.id(dept.getDeptId())
.name(dept.getDeptName())
.selected(false)
.type("dept")
.build());
});