新增 删除商品sku信息同时删除es中数据
This commit is contained in:
parent
3019bc5737
commit
c8610f2b3e
@ -86,7 +86,7 @@ public class SkuInfoController {
|
|||||||
//TODO 删除es
|
//TODO 删除es
|
||||||
public Result remove(@PathVariable Long id) {
|
public Result remove(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
skuInfoService.removeById(id);
|
skuInfoService.deleteById(id);
|
||||||
return Result.ok(null);
|
return Result.ok(null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("删除商品sku信息异常", e);
|
throw new RuntimeException("删除商品sku信息异常", e);
|
||||||
@ -98,7 +98,7 @@ public class SkuInfoController {
|
|||||||
//TODO 删除es
|
//TODO 删除es
|
||||||
public Result batchRemove(@RequestBody List<Long> idList) {
|
public Result batchRemove(@RequestBody List<Long> idList) {
|
||||||
try {
|
try {
|
||||||
skuInfoService.removeByIds(idList);
|
skuInfoService.deleteByIds(idList);
|
||||||
return Result.ok(null);
|
return Result.ok(null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("根据id列表删除商品sku信息异常", e);
|
throw new RuntimeException("根据id列表删除商品sku信息异常", e);
|
||||||
|
@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* sku信息 服务类
|
* sku信息 服务类
|
||||||
@ -29,4 +31,8 @@ public interface SkuInfoService extends IService<SkuInfo> {
|
|||||||
void publish(Long skuId, Integer status);
|
void publish(Long skuId, Integer status);
|
||||||
|
|
||||||
void isNewPerson(Long skuId, Integer status);
|
void isNewPerson(Long skuId, Integer status);
|
||||||
|
|
||||||
|
void deleteByIds(List<Long> idList);
|
||||||
|
|
||||||
|
void deleteById(Long id);
|
||||||
}
|
}
|
||||||
|
@ -202,6 +202,7 @@ public class SkuInfoServiceImpl extends ServiceImpl<SkuInfoMapper, SkuInfo> impl
|
|||||||
* @param skuId
|
* @param skuId
|
||||||
* @param status
|
* @param status
|
||||||
*/
|
*/
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
@Override
|
@Override
|
||||||
public void publish(Long skuId, Integer status) {
|
public void publish(Long skuId, Integer status) {
|
||||||
// 更改发布状态
|
// 更改发布状态
|
||||||
@ -235,6 +236,24 @@ public class SkuInfoServiceImpl extends ServiceImpl<SkuInfoMapper, SkuInfo> impl
|
|||||||
baseMapper.updateById(skuInfo);
|
baseMapper.updateById(skuInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByIds(List<Long> idList) {
|
||||||
|
baseMapper.deleteBatchIds(idList);
|
||||||
|
|
||||||
|
//商品下架:发送mq消息同步es
|
||||||
|
for (Long id : idList) {
|
||||||
|
rabbitService.sendMessage(MqConst.EXCHANGE_GOODS_DIRECT, MqConst.ROUTING_GOODS_LOWER, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteById(Long id) {
|
||||||
|
baseMapper.deleteById(id);
|
||||||
|
|
||||||
|
//商品删除:发送mq消息同步es
|
||||||
|
rabbitService.sendMessage(MqConst.EXCHANGE_GOODS_DIRECT, MqConst.ROUTING_GOODS_LOWER, id);
|
||||||
|
}
|
||||||
|
|
||||||
private SkuInfoVo getSkuInfoDB(Long skuId) {
|
private SkuInfoVo getSkuInfoDB(Long skuId) {
|
||||||
SkuInfoVo skuInfoVo = new SkuInfoVo();
|
SkuInfoVo skuInfoVo = new SkuInfoVo();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user