User trace report can contains messages
This commit is contained in:
parent
1348678be1
commit
49dd674f72
2 changed files with 20 additions and 9 deletions
18
works.go
18
works.go
|
@ -375,8 +375,9 @@ func declareAPIAdminWorksRoutes(router *gin.RouterGroup) {
|
|||
}
|
||||
|
||||
type UserTraceItem struct {
|
||||
Title string `json:"title"`
|
||||
Status string `json:"status"`
|
||||
Title string `json:"title"`
|
||||
Status string `json:"status"`
|
||||
Message string `json:"msg,omitempty"`
|
||||
}
|
||||
|
||||
type UserTrace struct {
|
||||
|
@ -516,14 +517,19 @@ func declareAPIAuthWorksRoutes(router *gin.RouterGroup) {
|
|||
items := []UserTraceItem{}
|
||||
for _, line := range result {
|
||||
if strings.HasPrefix(line.Message, "report:") {
|
||||
tmp := strings.Split(strings.TrimSpace(line.Message), ":")
|
||||
if len(tmp) != 3 {
|
||||
tmp := strings.SplitN(strings.TrimSpace(line.Message), ":", 4)
|
||||
if len(tmp) < 3 {
|
||||
continue
|
||||
}
|
||||
items = append(items, UserTraceItem{
|
||||
|
||||
uti := UserTraceItem{
|
||||
Title: tmp[1],
|
||||
Status: tmp[2],
|
||||
})
|
||||
}
|
||||
if len(tmp) >= 4 {
|
||||
uti.Message = tmp[3]
|
||||
}
|
||||
items = append(items, uti)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue