package com.gxwebsoft.bszx.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.bszx.mapper.BszxGradeMapper;
import com.gxwebsoft.bszx.service.BszxGradeService;
import com.gxwebsoft.bszx.entity.BszxGrade;
import com.gxwebsoft.bszx.param.BszxGradeParam;
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-06 22:50:25
 */
@Service
public class BszxGradeServiceImpl extends ServiceImpl<BszxGradeMapper, BszxGrade> implements BszxGradeService {

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

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

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

}
