package com.gxwebsoft.bszx.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.bszx.mapper.BszxPayRankingMapper;
import com.gxwebsoft.bszx.service.BszxPayRankingService;
import com.gxwebsoft.bszx.entity.BszxPayRanking;
import com.gxwebsoft.bszx.param.BszxPayRankingParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 百色中学-捐款排行Service实现
 *
 * @author 科技小王子
 * @since 2025-03-25 08:54:09
 */
@Service
public class BszxPayRankingServiceImpl extends ServiceImpl<BszxPayRankingMapper, BszxPayRanking> implements BszxPayRankingService {

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

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

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

}
