ref: 补充修改后的建表sql文件 ref: 微调部分数据格式 ref: 调整springboot3.2下接口404的异常处理 fix: 修复特定分钟粒度下获取监测数据的sql错误问题dev-lensfrex
parent
c82c6d5799
commit
3fb9308f95
@ -0,0 +1,36 @@ |
||||
package rition.backend.api.interceptor; |
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import jakarta.annotation.Nonnull; |
||||
import jakarta.servlet.http.HttpServletRequest; |
||||
import jakarta.servlet.http.HttpServletResponse; |
||||
import org.springframework.http.HttpStatus; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.servlet.HandlerInterceptor; |
||||
import org.springframework.web.servlet.ModelAndView; |
||||
import rition.backend.api.v1.dto.response.Response; |
||||
import rition.common.exception.code.ServiceCode; |
||||
|
||||
@Component |
||||
public class NotFoundPathInterceptor implements HandlerInterceptor { |
||||
private final ObjectMapper objectMapper; |
||||
|
||||
public NotFoundPathInterceptor(ObjectMapper objectMapper) { |
||||
this.objectMapper = objectMapper; |
||||
} |
||||
|
||||
@Override |
||||
public void postHandle(@Nonnull HttpServletRequest request, |
||||
@Nonnull HttpServletResponse servletResponse, |
||||
@Nonnull Object handler, |
||||
ModelAndView modelAndView) throws Exception { |
||||
if (servletResponse.getStatus() == HttpStatus.NOT_FOUND.value()) { |
||||
var response = Response.error(ServiceCode.ApiNotImplement); |
||||
var json = objectMapper.writeValueAsString(response); |
||||
|
||||
servletResponse.setContentType("application/json"); |
||||
servletResponse.setCharacterEncoding("utf-8"); |
||||
servletResponse.getWriter().write(json); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue