Skip to content

Commit eb7ee5e

Browse files
authored
refactor(timesheet): update data types for entity ID and timesheet ID (#148)
- Change EntityID from int to int64 in CreateTimesheetRequest, GetTimesheetsRequest, GetTimesheetsCountRequest, and UpdateTimesheetRequest - Update test cases to use int64 for EntityID and timesheet ID - This change improves compatibility with large entity IDs and timesheet IDs Signed-off-by: Flc <four_leaf_clover@foxmail.com>
1 parent 82db2f8 commit eb7ee5e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

api_timesheet.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type TimesheetService struct {
3131

3232
type CreateTimesheetRequest struct {
3333
EntityType *EntityType `json:"entity_type,omitempty"` // [必须]对象类型,如story、task、bug等
34-
EntityID *int `json:"entity_id,omitempty"` // [必须]对象ID
34+
EntityID *int64 `json:"entity_id,omitempty"` // [必须]对象ID
3535
Timespent *string `json:"timespent,omitempty"` // [必须]花费工时
3636
Timeremain *string `json:"timeremain,omitempty"` // 剩余工时
3737
Spentdate *string `json:"spentdate,omitempty"` // 花费日期
@@ -67,7 +67,7 @@ func (s *TimesheetService) CreateTimesheet(
6767

6868
type GetTimesheetsRequest struct {
6969
// [可选]id 支持多ID查询
70-
ID *Multi[int] `url:"id,omitempty"`
70+
ID *Multi[int64] `url:"id,omitempty"`
7171

7272
// [必选]项目ID
7373
WorkspaceID *int `url:"workspace_id,omitempty"`
@@ -76,7 +76,7 @@ type GetTimesheetsRequest struct {
7676
EntityType *EntityType `url:"entity_type,omitempty"`
7777

7878
// [可选]对象ID
79-
EntityID *int `url:"entity_id,omitempty"`
79+
EntityID *int64 `url:"entity_id,omitempty"`
8080

8181
// [可选]花费工时
8282
Timespent *string `url:"timespent,omitempty"`
@@ -147,7 +147,7 @@ func (s *TimesheetService) GetTimesheets(
147147

148148
type GetTimesheetsCountRequest struct {
149149
// [可选]id 支持多ID查询
150-
ID *Multi[int] `url:"id,omitempty"`
150+
ID *Multi[int64] `url:"id,omitempty"`
151151

152152
// [必选]项目ID
153153
WorkspaceID *int `url:"workspace_id,omitempty"`
@@ -156,7 +156,7 @@ type GetTimesheetsCountRequest struct {
156156
EntityType *EntityType `url:"entity_type,omitempty"`
157157

158158
// [可选]对象ID
159-
EntityID *int `url:"entity_id,omitempty"`
159+
EntityID *int64 `url:"entity_id,omitempty"`
160160

161161
// [可选]花费工时
162162
Timespent *string `url:"timespent,omitempty"`
@@ -207,7 +207,7 @@ func (s *TimesheetService) GetTimesheetsCount(
207207
// -----------------------------------------------------------------------------
208208

209209
type UpdateTimesheetRequest struct {
210-
ID *int `json:"id"` // [必须]工时花费ID
210+
ID *int64 `json:"id"` // [必须]工时花费ID
211211
Timespent *string `json:"timespent,omitempty"` // [可选]花费工时
212212
Timeremain *string `json:"timeremain,omitempty"` // [可选]剩余工时
213213
WorkspaceID *int `json:"workspace_id,omitempty"` // [必须]项目ID

api_timesheet_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestTimesheetService_CreateTimesheet(t *testing.T) {
3939

4040
timesheet, _, err := client.TimesheetService.CreateTimesheet(ctx, &CreateTimesheetRequest{
4141
EntityType: Ptr(EntityTypeStory),
42-
EntityID: Ptr(11223344),
42+
EntityID: Ptr[int64](11223344),
4343
Timespent: Ptr("2"),
4444
Timeremain: Ptr("0"),
4545
Spentdate: Ptr("2024-08-22"),
@@ -88,7 +88,7 @@ func TestTimesheetService_GetTimesheets(t *testing.T) {
8888
timesheets, _, err := client.TimesheetService.GetTimesheets(ctx, &GetTimesheetsRequest{
8989
WorkspaceID: Ptr(11112222),
9090
EntityType: Ptr(EntityTypeStory),
91-
EntityID: Ptr(111111222222),
91+
EntityID: Ptr[int64](111111222222),
9292
Timespent: Ptr("2"),
9393
Spentdate: Ptr("2024-08-22"),
9494
Modified: Ptr("2024-08-22"),
@@ -141,7 +141,7 @@ func TestTimesheetService_GetTimesheetsCount(t *testing.T) {
141141
count, _, err := client.TimesheetService.GetTimesheetsCount(ctx, &GetTimesheetsCountRequest{
142142
WorkspaceID: Ptr(11112222),
143143
EntityType: Ptr(EntityTypeStory),
144-
EntityID: Ptr(111111222222),
144+
EntityID: Ptr[int64](111111222222),
145145
Timespent: Ptr("2"),
146146
Spentdate: Ptr("2024-08-22"),
147147
Modified: Ptr("2024-08-22"),
@@ -178,7 +178,7 @@ func TestTimesheetService_UpdateTimesheet(t *testing.T) {
178178
}))
179179

180180
timesheet, _, err := client.TimesheetService.UpdateTimesheet(ctx, &UpdateTimesheetRequest{
181-
ID: Ptr(1134190502001044767),
181+
ID: Ptr[int64](1134190502001044767),
182182
Timespent: Ptr("2"),
183183
Timeremain: Ptr("0"),
184184
WorkspaceID: Ptr(11112222),

0 commit comments

Comments
 (0)