MatchCollegePdfServiceImpl.java 3.15 KB
package com.zhongzhi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhongzhi.common.exception.HttpException;
import com.zhongzhi.common.utils.Localstorage;
import com.zhongzhi.dao.MatchCollegePdfMapper;
import com.zhongzhi.dao.MatchDictDAO;
import com.zhongzhi.model.CollegesDictDO;
import com.zhongzhi.model.MatchCollegePdfDO;
import com.zhongzhi.model.MatchDictDO;
import com.zhongzhi.service.MatchCollegePdfService;
import com.zhongzhi.vo.project.QueryPdfStatusVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author DengMin
 * @since 2024-06-25
 */
@Service
public class MatchCollegePdfServiceImpl extends ServiceImpl<MatchCollegePdfMapper, MatchCollegePdfDO> implements MatchCollegePdfService {

    @Autowired
    private MatchDictDAO matchDictDAO;

    public void uploadPdf(MatchCollegePdfDO matchCollegePdfDO) {


        MatchDictDO matchDictDO = matchDictDAO.selectById(matchCollegePdfDO.getMatchId());

        //时间范围 当前时间在范围内
        if (null != matchDictDO.getStartTime() && null != matchDictDO.getEndTime() && (matchDictDO.getStartTime().after(new Date()) || matchDictDO.getEndTime().before(new Date(new Date().getTime() - 24 * 60 * 60 * 1000)))) {
            throw new HttpException(10018);
        }

        CollegesDictDO collegesDictDO = (CollegesDictDO) Localstorage.getUser();

        this.baseMapper.delete(new QueryWrapper<MatchCollegePdfDO>()
                .lambda()
                .eq(MatchCollegePdfDO::getMatchId, matchCollegePdfDO.getMatchId())
                .eq(MatchCollegePdfDO::getCollegeId, collegesDictDO.getId()));
        matchCollegePdfDO.setCollegeId(collegesDictDO.getId());
        this.baseMapper.insert(matchCollegePdfDO);
    }

    public void dropPdf(MatchCollegePdfDO matchCollegePdfDO) {

        MatchDictDO matchDictDO = matchDictDAO.selectById(matchCollegePdfDO.getMatchId());
        if (null != matchDictDO.getStartTime() && null != matchDictDO.getEndTime() && (matchDictDO.getStartTime().after(new Date()) || matchDictDO.getEndTime().before(new Date(new Date().getTime() - 24 * 60 * 60 * 1000)))) {
            throw new HttpException(10018);
        }

        CollegesDictDO collegesDictDO = (CollegesDictDO) Localstorage.getUser();
        this.baseMapper.delete(new QueryWrapper<MatchCollegePdfDO>()
                .lambda()
                .eq(MatchCollegePdfDO::getCollegeId, collegesDictDO.getId())
                .eq(MatchCollegePdfDO::getMatchId, matchCollegePdfDO.getMatchId()));
    }

    public MatchCollegePdfDO queryPdfStatus(MatchCollegePdfDO matchCollegePdfDO) {

        CollegesDictDO collegesDictDO = (CollegesDictDO) Localstorage.getUser();

        matchCollegePdfDO = this.baseMapper.selectOne(new QueryWrapper<MatchCollegePdfDO>()
                .lambda()
                .eq(MatchCollegePdfDO::getCollegeId, collegesDictDO.getId())
                .eq(MatchCollegePdfDO::getMatchId, matchCollegePdfDO.getMatchId()));

        return matchCollegePdfDO;
    }


}