Skip to content

Commit 21d7da1

Browse files
authored
Merge pull request #102 from jiaozifs/feat/change_time_ts
feat: change time to timestamp
2 parents 4855b77 + 48fe896 commit 21d7da1

File tree

19 files changed

+299
-300
lines changed

19 files changed

+299
-300
lines changed

api/jiaozifs.gen.go

Lines changed: 112 additions & 117 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger.yml

Lines changed: 56 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,21 @@ components:
2626
schema:
2727
type: string
2828

29-
PaginationBranchAfter:
29+
PaginationStringAfter:
3030
in: query
3131
name: after
3232
description: return items after this value
3333
schema:
3434
type: string
3535

36-
PaginationRepoAfter:
36+
PaginationInt64After:
3737
in: query
3838
name: after
3939
description: return items after this value
4040
schema:
41-
type: string
42-
format: date-time
43-
44-
PaginationCommitAfter:
45-
in: query
46-
name: after
47-
description: return items after this value
48-
schema:
49-
type: string
50-
format: date-time-ns
41+
type: integer
42+
format: int64
43+
5144

5245
PaginationAmount:
5346
in: query
@@ -224,11 +217,11 @@ components:
224217
type: string
225218
format: uuid
226219
created_at:
227-
type: string
228-
format: date-time
220+
type: integer
221+
format: int64
229222
updated_at:
230-
type: string
231-
format: date-time
223+
type: integer
224+
format: int64
232225
MergeRequestFullState:
233226
type: object
234227
required:
@@ -278,11 +271,11 @@ components:
278271
items:
279272
$ref: "#/components/schemas/ChangePair"
280273
created_at:
281-
type: string
282-
format: date-time
274+
type: integer
275+
format: int64
283276
updated_at:
284-
type: string
285-
format: date-time
277+
type: integer
278+
format: int64
286279
MergeRequestList:
287280
type: object
288281
required:
@@ -322,11 +315,11 @@ components:
322315
type: string
323316
format: uuid
324317
created_at:
325-
type: string
326-
format: date-time
318+
type: integer
319+
format: int64
327320
updated_at:
328-
type: string
329-
format: date-time
321+
type: integer
322+
format: int64
330323
BranchList:
331324
type: object
332325
required:
@@ -405,11 +398,11 @@ components:
405398
type: string
406399
format: uuid
407400
created_at:
408-
type: string
409-
format: date-time
401+
type: integer
402+
format: int64
410403
updated_at:
411-
type: string
412-
format: date-time
404+
type: integer
405+
format: int64
413406
Blob:
414407
type: object
415408
required:
@@ -440,11 +433,11 @@ components:
440433
additionalProperties:
441434
type: string
442435
created_at:
443-
type: string
444-
format: date-time
436+
type: integer
437+
format: int64
445438
updated_at:
446-
type: string
447-
format: date-time
439+
type: integer
440+
format: int64
448441
Signature:
449442
type: object
450443
required:
@@ -458,8 +451,8 @@ components:
458451
type: string
459452
format: email
460453
when:
461-
type: string
462-
format: date-time
454+
type: integer
455+
format: int64
463456
Commit:
464457
type: object
465458
required:
@@ -494,11 +487,11 @@ components:
494487
items:
495488
type: string
496489
created_at:
497-
type: string
498-
format: date-time
490+
type: integer
491+
format: int64
499492
updated_at:
500-
type: string
501-
format: date-time
493+
type: integer
494+
format: int64
502495
TreeEntry:
503496
type: object
504497
required:
@@ -532,11 +525,11 @@ components:
532525
type: integer
533526
format: int64
534527
created_at:
535-
type: string
536-
format: date-time
528+
type: integer
529+
format: int64
537530
updated_at:
538-
type: string
539-
format: date-time
531+
type: integer
532+
format: int64
540533
TreeNode:
541534
type: object
542535
required:
@@ -565,11 +558,11 @@ components:
565558
items:
566559
$ref: "#/components/schemas/TreeEntry"
567560
created_at:
568-
type: string
569-
format: date-time
561+
type: integer
562+
format: int64
570563
updated_at:
571-
type: string
572-
format: date-time
564+
type: integer
565+
format: int64
573566
Wip:
574567
type: object
575568
required:
@@ -603,11 +596,11 @@ components:
603596
type: string
604597
format: uuid
605598
created_at:
606-
type: string
607-
format: date-time
599+
type: integer
600+
format: int64
608601
updated_at:
609-
type: string
610-
format: date-time
602+
type: integer
603+
format: int64
611604
UpdateWip:
612605
type: object
613606
properties:
@@ -676,23 +669,23 @@ components:
676669
type: string
677670
format: email
678671
current_sign_in_at:
679-
type: string
680-
format: date-time
672+
type: integer
673+
format: int64
681674
last_sign_in_at:
682-
type: string
683-
format: date-time
675+
type: integer
676+
format: int64
684677
current_sign_in_ip:
685678
type: string
686679
format: ipv4
687680
last_sign_in_ip:
688681
type: string
689682
format: ipv4
690683
created_at:
691-
type: string
692-
format: date-time
684+
type: integer
685+
format: int64
693686
updated_at:
694-
type: string
695-
format: date-time
687+
type: integer
688+
format: int64
696689
UserRegisterInfo:
697690
type: object
698691
required:
@@ -1560,7 +1553,7 @@ paths:
15601553
operationId: getCommitsInRef
15611554
summary: get commits in ref
15621555
parameters:
1563-
- $ref: "#/components/parameters/PaginationCommitAfter"
1556+
- $ref: "#/components/parameters/PaginationInt64After"
15641557
- $ref: "#/components/parameters/PaginationAmount"
15651558
- in: query
15661559
name: refName
@@ -1662,7 +1655,7 @@ paths:
16621655
operationId: listMergeRequests
16631656
summary: get list of merge request in repository
16641657
parameters:
1665-
- $ref: "#/components/parameters/PaginationRepoAfter"
1658+
- $ref: "#/components/parameters/PaginationInt64After"
16661659
- $ref: "#/components/parameters/PaginationAmount"
16671660
- in: query
16681661
name: state
@@ -1833,7 +1826,7 @@ paths:
18331826
summary: list repository in specific owner
18341827
parameters:
18351828
- $ref: "#/components/parameters/PaginationPrefix"
1836-
- $ref: "#/components/parameters/PaginationRepoAfter"
1829+
- $ref: "#/components/parameters/PaginationInt64After"
18371830
- $ref: "#/components/parameters/PaginationAmount"
18381831
responses:
18391832
200:
@@ -1857,7 +1850,7 @@ paths:
18571850
summary: list repository
18581851
parameters:
18591852
- $ref: "#/components/parameters/PaginationPrefix"
1860-
- $ref: "#/components/parameters/PaginationRepoAfter"
1853+
- $ref: "#/components/parameters/PaginationInt64After"
18611854
- $ref: "#/components/parameters/PaginationAmount"
18621855
responses:
18631856
200:
@@ -1918,7 +1911,7 @@ paths:
19181911
summary: list branches
19191912
parameters:
19201913
- $ref: "#/components/parameters/PaginationPrefix"
1921-
- $ref: "#/components/parameters/PaginationBranchAfter"
1914+
- $ref: "#/components/parameters/PaginationStringAfter"
19221915
- $ref: "#/components/parameters/PaginationAmount"
19231916
responses:
19241917
200:

