From 5a003a42d2b34e8362910ac1d3e5a8866768e5fe Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期六, 20 十二月 2025 16:50:28 +0800
Subject: [PATCH] 2025.12.20 巡查任务统计相关功能修改
---
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