Selaa lähdekoodia

merge from release_v4.1.3

deason 2 vuotta sitten
vanhempi
commit
7fec24b3de

+ 26 - 0
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/DevOpsController.java

@@ -0,0 +1,26 @@
+package cn.com.qmth.examcloud.core.basic.api.controller;
+
+import cn.com.qmth.examcloud.web.support.Naked;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Api(tags = "运维接口")
+@RestController
+@RequestMapping("${$rmp.ctr.basic}")
+public class DevOpsController {
+
+    private static final Logger log = LoggerFactory.getLogger(DevOpsController.class);
+
+    @Naked
+    @ApiOperation(value = "运维监控检测接口")
+    @GetMapping("/devops")
+    public Long devops() {
+        return System.currentTimeMillis();
+    }
+
+}

+ 98 - 19
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/SystemPropertyController.java

@@ -1,16 +1,17 @@
 package cn.com.qmth.examcloud.core.basic.api.controller;
 
-import cn.com.qmth.examcloud.core.basic.api.controller.bean.SystemPropertyDomain;
-import cn.com.qmth.examcloud.core.basic.dao.SystemPropertyRepo;
-import cn.com.qmth.examcloud.core.basic.dao.entity.SystemPropertyEntity;
-import cn.com.qmth.examcloud.core.basic.service.SystemPropertyService;
-import cn.com.qmth.examcloud.core.basic.service.bean.SystemPropertyInfo;
-import cn.com.qmth.examcloud.core.basic.service.cache.SystemPropertyCache;
-import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
-import cn.com.qmth.examcloud.web.support.ControllerSupport;
-import com.google.common.collect.Lists;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import javax.persistence.criteria.Predicate;
+import javax.validation.Valid;
+
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,14 +21,33 @@ import org.springframework.data.domain.Sort;
 import org.springframework.data.domain.Sort.Direction;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
