动态头像-mp4-将YidunCheck审核内聚到uploadAvatarService中

This commit is contained in:
2025-09-04 20:21:42 +08:00
parent ec423e930a
commit 723b1c57d8
7 changed files with 36 additions and 16 deletions

View File

@@ -7,7 +7,7 @@ import java.util.Set;
public class ImageFileUtils {
// 定义一个包含常见静态图片扩展名的数组
private static final Set<String> imageFileExtensionSet = Set.of("jpg", "jpeg", "png", "gif", "svga");
private static final Set<String> imageFileExtensionSet = Set.of("jpg", "jpeg", "png", "gif", "svga", "mp4");
public static boolean isImageFile(String url) {
String extension = StringUtils.substringAfterLast(url, ".");
@@ -19,4 +19,9 @@ public class ImageFileUtils {
return "gif".equals(extension);
}
public static boolean isMp4(String url){
String extension = StringUtils.substringAfterLast(url, ".");
return "mp4".equals(extension);
}
}

View File

@@ -8,11 +8,13 @@ import com.accompany.business.mybatismapper.AvatarPaidRecordMapper;
import com.accompany.business.param.neteasepush.NeteaseSendMsgParam;
import com.accompany.business.service.family.FamilyService;
import com.accompany.business.service.guild.GuildService;
import com.accompany.business.service.netease.YidunCheckUtil;
import com.accompany.business.service.purse.UserPurseService;
import com.accompany.business.service.room.RoomService;
import com.accompany.business.util.VipUtil;
import com.accompany.common.config.SystemConfig;
import com.accompany.common.constant.Constant;
import com.accompany.common.device.DeviceInfo;
import com.accompany.common.netease.ErBanNetEaseService;
import com.accompany.common.netease.neteaseacc.result.BaseNetEaseRet;
import com.accompany.common.redis.RedisKey;
@@ -198,4 +200,8 @@ public class UploadAvatarService extends BaseService {
sendSysMsgService.sendMsg(msg);
}
public void reviewAvatar(Long uid, String avatar, String redisKey, Long price, String ip, String deviceId) {
YidunCheckUtil.reviewAvatar(uid, avatar, redisKey, price, ip, deviceId);
}
}

View File

