release- 专辑添加审批拒绝理由

release-2024-08-08
pikaqiudeshujia 7 months ago
parent 1bd8c0b433
commit 75fb525425

@ -0,0 +1,27 @@
package enums;
import lombok.Getter;
/**
* @Author: yawei.huang
* @Package: enums
* @Project: luoo_parent
* @Date: 2024/5/11 15:33
* @Filename: ApproveStateEnum
* @Describe:
*/
@Getter
public enum ApproveStateEnum {
SUCCESS(1, "成功"),
FAIL(2, "失败"),
;
private final Integer code;
private final String desc;
ApproveStateEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
}

@ -0,0 +1,27 @@
package enums;
import lombok.Getter;
/**
* @Author: yawei.huang
* @Package: enums
* @Project: luoo_parent
* @Date: 2024/5/11 15:33
* @Filename: ApproveTypeEnum
* @Describe:
*/
@Getter
public enum ApproveTypeEnum {
ALBUM(1, "专辑审核"),
;
private final Integer code;
private final String desc;
ApproveTypeEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
}

@ -87,7 +87,8 @@ public class AlbumController {
@PostMapping(value = "/change/state/{id}/{state}") @PostMapping(value = "/change/state/{id}/{state}")
public Result<Void> changeState(@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, public Result<Void> changeState(@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token,
@ApiParam(value = "专辑id") @PathVariable String id, @ApiParam(value = "专辑id") @PathVariable String id,
@ApiParam(value = "想要修改的状态值 -1不可抗力原因不允许显示0新建1待审核2退回3待上架4已上架5已删除6下架")@PathVariable Integer state) { @ApiParam(value = "想要修改的状态值 -1不可抗力原因不允许显示0新建1待审核2退回3待上架4已上架5已删除6下架")@PathVariable Integer state,
@ApiParam(value = "拒绝理由,在审批动作下,如果拒绝是必填字段") String content) {
albumService.changeAlbumState(token, id, state); albumService.changeAlbumState(token, id, state);
return Result.success(); return Result.success();
} }

@ -0,0 +1,16 @@
package com.luoo.music.dao;
import com.luoo.music.pojo.Approve;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @Author: yawei.huang
* @Package: com.luoo.music.dao
* @Project: luoo_parent
* @Date: 2024/5/11 15:37
* @Filename: AlbumDao
* @Describe:
*/
public interface ApproveDao extends JpaRepository<Approve,String>, JpaSpecificationExecutor<Approve> {
}

@ -0,0 +1,62 @@
package com.luoo.music.pojo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
* @Author: yawei.huang
* @Package: com.luoo.music.pojo
* @Project: luoo_parent
* @Date: 2024/5/11 15:17
* @Filename: Approve
* @Describe:
*/
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@ToString
@Entity
@Table(name = "tb_approve")
public class Approve implements Serializable {
@Id
@ApiModelProperty("id")
private String id;
@ApiModelProperty("tb_user表id")
private String userId;
@ApiModelProperty("申请类型 1-专辑审核")
private Integer type;
@ApiModelProperty("申请状态 0-待审批 1-审批通过 2-审批成功")
private Integer status;
@ApiModelProperty("拒绝理由")
private String content;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("创建时间")
@CreatedDate
private Date createTime;
@ApiModelProperty("修改时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@LastModifiedDate
private Date modifyTime;
}

@ -11,10 +11,7 @@ import constants.ErrorConstants;
import dto.MallProduct; import dto.MallProduct;
import dto.MallProductAttributeValue; import dto.MallProductAttributeValue;
import dto.UserLoginDto; import dto.UserLoginDto;
import enums.AlbumStateEnum; import enums.*;
import enums.SongInfoChargeEnum;
import enums.SongInfoStateEnum;
import enums.UserTypeEnum;
import exception.BizException; import exception.BizException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -85,6 +82,9 @@ public class AlbumService {
@Autowired @Autowired
private RabbitTemplate rabbitTemplate; private RabbitTemplate rabbitTemplate;
@Autowired
private ApproveDao approveDao;
public PageResult<ArtistAlbum> getList(AlbumSearchDTO albumSearchDTO, Integer page, Integer size) { public PageResult<ArtistAlbum> getList(AlbumSearchDTO albumSearchDTO, Integer page, Integer size) {
List<ArtistAlbum> result = new ArrayList<>(); List<ArtistAlbum> result = new ArrayList<>();
Sort sort = new Sort(Sort.Direction.DESC, "createTime"); Sort sort = new Sort(Sort.Direction.DESC, "createTime");
@ -319,8 +319,9 @@ public class AlbumService {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void changeAlbumState(String token, String id, Integer state) { public void changeAlbumState(String token, String id, Integer state, String content) {
ArtistAlbum artistAlbum = checkAlbumIsSelf(token, id); ArtistAlbum artistAlbum = checkAlbumIsSelf(token, id);
UserLoginDto user = jwtUtil.getUserLoginDto(token);
switch (state) { switch (state) {
case -1: case -1:
@ -331,8 +332,32 @@ public class AlbumService {
checkForApply(id, artistAlbum); checkForApply(id, artistAlbum);
break; break;
case 2: case 2:
// 审核通过操作
checkAlbum(artistAlbum);
Approve successApprove = Approve.builder()
.id(String.valueOf(idWorker.nextId()))
.status(ApproveStateEnum.SUCCESS.getCode())
.userId(user.getUserId())
.type(ApproveTypeEnum.ALBUM.getCode())
.build();
approveDao.save(successApprove);
break;
case 3: case 3:
// 审核不通过操作
checkAlbum(artistAlbum); checkAlbum(artistAlbum);
if(StringUtils.isBlank(content)) {
// 必须填写拒绝理由
throw new BizException(ErrorConstants.REASONS_FOR_REFUSAL_MUST_BE_GIVEN);
}
Approve failApprove = Approve.builder()
.id(String.valueOf(idWorker.nextId()))
.status(ApproveStateEnum.FAIL.getCode())
.userId(user.getUserId())
.content(content)
.type(ApproveTypeEnum.ALBUM.getCode())
.build();
approveDao.save(failApprove);
break; break;
case 4: case 4:
// 上架操作 // 上架操作
@ -401,6 +426,8 @@ public class AlbumService {
BeanUtils.copyProperties(songInfo, albumSongRequireDTO); BeanUtils.copyProperties(songInfo, albumSongRequireDTO);
checkSong(albumSongRequireDTO); checkSong(albumSongRequireDTO);
} }
} }
/** /**
@ -411,6 +438,7 @@ public class AlbumService {
// 必须在待审核状态下申请审核 // 必须在待审核状态下申请审核
throw new BizException(ErrorConstants.STATE_ERROR); throw new BizException(ErrorConstants.STATE_ERROR);
} }
} }
/** /**

Loading…
Cancel
Save