更改:blame接口响应结构体

This commit is contained in:
yystopf 2023-01-03 11:43:37 +08:00
parent 484a4ce01a
commit a6a662c6e3
1 changed files with 12 additions and 3 deletions

View File

@ -9,6 +9,13 @@ import (
hat_api "code.gitlink.org.cn/Gitlink/gitea_hat.git/modules/structs"
)
type APIBlameResponse struct {
FileSize int64 `json:"file_size"`
FileName string `json:"file_name"`
NumberLines int `json:"num_lines"`
BlameParts []hat_api.BlamePart `json:"blame_parts"`
}
func GetRepoRefBlame(ctx *context.APIContext) {
if ctx.Repo.Repository.IsEmpty {
ctx.NotFound()
@ -64,8 +71,10 @@ func GetRepoRefBlame(ctx *context.APIContext) {
blameParts = append(blameParts, *blamePart)
currentNumber += blamePart.EffectLine
}
ctx.JSON(http.StatusOK, map[string]interface{}{
"num_lines": numLines,
"blame_parts": blameParts,
ctx.JSON(http.StatusOK, APIBlameResponse{
FileSize: blob.Size(),
FileName: blob.Name(),
NumberLines: numLines,
BlameParts: blameParts,
})
}