package com.xjrsoft.module.courseTable.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.xjrsoft.common.model.result.R;
import com.xjrsoft.module.courseTable.dto.ClassListDto;
import com.xjrsoft.module.courseTable.service.ICourseTableService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;

/**
 * <p>
 * 课表 前端控制器
 * </p>
 *
 * @author baomidou
 * @since 2023-09-02 02:19:56
 */
@RequestMapping("/coursetable")
@Api(value = "/coursetable", tags = "课表")
@AllArgsConstructor
@RestController
public class CourseTableController {

    private ICourseTableService courseTableService;

    @GetMapping("/class")
    @ApiOperation(value = "获取班级课表")
    public R classList(ClassListDto dto) {
        return R.ok(courseTableService.classList(dto));
    }

    @PostMapping("/wordimport")
    @ApiOperation(value = "word课表导入")
    @SaCheckPermission("coursetable:wordimport")
    public R wordImport(@RequestParam("file") MultipartFile file) throws IOException {
        InputStream inputStream = file.getInputStream();

        return R.ok(courseTableService.wordImport(inputStream));
    }
}
