package com.hzu.labbooking.controller;

import com.hzu.labbooking.domain.vo.LabTableDetailsVO;
import com.hzu.labbooking.domain.vo.LabTableVO;
import com.hzu.labbooking.service.ILabService;
import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: yezihao
 * @date: 2021-06-14
 */
@RestController
@RequestMapping("/labbooking/table")
public class LabTableController {

    @Autowired
    private ILabService labService;

    @GetMapping("/list")
    public R<List<LabTableVO>> list(@RequestParam Long year,
                                    @RequestParam Long term) {
        List<LabTableVO> voList = labService.getAllLabTable(year, term);
        return R.ok(voList);
    }

    @GetMapping("/applyTableList/{labId}/{year}/{term}")
    public R<List<LabTableVO>> applyTableList(@PathVariable("labId") long labId,
                                              @PathVariable("year") long year,
                                              @PathVariable("term") long term) {
        List<LabTableVO> voList = labService.getAllApplyTable(labId, year, term);
        return R.ok(voList);
    }

    @GetMapping("/appliedTableList/{labId}/{year}/{term}")
    public R<List<LabTableVO>> appliedTableList(@PathVariable("labId") long labId,
                                                @PathVariable("year") long year,
                                                @PathVariable("term") long term) {
        List<LabTableVO> voList = labService.getAllAppliedTable(labId, year, term);
        return R.ok(voList);
    }

    @GetMapping("/get/{labId}")
    public R<LabTableDetailsVO> getTableDetails(@PathVariable("labId") Long labId) {
        LabTableDetailsVO vo = labService.getTableDetails(labId);
        return R.ok(vo);
    }

}