package edu.whut.smilepicturebackend.controller;
import edu.whut.smilepicturebackend.common.BaseResponse;
import edu.whut.smilepicturebackend.common.ResultUtils;
import edu.whut.smilepicturebackend.model.vo.CaptchaVO;
import edu.whut.smilepicturebackend.service.MainApplicationService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/")
@RequiredArgsConstructor
public class MainController {

    private final MainApplicationService mainApplicationService;
    /**
     * 健康检查
     */
    @GetMapping("/health")
    public BaseResponse<String> health() throws InterruptedException {
//        new Thread(() -> {
//            try {
//                Thread.sleep(100000L);
//            } catch (InterruptedException e) {
//                throw new RuntimeException(e);
//            }
//        }).start();
        return ResultUtils.success("ok");
    }

    /**
     * 获取图形验证码
     */
    @GetMapping("/captcha")
    public BaseResponse<CaptchaVO> captcha() {
        return ResultUtils.success(mainApplicationService.getCaptcha());
    }
}
