Kaynağa Gözat

add 本地枚举接口返回

GITZYY 2 ay önce
ebeveyn
işleme
4f2c20078b

+ 28 - 0
egress-gateway-service-app/src/main/java/com/hrsk/cloud/eg/app/api/comon/CommonServiceImpl.java

@@ -0,0 +1,28 @@
+package com.hrsk.cloud.eg.app.api.comon;
+
+import com.hrsk.cloud.eg.app.business.CommonService;
+import com.hrsk.cloud.eg.dto.data.common.LocalEnumDto;
+import com.hrsk.cloud.eg.vo.response.DefaultResponseVo;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @author zhangyy
+ * @version 1.0
+ * @description: commonService
+ * @date 2024/9/24 11:47
+ */
+@RequestMapping("common")
+@RestController
+public class CommonServiceImpl {
+    @Resource private CommonService commonService;
+
+
+    @RequestMapping("/localEnumList")
+    public DefaultResponseVo<List<LocalEnumDto>> getLocalEnumList(){
+        return  DefaultResponseVo.success(commonService.getLocalEnumList());
+    }
+}

+ 38 - 0
egress-gateway-service-app/src/main/java/com/hrsk/cloud/eg/app/business/CommonService.java

@@ -0,0 +1,38 @@
+package com.hrsk.cloud.eg.app.business;
+
+import com.hrsk.cloud.eg.app.constant.EgApiTypeEnum;
+import com.hrsk.cloud.eg.dto.data.common.LocalEnumDto;
+import com.hrsk.cloud.eg.vo.response.DefaultResponseVo;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author zhangyy
+ * @version 1.0
+ * @description: CommonService 公共信息操作类
+ * @date 2024/9/24 11:48
+ */
+@Service
+public class CommonService {
+
+    /**
+     * @description:  获取本地枚举返回给前端
+     * @author zhangyy
+     * @date 2024/9/24 11:56
+     * @version 1.0
+     */
+    public List<LocalEnumDto> getLocalEnumList() {
+        List<LocalEnumDto> localEnumDtoList = new ArrayList<>();
+        EgApiTypeEnum[] values = EgApiTypeEnum.values();
+        LocalEnumDto localEnumDto=null;
+        for (int i = 0; i < values.length; i++) {
+            localEnumDto = new LocalEnumDto();
+            localEnumDto.setCode(values[i].getCode());
+            localEnumDto.setMsg(values[i].getMsg());
+            localEnumDtoList.add(localEnumDto);
+        }
+        return localEnumDtoList;
+    }
+}

+ 15 - 0
egress-gateway-service-client/src/main/java/com/hrsk/cloud/eg/dto/data/common/LocalEnumDto.java

@@ -0,0 +1,15 @@
+package com.hrsk.cloud.eg.dto.data.common;
+
+import lombok.Data;
+
+/**
+ * @author zhangyy
+ * @version 1.0
+ * @description: LocalEnumDto
+ * @date 2024/9/24 11:53
+ */
+@Data
+public class LocalEnumDto {
+    private String code;
+    private String msg;
+}