feat:聊天打通用户体系
This commit is contained in:
1 parent
68ccacf074
commit
b03411c009
5 files changed
+11
-9
No files matched your search
+1
-1
@@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/third")
|
||||
@RequestMapping("/third/user")
|
||||
@Tag(name = "第三方/用户")
|
||||
@RequiredArgsConstructor
|
||||
public class ThirdUserController {
|
||||
|
||||
+2
-6
@@ -2,6 +2,7 @@ package com.bx.implatform.dto.third;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
@@ -9,7 +10,7 @@ import org.hibernate.validator.constraints.Length;
|
||||
@Schema(description = "third用户注册DTO")
|
||||
public class ThirdCreateOrUpdateUserDTO {
|
||||
|
||||
@NotEmpty(message = "用户id不可为空")
|
||||
@NotNull(message = "用户id不可为空")
|
||||
@Schema(description = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@@ -22,11 +23,6 @@ public class ThirdCreateOrUpdateUserDTO {
|
||||
@Schema(description = "用户手机号")
|
||||
private String phone;
|
||||
|
||||
@Length(min = 5, max = 20, message = "密码长度必须在5-20个字符之间")
|
||||
@NotEmpty(message = "用户密码不可为空")
|
||||
@Schema(description = "用户密码")
|
||||
private String password;
|
||||
|
||||
@Length(max = 20, message = "昵称不能大于20字符")
|
||||
@Schema(description = "用户昵称")
|
||||
private String nickName;
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ThirdLoginDTO {
|
||||
@Schema(description = "登录终端 0:web 1:app 2:pc")
|
||||
private Integer terminal;
|
||||
|
||||
@NotEmpty(message = "用户id不存在")
|
||||
@NotNull(message = "用户id不存在")
|
||||
@Schema(description = "用户id")
|
||||
private Long userId;
|
||||
|
||||
|
||||
+6
@@ -11,6 +11,7 @@ import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.time.Instant;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -47,6 +48,11 @@ public class ThirdAuthServiceImpl implements ThirdAuthService {
|
||||
if (ObjectUtil.isEmpty(keyType)) {
|
||||
return false;
|
||||
}
|
||||
// timestamp 不能超过5分钟
|
||||
long timestampLong = Long.parseLong(timestamp);
|
||||
if (Instant.now().getEpochSecond() - timestampLong > 5 * 60) {
|
||||
return false;
|
||||
}
|
||||
// 计算签名
|
||||
String signStr = String.format("%s%s%s%s%s", keyType.getAppKey(), keyType.getAppSecret(), keyType.getType(), timestamp, json);
|
||||
String successSignMd5 = DigestUtils.md5Hex(signStr);
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public class ThirdUserServiceImpl extends ServiceImpl<UserMapper, User> implemen
|
||||
saveObjUser.setHeadImageThumb(dto.getAvatar());
|
||||
if (ObjectUtil.isEmpty(user)) {
|
||||
// 创建用户
|
||||
saveObjUser.setPassword(passwordEncoder.encode(dto.getPassword()));
|
||||
saveObjUser.setPassword(passwordEncoder.encode(dto.generatePassword()));
|
||||
baseMapper.insert(saveObjUser);
|
||||
} else {
|
||||
// 更新用户
|
||||
|
||||
Reference in new issue
Block a user