package com.koobietech.eas.controller;


import com.koobietech.eas.common.result.JsonResult;
import com.koobietech.eas.mbg.model.EasArcTlsStudents;
import com.koobietech.eas.service.EasStuProfileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.FileNotFoundException;

/**
 * @author lc
 */
@Tag(name = "学生档案下载模块")
@RestController
public class EasSysStuProfileController {

    @Resource
    private EasStuProfileService easStuProfileService;

    @PostMapping("/StuProfileDownload")
    @Operation(summary = "保存学生档案为word文档到本地或者服务器中", description = "根据学生档案信息和管理员ID保存学生档案为word文档到本地或者服务器中，注意manager_id要传在url中")
    public JsonResult StuProfileDownload(@RequestBody EasArcTlsStudents easArcTlsStudents, @RequestParam Integer manager_id) throws FileNotFoundException {
        //StuProfileDownload返回值是boolean，这里用JsonResult包装一下 加上if判断
        if (easStuProfileService.StuProfileDownload(easArcTlsStudents, manager_id)) {
            return JsonResult.ok("下载成功");
        }
        return JsonResult.fail("下载失败");
    }

}
