diff --git a/luoo_tag/src/main/java/com/luoo/tag/pojo/Tag.java b/luoo_tag/src/main/java/com/luoo/tag/pojo/Tag.java index bb35c90..7b8a383 100644 --- a/luoo_tag/src/main/java/com/luoo/tag/pojo/Tag.java +++ b/luoo_tag/src/main/java/com/luoo/tag/pojo/Tag.java @@ -63,6 +63,11 @@ public class Tag implements Serializable { */ private String image; + /** + * 缩略图路径 + */ + private String thumbnail; + /** * 创建人用户ID */ diff --git a/luoo_tag/src/main/java/com/luoo/tag/pojo/TagCreateReq.java b/luoo_tag/src/main/java/com/luoo/tag/pojo/TagCreateReq.java index 1730fe7..baa9c54 100644 --- a/luoo_tag/src/main/java/com/luoo/tag/pojo/TagCreateReq.java +++ b/luoo_tag/src/main/java/com/luoo/tag/pojo/TagCreateReq.java @@ -30,4 +30,7 @@ public class TagCreateReq implements Serializable { @ApiModelProperty(value = "图片路径") private String image; + + @ApiModelProperty(value = "缩略图路径") + private String thumbnail; } diff --git a/luoo_tag/src/main/java/com/luoo/tag/pojo/TagDTO.java b/luoo_tag/src/main/java/com/luoo/tag/pojo/TagDTO.java index 9a59d8a..248cff4 100644 --- a/luoo_tag/src/main/java/com/luoo/tag/pojo/TagDTO.java +++ b/luoo_tag/src/main/java/com/luoo/tag/pojo/TagDTO.java @@ -37,6 +37,9 @@ public class TagDTO implements Serializable { @ApiModelProperty(value = "图片") private String image; + @ApiModelProperty(value = "缩略图") + private String thumbnail; + @ApiModelProperty(value = "子标签数量") private Long childTagCount = 0L; diff --git a/luoo_tag/src/main/java/com/luoo/tag/pojo/TagUpdateReq.java b/luoo_tag/src/main/java/com/luoo/tag/pojo/TagUpdateReq.java index ed04d6d..290d91e 100644 --- a/luoo_tag/src/main/java/com/luoo/tag/pojo/TagUpdateReq.java +++ b/luoo_tag/src/main/java/com/luoo/tag/pojo/TagUpdateReq.java @@ -37,4 +37,7 @@ public class TagUpdateReq implements Serializable { @ApiModelProperty(value = "图片路径") private String image; + + @ApiModelProperty(value = "缩略图路径") + private String thumbnail; } diff --git a/luoo_tag/src/main/java/com/luoo/tag/service/TagService.java b/luoo_tag/src/main/java/com/luoo/tag/service/TagService.java index 7abe5ba..3c1cafe 100644 --- a/luoo_tag/src/main/java/com/luoo/tag/service/TagService.java +++ b/luoo_tag/src/main/java/com/luoo/tag/service/TagService.java @@ -70,7 +70,8 @@ public class TagService { tagDTO.setChildTagCount(tagStatistic.getChildTagCount()); tagDTO.setJournalRefCount(tagStatistic.getJournalRefCount()); tagDTO.setSongRefCount(tagStatistic.getSongRefCount()); - tagDTO.setImage(TagS3Service.TAG_RESOURCE_PREFIX + TagS3Service.TAG_KEY_PREFIX + tag.getImage()); + tagDTO.setImage(null == tag.getImage() ? null : TagS3Service.TAG_RESOURCE_PREFIX + TagS3Service.TAG_KEY_PREFIX + tag.getImage()); + tagDTO.setThumbnail(null == tag.getThumbnail() ? null : TagS3Service.TAG_RESOURCE_PREFIX + TagS3Service.TAG_KEY_PREFIX + tag.getThumbnail()); Tag parentTag = parentTagMap.get(tagDTO.getParentId()); if (Objects.nonNull(parentTag)) { tagDTO.setParentNameCh(parentTag.getNameCh()); @@ -117,6 +118,16 @@ public class TagService { tag.setImage(image); } + if (null != createReq.getThumbnail() && !createReq.getThumbnail().isEmpty()) { + String thumbnail = tagS3Service.moveTagImageFromTempDir( + createReq.getThumbnail(), tag.getId() + ); + if (null == thumbnail) { + Result.failed("缩略图更新失败"); + } + tag.setThumbnail(thumbnail); + } + // // UserInfo userInfo = RequestContext.get(); // tag.setCreatorId(userInfo.getId()); @@ -167,6 +178,19 @@ public class TagService { } } + if (null == updateReq.getThumbnail()) { + tag.setThumbnail(null); + } else { + if (updateReq.getThumbnail().contains(TagS3Service.TEMP_KEY_PREFIX)) { + srcKey = updateReq.getThumbnail().substring(updateReq.getThumbnail().indexOf(TagS3Service.TEMP_KEY_PREFIX)); + } + if (StringUtils.isNotBlank(srcKey)) { + tag.setThumbnail( + tagS3Service.moveTagImageFromTempDir(updateReq.getThumbnail(), id) + ); + } + } + tagDao.save(tag); } @@ -183,6 +207,8 @@ public class TagService { Tag tag = tagOptional.get(); TagDTO tagDTO = new TagDTO(); BeanUtils.copyProperties(tag, tagDTO); + tagDTO.setImage(null == tag.getImage() ? null : TagS3Service.TAG_RESOURCE_PREFIX + TagS3Service.TAG_KEY_PREFIX + tag.getImage()); + tagDTO.setThumbnail(null == tag.getThumbnail() ? null : TagS3Service.TAG_RESOURCE_PREFIX + TagS3Service.TAG_KEY_PREFIX + tag.getThumbnail()); TagStatistic tagStatistic = queryTagStatistic(tag.getId()); tagDTO.setChildTagCount(tagStatistic.getChildTagCount());