1.remove mongodb denpency in common component

main
Gary 10 months ago
parent 24a7297d04
commit 6d657ded4c

@ -29,9 +29,5 @@
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
</dependencies>
</project>

@ -7,6 +7,10 @@
</parent>
<artifactId>luoo_music</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>

@ -23,7 +23,6 @@ import dto.UserLoginDto;
import enums.CollectTypeEnum;
import enums.DateTimePatternEnum;
import io.swagger.annotations.ApiOperation;
import mongodb.UserCollect;
import util.DateUtil;
import util.JwtUtil;
@ -59,24 +58,24 @@ public class JournalController {
return Result.success(new PageResult<JournalRespDTO>(Long.valueOf(list.size()), list) );
}
private JournalRespDTO getArticleRespDTO(Article article, UserLoginDto userLoginDto) {
StopWatch sw=new StopWatch();
sw.start("stage1");
//StopWatch sw=new StopWatch();
//sw.start("stage1");
JournalRespDTO journalRespDTO=new JournalRespDTO();
journalRespDTO.setId(article.getId());
journalRespDTO.setJournalNo(article.getVolid());
journalRespDTO.setTitle(article.getTitle());
journalRespDTO.setImage(Constants.MUSIC_RESOURCE_PREFIX+article.getImage());
journalRespDTO.setDate(getEditDate(article));
sw.stop();
System.out.println(sw.prettyPrint());
sw.start("stage2");
//sw.stop();
//System.out.println(sw.prettyPrint());
//sw.start("stage2");
//根据userId查询是否已收藏
if(null!=userLoginDto) {
long userCollectCount=userCollectDao.countByUserIdAndObjectIdAndCollectType(userLoginDto.getUserId(), journalRespDTO.getId(), CollectTypeEnum.JOURNAL.getType());
journalRespDTO.setHaveCollect(userCollectCount>0);
}
sw.stop();
System.out.println(sw.prettyPrint());
//if(null!=userLoginDto) {
// long userCollectCount=userCollectDao.countByUserIdAndObjectIdAndCollectType(userLoginDto.getUserId(), journalRespDTO.getId(), CollectTypeEnum.JOURNAL.getType());
// journalRespDTO.setHaveCollect(userCollectCount>0);
//}
//sw.stop();
//System.out.println(sw.prettyPrint());
return journalRespDTO;
}
private String getEditDate(Article article) {

@ -19,7 +19,6 @@ import enums.VerifyRegexEnum;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import mongodb.UserCollect;
import util.JwtUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -96,10 +95,10 @@ public class SongController {
songRespDTO.setLrc(Constants.MUSIC_RESOURCE_PREFIX + song.getUrl().replace(".mp3", ".lyric"));
songRespDTO.setSongNo(song.getSongno());
// 根据userId查询是否已收藏
if (null != userLoginDto) {
long userCollectCount=userCollectDao.countByUserIdAndObjectIdAndCollectType(userLoginDto.getUserId(), songRespDTO.getId(), CollectTypeEnum.SONG.getType());
songRespDTO.setHaveCollect(userCollectCount>0);
}
//if (null != userLoginDto) {
// long userCollectCount=userCollectDao.countByUserIdAndObjectIdAndCollectType(userLoginDto.getUserId(), songRespDTO.getId(), CollectTypeEnum.SONG.getType());
// songRespDTO.setHaveCollect(userCollectCount>0);
//}
return songRespDTO;
}

@ -3,7 +3,8 @@ package com.luoo.music.dao;
import org.springframework.data.mongodb.repository.MongoRepository;
import mongodb.UserCollect;
import com.luoo.music.pojo.UserCollect;
public interface UserCollectDao extends MongoRepository<UserCollect, String> {
public long countByUserIdAndObjectIdAndCollectType(String userId, String objectId, Integer collectType);

@ -0,0 +1,50 @@
package com.luoo.music.pojo;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.Id;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
/**
*
*/
@Getter
@Setter
public class UserCollect implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID
*/
@Id
private String collectId;
/**
* ID
*/
private String userId;
/**
* ID ID,ID
*/
private String objectId;
/**
* 0:,1:
*/
private Integer collectType;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date collectTime;
}

@ -7,6 +7,10 @@
</parent>
<artifactId>luoo_user</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>

@ -3,7 +3,7 @@ package com.luoo.user.dao;
import org.springframework.data.mongodb.repository.MongoRepository;
import mongodb.UserCollect;
import com.luoo.user.pojo.UserCollect;
public interface UserCollectDao extends MongoRepository<UserCollect, String> {
public UserCollect findByUserIdAndObjectIdAndCollectType(String userId, String objectId, Integer collectType);

@ -1,4 +1,4 @@
package mongodb;
package com.luoo.user.pojo;
import lombok.Getter;
import lombok.Setter;

@ -7,11 +7,11 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.luoo.user.dao.UserCollectDao;
import com.luoo.user.pojo.UserCollect;
import api.StatusCode;
import enums.CollectTypeEnum;
import exception.BizException;
import mongodb.UserCollect;
@Service
public class UserCollectService {

Loading…
Cancel
Save