package com.cirle.scientific.questionnaire.exception.handle;

import com.cirle.scientific.questionnaire.exception.AnswerSubmitException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 答案相关API接口异常处理类
 */
@SuppressWarnings("unused")
@ControllerAdvice
@ResponseBody
public class AnswerExceptionHandler {

    @ExceptionHandler(AnswerSubmitException.class)
    public Map<String, String> handleAnswerSubmitException(AnswerSubmitException e) {
        Map<String, String> map = new LinkedHashMap<>();
        map.put("code", "400");
        map.put("message", "答案提交失败：" + e.getMessage());
        return map;
    }

}
