Merge branch 'dev' of https://github.com/metersphere/metersphere into dev
This commit is contained in:
commit
0923ed43de
|
@ -1,11 +1,9 @@
|
|||
package io.metersphere.controller;
|
||||
|
||||
import io.metersphere.base.domain.SystemParameter;
|
||||
import io.metersphere.commons.constants.ParamConstants;
|
||||
import io.metersphere.service.SystemParameterService;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
|
@ -27,4 +25,14 @@ public class SystemParameterController {
|
|||
SystemParameterService.testConnection(hashMap);
|
||||
}
|
||||
|
||||
@GetMapping("/version")
|
||||
public String getVersion() {
|
||||
return SystemParameterService.getVersion();
|
||||
}
|
||||
|
||||
@GetMapping("/mail/info")
|
||||
public Object mailInfo() {
|
||||
return SystemParameterService.mailInfo(ParamConstants.Classify.MAIL.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,9 +15,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import javax.mail.MessagingException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@Service
|
||||
|
@ -83,7 +81,35 @@ public class SystemParameterService {
|
|||
} catch (MessagingException e) {
|
||||
MSException.throwException(Translator.get("connection_failed"));
|
||||
}
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return System.getenv("MS_VERSION");
|
||||
}
|
||||
|
||||
public Object mailInfo(String type) {
|
||||
List<SystemParameter> paramList = this.getParamList(type);
|
||||
if (CollectionUtils.isEmpty(paramList)) {
|
||||
paramList = new ArrayList<>();
|
||||
ParamConstants.MAIL[] values = ParamConstants.MAIL.values();
|
||||
for (ParamConstants.MAIL value : values) {
|
||||
SystemParameter systemParameter = new SystemParameter();
|
||||
if (value.equals(ParamConstants.MAIL.PASSWORD)) {
|
||||
systemParameter.setType(ParamConstants.Type.PASSWORD.getValue());
|
||||
} else {
|
||||
systemParameter.setType(ParamConstants.Type.TEXT.getValue());
|
||||
}
|
||||
systemParameter.setParamKey(value.getKey());
|
||||
systemParameter.setSort(value.getValue());
|
||||
paramList.add(systemParameter);
|
||||
}
|
||||
} else {
|
||||
paramList.stream().filter(param -> param.getParamKey().equals(ParamConstants.MAIL.PASSWORD.getKey())).forEach(param -> {
|
||||
String string = EncryptUtils.aesDecrypt(param.getParamValue()).toString();
|
||||
param.setParamValue(string);
|
||||
});
|
||||
}
|
||||
paramList.sort(Comparator.comparingInt(SystemParameter::getSort));
|
||||
return paramList;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue