|
|
package com.service.impl;
|
|
|
// 定义当前类所在的包路径,表示这是服务实现层的代码
|
|
|
|
|
|
// 导入必要的工具类和服务接口
|
|
|
import java.util.Map;
|
|
|
// Java Map接口,用于存储键值对集合
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
// Spring服务注解,标识该类为服务层组件
|
|
|
|
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
// MyBatis-Plus条件构造器,用于构建查询条件
|
|
|
|
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
|
// MyBatis-Plus分页插件类,用于分页查询
|
|
|
|
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
// MyBatis-Plus服务实现基类,提供通用CRUD操作
|
|
|
|
|
|
import com.dao.ConfigDao;
|
|
|
// 系统配置DAO接口,定义数据库操作方法
|
|
|
|
|
|
import com.entity.ConfigEntity;
|
|
|
// 系统配置实体类,对应数据库表
|
|
|
|
|
|
import com.service.ConfigService;
|
|
|
// 系统配置服务接口,定义业务方法
|
|
|
|
|
|
import com.utils.PageUtils;
|
|
|
// 分页工具类,用于封装分页结果
|
|
|
|
|
|
import com.utils.Query;
|
|
|
// 查询工具类,用于构建查询条件
|
|
|
|
|
|
|
|
|
// 系统配置服务实现类
|
|
|
//继承MyBatis-Plus服务基类并实现自定义服务接口
|
|
|
//@author yangliyuan 作者信息
|
|
|
//@date 2019年10月10日 创建日期
|
|
|
|
|
|
@Service("configService")
|
|
|
// 声明为Spring服务组件,指定bean名称为"configService"
|
|
|
public class ConfigServiceImpl extends ServiceImpl<ConfigDao, ConfigEntity> implements ConfigService {
|
|
|
|
|
|
|
|
|
//分页查询系统配置数据
|
|
|
//param params 查询参数Map,包含:
|
|
|
// - page:当前页码
|
|
|
// - limit:每页记录数
|
|
|
// - 其他查询条件参数
|
|
|
//return 封装了分页信息的PageUtils对象
|
|
|
|
|
|
@Override
|
|
|
public PageUtils queryPage(Map<String, Object> params) {
|
|
|
// 使用MyBatis-Plus的分页查询方法
|
|
|
// 1. 通过Query工具类从params参数中提取分页信息创建Page对象
|
|
|
// 2. 使用EntityWrapper构建查询条件(此处为空条件,查询全部)
|
|
|
// 3. 执行分页查询并将结果封装到Page对象中
|
|
|
Page<ConfigEntity> page = this.selectPage(
|
|
|
new Query<ConfigEntity>(params).getPage(),
|
|
|
new EntityWrapper<ConfigEntity>()
|
|
|
);
|
|
|
|
|
|
// 将MyBatis-Plus的分页对象转换为统一的PageUtils格式返回
|
|
|
return new PageUtils(page);
|
|
|
}
|
|
|
} |