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.CreditCourtSession;
import com.gxwebsoft.credit.mapper.CreditCourtSessionMapper;
import com.gxwebsoft.credit.param.CreditCourtSessionParam;
import com.gxwebsoft.credit.service.CreditCourtSessionService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 开庭公告司法大数据Service实现
 *
 * @author 科技小王子
 * @since 2025-12-19 19:49:33
 */
@Service
public class CreditCourtSessionServiceImpl extends ServiceImpl<CreditCourtSessionMapper, CreditCourtSession> implements CreditCourtSessionService {

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

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

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

}
