package com.gxwebsoft.credit.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.credit.entity.CreditDeliveryNotice;
import com.gxwebsoft.credit.mapper.CreditDeliveryNoticeMapper;
import com.gxwebsoft.credit.param.CreditDeliveryNoticeParam;
import com.gxwebsoft.credit.service.CreditDeliveryNoticeService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 送达公告司法大数据Service实现
 *
 * @author 科技小王子
 * @since 2025-12-19 19:49:51
 */
@Service
public class CreditDeliveryNoticeServiceImpl extends ServiceImpl<CreditDeliveryNoticeMapper, CreditDeliveryNotice> implements CreditDeliveryNoticeService {

    @Override
    public PageResult<CreditDeliveryNotice> pageRel(CreditDeliveryNoticeParam param) {
        PageParam<CreditDeliveryNotice, CreditDeliveryNoticeParam> page = new PageParam<>(param);
        page.setDefaultOrder("sort_number asc, create_time desc");
        List<CreditDeliveryNotice> list = baseMapper.selectPageRel(page, param);
        return new PageResult<>(list, page.getTotal());
    }

    @Override
    public List<CreditDeliveryNotice> listRel(CreditDeliveryNoticeParam param) {
        List<CreditDeliveryNotice> list = baseMapper.selectListRel(param);
        // 排序
        PageParam<CreditDeliveryNotice, CreditDeliveryNoticeParam> page = new PageParam<>();
        page.setDefaultOrder("sort_number asc, create_time desc");
        return page.sortRecords(list);
    }

    @Override
    public CreditDeliveryNotice getByIdRel(Integer id) {
        CreditDeliveryNoticeParam param = new CreditDeliveryNoticeParam();
        param.setId(id);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
