parent
cdc20eeb00
commit
aa8a25ef43
@ -1,4 +1,4 @@
|
||||
## TODO
|
||||
|
||||
- [ ] 添加按Key名查找接口
|
||||
- [x] 添加按Key名查找接口
|
||||
- [ ] 添加模糊查询接口
|
@ -0,0 +1,36 @@
|
||||
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,
|
||||
})
|
||||
}
|
Loading…
Reference in new issue