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.SmartSubjectRuleMapper;
import com.template.model.evaluate.student.SmartSubjectRule;
import com.template.model.result.PageUtils;
import com.template.services.SmartSubjectRuleService;
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 SmartSubjectRuleServiceImpl extends ServiceImpl<SmartSubjectRuleMapper, SmartSubjectRule> implements SmartSubjectRuleService {

    @Autowired
    private SmartSubjectRuleMapper smartSubjectRuleMapper;

    @Override
    public int insertSmartSubjectRule(SmartSubjectRule sa) {
        int result = smartSubjectRuleMapper.insert(sa);
        return result;
    }

    @Override
    public int updateSmartSubjectRule(SmartSubjectRule sa) {
        int result = smartSubjectRuleMapper.updateById(sa);
        return result;
    }

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

    @Override
    public int deleteSmartSubjectRuleById(int id) {
        int result = smartSubjectRuleMapper.deleteById(id);
        return result;
    }

    @Override
    public SmartSubjectRule getSmartSubjectRuleById(int id) {
        SmartSubjectRule result = smartSubjectRuleMapper.selectById(id);
        return result;
    }

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

    @Override
    public List<SmartSubjectRule> getSmartSubjectRuleByKey(QueryWrapper<SmartSubjectRule> queryWrapper) {
        List<SmartSubjectRule> result = smartSubjectRuleMapper.selectList(queryWrapper);
        return result;
    }
    
}
