package com.template.services.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.template.mapper.SmartScoreMapper;
import com.template.model.pojo.SmartScore;
import com.template.model.pojo.SmartScore;
import com.template.mapper.SmartScoreMapper;
import com.template.model.result.PageUtils;
import com.template.model.vo.ScorePageVo;
import com.template.services.SmartScoreService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 楼栋表 服务实现类
 * </p>
 *
 * @author ceshi
 * @since 2024-01-02
 */
@Service
public class SmartScoreServiceImpl extends ServiceImpl<SmartScoreMapper, SmartScore> implements SmartScoreService {
    @Autowired
    private SmartScoreMapper smartScoreMapper;

    @Override
    public int insertSmartScore(SmartScore sa) {
        int result = smartScoreMapper.insert(sa);
        return result;
    }

    @Override
    public int updateSmartScore(SmartScore sa) {
        int result = smartScoreMapper.updateById(sa);
        return result;
    }

    @Override
    public PageUtils<SmartScore> queryPageSmartScores(int currentPage, int pageCount, String name) {
        Page<SmartScore> page = new Page<>(currentPage, pageCount);
        QueryWrapper<SmartScore> queryWrapper = new QueryWrapper<>();
        //queryWrapper.like(StringUtils.hasText(name), "name", name);
        IPage<SmartScore> result = smartScoreMapper.selectPage(page, queryWrapper);
        return new PageUtils<>(result);
    }

    @Override
    public int deleteSmartScoreById(int id) {
        int result = smartScoreMapper.deleteById(id);
        return result;
    }

    @Override
    public SmartScore getSmartById(int id) {
        SmartScore result = smartScoreMapper.selectById(id);
        return result;
    }

    @Override
    public int deleteSmartScoreByIds(List<Integer> ids) {
        int result = smartScoreMapper.deleteBatchIds(ids);
        return result;
    }


    @Override
    public PageUtils<ScorePageVo> querySmartScorePage(int currentPage, int pageCount, String name, String semester, String grade, String schoolClass, Integer subject, Integer examType, Double MinScore, Double MaxScore) {
        Page<ScorePageVo> page = new Page<>(currentPage, pageCount);
        IPage<ScorePageVo> result = smartScoreMapper.querySmartScorePage(page, name, semester, grade, schoolClass, subject, examType, MinScore, MaxScore);
        return new PageUtils<>(result);
    }

    @Override
    public List<ScorePageVo> querySmartScores(String name, String semester, String grade, String schoolClass, Integer subject, Integer examType, Double MinScore, Double MaxScore) {
        List<ScorePageVo> result = smartScoreMapper.querySmartScores(name, semester, grade, schoolClass, subject, examType, MinScore, MaxScore);
        return result;
    }

}
