From 0f7b47105d80fb9a260486270cf925a232e74791 Mon Sep 17 00:00:00 2001
From: Riku <risaku@163.com>
Date: 星期一, 22 十二月 2025 21:20:13 +0800
Subject: [PATCH] 2025.12.22 1. 修改日任务统计接口,新增当天内整改问题数和48小时内整改问题数统计
---
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/BaseResponse.kt | 29 ++++++++++++++++++++++++++++-
1 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/BaseResponse.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/BaseResponse.kt
index cd80b71..7672db8 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/BaseResponse.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/BaseResponse.kt
@@ -14,12 +14,16 @@
data class BaseResponse<T>(
@ApiModelProperty("璇锋眰鏄惁鎴愬姛")
var success: Boolean,
+ @ApiModelProperty("璇锋眰杩斿洖鐘舵�佺爜")
+ var code: String = "200",
@ApiModelProperty("璇锋眰杩斿洖娑堟伅")
var message: String = "",
+ @ApiModelProperty("璇锋眰杩斿洖鏁版嵁澶�")
val head: DataHead? = null,
@ApiModelProperty("璇锋眰杩斿洖鏁版嵁")
val data: T? = null,
- var stackTrace: String = ""
+ @ApiModelProperty("璇锋眰杩斿洖寮傚父鏍堜俊鎭�")
+ var stackTrace: String = "",
) {
init {
if (message.isBlank()) {
@@ -30,4 +34,27 @@
}
}
}
+
+ companion object {
+ fun success(res: Any?): BaseResponse<Any> {
+ return if (res is Pair<*, *>) {
+ val head = res.first
+ if (head is DataHead) {
+ BaseResponse(true, head = head, data = res.second)
+ } else {
+ BaseResponse(true, data = res)
+ }
+ } else {
+ BaseResponse(true, data = res)
+ }
+ }
+
+ fun <T> fail(code: String = "500", message: String = "璇锋眰澶辫触"): BaseResponse<T> {
+ return BaseResponse(false, code, message)
+ }
+
+ fun <T> fail(code: String = "500", e: Exception): BaseResponse<T> {
+ return BaseResponse(false, code, e.message ?: "", stackTrace = e.stackTraceToString())
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3