Skip to content

Commit

Permalink
feat: change time to timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
hunjixin committed Jan 10, 2024
1 parent 3632e63 commit d85d09b
Show file tree
Hide file tree
Showing 19 changed files with 299 additions and 300 deletions.
229 changes: 112 additions & 117 deletions api/jiaozifs.gen.go

Large diffs are not rendered by default.

119 changes: 56 additions & 63 deletions api/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,21 @@ components:
schema:
type: string

PaginationBranchAfter:
PaginationStringAfter:
in: query
name: after
description: return items after this value
schema:
type: string

PaginationRepoAfter:
PaginationInt64After:
in: query
name: after
description: return items after this value
schema:
type: string
format: date-time

PaginationCommitAfter:
in: query
name: after
description: return items after this value
schema:
type: string
format: date-time-ns
type: integer
format: int64


PaginationAmount:
in: query
Expand Down Expand Up @@ -224,11 +217,11 @@ components:
type: string
format: uuid
created_at:
type: string
format: date-time
type: integer
format: int64
updated_at:
type: string
format: date-time
type: integer
format: int64
MergeRequestFullState:
type: object
required:
Expand Down Expand Up @@ -278,11 +271,11 @@ components:
items:
$ref: "#/components/schemas/ChangePair"
created_at:
type: string
format: date-time
type: integer
format: int64
updated_at:
type: string
format: date-time
type: integer
format: int64
MergeRequestList:
type: object
required:
Expand Down Expand Up @@ -322,11 +315,11 @@ components:
type: string
format: uuid
created_at:
type: string
format: date-time
type: integer
format: int64
updated_at:
type: string
format: date-time
type: integer
format: int64
BranchList:
type: object
required:
Expand Down Expand Up @@ -405,11 +398,11 @@ components:
type: string
format: uuid
created_at:
type: string
format: date-time
type: integer
format: int64
updated_at:
type: string
format: date-time
type: integer
format: int64
Blob:
type: object
required:
Expand Down Expand Up @@ -440,11 +433,11 @@ components:
additionalProperties:
type: string
created_at:
type: string
format: date-time
type: integer
format: int64
updated_at:
type: string
format: date-time
type: integer
format: int64
Signature:
type: object
required:
Expand All @@ -458,8 +451,8 @@ components:
type: string
format: email
when:
type: string
format: date-time
type: integer
format: int64
Commit:
type: object
required:
Expand Down Expand Up @@ -494,11 +487,11 @@ components:
items:
type: string
created_at:
type: string
format: date-time
type: integer
format: int64
updated_at:
type: string
format: date-time
type: integer
format: int64
TreeEntry:
type: object
required:
Expand Down Expand Up @@ -532,11 +525,11 @@ components:
type: integer
format: int64
created_at:
type: string
format: date-time
type: integer
format: int64
updated_at:
type: string
format: date-time
type: integer
format: int64
TreeNode:
type: object
required:
Expand Down Expand Up @@ -565,11 +558,11 @@ components:
items:
$ref: "#/components/schemas/TreeEntry"
created_at:
type: string
format: date-time
type: integer
format: int64
updated_at:
type: string
format: date-time
type: integer
format: int64
Wip:
type: object
required:
Expand Down Expand Up @@ -603,11 +596,11 @@ components:
type: string
format: uuid
created_at:
type: string
format: date-time
type: integer
format: int64
updated_at:
type: string
format: date-time
type: integer
format: int64
UpdateWip:
type: object
properties:
Expand Down Expand Up @@ -676,23 +669,23 @@ components:
type: string
format: email
current_sign_in_at:
type: string
format: date-time
type: integer
format: int64
last_sign_in_at:
type: string
format: date-time
type: integer
format: int64
current_sign_in_ip:
type: string
format: ipv4
last_sign_in_ip:
type: string
format: ipv4
created_at:
type: string
format: date-time
type: integer
format: int64
updated_at:
type: string
format: date-time
type: integer
format: int64
UserRegisterInfo:
type: object
required:
Expand Down Expand Up @@ -1560,7 +1553,7 @@ paths:
operationId: getCommitsInRef
summary: get commits in ref
parameters:
- $ref: "#/components/parameters/PaginationCommitAfter"
- $ref: "#/components/parameters/PaginationInt64After"
- $ref: "#/components/parameters/PaginationAmount"
- in: query
name: refName
Expand Down Expand Up @@ -1662,7 +1655,7 @@ paths:
operationId: listMergeRequests
summary: get list of merge request in repository
parameters:
- $ref: "#/components/parameters/PaginationRepoAfter"
- $ref: "#/components/parameters/PaginationInt64After"
- $ref: "#/components/parameters/PaginationAmount"
- in: query
name: state
Expand Down Expand Up @@ -1833,7 +1826,7 @@ paths:
summary: list repository in specific owner
parameters:
- $ref: "#/components/parameters/PaginationPrefix"
- $ref: "#/components/parameters/PaginationRepoAfter"
- $ref: "#/components/parameters/PaginationInt64After"
- $ref: "#/components/parameters/PaginationAmount"
responses:
200:
Expand All @@ -1857,7 +1850,7 @@ paths:
summary: list repository
parameters:
- $ref: "#/components/parameters/PaginationPrefix"
- $ref: "#/components/parameters/PaginationRepoAfter"
- $ref: "#/components/parameters/PaginationInt64After"
- $ref: "#/components/parameters/PaginationAmount"
responses:
200:
Expand Down Expand Up @@ -1918,7 +1911,7 @@ paths:
summary: list branches
parameters:
- $ref: "#/components/parameters/PaginationPrefix"
- $ref: "#/components/parameters/PaginationBranchAfter"
- $ref: "#/components/parameters/PaginationStringAfter"
- $ref: "#/components/parameters/PaginationAmount"
responses:
200:
Expand Down
12 changes: 6 additions & 6 deletions controller/branch_ctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ func (bct BranchController) ListBranches(ctx context.Context, w *api.JiaozifsRes
for _, branch := range branches {
r := api.Branch{
CommitHash: branch.CommitHash.Hex(),
CreatedAt: branch.CreatedAt,
CreatedAt: branch.CreatedAt.UnixMilli(),
CreatorId: branch.CreatorID,
Description: branch.Description,
Id: branch.ID,
Name: branch.Name,
RepositoryId: branch.RepositoryID,
UpdatedAt: branch.UpdatedAt,
UpdatedAt: branch.UpdatedAt.UnixMilli(),
}
results = append(results, r)
}
Expand Down Expand Up @@ -183,13 +183,13 @@ func (bct BranchController) CreateBranch(ctx context.Context, w *api.JiaozifsRes

w.JSON(api.Branch{
CommitHash: newBranch.CommitHash.Hex(),
CreatedAt: newBranch.CreatedAt,
CreatedAt: newBranch.CreatedAt.UnixMilli(),
CreatorId: newBranch.CreatorID,
Description: newBranch.Description,
Id: newBranch.ID,
Name: newBranch.Name,
RepositoryId: newBranch.RepositoryID,
UpdatedAt: newBranch.UpdatedAt,
UpdatedAt: newBranch.UpdatedAt.UnixMilli(),
}, http.StatusCreated)
}

Expand Down Expand Up @@ -271,12 +271,12 @@ func (bct BranchController) GetBranch(ctx context.Context, w *api.JiaozifsRespon
}
w.JSON(api.Branch{
CommitHash: ref.CommitHash.Hex(),
CreatedAt: ref.CreatedAt,
CreatedAt: ref.CreatedAt.UnixMilli(),
CreatorId: ref.CreatorID,
Description: ref.Description,
Id: ref.ID,
Name: ref.Name,
RepositoryId: ref.RepositoryID,
UpdatedAt: ref.UpdatedAt,
UpdatedAt: ref.UpdatedAt.UnixMilli(),
})
}
38 changes: 37 additions & 1 deletion controller/commit_ctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"net/http"
"strings"

