Blame view

MatchScheduleController.java 3.09 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
package com.zhongzhi.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhongzhi.common.constant.Platform;
import com.zhongzhi.common.constant.ProjectType;
import com.zhongzhi.common.utils.LoginRequired;
import com.zhongzhi.common.utils.ResponseData;
import com.zhongzhi.model.MatchDictDO;
import com.zhongzhi.model.MatchScheduleDO;
import com.zhongzhi.service.MatchDictService;
import com.zhongzhi.service.MatchScheduleService;
import com.zhongzhi.vo.ResponseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 时间安排 前端控制器
 * </p>
 *
 * @author DengMin
 * @since 2021-05-27
 */
@RestController
@RequestMapping("/matchSchedule")
@Api(tags = "时间安排")
public class MatchScheduleController {

    @Autowired
    private MatchScheduleService matchScheduleService;

    @Autowired
    private MatchDictService matchDictService;

    @PostMapping(value = "/getMatchSchedule")
    @LoginRequired({Platform.student})
    @ApiOperation("学生端 ---种子赛道查看时间安排:matchId/赛事年份ID")
    public ResponseVO getMatchSchedule(@RequestBody MatchScheduleDO matchScheduleDO) {
        MatchDictDO matchDictDO = matchDictService.getOne(new QueryWrapper<MatchDictDO>()
                .lambda()
                .eq(MatchDictDO::getId, matchScheduleDO.getMatchId())
                .eq(MatchDictDO::getMatchType, ProjectType.SEED_TRACK)
                .eq(MatchDictDO::getStatus, 1));
        List<MatchScheduleDO> list = new ArrayList<>();
        if (matchDictDO != null) {
            list = matchScheduleService.list(new QueryWrapper<MatchScheduleDO>()
                    .lambda()
                    .eq(MatchScheduleDO::getMatchId, matchDictDO.getId()));
        }
        return ResponseData.generateCreatedResponse(0, list);
    }

    @PostMapping(value = "getVocationalMatchSchedule")
    @LoginRequired({Platform.student})
    @ApiOperation("学生端 ---职教赛道查看时间安排:matchId/赛事年份ID")
    public ResponseVO getVocationalMatchSchedule(@RequestBody MatchScheduleDO matchScheduleDO) {
        MatchDictDO matchDictDO = matchDictService.getOne(new QueryWrapper<MatchDictDO>()
                .lambda()
                .eq(MatchDictDO::getId, matchScheduleDO.getMatchId())
                .eq(MatchDictDO::getMatchType, ProjectType.VOCATIONAL)
                .eq(MatchDictDO::getStatus, 1));
        List<MatchScheduleDO> list = new ArrayList<>();
        if (matchDictDO != null) {
            list = matchScheduleService.list(new QueryWrapper<MatchScheduleDO>()
                    .lambda()
                    .eq(MatchScheduleDO::getMatchId, matchDictDO.getId()));
        }
        return ResponseData.generateCreatedResponse(0, list);
    }
}