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.CreditJudicialDocument;
import com.gxwebsoft.credit.mapper.CreditJudicialDocumentMapper;
import com.gxwebsoft.credit.param.CreditJudicialDocumentParam;
import com.gxwebsoft.credit.service.CreditJudicialDocumentService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 裁判文书司法大数据Service实现
 *
 * @author 科技小王子
 * @since 2025-12-19 19:51:02
 */
@Service
public class CreditJudicialDocumentServiceImpl extends ServiceImpl<CreditJudicialDocumentMapper, CreditJudicialDocument> implements CreditJudicialDocumentService {

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

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

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

}
