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.CreditBreachOfTrust;
import com.gxwebsoft.credit.mapper.CreditBreachOfTrustMapper;
import com.gxwebsoft.credit.param.CreditBreachOfTrustParam;
import com.gxwebsoft.credit.service.CreditBreachOfTrustService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 失信被执行人Service实现
 *
 * @author 科技小王子
 * @since 2025-12-19 19:46:14
 */
@Service
public class CreditBreachOfTrustServiceImpl extends ServiceImpl<CreditBreachOfTrustMapper, CreditBreachOfTrust> implements CreditBreachOfTrustService {

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

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

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

}
