package com.template.services.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.template.model.pojo.SmartVisitorParentsConfig;
import com.template.mapper.SmartVisitorParentsConfigMapper;
import com.template.model.result.PageUtils;
import com.template.model.vo.AskForLeaveVo;
import com.template.model.vo.SmartVisitorParentsConfigVo;
import com.template.services.SmartVisitorParentsConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ceshi
 * @since 2024-05-29
 */
@Service
public class SmartVisitorParentsConfigServiceImpl extends ServiceImpl<SmartVisitorParentsConfigMapper, SmartVisitorParentsConfig> implements SmartVisitorParentsConfigService {

    @Autowired
    SmartVisitorParentsConfigMapper smartVisitorParentsConfigMapper;

    @Override
    public PageUtils<SmartVisitorParentsConfigVo> getClassIdPage(Integer page, Integer size, Integer classId,Integer gradeId) {
        Page<SmartVisitorParentsConfigVo> p = new Page<>(page,size);

        IPage<SmartVisitorParentsConfigVo> page1 = smartVisitorParentsConfigMapper.getClassIdPage(p,classId,gradeId);

        return new PageUtils<>(page1);
    }

    @Override
    public SmartVisitorParentsConfigVo getClassId(Integer schoolClass) {

        return smartVisitorParentsConfigMapper.getClassId(schoolClass);
    }

    @Override
    public SmartVisitorParentsConfig getByClassId(Integer classId) {
        LambdaQueryWrapper<SmartVisitorParentsConfig> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(SmartVisitorParentsConfig::getClassId,classId);
        SmartVisitorParentsConfig one = this.getOne(wrapper);
        return one;
    }

}