-import javax.persistence.criteria.Predicate;
-import javax.validation.Valid;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
+import com.google.common.collect.Lists;
+
+import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.commons.util.UUID;
+import cn.com.qmth.examcloud.core.basic.api.controller.bean.SystemPropertyDomain;
+import cn.com.qmth.examcloud.core.basic.dao.SystemPropertyRepo;
+import cn.com.qmth.examcloud.core.basic.dao.entity.SystemPropertyEntity;
+import cn.com.qmth.examcloud.core.basic.service.SystemPropertyService;
+import cn.com.qmth.examcloud.core.basic.service.bean.SystemPropertyInfo;
+import cn.com.qmth.examcloud.core.basic.service.cache.SystemPropertyCache;
+import cn.com.qmth.examcloud.support.filestorage.FileStorageUtil;
+import cn.com.qmth.examcloud.web.config.SystemProperties;
+import cn.com.qmth.examcloud.web.filestorage.FileStoragePathEnvInfo;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
+import cn.com.qmth.examcloud.web.support.ControllerSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 
 /**
  * 系统配置
@@ -40,7 +60,8 @@ import java.util.stream.Stream;
 @Api(tags = "系统配置相关接口")
 @RequestMapping("${$rmp.ctr.basic}/systemProperty")
 public class SystemPropertyController extends ControllerSupport {
-
+    @Autowired
+    private SystemProperties systemConfig;
     @Autowired
     SystemPropertyService systemPropertyService;
 
@@ -50,6 +71,64 @@ public class SystemPropertyController extends ControllerSupport {
     @Autowired
     SystemPropertyCache systemPropertyCache;
 
+    @ApiOperation(value = "获取软件黑名单")
+    @GetMapping("blacklist")
+    public String getBlacklist() {
+    	File dir=new File(systemConfig.getTempDataDir() +"/" + UUID.randomUUID()+"/");
+    	try {
+    		dir.mkdirs();
+			File file = new File(dir.getAbsoluteFile()+"/software.json");
+			file.createNewFile();
+			try {
+				FileStorageUtil.saveUrlAs(FileStorageUtil.realPath("aliyun-1://oe_client/software.json"), file);
+			} catch (Exception e) {
+				return "";
+			}
+			String content=FileUtils.readFileToString(file, "UTF-8");
+			if(StringUtils.isBlank(content)) {
+				return "";
+			}
+			content=content.substring(0,content.length()-32);
+			StringBuilder sb=new StringBuilder(content);
+			sb.reverse();
+			return new String(Base64.getDecoder().decode(sb.toString()));
+		} catch (IOException e) {
+			throw new StatusException("500","保存失败",e);
+		}finally {
+			try {
+				FileUtils.deleteDirectory(dir);
+			} catch (IOException e) {
+			}
+		}
+    }
+    
+    @ApiOperation(value = "保存软件黑名单")
+    @PutMapping("blacklist")
+    public void saveBlacklist(@RequestParam(required = false) String blacklist) {
+    	File dir=new File(systemConfig.getTempDataDir() +"/" + UUID.randomUUID()+"/");
+    	try {
+    		dir.mkdirs();
+			File file = new File(dir.getAbsoluteFile()+"/software.json");
+			file.createNewFile();
+			if(StringUtils.isNotBlank(blacklist)) {
+				StringBuilder sb=new StringBuilder(Base64.getEncoder().encodeToString(blacklist.getBytes()));
+				sb.reverse();
+				String ret=sb.toString()+UUID.randomUUID().toUpperCase();
+				FileUtils.write(file, ret, "UTF-8");
+			}
+			FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
+            FileStorageUtil.saveFile("blacklist", env, file, null,0L);
+		} catch (IOException e) {
+			throw new StatusException("500","保存失败",e);
+		}finally {
+			try {
+				FileUtils.deleteDirectory(dir);
+			} catch (IOException e) {
+			}
+		}
+    }
+    
+    
     @ApiOperation(value = "查询系统配置")
     @GetMapping("{key}")
     public Object get(@PathVariable String key) {

+ 63 - 56
examcloud-core-basic-starter/src/main/resources/aliyun.xml

@@ -1,64 +1,71 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <sites>
 
-    <site>
-        <id>resource</id>
-        <name>资源</name>
-        <aliyunId>1</aliyunId>
-        <maxSize>50M</maxSize>
-        <path>/${relativePath}</path>
-    </site>
-    <site>
-        <id>orgLogo</id>
-        <name>机构logo</name>
-        <aliyunId>1</aliyunId>
-        <maxSize>1M</maxSize>
-        <path>/org_logo/${rootOrgId}/${timeMillis}${fileSuffix}</path>
-    </site>
-    <site>
-        <id>orgAnswers</id>
-        <name>机构答题纸</name>
-        <aliyunId>1</aliyunId>
-        <maxSize>2M</maxSize>
-        <path>/org_answers/${rootOrgId}/${timeMillis}${fileSuffix}</path>
-    </site>
+	<site>
+		<id>resource</id>
+		<name>资源</name>
+		<aliyunId>1</aliyunId>
+		<maxSize>50M</maxSize>
+		<path>/${relativePath}</path>
+	</site>
+	<site>
+		<id>orgLogo</id>
+		<name>机构logo</name>
+		<aliyunId>1</aliyunId>
+		<maxSize>1M</maxSize>
+		<path>/org_logo/${rootOrgId}/${timeMillis}${fileSuffix}</path>
+	</site>
+	<site>
+		<id>orgAnswers</id>
+		<name>机构答题纸</name>
+		<aliyunId>1</aliyunId>
+		<maxSize>2M</maxSize>
+		<path>/org_answers/${rootOrgId}/${timeMillis}${fileSuffix}</path>
+	</site>
 
-    <site>
-        <id>orgPropertiesByOrgId</id>
-        <name>机构属性(机构ID查询)</name>
-        <aliyunId>1</aliyunId>
-        <maxSize>1M</maxSize>
-        <path>/org_properties/byOrgId/${rootOrgId}/${ext1}${fileSuffix}</path>
-    </site>
+	<site>
+		<id>orgPropertiesByOrgId</id>
+		<name>机构属性(机构ID查询)</name>
+		<aliyunId>1</aliyunId>
+		<maxSize>1M</maxSize>
+		<path>/org_properties/byOrgId/${rootOrgId}/${ext1}${fileSuffix}</path>
+	</site>
 
-    <site>
-        <id>orgPropertiesByOrgDomain</id>
-        <name>机构属性(机构域名查询)</name>
-        <aliyunId>1</aliyunId>
-        <maxSize>1M</maxSize>
-        <path>/org_properties/byOrgDomain/${rootOrgDomain}/${ext1}${fileSuffix}</path>
-    </site>
+	<site>
+		<id>orgPropertiesByOrgDomain</id>
+		<name>机构属性(机构域名查询)</name>
+		<aliyunId>1</aliyunId>
+		<maxSize>1M</maxSize>
+		<path>/org_properties/byOrgDomain/${rootOrgDomain}/${ext1}${fileSuffix}</path>
+	</site>
 
-    <site>
-        <id>orgProperties</id>
-        <name>机构属性(登录规则配置)</name>
-        <aliyunId>1</aliyunId>
-        <maxSize>1M</maxSize>
-        <path>/org_properties/${ext1}.json</path>
-    </site>
+	<site>
+		<id>orgProperties</id>
+		<name>机构属性(登录规则配置)</name>
+		<aliyunId>1</aliyunId>
+		<maxSize>1M</maxSize>
+		<path>/org_properties/${ext1}.json</path>
+	</site>
 
-    <site>
-        <id>sysNotice</id>
-        <name>系统通知</name>
-        <aliyunId>1</aliyunId>
-        <maxSize>10M</maxSize>
-        <path>/sys_notice/org_${rootOrgId}${fileSuffix}</path>
-    </site>
-    <site>
-        <id>client_bg_picture</id>
-        <name>考生端登录界面图片</name>
-        <aliyunId>1</aliyunId>
-        <maxSize>1M</maxSize>
-        <path>/client_bg_picture/${rootOrgId}/${timeMillis}${fileSuffix}</path>
-    </site>
+	<site>
+		<id>sysNotice</id>
+		<name>系统通知</name>
+		<aliyunId>1</aliyunId>
+		<maxSize>10M</maxSize>
+		<path>/sys_notice/org_${rootOrgId}${fileSuffix}</path>
+	</site>
+	<site>
+		<id>client_bg_picture</id>
+		<name>考生端登录界面图片</name>
+		<aliyunId>1</aliyunId>
+		<maxSize>1M</maxSize>
+		<path>/client_bg_picture/${rootOrgId}/${timeMillis}${fileSuffix}</path>
+	</site>
+	<site>
+		<id>blacklist</id>
+		<name>软件黑名单</name>
+		<aliyunId>1</aliyunId>
+		<maxSize>10M</maxSize>
+		<path>/oe_client/software.json</path>
+	</site>
 </sites>