From 04f28b30c73e6316848f494a095ade687edf5a86 Mon Sep 17 00:00:00 2001 From: pikaqiudeshujia Date: Wed, 8 May 2024 16:49:47 +0800 Subject: [PATCH] =?UTF-8?q?release-=20=E4=B8=8B=E6=9E=B6=E4=B8=8Emall?= =?UTF-8?q?=E8=81=94=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/enums/AlbumStateEnum.java | 4 +++- .../com/luoo/music/service/AlbumService.java | 20 ++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) 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);