PaperDictServiceImpl.java 1.74 KB
package com.subsidy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.subsidy.common.exception.HttpException;
import com.subsidy.model.PaperDictDO;
import com.subsidy.mapper.PaperDictMapper;
import com.subsidy.service.PaperDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils;
import com.subsidy.vo.paper.QueryPapersVO;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 试卷字典表 服务实现类
 * </p>
 *
 * @author DengMin
 * @since 2021-12-03
 */
@Service
public class PaperDictServiceImpl extends ServiceImpl<PaperDictMapper, PaperDictDO> implements PaperDictService {

    public List<QueryPapersVO> queryPapers(PaperDictDO paperDictDO){
        return this.baseMapper.queryPapers(paperDictDO.getCourseId(),paperDictDO.getPaperName(),null);
    }

    public String deletePaper(PaperDictDO paperDictDO){
        this.baseMapper.deleteById(paperDictDO.getId());
        return ConstantUtils.DELETE_SUCCESS;
    }

    public String updateStatus(PaperDictDO paperDictDO){
        this.baseMapper.updateById(paperDictDO);
        return ConstantUtils.SET_SUCCESS;
    }

    public String addPaper(PaperDictDO paperDictDO){

        Integer count = this.baseMapper.selectCount(new QueryWrapper<PaperDictDO>()
        .lambda()
        .eq(PaperDictDO::getCourseId,paperDictDO.getCourseId())
        .eq(PaperDictDO::getPaperName,paperDictDO.getPaperName()));

        if (count>0){
            throw new HttpException(50001);
        }
        paperDictDO.setPaperStatus(0);
        this.baseMapper.insert(paperDictDO);
        return ConstantUtils.ADD_SUCCESS;
    }
}