Commit 6914d9f0 authored by xuepeng.chang's avatar xuepeng.chang

头像替换 avatar.xyqb.com 域名处理

parent da0fa8ad
...@@ -27,6 +27,11 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -27,6 +27,11 @@ 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 javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
...@@ -321,16 +326,16 @@ public class UserCenterController implements IBaseController { ...@@ -321,16 +326,16 @@ public class UserCenterController implements IBaseController {
for (UserInfoEntity userInfoEntity : allUserInfo) { for (UserInfoEntity userInfoEntity : allUserInfo) {
executorService.execute(() -> { executorService.execute(() -> {
try { try {
String avatarUrl = userInfoEntity.getPhoto(); String avatarUrl= userInfoEntity.getPhoto();
log.info("开始执行头像刷新.id={},avatarUrl={}", userInfoEntity.getId(),avatarUrl); log.info("开始执行头像刷新.id={},avatarUrl={}", userInfoEntity.getId(),avatarUrl);
if(StringUtils.isEmpty(avatarUrl)){ if(StringUtils.isEmpty(avatarUrl)){
return; return;
} }
if(StringUtils.isEmpty(extractPhoneNumberFromUrl(avatarUrl))){ if (avatarUrl.contains("avatar.xyqb.com")) {
return; avatarUrl=avatarUrl.replace("avatar.xyqb.com", "avatar.q-gp.com");
} }
byte[] avatarBytes = HttpClientUtil.download(avatarUrl); byte[] avatarBytes = HttpClientUtil.download(avatarUrl);
// log.info("头像:"+avatarBytes);
if(Objects.isNull(avatarBytes)){ if(Objects.isNull(avatarBytes)){
log.info("下载头像失败.id={},avatarUrl={}", userInfoEntity.getId(),avatarUrl); log.info("下载头像失败.id={},avatarUrl={}", userInfoEntity.getId(),avatarUrl);
userInfoEntity.setPhoto("https://img.91xr.cn/avatar.18dd2e2a.png"); userInfoEntity.setPhoto("https://img.91xr.cn/avatar.18dd2e2a.png");
...@@ -338,7 +343,7 @@ public class UserCenterController implements IBaseController { ...@@ -338,7 +343,7 @@ public class UserCenterController implements IBaseController {
return; return;
} }
String imageName = "avatar/"+UUID.randomUUID().toString()+".jpg"; String imageName = "avatar/"+UUID.randomUUID().toString()+".jpg";
String fileName = qiNiuYunUtil.overrideUpload(avatarBytes, ".jpg",imageName); String fileName = qiNiuYunUtil.upload(avatarBytes, null);
userInfoEntity.setPhoto(fileName); userInfoEntity.setPhoto(fileName);
userInfoRepository.save(userInfoEntity); userInfoRepository.save(userInfoEntity);
log.info("开始执行头像刷新完成.id={},avatarUrl={}", userInfoEntity.getId(),avatarUrl); log.info("开始执行头像刷新完成.id={},avatarUrl={}", userInfoEntity.getId(),avatarUrl);
......
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