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> <groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId> <artifactId>swagger-bootstrap-ui</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

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

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

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

@ -3,7 +3,8 @@ package com.luoo.music.dao;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import mongodb.UserCollect; import com.luoo.music.pojo.UserCollect;
public interface UserCollectDao extends MongoRepository<UserCollect, String> { public interface UserCollectDao extends MongoRepository<UserCollect, String> {
public long countByUserIdAndObjectIdAndCollectType(String userId, String objectId, Integer collectType); 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> </parent>
<artifactId>luoo_user</artifactId> <artifactId>luoo_user</artifactId>
<dependencies> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>

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

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

Loading…
Cancel
Save