Skip to content

Commit a087535

Browse files
committed
变更ApiBootLog所属位置,添加美化JSON工具类
1 parent f1e61db commit a087535

File tree

4 files changed

+159
-1
lines changed

4 files changed

+159
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright [2019] [恒宇少年 - 于起宇]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package org.minbox.framework.api.boot.plugin.logging.admin.event;
19+
20+
import lombok.Getter;
21+
import org.minbox.framework.api.boot.plugin.logging.ApiBootLogClientNotice;
22+
import org.springframework.context.ApplicationEvent;
23+
24+
/**
25+
* The time of publication after receiving the reported log information
26+
*
27+
* @author:恒宇少年 - 于起宇
28+
* <p>
29+
* DateTime:2019-07-22 15:08
30+
* Blog:http://blog.yuqiyu.com
31+
* WebSite:http://www.jianshu.com/u/092df3f77bca
32+
* Gitee:https://gitee.com/hengboy
33+
* GitHub:https://github.com/hengboy
34+
* @see org.minbox.framework.api.boot.plugin.logging.admin.endpoint.LoggingEndpoint
35+
*/
36+
@Getter
37+
public class ReportLogEvent extends ApplicationEvent {
38+
/**
39+
* ApiBoot Log Client Report Notice Object
40+
*/
41+
private ApiBootLogClientNotice logClientNotice;
42+
43+
public ReportLogEvent(Object source, ApiBootLogClientNotice logClientNotice) {
44+
super(source);
45+
this.logClientNotice = logClientNotice;
46+
}
47+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import lombok.Data;
2121

22+
import java.io.Serializable;
2223
import java.util.Map;
2324

2425
/**
@@ -33,7 +34,7 @@
3334
* GitHub:https://github.com/hengboy
3435
*/
3536
@Data
36-
public class ApiBootLog {
37+
public class ApiBootLog implements Serializable {
3738
/**
3839
* trace id
3940
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright [2019] [恒宇少年 - 于起宇]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package org.minbox.framework.api.boot.plugin.logging;
19+
20+
import lombok.Data;
21+
22+
/**
23+
* Report Request Log To Admin After Response Entity
24+
*
25+
* @author:恒宇少年 - 于起宇
26+
* <p>
27+
* DateTime:2019-07-19 18:14
28+
* Blog:http://blog.yuqiyu.com
29+
* WebSite:http://www.jianshu.com/u/092df3f77bca
30+
* Gitee:https://gitee.com/hengboy
31+
* GitHub:https://github.com/hengboy
32+
*/
33+
@Data
34+
public class ReportResponse {
35+
36+
public static final String SUCCESS = "SUCCESS";
37+
38+
public static final String ERROR = "ERROR";
39+
40+
private String status;
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright [2019] [恒宇少年 - 于起宇]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package org.minbox.framework.api.boot.plugin.tools;
19+
20+
import com.alibaba.fastjson.JSON;
21+
import com.alibaba.fastjson.JSONObject;
22+
import com.alibaba.fastjson.serializer.SerializerFeature;
23+
import org.springframework.util.ObjectUtils;
24+
25+
/**
26+
* json tools
27+
*
28+
* @author:恒宇少年 - 于起宇
29+
* <p>
30+
* DateTime:2019-07-19 14:39
31+
* Blog:http://blog.yuqiyu.com
32+
* WebSite:http://www.jianshu.com/u/092df3f77bca
33+
* Gitee:https://gitee.com/hengboy
34+
* GitHub:https://github.com/hengboy
35+
*/
36+
public class JsonTools {
37+
/**
38+
* beautify object to json
39+
*
40+
* @param object object
41+
* @return object json string
42+
*/
43+
public static String beautifyJson(Object object) {
44+
if (ObjectUtils.isEmpty(object)) {
45+
return null;
46+
}
47+
return JSON.toJSONString(object,
48+
SerializerFeature.PrettyFormat,
49+
SerializerFeature.SortField,
50+
SerializerFeature.MapSortField
51+
);
52+
}
53+
54+
/**
55+
* beautify string to json
56+
*
57+
* @param json json string
58+
* @return after beautify json
59+
*/
60+
public static String beautifyJson(String json) {
61+
if (ObjectUtils.isEmpty(json)) {
62+
return json;
63+
}
64+
return JSON.toJSONString(
65+
JSONObject.parse(json),
66+
SerializerFeature.PrettyFormat
67+
);
68+
}
69+
}

0 commit comments

Comments
 (0)