release- 新增专辑状态修改

release-2024-08-08
pikaqiudeshujia 7 months ago
parent 471f1f3c0f
commit 9065196e6d

@ -28,6 +28,8 @@ public class ErrorConstants {
public final static String ALBUM_SONG_LIST_IS_EMPTY = "专辑歌曲为空";
public final static String STATE_ERROR = "状态错误";
// 用户部分
public final static String REAL_NAME_APPROVE_IS_EXISTS = "该用户实名认证已存在";

@ -66,14 +66,6 @@ public class AlbumController {
return Result.success();
}
@ApiOperation(value = "删除专辑", notes = "删除专辑")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public Result<Void> delete(@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token,
@ApiParam(value = "专辑id", required = true) String id) {
albumService.deleteAlbum(token, id);
return Result.success();
}
@ApiOperation(value = "删除专辑中的歌曲", notes = "删除专辑中的歌曲")
@RequestMapping(value = "/delete/song", method = RequestMethod.POST)
public Result<Void> deleteAlbumSong(@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token,
@ -91,13 +83,16 @@ public class AlbumController {
return Result.success();
}
@ApiOperation(value = "申请审核", notes = "申请审核")
@RequestMapping(value = "/check/apply/{id}", method = RequestMethod.POST)
public Result<Void> checkForApply(@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token,
@ApiParam(value = "专辑id") @PathVariable String id) {
albumService.checkForApply(token, id);
@ApiOperation(value = "修改专辑状态", notes = "修改专辑状态")
@PostMapping(value = "/change/state/{id}/{state}")
public Result<Void> changeState(@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token,
@ApiParam(value = "专辑id") @PathVariable String id,
@ApiParam(value = "想要修改的状态值 -1不可抗力原因不允许显示0新建1待审核2退回3待上架4已上架5已删除")@PathVariable Integer state) {
albumService.changeAlbumState(token, id, state);
return Result.success();
}
}

@ -1,8 +1,10 @@
package com.luoo.music.dto.response;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
@ -19,55 +21,58 @@ import java.util.Date;
public class AlbumUpdateDTO implements Serializable {
@NotNull
@ApiModelProperty("id")
@NotBlank
private String id;
/**
*
*/
@NotBlank(message = "专辑名称不能为空")
@ApiModelProperty("专辑名称")
@NotNull(message = "专辑名称不能为空")
private String name;
/**
*
*/
@NotNull(message = "专辑类型不能为空")
@ApiModelProperty("专辑类型")
private Integer type;
/**
*
*/
@NotBlank(message = "专辑封面不能为空")
@ApiModelProperty("专辑封面")
@NotNull(message = "专辑封面不能为空")
private String image;
/**
*
*
*/
@ApiModelProperty("专辑版本")
private Integer version;
@NotNull(message = "专辑状态不能为空")
@ApiModelProperty("专辑状态 -1不可抗力原因不允许显示 0新建 1待审核 2退回 3待上架 4已上架 5已删除")
private Integer state;
/**
*
*/
@NotNull(message = "发行日期不能为空")
@ApiModelProperty("发行日期")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date publishDate;
/**
*
*/
@ApiModelProperty("主要风格")
@NotNull(message = "主要风格不能为空")
@NotBlank(message = "专辑风格不能为空")
@ApiModelProperty("专辑风格不能为空")
private String mainStyle;
/**
*
*/
@NotNull(message = "次要风格不能为空")
@ApiModelProperty("次要风格")
private String subStyle;
/**
*
*/
@ApiModelProperty("专辑条码")
private String barcode;
/**
*
*/
@ -75,22 +80,9 @@ public class AlbumUpdateDTO implements Serializable {
private String description;
/**
* id
*/
@ApiModelProperty("音乐人id")
private String artistId;
/**
*
*/
@ApiModelProperty("音乐人昵称")
private String artistName;
/**
* 1- 2-
*
*/
@ApiModelProperty("收费类型 1-下载 2-试听及下载")
private Integer chargeType;
@ApiModelProperty("专辑版本")
private Integer version;
}

@ -31,10 +31,7 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -279,6 +276,54 @@ public class AlbumService {
ArtistAlbum artistAlbum = new 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);
if (user != null) {
if (ObjectUtils.notEqual(user.getUserId(), artistAlbum.getCreateUser())) {
@ -291,22 +336,59 @@ public class AlbumService {
throw new BizException(ErrorConstants.USER_VERIFICATION_FAILURE);
}
artistAlbumDao.save(artistAlbum);
}
/**
*
*
*
* @param id id
* @param artistAlbum
*/
@Transactional(rollbackFor = Exception.class)
public void deleteAlbum(String token, String id) {
ArtistAlbum artistAlbum = checkAlbum(token, id);
private void checkForApply(String id, ArtistAlbum artistAlbum) {
if (ObjectUtils.notEqual(AlbumStateEnum.SAVE.getCode(), artistAlbum.getState())) {
// 必须在新建状态下申请审核
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);
}
/**
*
*
* @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
*/
private void checkSong(@Validated AlbumSongRequireDTO albumSongRequireDTO) {
if(ObjectUtils.notEqual(SongInfoChargeEnum.CHARGE.getCode(), albumSongRequireDTO.getCharge())) {
if(albumSongRequireDTO.getPrice() == null) {
if (ObjectUtils.notEqual(SongInfoChargeEnum.CHARGE.getCode(), albumSongRequireDTO.getCharge())) {
if (albumSongRequireDTO.getPrice() == null) {
// 定价不能为空
throw new BizException(ErrorConstants.PRICE_CAN_NOT_BE_EMPTY);
}
if(albumSongRequireDTO.getPrice() <= 0) {
if (albumSongRequireDTO.getPrice() <= 0) {
// 定价必须大于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) {
if(ObjectUtils.equals(SongInfoChargeEnum.CHARGE.getCode(), albumSongAddDTO.getCharge())) {
if(albumSongAddDTO.getPrice() == null) {
if (ObjectUtils.equals(SongInfoChargeEnum.CHARGE.getCode(), albumSongAddDTO.getCharge())) {
if (albumSongAddDTO.getPrice() == null) {
// 定价不能为空
throw new BizException(ErrorConstants.PRICE_CAN_NOT_BE_EMPTY);
}
if(albumSongAddDTO.getPrice() <= 0) {
if (albumSongAddDTO.getPrice() <= 0) {
// 定价必须大于0
throw new BizException(ErrorConstants.PRICING_MUST_BE_GREATER_THAN_0);
}

Loading…
Cancel
Save