|
|
|
@ -9,10 +9,7 @@ import org.springframework.data.annotation.CreatedDate;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import util.IdWorker;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class UserCollectInfoService {
|
|
|
|
@ -38,7 +35,7 @@ public class UserCollectInfoService {
|
|
|
|
|
List list = new ArrayList();
|
|
|
|
|
list.add(userCollectSongDto);
|
|
|
|
|
list.add(userCollectSongDto1);
|
|
|
|
|
userCollectInfo.setSongList(list);
|
|
|
|
|
// userCollectInfo.setSongList(list);
|
|
|
|
|
userCollectInfo.setCollectId(idWorker.nextId()+"");
|
|
|
|
|
userCollectInfo.setUserId("111222");
|
|
|
|
|
userCollectInfoDao.save(userCollectInfo);
|
|
|
|
@ -50,12 +47,76 @@ public class UserCollectInfoService {
|
|
|
|
|
return userCollectInfoDao.findUserCollectInfoByUserId(userId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void collectSong(String userid, String id) {
|
|
|
|
|
|
|
|
|
|
UserCollectInfo userCollectInfo = userCollectInfoDao.findUserCollectInfoByUserId(userid);
|
|
|
|
|
if (null == userCollectInfo) {
|
|
|
|
|
userCollectInfo = new UserCollectInfo();
|
|
|
|
|
userCollectInfo.setUserId(userid);
|
|
|
|
|
Set songSet = new HashSet();
|
|
|
|
|
songSet.add(id);
|
|
|
|
|
userCollectInfo.setSongSet(songSet);
|
|
|
|
|
userCollectInfoDao.save(userCollectInfo);
|
|
|
|
|
} else {
|
|
|
|
|
Set songSet = userCollectInfo.getSongSet();
|
|
|
|
|
if(null == songSet) {
|
|
|
|
|
songSet = new HashSet<>();
|
|
|
|
|
}
|
|
|
|
|
songSet.add(id);
|
|
|
|
|
|
|
|
|
|
userCollectInfo.setSongSet(songSet);
|
|
|
|
|
userCollectInfoDao.save(userCollectInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void collectJournal(String userid, String id) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UserCollectInfo userCollectInfo = userCollectInfoDao.findUserCollectInfoByUserId(userid);
|
|
|
|
|
if (null == userCollectInfo) {
|
|
|
|
|
userCollectInfo = new UserCollectInfo();
|
|
|
|
|
userCollectInfo.setUserId(userid);
|
|
|
|
|
Set journalSet = new HashSet();
|
|
|
|
|
journalSet.add(id);
|
|
|
|
|
userCollectInfo.setJournalSet(journalSet);
|
|
|
|
|
userCollectInfoDao.save(userCollectInfo);
|
|
|
|
|
} else {
|
|
|
|
|
Set journalSet =userCollectInfo.getJournalSet();
|
|
|
|
|
if(null== journalSet) {
|
|
|
|
|
journalSet = new HashSet();
|
|
|
|
|
}
|
|
|
|
|
journalSet.add(id);
|
|
|
|
|
userCollectInfo.setJournalSet(journalSet);
|
|
|
|
|
userCollectInfoDao.save(userCollectInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 方法过期
|
|
|
|
|
*/
|
|
|
|
|
public void unCollect(){
|
|
|
|
|
UserCollectInfo userCollectInfo = userCollectInfoDao.findUserCollectInfoByUserId("111222");
|
|
|
|
|
UserCollectSongDto userCollectSongDto = new UserCollectSongDto();
|
|
|
|
|
userCollectSongDto.setName("smell like teensprit");
|
|
|
|
|
userCollectSongDto.setArtist("Nirvana");
|
|
|
|
|
userCollectInfo.getSongList().remove(userCollectSongDto);
|
|
|
|
|
// userCollectInfo.getSongList().remove(userCollectSongDto);
|
|
|
|
|
userCollectInfoDao.save(userCollectInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void unCollectJournal(String userid, String id) {
|
|
|
|
|
UserCollectInfo userCollectInfo = userCollectInfoDao.findUserCollectInfoByUserId(userid);
|
|
|
|
|
userCollectInfo.getJournalSet().remove(id);
|
|
|
|
|
userCollectInfoDao.save(userCollectInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void unCollectSong(String userid, String id) {
|
|
|
|
|
UserCollectInfo userCollectInfo = userCollectInfoDao.findUserCollectInfoByUserId(userid);
|
|
|
|
|
userCollectInfo.getSongSet().remove(id);
|
|
|
|
|
userCollectInfoDao.save(userCollectInfo);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|