Blame view

MatchCollegePdfServiceImpl.java 3.15 KB
涂亚平 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
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;
    }


}