release_1.0.0
liu 1 year ago
parent a289fb81d7
commit 8c1ab30dfc

@ -1,6 +1,7 @@
package com.supervision.config;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.supervision.domain.GlobalResult;
import com.supervision.exception.BusinessException;
@ -47,7 +48,7 @@ public class ResponseConfig implements ResponseBodyAdvice<Object> {
public Object beforeBodyWrite(Object o, @Nullable MethodParameter methodParameter, @Nullable MediaType mediaType,
@Nullable Class<? extends HttpMessageConverter<?>> aClass, @Nullable ServerHttpRequest serverHttpRequest,
@Nullable ServerHttpResponse serverHttpResponse) {
serverHttpResponse.getHeaders().set("Content-Type","application/json");
serverHttpResponse.getHeaders().set("Content-Type", "application/json");
if (Objects.isNull(o)) {
return GlobalResult.ok(null, "success");
@ -99,7 +100,7 @@ public class ResponseConfig implements ResponseBodyAdvice<Object> {
// 格式化错误信息
String errorMsg = exception.getBindingResult().getFieldErrors().stream()
.map(e -> e.getField() + ":" + e.getDefaultMessage()).collect(Collectors.joining("、"));
return GlobalResult.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), "参数验证异常", errorMsg);
return GlobalResult.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), errorMsg, "参数验证异常");
}
@ -112,7 +113,7 @@ public class ResponseConfig implements ResponseBodyAdvice<Object> {
@ExceptionHandler(Exception.class)
public GlobalResult<?> validationExceptionResponse(Exception exception) {
log.error(exception.getMessage(), exception);
return GlobalResult.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), "未知错误", exception.getMessage());
return GlobalResult.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), exception.getMessage(), "未知错误");
}

@ -92,7 +92,7 @@ public class AskServiceImpl implements AskService {
.eq(AskPatientAnswer::getLibraryQuestionId, library.getId()).last("limit 1").one();
// 如果没有找到回答,去默认回答里面看看有没有
if (ObjectUtil.isEmpty(askPatientAnswer)) {
log.info("{}:病历配置,未找到回答结果,尝试回答默认答案", rasaResult);
log.info("{}:病历配置,未从AskPatientAnswer中找到回答结果,尝试回答默认答案", rasaResult);
// 首先看看default里面是不是存在,如果存在,就从default里面去找
if (CollUtil.isNotEmpty(library.getDefaultAnswer())) {
String resText = library.getDefaultAnswer().get(RandomUtil.randomInt(0, library.getDefaultAnswer().size()));

Loading…
Cancel
Save