1.fix journal image update issue

main
Gary 10 months ago
parent 604476f6d0
commit 6d67d4d60b

@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import util.IdWorker;
@ -53,7 +54,8 @@ public class CMSJournalService {
private SongInfoDao songDao;
@Autowired
private UserClient userClient;
@Autowired
private RedisTemplate redisTemplate;
/**
@ -376,6 +378,7 @@ public class CMSJournalService {
Journal journal=optional.get();
updateJournal(journal, param, token);
journalDao.save(journal);
redisTemplate.opsForValue().set("journal_"+id,journal);
if (!CollectionUtils.isEmpty(param.getTag())) {
journalTagDao.deleteByJournalId(id);
}
@ -409,13 +412,22 @@ public class CMSJournalService {
String tempImage=param.getImage();
if(!StringTools.isEmpty(tempImage)&&tempImage.contains(Constants.TEMP_KEY_PREFIX)) {
String srcKey=param.getImage().substring(param.getImage().indexOf(Constants.TEMP_KEY_PREFIX));
String image = moveJournalImage(srcKey, param);
if (!StringUtils.isBlank(image)) {
String image = copyJournalImage(srcKey, journal.getJournalNo());
if (null!=image) {
journal.setImage(image);
}
}
}
private String copyJournalImage(String srcKey, String journalNo) {
String destKeySuffix = String.format("%05d/%s", Integer.parseInt(journalNo), srcKey.replace(Constants.TEMP_KEY_PREFIX, ""));
String destKey = Constants.MUSIC_KEY_PREFIX + destKeySuffix;
int copy = s3Service.copy(Constants.BUCKET, srcKey, destKey);
if (copy > 0) {
return destKeySuffix;
}
return null;
}
/**
*
* @param journalId

@ -0,0 +1,19 @@
package com.luoo.music.service;
import static org.junit.Assert.*;
import org.junit.Test;
import com.luoo.music.util.Constants;
public class CMSJournalServiceTest {
@Test
public void testUpdateImage() {
String srcKey="temp/1755154941737046016.png";
String destKeySuffix = String.format("%05d/%s", 20, srcKey.replace(Constants.TEMP_KEY_PREFIX, ""));
System.out.println(destKeySuffix);
}
}
Loading…
Cancel
Save