Commit 5543af64 authored by AfirSraftGarrier's avatar AfirSraftGarrier

文档说明

parent 27f45898
...@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.GetMapping; ...@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -33,7 +34,7 @@ public class LoginController { ...@@ -33,7 +34,7 @@ public class LoginController {
static Map<String, LoginUser> userMap = new HashMap<>(); static Map<String, LoginUser> userMap = new HashMap<>();
static { static {
LoginUser user1 = new LoginUser("2147483647","root", "123456"); LoginUser user1 = new LoginUser("2147483647", "root", "123456");
userMap.put("2147483647", user1); userMap.put("2147483647", user1);
} }
...@@ -44,8 +45,8 @@ public class LoginController { ...@@ -44,8 +45,8 @@ public class LoginController {
@GetMapping("login") @GetMapping("login")
@MyLog(title = "登录", optParam = "#{userName},#{password}", businessType = BusinessType.OTHER) @MyLog(title = "登录", optParam = "#{userName},#{password}", businessType = BusinessType.OTHER)
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "userName",value = "用户名",required = true), @ApiImplicitParam(name = "userName", value = "用户名", required = true),
@ApiImplicitParam(name = "password",value = "密码",required = true) @ApiImplicitParam(name = "password", value = "密码", required = true)
}) })
public ResResult<LoginVo> login(@RequestParam("userName") String userName, @RequestParam("password") String password) { public ResResult<LoginVo> login(@RequestParam("userName") String userName, @RequestParam("password") String password) {
...@@ -67,4 +68,10 @@ public class LoginController { ...@@ -67,4 +68,10 @@ public class LoginController {
public BaseResult logout() { public BaseResult logout() {
return BaseResult.success(); return BaseResult.success();
} }
@GetMapping("fail")
@ApiIgnore
public ResResult fail() {
return ResResult.fail().msg("认证信息非法");
}
} }
...@@ -44,7 +44,7 @@ public class JwtFilter implements Filter { ...@@ -44,7 +44,7 @@ public class JwtFilter implements Filter {
String uri = request.getRequestURI(); String uri = request.getRequestURI();
if (uri.contains(url1) || uri.contains(url2) || uri.contains(url3) || uri.contains(url4) || uri.contains(url7) || uri.contains(url8)) { if (uri.contains(url1) || uri.contains(url2) || uri.contains(url3) || uri.contains(url4) || uri.contains(url7) || uri.contains(url8)) {
if(uri.contains(url1) || uri.contains(url2) ) { if (uri.contains(url1) || uri.contains(url2)) {
UserUtils.setUri(uri); UserUtils.setUri(uri);
} }
check = false; check = false;
...@@ -61,8 +61,7 @@ public class JwtFilter implements Filter { ...@@ -61,8 +61,7 @@ public class JwtFilter implements Filter {
} else { } else {
DecodedJWT jwt = JwtUtil.verifyToken(token); DecodedJWT jwt = JwtUtil.verifyToken(token);
if (jwt == null) { if (jwt == null) {
String resultStr = JSON.toJSONString(ResResult.fail().msg("认证信息非法")); request.getRequestDispatcher("/fail").forward(request, response);
response.getWriter().write(resultStr);
return; return;
} else { } else {
Map<String, Claim> userData = jwt.getClaims(); Map<String, Claim> userData = jwt.getClaims();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment