MatchScheduleController.java 3.09 KB
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);
    }
}