WANG 6 éve
szülő
commit
42e8553f81

+ 21 - 20
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/SysConfigEntity.java

@@ -5,10 +5,9 @@ import javax.persistence.Entity;
 import javax.persistence.EnumType;
 import javax.persistence.Enumerated;
 import javax.persistence.Id;
-import javax.persistence.Lob;
 import javax.persistence.Table;
 
-import cn.com.qmth.examcloud.commons.helpers.DataType;
+import cn.com.qmth.examcloud.api.commons.enums.BasicDataType;
 import cn.com.qmth.examcloud.web.jpa.JpaEntity;
 
 /**
@@ -19,29 +18,31 @@ import cn.com.qmth.examcloud.web.jpa.JpaEntity;
  * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
  */
 @Entity
-@Table(name = "EC_B_SYS_CONF")
+@Table(name = "EC_B_SYS_CONFIG")
 public class SysConfigEntity extends JpaEntity {
 
 	private static final long serialVersionUID = -3688247462533274177L;
 
 	@Id
-	private String propertyKey;
+	@Column(nullable = false, length = 200)
+	private String propKey;
 
+	@Column(nullable = false, length = 200)
 	private String description;
 
-	@Enumerated(EnumType.STRING)
 	@Column(nullable = false)
-	private DataType dataType;
+	@Enumerated(EnumType.STRING)
+	private BasicDataType propValueType;
 
-	@Lob
-	private String value;
+	@Column(nullable = false, length = 1000)
+	private String propValue;
 
-	public String getPropertyKey() {
-		return propertyKey;
+	public String getPropKey() {
+		return propKey;
 	}
 
-	public void setPropertyKey(String propertyKey) {
-		this.propertyKey = propertyKey;
+	public void setPropKey(String propKey) {
+		this.propKey = propKey;
 	}
 
 	public String getDescription() {
@@ -52,20 +53,20 @@ public class SysConfigEntity extends JpaEntity {
 		this.description = description;
 	}
 
-	public DataType getDataType() {
-		return dataType;
+	public BasicDataType getPropValueType() {
+		return propValueType;
 	}
 
-	public void setDataType(DataType dataType) {
-		this.dataType = dataType;
+	public void setPropValueType(BasicDataType propValueType) {
+		this.propValueType = propValueType;
 	}
 
-	public String getValue() {
-		return value;
+	public String getPropValue() {
+		return propValue;
 	}
 
-	public void setValue(String value) {
-		this.value = value;
+	public void setPropValue(String propValue) {
+		this.propValue = propValue;
 	}
 
 }

+ 23 - 22
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/SysConfigServiceImpl.java

@@ -4,8 +4,8 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import cn.com.qmth.examcloud.api.commons.enums.BasicDataType;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
-import cn.com.qmth.examcloud.commons.helpers.DataType;
 import cn.com.qmth.examcloud.commons.util.DateUtil;
 import cn.com.qmth.examcloud.commons.util.DateUtil.DatePatterns;
 import cn.com.qmth.examcloud.core.basic.dao.SysConfigRepo;
@@ -35,36 +35,37 @@ public class SysConfigServiceImpl implements SysConfigService {
 		if (null == sysConf) {
 			throw new StatusException("350002", "key is wrong");
 		}
-		DataType dataType = sysConf.getDataType();
+		BasicDataType dataType = sysConf.getPropValueType();
 
 		if (StringUtils.isBlank(value)) {
-			sysConf.setValue(null);
-		} else if (dataType.equals(DataType.STRING)) {
-			sysConf.setValue(value);
-		} else if (dataType.equals(DataType.LONG)) {
+			sysConf.setPropValue(null);
+		} else if (dataType.equals(BasicDataType.STRING)) {
+			sysConf.setPropValue(value);
+		} else if (dataType.equals(BasicDataType.LONG)) {
 			try {
-				sysConf.setValue(String.valueOf(Long.parseLong(value)));
+				sysConf.setPropValue(String.valueOf(Long.parseLong(value)));
 			} catch (NumberFormatException e) {
 				throw new StatusException("350002", "value is wrong");
 			}
-		} else if (dataType.equals(DataType.INTEGER)) {
+		} else if (dataType.equals(BasicDataType.INTEGER)) {
 			try {
-				sysConf.setValue(String.valueOf(Integer.parseInt(value)));
+				sysConf.setPropValue(String.valueOf(Integer.parseInt(value)));
 			} catch (NumberFormatException e) {
 				throw new StatusException("350002", "value is wrong");
 			}
-		} else if (dataType.equals(DataType.DATE)) {
+		} else if (dataType.equals(BasicDataType.DATE)) {
 			try {
-				sysConf.setValue(DateUtil.format(DateUtil.parse(value, DatePatterns.CHINA_DEFAULT),
-						DatePatterns.CHINA_DEFAULT));
+				sysConf.setPropValue(
+						DateUtil.format(DateUtil.parse(value, DatePatterns.CHINA_DEFAULT),
+								DatePatterns.CHINA_DEFAULT));
 			} catch (Exception e) {
 				throw new StatusException("350002", "value is wrong");
 			}
-		} else if (dataType.equals(DataType.BOOLEAN)) {
+		} else if (dataType.equals(BasicDataType.BOOLEAN)) {
 			if ("true".equals(value)) {
-				sysConf.setValue(value);
+				sysConf.setPropValue(value);
 			} else if ("false".equals(value)) {
-				sysConf.setValue(value);
+				sysConf.setPropValue(value);
 			} else {
 				throw new StatusException("350002", "value is wrong");
 			}
@@ -83,32 +84,32 @@ public class SysConfigServiceImpl implements SysConfigService {
 			throw new StatusException("350002", "key is wrong");
 		}
 
-		String value = sysConf.getValue();
-		DataType dataType = sysConf.getDataType();
+		String value = sysConf.getPropValue();
+		BasicDataType dataType = sysConf.getPropValueType();
 
 		if (StringUtils.isBlank(value)) {
 			return null;
-		} else if (dataType.equals(DataType.STRING)) {
+		} else if (dataType.equals(BasicDataType.STRING)) {
 			return value;
-		} else if (dataType.equals(DataType.LONG)) {
+		} else if (dataType.equals(BasicDataType.LONG)) {
 			try {
 				return Long.parseLong(value);
 			} catch (NumberFormatException e) {
 				throw new StatusException("350002", "value is wrong");
 			}
-		} else if (dataType.equals(DataType.INTEGER)) {
+		} else if (dataType.equals(BasicDataType.INTEGER)) {
 			try {
 				return Integer.parseInt(value);
 			} catch (NumberFormatException e) {
 				throw new StatusException("350002", "value is wrong");
 			}
-		} else if (dataType.equals(DataType.DATE)) {
+		} else if (dataType.equals(BasicDataType.DATE)) {
 			try {
 				return DateUtil.parse(value, DatePatterns.CHINA_DEFAULT);
 			} catch (Exception e) {
 				throw new StatusException("350002", "value is wrong");
 			}
-		} else if (dataType.equals(DataType.BOOLEAN)) {
+		} else if (dataType.equals(BasicDataType.BOOLEAN)) {
 			if ("true".equals(value)) {
 				return true;
 			} else if ("false".equals(value)) {