You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
843 B
37 lines
843 B
3 years ago
|
package api
|
||
|
|
||
|
import (
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"net/http"
|
||
|
"zggsong.cn/sandstone/server/dao"
|
||
|
"zggsong.cn/sandstone/server/response"
|
||
|
"zggsong.cn/sandstone/server/util"
|
||
|
)
|
||
|
|
||
|
func GetRecord(ctx *gin.Context) {
|
||
|
keyName := ctx.GetHeader("keyName")
|
||
|
record := dao.GetRecord(keyName)
|
||
|
if record.KeyName == "" {
|
||
|
ctx.JSON(http.StatusOK, response.Response{
|
||
|
Code: http.StatusOK,
|
||
|
Message: "没有数据",
|
||
|
Data: nil,
|
||
|
})
|
||
|
return
|
||
|
}
|
||
|
var data response.Data
|
||
|
data.KeyName = record.KeyName
|
||
|
data.Size = record.Size
|
||
|
data.CreateTime = record.CreateTime
|
||
|
data.UploadTime = record.UploadTime
|
||
|
data.Line = record.Line
|
||
|
data.Machine = record.Machine
|
||
|
data.Url = util.GetUrl(record.KeyName)
|
||
|
data.Tags = util.GetTags(record.KeyName)
|
||
|
ctx.JSON(http.StatusOK, response.GetResponse{
|
||
|
Code: 200,
|
||
|
Message: "success",
|
||
|
Data: data,
|
||
|
})
|
||
|
}
|