release- 调整专辑/歌曲字段

release-2024-08-08
pikaqiudeshujia 7 months ago
parent 89f2070659
commit d98d9abbc4

@ -0,0 +1,27 @@
package constants;
/**
* @Author: yawei.huang
* @Package: constants
* @Project: luoo_parent
* @Date: 2024/5/6 9:14
* @Filename: ErrorConstants
* @Describe: 便
*/
public class ErrorConstants {
public final static String MUST_APPLY_FOR_REVIEW_IN_THE_NEW_STATE = "必须在新建状态下申请审核";
public final static String MUST_OPERATE_IN_PERSON = "必须本人操作";
public final static String USER_VERIFICATION_FAILURE = "用户校验失败,请重新登录";
public final static String THE_SONG_DOES_NOT_EXIST = "该专辑不存在此歌曲";
public final static String ALBUM_DOES_NOT_EXIST = "专辑不存在,请刷新后重试";
public final static String CAUSE_OF_FORCE_MAJEURE = "专辑因不可抗力原因无法显示";
public final static String PRICE_CAN_NOT_BE_EMPTY = "定价不能为空";
public final static String PRICING_MUST_BE_GREATER_THAN_0 = "定价必须大于0";
}

@ -36,4 +36,13 @@ public enum AlbumStateEnum {
this.code = code;
this.desc = desc;
}
public static AlbumStateEnum getByStatus(Integer code) {
for (AlbumStateEnum al : AlbumStateEnum.values()) {
if (al.code.equals(code)) {
return al;
}
}
return null;
}
}

@ -0,0 +1,27 @@
package enums;
import lombok.Getter;
/**
* @Author: yawei.huang
* @Package: enums
* @Project: luoo_parent
* @Date: 2024/5/6 9:52
* @Filename: SongInfoChargeEnum
* @Describe:
*/
@Getter
public enum SongInfoChargeEnum {
CHARGE(1, "收费"),
FREE(2, "收费");
private Integer code;
private String desc;
SongInfoChargeEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
}

@ -90,5 +90,13 @@ 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);
return Result.success();
}
}

@ -42,9 +42,10 @@ public interface SongInfoDao extends JpaRepository<SongInfo, String>, JpaSpecifi
@Query(value = "select * from tb_song_info where match(name, artist, album) against(?1 IN BOOLEAN MODE) limit ?2,?3 ", nativeQuery = true)
List<SongInfo> fuzzySearch(String keyword, int offset, int limit);
@Query(value = "select * from tb_song_info where id in (\n" +
" select song_id from tb_artist_album_song where album_id = ?\n" +
" \n" +
" )", nativeQuery = true)
@Query(value = "select t2.* from tb_artist_album_song t1 \n" +
" left join tb_song_info t2 \n" +
" on t1.song_id = t2.id\n" +
" where t1.album_id = ?1\n" +
" ORDER BY t1.sort", nativeQuery = true)
List<SongInfo> findByAlbumId(String id);
}

