package com.qmth.teachcloud.mark.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
import com.qmth.teachcloud.common.enums.mark.MarkPaperStatus;
import com.qmth.teachcloud.mark.entity.MarkPaperPackage;
import com.qmth.teachcloud.mark.mapper.MarkPaperPackageMapper;
import com.qmth.teachcloud.mark.service.MarkPaperPackageService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MarkPaperPackageServiceImpl extends MppServiceImpl<MarkPaperPackageMapper, MarkPaperPackage> implements MarkPaperPackageService {
    @Override
    public List<MarkPaperPackage> listByExamIdAndPackageCode(Long examId, String packageCode) {
        QueryWrapper<MarkPaperPackage> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(MarkPaperPackage::getExamId, examId)
                .eq(MarkPaperPackage::getPackageCode, packageCode);
        return this.list(queryWrapper);
    }

    @Override
    public int getPackageCountByExamId(Long examId, String courseCode, String coursePaperId, MarkPaperStatus status, DataPermissionRule dpr) {
        return this.baseMapper.getPackageCountByExamId(examId, courseCode, coursePaperId, status.name(), dpr);
    }
}
