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.SmartEvaluateStudentMapper;
import com.template.model.evaluate.student.SmartEvaluateStudent;
import com.template.model.result.PageUtils;
import com.template.services.SmartEvaluateStudentService;
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 SmartEvaluateStudentServiceImpl extends ServiceImpl<SmartEvaluateStudentMapper, SmartEvaluateStudent> implements SmartEvaluateStudentService {

    @Autowired
    private SmartEvaluateStudentMapper smartEvaluateStudentMapper;

    @Override
    public int insertSmartEvaluateStudent(SmartEvaluateStudent sa) {
        int result = smartEvaluateStudentMapper.insert(sa);
        return result;
    }

    @Override
    public int updateSmartEvaluateStudent(SmartEvaluateStudent sa) {
        int result = smartEvaluateStudentMapper.updateById(sa);
        return result;
    }

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

    @Override
    public int deleteSmartEvaluateStudentById(int id) {
        int result = smartEvaluateStudentMapper.deleteById(id);
        return result;
    }

    @Override
    public SmartEvaluateStudent getSmartEvaluateStudentById(int id) {
        SmartEvaluateStudent result = smartEvaluateStudentMapper.selectById(id);
        return result;
    }

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

    @Override
    public List<SmartEvaluateStudent> getSmartEvaluateStudentByKey(QueryWrapper<SmartEvaluateStudent> queryWrapper) {
        List<SmartEvaluateStudent> result = smartEvaluateStudentMapper.selectList(queryWrapper);
        return result;
    }

}
