Commit c674d9bf authored by zengtianlai3's avatar zengtianlai3

更改驼峰命名变量

parent 8e9e0707
......@@ -36,11 +36,11 @@ public class LoginController {
public ResResult login(@RequestParam("userName") String userName, @RequestParam("password") String password) {
// @RequestBody JSONObject jsonObject
LoginUser user = new LoginUser();
user.setUser_name(userName);
user.setUserName(userName);
user.setPassword(password);
for (LoginUser dbUser : userMap.values()) {
if (dbUser.getUser_name().equals(user.getUser_name()) && dbUser.getPassword().equals(user.getPassword())) {
if (dbUser.getUserName().equals(user.getUserName()) && dbUser.getPassword().equals(user.getPassword())) {
log.info("登录成功!生成token!");
String token = JwtUtil.createToken(dbUser);
Map<String, String> map = new HashMap<>();
......@@ -56,11 +56,11 @@ public class LoginController {
public ResResult logout(@RequestParam("userName") String userName, @RequestParam("password") String password) {
// @RequestBody JSONObject jsonObject
LoginUser user = new LoginUser();
user.setUser_name(userName);
user.setUserName(userName);
user.setPassword(password);
for (LoginUser dbUser : userMap.values()) {
if (dbUser.getUser_name().equals(user.getUser_name()) && dbUser.getPassword().equals(user.getPassword())) {
if (dbUser.getUserName().equals(user.getUserName()) && dbUser.getPassword().equals(user.getPassword())) {
log.info("登录成功!生成token!");
String token = JwtUtil.createToken(dbUser);
Map<String, String> map = new HashMap<>();
......@@ -69,6 +69,6 @@ public class LoginController {
return ResResult.success().record(map);
}
}
return ResResult.fail().msg("user_name or password is error");
return ResResult.fail().msg("用户名或密码错误");
}
}
......@@ -20,14 +20,14 @@ public class OperateController {
List<JSONObject> list = new ArrayList<>();
JSONObject obj = new JSONObject();
obj.put("server_ip", "192.168.1.11");
obj.put("server_sam", 100);
obj.put("online_count",55);
obj.put("serverIp", "192.168.1.11");
obj.put("serverSam", 100);
obj.put("onlineCount",55);
list.add(obj);
JSONObject obj2 = new JSONObject();
obj2.put("server_ip", "192.168.1.12");
obj2.put("server_sam", 100);
obj2.put("online_count",55);
obj2.put("serverIp", "192.168.1.12");
obj2.put("serverSam", 100);
obj2.put("onlineCount",55);
list.add(obj2);
return ResResult.success().record(list);
}
......
......@@ -7,6 +7,7 @@ import iot.sixiang.license.model.ResResult;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
......@@ -60,10 +61,10 @@ public class JwtFilter implements Filter {
return;
}
String userName = userData.get("user_name").asString();
String userName = userData.get("userName").asString();
String password = userData.get("password").asString();
//拦截器 拿到用户信息,放到request中
request.setAttribute("user_name", userName);
request.setAttribute("userName", userName);
request.setAttribute("password", password);
filterChain.doFilter(servletRequest, servletResponse);
}
......
......@@ -35,7 +35,7 @@ public class JwtUtil {
String token= JWT.create()
.withHeader(map) //添加头部
//可以把数据存在claim中
.withClaim("user_name",user.getUser_name())
.withClaim("userName",user.getUserName())
.withClaim("password",user.getPassword())
.withExpiresAt(expireDate) //超时设置,设置过期的日期
.withIssuedAt(new Date()) //签发时间
......
......@@ -4,14 +4,14 @@ import lombok.Data;
@Data
public class LoginUser {
private String user_name;
private String userName;
private String password;
public LoginUser() {
}
public LoginUser(String user_name, String password) {
this.user_name = user_name;
public LoginUser(String userName, String password) {
this.userName = userName;
this.password = password;
}
}
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