diff --git a/luoo_common/src/main/java/enums/AlbumStateEnum.java b/luoo_common/src/main/java/enums/AlbumStateEnum.java index f9a149a..a864a18 100644 --- a/luoo_common/src/main/java/enums/AlbumStateEnum.java +++ b/luoo_common/src/main/java/enums/AlbumStateEnum.java @@ -24,7 +24,9 @@ public enum AlbumStateEnum { ARRIVED(4, "已上架"), - DELETE(5, "已删除") + DELETE(5, "已删除"), + + REMOVAL(6, "下架") ; private Integer code; 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 1d32119..109aa88 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 @@ -342,6 +342,10 @@ public class AlbumService { // 删除操作 deleteAlbum(artistAlbum); break; + case 6: + //下架操作 + removal(artistAlbum); + break; default: // 其他不允许操作 throw new BizException(ErrorConstants.STATE_ERROR); @@ -421,6 +425,7 @@ public class AlbumService { } // 拼接MALL模块需要的商品对象和参数对象 + // 上架的同时,发起MQ,MALL接收到后会调用商品新增的接口 List songInfoList = songInfoDao.findByAlbumId(artistAlbum.getId()); for (SongInfo songInfo : songInfoList) { MallProduct mallProduct = MallProduct.builder() @@ -447,9 +452,17 @@ public class AlbumService { rabbitTemplate.convertAndSend("luoo_mall_product_add", mallMqMap); } + } + // 下架操作 + private void removal(ArtistAlbum artistAlbum) { + // 只有上架允许下架 + if (ObjectUtils.notEqual(AlbumStateEnum.ARRIVED.getCode(), artistAlbum.getState())) { + throw new BizException(ErrorConstants.STATE_ERROR); + } - // 上架的同时,发起MQ,MALL接收到后会调用商品新增的接口 + // 下架或删除的同时,发起MQ,MALL接收到后会调用商品下架的接口 + rabbitTemplate.convertAndSend("luoo_mall_product_delete", artistAlbum.getId()); } /** @@ -459,12 +472,13 @@ public class AlbumService { */ private void deleteAlbum(ArtistAlbum artistAlbum) { - // 只有新建,待上架,已驳回状态下允许删除 + // 只有新建,待上架,已驳回,下架状态下允许删除 Integer state = artistAlbum.getState(); Integer[] allowState = new Integer[]{ AlbumStateEnum.SAVE.getCode(), AlbumStateEnum.WAIT_ARRIVE.getCode(), - AlbumStateEnum.BACK.getCode() + AlbumStateEnum.BACK.getCode(), + AlbumStateEnum.REMOVAL.getCode() }; if (!Arrays.asList(allowState).contains(state)) { throw new BizException(ErrorConstants.STATE_ERROR);