controller/branch_ctl.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ func (bct BranchController) ListBranches(ctx context.Context, w *api.JiaozifsRes
103103
for _, branch := range branches {
104104
r := api.Branch{
105105
CommitHash: branch.CommitHash.Hex(),
106-
CreatedAt: branch.CreatedAt,
106+
CreatedAt: branch.CreatedAt.UnixMilli(),
107107
CreatorId: branch.CreatorID,
108108
Description: branch.Description,
109109
Id: branch.ID,
110110
Name: branch.Name,
111111
RepositoryId: branch.RepositoryID,
112-
UpdatedAt: branch.UpdatedAt,
112+
UpdatedAt: branch.UpdatedAt.UnixMilli(),
113113
}
114114
results = append(results, r)
115115
}
@@ -183,13 +183,13 @@ func (bct BranchController) CreateBranch(ctx context.Context, w *api.JiaozifsRes
183183

184184
w.JSON(api.Branch{
185185
CommitHash: newBranch.CommitHash.Hex(),
186-
CreatedAt: newBranch.CreatedAt,
186+
CreatedAt: newBranch.CreatedAt.UnixMilli(),
187187
CreatorId: newBranch.CreatorID,
188188
Description: newBranch.Description,
189189
Id: newBranch.ID,
190190
Name: newBranch.Name,
191191
RepositoryId: newBranch.RepositoryID,
192-
UpdatedAt: newBranch.UpdatedAt,
192+
UpdatedAt: newBranch.UpdatedAt.UnixMilli(),
193193
}, http.StatusCreated)
194194
}
195195

@@ -271,12 +271,12 @@ func (bct BranchController) GetBranch(ctx context.Context, w *api.JiaozifsRespon
271271
}
272272
w.JSON(api.Branch{
273273
CommitHash: ref.CommitHash.Hex(),
274-
CreatedAt: ref.CreatedAt,
274+
CreatedAt: ref.CreatedAt.UnixMilli(),
275275
CreatorId: ref.CreatorID,
276276
Description: ref.Description,
277277
Id: ref.ID,
278278
Name: ref.Name,
279279
RepositoryId: ref.RepositoryID,
280-
UpdatedAt: ref.UpdatedAt,
280+
UpdatedAt: ref.UpdatedAt.UnixMilli(),
281281
})
282282
}