@ -25,39 +25,53 @@ public class AlbumAddDTO implements Serializable {
@ApiModelProperty("专辑名称")
@NotNull(message = "专辑名称不能为空")
private String name;
/**
*
*/
@ApiModelProperty("专辑封面")
private String image;
/**
*
*/
@ApiModelProperty("专辑版本")
private Integer version;
/**
*
*
*/
@ApiModelProperty("发行日期")
private Date publishDate;
@ApiModelProperty("专辑类型")
@NotNull(message = "专辑类型不能为空")
private Integer type;
/**
*
*
*/
@ApiModelProperty("风格")
@NotNull(message = "风格不能为空")
@ApiModelProperty("专辑风格")
@NotNull(message = "专辑风格不能为空")
private String mainStyle;
/**
*
*/
@ApiModelProperty("发行日期")
@NotNull(message = "发行日期不能为空")
private Date publishDate;
/**
*
*/
@ApiModelProperty("专辑条码")
private String barcode;
/**
*
*/
@ApiModelProperty("专辑描述")
private String description;
/**
*
*/
@ApiModelProperty("专辑封面")
@NotNull(message = "专辑封面不能为空")
private String image;
/**
* id
*/

@ -23,14 +23,26 @@ public class AlbumSongAddDTO implements Serializable {
@NotNull(message = "歌曲名称不能为空")
private String name;
@ApiModelProperty("语种")
private Integer language;
@ApiModelProperty("歌曲版本")
@NotNull(message = "歌曲版本不能为空")
private Integer version;
@ApiModelProperty("是否收费")
@NotNull(message = "是否收费不能为空")
private Integer charge;
@ApiModelProperty("歌曲定价")
private Float price;
@ApiModelProperty("歌手")
@NotBlank(message = "歌手不能为空")
private String albumStr;
@ApiModelProperty("曲风")
private List<String> tags;
@ApiModelProperty("售价")
private float price;
@ApiModelProperty("语种")
private List<String> language;
@ApiModelProperty("作词")
private String lyricName;
@ -38,9 +50,6 @@ public class AlbumSongAddDTO implements Serializable {
@ApiModelProperty("作曲")
private String compositionName;
// @ApiModelProperty("编曲")
// private String arrangementName;
@ApiModelProperty("歌词")
private String lyric;
@ -48,12 +57,9 @@ public class AlbumSongAddDTO implements Serializable {
@NotNull(message = "歌曲不能为空")
private String url;
@ApiModelProperty("歌曲版本")
private Integer version;
@ApiModelProperty("歌手")
@NotBlank(message = "歌手不能为空")
private String albumStr;
@ApiModelProperty("排序")
@NotNull(message = "排序不能为空")
private Integer sort;
// @ApiModelProperty("mv")
// private String mvUrl;

@ -35,11 +35,19 @@ public class ArtistAlbum implements Serializable {
@Id
private String id;
/**
*
*/
@ApiModelProperty("专辑名称")
private String name;
/**
*
*/
@ApiModelProperty("专辑类型")
private Integer type;
/**
*
*/
@ -49,7 +57,7 @@ public class ArtistAlbum implements Serializable {
/**
*
*/
@ApiModelProperty("专辑状态")
@ApiModelProperty("专辑状态 -1不可抗力原因不允许显示 0新建 1待审核 2退回 3待上架 4已上架 5已删除")
private Integer state;
/**
@ -57,6 +65,7 @@ public class ArtistAlbum implements Serializable {
*/
@ApiModelProperty("发行日期")
private Date publishDate;
/**
*
*/
@ -68,11 +77,13 @@ public class ArtistAlbum implements Serializable {
*/
@ApiModelProperty("专辑条码")
private String barcode;
/**
*
*/
@ApiModelProperty("专辑描述")
private String description;
/**
*
*/
@ -80,6 +91,7 @@ public class ArtistAlbum implements Serializable {
@CreatedDate
@ApiModelProperty("创建时间")
private LocalDateTime createTime;
/**
*
*/
@ -87,21 +99,25 @@ public class ArtistAlbum implements Serializable {
@LastModifiedDate
@ApiModelProperty("修改时间")
private LocalDateTime updateTime;
/**
* id
*/
@ApiModelProperty("音乐人id")
private String artistId;
/**
*
*/
@ApiModelProperty("音乐人昵称")
private String artistName;
/**
*
*/
@ApiModelProperty("创建人")
private String createUser;
/**
*
*/
@ -123,6 +139,9 @@ public class ArtistAlbum implements Serializable {
@ApiModelProperty("风格列表")
private List<Tag> style;
@Transient
@ApiModelProperty("专辑状态-中文")
private String stateStr;
}

@ -11,6 +11,7 @@ import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
@ -102,6 +103,14 @@ public class SongInfo implements Serializable {
@ApiModelProperty("作曲")
private String compositionName;
@ApiModelProperty("是否收费")
@NotNull(message = "是否收费不能为空")
private Integer charge;
@ApiModelProperty("歌曲定价")
private Float price;
// @ApiModelProperty("编曲")
// private String arrangementName;

@ -8,8 +8,10 @@ import com.luoo.music.dto.response.AlbumSongAddDTO;
import com.luoo.music.dto.response.AlbumUpdateDTO;
import com.luoo.music.pojo.*;
import com.luoo.music.util.Constants;
import constants.ErrorConstants;
import dto.UserLoginDto;
import enums.AlbumStateEnum;
import enums.SongInfoChargeEnum;
import enums.SongInfoStateEnum;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
@ -29,6 +31,7 @@ import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.validation.Valid;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
@ -86,6 +89,12 @@ public class AlbumService {
result = albumPage.getContent();
for (ArtistAlbum artistAlbum : result) {
if (artistAlbum.getState() != null) {
// 中文状态名
AlbumStateEnum byStatus = AlbumStateEnum.getByStatus(artistAlbum.getState());
artistAlbum.setStateStr(byStatus != null ? byStatus.getDesc() : "");
}
//todo 传递点赞,喜欢,评论,收益
}
long totalElements = albumPage.getTotalElements();
@ -168,10 +177,12 @@ public class AlbumService {
public ArtistAlbum getOne(String id) {
ArtistAlbum artistAlbum = artistAlbumDao.findById(id).get();
if (artistAlbum == null) {
throw new RuntimeException("专辑不存在,请刷新后重试");
// 专辑不存在,请刷新后重试
throw new RuntimeException(ErrorConstants.ALBUM_DOES_NOT_EXIST);
}
if (ObjectUtils.equals(AlbumStateEnum.FORCE.getCode(), artistAlbum.getState())) {
throw new RuntimeException("专辑因不可抗力原因无法显示");
// 专辑因不可抗力原因无法显示
throw new RuntimeException(ErrorConstants.CAUSE_OF_FORCE_MAJEURE);
}
// 整个数据库所有的tag
@ -244,16 +255,15 @@ public class AlbumService {
if (user != null) {
artistAlbum.setCreateUser(user.getUserId());
} else {
throw new RuntimeException("用户校验失败,请重新登录");
// 用户校验失败,请重新登录
throw new RuntimeException(ErrorConstants.USER_VERIFICATION_FAILURE);
}
artistAlbum.setState(AlbumStateEnum.SAVE.getCode());
artistAlbumDao.save(artistAlbum);
// 处理歌曲对象
List<AlbumSongAddDTO> songAddList = albumAddDTO.getSongAddList();
if (songAddList.isEmpty()) {
throw new RuntimeException("专辑音乐不能为空!");
} else {
if (!songAddList.isEmpty()) {
for (AlbumSongAddDTO albumSongAddDTO : songAddList) {
addSongForAlbum(albumSongAddDTO, user, artistAlbum);
}
@ -274,11 +284,13 @@ public class AlbumService {
UserLoginDto user = jwtUtil.getUserLoginDto(token);
if (user != null) {
if (ObjectUtils.notEqual(user.getUserId(), artistAlbum.getCreateUser())) {
throw new RuntimeException("只允许本人操作!");
// 必须本人操作
throw new RuntimeException(ErrorConstants.USER_VERIFICATION_FAILURE);
}
artistAlbum.setUpdateUser(user.getUserId());
} else {
throw new RuntimeException("用户校验失败,请重新登录");
// 用户校验失败,请重新登
throw new RuntimeException(ErrorConstants.USER_VERIFICATION_FAILURE);
}
artistAlbumDao.save(artistAlbum);
@ -309,7 +321,8 @@ public class AlbumService {
ArtistAlbumSong artistAlbumSong = artistAlbumSongDao.findById(id).get();
if (artistAlbumSong.getId() == null) {
throw new RuntimeException("该专辑不存在此歌曲");
// 该专辑不存在此歌曲
throw new RuntimeException(ErrorConstants.THE_SONG_DOES_NOT_EXIST);
}
checkAlbum(token, artistAlbumSong.getAlbumId());
@ -330,10 +343,12 @@ public class AlbumService {
UserLoginDto user = jwtUtil.getUserLoginDto(token);
if (user != null) {
if (ObjectUtils.notEqual(user.getUserId(), artistAlbum.getCreateUser())) {
throw new RuntimeException("只允许本人操作!");
// 必须本人操作
throw new RuntimeException(ErrorConstants.MUST_OPERATE_IN_PERSON);
}
} else {
throw new RuntimeException("用户校验失败,请重新登录");
// 用户校验失败,请重新登录
throw new RuntimeException(ErrorConstants.USER_VERIFICATION_FAILURE);
}
return artistAlbum;
}
@ -352,6 +367,16 @@ public class AlbumService {
addSongForAlbum(albumSongAddDTO, user, artistAlbum);
}
@Transactional(rollbackFor = Exception.class)
public void checkForApply(String token, String id) {
UserLoginDto user = jwtUtil.getUserLoginDto(token);
ArtistAlbum artistAlbum = checkAlbum(token, id);
if (ObjectUtils.notEqual(AlbumStateEnum.SAVE.getCode(), artistAlbum.getState())) {
// 必须在新建状态下申请审核
throw new RuntimeException(ErrorConstants.MUST_APPLY_FOR_REVIEW_IN_THE_NEW_STATE);
}
}
/**
*
*
@ -359,7 +384,18 @@ public class AlbumService {
* @param user
* @param artistAlbum
*/
private void addSongForAlbum(AlbumSongAddDTO albumSongAddDTO, UserLoginDto user, ArtistAlbum artistAlbum) {
private void addSongForAlbum(@Valid AlbumSongAddDTO albumSongAddDTO, UserLoginDto user, ArtistAlbum artistAlbum) {
if(ObjectUtils.notEqual(SongInfoChargeEnum.CHARGE.getCode(), artistAlbum.getChargeType())) {
if(albumSongAddDTO.getPrice() == null) {
// 定价不能为空
throw new RuntimeException(ErrorConstants.PRICE_CAN_NOT_BE_EMPTY);
}
if(albumSongAddDTO.getPrice() <= 0) {
// 定价必须大于0
throw new RuntimeException(ErrorConstants.PRICING_MUST_BE_GREATER_THAN_0);
}
}
String albumName = artistAlbum.getName();
String artistName = artistAlbum.getArtistName();
@ -374,7 +410,7 @@ public class AlbumService {
if (user != null) {
artistAlbum.setCreateUser(user.getUserId());
} else {
throw new RuntimeException("用户校验失败,请重新登录");
throw new RuntimeException(ErrorConstants.MUST_OPERATE_IN_PERSON);
}
songInfoDao.save(songInfo);
@ -389,10 +425,11 @@ public class AlbumService {
songInfoDao.updateSongLyricAndUrl(id, lyric, lyricUrl);
}
// 曲风绑定
// 曲风和语言绑定
List<String> tags = albumSongAddDTO.getTags();
List<String> language = albumSongAddDTO.getLanguage();
tags.addAll(language);
if (!tags.isEmpty()) {
songTagDao.deleteBySongId(id);
List<SongTag> songTagList = new ArrayList<>();
for (String item : tags) {
SongTag songTag = new SongTag();

@ -0,0 +1,9 @@
alter table tb_artist_album
add type int null comment '专辑类型' after name;
alter table tb_song_info
add charge int null comment '是否收费 1-收费 2-免费';
alter table tb_artist_album_song
add sort int null comment '排序';
Loading…
Cancel
Save