diff --git a/luoo_user/src/main/java/com/luoo/user/controller/UserCollectInfoController.java b/luoo_user/src/main/java/com/luoo/user/controller/UserCollectInfoController.java new file mode 100644 index 0000000..65f1207 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/controller/UserCollectInfoController.java @@ -0,0 +1,37 @@ +package com.luoo.user.controller; + + +import api.Result; +import com.luoo.user.pojo.UserCollectInfo; +import com.luoo.user.service.UserCollectInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/UserCollectInfo") +public class UserCollectInfoController { + + + @Autowired + private UserCollectInfoService userCollectInfoService; + + + @PostMapping("/save") + public Result save(){ + userCollectInfoService.save(); + return Result.success(); + } + + @GetMapping("/show") + public Result show(){ + UserCollectInfo userCollectInfo =userCollectInfoService.findByUserId(); + return Result.success(userCollectInfo); + } + + @PutMapping("/unCollect") + public Result unCollect() { + userCollectInfoService.unCollect(); + return Result.success(); + } + +} diff --git a/luoo_user/src/main/java/com/luoo/user/dao/UserCollectInfoDao.java b/luoo_user/src/main/java/com/luoo/user/dao/UserCollectInfoDao.java new file mode 100644 index 0000000..21d7e48 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/dao/UserCollectInfoDao.java @@ -0,0 +1,9 @@ +package com.luoo.user.dao; + +import com.luoo.user.pojo.UserCollectInfo; +import org.springframework.data.mongodb.repository.MongoRepository; + +public interface UserCollectInfoDao extends MongoRepository { + + UserCollectInfo findUserCollectInfoByUserId(String userId); +} diff --git a/luoo_user/src/main/java/com/luoo/user/dto/UserCollectJournalDto.java b/luoo_user/src/main/java/com/luoo/user/dto/UserCollectJournalDto.java new file mode 100644 index 0000000..932c189 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/dto/UserCollectJournalDto.java @@ -0,0 +1,59 @@ +package com.luoo.user.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + + +@Data +public class UserCollectJournalDto implements Serializable { + private String id; + + /** + * 期刊编号 + */ + private String number; + /** + * 期刊标题 + */ + private String name; + /** + * 期刊简介 + */ + private String summary; + /** + * 用户ID + */ + private String userId; + /** + * 启停状态 停用:0,启用:1 + */ + private String state; + /** + * 发布状态 未发布:0,已发布:1 + */ + private String status; + /** + * 是否定时 否:0 是:1 + */ + private String scheduled; + /** + * 封面路径 + */ + private String coverPhoto; + /** + * 发布日期 + */ + private LocalDateTime pubTime; + /** + * 创建日期 + */ + private LocalDateTime createTime; + /** + * 更新日期 + */ + private LocalDateTime updateTime; + + +} diff --git a/luoo_user/src/main/java/com/luoo/user/dto/UserCollectSongDto.java b/luoo_user/src/main/java/com/luoo/user/dto/UserCollectSongDto.java new file mode 100644 index 0000000..5eec7b0 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/dto/UserCollectSongDto.java @@ -0,0 +1,67 @@ +package com.luoo.user.dto; + +import lombok.Data; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; + +import java.io.Serializable; +import java.time.LocalDateTime; + + +@Data +public class UserCollectSongDto implements Serializable { + + private String id; + + /** + * 歌曲名称 + */ + private String name; + /** + * 歌手或乐队 + */ + private String artist; + /** + * 专辑 + */ + private String album; + /** + * 封面图片路径 + */ + private String picture; + /** + * 歌曲状态 0:停用,1:启用 + */ + private String state; + /** + * 文件大小 + */ + private Long size; + /** + * 歌曲时长 + */ + private Long duration; + /** + * 歌曲文件路径 + */ + private String url; + /** + * 歌词 + */ + private String lyric; + /** + * 上传人员ID + */ + private String userId; + /** + * 创建日期 + */ + private LocalDateTime createTime; + /** + * 更新日期 + */ + private LocalDateTime updateTime; + + + +} diff --git a/luoo_user/src/main/java/com/luoo/user/pojo/UserCollectInfo.java b/luoo_user/src/main/java/com/luoo/user/pojo/UserCollectInfo.java new file mode 100644 index 0000000..2313084 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/pojo/UserCollectInfo.java @@ -0,0 +1,40 @@ +package com.luoo.user.pojo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + + +@Data +public class UserCollectInfo implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 收藏ID + */ + @Id + private String collectId; + + /** + * 用户ID + */ + private String userId; + + /** + * 收藏的单曲 + */ + private List songList; + + + + /** + * 收藏的期刊 + */ + private List journalList; +} diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserCollectInfoService.java b/luoo_user/src/main/java/com/luoo/user/service/UserCollectInfoService.java new file mode 100644 index 0000000..16cde92 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/service/UserCollectInfoService.java @@ -0,0 +1,61 @@ +package com.luoo.user.service; + + +import com.luoo.user.dao.UserCollectInfoDao; +import com.luoo.user.dto.UserCollectSongDto; +import com.luoo.user.pojo.UserCollectInfo; +import org.springframework.beans.factory.annotation.Autowired; +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; + +@Service +public class UserCollectInfoService { + + @Autowired + private UserCollectInfoDao userCollectInfoDao; + + @Autowired + private IdWorker idWorker; + + + public void save() { + + UserCollectInfo userCollectInfo = new UserCollectInfo(); + UserCollectSongDto userCollectSongDto = new UserCollectSongDto(); + userCollectSongDto.setName("smell like teensprit"); + userCollectSongDto.setArtist("Nirvana"); + + UserCollectSongDto userCollectSongDto1 = new UserCollectSongDto(); + userCollectSongDto1.setName("the unforgiven"); + userCollectSongDto1.setArtist("Metallica"); + + List list = new ArrayList(); + list.add(userCollectSongDto); + list.add(userCollectSongDto1); + userCollectInfo.setSongList(list); + userCollectInfo.setCollectId(idWorker.nextId()+""); + userCollectInfo.setUserId("111222"); + userCollectInfoDao.save(userCollectInfo); + } + + + public UserCollectInfo findByUserId(){ + + return userCollectInfoDao.findUserCollectInfoByUserId("111222"); + } + + public void unCollect(){ + UserCollectInfo userCollectInfo = userCollectInfoDao.findUserCollectInfoByUserId("111222"); + UserCollectSongDto userCollectSongDto = new UserCollectSongDto(); + userCollectSongDto.setName("smell like teensprit"); + userCollectSongDto.setArtist("Nirvana"); + userCollectInfo.getSongList().remove(userCollectSongDto); + userCollectInfoDao.save(userCollectInfo); + } +}