Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
contract_backend
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
contract_backend
Commits
06407ece
Commit
06407ece
authored
Nov 01, 2024
by
贾浩@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rm task.go
parent
b818ad31
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
91 deletions
+0
-91
task.go
server/task.go
+0
-91
No files found.
server/task.go
deleted
100644 → 0
View file @
b818ad31
package
server
import
(
.
"contract_backend/constant"
"contract_backend/util"
"crypto/ecdsa"
"io"
"math/big"
"github.com/gin-gonic/gin"
log
"github.com/sirupsen/logrus"
"github.com/tidwall/gjson"
)
func
taskChange
(
c
*
gin
.
Context
)
{
// 获取原始json数据
rawJson
,
err
:=
io
.
ReadAll
(
c
.
Request
.
Body
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"read body error"
)
c
.
JSON
(
200
,
withError
(
InvalidParam
))
return
}
// 判断是插入还是update
table
:=
gjson
.
Get
(
string
(
rawJson
),
"table"
)
.
String
()
if
table
!=
"exec_task"
{
log
.
WithField
(
"table"
,
table
)
.
Error
(
"wrong table"
)
c
.
JSON
(
200
,
withError
(
InvalidParam
))
return
}
var
userId
string
var
taskId
string
var
appId
string
var
modelIds
[]
string
var
key
*
ecdsa
.
PrivateKey
operation
:=
gjson
.
Get
(
string
(
rawJson
),
"operation"
)
.
String
()
switch
operation
{
case
"UPDATE"
:
userId
=
gjson
.
Get
(
string
(
rawJson
),
"new_row.user_id"
)
.
String
()
taskId
=
gjson
.
Get
(
string
(
rawJson
),
"new_row.id"
)
.
String
()
appId
=
gjson
.
Get
(
string
(
rawJson
),
"new_row.app_key"
)
.
String
()
tmp
:=
gjson
.
Get
(
string
(
rawJson
),
"new_row.model_ids"
)
.
Array
()
for
_
,
v
:=
range
tmp
{
modelIds
=
append
(
modelIds
,
v
.
String
())
}
key
,
err
=
util
.
GetPrivKeyByPriv
(
conf
.
Chain
.
XPrivateKey
,
userId
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"get private key error"
)
c
.
JSON
(
200
,
withError
(
InternalError
))
return
}
default
:
log
.
WithField
(
"operation"
,
operation
)
.
Error
(
"wrong operation"
)
c
.
JSON
(
200
,
withError
(
InvalidParam
))
return
}
oldStatus
:=
gjson
.
Get
(
string
(
rawJson
),
"old_row.status"
)
.
Int
()
newStatus
:=
gjson
.
Get
(
string
(
rawJson
),
"new_row.status"
)
.
Int
()
if
!
(
oldStatus
==
0
&&
newStatus
==
1
)
{
c
.
JSON
(
200
,
withSuccess
(
""
))
return
}
dbTxHash
:=
gjson
.
Get
(
string
(
rawJson
),
"new_row.tx_hash"
)
.
String
()
txStatus
:=
gjson
.
Get
(
string
(
rawJson
),
"new_row.tx_status"
)
.
Int
()
if
dbTxHash
!=
""
||
txStatus
!=
0
{
log
.
WithField
(
"txHash"
,
dbTxHash
)
.
WithField
(
"txStatus"
,
txStatus
)
.
Error
(
"already processed"
)
c
.
JSON
(
200
,
withError
(
InternalError
))
return
}
val10
,
_
:=
big
.
NewInt
(
10
)
.
SetString
(
"10000000000000000000"
,
10
)
txHash
,
err
:=
d
.
ExecuteTask
(
key
,
taskId
,
userId
,
appId
,
modelIds
,
val10
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"execute task error"
)
c
.
JSON
(
200
,
withError
(
InternalError
))
return
}
err
=
d
.
UpdateTask
(
taskId
,
txHash
.
String
(),
0
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"update task error"
)
c
.
JSON
(
200
,
withError
(
InternalError
))
return
}
c
.
JSON
(
200
,
withSuccess
(
txHash
.
String
()))
}
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