修复序列化

This commit is contained in:
zjf committed 2025-07-25 15:36:06 +08:00
1 parent 6092511d12
commit 2a8015ef18
1 file changed
+21 -9
@@ -12,9 +12,11 @@ import com.bsd.pjcloud.integrated.service.VisitorUserService;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpHeaders;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
@@ -40,13 +42,15 @@ public class AppVisitorUserController {
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Value("${visitor.jwt-secret}")
private String secret;
// 登录验证
@PostMapping("/login")
// @Inner(value = false)
@Transactional
public R<Map<String, Object>> login(
@RequestParam String phone,
@@ -105,22 +109,30 @@ public class AppVisitorUserController {
private boolean verifyImageCode(String randomStr, String imageCode) {
String key = CacheConstants.VISITOR_CODE_KEY + randomStr;
Object imageCodeValueObj = redisTemplate.opsForValue().get(key);
if (imageCodeValueObj == null) {
String s = stringRedisTemplate.opsForValue().get(key);
// Object imageCodeValueObj = redisTemplate.opsForValue().get(key);
// if (imageCodeValueObj == null) {
// return false;
// }
if (StringUtils.isBlank(s)){
return false;
}
String imageCodeValue = imageCodeValueObj.toString();
return imageCodeValue.equals(imageCode);
// String imageCodeValue = imageCodeValueObj.toString();
return s.equals(imageCode);
}
private boolean verifySmsCode(String phone, String smsCode) {
String key = CacheConstants.SMS_VISITOR_CODE_KEY + phone;
Object smsCodeValueObj = redisTemplate.opsForValue().get(key);
if (smsCodeValueObj == null) {
String s = stringRedisTemplate.opsForValue().get(key);
if (StringUtils.isBlank(s)){
return false;
}
String o = smsCodeValueObj.toString();
return o.equals(smsCode);
// Object smsCodeValueObj = redisTemplate.opsForValue().get(key);
// if (smsCodeValueObj == null) {
// return false;
// }
// String o = smsCodeValueObj.toString();
return s.equals(smsCode);
}