refactor(iot): 删除设备和产品图片或预览图功能- 移除 DeviceController、DeviceService 和 DeviceServiceImpl 中的 deleteIconOrPreview 方法
- 在 ProductController 中添加 deleteIconOrPreview 方法- 在 ProductService 中添加 deleteIconOrPreview 方法 - 在 ProductServiceImpl 中实现 deleteIconOrPreview 方法
This commit is contained in:
parent
7908eba135
commit
11ddc374af
@ -171,12 +171,4 @@ public class DeviceController {
|
|||||||
return service.toggle(id);
|
return service.toggle(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除图片或预览图
|
|
||||||
*/
|
|
||||||
@DeleteMapping("/attachment/{id}")
|
|
||||||
@OperationLogAnnotation(content = "'设备图片或预览图'", operationType = "删除")
|
|
||||||
public Boolean deleteIconOrPreview(@PathVariable("id") Long id, String attachmentId) {
|
|
||||||
return service.deleteIconOrPreview(id, attachmentId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -39,5 +39,4 @@ public interface DeviceService extends IService<Device> {
|
|||||||
|
|
||||||
int toggle(Long id);
|
int toggle(Long id);
|
||||||
|
|
||||||
boolean deleteIconOrPreview(Long id, String attachmentId);
|
|
||||||
}
|
}
|
||||||
|
@ -254,20 +254,4 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceRepository, Device> imp
|
|||||||
return baseMapper.updateById(device);
|
return baseMapper.updateById(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除设备头像
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean deleteIconOrPreview(Long id, String attachmentId) {
|
|
||||||
Device device = baseMapper.selectById(id);
|
|
||||||
if (device.getIconId().equals(attachmentId)) {
|
|
||||||
device.setIconId("");
|
|
||||||
}
|
|
||||||
if (device.getPreviewId().equals(attachmentId)) {
|
|
||||||
device.setPreviewId("");
|
|
||||||
}
|
|
||||||
attachmentService.delete(attachmentId);
|
|
||||||
baseMapper.updateById(device);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -112,5 +112,15 @@ public class ProductController {
|
|||||||
public Object status() {
|
public Object status() {
|
||||||
return service.status();
|
return service.status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除图片或预览图
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/attachment/{id}")
|
||||||
|
@OperationLogAnnotation(content = "'设备图片或预览图'", operationType = "删除")
|
||||||
|
public Boolean deleteIconOrPreview(@PathVariable("id") Long id, String attachmentId) {
|
||||||
|
return service.deleteIconOrPreview(id, attachmentId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,4 +25,6 @@ public interface ProductService extends IService<Product> {
|
|||||||
List<Product> list(ProductQuery query);
|
List<Product> list(ProductQuery query);
|
||||||
|
|
||||||
ProductStatusVo status();
|
ProductStatusVo status();
|
||||||
|
|
||||||
|
boolean deleteIconOrPreview(Long id, String attachmentId);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.zsc.edu.gateway.modules.iot.product.service.impl;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.zsc.edu.gateway.exception.ConstraintException;
|
import com.zsc.edu.gateway.exception.ConstraintException;
|
||||||
|
import com.zsc.edu.gateway.modules.attachment.service.AttachmentService;
|
||||||
import com.zsc.edu.gateway.modules.iot.product.dto.ProductDto;
|
import com.zsc.edu.gateway.modules.iot.product.dto.ProductDto;
|
||||||
import com.zsc.edu.gateway.modules.iot.product.entity.Product;
|
import com.zsc.edu.gateway.modules.iot.product.entity.Product;
|
||||||
import com.zsc.edu.gateway.modules.iot.product.mapper.ProductMapper;
|
import com.zsc.edu.gateway.modules.iot.product.mapper.ProductMapper;
|
||||||
@ -27,6 +28,7 @@ import java.util.List;
|
|||||||
public class ProductServiceImpl extends ServiceImpl<ProductRepository, Product> implements ProductService {
|
public class ProductServiceImpl extends ServiceImpl<ProductRepository, Product> implements ProductService {
|
||||||
private final ProductMapper mapper;
|
private final ProductMapper mapper;
|
||||||
private final ParamService paramService;
|
private final ParamService paramService;
|
||||||
|
private final AttachmentService attachmentService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新建产品
|
* 新建产品
|
||||||
@ -100,4 +102,22 @@ public class ProductServiceImpl extends ServiceImpl<ProductRepository, Product>
|
|||||||
vo.disabledCount = baseMapper.selectCount(new LambdaQueryWrapper<Product>().eq(Product::getEnabled, false));
|
vo.disabledCount = baseMapper.selectCount(new LambdaQueryWrapper<Product>().eq(Product::getEnabled, false));
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除设备头像
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean deleteIconOrPreview(Long id, String attachmentId) {
|
||||||
|
Product product = baseMapper.selectById(id);
|
||||||
|
if (product.getIconId().equals(attachmentId)) {
|
||||||
|
product.setIconId("");
|
||||||
|
}
|
||||||
|
if (product.getPreviewId().equals(attachmentId)) {
|
||||||
|
product.setPreviewId("");
|
||||||
|
}
|
||||||
|
attachmentService.delete(attachmentId);
|
||||||
|
baseMapper.updateById(product);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 5.7 KiB |
Loading…
Reference in New Issue
Block a user