Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskcenter
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
taskcenter
Commits
21aed002
Commit
21aed002
authored
Jan 13, 2025
by
贾浩@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add submitTimestamp
parent
7bcec231
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
25 deletions
+27
-25
db.go
dao/db.go
+6
-6
api.go
model/api/api.go
+15
-14
task.go
server/task.go
+2
-2
group.go
service/group.go
+2
-1
task.go
service/task.go
+2
-2
No files found.
dao/db.go
View file @
21aed002
...
@@ -136,28 +136,28 @@ func (d *Dao) IsTaskDone(tid int, userId string) (ok bool, err error) {
...
@@ -136,28 +136,28 @@ func (d *Dao) IsTaskDone(tid int, userId string) (ok bool, err error) {
return
count
>
0
,
err
return
count
>
0
,
err
}
}
func
(
d
*
Dao
)
GetTaskResult
(
tid
int
,
userId
string
)
(
status
string
,
err
error
)
{
func
(
d
*
Dao
)
GetTaskResult
(
tid
int
,
userId
string
)
(
status
string
,
createdAt
time
.
Time
,
err
error
)
{
isDailyTask
,
err
:=
d
.
IsDailyTask
(
tid
)
isDailyTask
,
err
:=
d
.
IsDailyTask
(
tid
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
time
.
Time
{},
err
}
}
temp
:=
&
dbModel
.
TaskHistory
{}
temp
:=
&
dbModel
.
TaskHistory
{}
tx
:=
d
.
db
.
Session
(
&
gorm
.
Session
{
Logger
:
logger
.
Default
.
LogMode
(
logger
.
Silent
)})
tx
:=
d
.
db
.
Session
(
&
gorm
.
Session
{
Logger
:
logger
.
Default
.
LogMode
(
logger
.
Silent
)})
if
!
isDailyTask
{
if
!
isDailyTask
{
err
=
tx
.
Model
(
&
dbModel
.
TaskHistory
{})
.
Where
(
"task_id = ? and user_id = ?"
,
tid
,
userId
)
.
First
(
temp
)
.
Error
err
=
tx
.
Model
(
&
dbModel
.
TaskHistory
{})
.
Where
(
"task_id = ? and user_id = ?"
,
tid
,
userId
)
.
First
(
temp
)
.
Error
if
err
==
gorm
.
ErrRecordNotFound
{
if
err
==
gorm
.
ErrRecordNotFound
{
return
constant
.
TaskHistoryStatusTodo
,
nil
return
constant
.
TaskHistoryStatusTodo
,
time
.
Time
{},
nil
}
}
return
temp
.
Status
,
err
return
temp
.
Status
,
temp
.
CreatedAt
,
err
}
}
err
=
tx
.
Model
(
&
dbModel
.
TaskHistory
{})
.
err
=
tx
.
Model
(
&
dbModel
.
TaskHistory
{})
.
Where
(
"task_id = ? and user_id = ? and created_at >= ?"
,
tid
,
userId
,
time
.
Now
()
.
UTC
()
.
Truncate
(
24
*
time
.
Hour
))
.
Where
(
"task_id = ? and user_id = ? and created_at >= ?"
,
tid
,
userId
,
time
.
Now
()
.
UTC
()
.
Truncate
(
24
*
time
.
Hour
))
.
First
(
temp
)
.
Error
First
(
temp
)
.
Error
if
err
==
gorm
.
ErrRecordNotFound
{
if
err
==
gorm
.
ErrRecordNotFound
{
return
constant
.
TaskHistoryStatusTodo
,
nil
return
constant
.
TaskHistoryStatusTodo
,
time
.
Time
{},
nil
}
}
return
temp
.
Status
,
err
return
temp
.
Status
,
temp
.
CreatedAt
,
err
}
}
func
(
d
*
Dao
)
CreateTaskHistory
(
taskId
int
,
userId
string
,
isDailyTask
bool
,
initStatus
string
)
(
exist
bool
,
err
error
)
{
func
(
d
*
Dao
)
CreateTaskHistory
(
taskId
int
,
userId
string
,
isDailyTask
bool
,
initStatus
string
)
(
exist
bool
,
err
error
)
{
...
...
model/api/api.go
View file @
21aed002
...
@@ -46,20 +46,21 @@ type CreateGroupRequest struct {
...
@@ -46,20 +46,21 @@ type CreateGroupRequest struct {
}
}
type
Task
struct
{
type
Task
struct
{
TaskId
interface
{}
`json:"taskId,omitempty"`
TaskId
interface
{}
`json:"taskId,omitempty"`
Platform
string
`json:"platform" binding:"required"`
Platform
string
`json:"platform" binding:"required"`
Action
string
`json:"action" binding:"required"`
Action
string
`json:"action" binding:"required"`
Url
string
`json:"url"`
Url
string
`json:"url"`
TweetId
int
`json:"tweetId"`
TweetId
int
`json:"tweetId"`
Description
string
`json:"description" binding:"required"`
Description
string
`json:"description" binding:"required"`
Reward
int
`json:"reward" binding:"required"`
Reward
int
`json:"reward" binding:"required"`
Start
int
`json:"start" binding:"required"`
Start
int
`json:"start" binding:"required"`
End
int
`json:"end" binding:"required"`
End
int
`json:"end" binding:"required"`
Daily
bool
`json:"daily" binding:"required"`
Daily
bool
`json:"daily" binding:"required"`
Status
string
`json:"status"`
Status
string
`json:"status"`
TelegramActiveThreshold
int
`json:"telegramActiveThreshold"`
// 仅电报活跃可用
TelegramActiveThreshold
int
`json:"telegramActiveThreshold"`
// 仅电报活跃可用
Enable
bool
`json:"enable"`
Enable
bool
`json:"enable"`
Msg
string
`json:"msg"`
Msg
string
`json:"msg"`
SubmitTimestamp
int
`json:"submitTimestamp"`
}
}
type
CreateTaskRequest
struct
{
type
CreateTaskRequest
struct
{
...
...
server/task.go
View file @
21aed002
...
@@ -79,7 +79,7 @@ func checkTask(c *gin.Context) {
...
@@ -79,7 +79,7 @@ func checkTask(c *gin.Context) {
return
return
}
}
status
,
err
:=
srv
.
GetTaskResult
(
taskId
,
userId
)
status
,
_
,
err
:=
srv
.
GetTaskResult
(
taskId
,
userId
)
if
err
!=
nil
{
if
err
!=
nil
{
c
.
JSON
(
200
,
withError
(
constant
.
InternalError
))
c
.
JSON
(
200
,
withError
(
constant
.
InternalError
))
return
return
...
@@ -117,7 +117,7 @@ func submitTask(c *gin.Context) {
...
@@ -117,7 +117,7 @@ func submitTask(c *gin.Context) {
return
return
}
}
status
,
err
:=
srv
.
GetTaskResult
(
taskId
,
userId
)
status
,
_
,
err
:=
srv
.
GetTaskResult
(
taskId
,
userId
)
if
err
!=
nil
{
if
err
!=
nil
{
c
.
JSON
(
200
,
withError
(
constant
.
InternalError
))
c
.
JSON
(
200
,
withError
(
constant
.
InternalError
))
return
return
...
...
service/group.go
View file @
21aed002
...
@@ -74,7 +74,7 @@ func (s *Service) GetGroup(gid int, userId string, admin bool) (resp *apiModel.G
...
@@ -74,7 +74,7 @@ func (s *Service) GetGroup(gid int, userId string, admin bool) (resp *apiModel.G
Enable
:
task
.
Enable
,
Enable
:
task
.
Enable
,
}
}
status
,
err
:=
s
.
GetTaskResult
(
_task
.
TaskId
.
(
int
),
userId
)
status
,
createdAt
,
err
:=
s
.
GetTaskResult
(
_task
.
TaskId
.
(
int
),
userId
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"group check task"
)
log
.
WithError
(
err
)
.
Error
(
"group check task"
)
return
nil
,
err
return
nil
,
err
...
@@ -83,6 +83,7 @@ func (s *Service) GetGroup(gid int, userId string, admin bool) (resp *apiModel.G
...
@@ -83,6 +83,7 @@ func (s *Service) GetGroup(gid int, userId string, admin bool) (resp *apiModel.G
if
status
==
constant
.
TaskHistoryStatusRetry
{
if
status
==
constant
.
TaskHistoryStatusRetry
{
_task
.
Msg
=
"The task is not completed, please try again."
_task
.
Msg
=
"The task is not completed, please try again."
}
}
_task
.
SubmitTimestamp
=
int
(
createdAt
.
Unix
())
resp
.
Tasks
=
append
(
resp
.
Tasks
,
_task
)
resp
.
Tasks
=
append
(
resp
.
Tasks
,
_task
)
}
}
return
return
...
...
service/task.go
View file @
21aed002
...
@@ -149,8 +149,8 @@ func (s *Service) GetTaskDetail(taskId int) (task *dbModel.Task, err error) {
...
@@ -149,8 +149,8 @@ func (s *Service) GetTaskDetail(taskId int) (task *dbModel.Task, err error) {
return
return
}
}
func
(
s
*
Service
)
GetTaskResult
(
taskId
int
,
userId
string
)
(
status
string
,
err
error
)
{
func
(
s
*
Service
)
GetTaskResult
(
taskId
int
,
userId
string
)
(
status
string
,
createdAt
time
.
Time
,
err
error
)
{
status
,
err
=
s
.
d
.
GetTaskResult
(
taskId
,
userId
)
status
,
createdAt
,
err
=
s
.
d
.
GetTaskResult
(
taskId
,
userId
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"get task result error"
)
log
.
WithError
(
err
)
.
Error
(
"get task result error"
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment