From 85c5fafda53f21697499ff0587ff6dc0f2b00f0a Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 16 三月 2023 09:34:20 +0800
Subject: [PATCH] 更新前后端分离部署文档
---
src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java | 60 +++++++++++++++++++++++-------------------------------------
1 files changed, 23 insertions(+), 37 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java
index a9b23ef..3cabb99 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java
@@ -1,27 +1,23 @@
package com.genersoft.iot.vmp.vmanager.log;
import com.genersoft.iot.vmp.conf.UserSetting;
+import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.service.ILogService;
import com.genersoft.iot.vmp.storager.dao.dto.LogDto;
import com.genersoft.iot.vmp.utils.DateUtil;
-import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
+import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.github.pagehelper.PageInfo;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.util.StringUtils;
+import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
-import java.text.ParseException;
+@Tag(name = "鏃ュ織绠$悊")
-@Api(tags = "鏃ュ織绠$悊")
-@CrossOrigin
@RestController
@RequestMapping("/api/log")
public class LogController {
@@ -45,17 +41,15 @@
* @param endTime 缁撴潫鏃堕棿
* @return
*/
- @ApiOperation("鍒嗛〉鏌ヨ鎶ヨ")
@GetMapping("/all")
- @ApiImplicitParams({
- @ApiImplicitParam(name="query", value = "鏌ヨ鍐呭", dataTypeClass = String.class),
- @ApiImplicitParam(name="page", value = "褰撳墠椤�", required = true ,dataTypeClass = Integer.class),
- @ApiImplicitParam(name="count", value = "姣忛〉鏌ヨ鏁伴噺", required = true ,dataTypeClass = Integer.class),
- @ApiImplicitParam(name="type", value = "绫诲瀷" ,dataTypeClass = String.class),
- @ApiImplicitParam(name="startTime", value = "鏌ヨ鍐呭" ,dataTypeClass = String.class),
- @ApiImplicitParam(name="endTime", value = "鏌ヨ鍐呭" ,dataTypeClass = String.class),
- })
- public ResponseEntity<PageInfo<LogDto>> getAll(
+ @Operation(summary = "鍒嗛〉鏌ヨ鎶ヨ")
+ @Parameter(name = "query", description = "鏌ヨ鍐呭", required = true)
+ @Parameter(name = "page", description = "褰撳墠椤�", required = true)
+ @Parameter(name = "count", description = "姣忛〉鏌ヨ鏁伴噺", required = true)
+ @Parameter(name = "type", description = "绫诲瀷", required = true)
+ @Parameter(name = "startTime", description = "寮�濮嬫椂闂�", required = true)
+ @Parameter(name = "endTime", description = "缁撴潫鏃堕棿", required = true)
+ public PageInfo<LogDto> getAll(
@RequestParam int page,
@RequestParam int count,
@RequestParam(required = false) String query,
@@ -63,13 +57,13 @@
@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime
) {
- if (StringUtils.isEmpty(query)) {
+ if (ObjectUtils.isEmpty(query)) {
query = null;
}
- if (StringUtils.isEmpty(startTime)) {
+ if (ObjectUtils.isEmpty(startTime)) {
startTime = null;
}
- if (StringUtils.isEmpty(endTime)) {
+ if (ObjectUtils.isEmpty(endTime)) {
endTime = null;
}
if (!userSetting.getLogInDatebase()) {
@@ -77,28 +71,20 @@
}
if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){
- return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
+ throw new ControllerException(ErrorCode.ERROR400);
}
- PageInfo<LogDto> allLog = logService.getAll(page, count, query, type, startTime, endTime);
- return new ResponseEntity<>(allLog, HttpStatus.OK);
+ return logService.getAll(page, count, query, type, startTime, endTime);
}
/**
* 娓呯┖鏃ュ織
*
*/
- @ApiOperation("娓呯┖鏃ュ織")
+ @Operation(summary = "鍋滄瑙嗛鍥炴斁")
@DeleteMapping("/clear")
- @ApiImplicitParams({})
- public ResponseEntity<WVPResult<String>> clear() {
-
- int count = logService.clear();
- WVPResult wvpResult = new WVPResult();
- wvpResult.setCode(0);
- wvpResult.setMsg("success");
- wvpResult.setData(count);
- return new ResponseEntity<WVPResult<String>>(wvpResult, HttpStatus.OK);
+ public void clear() {
+ logService.clear();
}
}
--
Gitblit v1.8.0