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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.template.mapper.SmartEvaluateSdetailMapper;
import com.template.model.evaluate.student.SmartEvaluateSdetail;
import com.template.model.evaluate.student.SmartEvaluateSdetail;
import com.template.model.result.PageUtils;
import com.template.services.SmartEvaluateSdetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 成绩表 服务实现类
 * </p>
 *
 * @author ceshi
 * @since 2024-01-08
 */
@Service
public class SmartEvaluateSdetailServiceImpl extends ServiceImpl<SmartEvaluateSdetailMapper, SmartEvaluateSdetail> implements SmartEvaluateSdetailService {

    @Autowired
    private SmartEvaluateSdetailMapper smartEvaluateSdetailMapper;

    @Override
    public int insertSmartEvaluateSdetail(SmartEvaluateSdetail sa) {
        int result = smartEvaluateSdetailMapper.insert(sa);
        return result;
    }

    @Override
    public int updateSmartEvaluateSdetail(SmartEvaluateSdetail sa) {
        int result = smartEvaluateSdetailMapper.updateById(sa);
        return result;
    }

    @Override
    public PageUtils<SmartEvaluateSdetail> queryPageSmartEvaluateSdetail(int currentPage, int pageCount, QueryWrapper<SmartEvaluateSdetail> queryWrapper) {
        Page<SmartEvaluateSdetail> page = new Page<>(currentPage, pageCount);
        IPage<SmartEvaluateSdetail> result = smartEvaluateSdetailMapper.selectPage(page,queryWrapper);
        return new PageUtils<>(result);
    }

    @Override
    public int deleteSmartEvaluateSdetailById(int id) {
        int result = smartEvaluateSdetailMapper.deleteById(id);
        return result;
    }

    @Override
    public SmartEvaluateSdetail getSmartEvaluateSdetailById(int id) {
        SmartEvaluateSdetail result = smartEvaluateSdetailMapper.selectById(id);
        return result;
    }

    @Override
    public List<SmartEvaluateSdetail> getSmartEvaluateSdetailList() {
        QueryWrapper<SmartEvaluateSdetail> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("deleted", 0);
        List<SmartEvaluateSdetail> result = smartEvaluateSdetailMapper.selectList(queryWrapper);
        return result;
    }

    @Override
    public List<SmartEvaluateSdetail> getSmartEvaluateSdetailByKey(QueryWrapper<SmartEvaluateSdetail> queryWrapper) {
        List<SmartEvaluateSdetail> result = smartEvaluateSdetailMapper.selectList(queryWrapper);
        return result;
    }
    
}