@@ -3,6 +3,7 @@ package com.accompany.business.service.family;
import com.accompany.business.constant.family.FamilyConstant;
import com.accompany.business.event.FamilyMemberStatusChangeEvent;
import com.accompany.business.model.family.*;
import com.accompany.business.service.UploadAvatarService;
import com.accompany.business.service.guild.BdGuildService;
import com.accompany.business.service.level.LevelService;
import com.accompany.business.service.netease.YidunCheckUtil;
@@ -73,6 +74,8 @@ public class FamilyManagerService {
private BdGuildService bdGuildService;
@Autowired
private ApplicationContext applicationContext;
@Autowired
private UploadAvatarService uploadAvatarService;
@SneakyThrows
public FamilyVo getFamilyVo(Long uid) {
@@ -306,11 +309,10 @@ public class FamilyManagerService {
if (!StringUtils.isBlank(avatar)){
if (!ImageFileUtils.isImageFile(avatar)) {
throw new ServiceException(BusiStatus.FILE_FORMAT_ERROR);
} else if (ImageFileUtils.isGif(avatar)) {
throw new ServiceException(BusiStatus.CANNOT_UPLOAD_GIF);
}
DeviceInfo deviceInfo = DeviceInfoContextHolder.get();
YidunCheckUtil.reviewAvatar(uid, avatar, RedisKey.family_avatar_under_review.getKey(), deviceInfo);
uploadAvatarService.reviewAvatar(uid, avatar, RedisKey.family_avatar_under_review.getKey(), null, deviceInfo.getClientIp(), deviceInfo.getDeviceId());
}
if (!StringUtils.isBlank(backgroundUrl)){

View File

@@ -7,6 +7,7 @@ import com.accompany.business.model.guild.Guild;
import com.accompany.business.model.guild.GuildAuth;
import com.accompany.business.model.guild.GuildMember;
import com.accompany.business.model.guild.GuildOperateRecord;
import com.accompany.business.service.UploadAvatarService;
import com.accompany.business.service.level.LevelService;
import com.accompany.business.service.netease.YidunCheckUtil;
import com.accompany.business.service.purse.UserPurseService;
@@ -90,6 +91,8 @@ public class GuildManagerService {
private ApplicationContext applicationContext;
@Autowired
private UserPurseService userPurseService;
@Autowired
private UploadAvatarService uploadAvatarService;
@SneakyThrows
public GuildVo getGuildVo(Long uid) {
@@ -349,11 +352,10 @@ public class GuildManagerService {
if (!StringUtils.isBlank(avatar)){
if (!ImageFileUtils.isImageFile(avatar)) {
throw new ServiceException(BusiStatus.FILE_FORMAT_ERROR);
} else if (ImageFileUtils.isGif(avatar)) {
throw new ServiceException(BusiStatus.CANNOT_UPLOAD_GIF);
}
DeviceInfo deviceInfo = DeviceInfoContextHolder.get();
YidunCheckUtil.reviewAvatar(uid, avatar, RedisKey.guild_avatar_under_review.getKey(), deviceInfo);
uploadAvatarService.reviewAvatar(uid, avatar, RedisKey.guild_avatar_under_review.getKey(), null, deviceInfo.getClientIp(), deviceInfo.getDeviceId());
}
if (!StringUtils.isBlank(backgroundUrl)){

View File

@@ -159,7 +159,7 @@ public class YidunCheckUtil {
* @param deviceInfo
*/
public static void reviewAvatar(Long uid, String avatar, String redisKey, DeviceInfo deviceInfo) {
reviewAvatar(uid, avatar, redisKey, null, deviceInfo);
reviewAvatar(uid, avatar, redisKey, null, deviceInfo.getClientIp(), deviceInfo.getDeviceId());
}
/**
@@ -167,11 +167,13 @@ public class YidunCheckUtil {
*
* @param avatar
*/
public static void reviewAvatar(Long uid, String avatar, String redisKey, Long price, DeviceInfo deviceInfo) {
public static void reviewAvatar(Long uid, String avatar, String redisKey, Long price, String ip, String deviceId) {
log.info("用户{}进行头像{}上传审核", uid, avatar);
if (StringUtils.isBlank(avatar) || ObjectUtil.isNull(uid))
return;
//todo upload
if (SpringContextHolder.getBean(EnvComponent.class).getDevOrNativeEnv()){
String taskId = UUIDUtil.get();
SpringContextHolder.getBean(UploadAvatarService.class).cacheReviewAvatar(redisKey, String.valueOf(uid), avatar, price);
@@ -191,8 +193,8 @@ public class YidunCheckUtil {
// 传图片url进行检测name结构产品自行设计用于唯一定位该图片数据
JsonObject image = new JsonObject();
image.addProperty("account", uid);
image.addProperty("ip", deviceInfo.getClientIp());
image.addProperty("deviceId", deviceInfo.getDeviceId());
image.addProperty("ip", ip);
image.addProperty("deviceId", deviceId);
image.addProperty("name", redisKey);
image.addProperty("type", 1);
// 主动回调地址url,如果设置了则走主动回调逻辑

View File

@@ -7,6 +7,7 @@ import com.accompany.business.event.RoomOpenEvent;
import com.accompany.business.event.room.RoomPasswordChangeEvent;
import com.accompany.business.param.RoomParam;
import com.accompany.business.sensitvienew.SensitiveFilterUtil;
import com.accompany.business.service.UploadAvatarService;
import com.accompany.business.service.dfa.DfaService;
import com.accompany.business.service.netease.YidunCheckUtil;
import com.accompany.business.service.user.UsersService;
@@ -62,6 +63,8 @@ public class RoomManageService {
private DfaService dfaService;
@Autowired
private RoomLevelService roomLevelService;
@Autowired
private UploadAvatarService uploadAvatarService;
@Transactional(rollbackFor = Exception.class)
public void switchType(Long roomUid, Byte newRoomType, Byte newPermitType) {
@@ -219,11 +222,10 @@ public class RoomManageService {
if (StringUtils.isNotBlank(newRoom.getAvatar()) && !oldRoom.getAvatar().equals(newRoom.getAvatar())){
if (!ImageFileUtils.isImageFile(newRoom.getAvatar())) {
throw new ServiceException(BusiStatus.FILE_FORMAT_ERROR);
} else if (ImageFileUtils.isGif(newRoom.getAvatar())) {
throw new ServiceException(BusiStatus.CANNOT_UPLOAD_GIF);
}
YidunCheckUtil.reviewAvatar(uid, newRoom.getAvatar(), RedisKey.room_avatar_under_review.getKey(), deviceInfo);
uploadAvatarService.reviewAvatar(uid, newRoom.getAvatar(), RedisKey.room_avatar_under_review.getKey(), null, deviceInfo.getClientIp(), deviceInfo.getDeviceId());
newRoom.setAvatar(null);
}

View File

@@ -594,7 +594,7 @@ public class UsersService extends BaseService {
userVo.setIsReview(true);
userVo.setNewAvatar(jedisService.hget(RedisKey.user_avatar_under_review.getKey(), String.valueOf(users.getUid())));
YidunCheckUtil.reviewAvatar(users.getUid(), avatarUrl, RedisKey.user_avatar_under_review.getKey(), avatarPrice, deviceInfo);
uploadAvatarService.reviewAvatar(users.getUid(), avatarUrl, RedisKey.user_avatar_under_review.getKey(), avatarPrice, deviceInfo.getClientIp(), deviceInfo.getDeviceId());
}
applicationContext.publishEvent(new RoomCacheDealEvent(users.getUid()));
return userVo;
@@ -647,7 +647,8 @@ public class UsersService extends BaseService {
}
Long price = uploadAvatarService.checkAvatarUrlAndPaid(uid, avatarUrl, needPay);
YidunCheckUtil.reviewAvatar(uid, avatarUrl, RedisKey.user_avatar_under_review.getKey(), price, deviceInfo);
uploadAvatarService.reviewAvatar(uid, avatarUrl, RedisKey.user_avatar_under_review.getKey(), price, deviceInfo.getClientIp(), deviceInfo.getDeviceId());
deleteUserRelateCaches(u);
}