package com.template.services.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.template.mapper.SmartSubjectTemplateMapper;
import com.template.model.evaluate.student.SmartSubjectTemplate;
import com.template.model.pojo.SmartTeaching;
import com.template.mapper.SmartTeachingMapper;
import com.template.model.vo.UserSubjectVo;
import com.template.services.SmartTeachingService;
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-05-24
 */
@Service
public class SmartTeachingServiceImpl extends ServiceImpl<SmartTeachingMapper, SmartTeaching> implements SmartTeachingService {
    @Autowired
    private SmartTeachingMapper smartTeachingMapper;

    @Override
    public List<SmartTeaching> queryTeachingByUserId(Integer userId) {
        QueryWrapper<SmartTeaching> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId);
        List<SmartTeaching> result = smartTeachingMapper.selectList(queryWrapper);
        return result;
    }

    @Override
    public int deleteByUserId(Integer userId) {
        QueryWrapper<SmartTeaching> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId);
        int result = smartTeachingMapper.delete(queryWrapper);
        return result;
    }

    @Override
    public int deleteByUserIds(List<Integer> userIds) {
        QueryWrapper<SmartTeaching> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("user_id", userIds);
        int result = smartTeachingMapper.delete(queryWrapper);
        return result;
    }

    @Override
    public List<SmartTeaching> queryByUserIds(List<Integer> userIds) {
        QueryWrapper<SmartTeaching> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("user_id", userIds);
        List<SmartTeaching> result = smartTeachingMapper.selectList(queryWrapper);
        return result;
    }

    public List<UserSubjectVo> querySmartTeachings(List<Integer> userIds){
        List<UserSubjectVo> result = smartTeachingMapper.querySmartTeachings(userIds);
        return result;
    }
}
