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.SmartEvaluateTeacherMapper;
import com.template.model.evaluate.teacher.SmartEvaluateTeacher;
import com.template.model.result.PageUtils;
import com.template.services.SmartEvaluateTeacherService;
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 SmartEvaluateTeacherServiceImpl extends ServiceImpl<SmartEvaluateTeacherMapper, SmartEvaluateTeacher> implements SmartEvaluateTeacherService {

    @Autowired
    private SmartEvaluateTeacherMapper smartEvaluateTeacherMapper;

    @Override
    public int insertSmartEvaluateTeacher(SmartEvaluateTeacher sa) {
        int result = smartEvaluateTeacherMapper.insert(sa);
        return result;
    }

    @Override
    public int updateSmartEvaluateTeacher(SmartEvaluateTeacher sa) {
        int result = smartEvaluateTeacherMapper.updateById(sa);
        return result;
    }

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

    @Override
    public int deleteSmartEvaluateTeacherById(int id) {
        int result = smartEvaluateTeacherMapper.deleteById(id);
        return result;
    }

    @Override
    public SmartEvaluateTeacher getSmartEvaluateTeacherById(int id) {
        SmartEvaluateTeacher result = smartEvaluateTeacherMapper.selectById(id);
        return result;
    }

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

    @Override
    public List<SmartEvaluateTeacher> getEvaluateTeacherByKey(QueryWrapper<SmartEvaluateTeacher> queryWrapper) {
        List<SmartEvaluateTeacher> result = smartEvaluateTeacherMapper.selectList(queryWrapper);
        return result;
    }

    @Override
    public Double getAvgLowingScore(String term){
        return smartEvaluateTeacherMapper.getAvgLowingScore(term);
    }
    
}
