Commit 2785fdd6c71cf300dade4d34a55dafcb0357d2ed
Merge remote-tracking branch 'origin/develop' into develop
Showing
26 changed files
with
1227 additions
and
5 deletions
src/main/java/com/huaheng/api/acs/controller/StateInfoUp.java
... | ... | @@ -2,6 +2,7 @@ package com.huaheng.api.acs.controller; |
2 | 2 | |
3 | 3 | import com.huaheng.api.acs.domain.StateInfoUploadModel; |
4 | 4 | import com.huaheng.api.acs.service.AcsService; |
5 | +import com.huaheng.framework.aspectj.lang.annotation.ApiLogger; | |
5 | 6 | import com.huaheng.framework.aspectj.lang.annotation.Log; |
6 | 7 | import com.huaheng.framework.aspectj.lang.constant.BusinessType; |
7 | 8 | import com.huaheng.framework.web.controller.BaseController; |
... | ... | @@ -28,6 +29,7 @@ public class StateInfoUp extends BaseController { |
28 | 29 | @PostMapping("/StateInfoUpload") |
29 | 30 | @ApiOperation("AGV 信息上传接口") |
30 | 31 | @ResponseBody |
32 | + @ApiLogger(apiName = "AGV 信息上传", from="ACS") | |
31 | 33 | public AjaxResult StateInfoUpload(@RequestBody StateInfoUploadModel model) |
32 | 34 | { |
33 | 35 | return acsService.StateInfoUpload(model); |
... | ... |
src/main/java/com/huaheng/api/acs/controller/TaskConfirm.java
... | ... | @@ -2,6 +2,7 @@ package com.huaheng.api.acs.controller; |
2 | 2 | |
3 | 3 | import com.huaheng.api.acs.domain.AgvTask; |
4 | 4 | import com.huaheng.api.acs.service.AcsService; |
5 | +import com.huaheng.framework.aspectj.lang.annotation.ApiLogger; | |
5 | 6 | import com.huaheng.framework.aspectj.lang.annotation.Log; |
6 | 7 | import com.huaheng.framework.aspectj.lang.constant.BusinessType; |
7 | 8 | import com.huaheng.framework.web.controller.BaseController; |
... | ... | @@ -28,6 +29,7 @@ public class TaskConfirm extends BaseController { |
28 | 29 | @PostMapping("/TaskConfirm") |
29 | 30 | @ApiOperation("AGV 任务回传接口") |
30 | 31 | @ResponseBody |
32 | + @ApiLogger(apiName = "AGV任务回传", from="ACS") | |
31 | 33 | public AjaxResult TaskConfirm(@RequestBody AgvTask model) |
32 | 34 | { |
33 | 35 | return acsService.TaskConfirm(model); |
... | ... |
src/main/java/com/huaheng/api/general/controller/AdjustApi.java
... | ... | @@ -5,6 +5,7 @@ import com.huaheng.api.general.domain.AdjustDomain; |
5 | 5 | import com.huaheng.api.general.domain.CycCountDomain; |
6 | 6 | import com.huaheng.api.general.service.AdjustService; |
7 | 7 | import com.huaheng.api.general.service.CycleCountService; |
8 | +import com.huaheng.framework.aspectj.lang.annotation.ApiLogger; | |
8 | 9 | import com.huaheng.framework.aspectj.lang.annotation.Log; |
9 | 10 | import com.huaheng.framework.aspectj.lang.constant.BusinessType; |
10 | 11 | import com.huaheng.framework.web.domain.AjaxResult; |
... | ... | @@ -30,6 +31,7 @@ public class AdjustApi { |
30 | 31 | @PostMapping("/adjust") |
31 | 32 | @ApiOperation("调整单添加公共接口") |
32 | 33 | @ResponseBody |
34 | + @ApiLogger(apiName = "添加调整单", from="ERP") | |
33 | 35 | public AjaxResult adjust(@RequestBody AdjustDomain adjustDomain) |
34 | 36 | { |
35 | 37 | AjaxResult ajaxResult = adjustService.insertAdjust(adjustDomain); |
... | ... |
src/main/java/com/huaheng/api/general/controller/BasicDataApi.java
1 | 1 | package com.huaheng.api.general.controller; |
2 | 2 | |
3 | 3 | import com.huaheng.api.general.service.BasicDataApiService; |
4 | +import com.huaheng.framework.aspectj.lang.annotation.ApiLogger; | |
4 | 5 | import com.huaheng.framework.aspectj.lang.annotation.Log; |
5 | 6 | import com.huaheng.framework.aspectj.lang.constant.BusinessType; |
6 | 7 | import com.huaheng.framework.web.controller.BaseController; |
... | ... | @@ -34,6 +35,7 @@ public class BasicDataApi extends BaseController { |
34 | 35 | @PostMapping("/addMaterial") |
35 | 36 | @ApiOperation("物料添加公共接口") |
36 | 37 | @ResponseBody |
38 | + @ApiLogger(apiName = "添加物料", from="ERP") | |
37 | 39 | public AjaxResult AddMaterialApi(@RequestBody Material material) |
38 | 40 | { |
39 | 41 | AjaxResult ajaxResult = basicDataApiService.material(material); |
... | ... | @@ -45,6 +47,7 @@ public class BasicDataApi extends BaseController { |
45 | 47 | @PostMapping("/queryMaterial") |
46 | 48 | @ApiOperation("物料查询公共接口") |
47 | 49 | @ResponseBody |
50 | + @ApiLogger(apiName = "查询物料", from="ERP") | |
48 | 51 | public AjaxResult QueryMaterialApi(@RequestBody Material material) |
49 | 52 | { |
50 | 53 | AjaxResult ajaxResult = basicDataApiService.queryMaterial(material); |
... | ... | @@ -58,6 +61,7 @@ public class BasicDataApi extends BaseController { |
58 | 61 | @PostMapping("/dictData") |
59 | 62 | @ApiOperation("字典添加公共接口") |
60 | 63 | @ResponseBody |
64 | + @ApiLogger(apiName = "添加字典", from="ERP") | |
61 | 65 | public AjaxResult UnitlApi(@RequestBody DictData dictData) |
62 | 66 | { |
63 | 67 | AjaxResult ajaxResult = basicDataApiService.dict(dictData); |
... | ... | @@ -72,6 +76,7 @@ public class BasicDataApi extends BaseController { |
72 | 76 | @PostMapping("/addWarehouse") |
73 | 77 | @ApiOperation("仓库添加公共接口") |
74 | 78 | @ResponseBody |
79 | + @ApiLogger(apiName = "添加仓库", from="ERP") | |
75 | 80 | public AjaxResult WarehouseApi(@RequestBody Warehouse warehouse) |
76 | 81 | { |
77 | 82 | AjaxResult ajaxResult = basicDataApiService.warehouse(warehouse); |
... | ... | @@ -85,6 +90,7 @@ public class BasicDataApi extends BaseController { |
85 | 90 | @PostMapping("/customer") |
86 | 91 | @ApiOperation("客户档案添加公共接口") |
87 | 92 | @ResponseBody |
93 | + @ApiLogger(apiName = "添加客户", from="ERP") | |
88 | 94 | public AjaxResult CustomerApi(@RequestBody Customer customer) |
89 | 95 | { |
90 | 96 | AjaxResult ajaxResult = basicDataApiService.customer(customer); |
... | ... | @@ -98,6 +104,7 @@ public class BasicDataApi extends BaseController { |
98 | 104 | @PostMapping("/dept") |
99 | 105 | @ApiOperation("部门档案添加公共接口") |
100 | 106 | @ResponseBody |
107 | + @ApiLogger(apiName = "添加部门", from="ERP") | |
101 | 108 | public AjaxResult DeptApi(@RequestBody Dept dept) |
102 | 109 | { |
103 | 110 | AjaxResult ajaxResult = basicDataApiService.dept(dept); |
... | ... | @@ -111,6 +118,7 @@ public class BasicDataApi extends BaseController { |
111 | 118 | @PostMapping("/user") |
112 | 119 | @ApiOperation("人员档案添加公共接口") |
113 | 120 | @ResponseBody |
121 | + @ApiLogger(apiName = "添加人员", from="ERP") | |
114 | 122 | public AjaxResult UserApi(@RequestBody User user) |
115 | 123 | { |
116 | 124 | AjaxResult ajaxResult = basicDataApiService.user(user); |
... | ... | @@ -122,6 +130,7 @@ public class BasicDataApi extends BaseController { |
122 | 130 | @PostMapping("/queryUserApi") |
123 | 131 | @ApiOperation("用户查询公共接口") |
124 | 132 | @ResponseBody |
133 | + @ApiLogger(apiName = "查询用户", from="ERP") | |
125 | 134 | public AjaxResult queryUserApi(@RequestBody User user) |
126 | 135 | { |
127 | 136 | AjaxResult ajaxResult = basicDataApiService.queryUser(user); |
... | ... | @@ -135,6 +144,7 @@ public class BasicDataApi extends BaseController { |
135 | 144 | @PostMapping("/containerCapacity") |
136 | 145 | @ApiOperation("容器容量添加公共接口") |
137 | 146 | @ResponseBody |
147 | + @ApiLogger(apiName = "添加容器", from="ERP") | |
138 | 148 | public AjaxResult containerCapacityApi(@RequestBody ContainerCapacity containerCapacity){ |
139 | 149 | AjaxResult ajaxResult = basicDataApiService.containerCapacity(containerCapacity); |
140 | 150 | return ajaxResult; |
... | ... | @@ -147,6 +157,7 @@ public class BasicDataApi extends BaseController { |
147 | 157 | @PostMapping("/supplier") |
148 | 158 | @ApiOperation("供应商档案添加公共接口") |
149 | 159 | @ResponseBody |
160 | + @ApiLogger(apiName = "添加供应商", from="ERP") | |
150 | 161 | public AjaxResult SupplierApi(@RequestBody Supplier supplier){ |
151 | 162 | AjaxResult ajaxResult = basicDataApiService.supplier(supplier); |
152 | 163 | return ajaxResult; |
... | ... | @@ -158,6 +169,7 @@ public class BasicDataApi extends BaseController { |
158 | 169 | @PostMapping("/queryInventoryApi") |
159 | 170 | @ApiOperation("库存查询公共接口") |
160 | 171 | @ResponseBody |
172 | + @ApiLogger(apiName = "查询库存", from="ERP") | |
161 | 173 | public AjaxResult queryInventoryApi(@RequestBody InventoryDetail inventoryDetail) |
162 | 174 | { |
163 | 175 | AjaxResult ajaxResult = basicDataApiService.queryInventoryApi(inventoryDetail); |
... | ... |
src/main/java/com/huaheng/api/general/controller/CycleCountApi.java
... | ... | @@ -5,6 +5,7 @@ import com.huaheng.api.general.domain.CycCountDomain; |
5 | 5 | import com.huaheng.api.general.domain.ReceiptDomain; |
6 | 6 | import com.huaheng.api.general.service.CycleCountService; |
7 | 7 | import com.huaheng.api.general.service.ReceiptApiService; |
8 | +import com.huaheng.framework.aspectj.lang.annotation.ApiLogger; | |
8 | 9 | import com.huaheng.framework.aspectj.lang.annotation.Log; |
9 | 10 | import com.huaheng.framework.aspectj.lang.constant.BusinessType; |
10 | 11 | import com.huaheng.framework.web.domain.AjaxResult; |
... | ... | @@ -32,6 +33,7 @@ public class CycleCountApi { |
32 | 33 | @PostMapping("/adjust") |
33 | 34 | @ApiOperation("盘点单添加公共接口") |
34 | 35 | @ResponseBody |
36 | + @ApiLogger(apiName = "添加盘点单", from="ERP") | |
35 | 37 | public AjaxResult cycleCount(@RequestBody CycCountDomain cycCountDomain) |
36 | 38 | { |
37 | 39 | AjaxResult ajaxResult = cycleCountService.insertCycleCount(cycCountDomain); |
... | ... |
src/main/java/com/huaheng/api/general/controller/ReceiptApi.java
... | ... | @@ -4,6 +4,7 @@ package com.huaheng.api.general.controller; |
4 | 4 | import com.huaheng.api.general.domain.ReceiptDomain; |
5 | 5 | import com.huaheng.api.general.service.ReceiptApiService; |
6 | 6 | import com.huaheng.common.utils.StringUtils; |
7 | +import com.huaheng.framework.aspectj.lang.annotation.ApiLogger; | |
7 | 8 | import com.huaheng.framework.aspectj.lang.annotation.Log; |
8 | 9 | import com.huaheng.framework.aspectj.lang.constant.BusinessType; |
9 | 10 | import com.huaheng.framework.web.domain.AjaxResult; |
... | ... | @@ -31,6 +32,7 @@ public class ReceiptApi { |
31 | 32 | @PostMapping("/receipt") |
32 | 33 | @ApiOperation("入库单添加公共接口") |
33 | 34 | @ResponseBody |
35 | + @ApiLogger(apiName = "添加入库单", from="ERP") | |
34 | 36 | public AjaxResult Receipt(@RequestBody ReceiptDomain receiptDomain) |
35 | 37 | { |
36 | 38 | AjaxResult ajaxResult = receiptApiService.receipt(receiptDomain); |
... | ... | @@ -44,6 +46,7 @@ public class ReceiptApi { |
44 | 46 | @Log(title = "入库-入库单 ",operating = "入库单删除", action = BusinessType.UPDATE) |
45 | 47 | @PostMapping("/remove") |
46 | 48 | @ResponseBody |
49 | + @ApiLogger(apiName = "取消入库单", from="ERP") | |
47 | 50 | public AjaxResult remove(@RequestBody Integer[] ids){ |
48 | 51 | if (StringUtils.isNull(ids)){ |
49 | 52 | return AjaxResult.error("id为空"); |
... | ... |
src/main/java/com/huaheng/api/general/controller/ReceiptController.java
... | ... | @@ -2,6 +2,7 @@ package com.huaheng.api.general.controller; |
2 | 2 | |
3 | 3 | import com.huaheng.api.general.domain.Receipt; |
4 | 4 | import com.huaheng.api.general.service.ReceiptService; |
5 | +import com.huaheng.framework.aspectj.lang.annotation.ApiLogger; | |
5 | 6 | import com.huaheng.framework.aspectj.lang.annotation.Log; |
6 | 7 | import com.huaheng.framework.aspectj.lang.constant.BusinessType; |
7 | 8 | import com.huaheng.framework.web.domain.AjaxResult; |
... | ... | @@ -30,6 +31,7 @@ public class ReceiptController { |
30 | 31 | @PostMapping("/insertReceipt") |
31 | 32 | @ApiOperation("入库单下发接口") |
32 | 33 | @ResponseBody |
34 | + @ApiLogger(apiName = "下发入库单", from="ERP") | |
33 | 35 | public AjaxResult MaterialApi(@RequestBody Receipt receipt) { |
34 | 36 | System.out.println("————————开始接收入库单——————————"); |
35 | 37 | System.out.println(receipt); |
... | ... |
src/main/java/com/huaheng/api/general/controller/ShipmentApi.java
... | ... | @@ -3,6 +3,7 @@ package com.huaheng.api.general.controller; |
3 | 3 | |
4 | 4 | import com.huaheng.api.general.domain.ShipmentDomain; |
5 | 5 | import com.huaheng.api.general.service.ShipmentApiService; |
6 | +import com.huaheng.framework.aspectj.lang.annotation.ApiLogger; | |
6 | 7 | import com.huaheng.framework.aspectj.lang.annotation.Log; |
7 | 8 | import com.huaheng.framework.aspectj.lang.constant.BusinessType; |
8 | 9 | import com.huaheng.framework.web.domain.AjaxResult; |
... | ... | @@ -27,6 +28,7 @@ public class ShipmentApi { |
27 | 28 | @PostMapping("/shipment") |
28 | 29 | @ApiOperation("出库单添加公共接口") |
29 | 30 | @ResponseBody |
31 | + @ApiLogger(apiName = "添加出库单", from="ERP") | |
30 | 32 | public AjaxResult Shipment(@RequestBody ShipmentDomain shipmentDomain) |
31 | 33 | { |
32 | 34 | AjaxResult ajaxResult = shipmentApiService.shipment(shipmentDomain); |
... | ... |
src/main/java/com/huaheng/api/wcs/controller/EmptyOutHandle.java
1 | 1 | package com.huaheng.api.wcs.controller; |
2 | 2 | |
3 | 3 | import com.huaheng.api.wcs.service.emptyOutHandle.EmptyOutHandleService; |
4 | +import com.huaheng.framework.aspectj.lang.annotation.ApiLogger; | |
4 | 5 | import com.huaheng.framework.aspectj.lang.annotation.Log; |
5 | 6 | import com.huaheng.framework.aspectj.lang.constant.BusinessType; |
6 | 7 | import com.huaheng.framework.web.controller.BaseController; |
... | ... | @@ -31,6 +32,7 @@ public class EmptyOutHandle extends BaseController { |
31 | 32 | @PostMapping("/EmptyOutHandle") |
32 | 33 | @ApiOperation("wcs空出处理") |
33 | 34 | @ResponseBody |
35 | + @ApiLogger(apiName = "空出处理", from="WCS") | |
34 | 36 | public AjaxResult EmptyOutHandle(String taskNo) |
35 | 37 | { |
36 | 38 | AjaxResult ajaxResult =emptyOutHandleService.EmptyOutHandle(taskNo) ; |
... | ... |
src/main/java/com/huaheng/api/wcs/controller/OverrideHandle.java
... | ... | @@ -2,6 +2,7 @@ package com.huaheng.api.wcs.controller; |
2 | 2 | |
3 | 3 | import com.huaheng.api.wcs.domain.TaskFinishDomain; |
4 | 4 | import com.huaheng.api.wcs.service.overrideHandle.OverrideHandleService; |
5 | +import com.huaheng.framework.aspectj.lang.annotation.ApiLogger; | |
5 | 6 | import com.huaheng.framework.aspectj.lang.annotation.Log; |
6 | 7 | import com.huaheng.framework.aspectj.lang.constant.BusinessType; |
7 | 8 | import com.huaheng.framework.web.controller.BaseController; |
... | ... | @@ -30,6 +31,7 @@ public class OverrideHandle extends BaseController { |
30 | 31 | @PostMapping("/ReenterHandle") |
31 | 32 | @ApiOperation("wcs重入处理") |
32 | 33 | @ResponseBody |
34 | + @ApiLogger(apiName = "重入处理", from="WCS") | |
33 | 35 | public AjaxResult ReenterHandle(@RequestBody TaskFinishDomain taskFinishDomain) { |
34 | 36 | return overrideHandleService.OverrideHandle(taskFinishDomain); |
35 | 37 | } |
... | ... |
src/main/java/com/huaheng/api/wcs/controller/TaskFinish.java
... | ... | @@ -3,6 +3,7 @@ package com.huaheng.api.wcs.controller; |
3 | 3 | import com.huaheng.api.wcs.domain.TaskFinishDomain; |
4 | 4 | import com.huaheng.api.wcs.domain.WcsTask; |
5 | 5 | import com.huaheng.api.wcs.service.taskFinish.TaskFinishService; |
6 | +import com.huaheng.framework.aspectj.lang.annotation.ApiLogger; | |
6 | 7 | import com.huaheng.framework.aspectj.lang.annotation.Log; |
7 | 8 | import com.huaheng.framework.aspectj.lang.constant.BusinessType; |
8 | 9 | import com.huaheng.framework.web.controller.BaseController; |
... | ... | @@ -31,6 +32,7 @@ public class TaskFinish extends BaseController { |
31 | 32 | @PostMapping("/complete") |
32 | 33 | @ApiOperation("wcs任务完成") |
33 | 34 | @ResponseBody |
35 | + @ApiLogger(apiName = "任务完成", from="WCS") | |
34 | 36 | public AjaxResult TaskFinish(@RequestBody TaskFinishDomain taskFinishDomain) |
35 | 37 | { |
36 | 38 | AjaxResult ajaxResult =taskFinishService.completeTaskByWCS(taskFinishDomain) ; |
... | ... |
src/main/java/com/huaheng/api/wcs/controller/TaskInfoController.java
1 | 1 | package com.huaheng.api.wcs.controller; |
2 | 2 | |
3 | 3 | import com.huaheng.api.wcs.service.taskCancel.TaskCancelService; |
4 | +import com.huaheng.framework.aspectj.lang.annotation.ApiLogger; | |
4 | 5 | import com.huaheng.framework.web.controller.BaseController; |
5 | 6 | import com.huaheng.framework.web.domain.AjaxResult; |
6 | 7 | import org.springframework.web.bind.annotation.GetMapping; |
... | ... | @@ -21,6 +22,7 @@ public class TaskInfoController extends BaseController { |
21 | 22 | |
22 | 23 | |
23 | 24 | @GetMapping |
25 | + @ApiLogger(apiName = "取消任务", from="WCS") | |
24 | 26 | public AjaxResult info(Integer id) { |
25 | 27 | return taskCancelService.TaskCance(id); |
26 | 28 | } |
... | ... |
src/main/java/com/huaheng/api/wcs/controller/WarecellAllocation.java
... | ... | @@ -3,6 +3,7 @@ package com.huaheng.api.wcs.controller; |
3 | 3 | import com.huaheng.api.wcs.domain.WcsTask; |
4 | 4 | import com.huaheng.api.wcs.service.emptyOutHandle.EmptyOutHandleService; |
5 | 5 | import com.huaheng.api.wcs.service.warecellAllocation.WarecellAllocationService; |
6 | +import com.huaheng.framework.aspectj.lang.annotation.ApiLogger; | |
6 | 7 | import com.huaheng.framework.aspectj.lang.annotation.Log; |
7 | 8 | import com.huaheng.framework.aspectj.lang.constant.BusinessType; |
8 | 9 | import com.huaheng.framework.web.controller.BaseController; |
... | ... | @@ -31,6 +32,7 @@ public class WarecellAllocation extends BaseController { |
31 | 32 | @PostMapping("/WarecellAllocation") |
32 | 33 | @ApiOperation(value="wcs仓位分配", notes="wcs仓位分配", httpMethod = "POST") |
33 | 34 | @ResponseBody |
35 | + @ApiLogger(apiName = "仓位分配", from="WCS") | |
34 | 36 | public AjaxResult WarecellAllocation(String taskNo, String length, String width, String height, String weight, String destination, String locationType) { |
35 | 37 | WcsTask wcsTask = new WcsTask(); |
36 | 38 | wcsTask.setTaskNo(taskNo); |
... | ... | @@ -55,6 +57,7 @@ public class WarecellAllocation extends BaseController { |
55 | 57 | @PostMapping("/DestinationAllocation") |
56 | 58 | @ApiOperation(value="wcs去向分配", notes="wcs去向分配", httpMethod = "POST") |
57 | 59 | @ResponseBody |
60 | + @ApiLogger(apiName = "去向分配", from="WCS") | |
58 | 61 | public AjaxResult DestinationAllocation(String taskNo, String length, String width, String height, String weight) { |
59 | 62 | WcsTask wcsTask = new WcsTask(); |
60 | 63 | wcsTask.setTaskNo(taskNo); |
... | ... |
src/main/java/com/huaheng/common/utils/http/HttpUtils.java
1 | 1 | package com.huaheng.common.utils.http; |
2 | 2 | |
3 | +import com.huaheng.framework.aspectj.ApiLogAspect; | |
4 | +import com.huaheng.pc.monitor.apilog.domain.ApiLog; | |
5 | +import org.apache.commons.io.IOUtils; | |
3 | 6 | import org.apache.http.HttpResponse; |
4 | 7 | import org.apache.http.HttpStatus; |
5 | 8 | import org.apache.http.client.methods.HttpPost; |
... | ... | @@ -225,11 +228,15 @@ public class HttpUtils |
225 | 228 | public static String bodypost(String strURL, String params) { |
226 | 229 | System.out.println(strURL); |
227 | 230 | System.out.println(params); |
231 | + HttpURLConnection connection = null; | |
232 | + InputStream is = null; | |
233 | + OutputStreamWriter out = null; | |
228 | 234 | String result = null; |
235 | + ApiLog log = null; | |
236 | + | |
229 | 237 | try { |
230 | 238 | URL url = new URL(strURL);// 创建连接 |
231 | - HttpURLConnection connection = (HttpURLConnection) | |
232 | - url.openConnection(); | |
239 | + connection = (HttpURLConnection) url.openConnection(); | |
233 | 240 | connection.setDoOutput(true); |
234 | 241 | connection.setDoInput(true); |
235 | 242 | connection.setUseCaches(false); |
... | ... | @@ -237,10 +244,12 @@ public class HttpUtils |
237 | 244 | connection.setRequestMethod("POST");// 设置请求方式 |
238 | 245 | connection.setRequestProperty("Accept","application/json");// 设置接收数据的格式 |
239 | 246 | connection.setRequestProperty("Content-Type","application/json");// 设置发送数据的格式 |
240 | - connection.connect(); OutputStreamWriter out = new OutputStreamWriter( connection.getOutputStream(),"UTF-8");// utf-8编码 | |
247 | + log = ApiLogAspect.initApiLog(connection, params); | |
248 | + connection.connect(); | |
249 | + out = new OutputStreamWriter( connection.getOutputStream(),"UTF-8");// utf-8编码 | |
241 | 250 | out.append(params); out.flush(); out.close(); // 读取响应 |
242 | 251 | int length = (int) connection.getContentLength();// 获取长度 |
243 | - InputStream is = connection.getInputStream(); | |
252 | + is = connection.getInputStream(); | |
244 | 253 | BufferedReader br = new BufferedReader(new InputStreamReader(is)); |
245 | 254 | // String ret = ""; |
246 | 255 | // if ((ret = br.readLine()) != null) { |
... | ... | @@ -256,8 +265,13 @@ public class HttpUtils |
256 | 265 | |
257 | 266 | // } |
258 | 267 | } catch (Exception e) { |
259 | - // TODO: handle exception | |
268 | + ApiLogAspect.setApiLogException(log, e); | |
260 | 269 | e.printStackTrace(); |
270 | + }finally { | |
271 | + ApiLogAspect.finishApiLog(log, connection, result); | |
272 | + if(connection != null) | |
273 | + connection.disconnect(); | |
274 | + IOUtils.closeQuietly(out, is); | |
261 | 275 | } |
262 | 276 | return result; |
263 | 277 | } |
... | ... |
src/main/java/com/huaheng/framework/aspectj/ApiLogAspect.java
0 → 100644
1 | +package com.huaheng.framework.aspectj; | |
2 | + | |
3 | +import com.alibaba.fastjson.JSON; | |
4 | +import com.alibaba.fastjson.JSONObject; | |
5 | +import com.huaheng.common.utils.ServletUtils; | |
6 | +import com.huaheng.common.utils.StringUtils; | |
7 | +import com.huaheng.framework.aspectj.lang.annotation.ApiLogger; | |
8 | +import com.huaheng.framework.web.domain.AjaxResult; | |
9 | +import com.huaheng.pc.config.address.domain.Address; | |
10 | +import com.huaheng.pc.config.address.service.AddressService; | |
11 | +import com.huaheng.pc.monitor.apilog.domain.ApiLog; | |
12 | +import com.huaheng.pc.monitor.apilog.service.IApiLogService; | |
13 | +import org.apache.commons.lang.exception.ExceptionUtils; | |
14 | +import org.aspectj.lang.ProceedingJoinPoint; | |
15 | +import org.aspectj.lang.annotation.*; | |
16 | +import org.aspectj.lang.reflect.MethodSignature; | |
17 | +import org.slf4j.Logger; | |
18 | +import org.slf4j.LoggerFactory; | |
19 | +import org.springframework.beans.factory.annotation.Autowired; | |
20 | +import org.springframework.scheduling.annotation.EnableAsync; | |
21 | +import org.springframework.stereotype.Component; | |
22 | + | |
23 | +import javax.servlet.http.HttpServletRequest; | |
24 | +import javax.servlet.http.HttpServletResponse; | |
25 | +import java.net.HttpURLConnection; | |
26 | +import java.net.URL; | |
27 | +import java.util.*; | |
28 | + | |
29 | +/** | |
30 | + * Api调用日志记录处理 | |
31 | + * | |
32 | + * @author huaheng | |
33 | + */ | |
34 | +@Aspect | |
35 | +@Component | |
36 | +//@EnableAsync | |
37 | +public class ApiLogAspect | |
38 | +{ | |
39 | + private static final Logger log = LoggerFactory.getLogger(ApiLogAspect.class); | |
40 | + | |
41 | + private static IApiLogService apiLogService; | |
42 | + | |
43 | + private static AddressService addressService; | |
44 | + | |
45 | + | |
46 | + @Autowired | |
47 | + public void setApiLogService(IApiLogService apiLogService){ | |
48 | + ApiLogAspect.apiLogService = apiLogService; | |
49 | + } | |
50 | + | |
51 | + @Autowired | |
52 | + public void setAddressService(AddressService addressService){ | |
53 | + ApiLogAspect.addressService = addressService; | |
54 | + } | |
55 | + | |
56 | + // 配置织入点 | |
57 | + @Pointcut("@annotation(com.huaheng.framework.aspectj.lang.annotation.ApiLogger)") | |
58 | + public void logPointCut() | |
59 | + { | |
60 | + } | |
61 | + | |
62 | + @Around("logPointCut() && @annotation(apiLogger)") | |
63 | + public Object around(ProceedingJoinPoint point, ApiLogger apiLogger) throws Throwable | |
64 | + { | |
65 | + if("WMS".equalsIgnoreCase(apiLogger.from())) | |
66 | + //实际上静态方法上的Aop注解无法拦截到 | |
67 | + return aroundWms2XXX(point, apiLogger); | |
68 | + else | |
69 | + return aroundXXX2Wms(point, apiLogger); | |
70 | + } | |
71 | + | |
72 | + /**处理xxx调用wms接口的日志**/ | |
73 | + private Object aroundXXX2Wms(ProceedingJoinPoint point, ApiLogger apiLogger){ | |
74 | + Object ret = null; | |
75 | + ApiLog log = initApiLog(apiLogger, point); | |
76 | + try{ | |
77 | + ret = point.proceed(); | |
78 | + }catch (Exception e){ | |
79 | + setApiLogException(log, e); | |
80 | + throw e; | |
81 | + }finally{ | |
82 | + finishApiLog(log, ret); | |
83 | + return ret; | |
84 | + } | |
85 | + } | |
86 | + | |
87 | + /**处理WMS调用xxx接口的日志**/ | |
88 | + private Object aroundWms2XXX(ProceedingJoinPoint point, ApiLogger apiLogger){ | |
89 | + Object ret = null; | |
90 | + ApiLog log = new ApiLog(); | |
91 | + | |
92 | + HttpURLConnection connection = null; | |
93 | + String body = null; | |
94 | + | |
95 | + try { | |
96 | + connection = (HttpURLConnection) point.getArgs()[0]; | |
97 | + body = (String) point.getArgs()[1]; | |
98 | + initApiLog(connection, body); | |
99 | + }catch (Exception e){ | |
100 | + | |
101 | + } | |
102 | + | |
103 | + try{ | |
104 | + ret = point.proceed(); | |
105 | + }catch (Exception e){ | |
106 | + setApiLogException(log, e); | |
107 | + throw e; | |
108 | + }finally{ | |
109 | + finishApiLog(log, connection, ret.toString()); | |
110 | + return ret; | |
111 | + } | |
112 | + } | |
113 | + | |
114 | + /**记录WMS调用外接口的请求信息 | |
115 | + * 在HttpUtils.bodypost方法中直接调用本类static方法**/ | |
116 | + public static ApiLog initApiLog(HttpURLConnection connection, String body){ | |
117 | + ApiLog log = new ApiLog(); | |
118 | + try { | |
119 | + log.setApiMethod(connection.getRequestMethod()); | |
120 | + log.setUrl(connection.getURL().toString()); | |
121 | + log.setRequestTime(new Date()); | |
122 | + parseUrl(log, connection.getURL()); | |
123 | + | |
124 | + //请求头 | |
125 | + Set<String> keySet = connection.getRequestProperties().keySet(); | |
126 | + ArrayList<String> headerList = new ArrayList<>(); | |
127 | + Iterator<String> it = keySet.iterator(); | |
128 | + while (it.hasNext()) { | |
129 | + String name = it.next(); | |
130 | + String header = connection.getRequestProperty(name); | |
131 | + headerList.add(name + ": " + header); | |
132 | + } | |
133 | + | |
134 | + log.setRequestHeader(org.apache.commons.lang3.StringUtils.join(headerList, "\n")); | |
135 | + log.setRequestBody(body); | |
136 | + }catch (Exception e){ | |
137 | + e.printStackTrace(); | |
138 | + } | |
139 | + | |
140 | + return log; | |
141 | + } | |
142 | + | |
143 | + /**根据url,从address表中判断调用的去向**/ | |
144 | + public static void parseUrl(ApiLog log, URL url){ | |
145 | + try { | |
146 | + String[] spList = url.toString().split("/"); | |
147 | + String apiName = spList[spList.length - 1]; | |
148 | + int index = url.toString().lastIndexOf(apiName); | |
149 | + String addUrl = url.toString().substring(0, index); | |
150 | + | |
151 | + Address address = addressService.getAddressByUrl(addUrl); | |
152 | + log.setApiName(apiName); | |
153 | + log.setRequestFrom("WMS"); | |
154 | + log.setResponseBy(address.getParam().toUpperCase()); | |
155 | + }catch (Exception e){ | |
156 | + e.printStackTrace(); | |
157 | + } | |
158 | + } | |
159 | + | |
160 | + /**记录响应头信息**/ | |
161 | + public static void finishApiLog(ApiLog log, HttpURLConnection connection, String body){ | |
162 | + try { | |
163 | + log.setResponseBody(body); | |
164 | + log.setResponseTime(new Date()); | |
165 | + Long duration = log.getResponseTime().getTime() - log.getRequestTime().getTime(); | |
166 | + log.setDuration(duration.intValue()); | |
167 | + log.setHttpCode(String.valueOf(connection.getResponseCode())); | |
168 | + | |
169 | + //响应头 | |
170 | + Set<String> keyset = connection.getHeaderFields().keySet(); | |
171 | + ArrayList<String> headerList = new ArrayList<>(); | |
172 | + Iterator<String> it = keyset.iterator(); | |
173 | + while(it.hasNext()){ | |
174 | + String name = it.next(); | |
175 | + String header = connection.getHeaderField(name); | |
176 | + headerList.add(name + ": " + header); | |
177 | + } | |
178 | + log.setResponseHeader(org.apache.commons.lang3.StringUtils.join(headerList, "\n")); | |
179 | + AjaxResult json = JSON.parseObject(body, AjaxResult.class); | |
180 | + log.setHttpCode(String.valueOf(json.getCode())); | |
181 | + }catch (Exception e){ | |
182 | + e.printStackTrace(); | |
183 | + }finally { | |
184 | + saveApiLog(log); | |
185 | + } | |
186 | + } | |
187 | + | |
188 | + private ApiLog initApiLog(ApiLogger apiLogger, ProceedingJoinPoint point){ | |
189 | + ApiLog log = new ApiLog(); | |
190 | + try{ | |
191 | + log.setRequestTime(new Date()); | |
192 | + log.setRequestFrom(apiLogger.from()); | |
193 | + log.setResponseBy(apiLogger.to()); | |
194 | + log.setApiName(apiLogger.apiName()); | |
195 | + | |
196 | + HttpServletRequest request = ServletUtils.getRequest(); | |
197 | + | |
198 | + String qryStr = request.getQueryString(); | |
199 | + String url = request.getRequestURL().toString(); | |
200 | + if(StringUtils.isNotEmpty(qryStr)) | |
201 | + url = url + "?" + qryStr; | |
202 | + log.setUrl(url); | |
203 | + | |
204 | + log.setApiMethod(request.getMethod()); | |
205 | + log.setIp(request.getRemoteAddr()); | |
206 | + | |
207 | + rebuildRequestHeader(log); | |
208 | + | |
209 | + rebuildRequestBody(log, request); | |
210 | + | |
211 | + //如果reqeust中取不到post参数,就从接口方法参数中取json对象 | |
212 | + if(StringUtils.isEmpty(log.getRequestBody())) | |
213 | + rebuildRequestBody(log, point); | |
214 | + | |
215 | + }catch (Exception e){ | |
216 | + e.printStackTrace(); | |
217 | + } | |
218 | + | |
219 | + return log; | |
220 | + } | |
221 | + | |
222 | + private void finishApiLog(ApiLog log, Object ret){ | |
223 | + try { | |
224 | + rebuildResponseHeader(log); | |
225 | + rebuildResponseBody(log, ret); | |
226 | + | |
227 | + log.setResponseTime(new Date()); | |
228 | + Long duration = log.getResponseTime().getTime() - log.getRequestTime().getTime(); | |
229 | + log.setDuration(duration.intValue()); | |
230 | + | |
231 | + HttpServletResponse resp = ServletUtils.getResponse(); | |
232 | + log.setHttpCode(String.valueOf(resp.getStatus())); | |
233 | + | |
234 | + if (ret instanceof AjaxResult) { | |
235 | + int retCode = ((AjaxResult) ret).getCode(); | |
236 | + log.setRetCode(String.valueOf(retCode)); | |
237 | + } | |
238 | + }catch (Exception e){ | |
239 | + e.printStackTrace(); | |
240 | + }finally { | |
241 | + saveApiLog(log); | |
242 | + } | |
243 | + } | |
244 | + | |
245 | + public static void setApiLogException(ApiLog log, Exception e){ | |
246 | + try { | |
247 | + String exception = ExceptionUtils.getFullStackTrace(e); | |
248 | + String shortExpInfo = e.getMessage() + "\n" + org.apache.commons.lang3.StringUtils.left(exception, 1000); | |
249 | + log.setException(shortExpInfo); | |
250 | + }catch (Exception ex){ | |
251 | + ex.printStackTrace(); | |
252 | + } | |
253 | + } | |
254 | + | |
255 | + private void rebuildRequestHeader(ApiLog log){ | |
256 | + try { | |
257 | + HttpServletRequest req = ServletUtils.getRequest(); | |
258 | + Enumeration names = req.getHeaderNames(); | |
259 | + ArrayList<String> headerList = new ArrayList<>(); | |
260 | + while(names.hasMoreElements()){ | |
261 | + String name = (String)names.nextElement(); | |
262 | + String header = req.getHeader(name); | |
263 | + headerList.add(name + ": " + header); | |
264 | + } | |
265 | + String headers = org.apache.commons.lang3.StringUtils.join(headerList, "\n"); | |
266 | + log.setRequestHeader(headers); | |
267 | + }catch (Exception e){ | |
268 | + e.printStackTrace(); | |
269 | + } | |
270 | + } | |
271 | + | |
272 | + /**先从post参数中构造request body*/ | |
273 | + private void rebuildRequestBody(ApiLog log, HttpServletRequest request){ | |
274 | + try{ | |
275 | + Set<String> keySet = request.getParameterMap().keySet(); | |
276 | + Iterator<String> it = keySet.iterator(); | |
277 | + StringBuffer sbf = new StringBuffer(); | |
278 | + while(it.hasNext()){ | |
279 | + String key = it.next(); | |
280 | + String value = request.getParameter(key); | |
281 | + sbf.append(key).append("=").append(value); | |
282 | + if(it.hasNext()) | |
283 | + sbf.append("&"); | |
284 | + } | |
285 | + log.setRequestBody(sbf.toString()); | |
286 | + }catch (Exception e){ | |
287 | + e.printStackTrace(); | |
288 | + } | |
289 | + } | |
290 | + | |
291 | + /** | |
292 | + * 根据接口中的参数构造request body | |
293 | + */ | |
294 | + private void rebuildRequestBody(ApiLog log, ProceedingJoinPoint point) | |
295 | + { | |
296 | + try { | |
297 | + if (point.getArgs().length == 1) { | |
298 | + log.setRequestBody(JSONObject.toJSONString(point.getArgs()[0])); | |
299 | + return; | |
300 | + } | |
301 | + | |
302 | + MethodSignature m = (MethodSignature) point.getSignature(); | |
303 | + HashMap<String, Object> map = new HashMap<>(); | |
304 | + Object[] args = point.getArgs(); | |
305 | + for (int i = 0; i < m.getParameterNames().length; i++) { | |
306 | + String name = m.getParameterNames()[i]; | |
307 | +// Class type = m.getParameterTypes()[i]; | |
308 | + map.put(name, args[i]); | |
309 | + } | |
310 | + | |
311 | + log.setRequestBody(JSONObject.toJSONString(map)); | |
312 | + }catch (Exception e){ | |
313 | + e.printStackTrace(); | |
314 | + } | |
315 | + } | |
316 | + | |
317 | + private void rebuildResponseHeader(ApiLog log){ | |
318 | + try { | |
319 | + HttpServletResponse resp = ServletUtils.getResponse(); | |
320 | + Collection names = resp.getHeaderNames(); | |
321 | + ArrayList<String> headerList = new ArrayList<>(); | |
322 | + Iterator<String> it = names.iterator(); | |
323 | + while(it.hasNext()){ | |
324 | + String name = it.next(); | |
325 | + String header = resp.getHeader(name); | |
326 | + headerList.add(name + ": " + header); | |
327 | + } | |
328 | + String headers = org.apache.commons.lang3.StringUtils.join(headerList, "\n"); | |
329 | + log.setResponseHeader(headers); | |
330 | + }catch (Exception e){ | |
331 | + e.printStackTrace(); | |
332 | + } | |
333 | + } | |
334 | + | |
335 | + private void rebuildResponseBody(ApiLog log, Object ret){ | |
336 | + try { | |
337 | + log.setResponseBody(JSONObject.toJSON(ret).toString()); | |
338 | + }catch (Exception e){ | |
339 | + e.printStackTrace(); | |
340 | + } | |
341 | + } | |
342 | + | |
343 | + public static void saveApiLog(ApiLog log){ | |
344 | + try{ | |
345 | + apiLogService.saveOrUpdate(log); | |
346 | + }catch (Exception e){ | |
347 | + e.printStackTrace(); | |
348 | + } | |
349 | + } | |
350 | +} | |
... | ... |
src/main/java/com/huaheng/framework/aspectj/lang/annotation/ApiLogger.java
0 → 100644
1 | +package com.huaheng.framework.aspectj.lang.annotation; | |
2 | + | |
3 | +import com.huaheng.framework.aspectj.lang.constant.OperatorType; | |
4 | + | |
5 | +import java.lang.annotation.*; | |
6 | + | |
7 | +/** | |
8 | + * 第三方系统API请求调用日志注解 | |
9 | + * | |
10 | + * @author huaheng | |
11 | + * | |
12 | + */ | |
13 | +@Target({ ElementType.METHOD }) | |
14 | +@Retention(RetentionPolicy.RUNTIME) | |
15 | +@Documented | |
16 | +public @interface ApiLogger | |
17 | +{ | |
18 | + /** 接口名称 */ | |
19 | + String apiName() default ""; | |
20 | + | |
21 | + /** 接口调用方 */ | |
22 | + String from() default ""; | |
23 | + | |
24 | + /** 接口提供方 */ | |
25 | + String to() default "WMS"; | |
26 | + | |
27 | +} | |
... | ... |
src/main/java/com/huaheng/pc/config/address/service/AddressService.java
src/main/java/com/huaheng/pc/config/address/service/AddressServiceImpl.java
... | ... | @@ -68,4 +68,13 @@ public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address> impl |
68 | 68 | return false; |
69 | 69 | } |
70 | 70 | } |
71 | + | |
72 | + @Override | |
73 | + public Address getAddressByUrl(String url) { | |
74 | + LambdaQueryWrapper<Address> addressLam = Wrappers.lambdaQuery(); | |
75 | + addressLam.eq(Address::getUrl,url) | |
76 | + .eq(Address::getWarehouseCode, ShiroUtils.getWarehouseCode()); | |
77 | + Address address=this.getOne(addressLam); | |
78 | + return address; | |
79 | + } | |
71 | 80 | } |
... | ... |
src/main/java/com/huaheng/pc/monitor/apilog/controller/ApiLogController.java
0 → 100644
1 | +package com.huaheng.pc.monitor.apilog.controller; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
4 | +import com.baomidou.mybatisplus.core.metadata.IPage; | |
5 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
6 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |
7 | +import com.huaheng.common.utils.DateUtils; | |
8 | +import com.huaheng.framework.web.page.PageDomain; | |
9 | +import com.huaheng.framework.web.page.TableDataInfo; | |
10 | +import com.huaheng.framework.web.page.TableSupport; | |
11 | +import com.huaheng.common.utils.StringUtils; | |
12 | +import io.swagger.annotations.ApiParam; | |
13 | +import org.apache.commons.lang3.math.NumberUtils; | |
14 | +import org.apache.shiro.authz.annotation.RequiresPermissions; | |
15 | +import org.springframework.stereotype.Controller; | |
16 | +import org.springframework.ui.ModelMap; | |
17 | +import org.springframework.web.bind.annotation.GetMapping; | |
18 | +import org.springframework.web.bind.annotation.PathVariable; | |
19 | +import org.springframework.web.bind.annotation.PostMapping; | |
20 | +import org.springframework.web.bind.annotation.RequestMapping; | |
21 | +import org.springframework.web.bind.annotation.ResponseBody; | |
22 | +import com.huaheng.framework.aspectj.lang.annotation.Log; | |
23 | +import com.huaheng.framework.aspectj.lang.constant.BusinessType; | |
24 | +import com.huaheng.pc.monitor.apilog.domain.ApiLog; | |
25 | +import com.huaheng.pc.monitor.apilog.service.IApiLogService; | |
26 | +import com.huaheng.framework.web.controller.BaseController; | |
27 | +import com.huaheng.framework.web.domain.AjaxResult; | |
28 | +import com.huaheng.common.support.Convert; | |
29 | + | |
30 | +import javax.annotation.Resource; | |
31 | +import java.util.Arrays; | |
32 | +import java.util.Date; | |
33 | +import java.util.List; | |
34 | + | |
35 | +/** | |
36 | + * 接口调用日志 信息操作处理 | |
37 | + * | |
38 | + * @author huaheng | |
39 | + * @date 2020-07-14 | |
40 | + */ | |
41 | +@Controller | |
42 | +@RequestMapping("/monitor/apilog") | |
43 | +public class ApiLogController extends BaseController { | |
44 | + private String prefix = "monitor/apilog"; | |
45 | + | |
46 | + @Resource | |
47 | + private IApiLogService apiLogService; | |
48 | + | |
49 | + @RequiresPermissions("monitor:apiLog:view") | |
50 | + @GetMapping() | |
51 | + public String apiLog() { | |
52 | + return prefix + "/apiLog"; | |
53 | + } | |
54 | + | |
55 | + | |
56 | + @RequiresPermissions("monitor:apiLog:view") | |
57 | + @GetMapping("/list/{id}") | |
58 | + public String apiLogDetail(@PathVariable("id") Integer id, ModelMap mmap) { | |
59 | + mmap.put("apiLog", apiLogService.getById(id)); | |
60 | + return prefix + "/detail"; | |
61 | + } | |
62 | + | |
63 | + /** | |
64 | + * 查询接口调用日志列表 | |
65 | + */ | |
66 | + @RequiresPermissions("monitor:apiLog:list") | |
67 | + @PostMapping("/list") | |
68 | + @ResponseBody | |
69 | + public TableDataInfo list(ApiLog apiLog, @ApiParam(name = "beginRequestTime", value = "起始时间") String beginRequestTime, | |
70 | + @ApiParam(name = "endRequestTime", value = "起始时间") String endRequestTime, | |
71 | + @ApiParam(name = "endRequestTime", value = "起始时间") String hasException, | |
72 | + @ApiParam(name = "endRequestTime", value = "起始时间") String paramDuration) { | |
73 | + LambdaQueryWrapper<ApiLog> lambdaQueryWrapper = Wrappers.lambdaQuery(); | |
74 | + | |
75 | + Date requestTime = new Date(); | |
76 | + try { | |
77 | + requestTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD, endRequestTime); | |
78 | + }catch (Exception e){ | |
79 | + | |
80 | + } | |
81 | + requestTime = DateUtils.addDays(requestTime, 1); | |
82 | + | |
83 | + lambdaQueryWrapper | |
84 | + .eq(StringUtils.isNotEmpty(apiLog.getApiName()), ApiLog::getApiName, apiLog.getApiName()) | |
85 | + .eq(StringUtils.isNotEmpty(apiLog.getRequestFrom()), ApiLog::getRequestFrom, apiLog.getRequestFrom()) | |
86 | + .eq(StringUtils.isNotEmpty(apiLog.getResponseBy()), ApiLog::getResponseBy, apiLog.getResponseBy()) | |
87 | + .ge(StringUtils.isNotEmpty(beginRequestTime), ApiLog::getRequestTime, beginRequestTime) | |
88 | + .ge(NumberUtils.isNumber(paramDuration), ApiLog::getDuration, paramDuration) | |
89 | + .isNotNull("1".equals(hasException),ApiLog::getException) | |
90 | + .isNull("0".equals(hasException),ApiLog::getException) | |
91 | + .le(StringUtils.isNotEmpty(endRequestTime), ApiLog::getRequestTime, requestTime) | |
92 | + .eq(StringUtils.isNotEmpty(apiLog.getHttpCode()), ApiLog::getHttpCode, apiLog.getHttpCode()) | |
93 | + .eq(StringUtils.isNotEmpty(apiLog.getRetCode()), ApiLog::getRetCode, apiLog.getRetCode()).orderByDesc(ApiLog::getId); | |
94 | + PageDomain pageDomain = TableSupport.buildPageRequest(); | |
95 | + Integer pageNum = pageDomain.getPageNum(); | |
96 | + Integer pageSize = pageDomain.getPageSize(); | |
97 | + ; | |
98 | + if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) { | |
99 | + /*使用分页查询*/ | |
100 | + Page<ApiLog> page = new Page<>(pageNum, pageSize); | |
101 | + IPage<ApiLog> iPage = apiLogService.page(page, lambdaQueryWrapper); | |
102 | + return getMpDataTable(iPage.getRecords(), iPage.getTotal()); | |
103 | + } else { | |
104 | + List<ApiLog> list = apiLogService.list(lambdaQueryWrapper); | |
105 | + return getDataTable(list); | |
106 | + } | |
107 | + } | |
108 | + | |
109 | + /** | |
110 | + * 新增接口调用日志 | |
111 | + */ | |
112 | + @GetMapping("/add") | |
113 | + public String add() { | |
114 | + return prefix + "/add"; | |
115 | + } | |
116 | + | |
117 | + /** | |
118 | + * 新增保存接口调用日志 | |
119 | + */ | |
120 | + @RequiresPermissions("monitor:apiLog:add") | |
121 | + @Log(title = "接口日志", action = BusinessType.INSERT) | |
122 | + @PostMapping("/add") | |
123 | + @ResponseBody | |
124 | + public AjaxResult addSave(ApiLog apiLog) { | |
125 | + return toAjax(apiLogService.save(apiLog)); | |
126 | + } | |
127 | + | |
128 | + /** | |
129 | + * 修改接口调用日志 | |
130 | + */ | |
131 | + @GetMapping("/edit/{id}") | |
132 | + public String edit(@PathVariable("id") Integer id, ModelMap mmap) { | |
133 | + ApiLog apiLog = apiLogService.getById(id); | |
134 | + mmap.put("apiLog", apiLog); | |
135 | + return prefix + "/edit"; | |
136 | + } | |
137 | + | |
138 | + /** | |
139 | + * 修改保存接口调用日志 | |
140 | + */ | |
141 | + @RequiresPermissions("monitor:apiLog:edit") | |
142 | + @Log(title = "接口日志", action = BusinessType.UPDATE) | |
143 | + @PostMapping("/edit") | |
144 | + @ResponseBody | |
145 | + public AjaxResult editSave(ApiLog apiLog) { | |
146 | + return toAjax(apiLogService.updateById(apiLog)); | |
147 | + } | |
148 | + | |
149 | + /** | |
150 | + * 删除接口调用日志 | |
151 | + */ | |
152 | + @RequiresPermissions("monitor:apiLog:remove") | |
153 | + @Log(title = "接口日志", action = BusinessType.DELETE) | |
154 | + @PostMapping("/remove") | |
155 | + @ResponseBody | |
156 | + public AjaxResult remove(String ids) { | |
157 | + if (StringUtils.isEmpty(ids)) { | |
158 | + return AjaxResult.error("id不能为空"); | |
159 | + } | |
160 | + return toAjax(apiLogService.removeByIds(Arrays.asList(Convert.toIntArray(ids)))); | |
161 | + } | |
162 | + | |
163 | +} | |
... | ... |
src/main/java/com/huaheng/pc/monitor/apilog/domain/ApiLog.java
0 → 100644
1 | +package com.huaheng.pc.monitor.apilog.domain; | |
2 | + | |
3 | +import com.alibaba.fastjson.annotation.JSONField; | |
4 | +import com.baomidou.mybatisplus.annotation.IdType; | |
5 | +import com.baomidou.mybatisplus.annotation.TableField; | |
6 | +import com.baomidou.mybatisplus.annotation.TableId; | |
7 | +import com.baomidou.mybatisplus.annotation.TableName; | |
8 | +import com.fasterxml.jackson.annotation.JsonFormat; | |
9 | +import lombok.Data; | |
10 | +import org.apache.commons.lang3.builder.ToStringBuilder; | |
11 | +import org.apache.commons.lang3.builder.ToStringStyle; | |
12 | +import io.swagger.annotations.ApiModelProperty; | |
13 | +import javax.validation.constraints.*; | |
14 | +import java.io.Serializable; | |
15 | +import java.math.BigDecimal; | |
16 | +import java.text.SimpleDateFormat; | |
17 | +import java.util.Date; | |
18 | + | |
19 | +/** | |
20 | + * 接口调用日志表 api_log | |
21 | + * | |
22 | + * @author huaheng | |
23 | + * @date 2020-07-14 | |
24 | + */ | |
25 | +@TableName(value = "api_log") | |
26 | +@Data | |
27 | +public class ApiLog implements Serializable{ | |
28 | + private static final long serialVersionUID = 1L; | |
29 | + | |
30 | + /** - */ | |
31 | + @TableId(value = "id", type = IdType.AUTO) | |
32 | + private Integer id; | |
33 | + /** 模块标题 */ | |
34 | + @TableField(value = "apiName") | |
35 | + private String apiName; | |
36 | + /** 请求类型 */ | |
37 | + @TableField(value = "apiMethod") | |
38 | + private String apiMethod; | |
39 | + /** 请求方ip地址 */ | |
40 | + @TableField(value = "ip") | |
41 | + private String ip; | |
42 | + /** 请求方名称 */ | |
43 | + @TableField(value = "requestFrom") | |
44 | + private String requestFrom; | |
45 | + /** 响应方名称 */ | |
46 | + @TableField(value = "responseBy") | |
47 | + private String responseBy; | |
48 | + /** 请求地址 */ | |
49 | + @TableField(value = "url") | |
50 | + private String url; | |
51 | + /** 请求时间 */ | |
52 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
53 | + @TableField(value = "requestTime") | |
54 | + private Date requestTime; | |
55 | + /** 响应时间 */ | |
56 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
57 | + @TableField(value = "responseTime") | |
58 | + private Date responseTime; | |
59 | + /** 请求头 */ | |
60 | + @TableField(value = "requestHeader") | |
61 | + private String requestHeader; | |
62 | + /** 请求内容 */ | |
63 | + @TableField(value = "requestBody") | |
64 | + private String requestBody; | |
65 | + /** 响应头 */ | |
66 | + @TableField(value = "responseHeader") | |
67 | + private String responseHeader; | |
68 | + /** 响应内容 */ | |
69 | + @TableField(value = "responseBody") | |
70 | + private String responseBody; | |
71 | + /** 响应耗时(毫秒) */ | |
72 | + @TableField(value = "duration") | |
73 | + private int duration; | |
74 | + /** httpCode */ | |
75 | + @TableField(value = "httpCode") | |
76 | + private String httpCode; | |
77 | + /** retCode */ | |
78 | + @TableField(value = "retCode") | |
79 | + private String retCode; | |
80 | + /** 异常堆栈信息 */ | |
81 | + @TableField(value = "exception") | |
82 | + private String exception; | |
83 | + | |
84 | + public String getExceptionMsg(){ | |
85 | + String msg = exception; | |
86 | + try{ | |
87 | + msg = exception.split("\n")[0]; | |
88 | + }catch (Exception e){ | |
89 | + | |
90 | + } | |
91 | + return msg; | |
92 | + } | |
93 | + | |
94 | +} | |
... | ... |
src/main/java/com/huaheng/pc/monitor/apilog/mapper/ApiLogMapper.java
0 → 100644
1 | +package com.huaheng.pc.monitor.apilog.mapper; | |
2 | + | |
3 | +import com.huaheng.pc.monitor.apilog.domain.ApiLog; | |
4 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |
5 | +import java.util.List; | |
6 | + | |
7 | +/** | |
8 | + * 接口调用日志 数据层 | |
9 | + * | |
10 | + * @author huaheng | |
11 | + * @date 2020-07-14 | |
12 | + */ | |
13 | +public interface ApiLogMapper extends BaseMapper<ApiLog> { | |
14 | + | |
15 | + public List<String> getRequestFromList(); | |
16 | + | |
17 | + public List<String> getResponseByList(); | |
18 | + | |
19 | + public List<String> getHttpCodeList(); | |
20 | + | |
21 | + public List<String> getApiNameList(); | |
22 | + | |
23 | + public List<String> getHttpRetList(); | |
24 | +} | |
25 | + | |
... | ... |
src/main/java/com/huaheng/pc/monitor/apilog/service/IApiLogService.java
0 → 100644
1 | +package com.huaheng.pc.monitor.apilog.service; | |
2 | + | |
3 | +import com.huaheng.pc.monitor.apilog.domain.ApiLog; | |
4 | +import com.baomidou.mybatisplus.extension.service.IService; | |
5 | +import java.util.List; | |
6 | + | |
7 | +/** | |
8 | + * 接口调用日志 服务层 | |
9 | + * | |
10 | + * @author huaheng | |
11 | + * @date 2020-07-14 | |
12 | + */ | |
13 | +public interface IApiLogService extends IService<ApiLog> { | |
14 | + | |
15 | + public List<String> getRequestFromList(); | |
16 | + | |
17 | + public List<String> getResponseByList(); | |
18 | + | |
19 | + public List<String> getHttpCodeList(); | |
20 | + | |
21 | + public List<String> getApiNameList(); | |
22 | + | |
23 | + public List<String> getRetCodeList(); | |
24 | +} | |
25 | + | |
26 | + | |
... | ... |
src/main/java/com/huaheng/pc/monitor/apilog/service/impl/ApiLogServiceImpl.java
0 → 100644
1 | +package com.huaheng.pc.monitor.apilog.service.impl; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
4 | +import com.huaheng.pc.monitor.apilog.service.IApiLogService; | |
5 | +import com.huaheng.pc.monitor.apilog.domain.ApiLog; | |
6 | +import com.huaheng.pc.monitor.apilog.mapper.ApiLogMapper; | |
7 | +import org.springframework.stereotype.Service; | |
8 | + | |
9 | +import javax.annotation.Resource; | |
10 | +import java.util.List; | |
11 | + | |
12 | + | |
13 | +/** | |
14 | + * 接口调用日志 服务层实现 | |
15 | + * | |
16 | + * @author huaheng | |
17 | + * @date 2020-07-14 | |
18 | + */ | |
19 | +@Service("apiLogService") | |
20 | +public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper, ApiLog> implements IApiLogService { | |
21 | + | |
22 | + @Resource | |
23 | + ApiLogMapper apiLogMapper; | |
24 | + | |
25 | + @Override | |
26 | + public List<String> getRequestFromList() { | |
27 | + return apiLogMapper.getRequestFromList(); | |
28 | + } | |
29 | + | |
30 | + @Override | |
31 | + public List<String> getResponseByList() { | |
32 | + return apiLogMapper.getResponseByList(); | |
33 | + } | |
34 | + | |
35 | + @Override | |
36 | + public List<String> getHttpCodeList() { | |
37 | + return apiLogMapper.getHttpCodeList(); | |
38 | + } | |
39 | + | |
40 | + @Override | |
41 | + public List<String> getRetCodeList() { | |
42 | + return apiLogMapper.getHttpRetList(); | |
43 | + } | |
44 | + | |
45 | + @Override | |
46 | + public List<String> getApiNameList() { | |
47 | + return apiLogMapper.getApiNameList(); | |
48 | + } | |
49 | +} | |
... | ... |
src/main/resources/mybatis/monitor/ApiLogMapper.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
2 | +<!DOCTYPE mapper | |
3 | + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |
4 | + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
5 | +<mapper namespace="com.huaheng.pc.monitor.apilog.mapper.ApiLogMapper"> | |
6 | + | |
7 | + <resultMap type="com.huaheng.pc.monitor.apilog.domain.ApiLog" id="apiLogResult"> | |
8 | + <result property="id" column="id"/> | |
9 | + <result property="apiName" column="apiName"/> | |
10 | + <result property="apiMethod" column="apiMethod"/> | |
11 | + <result property="ip" column="ip"/> | |
12 | + <result property="requestFrom" column="requestFrom"/> | |
13 | + <result property="responseBy" column="responseBy"/> | |
14 | + <result property="url" column="url"/> | |
15 | + <result property="requestTime" column="requestTime"/> | |
16 | + <result property="responseTime" column="responseTime"/> | |
17 | + <result property="requestHeader" column="requestHeader"/> | |
18 | + <result property="requestBody" column="requestBody"/> | |
19 | + <result property="responseHeader" column="responseHeader"/> | |
20 | + <result property="responseBody" column="responseBody"/> | |
21 | + <result property="duration" column="duration"/> | |
22 | + <result property="httpCode" column="httpCode"/> | |
23 | + <result property="retCode" column="retCode"/> | |
24 | + <result property="exception" column="exception"/> | |
25 | + </resultMap> | |
26 | + <sql id="selectapiLogVo"> | |
27 | + select id, apiName, apiMethod, ip, requestFrom, responseBy, url, requestTime, responseTime, requestHeader, requestBody, responseHeader, responseBody, duration, httpCode, retCode, `exception` from api_log | |
28 | + </sql> | |
29 | + <select id="getRequestFromList" resultType="java.lang.String"> | |
30 | + select distinct(requestFrom) from api_log order by requestFrom asc | |
31 | + </select> | |
32 | + <select id="getResponseByList" resultType="java.lang.String"> | |
33 | + select distinct(responseBy) from api_log order by responseBy asc | |
34 | + </select> | |
35 | + <select id="getHttpCodeList" resultType="java.lang.String"> | |
36 | + select distinct(httpCode) from api_log order by httpCode asc | |
37 | + </select> | |
38 | + <select id="getApiNameList" resultType="java.lang.String"> | |
39 | + select distinct(apiName) from api_log order by apiName asc | |
40 | + </select> | |
41 | + <select id="getHttpRetList" resultType="java.lang.String"> | |
42 | + select distinct(retCode) from api_log order by retCode asc | |
43 | + </select> | |
44 | + | |
45 | +</mapper> | |
0 | 46 | \ No newline at end of file |
... | ... |
src/main/resources/templates/monitor/apilog/apilog.html
0 → 100644
1 | +<!DOCTYPE HTML> | |
2 | +<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"> | |
3 | +<meta charset="utf-8"> | |
4 | +<head th:include="include :: header"></head> | |
5 | +<body class="gray-bg"> | |
6 | +<div class="container-div"> | |
7 | + <div class="row"> | |
8 | + <div class="col-sm-12 select-info"> | |
9 | + <form id="formId"> | |
10 | + <div class="select-list"> | |
11 | + <ul> | |
12 | + <li> | |
13 | + <label>API:</label> | |
14 | + <select name="apiName"> | |
15 | + <option value=""></option> | |
16 | + <option th:each="item:${@apiLogService.getApiNameList()}" th:value="${item}" th:text="${item}"></option> | |
17 | + </select> | |
18 | + </li> | |
19 | + <li> | |
20 | + <label>请求方:</label> | |
21 | + <select name="requestFrom"> | |
22 | + <option value=""></option> | |
23 | + <option th:each="item:${@apiLogService.getRequestFromList()}" th:value="${item}" th:text="${item}"></option> | |
24 | + </select> | |
25 | + </li> | |
26 | + <li> | |
27 | + <label>响应方:</label> | |
28 | + <select name="responseBy"> | |
29 | + <option value=""></option> | |
30 | + <option th:each="item:${@apiLogService.getResponseByList()}" th:value="${item}" th:text="${item}"></option> | |
31 | + </select> | |
32 | + </li> | |
33 | + <li> | |
34 | + <label>httpCode:</label> | |
35 | + <select name="httpCode"> | |
36 | + <option value=""></option> | |
37 | + <option th:each="item:${@apiLogService.getHttpCodeList()}" th:value="${item}" th:text="${item}"></option> | |
38 | + </select> | |
39 | + </li> | |
40 | + <li> | |
41 | + <label>retCode:</label> | |
42 | + <select name="retCode"> | |
43 | + <option value=""></option> | |
44 | + <option th:each="item:${@apiLogService.getHttpCodeList()}" th:value="${item}" th:text="${item}"></option> | |
45 | + </select> | |
46 | + </li> | |
47 | + <li> | |
48 | + <label>异常:</label> | |
49 | + <select name="hasException"> | |
50 | + <option value=""></option> | |
51 | + <option value="1">有异常</option> | |
52 | + <option value="0">无异常</option> | |
53 | + </select> | |
54 | + </li> | |
55 | + <li> | |
56 | + <label>响应时间 > </label> | |
57 | + <input type="text" name="paramDuration" placeholder="1000毫秒"/> | |
58 | + </li> | |
59 | + <li class="time"> | |
60 | + <label>请求时间:</label> | |
61 | + <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="beginRequestTime"/> | |
62 | + <span>-</span> | |
63 | + <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endRequestTime"/> | |
64 | + </li> | |
65 | + <li> | |
66 | + <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i | |
67 | + class="fa fa-search"></i> 搜索</a> | |
68 | + <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i | |
69 | + class="fa fa-refresh"></i> 重置</a> | |
70 | + </li> | |
71 | + </ul> | |
72 | + </div> | |
73 | + </form> | |
74 | + </div> | |
75 | + <div class="btn-group hidden-xs" id="toolbar" role="group"> | |
76 | + <a class="btn btn-outline btn-success btn-rounded" onclick="$.operate.add()" | |
77 | + shiro:hasPermission="apilog:apiLog:add"> | |
78 | + <i class="fa fa-plus"></i> 新增 | |
79 | + </a> | |
80 | + <a class="btn btn-outline btn-primary single disabled" onclick="$.operate.edit()" | |
81 | + shiro:hasPermission="apilog:apilog:edit"> | |
82 | + <i class="fa fa-edit"></i> 修改 | |
83 | + </a> | |
84 | + <a class="btn btn-outline btn-danger btn-rounded multiple disabled" onclick="$.operate.batRemove()" | |
85 | + shiro:hasPermission="apilog:apiLog:remove"> | |
86 | + <i class="fa fa-trash-o"></i> 删除 | |
87 | + </a> | |
88 | + </div> | |
89 | + | |
90 | + <div class="col-sm-12 select-info table-striped"> | |
91 | + <table id="bootstrap-table" data-mobile-responsive="true"></table> | |
92 | + </div> | |
93 | + </div> | |
94 | +</div> | |
95 | +<div th:include="include :: footer"></div> | |
96 | +<script th:inline="javascript"> | |
97 | + var editFlag = [[${@permission.hasPermi('apilog:apiLog:edit')}]]; | |
98 | + var removeFlag = [[${@permission.hasPermi('apilog:apiLog:remove')}]]; | |
99 | + var prefix = ctx + "monitor/apilog" | |
100 | + | |
101 | + $(function () { | |
102 | + var options = { | |
103 | + url: prefix + "/list", | |
104 | + detailUrl: prefix + "/list/{id}", | |
105 | + // createUrl: prefix + "/add", | |
106 | + // updateUrl: prefix + "/edit/{id}", | |
107 | + // removeUrl: prefix + "/remove", | |
108 | + modalName: "接口调用日志", | |
109 | + pageSize: 30, | |
110 | + columns: [ | |
111 | + { | |
112 | + field: 'id', | |
113 | + title: 'id', | |
114 | + visible: true | |
115 | + }, | |
116 | + { | |
117 | + title: '操作', | |
118 | + align: 'center', | |
119 | + formatter: function (value, row, index) { | |
120 | + var actions = []; | |
121 | + actions.push('<a class="btn btn-success btn-xs " href="#" onclick="$.operate.detail(\'' + row.id + '\')">详情</a> '); | |
122 | + return actions.join(''); | |
123 | + } | |
124 | + }, | |
125 | + { | |
126 | + field: 'apiName', | |
127 | + title: 'API' | |
128 | + }, | |
129 | + /** | |
130 | + { | |
131 | + field: 'ip', | |
132 | + title: 'IP' | |
133 | + }, | |
134 | + **/ | |
135 | + { | |
136 | + field: 'requestFrom', | |
137 | + title: 'from' | |
138 | + }, | |
139 | + { | |
140 | + field: 'responseBy', | |
141 | + title: 'to' | |
142 | + }, | |
143 | + /** | |
144 | + { | |
145 | + field: 'url', | |
146 | + title: '请求地址' | |
147 | + }, | |
148 | + **/ | |
149 | + { | |
150 | + field: 'httpCode', | |
151 | + title: 'http', | |
152 | + formatter: function(value, row, index) { | |
153 | + var actions = []; | |
154 | + var style = "style='color:green'" | |
155 | + if(value>200) | |
156 | + style = " style='color:red'"; | |
157 | + if(value == undefined) | |
158 | + value = " " | |
159 | + actions.push('<span '+ style + '>'+value+ '</span>') | |
160 | + return actions.join(" ") | |
161 | + } | |
162 | + }, | |
163 | + { | |
164 | + field: 'retCode', | |
165 | + title: 'ret', | |
166 | + formatter: function(value, row, index) { | |
167 | + var actions = []; | |
168 | + var style = "style='color:green'" | |
169 | + if(value>200) | |
170 | + style = " style='color:red'"; | |
171 | + if(value == undefined) | |
172 | + value = " " | |
173 | + actions.push('<span '+ style + '>'+value+ '</span>') | |
174 | + return actions.join(" ") | |
175 | + } | |
176 | + }, | |
177 | + { | |
178 | + field: 'requestTime', | |
179 | + title: '请求时间' | |
180 | + }, | |
181 | + /** | |
182 | + { | |
183 | + field: 'responseTime', | |
184 | + title: '响应时间' | |
185 | + }, | |
186 | + **/ | |
187 | + { | |
188 | + field: 'duration', | |
189 | + title: '耗时', | |
190 | + formatter: function(value, row, index) { | |
191 | + var actions = []; | |
192 | + var style = "" | |
193 | + if(value>1000) | |
194 | + style = " style='color:red'"; | |
195 | + if(value == undefined) | |
196 | + value = " " | |
197 | + actions.push('<span '+ style + ' title="毫秒">'+value+ '</span>') | |
198 | + return actions.join(" ") | |
199 | + } | |
200 | + }, | |
201 | + /** | |
202 | + { | |
203 | + field: 'requestHeader', | |
204 | + title: '请求头' | |
205 | + }, | |
206 | + **/ | |
207 | + | |
208 | + { | |
209 | + field: 'requestBody', | |
210 | + title: '请求内容', | |
211 | + formatter: function(value, row, index) { | |
212 | + var actions = []; | |
213 | + if(value == undefined) | |
214 | + value = " " | |
215 | + actions.push('<pre style="white-space: pre-wrap; width:400px" ondblclick="parseJson(this)" title="双击格式化">'+value+ '</pre>') | |
216 | + return actions.join(" ") | |
217 | + } | |
218 | + }, | |
219 | + /** | |
220 | + { | |
221 | + field: 'responseHeader', | |
222 | + title: '响应头' | |
223 | + }, | |
224 | + **/ | |
225 | + { | |
226 | + field: 'responseBody', | |
227 | + title: '响应内容', | |
228 | + formatter: function(value, row, index) { | |
229 | + var actions = []; | |
230 | + if(value == undefined) | |
231 | + value = " " | |
232 | + actions.push('<pre style="white-space: pre-wrap; width:400px" ondblclick="parseJson(this)" title="双击格式化">'+value+ '</pre>') | |
233 | + return actions.join(" ") | |
234 | + } | |
235 | + }, | |
236 | + | |
237 | + { | |
238 | + field: 'exceptionMsg', | |
239 | + title: '异常信息', | |
240 | + formatter: function(value, row, index) { | |
241 | + var actions = []; | |
242 | + if(value == undefined) | |
243 | + value = " " | |
244 | + actions.push('<span style="color:red">'+value+ '</span>') | |
245 | + return actions.join(" ") | |
246 | + } | |
247 | + } | |
248 | + ] | |
249 | + }; | |
250 | + $.table.init(options); | |
251 | + }); | |
252 | + | |
253 | + function parseJson(obj){ | |
254 | + var str = obj.innerHTML | |
255 | + try { | |
256 | + str = JSON.parse(str); | |
257 | + obj.outerHTML = '<pre style="white-space: pre-wrap; width:400px">' + JSON.stringify(str, null, 2) + '</pre>'; | |
258 | + }catch (e) { | |
259 | + str = str.split("&").join(" ") | |
260 | + obj.outerHTML = '<pre style="white-space: pre-wrap; width:400px">' + str + '</pre>'; | |
261 | + } | |
262 | + } | |
263 | +</script> | |
264 | +</body> | |
265 | +</html> | |
0 | 266 | \ No newline at end of file |
... | ... |
src/main/resources/templates/monitor/apilog/detail.html
0 → 100644
1 | +<!DOCTYPE html> | |
2 | +<html lang="zh" xmlns:th="http://www.thymeleaf.org"> | |
3 | +<head> | |
4 | + <th:block th:include="include :: header"/> | |
5 | + <th:block th:include="include :: datetimepicker-css"/> | |
6 | + <style> | |
7 | + .mylabel{ | |
8 | + text-align: right; | |
9 | + } | |
10 | + .red{ | |
11 | + color:red; | |
12 | + } | |
13 | + .green{ | |
14 | + color:green; | |
15 | + } | |
16 | + </style> | |
17 | +</head> | |
18 | +<body class="white-bg"> | |
19 | +<div class="wrapper wrapper-content animated fadeInRight ibox-content"> | |
20 | + <div class="" id="form-apilog-edit" th:object="${apiLog}"> | |
21 | + <div class=""> | |
22 | + <label class="col-sm-2 mylabel">ID:</label> | |
23 | + <label class="col-sm-10" th:text="${apiLog.getId()}"></label> | |
24 | + </div> | |
25 | + <div class=""> | |
26 | + <label class="col-sm-2 mylabel">接口名:</label> | |
27 | + <label class="col-sm-10" th:text="${apiLog.getApiName()}"></label> | |
28 | + </div> | |
29 | + <div class=""> | |
30 | + <label class="col-sm-2 mylabel">请求方ip:</label> | |
31 | + <label class="col-sm-10" th:text="${apiLog.getIp()}==null?' ':${apiLog.getIp()} + ' '"></label> | |
32 | + </div> | |
33 | + <div class=""> | |
34 | + <label class="col-sm-2 mylabel">调用方向:</label> | |
35 | + <label class="col-sm-10" th:text="${apiLog.getRequestFrom()} + ' -> ' + ${apiLog.getResponseBy()}"></label> | |
36 | + </div> | |
37 | + <div class=""> | |
38 | + <label class="col-sm-2 mylabel">Method:</label> | |
39 | + <label class="col-sm-10" th:text="${apiLog.getApiMethod()}"></label> | |
40 | + </div> | |
41 | + <div class=""> | |
42 | + <label class="col-sm-2 mylabel">接口地址:</label> | |
43 | + <label class="col-sm-10" th:text="${apiLog.getUrl()}"></label> | |
44 | + </div> | |
45 | + <div class=""> | |
46 | + <label class="col-sm-2 mylabel">请求时间:</label> | |
47 | + <label class="col-sm-10" th:text="${#dates.format(apiLog.requestTime, 'yyyy-MM-dd HH:mm:ss')}"></label> | |
48 | + </div> | |
49 | + <!--<div class="">--> | |
50 | + <!--<label class="col-sm-2 mylabel">响应时间:</label>--> | |
51 | + <!--<label class="col-sm-10" th:text="${#dates.format(apiLog.responseTime, 'yyyy-MM-dd HH:mm:ss')}"></label>--> | |
52 | + <!--</div>--> | |
53 | + <div class="" th:classappend="${apiLog.getDuration()}>=1000?'red'"> | |
54 | + <label class="col-sm-2 mylabel">耗时:</label> | |
55 | + <label class="col-sm-10" th:text="${apiLog.getDuration()} + ' 毫秒'"></label> | |
56 | + </div> | |
57 | + <div class="" th:classappend="${apiLog.getHttpCode()}=='200'?'green':'red'"> | |
58 | + <label class="col-sm-2 mylabel">HttpCode:</label> | |
59 | + <label class="col-sm-10" th:text="${apiLog.getHttpCode()}==null?' ':${apiLog.getHttpCode()}"></label> | |
60 | + </div> | |
61 | + <div class="" th:classappend="${apiLog.getRetCode()}=='200'?'green':'red'"> | |
62 | + <label class="col-sm-2 mylabel">RetCode:</label> | |
63 | + <label class="col-sm-10" th:text="${apiLog.getRetCode()}==null?' ':${apiLog.getRetCode()}"></label> | |
64 | + </div> | |
65 | + <div class=""> | |
66 | + <label class="col-sm-2 mylabel">请求头:</label> | |
67 | + <div class="col-sm-10"><pre style="white-space: pre-wrap;" th:text="${apiLog.getRequestHeader()}"></pre></div> | |
68 | + </div> | |
69 | + <div class=""> | |
70 | + <label class="col-sm-2 mylabel">响应头:</label> | |
71 | + <div class="col-sm-10"><pre style="white-space: pre-wrap;" th:text="${apiLog.getResponseHeader()}"></pre></div> | |
72 | + </div> | |
73 | + <div class=""> | |
74 | + <label class="col-sm-2 mylabel">请求内容:</label> | |
75 | + <div class="col-sm-10"><pre id="preReqBody" style="white-space: pre-wrap;" th:text="${apiLog.getRequestBody()}"></pre></div> | |
76 | + </div> | |
77 | + <div class=""> | |
78 | + <label class="col-sm-2 mylabel">响应内容:</label> | |
79 | + <div class="col-sm-10"><pre id="preRespBody" style="white-space: pre-wrap;" th:text="${apiLog.getResponseBody()}"></pre></div> | |
80 | + </div> | |
81 | + <!--<div class="">--> | |
82 | + <!--<label class="col-sm-2 mylabel">httpCode:</label>--> | |
83 | + <!--<div class="col-sm-8">--> | |
84 | + <!--<select name="httpcode" class="form-control m-b">--> | |
85 | + <!--<option value="">所有</option>--> | |
86 | + <!--</select>--> | |
87 | + <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>--> | |
88 | + <!--</div>--> | |
89 | + <!--</div>--> | |
90 | + <div class="" th:classappend="${apiLog.getException()}!=null?'red'"> | |
91 | + <label class="col-sm-2 mylabel">异常信息:</label> | |
92 | + <div class="col-sm-10"><pre style="white-space: pre-wrap;" th:text="${apiLog.getException()}"></pre></div> | |
93 | + </div> | |
94 | + </div> | |
95 | +</div> | |
96 | +<th:block th:include="include :: footer"/> | |
97 | +<th:block th:include="include :: datetimepicker-js"/> | |
98 | +<script th:inline="javascript"> | |
99 | + var prefix = ctx + "apilog/apilog"; | |
100 | + function parseJson(obj){ | |
101 | + var str = obj.innerHTML | |
102 | + try { | |
103 | + str = JSON.parse(str); | |
104 | + obj.innerHTML = JSON.stringify(str, null, 2); | |
105 | + }catch (e) { | |
106 | + str = str.split("&").join(" ") | |
107 | + obj.innerHTML = str; | |
108 | + } | |
109 | + } | |
110 | + | |
111 | + parseJson(document.getElementById("preReqBody")) | |
112 | + parseJson(document.getElementById("preRespBody")) | |
113 | +</script> | |
114 | +</body> | |
115 | +</html> | |
0 | 116 | \ No newline at end of file |
... | ... |