You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
3.8 KiB
92 lines
3.8 KiB
// 声明该类所在的包为 com.service.impl
|
|
package com.service.impl;
|
|
|
|
// 导入 Spring 框架的 @Service 注解,用于将该类标记为服务层组件
|
|
import org.springframework.stereotype.Service;
|
|
// 导入 Java 中的 Map 接口,用于处理键值对数据
|
|
import java.util.Map;
|
|
// 导入 Java 中的 List 接口,用于处理列表数据
|
|
import java.util.List;
|
|
|
|
// 导入 MyBatis-Plus 的 Wrapper 接口,用于封装查询条件
|
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
|
// 导入 MyBatis-Plus 的 EntityWrapper 类,用于构建查询条件
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
// 导入 MyBatis-Plus 的 Page 类,用于实现分页查询
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
// 导入 MyBatis-Plus 的 ServiceImpl 类,作为服务实现类的基类
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
// 导入自定义的分页工具类
|
|
import com.utils.PageUtils;
|
|
// 导入自定义的查询工具类
|
|
import com.utils.Query;
|
|
|
|
// 导入用户数据访问对象
|
|
import com.dao.YonghuDao;
|
|
// 导入用户实体类
|
|
import com.entity.YonghuEntity;
|
|
// 导入用户服务接口
|
|
import com.service.YonghuService;
|
|
// 导入用户值对象类
|
|
import com.entity.vo.YonghuVO;
|
|
// 导入用户视图类
|
|
import com.entity.view.YonghuView;
|
|
|
|
// 使用 @Service 注解,将该类注册为 Spring 服务,服务名为 yonghuService
|
|
@Service("yonghuService")
|
|
// 定义 YonghuServiceImpl 类,继承自 MyBatis-Plus 的 ServiceImpl 类,并实现 YonghuService 接口
|
|
public class YonghuServiceImpl extends ServiceImpl<YonghuDao, YonghuEntity> implements YonghuService {
|
|
|
|
// 重写 queryPage 方法,根据传入的参数进行分页查询用户实体数据
|
|
@Override
|
|
public PageUtils queryPage(Map<String, Object> params) {
|
|
// 创建一个分页对象,通过 Query 工具类根据参数生成
|
|
Page<YonghuEntity> page = this.selectPage(
|
|
new Query<YonghuEntity>(params).getPage(),
|
|
// 创建一个空的查询条件包装器
|
|
new EntityWrapper<YonghuEntity>()
|
|
);
|
|
// 将分页对象封装到 PageUtils 工具类中并返回
|
|
return new PageUtils(page);
|
|
}
|
|
|
|
// 重写 queryPage 方法,根据传入的参数和查询条件进行分页查询用户视图数据
|
|
@Override
|
|
public PageUtils queryPage(Map<String, Object> params, Wrapper<YonghuEntity> wrapper) {
|
|
// 创建一个分页对象,通过 Query 工具类根据参数生成,用于存储用户视图数据
|
|
Page<YonghuView> page = new Query<YonghuView>(params).getPage();
|
|
// 调用基础映射器的 selectListView 方法,根据分页和查询条件获取用户视图列表,并设置到分页对象中
|
|
page.setRecords(baseMapper.selectListView(page, wrapper));
|
|
// 将分页对象封装到 PageUtils 工具类中并返回
|
|
PageUtils pageUtil = new PageUtils(page);
|
|
return pageUtil;
|
|
}
|
|
|
|
// 重写 selectListVO 方法,根据查询条件查询用户值对象列表
|
|
@Override
|
|
public List<YonghuVO> selectListVO(Wrapper<YonghuEntity> wrapper) {
|
|
// 调用基础映射器的 selectListVO 方法进行查询
|
|
return baseMapper.selectListVO(wrapper);
|
|
}
|
|
|
|
// 重写 selectVO 方法,根据查询条件查询单个用户值对象
|
|
@Override
|
|
public YonghuVO selectVO(Wrapper<YonghuEntity> wrapper) {
|
|
// 调用基础映射器的 selectVO 方法进行查询
|
|
return baseMapper.selectVO(wrapper);
|
|
}
|
|
|
|
// 重写 selectListView 方法,根据查询条件查询用户视图列表
|
|
@Override
|
|
public List<YonghuView> selectListView(Wrapper<YonghuEntity> wrapper) {
|
|
// 调用基础映射器的 selectListView 方法进行查询
|
|
return baseMapper.selectListView(wrapper);
|
|
}
|
|
|
|
// 重写 selectView 方法,根据查询条件查询单个用户视图
|
|
@Override
|
|
public YonghuView selectView(Wrapper<YonghuEntity> wrapper) {
|
|
// 调用基础映射器的 selectView 方法进行查询
|
|
return baseMapper.selectView(wrapper);
|
|
}
|
|
} |