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
71c29da5
Commit
71c29da5
authored
Aug 02, 2024
by
1486327116
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wait cron
parent
e2ecf8d6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
245 additions
and
7 deletions
+245
-7
index.ts
index.ts
+2
-5
coinType.control.ts
src/functional/mvc/control/coinType.control.ts
+43
-0
spotPair.control.ts
src/functional/mvc/control/spotPair.control.ts
+41
-0
coinType.service.ts
src/functional/mvc/service/coinType.service.ts
+108
-0
i18n.service.ts
src/functional/mvc/service/i18n.service.ts
+1
-1
spotPair.service.ts
src/functional/mvc/service/spotPair.service.ts
+43
-0
index.ts
src/functional/router/v1/index.ts
+7
-1
No files found.
index.ts
View file @
71c29da5
...
...
@@ -10,14 +10,11 @@ let app = express();
logger
.
use
(
app
);
const
tfUrl
=
"/api/v1/tf"
;
// express 全局设定
require
(
'@madex/ex-js-common'
).
expressSetting
(
app
);
// Request frequency limit
const
limitList
=
[
"transfer/transferInList"
,
"transfer/transferOutList"
,
"transfer/bills"
,
];
require
(
"@madex/ex-js-common"
).
frequencyLimiting
.
cookieLimitForCmd
(
app
,
limitList
);
...
...
@@ -49,7 +46,7 @@ else {
import
{
apiRouterV1
}
from
"./src/functional/router/v1/index"
app
.
use
(
'/
demo
/v1'
,
apiRouterV1
);
app
.
use
(
'/
admin
/v1'
,
apiRouterV1
);
//启动Server
...
...
src/functional/mvc/control/coinType.control.ts
0 → 100644
View file @
71c29da5
import
*
as
service
from
"../service/coinType.service"
;
import
{
AddParam
,
ListParam
}
from
"../service/coinType.service"
;
let
{
logger
,
ResponseUtils
,
optionalUtils
:
Optional
,
apiAssertUtils
:
ApiAssert
}
=
require
(
'@madex/ex-js-public'
);
export
const
list
=
async
(
req
:
any
,
param
:
ListParam
)
=>
{
let
func_name
=
"coinTypeCtl.list"
;
let
cmd
=
req
.
path
;
try
{
param
.
page
=
Optional
.
opt
(
param
,
'page'
,
1
);
param
.
size
=
Optional
.
opt
(
param
,
'size'
,
50
);
let
res
=
await
service
.
list
(
param
);
return
ResponseUtils
.
success
(
cmd
,
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
ResponseUtils
.
error
(
func_name
,
cmd
,
e
);
}
};
export
const
add
=
async
(
req
:
any
,
param
:
AddParam
)
=>
{
let
func_name
=
"coinTypeCtl.add"
;
let
cmd
=
req
.
path
;
try
{
ApiAssert
.
notNull
(
'3000'
,
param
.
symbol
);
ApiAssert
.
notNull
(
'3000'
,
param
.
name
);
ApiAssert
.
notNull
(
'3000'
,
param
.
general_name
);
ApiAssert
.
isInt
(
'3000'
,
param
.
is_active
);
ApiAssert
.
isInt
(
'3000'
,
param
.
is_main
);
ApiAssert
.
isInt
(
'3000'
,
param
.
original_decimals
);
ApiAssert
.
isInt
(
'3000'
,
param
.
valid_decimals
);
ApiAssert
.
isInt
(
'3000'
,
param
.
deposit_confirm_count
);
ApiAssert
.
isInt
(
'3000'
,
param
.
safe_confirm_count
);
let
res
=
await
service
.
add
(
param
);
return
ResponseUtils
.
success
(
cmd
,
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
ResponseUtils
.
error
(
func_name
,
cmd
,
e
);
}
};
src/functional/mvc/control/spotPair.control.ts
0 → 100644
View file @
71c29da5
import
*
as
service
from
"../service/spotPair.service"
;
import
{
AddParam
,
ListParam
}
from
"../service/spotPair.service"
;
let
{
logger
,
ResponseUtils
,
optionalUtils
:
Optional
,
apiAssertUtils
:
ApiAssert
}
=
require
(
'@madex/ex-js-public'
);
export
const
list
=
async
(
req
:
any
,
param
:
ListParam
)
=>
{
let
func_name
=
"spotPairCtl.list"
;
let
cmd
=
req
.
path
;
try
{
param
.
page
=
Optional
.
opt
(
param
,
'page'
,
1
);
param
.
size
=
Optional
.
opt
(
param
,
'size'
,
50
);
let
res
=
await
service
.
list
(
param
);
return
ResponseUtils
.
success
(
cmd
,
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
ResponseUtils
.
error
(
func_name
,
cmd
,
e
);
}
};
export
const
add
=
async
(
req
:
any
,
param
:
AddParam
)
=>
{
let
func_name
=
"spotPairCtl.add"
;
let
cmd
=
req
.
path
;
try
{
ApiAssert
.
notNull
(
'3000'
,
param
.
base
);
ApiAssert
.
notNull
(
'3000'
,
param
.
quote
);
ApiAssert
.
notNull
(
'3000'
,
param
.
symbol
);
ApiAssert
.
notNull
(
'3000'
,
param
.
name
);
ApiAssert
.
notNull
(
'3000'
,
param
.
price_scale
);
ApiAssert
.
notNull
(
'3000'
,
param
.
quantity_scale
);
ApiAssert
.
notNull
(
'3000'
,
param
.
maker_fee
);
ApiAssert
.
notNull
(
'3000'
,
param
.
taker_fee
);
let
res
=
await
service
.
add
(
param
);
return
ResponseUtils
.
success
(
cmd
,
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
ResponseUtils
.
error
(
func_name
,
cmd
,
e
);
}
};
src/functional/mvc/service/coinType.service.ts
0 → 100644
View file @
71c29da5
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import
{
coinType
,
ormDB
}
from
"@madex/ex-ts-dao"
;
export
interface
ListParam
{
symbol
:
string
|
any
;
page
:
number
;
size
:
number
;
}
export
interface
AddParam
{
symbol
:
string
;
is_active
:
number
;
is_main
:
number
;
name
:
string
;
general_name
:
string
;
chain_type
?:
string
;
original_decimals
:
number
;
valid_decimals
:
number
;
contract
?:
string
;
contract_father
?:
string
;
enable_deposit
?:
number
;
enable_withdraw
?:
number
;
enable_transfer
?:
number
;
withdraw_fee
?:
number
;
withdraw_min
?:
number
;
deposit_min
?:
number
;
deposit_confirm_count
:
number
;
safe_confirm_count
:
number
;
explor_url
?:
string
;
icon_url
?:
string
;
describe_url
?:
string
;
forbid_info
?:
string
;
describe_summary
?:
string
;
total_amount
?:
number
;
supply_amount
?:
number
;
circulation_rate
?:
number
;
address_num
?:
number
;
price
?:
string
;
supply_time
?:
string
;
deflation_rate
?:
number
;
comment
?:
string
;
max_transfer_amount
?:
number
;
tag
:
string
;
forbid_info_related
?:
number
;
is_hidden
?:
number
;
main_status
?:
number
;
}
export
async
function
list
(
param
:
ListParam
)
{
let
where
=
{};
if
(
param
.
symbol
)
{
where
[
"symbol"
]
=
{
[
ormDB
.
Op
.
like
]:
`%
${
param
.
symbol
}
%`
};
}
let
resList
=
await
coinType
.
prototype
.
findAndCount
({
where
:
where
,
limit
:
param
.
size
,
offset
:
(
param
.
page
-
1
)
*
param
.
size
,
order
:
[[
"id"
,
"desc"
]],
raw
:
true
});
return
resList
;
}
export
const
add
=
async
(
param
:
AddParam
)
=>
{
await
coinType
.
prototype
.
create
(
param
);
return
'ok'
;
};
src/functional/mvc/service/i18n.service.ts
View file @
71c29da5
...
...
@@ -27,7 +27,7 @@ export interface I18nInfoVO {
}
export
interface
I18nInfoPageVO
extends
I18nInfoVO
{
page
?:
number
,
page
?:
number
;
size
?:
number
}
...
...
src/functional/mvc/service/spotPair.service.ts
0 → 100644
View file @
71c29da5
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import
{
spotPairs
,
ormDB
}
from
"@madex/ex-ts-dao"
;
import
{
NUMBER
}
from
"sequelize"
;
export
interface
ListParam
{
symbol
:
string
|
any
;
page
:
number
;
size
:
number
;
}
export
interface
AddParam
{
base
:
string
;
quote
:
string
;
symbol
:
string
;
name
:
string
;
price_scale
:
number
;
quantity_scale
:
number
;
maker_fee
:
string
;
taker_fee
:
string
;
}
export
async
function
list
(
param
:
ListParam
)
{
let
where
=
{};
if
(
param
.
symbol
)
{
where
[
"symbol"
]
=
{
[
ormDB
.
Op
.
like
]:
`%
${
param
.
symbol
}
%`
};
}
let
resList
=
await
spotPairs
.
prototype
.
findAndCount
({
where
:
where
,
limit
:
param
.
size
,
offset
:
(
Number
(
param
.
page
)
-
1
)
*
Number
(
param
.
size
),
order
:
[[
"id"
,
"desc"
]],
raw
:
true
});
return
resList
;
}
export
const
add
=
async
(
param
:
AddParam
)
=>
{
await
spotPairs
.
prototype
.
create
(
param
);
return
'ok'
;
};
src/functional/router/v1/index.ts
View file @
71c29da5
...
...
@@ -6,7 +6,8 @@ const router = Express.Router();
import
*
as
userController
from
"../../mvc/control/user.control"
;
import
*
as
i18nCtrl
from
"../../mvc/control/i18n.control"
;
import
*
as
i18nLogCtrl
from
"../../mvc/control/i18nlog.control"
;
import
*
as
spotPairCtrl
from
"../../mvc/control/spotPair.control"
;
import
*
as
coinTypeCtrl
from
"../../mvc/control/coinType.control"
;
const
getFunc
=
{
'user/info'
:
userController
.
getUserInfo
,
};
...
...
@@ -19,6 +20,11 @@ const postFunc = {
'i18n/info/log/list'
:
i18nLogCtrl
.
list
,
'i18n/info/log/revert'
:
i18nLogCtrl
.
revert
,
'spotpair/add'
:
spotPairCtrl
.
add
,
'spotpair/list'
:
spotPairCtrl
.
list
,
'coinType/add'
:
coinTypeCtrl
.
add
,
'coinType/list'
:
coinTypeCtrl
.
list
,
};
...
...
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