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.CreditCaseFiling;
import com.gxwebsoft.credit.mapper.CreditCaseFilingMapper;
import com.gxwebsoft.credit.param.CreditCaseFilingParam;
import com.gxwebsoft.credit.service.CreditCaseFilingService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 司法大数据Service实现
 *
 * @author 科技小王子
 * @since 2025-12-19 19:47:22
 */
@Service
public class CreditCaseFilingServiceImpl extends ServiceImpl<CreditCaseFilingMapper, CreditCaseFiling> implements CreditCaseFilingService {

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

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

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

}
