优化加密字段
This commit is contained in:
@@ -101,46 +101,48 @@ public class UserPasswordController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @PostMapping("/set_info")
|
@PostMapping("/set_info")
|
||||||
// public Result newUserSetInfo(
|
public Result newUserSetInfo(
|
||||||
// @RequestHeader(value = "Authorization", required = false) String authHeader, @RequestHeader("Device-ID") String deviceId,
|
@RequestHeader(value = "Authorization", required = false) String authHeader, @RequestHeader("Device-ID") String deviceId,
|
||||||
// @RequestParam(value = "user_id") String userId, @RequestParam(value = "nick_name", required = false) String nickName,
|
@RequestParam(value = "user_id") String userId, @RequestParam(value = "nick_name", required = false) String nickName,
|
||||||
// @RequestParam(value = "avatar", required = false) String avatar,
|
@RequestParam(value = "avatar", required = false) String avatar,
|
||||||
// @RequestParam String password, @RequestParam(value = "verify_password") String verifyPassword) {
|
@RequestParam String password, @RequestParam(value = "verify_password") String verifyPassword) {
|
||||||
//
|
|
||||||
// if (authHeader == null || !authHeader.startsWith("Bearer ")) {
|
if (authHeader == null || !authHeader.startsWith("Bearer ")) {
|
||||||
// return Result.error().message("Authorization header is incorrect");
|
return Result.error().message("Authorization header is incorrect");
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// String token = authHeader.substring(7);
|
String token = authHeader.substring(7);
|
||||||
// if (!jwtUtil.validateAccessToken(userId, token, deviceId)) {
|
if (!jwtUtil.validateAccessToken(userId, token, deviceId)) {
|
||||||
// return Result.error().message("Invalid token");
|
return Result.error().message("Invalid token");
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// User user = userService.getUserByUserId(userId);
|
User user = userService.getUserByUserId(userId);
|
||||||
// if (user == null) {
|
if (user == null) {
|
||||||
// return Result.error().message("user not found");
|
return Result.error().message("user not found");
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if (!TextUtils.isEmpty(user.getPassword())) {
|
if (!TextUtils.isEmpty(user.getPassword())) {
|
||||||
// return Result.error().message("user is not new user");
|
return Result.error().message("user is not new user");
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if (!StringUtils.equals(password, verifyPassword)) {
|
if (!StringUtils.equals(password, verifyPassword)) {
|
||||||
// return Result.error().message("password is not same");
|
return Result.error().message("password is not same");
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// user.setPassword(password);
|
user.setPassword(password);
|
||||||
// if (!TextUtils.isEmpty(nickName)) {
|
|
||||||
// user.setNickname(nickName);
|
if (!TextUtils.isEmpty(nickName)) {
|
||||||
// }
|
user.setNickname(nickName);
|
||||||
// if (!TextUtils.isEmpty(avatar)) {
|
}
|
||||||
// user.setAvatar(avatar);
|
if (!TextUtils.isEmpty(avatar)) {
|
||||||
// }
|
user.setAvatar(avatar);
|
||||||
// if (userService.updateUser(user)) {
|
}
|
||||||
// return Result.ok().message("set info success");
|
|
||||||
// } else {
|
if (userService.saveUser(user)) {
|
||||||
// return Result.error().message("set info fail");
|
return Result.ok().message("set info success");
|
||||||
// }
|
} else {
|
||||||
// }
|
return Result.error().message("set info fail");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,26 @@
|
|||||||
package com.onekeycall.videotablet.entity;
|
package com.onekeycall.videotablet.entity;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.onekeycall.videotablet.converter.AesAttributeConverter;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "tablet_default_settings")
|
@Table(name = "device_contacts")
|
||||||
public class Contact {
|
public class Contact {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id",unique = true, nullable = false)
|
@Column(name = "id",unique = true, nullable = false)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@Convert(converter = AesAttributeConverter.class)
|
||||||
@NotBlank(message = "姓名不能为空")
|
@NotBlank(message = "姓名不能为空")
|
||||||
@Column
|
@Column
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@Convert(converter = AesAttributeConverter.class)
|
||||||
@NotBlank(message = "手机号不能为空")
|
@NotBlank(message = "手机号不能为空")
|
||||||
@JsonProperty("phone_number")
|
@JsonProperty("phone_number")
|
||||||
@Column(name = "phone_number")
|
@Column(name = "phone_number")
|
||||||
@@ -29,9 +32,11 @@ public class Contact {
|
|||||||
@Column
|
@Column
|
||||||
private String tag;
|
private String tag;
|
||||||
|
|
||||||
|
@Convert(converter = AesAttributeConverter.class)
|
||||||
@Column
|
@Column
|
||||||
private String wxid;
|
private String wxid;
|
||||||
|
|
||||||
|
@Convert(converter = AesAttributeConverter.class)
|
||||||
@Column
|
@Column
|
||||||
private String qq;
|
private String qq;
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ public class DeviceInfo {
|
|||||||
@Column(name = "tablet_avatar")
|
@Column(name = "tablet_avatar")
|
||||||
private String tabletAvatar;
|
private String tabletAvatar;
|
||||||
|
|
||||||
@Convert(converter = AesAttributeConverter.class)
|
|
||||||
@Column(name = "user_id")
|
@Column(name = "user_id")
|
||||||
private String userId;
|
private String userId;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.onekeycall.videotablet.entity;
|
package com.onekeycall.videotablet.entity;
|
||||||
|
|
||||||
|
import com.onekeycall.videotablet.converter.AesAttributeConverter;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -18,9 +19,11 @@ public class DeviceLocation {
|
|||||||
@Column(name = "sn", unique = true, nullable = false)
|
@Column(name = "sn", unique = true, nullable = false)
|
||||||
String sn;
|
String sn;
|
||||||
|
|
||||||
|
@Convert(converter = AesAttributeConverter.class)
|
||||||
@Column(name = "address", nullable = false)
|
@Column(name = "address", nullable = false)
|
||||||
String address;
|
String address;
|
||||||
|
|
||||||
|
@Convert(converter = AesAttributeConverter.class)
|
||||||
@Column(name = "location_describe")
|
@Column(name = "location_describe")
|
||||||
String location_describe;
|
String location_describe;
|
||||||
|
|
||||||
|
|||||||
@@ -27,14 +27,13 @@ public class User implements UserDetails {
|
|||||||
@Column(name = "user_id", unique = true, nullable = false)
|
@Column(name = "user_id", unique = true, nullable = false)
|
||||||
private String userId;
|
private String userId;
|
||||||
|
|
||||||
// 使用@Convert注解指定转换器
|
|
||||||
@Convert(converter = AesAttributeConverter.class)
|
|
||||||
@Column
|
@Column
|
||||||
private String nickname;
|
private String nickname;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
// 使用@Convert注解指定转换器
|
||||||
@Convert(converter = AesAttributeConverter.class)
|
@Convert(converter = AesAttributeConverter.class)
|
||||||
@Column(unique = true, nullable = false)
|
@Column(unique = true, nullable = false)
|
||||||
private String phone;
|
private String phone;
|
||||||
|
|||||||
@@ -125,4 +125,12 @@ public class UserService implements UserDetailsService {
|
|||||||
// }
|
// }
|
||||||
// return userRepository.updateUser(user);
|
// return userRepository.updateUser(user);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
public boolean saveUser(User user) {
|
||||||
|
if (userRepository.existsByUserId(user.getUserId())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
userRepository.save(user);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user