1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| package cn.flightfeather.supervision.lightshare.web
|
| import cn.flightfeather.supervision.lightshare.vo.BaseResponse
| import cn.flightfeather.supervision.lightshare.vo.DataHead
|
| /**
| * 包装接口返回结果
| */
| fun resPack(service: () -> Any?): BaseResponse<Any> {
| return try {
| val res = service()
| 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)
| }
| } catch (e: IllegalStateException) {
| BaseResponse(false, message = e.message ?: "")
| }
| }
|
|