After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 75 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 65 KiB |
After Width: | Height: | Size: 58 KiB |
After Width: | Height: | Size: 65 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 630 KiB |
@ -0,0 +1,20 @@
|
|||||||
|
package com.sa.unsafeincidents.config;
|
||||||
|
|
||||||
|
import com.sa.unsafeincidents.interceptors.LoginInterceptor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class webconfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LoginInterceptor loginInterceptor;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(loginInterceptor).excludePathPatterns("/user/login", "/user/register");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.sa.unsafeincidents.interceptors;
|
||||||
|
|
||||||
|
import com.sa.unsafeincidents.utils.JwtUtil;
|
||||||
|
import com.sa.unsafeincidents.utils.ThreadLocalUtil;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class LoginInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
String token = request.getHeader("Authorization");
|
||||||
|
try {
|
||||||
|
ThreadLocalUtil.set(JwtUtil.parseToken(token));
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
response.setStatus(401);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||||
|
ThreadLocalUtil.remove();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.sa.unsafeincidents.pojo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Image {
|
||||||
|
private Integer id; //图片id
|
||||||
|
private String image; //图片url
|
||||||
|
private String link; //图片跳转链接
|
||||||
|
private String content; //图片文本
|
||||||
|
@JsonIgnore
|
||||||
|
private String category; //图片类别,图片用在什么地方
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 82e6cdfe5347265c04cced222bd6398dcb6eb279
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.5 KiB |
After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |