【功能新增】IoT:产品导出功能
This commit is contained in:
parent
9841c869a2
commit
db9c485285
|
@ -0,0 +1,16 @@
|
|||
package cn.iocoder.yudao.module.iot.enums;
|
||||
|
||||
/**
|
||||
* IoT 字典类型的枚举类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public class DictTypeConstants {
|
||||
|
||||
public static final String PRODUCT_STATUS = "iot_product_status";
|
||||
public static final String PRODUCT_DEVICE_TYPE = "iot_product_device_type";
|
||||
public static final String NET_TYPE = "iot_net_type";
|
||||
public static final String PROTOCOL_TYPE = "iot_protocol_type";
|
||||
public static final String DATA_FORMAT = "iot_data_format";
|
||||
public static final String VALIDATE_TYPE = "iot_validate_type";
|
||||
}
|
|
@ -1,9 +1,12 @@
|
|||
package cn.iocoder.yudao.module.iot.controller.admin.product;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.product.vo.product.IotProductPageReqVO;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.product.vo.product.IotProductRespVO;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.product.vo.product.IotProductSaveReqVO;
|
||||
|
@ -15,14 +18,17 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
|
||||
|
@ -101,6 +107,19 @@ public class IotProductController {
|
|||
}));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出产品 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('iot:product:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportProductExcel(@Valid IotProductPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
CommonResult<PageResult<IotProductRespVO>> result = getProductPage(exportReqVO);
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "产品.xls", "数据", IotProductRespVO.class,
|
||||
result.getData().getList());
|
||||
}
|
||||
|
||||
@GetMapping("/simple-list")
|
||||
@Operation(summary = "获得所有产品列表")
|
||||
@PreAuthorize("@ss.hasPermission('iot:product:query')")
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package cn.iocoder.yudao.module.iot.controller.admin.product.vo.product;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.iot.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
@ -28,12 +31,15 @@ public class IotProductRespVO {
|
|||
private Long categoryId;
|
||||
|
||||
@Schema(description = "产品分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("产品分类")
|
||||
private String categoryName;
|
||||
|
||||
@Schema(description = "产品图标", example = "https://iocoder.cn/1.svg")
|
||||
@ExcelProperty("产品图标")
|
||||
private String icon;
|
||||
|
||||
@Schema(description = "产品图标", example = "https://iocoder.cn/1.png")
|
||||
@ExcelProperty("产品图标")
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "产品描述", example = "你猜")
|
||||
|
@ -41,19 +47,23 @@ public class IotProductRespVO {
|
|||
private String description;
|
||||
|
||||
@Schema(description = "产品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("产品状态")
|
||||
@ExcelProperty(value = "产品状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.PRODUCT_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "设备类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("设备类型")
|
||||
@ExcelProperty(value = "设备类型", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.PRODUCT_DEVICE_TYPE)
|
||||
private Integer deviceType;
|
||||
|
||||
@Schema(description = "联网方式", example = "2")
|
||||
@ExcelProperty("联网方式")
|
||||
@ExcelProperty(value = "联网方式", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.NET_TYPE)
|
||||
private Integer netType;
|
||||
|
||||
@Schema(description = "接入网关协议", example = "2")
|
||||
@ExcelProperty("接入网关协议")
|
||||
@ExcelProperty(value = "接入网关协议", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.PROTOCOL_TYPE)
|
||||
private Integer protocolType;
|
||||
|
||||
@Schema(description = "协议编号(脚本解析 id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "13177")
|
||||
|
@ -61,11 +71,13 @@ public class IotProductRespVO {
|
|||
private Long protocolId;
|
||||
|
||||
@Schema(description = "数据格式")
|
||||
@ExcelProperty("数据格式")
|
||||
@ExcelProperty(value = "数据格式", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.DATA_FORMAT)
|
||||
private Integer dataFormat;
|
||||
|
||||
@Schema(description = "数据校验级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("数据校验级别")
|
||||
@ExcelProperty(value = "数据校验级别", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.VALIDATE_TYPE)
|
||||
private Integer validateType;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
|
|
Loading…
Reference in New Issue