Browse Source

同步配置加学校id

wangliang 2 years ago
parent
commit
11be2c0a38

+ 12 - 12
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/SysAdminSetParam.java

@@ -27,10 +27,10 @@ public class SysAdminSetParam extends TSchoolPrivilege {
     Boolean accountSmsVerify;
 
     @ApiModelProperty(value = "第三方统一身份认证地址")
-    String teachcloudExchangeSerivePath;
+    String teachcloudExchangeHostUrl;
 
     @ApiModelProperty(value = "同步配置地址")
-    String syncServicePath;
+    String syncServicePaths;
 
     @JsonSerialize(using = ToStringSerializer.class)
     @ApiModelProperty(value = "角色id数组")
@@ -40,17 +40,17 @@ public class SysAdminSetParam extends TSchoolPrivilege {
 
     }
 
-    public SysAdminSetParam(Boolean accountSmsVerify, String teachcloudExchangeSerivePath) {
+    public SysAdminSetParam(Boolean accountSmsVerify, String teachcloudExchangeHostUrl) {
         this.accountSmsVerify = accountSmsVerify;
-        this.teachcloudExchangeSerivePath = teachcloudExchangeSerivePath;
+        this.teachcloudExchangeHostUrl = teachcloudExchangeHostUrl;
     }
 
-    public String getTeachcloudExchangeSerivePath() {
-        return teachcloudExchangeSerivePath;
+    public String getTeachcloudExchangeHostUrl() {
+        return teachcloudExchangeHostUrl;
     }
 
-    public void setTeachcloudExchangeSerivePath(String teachcloudExchangeSerivePath) {
-        this.teachcloudExchangeSerivePath = teachcloudExchangeSerivePath;
+    public void setTeachcloudExchangeHostUrl(String teachcloudExchangeHostUrl) {
+        this.teachcloudExchangeHostUrl = teachcloudExchangeHostUrl;
     }
 
     public Long[] getRoleIds() {
@@ -61,12 +61,12 @@ public class SysAdminSetParam extends TSchoolPrivilege {
         this.roleIds = roleIds;
     }
 
-    public String getSyncServicePath() {
-        return syncServicePath;
+    public String getSyncServicePaths() {
+        return syncServicePaths;
     }
 
-    public void setSyncServicePath(String syncServicePath) {
-        this.syncServicePath = syncServicePath;
+    public void setSyncServicePaths(String syncServicePaths) {
+        this.syncServicePaths = syncServicePaths;
     }
 
     public Boolean getAccountSmsVerify() {

+ 14 - 14
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/SysAdminSetResult.java

@@ -32,10 +32,10 @@ public class SysAdminSetResult implements Serializable {
     Boolean accountSmsVerify;
 
     @ApiModelProperty(value = "第三方统一身份认证地址")
-    String teachcloudExchangeSerivePath;
+    String teachcloudExchangeHostUrl;
 
     @ApiModelProperty(value = "同步配置地址")
-    String syncServicePath;
+    String syncServicePaths;
 
     @ApiModelProperty(value = "自定义角色id")
     List<String> roleIdList;
@@ -53,15 +53,15 @@ public class SysAdminSetResult implements Serializable {
         this.privilegeIdList = privilegeIdList;
     }
 
-    public SysAdminSetResult(Long schoolId, String syncServicePath) {
+    public SysAdminSetResult(Long schoolId, String syncServicePaths) {
         this.schoolId = schoolId;
-        this.syncServicePath = syncServicePath;
+        this.syncServicePaths = syncServicePaths;
     }
 
-    public SysAdminSetResult(Long schoolId, Boolean accountSmsVerify, String teachcloudExchangeSerivePath) {
+    public SysAdminSetResult(Long schoolId, Boolean accountSmsVerify, String teachcloudExchangeHostUrl) {
         this.schoolId = schoolId;
         this.accountSmsVerify = accountSmsVerify;
-        this.teachcloudExchangeSerivePath = teachcloudExchangeSerivePath;
+        this.teachcloudExchangeHostUrl = teachcloudExchangeHostUrl;
     }
 
     public List<String> getRoleIdList() {
@@ -72,20 +72,20 @@ public class SysAdminSetResult implements Serializable {
         this.roleIdList = roleIdList;
     }
 
-    public String getSyncServicePath() {
-        return syncServicePath;
+    public String getTeachcloudExchangeHostUrl() {
+        return teachcloudExchangeHostUrl;
     }
 
-    public void setSyncServicePath(String syncServicePath) {
-        this.syncServicePath = syncServicePath;
+    public void setTeachcloudExchangeHostUrl(String teachcloudExchangeHostUrl) {
+        this.teachcloudExchangeHostUrl = teachcloudExchangeHostUrl;
     }
 
-    public String getTeachcloudExchangeSerivePath() {
-        return teachcloudExchangeSerivePath;
+    public String getSyncServicePaths() {
+        return syncServicePaths;
     }
 
-    public void setTeachcloudExchangeSerivePath(String teachcloudExchangeSerivePath) {
-        this.teachcloudExchangeSerivePath = teachcloudExchangeSerivePath;
+    public void setSyncServicePaths(String syncServicePaths) {
+        this.syncServicePaths = syncServicePaths;
     }
 
     public Boolean getAccountSmsVerify() {

+ 40 - 31
distributed-print/src/main/java/com/qmth/distributed/print/api/SysAdminSetController.java

@@ -104,32 +104,41 @@ public class SysAdminSetController {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
-        Optional.ofNullable(sysAdminSetParam.getSyncServicePath()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("同步配置地址不能为空"));
-
-        SysConfig sysConfigSyncServicePath = commonCacheService.addSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.SYNC_SERVICE_PATHS);
-        if (Objects.isNull(sysConfigSyncServicePath)) {
-            sysConfigSyncServicePath = new SysConfig(sysAdminSetParam.getSchoolId(), SystemConstant.SYNC_SERVICE_PATHS, "同步配置地址", sysAdminSetParam.getSyncServicePath());
-            JSONObject jsonObject = JSONObject.parseObject(sysConfigSyncServicePath.getConfigValue());
-            SysConfig sysConfigQuestionHostUrl = commonCacheService.addSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.QUESTION_HOST_URL);
-            sysConfigQuestionHostUrl.setConfigValue(jsonObject.getString(SystemConstant.QUESTION_HOST_URL));
-
-            SysConfig sysConfigCloudmarkHostUrl = commonCacheService.addSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.CLOUDMARK_HOST_URL);
-            sysConfigCloudmarkHostUrl.setConfigValue(jsonObject.getString(SystemConstant.CLOUDMARK_HOST_URL));
-
-            SysConfig sysConfigTeachcloudReportHostUrl = commonCacheService.addSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.TEACHCLOUD_REPORT_HOST_URL);
-            sysConfigQuestionHostUrl.setConfigValue(jsonObject.getString(SystemConstant.TEACHCLOUD_REPORT_HOST_URL));
-
-            sysConfigService.saveOrUpdateBatch(Arrays.asList(sysConfigQuestionHostUrl, sysConfigCloudmarkHostUrl, sysConfigTeachcloudReportHostUrl));
-
-            commonCacheService.updateSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.QUESTION_HOST_URL);
-            commonCacheService.updateSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.CLOUDMARK_HOST_URL);
-            commonCacheService.updateSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.TEACHCLOUD_REPORT_HOST_URL);
+        Optional.ofNullable(sysAdminSetParam.getSyncServicePaths()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("同步配置地址不能为空"));
+
+//        SysConfig sysConfigSyncServicePath = commonCacheService.addSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.SYNC_SERVICE_PATHS);
+
+        SysConfig sysConfigQuestionHostUrl = commonCacheService.addSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.QUESTION_HOST_URL);
+        SysConfig sysConfigCloudmarkHostUrl = commonCacheService.addSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.CLOUDMARK_HOST_URL);
+        SysConfig sysConfigTeachcloudReportHostUrl = commonCacheService.addSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.TEACHCLOUD_REPORT_HOST_URL);
+
+        JSONObject jsonObject = JSONObject.parseObject(sysAdminSetParam.getSyncServicePaths());;
+        if (Objects.isNull(sysConfigQuestionHostUrl)) {
+            sysConfigQuestionHostUrl = new SysConfig(sysAdminSetParam.getSchoolId(), SystemConstant.QUESTION_HOST_URL, "同步配置地址", jsonObject.getString(SystemConstant.QUESTION_HOST_URL));
+//            JSONObject jsonObject = JSONObject.parseObject(sysConfigSyncServicePath.getConfigValue());
+////            SysConfig sysConfigQuestionHostUrl = commonCacheService.addSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.QUESTION_HOST_URL);
+//            sysConfigQuestionHostUrl.setConfigValue(jsonObject.getString(SystemConstant.QUESTION_HOST_URL));
+//
+//            SysConfig sysConfigCloudmarkHostUrl = commonCacheService.addSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.CLOUDMARK_HOST_URL);
+//            sysConfigCloudmarkHostUrl.setConfigValue(jsonObject.getString(SystemConstant.CLOUDMARK_HOST_URL));
+//
+//            SysConfig sysConfigTeachcloudReportHostUrl = commonCacheService.addSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.TEACHCLOUD_REPORT_HOST_URL);
+//            sysConfigQuestionHostUrl.setConfigValue(jsonObject.getString(SystemConstant.TEACHCLOUD_REPORT_HOST_URL));
+//
+//            sysConfigService.saveOrUpdateBatch(Arrays.asList(sysConfigQuestionHostUrl, sysConfigCloudmarkHostUrl, sysConfigTeachcloudReportHostUrl));
+//
+//            commonCacheService.updateSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.QUESTION_HOST_URL);
+//            commonCacheService.updateSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.CLOUDMARK_HOST_URL);
+//            commonCacheService.updateSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.TEACHCLOUD_REPORT_HOST_URL);
         } else {
-            sysConfigSyncServicePath.setConfigValue(sysAdminSetParam.getSyncServicePath());
+            jsonObject = JSONObject.parseObject(sysAdminSetParam.getSyncServicePaths());
         }
-        sysConfigService.saveOrUpdate(sysConfigSyncServicePath);
+//        sysConfigService.saveOrUpdate(sysConfigSyncServicePath);
+        sysConfigService.saveOrUpdateBatch(Arrays.asList(sysConfigQuestionHostUrl, sysConfigCloudmarkHostUrl, sysConfigTeachcloudReportHostUrl));
 
-        commonCacheService.updateSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.SYNC_SERVICE_PATHS);
+        commonCacheService.updateSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.QUESTION_HOST_URL);
+        commonCacheService.updateSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.CLOUDMARK_HOST_URL);
+        commonCacheService.updateSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.TEACHCLOUD_REPORT_HOST_URL);
         return ResultUtil.ok(true);
     }
 
@@ -190,8 +199,8 @@ public class SysAdminSetController {
     @RequestMapping(value = "/user/select", method = RequestMethod.POST)
     public Result sysadminUserSelect(@ApiParam(value = "学校id ", required = true) @RequestParam Long schoolId) {
         SysConfig sysConfigAccount = commonCacheService.addSysConfigCache(schoolId, SystemConstant.ACCOUNT_SMS_VERIFY);
-        SysConfig sysConfigTeachcloudExchangeSerivePath = commonCacheService.addSysConfigCache(schoolId, SystemConstant.TEACHCLOUD_EXCHANGE_HOST_URL);
-        return ResultUtil.ok(new SysAdminSetResult(schoolId, Objects.nonNull(sysConfigAccount) ? Boolean.valueOf(sysConfigAccount.getConfigValue()) : false, Objects.nonNull(sysConfigTeachcloudExchangeSerivePath) ? sysConfigTeachcloudExchangeSerivePath.getConfigValue() : ""));
+        SysConfig sysConfigTeachcloudExchangeHostUrl = commonCacheService.addSysConfigCache(schoolId, SystemConstant.TEACHCLOUD_EXCHANGE_HOST_URL);
+        return ResultUtil.ok(new SysAdminSetResult(schoolId, Objects.nonNull(sysConfigAccount) ? Boolean.valueOf(sysConfigAccount.getConfigValue()) : false, Objects.nonNull(sysConfigTeachcloudExchangeHostUrl) ? sysConfigTeachcloudExchangeHostUrl.getConfigValue() : ""));
     }
 
     @ApiOperation(value = "用户验证保存")
@@ -203,7 +212,7 @@ public class SysAdminSetController {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
         Optional.ofNullable(sysAdminSetParam.getAccountSmsVerify()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("用户/密码模式是否开启不能为空"));
-        Optional.ofNullable(sysAdminSetParam.getTeachcloudExchangeSerivePath()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("第三方统一身份认证不能为空"));
+        Optional.ofNullable(sysAdminSetParam.getTeachcloudExchangeHostUrl()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("第三方统一身份认证不能为空"));
 
         List<SysConfig> sysConfigList = new ArrayList<>();
         SysConfig sysConfigAccount = commonCacheService.addSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.ACCOUNT_SMS_VERIFY);
@@ -214,13 +223,13 @@ public class SysAdminSetController {
         }
         sysConfigList.add(sysConfigAccount);
 
-        SysConfig sysConfigTeachcloudExchangeSerivePath = commonCacheService.addSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.TEACHCLOUD_EXCHANGE_HOST_URL);
-        if (Objects.isNull(sysConfigTeachcloudExchangeSerivePath)) {
-            sysConfigTeachcloudExchangeSerivePath = new SysConfig(sysAdminSetParam.getSchoolId(), SystemConstant.TEACHCLOUD_EXCHANGE_HOST_URL, "第三方统一身份认证", sysAdminSetParam.getTeachcloudExchangeSerivePath());
+        SysConfig sysConfigTeachcloudExchangeHostUrl = commonCacheService.addSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.TEACHCLOUD_EXCHANGE_HOST_URL);
+        if (Objects.isNull(sysConfigTeachcloudExchangeHostUrl)) {
+            sysConfigTeachcloudExchangeHostUrl = new SysConfig(sysAdminSetParam.getSchoolId(), SystemConstant.TEACHCLOUD_EXCHANGE_HOST_URL, "第三方统一身份认证", sysAdminSetParam.getTeachcloudExchangeHostUrl());
         } else {
-            sysConfigTeachcloudExchangeSerivePath.setConfigValue(sysAdminSetParam.getTeachcloudExchangeSerivePath());
+            sysConfigTeachcloudExchangeHostUrl.setConfigValue(sysAdminSetParam.getTeachcloudExchangeHostUrl());
         }
-        sysConfigList.add(sysConfigTeachcloudExchangeSerivePath);
+        sysConfigList.add(sysConfigTeachcloudExchangeHostUrl);
         sysConfigService.saveOrUpdateBatch(sysConfigList);
 
         commonCacheService.updateSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.ACCOUNT_SMS_VERIFY);