|
@@ -1,15 +1,21 @@
|
|
package cn.iocoder.yudao.module.pms.controller.admin.iotdevicecategorytemplate;
|
|
package cn.iocoder.yudao.module.pms.controller.admin.iotdevicecategorytemplate;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotdevicecategorytemplate.vo.DeviceCategoryTemplateUpdateStatusReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdevicecategorytemplate.vo.IotDeviceCategoryTemplatePageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdevicecategorytemplate.vo.IotDeviceCategoryTemplatePageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdevicecategorytemplate.vo.IotDeviceCategoryTemplateRespVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdevicecategorytemplate.vo.IotDeviceCategoryTemplateRespVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdevicecategorytemplate.vo.IotDeviceCategoryTemplateSaveReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdevicecategorytemplate.vo.IotDeviceCategoryTemplateSaveReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotdevicetemplate.vo.DeviceTemplateUpdateStatusReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.convert.iotdevicecategorytemplate.IotDeviceCategoryTemplateConvert;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.IotProductClassifyDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicecategorytemplate.IotDeviceCategoryTemplateDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicecategorytemplate.IotDeviceCategoryTemplateDO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.service.IotProductClassifyService;
|
|
import cn.iocoder.yudao.module.pms.service.iotdevicecategorytemplate.IotDeviceCategoryTemplateService;
|
|
import cn.iocoder.yudao.module.pms.service.iotdevicecategorytemplate.IotDeviceCategoryTemplateService;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
@@ -23,9 +29,11 @@ import javax.servlet.http.HttpServletResponse;
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.List;
|
|
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.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
|
|
|
|
@Tag(name = "管理后台 - 设备分类属性公用模板")
|
|
@Tag(name = "管理后台 - 设备分类属性公用模板")
|
|
@RestController
|
|
@RestController
|
|
@@ -35,6 +43,8 @@ public class IotDeviceCategoryTemplateController {
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private IotDeviceCategoryTemplateService iotDeviceCategoryTemplateService;
|
|
private IotDeviceCategoryTemplateService iotDeviceCategoryTemplateService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IotProductClassifyService iotProductClassifyService;
|
|
|
|
|
|
@PostMapping("/create")
|
|
@PostMapping("/create")
|
|
@Operation(summary = "创建设备分类属性公用模板")
|
|
@Operation(summary = "创建设备分类属性公用模板")
|
|
@@ -51,6 +61,14 @@ public class IotDeviceCategoryTemplateController {
|
|
return success(true);
|
|
return success(true);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @PutMapping("/update-status")
|
|
|
|
+ @Operation(summary = "修改 设备分类属性模板 状态")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('pms:iot-device-category-template:update')")
|
|
|
|
+ public CommonResult<Boolean> updateDeviceCategoryTemplateStatus(@Valid @RequestBody DeviceCategoryTemplateUpdateStatusReqVO reqVO) {
|
|
|
|
+ iotDeviceCategoryTemplateService.updateDeviceCategoryTemplateStatus(reqVO.getId(), reqVO.getStatus());
|
|
|
|
+ return success(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
@DeleteMapping("/delete")
|
|
@DeleteMapping("/delete")
|
|
@Operation(summary = "删除设备分类属性公用模板")
|
|
@Operation(summary = "删除设备分类属性公用模板")
|
|
@Parameter(name = "id", description = "编号", required = true)
|
|
@Parameter(name = "id", description = "编号", required = true)
|
|
@@ -74,7 +92,14 @@ public class IotDeviceCategoryTemplateController {
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-device-category-template:query')")
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-device-category-template:query')")
|
|
public CommonResult<PageResult<IotDeviceCategoryTemplateRespVO>> getIotDeviceCategoryTemplatePage(@Valid IotDeviceCategoryTemplatePageReqVO pageReqVO) {
|
|
public CommonResult<PageResult<IotDeviceCategoryTemplateRespVO>> getIotDeviceCategoryTemplatePage(@Valid IotDeviceCategoryTemplatePageReqVO pageReqVO) {
|
|
PageResult<IotDeviceCategoryTemplateDO> pageResult = iotDeviceCategoryTemplateService.getIotDeviceCategoryTemplatePage(pageReqVO);
|
|
PageResult<IotDeviceCategoryTemplateDO> pageResult = iotDeviceCategoryTemplateService.getIotDeviceCategoryTemplatePage(pageReqVO);
|
|
- return success(BeanUtils.toBean(pageResult, IotDeviceCategoryTemplateRespVO.class));
|
|
|
|
|
|
+ if (CollUtil.isEmpty(pageResult.getList())) {
|
|
|
|
+ return success(new PageResult<>(pageResult.getTotal()));
|
|
|
|
+ }
|
|
|
|
+ // 拼接所属 设备分类 名称
|
|
|
|
+ Map<Long, IotProductClassifyDO> deviceCategoryMap = iotProductClassifyService.getIotProductClassifyMap(
|
|
|
|
+ convertList(pageResult.getList(), IotDeviceCategoryTemplateDO::getDeviceCategoryId));
|
|
|
|
+ return success(new PageResult<>(IotDeviceCategoryTemplateConvert.INSTANCE.convertList(pageResult.getList(), deviceCategoryMap),
|
|
|
|
+ pageResult.getTotal()));
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("/export-excel")
|
|
@GetMapping("/export-excel")
|