|
|
@ -31,10 +31,7 @@ import javax.persistence.criteria.CriteriaQuery;
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
|
import javax.persistence.criteria.Root;
|
|
|
|
import javax.persistence.criteria.Root;
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -279,6 +276,54 @@ public class AlbumService {
|
|
|
|
ArtistAlbum artistAlbum = new ArtistAlbum();
|
|
|
|
ArtistAlbum artistAlbum = new ArtistAlbum();
|
|
|
|
BeanUtils.copyProperties(albumUpdateDTO, artistAlbum);
|
|
|
|
BeanUtils.copyProperties(albumUpdateDTO, artistAlbum);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ArtistAlbum old = checkAlbum(token, artistAlbum.getId());
|
|
|
|
|
|
|
|
artistAlbum.setArtistId(old.getArtistId());
|
|
|
|
|
|
|
|
artistAlbum.setArtistName(old.getArtistName());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkUserIsSelf(token, artistAlbum);
|
|
|
|
|
|
|
|
artistAlbumDao.save(artistAlbum);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
|
|
|
public void changeAlbumState(String token, String id, Integer state) {
|
|
|
|
|
|
|
|
ArtistAlbum artistAlbum = checkAlbum(token, id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
|
|
|
|
case -1:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
// 申请审核操作
|
|
|
|
|
|
|
|
checkForApply(id, artistAlbum);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
|
|
// 上架操作
|
|
|
|
|
|
|
|
shelving(artistAlbum);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
|
|
|
|
// 删除操作
|
|
|
|
|
|
|
|
deleteAlbum(artistAlbum);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
// 其他不允许操作
|
|
|
|
|
|
|
|
throw new BizException(ErrorConstants.STATE_ERROR);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
artistAlbum.setState(state);
|
|
|
|
|
|
|
|
if(ObjectUtils.notEqual(state, AlbumStateEnum.FORCE.getCode())) {
|
|
|
|
|
|
|
|
// 强制下架不校验是否本人操作
|
|
|
|
|
|
|
|
checkUserIsSelf(token, artistAlbum);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
artistAlbumDao.save(artistAlbum);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 校验修改的用户是否是自己
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param token token
|
|
|
|
|
|
|
|
* @param artistAlbum 专辑
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void checkUserIsSelf(String token, ArtistAlbum artistAlbum) {
|
|
|
|
UserLoginDto user = jwtUtil.getUserLoginDto(token);
|
|
|
|
UserLoginDto user = jwtUtil.getUserLoginDto(token);
|
|
|
|
if (user != null) {
|
|
|
|
if (user != null) {
|
|
|
|
if (ObjectUtils.notEqual(user.getUserId(), artistAlbum.getCreateUser())) {
|
|
|
|
if (ObjectUtils.notEqual(user.getUserId(), artistAlbum.getCreateUser())) {
|
|
|
@ -291,22 +336,59 @@ public class AlbumService {
|
|
|
|
throw new BizException(ErrorConstants.USER_VERIFICATION_FAILURE);
|
|
|
|
throw new BizException(ErrorConstants.USER_VERIFICATION_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
artistAlbumDao.save(artistAlbum);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 删除专辑
|
|
|
|
* 提交审核状态校验
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param id 专辑id
|
|
|
|
* @param id 专辑id
|
|
|
|
|
|
|
|
* @param artistAlbum 专辑对象
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
private void checkForApply(String id, ArtistAlbum artistAlbum) {
|
|
|
|
public void deleteAlbum(String token, String id) {
|
|
|
|
if (ObjectUtils.notEqual(AlbumStateEnum.SAVE.getCode(), artistAlbum.getState())) {
|
|
|
|
|
|
|
|
// 必须在新建状态下申请审核
|
|
|
|
ArtistAlbum artistAlbum = checkAlbum(token, id);
|
|
|
|
throw new BizException(ErrorConstants.MUST_APPLY_FOR_REVIEW_IN_THE_NEW_STATE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
List<SongInfo> songInfoList = songInfoDao.findByAlbumId(id);
|
|
|
|
|
|
|
|
if (songInfoList.isEmpty()) {
|
|
|
|
|
|
|
|
throw new BizException(ErrorConstants.ALBUM_SONG_LIST_IS_EMPTY);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (SongInfo songInfo : songInfoList) {
|
|
|
|
|
|
|
|
AlbumSongRequireDTO albumSongRequireDTO = new AlbumSongRequireDTO();
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(songInfo, albumSongRequireDTO);
|
|
|
|
|
|
|
|
checkSong(albumSongRequireDTO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
artistAlbumDao.delete(artistAlbum);
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 上架操作
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param artistAlbum 专辑对象
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void shelving(ArtistAlbum artistAlbum) {
|
|
|
|
|
|
|
|
// 只有待上架允许上架
|
|
|
|
|
|
|
|
if (ObjectUtils.notEqual(AlbumStateEnum.WAIT_ARRIVE.getCode(), artistAlbum.getState())) {
|
|
|
|
|
|
|
|
throw new BizException(ErrorConstants.STATE_ERROR);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
artistAlbumSongDao.deleteByAlbumId(id);
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 删除专辑
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param artistAlbum 专辑对象
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void deleteAlbum(ArtistAlbum artistAlbum) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 只有新建,待上架,已驳回状态下允许删除
|
|
|
|
|
|
|
|
Integer state = artistAlbum.getState();
|
|
|
|
|
|
|
|
Integer[] allowState = new Integer[]{
|
|
|
|
|
|
|
|
AlbumStateEnum.SAVE.getCode(),
|
|
|
|
|
|
|
|
AlbumStateEnum.WAIT_ARRIVE.getCode(),
|
|
|
|
|
|
|
|
AlbumStateEnum.BACK.getCode()
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!Arrays.asList(allowState).contains(state)) {
|
|
|
|
|
|
|
|
throw new BizException(ErrorConstants.STATE_ERROR);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -365,46 +447,18 @@ public class AlbumService {
|
|
|
|
addSongForAlbum(albumSongAddDTO, user, artistAlbum);
|
|
|
|
addSongForAlbum(albumSongAddDTO, user, artistAlbum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 提交审核
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param token token
|
|
|
|
|
|
|
|
* @param id 专辑id
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
|
|
|
public void checkForApply(String token, String id) {
|
|
|
|
|
|
|
|
ArtistAlbum artistAlbum = checkAlbum(token, id);
|
|
|
|
|
|
|
|
if (ObjectUtils.notEqual(AlbumStateEnum.SAVE.getCode(), artistAlbum.getState())) {
|
|
|
|
|
|
|
|
// 必须在新建状态下申请审核
|
|
|
|
|
|
|
|
throw new BizException(ErrorConstants.MUST_APPLY_FOR_REVIEW_IN_THE_NEW_STATE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ArtistAlbum album = getOne(id);
|
|
|
|
|
|
|
|
List<SongInfo> songList = album.getSongList();
|
|
|
|
|
|
|
|
if(songList.isEmpty()) {
|
|
|
|
|
|
|
|
throw new BizException(ErrorConstants.ALBUM_SONG_LIST_IS_EMPTY);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (SongInfo songInfo : songList) {
|
|
|
|
|
|
|
|
AlbumSongRequireDTO albumSongRequireDTO = new AlbumSongRequireDTO();
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(songInfo, albumSongRequireDTO);
|
|
|
|
|
|
|
|
checkSong(albumSongRequireDTO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
artistAlbum.setState(AlbumStateEnum.IN_APPROVE.getCode());
|
|
|
|
|
|
|
|
artistAlbumDao.save(artistAlbum);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 必填校验
|
|
|
|
* 必填校验
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param albumSongRequireDTO 校验对象
|
|
|
|
* @param albumSongRequireDTO 校验对象
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void checkSong(@Validated AlbumSongRequireDTO albumSongRequireDTO) {
|
|
|
|
private void checkSong(@Validated AlbumSongRequireDTO albumSongRequireDTO) {
|
|
|
|
if(ObjectUtils.notEqual(SongInfoChargeEnum.CHARGE.getCode(), albumSongRequireDTO.getCharge())) {
|
|
|
|
if (ObjectUtils.notEqual(SongInfoChargeEnum.CHARGE.getCode(), albumSongRequireDTO.getCharge())) {
|
|
|
|
if(albumSongRequireDTO.getPrice() == null) {
|
|
|
|
if (albumSongRequireDTO.getPrice() == null) {
|
|
|
|
// 定价不能为空
|
|
|
|
// 定价不能为空
|
|
|
|
throw new BizException(ErrorConstants.PRICE_CAN_NOT_BE_EMPTY);
|
|
|
|
throw new BizException(ErrorConstants.PRICE_CAN_NOT_BE_EMPTY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(albumSongRequireDTO.getPrice() <= 0) {
|
|
|
|
if (albumSongRequireDTO.getPrice() <= 0) {
|
|
|
|
// 定价必须大于0
|
|
|
|
// 定价必须大于0
|
|
|
|
throw new BizException(ErrorConstants.PRICING_MUST_BE_GREATER_THAN_0);
|
|
|
|
throw new BizException(ErrorConstants.PRICING_MUST_BE_GREATER_THAN_0);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -420,12 +474,12 @@ public class AlbumService {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void addSongForAlbum(@Validated AlbumSongAddDTO albumSongAddDTO, UserLoginDto user, ArtistAlbum artistAlbum) {
|
|
|
|
private void addSongForAlbum(@Validated AlbumSongAddDTO albumSongAddDTO, UserLoginDto user, ArtistAlbum artistAlbum) {
|
|
|
|
|
|
|
|
|
|
|
|
if(ObjectUtils.equals(SongInfoChargeEnum.CHARGE.getCode(), albumSongAddDTO.getCharge())) {
|
|
|
|
if (ObjectUtils.equals(SongInfoChargeEnum.CHARGE.getCode(), albumSongAddDTO.getCharge())) {
|
|
|
|
if(albumSongAddDTO.getPrice() == null) {
|
|
|
|
if (albumSongAddDTO.getPrice() == null) {
|
|
|
|
// 定价不能为空
|
|
|
|
// 定价不能为空
|
|
|
|
throw new BizException(ErrorConstants.PRICE_CAN_NOT_BE_EMPTY);
|
|
|
|
throw new BizException(ErrorConstants.PRICE_CAN_NOT_BE_EMPTY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(albumSongAddDTO.getPrice() <= 0) {
|
|
|
|
if (albumSongAddDTO.getPrice() <= 0) {
|
|
|
|
// 定价必须大于0
|
|
|
|
// 定价必须大于0
|
|
|
|
throw new BizException(ErrorConstants.PRICING_MUST_BE_GREATER_THAN_0);
|
|
|
|
throw new BizException(ErrorConstants.PRICING_MUST_BE_GREATER_THAN_0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|