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.CreditJudgmentDebtor;
import com.gxwebsoft.credit.mapper.CreditJudgmentDebtorMapper;
import com.gxwebsoft.credit.param.CreditJudgmentDebtorParam;
import com.gxwebsoft.credit.service.CreditJudgmentDebtorService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 被执行人Service实现
 *
 * @author 科技小王子
 * @since 2025-12-19 19:50:55
 */
@Service
public class CreditJudgmentDebtorServiceImpl extends ServiceImpl<CreditJudgmentDebtorMapper, CreditJudgmentDebtor> implements CreditJudgmentDebtorService {

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

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

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

}
