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.SmartSubjectTemplateMapper;
import com.template.model.evaluate.student.SmartSubjectTemplate;
import com.template.model.evaluate.student.SmartSubjectTemplate;
import com.template.model.result.PageUtils;
import com.template.services.SmartSubjectTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 平分项管理 服务实现类
 * </p>
 *
 * @author ceshi
 * @since 2024-03-14
 */
@Service
public class SmartSubjectTemplateServiceImpl extends ServiceImpl<SmartSubjectTemplateMapper, SmartSubjectTemplate> implements SmartSubjectTemplateService {

    @Autowired
    private SmartSubjectTemplateMapper smartSubjectTemplateMapper;

    @Override
    public int insertSmartSubjectTemplate(SmartSubjectTemplate sa) {
        int result = smartSubjectTemplateMapper.insert(sa);
        return result;
    }

    @Override
    public int updateSmartSubjectTemplate(SmartSubjectTemplate sa) {
        int result = smartSubjectTemplateMapper.updateById(sa);
        return result;
    }

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

    @Override
    public int deleteSmartSubjectTemplateById(int id) {
        int result = smartSubjectTemplateMapper.deleteById(id);
        return result;
    }

    @Override
    public SmartSubjectTemplate getSmartSubjectTemplateById(int id) {
        SmartSubjectTemplate result = smartSubjectTemplateMapper.selectById(id);
        return result;
    }

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

    @Override
    public List<SmartSubjectTemplate> getSmartSubjectTemplateByKey(QueryWrapper<SmartSubjectTemplate> queryWrapper) {
        List<SmartSubjectTemplate> result = smartSubjectTemplateMapper.selectList(queryWrapper);
        return result;
    }
    
}
