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.CreditFinalVersion;
import com.gxwebsoft.credit.mapper.CreditFinalVersionMapper;
import com.gxwebsoft.credit.param.CreditFinalVersionParam;
import com.gxwebsoft.credit.service.CreditFinalVersionService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 终本案件Service实现
 *
 * @author 科技小王子
 * @since 2025-12-19 19:50:19
 */
@Service
public class CreditFinalVersionServiceImpl extends ServiceImpl<CreditFinalVersionMapper, CreditFinalVersion> implements CreditFinalVersionService {

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

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

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

}
