添加组织功能优化
parent
1eb27e961a
commit
0531af8389
@ -0,0 +1,62 @@
|
||||
package cn.estsh.i3plus.core.apiservice.controller.base;
|
||||
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
||||
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
||||
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
||||
import cn.estsh.impp.framework.boot.util.ResultBean;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.AbstractEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description :
|
||||
* @Reference :
|
||||
* @Author : wei.peng
|
||||
* @CreateDate : 2019-07-09 下午5:57
|
||||
* @Modify:
|
||||
**/
|
||||
@RestController
|
||||
@Api(description = "系统服务")
|
||||
@RequestMapping("/system")
|
||||
public class SystemController {
|
||||
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
|
||||
@GetMapping("/get-properties")
|
||||
@ApiOperation(value = "获取系统配置信息", notes = "获取系统配置信息")
|
||||
public ResultBean getProperties(){
|
||||
try {
|
||||
//条件验证
|
||||
String[] profiles = environment.getDefaultProfiles();
|
||||
Map<String, Object> map = new HashMap();
|
||||
for(Iterator it = ((AbstractEnvironment) environment).getPropertySources().iterator(); it.hasNext(); ) {
|
||||
PropertySource propertySource = (PropertySource) it.next();
|
||||
if (propertySource instanceof MapPropertySource) {
|
||||
MapPropertySource source = (MapPropertySource) propertySource;
|
||||
for (String key : source.getPropertyNames()) {
|
||||
map.put(key,source.getProperty(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ResultBean.success("操作成功")
|
||||
.setResultMap(map)
|
||||
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
||||
} catch (ImppBusiException busExcep) {
|
||||
return ResultBean.fail(busExcep);
|
||||
} catch (Exception e) {
|
||||
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue