@@ -46,7 +46,7 @@ type workspaceDTO struct {
46
46
Type string `db:"type"`
47
47
Title string `db:"title"`
48
48
Data sql.NullString `db:"data"`
49
- Sort int64 `db:"sort"`
49
+ Sort int `db:"sort"`
50
50
Expanded bool `db:"expanded"`
51
51
}
52
52
@@ -64,6 +64,9 @@ func newWorkspaceDTO(in *entity.Workspace) (dto *workspaceDTO, err error) {
64
64
}
65
65
dto .Data = types .StringToSQL (string (data ))
66
66
}
67
+ if in .Sort != nil {
68
+ dto .Sort = * in .Sort
69
+ }
67
70
68
71
return
69
72
}
@@ -75,6 +78,7 @@ func (dto *workspaceDTO) entity() (*entity.Workspace, error) {
75
78
HasChild : & dto .HasChild ,
76
79
Type : entity .WorkspaceType (dto .Type ),
77
80
Title : dto .Title ,
81
+ Sort : & dto .Sort ,
78
82
Expanded : & dto .Expanded ,
79
83
}
80
84
@@ -168,7 +172,7 @@ func (repo *WorkspaceRepository) Get() ([]*entity.Workspace, error) {
168
172
err := repo .db .Connector .SelectContext (repo .ctx , & dto , fmt .Sprintf (`
169
173
SELECT %s
170
174
FROM %s
171
- ORDER BY type, sort;` , workspaceTableFields , workspaceTable ))
175
+ ORDER BY type, sort, created_at ;` , workspaceTableFields , workspaceTable ))
172
176
if err != nil {
173
177
return nil , err
174
178
}
@@ -197,8 +201,8 @@ func (repo *WorkspaceRepository) Create(in *entity.Workspace) (*entity.Workspace
197
201
defer repo .commit (tx , err )
198
202
199
203
query , args , err = tx .BindNamed (fmt .Sprintf (`
200
- INSERT INTO %s (parent_id, has_child, type, title, data)
201
- VALUES (:parent_id, :has_child, :type, :title, :data)
204
+ INSERT INTO %s (parent_id, has_child, type, title, data, sort )
205
+ VALUES (:parent_id, :has_child, :type, :title, :data, :sort )
202
206
RETURNING %s;` , workspaceTable , workspaceTableFields ), dto )
203
207
if err != nil {
204
208
return nil , err
0 commit comments