WANG 6 роки тому
батько
коміт
c1c7573a6d

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

@@ -27,10 +27,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.google.common.collect.Lists;
+
+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 io.swagger.annotations.ApiOperation;
@@ -53,6 +57,9 @@ public class SystemPropertyController extends ControllerSupport {
 	@Autowired
 	SystemPropertyRepo systemPropertyRepo;
 
+	@Autowired
+	SystemPropertyCache systemPropertyCache;
+
 	@ApiOperation(value = "查询系统配置")
 	@GetMapping("{key}")
 	public Object get(@PathVariable String key) {
@@ -93,13 +100,23 @@ public class SystemPropertyController extends ControllerSupport {
 
 	@ApiOperation(value = "新增系统参数")
 	@PostMapping
-	public void addSysProp(@RequestBody @Valid SystemPropertyInfo info) {
+	public void addSysProp(@RequestBody @Valid SystemPropertyDomain domain) {
+		SystemPropertyInfo info = new SystemPropertyInfo();
+		info.setDescription(domain.getDescription());
+		info.setPropKey(domain.getPropKey());
+		info.setPropValue(domain.getPropValue());
+		info.setPropValueType(domain.getPropValueType());
 		systemPropertyService.addSysProp(info);
 	}
 
 	@ApiOperation(value = "更新系统参数")
 	@PutMapping
-	public void updateSysProp(@RequestBody @Valid SystemPropertyInfo info) {
+	public void updateSysProp(@RequestBody @Valid SystemPropertyDomain domain) {
+		SystemPropertyInfo info = new SystemPropertyInfo();
+		info.setDescription(domain.getDescription());
+		info.setPropKey(domain.getPropKey());
+		info.setPropValue(domain.getPropValue());
+		info.setPropValueType(domain.getPropValueType());
 		systemPropertyService.updateSysProp(info);
 	}
 
@@ -108,14 +125,18 @@ public class SystemPropertyController extends ControllerSupport {
 	public void deleteSysProp(@PathVariable @Required String ids) {
 		List<String> propKeys = Stream.of(ids.split(",")).map(s -> s.trim())
 				.collect(Collectors.toList());
+		List<SystemPropertyEntity> list = Lists.newArrayList();
 		for (String key : propKeys) {
-			SystemPropertyEntity prop = GlobalHelper.getEntity(systemPropertyRepo, key,
+			SystemPropertyEntity prop = GlobalHelper.getPresentEntity(systemPropertyRepo, key,
 					SystemPropertyEntity.class);
-			if (null == prop) {
-				continue;
-			}
 			systemPropertyRepo.delete(prop);
+			list.add(prop);
 		}
+
+		for (SystemPropertyEntity cur : list) {
+			systemPropertyCache.refresh(cur.getPropKey());
+		}
+
 	}
 
 }

+ 27 - 4
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/bean/ResourceDomain.java

@@ -6,71 +6,94 @@ import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
 
 public class ResourceDomain implements JsonSerializable {
 
-
-	/**
-	 * 
-	 */
 	private static final long serialVersionUID = -8364653908915038360L;
+
 	private Long id;
+
 	private Long rootOrgId;
+
 	private String name;
+
 	private Boolean isFile;
+
 	private String suffix;
+
 	private String filePath;
+
 	private String fileUrl;
+
 	private Long parentId;
+
 	private Date creationTime;
+
 	public Long getId() {
 		return id;
 	}
+
 	public void setId(Long id) {
 		this.id = id;
 	}
+
 	public Long getRootOrgId() {
 		return rootOrgId;
 	}
+
 	public void setRootOrgId(Long rootOrgId) {
 		this.rootOrgId = rootOrgId;
 	}
+
 	public String getName() {
 		return name;
 	}
+
 	public void setName(String name) {
 		this.name = name;
 	}
+
 	public Boolean getIsFile() {
 		return isFile;
 	}
+
 	public void setIsFile(Boolean isFile) {
 		this.isFile = isFile;
 	}
+
 	public String getSuffix() {
 		return suffix;
 	}
+
 	public void setSuffix(String suffix) {
 		this.suffix = suffix;
 	}
+
 	public String getFilePath() {
 		return filePath;
 	}
+
 	public void setFilePath(String filePath) {
 		this.filePath = filePath;
 	}
+
 	public String getFileUrl() {
 		return fileUrl;
 	}
+
 	public void setFileUrl(String fileUrl) {
 		this.fileUrl = fileUrl;
 	}
+
 	public Long getParentId() {
 		return parentId;
 	}
+
 	public void setParentId(Long parentId) {
 		this.parentId = parentId;
 	}
+
 	public Date getCreationTime() {
 		return creationTime;
 	}
+
 	public void setCreationTime(Date creationTime) {
 		this.creationTime = creationTime;
 	}

+ 66 - 0
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/bean/SystemPropertyDomain.java

@@ -0,0 +1,66 @@
+package cn.com.qmth.examcloud.core.basic.api.controller.bean;
+
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.validation.constraints.NotNull;
+
+import cn.com.qmth.examcloud.api.commons.enums.BasicDataType;
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 系统参数信息
+ */
+public class SystemPropertyDomain implements JsonSerializable {
+	private static final long serialVersionUID = 4454755569906692085L;
+
+	@NotNull(message = "参数名称不能为空")
+	@ApiModelProperty(value = "参数名称")
+	private String propKey;
+
+	@NotNull(message = "参数描述不能为空")
+	@ApiModelProperty(value = "参数描述")
+	private String description;
+
+	@NotNull(message = "参数类型不能为空")
+	@ApiModelProperty(value = "参数类型")
+
+	@Enumerated(EnumType.STRING)
+	private BasicDataType propValueType;
+
+	@NotNull(message = "参数值不能为空")
+	@ApiModelProperty(value = "参数值")
+	private String propValue;
+
+	public String getPropKey() {
+		return propKey;
+	}
+
+	public void setPropKey(String propKey) {
+		this.propKey = propKey;
+	}
+
+	public String getDescription() {
+		return description;
+	}
+
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
+	public BasicDataType getPropValueType() {
+		return propValueType;
+	}
+
+	public void setPropValueType(BasicDataType propValueType) {
+		this.propValueType = propValueType;
+	}
+
+	public String getPropValue() {
+		return propValue;
+	}
+
+	public void setPropValue(String propValue) {
+		this.propValue = propValue;
+	}
+}

+ 29 - 0
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/UniqueRuleHolder.java

@@ -0,0 +1,29 @@
+package cn.com.qmth.examcloud.core.basic.dao;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+
+import cn.com.qmth.examcloud.web.jpa.UniqueRule;
+
+/**
+ * 状态码范围: 111XXX
+ *
+ * @author WANGWEI
+ * @date 2019年3月8日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
+public class UniqueRuleHolder {
+
+	private static final List<UniqueRule> LIST = Lists.newArrayList();
+
+	public static List<UniqueRule> getUniqueRuleList() {
+		return LIST;
+	}
+
+	static {
+		// ResourceEntity
+		LIST.add(new UniqueRule("IDX_B_RESOURCE_000002", "111001", "路径已存在"));
+	}
+
+}

+ 19 - 0
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/ResourceEntity.java

@@ -23,55 +23,74 @@ public class ResourceEntity extends JpaEntity {
 
 	@Column(nullable = false)
 	private Long rootOrgId;
+
 	@Column(nullable = false)
 	private String name;
+
 	@Column(nullable = false)
 	private Boolean isFile;
+
 	@Column(nullable = true)
 	private String suffix;
+
 	@Column(nullable = false)
 	private String filePath;
+
 	@Column(nullable = true)
 	private Long parentId;
+
 	public Long getId() {
 		return id;
 	}
+
 	public void setId(Long id) {
 		this.id = id;
 	}
+
 	public Long getRootOrgId() {
 		return rootOrgId;
 	}
+
 	public void setRootOrgId(Long rootOrgId) {
 		this.rootOrgId = rootOrgId;
 	}
+
 	public String getName() {
 		return name;
 	}
+
 	public void setName(String name) {
 		this.name = name;
 	}
+
 	public Boolean getIsFile() {
 		return isFile;
 	}
+
 	public void setIsFile(Boolean isFile) {
 		this.isFile = isFile;
 	}
+
 	public String getSuffix() {
 		return suffix;
 	}
+
 	public void setSuffix(String suffix) {
 		this.suffix = suffix;
 	}
+
 	public String getFilePath() {
 		return filePath;
 	}
+
 	public void setFilePath(String filePath) {
 		this.filePath = filePath;
 	}
+
 	public Long getParentId() {
 		return parentId;
 	}
+
 	public void setParentId(Long parentId) {
 		this.parentId = parentId;
 	}

+ 27 - 3
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/bean/ResourceInfo.java

@@ -6,70 +6,94 @@ import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
 
 public class ResourceInfo implements JsonSerializable {
 
-	/**
-	 * 
-	 */
 	private static final long serialVersionUID = 5355007419690855633L;
+
 	private Long id;
+
 	private Long rootOrgId;
+
 	private String name;
+
 	private Boolean isFile;
+
 	private String suffix;
+
 	private String filePath;
+
 	private String fileUrl;
+
 	private Long parentId;
+
 	private Date creationTime;
+
 	public Long getId() {
 		return id;
 	}
+
 	public void setId(Long id) {
 		this.id = id;
 	}
+
 	public Long getRootOrgId() {
 		return rootOrgId;
 	}
+
 	public void setRootOrgId(Long rootOrgId) {
 		this.rootOrgId = rootOrgId;
 	}
+
 	public String getName() {
 		return name;
 	}
+
 	public void setName(String name) {
 		this.name = name;
 	}
+
 	public Boolean getIsFile() {
 		return isFile;
 	}
+
 	public void setIsFile(Boolean isFile) {
 		this.isFile = isFile;
 	}
+
 	public String getSuffix() {
 		return suffix;
 	}
+
 	public void setSuffix(String suffix) {
 		this.suffix = suffix;
 	}
+
 	public String getFilePath() {
 		return filePath;
 	}
+
 	public void setFilePath(String filePath) {
 		this.filePath = filePath;
 	}
+
 	public String getFileUrl() {
 		return fileUrl;
 	}
+
 	public void setFileUrl(String fileUrl) {
 		this.fileUrl = fileUrl;
 	}
+
 	public Long getParentId() {
 		return parentId;
 	}
+
 	public void setParentId(Long parentId) {
 		this.parentId = parentId;
 	}
+
 	public Date getCreationTime() {
 		return creationTime;
 	}
+
 	public void setCreationTime(Date creationTime) {
 		this.creationTime = creationTime;
 	}

+ 31 - 44
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/bean/SystemPropertyInfo.java

@@ -2,64 +2,51 @@ package cn.com.qmth.examcloud.core.basic.service.bean;
 
 import cn.com.qmth.examcloud.api.commons.enums.BasicDataType;
 import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
-import io.swagger.annotations.ApiModelProperty;
-
-import javax.persistence.Column;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.Id;
-import javax.validation.constraints.NotNull;
 
 /**
  * 系统参数信息
  */
 public class SystemPropertyInfo implements JsonSerializable {
-    @NotNull(message = "参数名称不能为空")
-    @ApiModelProperty(value = "参数名称")
-    private String propKey;
 
-    @NotNull(message = "参数描述不能为空")
-    @ApiModelProperty(value = "参数描述")
-    private String description;
+	private static final long serialVersionUID = 4454755569906692085L;
+
+	private String propKey;
+
+	private String description;
 
-    @NotNull(message = "参数类型不能为空")
-    @ApiModelProperty(value = "参数类型")
-    @Enumerated(EnumType.STRING)
-    private BasicDataType propValueType;
+	private BasicDataType propValueType;
 
-    @NotNull(message = "参数值不能为空")
-    @ApiModelProperty(value = "参数值")
-    private String propValue;
+	private String propValue;
 
-    public String getPropKey() {
-        return propKey;
-    }
+	public String getPropKey() {
+		return propKey;
+	}
 
-    public void setPropKey(String propKey) {
-        this.propKey = propKey;
-    }
+	public void setPropKey(String propKey) {
+		this.propKey = propKey;
+	}
 
-    public String getDescription() {
-        return description;
-    }
+	public String getDescription() {
+		return description;
+	}
 
-    public void setDescription(String description) {
-        this.description = description;
-    }
+	public void setDescription(String description) {
+		this.description = description;
+	}
 
-    public BasicDataType getPropValueType() {
-        return propValueType;
-    }
+	public BasicDataType getPropValueType() {
+		return propValueType;
+	}
 
-    public void setPropValueType(BasicDataType propValueType) {
-        this.propValueType = propValueType;
-    }
+	public void setPropValueType(BasicDataType propValueType) {
+		this.propValueType = propValueType;
+	}
 
-    public String getPropValue() {
-        return propValue;
-    }
+	public String getPropValue() {
+		return propValue;
+	}
 
-    public void setPropValue(String propValue) {
-        this.propValue = propValue;
-    }
+	public void setPropValue(String propValue) {
+		this.propValue = propValue;
+	}
 }

+ 44 - 42
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/ResourceServiceImpl.java

@@ -8,7 +8,6 @@ import java.util.Optional;
 
 import org.apache.commons.fileupload.disk.DiskFileItem;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.dao.DataIntegrityViolationException;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.commons.CommonsMultipartFile;
@@ -24,82 +23,85 @@ import cn.com.qmth.examcloud.exchange.inner.api.request.PutFileReq;
 
 @Service
 public class ResourceServiceImpl implements ResourceService {
-	private static final String fileRootPath="/net_disk";
-	private static final String filePathSeparate="/";
+
+	private static final String FILE_ROOT_PATH = "/net_disk";
+
+	private static final String FILE_PATH_SEPARATE = "/";
+
 	@Autowired
 	ResourceRepo resourceRepo;
+
 	@Autowired
 	UpyunCloudService upyunCloudService;
+
 	@Override
 	public void addDir(ResourceInfo info) {
-		ResourceEntity e=new ResourceEntity();
+
+		ResourceEntity e = new ResourceEntity();
 		e.setName(info.getName());
 		e.setRootOrgId(info.getRootOrgId());
 		e.setIsFile(false);
-		if(info.getParentId()==null||info.getParentId().longValue()==-1) {
+		if (info.getParentId() == null) {
 			e.setParentId(null);
-			e.setFilePath(fileRootPath+filePathSeparate+info.getRootOrgId()+filePathSeparate+info.getName());
-		}else {
+			e.setFilePath(FILE_ROOT_PATH + FILE_PATH_SEPARATE + info.getRootOrgId()
+					+ FILE_PATH_SEPARATE + info.getName());
+		} else {
 			e.setParentId(info.getParentId());
-			Optional<ResourceEntity>  op=resourceRepo.findById(info.getParentId());
-			if(op.isPresent()) {
-				ResourceEntity pe=op.get();
-				e.setFilePath(pe.getFilePath()+filePathSeparate+info.getName());
-			}else {
+			Optional<ResourceEntity> op = resourceRepo.findById(info.getParentId());
+			if (op.isPresent()) {
+				ResourceEntity pe = op.get();
+				e.setFilePath(pe.getFilePath() + FILE_PATH_SEPARATE + info.getName());
+			} else {
 				throw new StatusException("100000", "上级目录不存在");
 			}
 		}
-		try {
-			resourceRepo.save(e);
-		} catch (DataIntegrityViolationException e1) {
-			if(e1.getMessage().contains("IDX_B_RESOURCE_000002")) {
-				throw new StatusException("100001", "目录已存在");
-			}else {
-				throw e1;
-			}
-		}
+		resourceRepo.saveAndFlush(e);
 	}
+
 	@Override
 	public void addFile(Long rootOrgId, Long parentId, MultipartFile dataFile) {
-		ResourceEntity e=new ResourceEntity();
-		String fileName=dataFile.getOriginalFilename();
+
+		ResourceEntity e = new ResourceEntity();
+		String fileName = dataFile.getOriginalFilename();
 		e.setName(fileName);
 		e.setRootOrgId(rootOrgId);
 		e.setIsFile(true);
-        String suffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
-        e.setSuffix(suffix);
-		if(parentId==null||parentId.longValue()==-1) {
+		String suffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
+		e.setSuffix(suffix);
+		if (parentId == null || parentId.longValue() == -1) {
 			e.setParentId(null);
-			e.setFilePath(fileRootPath+filePathSeparate+rootOrgId+filePathSeparate+fileName);
-		}else {
+			e.setFilePath(FILE_ROOT_PATH + FILE_PATH_SEPARATE + rootOrgId + FILE_PATH_SEPARATE
+					+ fileName);
+		} else {
 			e.setParentId(parentId);
-			Optional<ResourceEntity>  op=resourceRepo.findById(parentId);
-			if(op.isPresent()) {
-				ResourceEntity pe=op.get();
-				e.setFilePath(pe.getFilePath()+filePathSeparate+fileName);
-			}else {
+			Optional<ResourceEntity> op = resourceRepo.findById(parentId);
+			if (op.isPresent()) {
+				ResourceEntity pe = op.get();
+				e.setFilePath(pe.getFilePath() + FILE_PATH_SEPARATE + fileName);
+			} else {
 				throw new StatusException("100020", "上级目录不存在");
 			}
 		}
-		ResourceEntity olde=resourceRepo.findByRootOrgIdAndFilePath(rootOrgId, e.getFilePath());
-		if(olde!=null) {
+		ResourceEntity olde = resourceRepo.findByRootOrgIdAndFilePath(rootOrgId, e.getFilePath());
+		if (olde != null) {
 			olde.setUpdateTime(new Date());
 			resourceRepo.save(olde);
-		}else {
+		} else {
 			resourceRepo.save(e);
 		}
-		PutFileReq req=new PutFileReq();
-		List<FormFilePart> formFilePartList =new ArrayList<FormFilePart>();
-        CommonsMultipartFile cf= (CommonsMultipartFile)dataFile; 
-        DiskFileItem fi = (DiskFileItem)cf.getFileItem(); 
+		PutFileReq req = new PutFileReq();
+		List<FormFilePart> formFilePartList = new ArrayList<FormFilePart>();
+		CommonsMultipartFile cf = (CommonsMultipartFile) dataFile;
+		DiskFileItem fi = (DiskFileItem) cf.getFileItem();
 
-        File f = fi.getStoreLocation();
+		File f = fi.getStoreLocation();
 		FormFilePart part = new FormFilePart("file", fileName, f);
 		formFilePartList.add(part);
 
 		req.setFormFilePartList(formFilePartList);
 		req.setSiteId("netDisk");
-		String relativePath=e.getFilePath().replaceFirst(fileRootPath, "").replaceFirst(filePathSeparate, "");
+		String relativePath = e.getFilePath().replaceFirst(FILE_ROOT_PATH, "")
+				.replaceFirst(FILE_PATH_SEPARATE, "");
 		req.setRelativePath(relativePath);
 		upyunCloudService.putFile(req);
 	}

+ 26 - 14
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/SystemPropertyServiceImpl.java

@@ -1,6 +1,5 @@
 package cn.com.qmth.examcloud.core.basic.service.impl;
 
-import cn.com.qmth.examcloud.core.basic.service.bean.SystemPropertyInfo;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -12,6 +11,7 @@ import cn.com.qmth.examcloud.commons.util.DateUtil.DatePatterns;
 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.cache.bean.SysPropertyCacheBean;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
@@ -38,7 +38,8 @@ public class SystemPropertyServiceImpl implements SystemPropertyService {
 			throw new StatusException("350001", "key is blank");
 		}
 
-		SystemPropertyEntity sysConf = GlobalHelper.getEntity(systemPropertyRepo, key, SystemPropertyEntity.class);
+		SystemPropertyEntity sysConf = GlobalHelper.getEntity(systemPropertyRepo, key,
+				SystemPropertyEntity.class);
 		if (null == sysConf) {
 			throw new StatusException("350002", "key is wrong");
 		}
@@ -63,7 +64,8 @@ public class SystemPropertyServiceImpl implements SystemPropertyService {
 		} else if (dataType.equals(BasicDataType.DATE)) {
 			try {
 				sysConf.setPropValue(
-						DateUtil.format(DateUtil.parse(value, DatePatterns.CHINA_DEFAULT), DatePatterns.CHINA_DEFAULT));
+						DateUtil.format(DateUtil.parse(value, DatePatterns.CHINA_DEFAULT),
+								DatePatterns.CHINA_DEFAULT));
 			} catch (Exception e) {
 				throw new StatusException("350002", "value is wrong");
 			}
@@ -87,28 +89,38 @@ public class SystemPropertyServiceImpl implements SystemPropertyService {
 
 	@Override
 	public void addSysProp(SystemPropertyInfo info) {
-		SystemPropertyEntity sysPropEntity = GlobalHelper.getEntity(systemPropertyRepo, info.getPropKey(), SystemPropertyEntity.class);
-		if (null!=sysPropEntity){
-			throw new StatusException("70001","参数名称已存在");
+
+		SystemPropertyEntity sysPropEntity = GlobalHelper.getEntity(systemPropertyRepo,
+				info.getPropKey(), SystemPropertyEntity.class);
+		if (null != sysPropEntity) {
+			throw new StatusException("70001", "参数名称已存在");
 		}
-		sysPropEntity= new SystemPropertyEntity();
+		sysPropEntity = new SystemPropertyEntity();
 		sysPropEntity.setPropKey(info.getPropKey());
 		sysPropEntity.setPropValueType(info.getPropValueType());
-		sysPropEntity.setPropValue(info.getPropValue());
+		sysPropEntity.setPropValue(null);
 		sysPropEntity.setDescription(info.getDescription());
-		systemPropertyRepo.save(sysPropEntity);
+
+		SystemPropertyEntity saved = systemPropertyRepo.save(sysPropEntity);
+		set(info.getPropKey(), info.getPropValue());
+		systemPropertyCache.refresh(saved.getPropKey());
 	}
 
 	@Override
 	public void updateSysProp(SystemPropertyInfo info) {
-		SystemPropertyEntity sysPropEntity = GlobalHelper.getEntity(systemPropertyRepo, info.getPropKey(), SystemPropertyEntity.class);
-		if (null==sysPropEntity){
-			throw new StatusException("70001","参数名称不存在");
+
+		SystemPropertyEntity sysPropEntity = GlobalHelper.getEntity(systemPropertyRepo,
+				info.getPropKey(), SystemPropertyEntity.class);
+		if (null == sysPropEntity) {
+			throw new StatusException("70001", "参数名称不存在");
 		}
 		sysPropEntity.setPropValueType(info.getPropValueType());
-		sysPropEntity.setPropValue(info.getPropValue());
+		sysPropEntity.setPropValue(null);
 		sysPropEntity.setDescription(info.getDescription());
-		systemPropertyRepo.save(sysPropEntity);
+
+		SystemPropertyEntity saved = systemPropertyRepo.save(sysPropEntity);
+		set(info.getPropKey(), info.getPropValue());
+		systemPropertyCache.refresh(saved.getPropKey());
 	}
 
 }

+ 3 - 0
examcloud-core-basic-starter/src/main/java/cn/com/qmth/examcloud/core/basic/starter/CoreBasicApp.java

@@ -16,9 +16,11 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 import org.springframework.web.multipart.MultipartResolver;
 import org.springframework.web.multipart.commons.CommonsMultipartResolver;
 
+import cn.com.qmth.examcloud.core.basic.dao.UniqueRuleHolder;
 import cn.com.qmth.examcloud.core.basic.dao.enums.OrgProperty;
 import cn.com.qmth.examcloud.core.basic.service.cache.AppCache;
 import cn.com.qmth.examcloud.web.bootstrap.AppBootstrap;
+import cn.com.qmth.examcloud.web.jpa.DataIntegrityViolationTransverter;
 import cn.com.qmth.examcloud.web.support.SpringContextHolder;
 
 @SpringBootApplication
@@ -41,6 +43,7 @@ public class CoreBasicApp {
 		System.setProperty("hibernate.dialect.storage_engine", "innodb");
 
 		OrgProperty.init();
+		DataIntegrityViolationTransverter.setUniqueRules(UniqueRuleHolder.getUniqueRuleList());
 	}
 
 	/**