package top.iletter.modules.baitutools.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import top.iletter.common.page.PageData;
import top.iletter.common.service.impl.CrudServiceImpl;
import top.iletter.modules.baitutools.dao.DlRenewalRemindDao;
import top.iletter.modules.baitutools.dto.DlRenewalRemindDTO;
import top.iletter.modules.baitutools.entity.DlRenewalRemindEntity;
import top.iletter.modules.baitutools.service.DlRenewalRemindService;
import cn.hutool.core.util.StrUtil;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 临期续费
 *
 * @author dellevin dellevin99@gmail.com
 * @since 1.0.0 2026-02-04
 */
@Service
public class DlRenewalRemindServiceImpl extends CrudServiceImpl<DlRenewalRemindDao, DlRenewalRemindEntity, DlRenewalRemindDTO> implements DlRenewalRemindService {

    @Override
    public QueryWrapper<DlRenewalRemindEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<DlRenewalRemindEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);

        return wrapper;
    }
    @Override
    public PageData<DlRenewalRemindDTO> page(Map<String, Object> params) {
        IPage<DlRenewalRemindEntity> page = getPage(params, "create_date", false);

        List<DlRenewalRemindEntity> list = baseDao.getList(params);
        return getPageData(list, page.getTotal(), DlRenewalRemindDTO.class);
    }

}