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.CreditMediation;
import com.gxwebsoft.credit.mapper.CreditMediationMapper;
import com.gxwebsoft.credit.param.CreditMediationParam;
import com.gxwebsoft.credit.service.CreditMediationService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 诉前调解司法大数据Service实现
 *
 * @author 科技小王子
 * @since 2025-12-19 19:51:25
 */
@Service
public class CreditMediationServiceImpl extends ServiceImpl<CreditMediationMapper, CreditMediation> implements CreditMediationService {

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

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

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

}
