1、先建一个数据表实体类
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
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 注解
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接口文章来源:https://www.toymoban.com/news/detail-791430.html
public interface SysDeptMapper extends BaseMapper<SysDept>
{
}
5、调试一下看看是否可以使用文章来源地址https://www.toymoban.com/news/detail-791430.html
// 部门
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());
});
到了这里,关于spring boot mybatis-plus操作实践的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!