1.add getCollectLatestImage interface

main
Gary 11 months ago
parent 3e6800ea4c
commit a55ec19878

@ -37,6 +37,7 @@ import constants.Constants;
import dto.UserLoginDto;
import enums.CollectTypeEnum;
import util.JwtUtil;
import util.StringTools;
/**
*
@ -139,6 +140,27 @@ public class JournalController {
return songController.getCollectSongs(user.getUserId(), queryReq.getUserId(),objectIds, true);
}
@ApiOperation(value = "2.2 获取用户收藏最新一期的期刊封面")
@GetMapping("/collectLatestImage/{userId}")
@GlobalInterceptor(checkAppUserLogin = true)
public Result<String> collectLatestImage(
@RequestHeader(value = "Authorization", required = true) String authorization,
@PathVariable @VerifyParam(required = true) String userId) {
String objectId=getCollectLatest(userId);
if (StringTools.isEmpty(objectId)) {
return Result.success(null);
}
JournalRespDTO journalRespDTO=journalService.queryJournalById(objectId);
if(null==journalRespDTO) {
return Result.success(null);
}
return Result.success(journalRespDTO.getImage());
}
private String getCollectLatest(String userId) {
return userCollectInfoService.getCollectLatest(userId, CollectTypeEnum.JOURNAL);
}
private List<String> getJournalObjectIds(CollectQueryReq queryReq) {
List<String> jouranlIds=userCollectInfoService.findByUserIdAndCollectType(queryReq.getUserId(), CollectTypeEnum.JOURNAL);
return journalService.orderByJournalIdField(jouranlIds);

@ -15,4 +15,6 @@ public interface UserCollectInfoDao extends MongoRepository<UserCollectInfo, Str
List<UserCollectInfo> findByUserIdAndCollectTypeAndObjectIdIn(String userId, Integer collectType,
List<String> objectIds);
UserCollectInfo findFirstByUserIdAndCollectTypeOrderByCreateTimeDesc(String userId, Integer collectType);
}

@ -62,4 +62,9 @@ public class UserCollectInfoService {
return userCollectInfoDao.findByUserIdAndCollectTypeAndObjectIdIn(userId,
collectTypeEnum.getType(),objectIds).stream().map(UserCollectInfo::getObjectId).collect(Collectors.toList());
}
public String getCollectLatest(String userId, CollectTypeEnum collectTypeEnum) {
UserCollectInfo userCollectInfo=userCollectInfoDao.findFirstByUserIdAndCollectTypeOrderByCreateTimeDesc(userId, collectTypeEnum.getType());
return null==userCollectInfo?null:userCollectInfo.getObjectId();
}
}

Loading…
Cancel
Save