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.
exam/sys/config/service/impl/SysConfigServiceImpl.java

55 lines
2.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// 定义当前类所在的包
package com.yf.exam.modules.sys.config.service.impl;
// 导入 MyBatis-Plus 框架的查询条件构造器类
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
// 导入 MyBatis-Plus 框架的服务实现基类
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
// 导入自定义的 Bean 映射工具类,用于对象属性的复制
import com.yf.exam.core.utils.BeanMapper;
// 导入系统配置数据传输对象类
import com.yf.exam.modules.sys.config.dto.SysConfigDTO;
// 导入系统配置实体类
import com.yf.exam.modules.sys.config.entity.SysConfig;
// 导入系统配置映射器接口
import com.yf.exam.modules.sys.config.mapper.SysConfigMapper;
// 导入系统配置服务接口
import com.yf.exam.modules.sys.config.service.SysConfigService;
// 导入 Spring 框架的服务注解,将该类标记为服务层组件
import org.springframework.stereotype.Service;
/**
* <p>
* 语言设置 服务实现类,负责处理系统配置的具体业务逻辑
* </p>
*
* @author 聪明笨狗
* @since 2020-04-17 09:12
*/
// 将该类标记为 Spring 服务组件,使其可以被 Spring 容器管理
@Service
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements SysConfigService {
/**
* 查找系统配置信息,返回第一个系统配置的 DTO 对象
*
* @return 系统配置数据传输对象
*/
@Override
public SysConfigDTO find() {
// 创建一个查询条件构造器,用于构建对 SysConfig 实体的查询条件
QueryWrapper<SysConfig> wrapper = new QueryWrapper<>();
// 在查询语句末尾添加 "LIMIT 1",表示只查询一条记录
wrapper.last(" LIMIT 1");
// 调用父类的 getOne 方法,根据查询条件获取一个 SysConfig 实体对象false 表示不严格校验是否只返回一条记录
SysConfig entity = this.getOne(wrapper, false);
// 创建一个新的系统配置数据传输对象
SysConfigDTO dto = new SysConfigDTO();
// 使用 BeanMapper 工具类将 SysConfig 实体对象的属性复制到 SysConfigDTO 对象中
BeanMapper.copy(entity, dto);
// 返回填充好数据的系统配置数据传输对象
return dto;
}
}