controller/commit_ctl.go

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"net/http"
88
"strings"
99

10+
openapi_types "github.com/oapi-codegen/runtime/types"
11+
1012
"github.com/jiaozifs/jiaozifs/api"
1113
"github.com/jiaozifs/jiaozifs/auth"
1214
"github.com/jiaozifs/jiaozifs/block/params"
@@ -123,7 +125,18 @@ func (commitCtl CommitController) GetEntriesInRef(ctx context.Context, w *api.Ji
123125
w.Error(err)
124126
return
125127
}
126-
w.JSON(treeEntry)
128+
apiTreeEntries := make([]api.FullTreeEntry, len(treeEntry))
129+
for index, entry := range treeEntry {
130+
apiTreeEntries[index] = api.FullTreeEntry{
131+
CreatedAt: entry.CreatedAt.UnixMilli(),
132+
Hash: entry.Hash.Hex(),
133+
IsDir: entry.IsDir,
134+
Name: entry.Name,
135+
Size: entry.Size,
136+
UpdatedAt: entry.UpdatedAt.UnixMilli(),
137+
}
138+
}
139+
w.JSON(apiTreeEntries)
127140
}
128141

129142
func (commitCtl CommitController) CompareCommit(ctx context.Context, w *api.JiaozifsResponse, _ *http.Request, ownerName string, repositoryName string, basehead string, params api.CompareCommitParams) {
@@ -237,3 +250,26 @@ func (commitCtl CommitController) GetCommitChanges(ctx context.Context, w *api.J
237250
}
238251
w.JSON(changesResp)
239252
}
253+
254+
func commitToDto(commit *models.Commit) *api.Commit {
255+
return &api.Commit{
256+
Author: api.Signature{
257+
Email: openapi_types.Email(commit.Author.Email),
258+
Name: commit.Author.Name,
259+
When: commit.Author.When.UnixMilli(),
260+
},
261+
Committer: api.Signature{
262+
Email: openapi_types.Email(commit.Committer.Email),
263+
Name: commit.Committer.Name,
264+
When: commit.Committer.When.UnixMilli(),
265+
},
266+
CreatedAt: commit.CreatedAt.UnixMilli(),
267+
Hash: commit.Hash.Hex(),
268+
MergeTag: commit.MergeTag,
269+
Message: commit.Message,
270+
ParentHashes: hash.HexArrayOfHashes(commit.ParentHashes...),
271+
RepositoryId: commit.RepositoryID,
272+
TreeHash: commit.TreeHash.Hex(),
273+
UpdatedAt: commit.UpdatedAt.UnixMilli(),
274+
}
275+
}

0 commit comments

Comments
 (0)