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/repo/service/impl/RepoServiceImpl.java

54 lines
1.8 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.repo.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yf.exam.core.api.dto.PagingReqDTO;
import com.yf.exam.core.utils.BeanMapper;
import com.yf.exam.modules.repo.dto.RepoDTO;
import com.yf.exam.modules.repo.dto.request.RepoReqDTO;
import com.yf.exam.modules.repo.dto.response.RepoRespDTO;
import com.yf.exam.modules.repo.entity.Repo;
import com.yf.exam.modules.repo.mapper.RepoMapper;
import com.yf.exam.modules.repo.service.RepoService;
import org.springframework.stereotype.Service;
/**
* <p>
* 题库服务实现类,实现了 RepoService 接口,继承自 MyBatis-Plus 的 ServiceImpl
* 用于处理题库相关的业务逻辑,与数据库进行交互。
* </p>
*
* @author 聪明笨狗
* @since 2020-05-25 13:23
*/
@Service
public class RepoServiceImpl extends ServiceImpl<RepoMapper, Repo> implements RepoService {
/**
* 分页查询题库信息
*
* @param reqDTO 包含分页信息和查询参数的请求对象
* @return 包含分页结果的 IPage 对象,其中元素为 RepoRespDTO 类型
*/
@Override
public IPage<RepoRespDTO> paging(PagingReqDTO<RepoReqDTO> reqDTO) {
// 调用 RepoMapper 的 paging 方法进行分页查询,传入分页对象和查询参数
return baseMapper.paging(reqDTO.toPage(), reqDTO.getParams());
}
/**
* 保存或更新题库信息
*
* @param reqDTO 包含题库信息的请求数据传输对象
*/
@Override
public void save(RepoDTO reqDTO) {
// 复制 DTO 对象的属性到实体对象
Repo entity = new Repo();
BeanMapper.copy(reqDTO, entity);
// 调用 MyBatis-Plus 的 saveOrUpdate 方法保存或更新实体对象
this.saveOrUpdate(entity);
}
}