From 3fdaabf000f98741704e10d8828b2080898e5116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=95=B8=E9=9D=9E?= <13281114856@qq.com> Date: Mon, 18 Jul 2022 10:09:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=86=E4=B9=85=E8=AE=BE=E5=A4=87=E5=B1=95?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xhx/common/code/DeviceSourceEnum.java | 63 +++++++++++++++++++ .../module/device/web/DeviceController.java | 3 +- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 device-manager/src/main/java/com/mortals/xhx/common/code/DeviceSourceEnum.java diff --git a/device-manager/src/main/java/com/mortals/xhx/common/code/DeviceSourceEnum.java b/device-manager/src/main/java/com/mortals/xhx/common/code/DeviceSourceEnum.java new file mode 100644 index 00000000..f76201bb --- /dev/null +++ b/device-manager/src/main/java/com/mortals/xhx/common/code/DeviceSourceEnum.java @@ -0,0 +1,63 @@ +package com.mortals.xhx.common.code; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * 鍒╂棫璁惧 + */ +public enum DeviceSourceEnum { + 鏄�(0, "鏄�"), + 鍚�(1, "鍚�"); + private Integer value; + private String desc; + + DeviceSourceEnum(Integer value, String desc) { + this.value = value; + this.desc = desc; + } + + public Integer getValue() { + return this.value; + } + + public String getDesc() { + return this.desc; + } + + public static DeviceSourceEnum getByValue(Integer value) { + for (DeviceSourceEnum enabledEnum : DeviceSourceEnum.values()) { + if (enabledEnum.getValue() == value) { + return enabledEnum; + } + } + return null; + } + + /** + * 鑾峰彇Map闆嗗悎 + * + * @param eItem 涓嶅寘鍚」 + * @return + */ + public static Map<String, String> getEnumMap(Integer... eItem) { + Map<String, String> resultMap = new LinkedHashMap<>(); + for (DeviceSourceEnum item : DeviceSourceEnum.values()) { + try { + boolean hasE = false; + for (Integer e : eItem) { + if (item.getValue() == e) { + hasE = true; + break; + } + } + if (!hasE) { + resultMap.put(item.getValue() + "", item.getDesc()); + } + } catch (Exception ex) { + + } + } + return resultMap; + } +} \ No newline at end of file diff --git a/device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java b/device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java index 9d7d74bc..6bbfed18 100644 --- a/device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java +++ b/device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java @@ -18,6 +18,7 @@ import com.mortals.xhx.base.system.upload.service.UploadService; import com.mortals.xhx.base.system.user.model.UserEntity; import com.mortals.xhx.busiz.rsp.ApiResp; import com.mortals.xhx.common.code.ApiRespCodeEnum; +import com.mortals.xhx.common.code.DeviceSourceEnum; import com.mortals.xhx.common.code.DeviceStatusEnum; import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.key.Constant; @@ -87,7 +88,7 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe this.addDict(model, "isReceiveMess", paramService.getParamBySecondOrganize("Device", "isReceiveMess")); this.addDict(model, "deviceStatus", paramService.getParamBySecondOrganize("Device", "deviceStatus")); this.addDict(model, "enabled", paramService.getParamBySecondOrganize("Device", "enabled")); - this.addDict(model, "source", YesNoEnum.getEnumMap()); + this.addDict(model, "source", DeviceSourceEnum.getEnumMap()); super.init(model, context); } -- 2.24.3