mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-11-30 10:58:14 +08:00
引入 jackson
This commit is contained in:
parent
ea379f38a9
commit
28882f7256
@ -6,7 +6,7 @@
|
||||
|
||||
1. 【Agent】 nginx管理支持自定义编译运行,管理方式变更
|
||||
2. 【Server】 监控通知新增企业微信(感谢@TinyBao。)
|
||||
3. 管理脚本支持自动识别环境变量和java路径
|
||||
3. 管理脚本支持自动识别环境变量和java路径(linux环境)
|
||||
4. 项目类型新增File(快速管理纯静态文件)
|
||||
|
||||
### 解决BUG、优化功能
|
||||
|
@ -0,0 +1,14 @@
|
||||
package io.jpom.controller.manage.jdk;
|
||||
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author bwcx_jzy
|
||||
* @date 2019/11/1
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/manage/jdk/")
|
||||
public class JdkListController extends BaseAgentController {
|
||||
}
|
@ -1,11 +1,19 @@
|
||||
package io.jpom;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.system.SystemUtil;
|
||||
import cn.jiangzeyin.common.ApplicationBuilder;
|
||||
import cn.jiangzeyin.common.validator.ParameterInterceptor;
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.jpom.common.JpomApplicationEvent;
|
||||
import io.jpom.common.JpomManifest;
|
||||
import io.jpom.common.Type;
|
||||
@ -13,6 +21,8 @@ import io.jpom.common.interceptor.PluginFeatureInterceptor;
|
||||
import io.jpom.plugin.PluginFactory;
|
||||
import io.jpom.util.CommandUtil;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
@ -58,6 +68,10 @@ public class JpomApplication extends ApplicationBuilder {
|
||||
|
||||
addHttpMessageConverter(new StringHttpMessageConverter(CharsetUtil.CHARSET_UTF_8));
|
||||
|
||||
//
|
||||
ObjectMapper build = createJackson();
|
||||
addHttpMessageConverter(new MappingJackson2HttpMessageConverter(build));
|
||||
|
||||
// 参数拦截器
|
||||
addInterceptor(ParameterInterceptor.class);
|
||||
addInterceptor(PluginFeatureInterceptor.class);
|
||||
@ -67,6 +81,31 @@ public class JpomApplication extends ApplicationBuilder {
|
||||
this.application().addInitializers(new PluginFactory());
|
||||
}
|
||||
|
||||
/**
|
||||
* jackson 配置
|
||||
*
|
||||
* @return mapper
|
||||
*/
|
||||
private static ObjectMapper createJackson() {
|
||||
Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder = Jackson2ObjectMapperBuilder.json();
|
||||
jackson2ObjectMapperBuilder.simpleDateFormat(DatePattern.NORM_DATETIME_PATTERN);
|
||||
ObjectMapper build = jackson2ObjectMapperBuilder.build();
|
||||
// 忽略空
|
||||
build.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
// 驼峰转下划线
|
||||
// build.setPropertyNamingStrategy(new PropertyNamingStrategy.SnakeCaseStrategy());
|
||||
// long to String
|
||||
SimpleModule simpleModule = new SimpleModule();
|
||||
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
|
||||
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
|
||||
build.registerModule(simpleModule);
|
||||
//
|
||||
build.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
// build.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(), ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.WRAPPER_ARRAY);
|
||||
|
||||
return build;
|
||||
}
|
||||
|
||||
private void checkEvent(String[] args) throws Exception {
|
||||
new JpomClose().main(args);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class SshController extends BaseServerController {
|
||||
@RequestMapping(value = "list_data.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
@ResponseBody
|
||||
@Feature(method = MethodFeature.LIST)
|
||||
public String listData() {
|
||||
public JsonMessage<List<SshModel>> listData() {
|
||||
List<SshModel> list = sshService.list();
|
||||
if (list != null) {
|
||||
List<NodeModel> list1 = nodeService.list();
|
||||
@ -73,7 +73,7 @@ public class SshController extends BaseServerController {
|
||||
sshModel.setNodeModel(nodeModel);
|
||||
});
|
||||
}
|
||||
return JsonMessage.getString(200, "", list);
|
||||
return new JsonMessage<>(200, "", list);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "save.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
|
Loading…
Reference in New Issue
Block a user