feat(t206): connect Android procurement tasks
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"cmroubao/backend-api/internal/domain"
|
||||
"cmroubao/backend-api/internal/transport/authcommon"
|
||||
@@ -235,8 +236,11 @@ func (handler *deviceHandlers) startTask(ctx *gin.Context) {
|
||||
}
|
||||
ctx.Header("Cache-Control", "no-store")
|
||||
ctx.JSON(http.StatusOK, gin.H{
|
||||
"task": deviceTaskResponse(result.Task),
|
||||
"execution": executionResponse(result.Execution),
|
||||
"task": deviceTaskResponse(result.Task),
|
||||
"execution": deviceExecutionResponse(
|
||||
result.Execution,
|
||||
result.Task.ClaimExpiresAt,
|
||||
),
|
||||
"replayed": result.Replayed,
|
||||
"server_time": formatTime(result.ServerTime),
|
||||
})
|
||||
@@ -275,8 +279,11 @@ func (handler *deviceHandlers) heartbeatTask(ctx *gin.Context) {
|
||||
}
|
||||
ctx.Header("Cache-Control", "no-store")
|
||||
ctx.JSON(http.StatusOK, gin.H{
|
||||
"task": deviceTaskResponse(result.Task),
|
||||
"execution": executionResponse(result.Execution),
|
||||
"task": deviceTaskResponse(result.Task),
|
||||
"execution": deviceExecutionResponse(
|
||||
result.Execution,
|
||||
result.Task.ClaimExpiresAt,
|
||||
),
|
||||
"cancel_requested": result.CancelRequested,
|
||||
"server_time": formatTime(result.ServerTime),
|
||||
})
|
||||
@@ -453,3 +460,12 @@ func deviceTaskResponse(task domain.PurchaseTask) gin.H {
|
||||
"currency": task.Currency,
|
||||
}
|
||||
}
|
||||
|
||||
func deviceExecutionResponse(
|
||||
execution domain.TaskExecution,
|
||||
expiresAt *time.Time,
|
||||
) gin.H {
|
||||
response := executionResponse(execution)
|
||||
response["execution_expires_at"] = formatOptionalTime(expiresAt)
|
||||
return response
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user