openapi_types "github.com/oapi-codegen/runtime/types"

"github.com/jiaozifs/jiaozifs/api"
"github.com/jiaozifs/jiaozifs/auth"
"github.com/jiaozifs/jiaozifs/block/params"
Expand Down Expand Up @@ -123,7 +125,18 @@ func (commitCtl CommitController) GetEntriesInRef(ctx context.Context, w *api.Ji
w.Error(err)
return
}
w.JSON(treeEntry)
apiTreeEntries := make([]api.FullTreeEntry, len(treeEntry))
for index, entry := range treeEntry {
apiTreeEntries[index] = api.FullTreeEntry{
CreatedAt: entry.CreatedAt.UnixMilli(),
Hash: entry.Hash.Hex(),
IsDir: entry.IsDir,
Name: entry.Name,
Size: entry.Size,
UpdatedAt: entry.UpdatedAt.UnixMilli(),
}
}
w.JSON(apiTreeEntries)
}

func (commitCtl CommitController) CompareCommit(ctx context.Context, w *api.JiaozifsResponse, _ *http.Request, ownerName string, repositoryName string, basehead string, params api.CompareCommitParams) {
Expand Down Expand Up @@ -237,3 +250,26 @@ func (commitCtl CommitController) GetCommitChanges(ctx context.Context, w *api.J
}
w.JSON(changesResp)
}

func commitToDto(commit *models.Commit) *api.Commit {
return &api.Commit{
Author: api.Signature{
Email: openapi_types.Email(commit.Author.Email),
Name: commit.Author.Name,
When: commit.Author.When.UnixMilli(),
},
Committer: api.Signature{
Email: openapi_types.Email(commit.Committer.Email),
Name: commit.Committer.Name,
When: commit.Committer.When.UnixMilli(),
},
CreatedAt: commit.CreatedAt.UnixMilli(),
Hash: commit.Hash.Hex(),
MergeTag: commit.MergeTag,
Message: commit.Message,
ParentHashes: hash.HexArrayOfHashes(commit.ParentHashes...),
RepositoryId: commit.RepositoryID,
TreeHash: commit.TreeHash.Hex(),
UpdatedAt: commit.UpdatedAt.UnixMilli(),
}
}
Loading

0 comments on commit d85d09b

Please sign in to comment.