瀏覽代碼

还原同步学校机构中心时对type字段的处理

caozixuan 4 年之前
父節點
當前提交
f3b3feefd9

+ 52 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/OrgCenterTypeEnum.java

@@ -0,0 +1,52 @@
+package com.qmth.distributed.print.business.enums;
+
+import com.qmth.distributed.print.business.enums.result.EnumResult;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Description: 机构用户中心机构类别
+ * @Author: CaoZixuan
+ * @Date: 2021-03-27
+ */
+public enum OrgCenterTypeEnum {
+    NETWORK("NETWORK","高校网院"),
+    COLLEGE("COLLEGE","高校教务处"),
+    UNDERGRADUATE("UNDERGRADUATE","本科招办"),
+    POSTGRADUATE("COLLEGE","研究生招办"),
+    MINISTRY("MINISTRY","考试院"),
+    AOPENG("AOPENG","奥鹏"),
+    PARTNER("PARTNER","合作机构"),
+    OTHER("OTHER","其他"),
+    ;
+
+    OrgCenterTypeEnum(String typeCode, String typeName) {
+        this.typeCode = typeCode;
+        this.typeName = typeName;
+    }
+
+    private final String typeCode;
+    private final String typeName;
+
+    public String getTypeCode() {
+        return typeCode;
+    }
+
+    public String getTypeName() {
+        return typeName;
+    }
+    public static List<EnumResult> listTypes() {
+        List<EnumResult> list = new ArrayList<EnumResult>();
+        for (OrgCenterTypeEnum value : OrgCenterTypeEnum.values()) {
+            EnumResult result = new EnumResult();
+            result.setName(value.name());
+            result.setOrdinal(value.ordinal());
+            result.setCode(value.getTypeCode());
+            result.setDesc(value.getTypeName());
+            list.add(result);
+        }
+        return list;
+    }
+
+}

+ 21 - 9
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/OrgCenterDataDisposeServiceImpl.java

@@ -1,18 +1,22 @@
 package com.qmth.distributed.print.business.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.qmth.distributed.print.business.entity.BasicSchool;
+import com.qmth.distributed.print.business.enums.OrgCenterTypeEnum;
 import com.qmth.distributed.print.business.service.BasicSchoolService;
 import com.qmth.distributed.print.business.service.CallApiOrgCenterService;
 import com.qmth.distributed.print.business.service.OrgCenterDataDisposeService;
 import com.qmth.distributed.print.common.contant.SystemConstant;
+import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -60,15 +64,23 @@ public class OrgCenterDataDisposeServiceImpl implements OrgCenterDataDisposeServ
             String logo = String.valueOf(map.get("logo"));
             String accessKey = String.valueOf(map.get("accessKey"));
             String accessSecret = String.valueOf(map.get("accessSecret"));
-            BasicSchool school = new BasicSchool();
-            school.setId(id);
-            school.setCode(code);
-            school.setName(name);
-            school.setEnable(true);
-            school.setAccessKey(accessKey);
-            school.setAccessSecret(accessSecret);
-            school.setLogo(logo);
-            basicSchoolService.save(school);
+            Map typeMap = JSONObject.parseObject(String.valueOf(map.get("type")));
+            String typeCode = String.valueOf(typeMap.get("code"));
+            String typeName = String.valueOf(typeMap.get("name"));
+            if (!Arrays.stream(OrgCenterTypeEnum.values()).map(OrgCenterTypeEnum::getTypeCode).collect(Collectors.toList()).contains(typeCode)) {
+                throw ExceptionResultEnum.ERROR.exception("机构类型在枚举中不存在 + typeCode = " + typeCode);
+            }
+            if (!OrgCenterTypeEnum.PARTNER.getTypeCode().equals(typeCode)) {
+                BasicSchool school = new BasicSchool();
+                school.setId(id);
+                school.setCode(code);
+                school.setName(name);
+                school.setEnable(true);
+                school.setAccessKey(accessKey);
+                school.setAccessSecret(accessSecret);
+                school.setLogo(logo);
+                basicSchoolService.save(school);
+            }
         }
     }
 }

+ 3 - 0
distributed-print/src/main/java/com/qmth/distributed/print/api/EnumsController.java

@@ -85,6 +85,9 @@ public class EnumsController {
         } else if (type.equals(EnumType.CARD_REQUIRED_FIELDS.name())) {
             //题卡必选字段
             list = CardRequiredFieldsEnum.listTypes();
+        } else if (type.equals(EnumType.ORG_CENTER_TYPE_ENUM.name())) {
+            //机构用户中心类型
+            list = OrgCenterTypeEnum.listTypes();
         } else if (type.equals(EnumType.PRINT_PLAN_STATUS_ENUM.name())) {
             //印刷计划状态
             list = PrintPlanStatusEnum.listTypes();