浏览代码

超管设置新增试卷规格配置

wangliang 2 年之前
父节点
当前提交
8e8513d998

+ 11 - 31
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/CustomPrivilegeResult.java

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.business.bean.result;
 
+import com.fasterxml.jackson.annotation.JsonInclude;
 import com.qmth.teachcloud.common.bean.dto.PrivilegeDto;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -13,16 +14,14 @@ import java.util.List;
  * @Author: wangliang
  * @Date: 2022/8/24
  */
+@JsonInclude(JsonInclude.Include.NON_NULL)
 public class CustomPrivilegeResult implements Serializable {
 
     @ApiModelProperty(value = "自定义菜单")
     List<PrivilegeDto> customPrivilegeList;
 
-//    @ApiModelProperty(value = "全局pdf格式")
-//    List<String> sysPdfSize;
-//
-//    @ApiModelProperty(value = "用户/密码模式是否开启短信验证")
-//    boolean accountSmsVerify;
+    @ApiModelProperty(value = "全局pdf格式")
+    List<String> sysPdfSize;
 
     public CustomPrivilegeResult() {
 
@@ -32,25 +31,6 @@ public class CustomPrivilegeResult implements Serializable {
         this.customPrivilegeList = customPrivilegeList;
     }
 
-//    public CustomPrivilegeResult(List<PrivilegeDto> customPrivilegeList, List<String> sysPdfSize) {
-//        this.customPrivilegeList = customPrivilegeList;
-//        this.sysPdfSize = sysPdfSize;
-//    }
-//
-//    public CustomPrivilegeResult(List<PrivilegeDto> customPrivilegeList, List<String> sysPdfSize, boolean accountSmsVerify) {
-//        this.customPrivilegeList = customPrivilegeList;
-//        this.sysPdfSize = sysPdfSize;
-//        this.accountSmsVerify = accountSmsVerify;
-//    }
-
-//    public boolean isAccountSmsVerify() {
-//        return accountSmsVerify;
-//    }
-//
-//    public void setAccountSmsVerify(boolean accountSmsVerify) {
-//        this.accountSmsVerify = accountSmsVerify;
-//    }
-
     public List<PrivilegeDto> getCustomPrivilegeList() {
         return customPrivilegeList;
     }
@@ -59,11 +39,11 @@ public class CustomPrivilegeResult implements Serializable {
         this.customPrivilegeList = customPrivilegeList;
     }
 
-//    public List<String> getSysPdfSize() {
-//        return sysPdfSize;
-//    }
-//
-//    public void setSysPdfSize(List<String> sysPdfSize) {
-//        this.sysPdfSize = sysPdfSize;
-//    }
+    public List<String> getSysPdfSize() {
+        return sysPdfSize;
+    }
+
+    public void setSysPdfSize(List<String> sysPdfSize) {
+        this.sysPdfSize = sysPdfSize;
+    }
 }

+ 54 - 0
distributed-print/src/main/java/com/qmth/distributed/print/api/SysAdminSetController.java

@@ -9,6 +9,7 @@ import com.qmth.distributed.print.business.bean.result.SysAdminSetResult;
 import com.qmth.teachcloud.common.bean.dto.PrivilegeDto;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.*;
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.service.*;
 import com.qmth.teachcloud.common.util.Result;
 import com.qmth.teachcloud.common.util.ResultUtil;
@@ -61,6 +62,56 @@ public class SysAdminSetController {
     @Resource
     SysConfigService sysConfigService;
 
+    @ApiOperation(value = "查询自定义菜单权限")
+    @ApiResponses({@ApiResponse(code = 200, message = "菜单权限信息", response = SysPrivilege.class)})
+    @RequestMapping(value = "/paper/sys/select", method = RequestMethod.POST)
+    public Result sysadminPaperSysSelect() {
+        SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.SYS_PDF_SIZE_LIST);
+        Optional.ofNullable(sysConfig).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未配置全局pdf格式清单"));
+        CustomPrivilegeResult customPrivilegeResult = new CustomPrivilegeResult();
+        customPrivilegeResult.setSysPdfSize(Arrays.asList(sysConfig.getConfigValue().replaceAll("\\[", "").replaceAll("\\]", "").split(", ")));
+        return ResultUtil.ok(customPrivilegeResult);
+    }
+
+    @ApiOperation(value = "试卷规格配置查询")
+    @ApiResponses({@ApiResponse(code = 200, message = "试卷规格配置信息", response = SysAdminSetResult.class)})
+    @RequestMapping(value = "/paper/select", method = RequestMethod.POST)
+    public Result sysadminPaperSelect(@ApiParam(value = "学校id ", required = true) @RequestParam Long schoolId) {
+        SysConfig sysConfigPdfSize = commonCacheService.addSysConfigCache(schoolId, SystemConstant.PDF_SIZE_LIST);
+        List<String> pdfSize = null;
+        if (Objects.nonNull(sysConfigPdfSize)) {
+            pdfSize = Arrays.asList(sysConfigPdfSize.getConfigValue().replaceAll("\\[", "").replaceAll("\\]", "").split(", "));
+        }
+        return ResultUtil.ok(new SysAdminSetResult(schoolId, CollectionUtils.isEmpty(pdfSize) ? new ArrayList<>() : pdfSize));
+    }
+
+    @ApiOperation(value = "试卷规格配置保存")
+    @ApiResponses({@ApiResponse(code = 200, message = "试卷规格配置信息", response = ResultUtil.class)})
+    @RequestMapping(value = "/paper/save", method = RequestMethod.POST)
+    @Transactional
+    public Result sysadminPaperSave(@Valid @RequestBody SysAdminSetParam sysAdminSetParam, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
+        }
+        Optional.ofNullable(sysAdminSetParam.getPdfSize()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("试卷规格配置不能为空"));
+
+        SysConfig sysConfigPdfSize = commonCacheService.addSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.PDF_SIZE_LIST);
+        if (Objects.isNull(sysConfigPdfSize)) {
+            sysConfigPdfSize = new SysConfig(sysAdminSetParam.getSchoolId(), SystemConstant.PDF_SIZE_LIST, "pdf格式清单", Arrays.asList(sysAdminSetParam.getPdfSize()).toString());
+        } else {
+            if (Objects.nonNull(sysAdminSetParam.getPdfSize()) && sysAdminSetParam.getPdfSize().length > 0) {
+                sysConfigPdfSize.setConfigValue(Arrays.asList(sysAdminSetParam.getPdfSize()).toString());
+            } else {
+                sysConfigPdfSize.setConfigValue(null);
+            }
+        }
+        sysConfigService.saveOrUpdate(sysConfigPdfSize);
+
+        commonCacheService.removeSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.PDF_SIZE_LIST);
+        return ResultUtil.ok(true);
+    }
+
+
     @ApiOperation(value = "用户验证查询")
     @ApiResponses({@ApiResponse(code = 200, message = "用户验证信息", response = SysAdminSetResult.class)})
     @RequestMapping(value = "/user/select", method = RequestMethod.POST)
@@ -78,6 +129,9 @@ public class SysAdminSetController {
         if (bindingResult.hasErrors()) {
             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("第三方统一身份认证不能为空"));
+
         List<SysConfig> sysConfigList = new ArrayList<>();
         SysConfig sysConfigAccount = commonCacheService.addSysConfigCache(sysAdminSetParam.getSchoolId(), SystemConstant.ACCOUNT_SMS_VERIFY);
         if (Objects.isNull(sysConfigAccount)) {