|
|
@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
import com.youlai.boot.common.constant.CommonConstants; |
|
|
import com.youlai.boot.common.constant.CommonConstants; |
|
|
import com.youlai.boot.common.exception.BusinessException; |
|
|
import com.youlai.boot.common.exception.MsgException; |
|
|
import com.youlai.boot.common.util.CoordinateTransformUtils; |
|
|
import com.youlai.boot.common.util.CoordinateTransformUtils; |
|
|
import com.youlai.boot.common.util.FileUtils; |
|
|
import com.youlai.boot.common.util.FileUtils; |
|
|
import com.youlai.boot.common.util.JavaVCUtils; |
|
|
import com.youlai.boot.common.util.JavaVCUtils; |
|
|
@ -212,18 +212,18 @@ public class StrayAnimalServiceImpl extends ServiceImpl<MiniStrayAnimalMapper, M |
|
|
private void validateInput(List<MultipartFile> images, List<MultipartFile> videos) { |
|
|
private void validateInput(List<MultipartFile> images, List<MultipartFile> videos) { |
|
|
// 验证必填图片
|
|
|
// 验证必填图片
|
|
|
if (images == null || images.isEmpty()) { |
|
|
if (images == null || images.isEmpty()) { |
|
|
throw new BusinessException("需要上传图片"); |
|
|
throw new MsgException("需要上传图片"); |
|
|
} |
|
|
} |
|
|
// 验证图片数量
|
|
|
// 验证图片数量
|
|
|
if (images.size() > CommonConstants.STRAY_ANIMAL_IMAGE_NUM_LIMIT) { |
|
|
if (images.size() > CommonConstants.STRAY_ANIMAL_IMAGE_NUM_LIMIT) { |
|
|
throw new BusinessException( |
|
|
throw new MsgException( |
|
|
"最多只能上传" + CommonConstants.STRAY_ANIMAL_IMAGE_NUM_LIMIT + "张图片" |
|
|
"最多只能上传" + CommonConstants.STRAY_ANIMAL_IMAGE_NUM_LIMIT + "张图片" |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 验证视频数量
|
|
|
// 验证视频数量
|
|
|
if (!CollUtil.isEmpty(videos) && videos.size() > CommonConstants.STRAY_ANIMAL_VIDEO_NUM_LIMIT) { |
|
|
if (!CollUtil.isEmpty(videos) && videos.size() > CommonConstants.STRAY_ANIMAL_VIDEO_NUM_LIMIT) { |
|
|
throw new BusinessException( |
|
|
throw new MsgException( |
|
|
"最多只能上传" + CommonConstants.STRAY_ANIMAL_VIDEO_NUM_LIMIT + "个视频" |
|
|
"最多只能上传" + CommonConstants.STRAY_ANIMAL_VIDEO_NUM_LIMIT + "个视频" |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
@ -239,11 +239,11 @@ public class StrayAnimalServiceImpl extends ServiceImpl<MiniStrayAnimalMapper, M |
|
|
.eq(MiniStrayAnimal::getDeleted, 0) |
|
|
.eq(MiniStrayAnimal::getDeleted, 0) |
|
|
); |
|
|
); |
|
|
if (animal == null) { |
|
|
if (animal == null) { |
|
|
throw new BusinessException("动物不存在"); |
|
|
throw new MsgException("动物不存在"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (1 == animal.getAuditStatus()) { |
|
|
if (1 == animal.getAuditStatus()) { |
|
|
throw new BusinessException("审核中无法更改"); |
|
|
throw new MsgException("审核中无法更改"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
long currentTimestamp = System.currentTimeMillis(); |
|
|
long currentTimestamp = System.currentTimeMillis(); |
|
|
@ -294,7 +294,7 @@ public class StrayAnimalServiceImpl extends ServiceImpl<MiniStrayAnimalMapper, M |
|
|
MiniStrayAnimalNote note = miniStrayAnimalNoteMapper.selectOne(new LambdaQueryWrapper<MiniStrayAnimalNote>() |
|
|
MiniStrayAnimalNote note = miniStrayAnimalNoteMapper.selectOne(new LambdaQueryWrapper<MiniStrayAnimalNote>() |
|
|
.eq(MiniStrayAnimalNote::getUuid, deleteStrayAnimalNoteMediaDTO.getNoteUuid())); |
|
|
.eq(MiniStrayAnimalNote::getUuid, deleteStrayAnimalNoteMediaDTO.getNoteUuid())); |
|
|
if (note == null) { |
|
|
if (note == null) { |
|
|
throw new BusinessException("笔记不存在"); |
|
|
throw new MsgException("笔记不存在"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
LambdaQueryWrapper<MiniStrayAnimalNoteMedia> queryWrapper = |
|
|
LambdaQueryWrapper<MiniStrayAnimalNoteMedia> queryWrapper = |
|
|
@ -333,7 +333,7 @@ public class StrayAnimalServiceImpl extends ServiceImpl<MiniStrayAnimalMapper, M |
|
|
@Override |
|
|
@Override |
|
|
public void saveMediaSource(String noteUuid, List<MultipartFile> images, List<MultipartFile> videos) { |
|
|
public void saveMediaSource(String noteUuid, List<MultipartFile> images, List<MultipartFile> videos) { |
|
|
if ((images == null || images.isEmpty()) && (videos == null || videos.isEmpty())) { |
|
|
if ((images == null || images.isEmpty()) && (videos == null || videos.isEmpty())) { |
|
|
throw new BusinessException("需要上传媒体资源"); |
|
|
throw new MsgException("需要上传媒体资源"); |
|
|
} |
|
|
} |
|
|
MiniStrayAnimalNote note = miniStrayAnimalNoteMapper.selectOne( |
|
|
MiniStrayAnimalNote note = miniStrayAnimalNoteMapper.selectOne( |
|
|
new LambdaQueryWrapper<MiniStrayAnimalNote>() |
|
|
new LambdaQueryWrapper<MiniStrayAnimalNote>() |
|
|
@ -341,16 +341,16 @@ public class StrayAnimalServiceImpl extends ServiceImpl<MiniStrayAnimalMapper, M |
|
|
.eq(MiniStrayAnimalNote::getDeleted, 0) |
|
|
.eq(MiniStrayAnimalNote::getDeleted, 0) |
|
|
); |
|
|
); |
|
|
if (note == null) { |
|
|
if (note == null) { |
|
|
throw new BusinessException("笔记不存在"); |
|
|
throw new MsgException("笔记不存在"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Long animalId = note.getStrayAnimalId(); |
|
|
Long animalId = note.getStrayAnimalId(); |
|
|
MiniStrayAnimal miniStrayAnimal = miniStrayAnimalMapper.selectById(animalId); |
|
|
MiniStrayAnimal miniStrayAnimal = miniStrayAnimalMapper.selectById(animalId); |
|
|
if (miniStrayAnimal == null) { |
|
|
if (miniStrayAnimal == null) { |
|
|
throw new BusinessException("动物信息不存在"); |
|
|
throw new MsgException("动物信息不存在"); |
|
|
} |
|
|
} |
|
|
if (1 == miniStrayAnimal.getAuditStatus()){ |
|
|
if (1 == miniStrayAnimal.getAuditStatus()){ |
|
|
throw new BusinessException("审核中"); |
|
|
throw new MsgException("审核中"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//校验数量有没有超出
|
|
|
//校验数量有没有超出
|
|
|
@ -361,14 +361,14 @@ public class StrayAnimalServiceImpl extends ServiceImpl<MiniStrayAnimalMapper, M |
|
|
param.put("mediaType", AnimalNoteMediaTypeEnum.IMAGE.name().toLowerCase()); |
|
|
param.put("mediaType", AnimalNoteMediaTypeEnum.IMAGE.name().toLowerCase()); |
|
|
int imagesExist = miniStrayAnimalNoteMediaMapper.getMediaCountByNoteIdAndType(param); |
|
|
int imagesExist = miniStrayAnimalNoteMediaMapper.getMediaCountByNoteIdAndType(param); |
|
|
if (imagesExist+images.size() > CommonConstants.STRAY_ANIMAL_IMAGE_NUM_LIMIT) { |
|
|
if (imagesExist+images.size() > CommonConstants.STRAY_ANIMAL_IMAGE_NUM_LIMIT) { |
|
|
throw new BusinessException("图片总数不能超过" + CommonConstants.STRAY_ANIMAL_IMAGE_NUM_LIMIT + "张"); |
|
|
throw new MsgException("图片总数不能超过" + CommonConstants.STRAY_ANIMAL_IMAGE_NUM_LIMIT + "张"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (CollectionUtils.isNotEmpty(videos)){ |
|
|
if (CollectionUtils.isNotEmpty(videos)){ |
|
|
param.put("mediaType", AnimalNoteMediaTypeEnum.VIDEO.name().toLowerCase()); |
|
|
param.put("mediaType", AnimalNoteMediaTypeEnum.VIDEO.name().toLowerCase()); |
|
|
int videosExist = miniStrayAnimalNoteMediaMapper.getMediaCountByNoteIdAndType(param); |
|
|
int videosExist = miniStrayAnimalNoteMediaMapper.getMediaCountByNoteIdAndType(param); |
|
|
if(videosExist+videos.size() > CommonConstants.STRAY_ANIMAL_VIDEO_NUM_LIMIT){ |
|
|
if(videosExist+videos.size() > CommonConstants.STRAY_ANIMAL_VIDEO_NUM_LIMIT){ |
|
|
throw new BusinessException("视频总数不能超过" + CommonConstants.STRAY_ANIMAL_VIDEO_NUM_LIMIT + "个"); |
|
|
throw new MsgException("视频总数不能超过" + CommonConstants.STRAY_ANIMAL_VIDEO_NUM_LIMIT + "个"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|