From 75fb525425b70c7f99f8d514a2f0299151f04d2f Mon Sep 17 00:00:00 2001 From: pikaqiudeshujia Date: Sat, 11 May 2024 15:41:51 +0800 Subject: [PATCH] =?UTF-8?q?release-=20=E4=B8=93=E8=BE=91=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E6=8B=92=E7=BB=9D=E7=90=86=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/enums/ApproveStateEnum.java | 27 ++++++++ .../src/main/java/enums/ApproveTypeEnum.java | 27 ++++++++ .../music/controller/AlbumController.java | 3 +- .../java/com/luoo/music/dao/ApproveDao.java | 16 +++++ .../java/com/luoo/music/pojo/Approve.java | 62 +++++++++++++++++++ .../com/luoo/music/service/AlbumService.java | 38 ++++++++++-- 6 files changed, 167 insertions(+), 6 deletions(-) create mode 100644 luoo_common/src/main/java/enums/ApproveStateEnum.java create mode 100644 luoo_common/src/main/java/enums/ApproveTypeEnum.java create mode 100644 luoo_music/src/main/java/com/luoo/music/dao/ApproveDao.java create mode 100644 luoo_music/src/main/java/com/luoo/music/pojo/Approve.java diff --git a/luoo_common/src/main/java/enums/ApproveStateEnum.java b/luoo_common/src/main/java/enums/ApproveStateEnum.java new file mode 100644 index 0000000..3e80b80 --- /dev/null +++ b/luoo_common/src/main/java/enums/ApproveStateEnum.java @@ -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; + } +} diff --git a/luoo_common/src/main/java/enums/ApproveTypeEnum.java b/luoo_common/src/main/java/enums/ApproveTypeEnum.java new file mode 100644 index 0000000..1798898 --- /dev/null +++ b/luoo_common/src/main/java/enums/ApproveTypeEnum.java @@ -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; + } +} diff --git a/luoo_music/src/main/java/com/luoo/music/controller/AlbumController.java b/luoo_music/src/main/java/com/luoo/music/controller/AlbumController.java index 3e2a63d..e053b0a 100644 --- a/luoo_music/src/main/java/com/luoo/music/controller/AlbumController.java +++ b/luoo_music/src/main/java/com/luoo/music/controller/AlbumController.java @@ -87,7 +87,8 @@ public class AlbumController { @PostMapping(value = "/change/state/{id}/{state}") public Result 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:已删除,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); return Result.success(); } diff --git a/luoo_music/src/main/java/com/luoo/music/dao/ApproveDao.java b/luoo_music/src/main/java/com/luoo/music/dao/ApproveDao.java new file mode 100644 index 0000000..cb41005 --- /dev/null +++ b/luoo_music/src/main/java/com/luoo/music/dao/ApproveDao.java @@ -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, JpaSpecificationExecutor { +} diff --git a/luoo_music/src/main/java/com/luoo/music/pojo/Approve.java b/luoo_music/src/main/java/com/luoo/music/pojo/Approve.java new file mode 100644 index 0000000..9873074 --- /dev/null +++ b/luoo_music/src/main/java/com/luoo/music/pojo/Approve.java @@ -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; + +} diff --git a/luoo_music/src/main/java/com/luoo/music/service/AlbumService.java b/luoo_music/src/main/java/com/luoo/music/service/AlbumService.java index 109aa88..89a0b89 100644 --- a/luoo_music/src/main/java/com/luoo/music/service/AlbumService.java +++ b/luoo_music/src/main/java/com/luoo/music/service/AlbumService.java @@ -11,10 +11,7 @@ import constants.ErrorConstants; import dto.MallProduct; import dto.MallProductAttributeValue; import dto.UserLoginDto; -import enums.AlbumStateEnum; -import enums.SongInfoChargeEnum; -import enums.SongInfoStateEnum; -import enums.UserTypeEnum; +import enums.*; import exception.BizException; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; @@ -85,6 +82,9 @@ public class AlbumService { @Autowired private RabbitTemplate rabbitTemplate; + @Autowired + private ApproveDao approveDao; + public PageResult getList(AlbumSearchDTO albumSearchDTO, Integer page, Integer size) { List result = new ArrayList<>(); Sort sort = new Sort(Sort.Direction.DESC, "createTime"); @@ -319,8 +319,9 @@ public class AlbumService { } @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); + UserLoginDto user = jwtUtil.getUserLoginDto(token); switch (state) { case -1: @@ -331,8 +332,32 @@ public class AlbumService { checkForApply(id, artistAlbum); break; 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: + // 审核不通过操作 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; case 4: // 上架操作 @@ -401,6 +426,8 @@ public class AlbumService { BeanUtils.copyProperties(songInfo, albumSongRequireDTO); checkSong(albumSongRequireDTO); } + + } /** @@ -411,6 +438,7 @@ public class AlbumService { // 必须在待审核状态下申请审核 throw new BizException(ErrorConstants.STATE_ERROR); } + } /**