Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
ts-api-demo
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
wmvm
ts-api-demo
Commits
911a6fe1
Commit
911a6fe1
authored
Aug 22, 2024
by
1486327116
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format
parent
848d1110
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
21 deletions
+83
-21
coinType.service.ts
src/functional/mvc/service/coinType.service.ts
+34
-18
spotPair.service.ts
src/functional/mvc/service/spotPair.service.ts
+24
-3
coreSystemUtils.ts
src/utils/coreSystemUtils.ts
+25
-0
No files found.
src/functional/mvc/service/coinType.service.ts
View file @
911a6fe1
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import
{
coinType
,
ormDB
}
from
"@madex/ex-ts-dao"
;
import
{
coinType
,
ormDB
,
spotPairs
}
from
"@madex/ex-ts-dao"
;
import
{
addCoin2Core
,
addPairToCore
}
from
"../../../utils/coreSystemUtils"
;
export
interface
ListParam
{
export
interface
ListParam
{
...
@@ -11,7 +12,7 @@ export interface ListParam {
...
@@ -11,7 +12,7 @@ export interface ListParam {
}
}
export
interface
AddParam
{
export
interface
AddParam
{
id
:
any
,
id
:
any
,
symbol
:
string
;
symbol
:
string
;
...
@@ -62,29 +63,29 @@ export interface AddParam {
...
@@ -62,29 +63,29 @@ export interface AddParam {
total_amount
?:
number
;
total_amount
?:
number
;
supply_amount
?:
number
;
supply_amount
?:
number
;
circulation_rate
?:
number
;
circulation_rate
?:
number
;
address_num
?:
number
;
address_num
?:
number
;
price
?:
string
;
price
?:
string
;
supply_time
?:
string
;
supply_time
?:
string
;
deflation_rate
?:
number
;
deflation_rate
?:
number
;
comment
?:
string
;
comment
?:
string
;
max_transfer_amount
?:
number
;
max_transfer_amount
?:
number
;
tag
:
string
;
tag
:
string
;
forbid_info_related
?:
number
;
forbid_info_related
?:
number
;
is_hidden
?:
number
;
is_hidden
?:
number
;
main_status
?:
number
;
main_status
?:
number
;
}
}
...
@@ -107,10 +108,11 @@ export const save = async (param: AddParam) => {
...
@@ -107,10 +108,11 @@ export const save = async (param: AddParam) => {
let
id
=
param
.
id
;
let
id
=
param
.
id
;
if
(
id
)
{
if
(
id
)
{
delete
param
.
id
delete
param
.
id
await
coinType
.
prototype
.
update
(
param
,{
await
coinType
.
prototype
.
update
(
param
,
{
where
:
{
id
:
id
}
where
:
{
id
:
id
}
})
})
}
else
{
}
else
{
await
coinType
.
prototype
.
create
(
param
);
await
coinType
.
prototype
.
create
(
param
);
}
}
...
@@ -118,9 +120,23 @@ export const save = async (param: AddParam) => {
...
@@ -118,9 +120,23 @@ export const save = async (param: AddParam) => {
};
};
export
const
pushToCoreSystem
=
async
(
id
:
any
)
=>
{
export
const
pushToCoreSystem
=
async
(
id
:
any
)
=>
{
await
coinType
.
prototype
.
update
({
main_status
:
1
},{
where
:{
id
:
id
,
main_status
:
0
}
let
where
=
{
id
:
id
,
main_status
:
0
,
is_main
:
1
};
})
let
cfg
=
await
coinType
.
prototype
.
find
({
where
:
where
,
raw
:
true
});
if
(
cfg
)
{
let
symbol
=
cfg
.
general_name
;
let
optResult
=
await
addCoin2Core
(
symbol
);
if
(
optResult
)
{
await
coinType
.
prototype
.
update
({
main_status
:
1
},
{
where
:
where
})
}
}
return
'ok'
;
return
'ok'
;
};
};
src/functional/mvc/service/spotPair.service.ts
View file @
911a6fe1
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import
{
spotPairs
,
ormDB
,
coinType
}
from
"@madex/ex-ts-dao"
;
import
{
spotPairs
,
ormDB
,
coinType
}
from
"@madex/ex-ts-dao"
;
import
{
NUMBER
}
from
"sequelize"
;
import
{
NUMBER
}
from
"sequelize"
;
import
{
addPairToCore
}
from
"../../../utils/coreSystemUtils"
;
export
interface
ListParam
{
export
interface
ListParam
{
...
@@ -62,9 +63,29 @@ export const save = async (param: AddParam) => {
...
@@ -62,9 +63,29 @@ export const save = async (param: AddParam) => {
};
};
export
const
pushToCoreSystem
=
async
(
id
:
any
)
=>
{
export
const
pushToCoreSystem
=
async
(
id
:
any
)
=>
{
await
spotPairs
.
prototype
.
update
({
status
:
1
},
{
let
where
=
{
id
:
id
,
status
:
0
};
where
:
{
id
:
id
,
status
:
0
}
})
let
cfg
=
await
spotPairs
.
prototype
.
find
({
where
:
where
,
raw
:
true
});
if
(
cfg
)
{
let
symbol
=
cfg
.
symbol
;
let
sps
=
symbol
.
split
(
"_"
);
let
base
=
sps
[
0
];
let
quote
=
sps
[
1
]
let
param
=
{
"base"
:
base
,
"quote"
:
quote
,
"symbol"
:
symbol
,
"name"
:
symbol
,
"price-scale"
:
cfg
.
price_scale
,
"quantity-scale"
:
cfg
.
quantity_scale
,
"maker-fee"
:
cfg
.
maker_fee
,
"taker-fee"
:
cfg
.
taker_fee
}
let
optResult
=
await
addPairToCore
(
param
);
if
(
optResult
)
{
await
spotPairs
.
prototype
.
update
({
status
:
1
},
{
where
:
where
});
}
}
return
'ok'
;
return
'ok'
;
};
};
src/utils/coreSystemUtils.ts
View file @
911a6fe1
...
@@ -34,4 +34,29 @@ export const getPairFromCore = async(symbol,market="spot")=> {
...
@@ -34,4 +34,29 @@ export const getPairFromCore = async(symbol,market="spot")=> {
return
data
[
0
]
return
data
[
0
]
}
}
export
const
addCoin2Core
=
async
(
symbol
)
=>
{
const
url
=
`
${
webadmin_endpoint
}
/asset/add`
let
body
=
{
"symbol"
:
symbol
,
}
let
{
data
}
=
await
axios
.
post
(
url
,
body
);
if
(
data
.
error
)
{
logger
.
error
(
data
);
return
false
;
}
return
true
;
}
export
const
addPairToCore
=
async
(
body
)
=>
{
const
url
=
`
${
webadmin_endpoint
}
/pair/add_product`
let
{
data
}
=
await
axios
.
post
(
url
,
body
);
if
(
data
.
error
)
{
logger
.
error
(
data
);
return
false
;
}
return
true
;
}
// getPairFromCore("BTC_USDT").then(console.log)
// getPairFromCore("BTC_USDT").then(console.log)
\ No newline at end of file
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