1.code clean

main
Gary 7 months ago
parent 90bad757d5
commit 848143d627

@ -4,7 +4,6 @@ import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.luoo.music.dao.CommentDao;
import com.luoo.music.dto.mapper.JournalMapper;
import com.luoo.music.dto.request.CollectQueryReq;
import com.luoo.music.dto.request.JournalQueryReq;
@ -14,7 +13,6 @@ import com.luoo.music.dto.response.SongRespDTO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
@ -57,12 +55,6 @@ public class JournalController {
@Autowired
private JwtUtil jwtUtil;
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private CommentDao commentDao;
@Autowired
private RedisTemplate redisTemplate;

@ -4,10 +4,8 @@ import com.luoo.music.dto.mapper.SongMapper;
import com.luoo.music.dto.request.CollectQueryReq;
import com.luoo.music.dto.response.SongRespDTO;
import com.luoo.music.pojo.JournalSong;
import com.luoo.music.pojo.SongInfo;
import com.luoo.music.service.JournalService;
import com.luoo.music.service.JournalSongService;
import com.luoo.music.service.SongInfoService;
import com.luoo.music.service.UserCollectInfoService;
import com.luoo.music.util.DeviceTypeUtil;
@ -24,7 +22,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.StringUtils;
import util.JwtUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -50,21 +47,9 @@ public class SongController {
private JournalService journalService;
@Autowired
private RedisTemplate redisTemplate;
//@Autowired
//private SongInfoService songInfoService;
@Autowired
private JwtUtil jwtUtil;
/**
*
*
* @return
*/
@GetMapping
public Result<List<JournalSong>> findAll() {
return Result.success(journalSongService.findAll());
}
@ApiOperation(value = "1.根据期刊号查询歌曲信息", notes = "若为游客期刊号须在最新10期内")
@GetMapping("/getByJournalNo/{journalNo}")
@GlobalInterceptor
@ -77,41 +62,16 @@ public class SongController {
return Result.unauthorized(null);
}
List<SongRespDTO> results = journalSongService.findByJournalNo(journalNo);
// results = results.stream().map(songRespDTO -> randomCDN(songRespDTO)).collect(Collectors.toList());
Set<String> songCollectSet = getSongCollectSet(results,user);
updateCollectStatus(results,songCollectSet);
return Result.success(results);
}
private SongRespDTO randomCDN1(SongRespDTO s){
Random random = new Random();
int rate = random.nextInt(100);
// int randomNum = random.nextInt(2)+1;
int randomNum =1;
if (rate>20) {
randomNum =2;
}
if (!StringUtils.isEmpty(s.getLrc())){
s.setLrc(s.getLrc().replaceFirst("cdn1","cdn"+randomNum));
s.setLrc(s.getLrc().replaceFirst("cdn2","cdn"+randomNum));
}
if (!StringUtils.isEmpty(s.getSrc())){
s.setSrc(s.getSrc().replaceFirst("cdn1","cdn"+randomNum));
s.setSrc(s.getSrc().replaceFirst("cdn2","cdn"+randomNum));
}
if (!StringUtils.isEmpty(s.getPic())){
s.setPic(s.getPic().replaceFirst("cdn1","cdn"+randomNum));
s.setPic(s.getPic().replaceFirst("cdn2","cdn"+randomNum));
}
return s;
}
@ApiOperation(value = "1.1 根据期刊id查询歌曲信息", notes = "仅用于外部分享")
@GetMapping("/journalId/{journalId}")
@GlobalInterceptor
public Result<List<SongRespDTO>> getByJournalId(@PathVariable String journalId) {
List<SongRespDTO> list = journalSongService.findByJournalId(journalId);
// list = list.stream().map(songRespDTO -> randomCDN(songRespDTO)).collect(Collectors.toList());
return Result.success(list);
}
@ -153,7 +113,6 @@ public class SongController {
Set<String> songCollectSet = getMyCollectSet(loginUserId,queryUserId,objectIds,isJouranlSource);
List<SongRespDTO> results = songs.stream().map(s -> SongMapper.getSongRespDTO(s, songCollectSet))
.collect(Collectors.toList());
// results = results.stream().map(songRespDTO -> randomCDN(songRespDTO)).collect(Collectors.toList());
return Result.success(new PageResult<SongRespDTO>(count, results));
}
@ -216,7 +175,6 @@ public class SongController {
SongRespDTO songRespDTO=SongMapper.getSongRespDTO(song);
boolean isCollect=null == user ? false:userCollectInfoService.isCollect(user.getUserId(),id, CollectTypeEnum.SONG);
songRespDTO.setHaveCollect(isCollect);
// songRespDTO = randomCDN(songRespDTO);
return Result.success(songRespDTO);
}
}

Loading…
Cancel
Save