package com.bc.exam.modules.tsjxxb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bc.exam.core.api.dto.PagingReqDTO;
import com.bc.exam.core.utils.StringUtils;
import com.bc.exam.modules.tsjxxb.entity.TSjxxb;
import com.bc.exam.modules.tsjxxb.mapper.TSjxxbMapper;
import com.bc.exam.modules.tsjxxb.service.TSjxxbService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * @Description 描述:书籍信息表服务实现类
 * @Author A贾宇婷034244310
 * @Date 20260615
 */
@Service
public class TSjxxbServiceImpl extends ServiceImpl<TSjxxbMapper, TSjxxb> implements TSjxxbService {

    @Override
    public IPage<TSjxxb> paging(PagingReqDTO<TSjxxb> reqDTO) {
        //创建分页对象
        Page<TSjxxb> query = new Page<>(reqDTO.getCurrent(), reqDTO.getSize());

        //查询条件
        QueryWrapper<TSjxxb> wrapper = new QueryWrapper<>();

        TSjxxb params = reqDTO.getParams();
        if(!StringUtils.isBlank(params.getId())){
            wrapper.eq("id", params.getId());
        }
        if(!StringUtils.isBlank(params.getBType())){
            wrapper.eq("b_type", params.getBType());
        }

        wrapper.like(!StringUtils.isBlank(params.getIsbn()),"isbn", params.getIsbn());//书号
        wrapper.like(!StringUtils.isBlank(params.getBName()),"b_name", params.getBName());//书名
        wrapper.like(!StringUtils.isBlank(params.getBAuthor()),"b_author", params.getBAuthor());//作者
        wrapper.like(!(null== params.getBState()),"b_state", params.getBState());//状态

        //获得数据
        IPage<TSjxxb> page = this.page(query, wrapper);
        return page;
    }
}
