|
@@ -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)) {
|