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
b567f188
Commit
b567f188
authored
Aug 22, 2024
by
1486327116
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
9b18f9a7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
91 additions
and
24 deletions
+91
-24
coinType.control.ts
src/functional/mvc/control/coinType.control.ts
+23
-8
spotPair.control.ts
src/functional/mvc/control/spotPair.control.ts
+23
-8
coinType.service.ts
src/functional/mvc/service/coinType.service.ts
+20
-2
spotPair.service.ts
src/functional/mvc/service/spotPair.service.ts
+19
-3
index.ts
src/functional/router/v1/index.ts
+6
-3
No files found.
src/functional/mvc/control/coinType.control.ts
View file @
b567f188
import
*
as
service
from
"../service/coinType.service"
;
import
{
AddParam
,
ListParam
}
from
"../service/coinType.service"
;
let
{
logger
,
Res
ponse
Utils
,
optionalUtils
:
Optional
,
apiAssertUtils
:
ApiAssert
}
=
require
(
'@madex/ex-js-public'
);
let
{
logger
,
Res
3
Utils
,
optionalUtils
:
Optional
,
apiAssertUtils
:
ApiAssert
}
=
require
(
'@madex/ex-js-public'
);
export
const
list
=
async
(
req
:
any
,
param
:
ListParam
)
=>
{
...
...
@@ -11,16 +11,16 @@ export const list = async (req: any, param: ListParam) => {
param
.
page
=
Optional
.
opt
(
param
,
'page'
,
1
);
param
.
size
=
Optional
.
opt
(
param
,
'size'
,
50
);
let
res
=
await
service
.
list
(
param
);
return
Res
ponseUtils
.
success
(
cmd
,
res
);
return
Res
3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res
ponseUtils
.
error
(
func_name
,
cmd
,
e
);
return
Res
3Utils
.
getErrorResult
(
e
);
}
};
export
const
add
=
async
(
req
:
any
,
param
:
AddParam
)
=>
{
let
func_name
=
"coinTypeCtl.
add
"
;
export
const
save
=
async
(
req
:
any
,
param
:
AddParam
)
=>
{
let
func_name
=
"coinTypeCtl.
save
"
;
let
cmd
=
req
.
path
;
try
{
ApiAssert
.
notNull
(
'3000'
,
param
.
symbol
);
...
...
@@ -33,11 +33,26 @@ export const add = async (req: any, param: AddParam) => {
ApiAssert
.
isInt
(
'3000'
,
param
.
deposit_confirm_count
);
ApiAssert
.
isInt
(
'3000'
,
param
.
safe_confirm_count
);
let
res
=
await
service
.
add
(
param
);
return
Res
ponseUtils
.
success
(
cmd
,
res
);
let
res
=
await
service
.
save
(
param
);
return
Res
3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
ResponseUtils
.
error
(
func_name
,
cmd
,
e
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
export
const
pushToCoreSystem
=
async
(
req
:
any
,
id
:
any
)
=>
{
let
func_name
=
"coinTypeCtl.pushToCoreSystem"
;
let
cmd
=
req
.
path
;
try
{
ApiAssert
.
notNull
(
'3000'
,
id
);
let
res
=
await
service
.
pushToCoreSystem
(
id
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
src/functional/mvc/control/spotPair.control.ts
View file @
b567f188
import
*
as
service
from
"../service/spotPair.service"
;
import
{
AddParam
,
ListParam
}
from
"../service/spotPair.service"
;
let
{
logger
,
Res
ponse
Utils
,
optionalUtils
:
Optional
,
apiAssertUtils
:
ApiAssert
}
=
require
(
'@madex/ex-js-public'
);
let
{
logger
,
Res
3
Utils
,
optionalUtils
:
Optional
,
apiAssertUtils
:
ApiAssert
}
=
require
(
'@madex/ex-js-public'
);
export
const
list
=
async
(
req
:
any
,
param
:
ListParam
)
=>
{
...
...
@@ -11,16 +11,16 @@ export const list = async (req: any, param: ListParam) => {
param
.
page
=
Optional
.
opt
(
param
,
'page'
,
1
);
param
.
size
=
Optional
.
opt
(
param
,
'size'
,
50
);
let
res
=
await
service
.
list
(
param
);
return
Res
ponseUtils
.
success
(
cmd
,
res
);
return
Res
3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res
ponseUtils
.
error
(
func_name
,
cmd
,
e
);
return
Res
3Utils
.
getErrorResult
(
e
);
}
};
export
const
add
=
async
(
req
:
any
,
param
:
AddParam
)
=>
{
let
func_name
=
"spotPairCtl.
add
"
;
export
const
save
=
async
(
req
:
any
,
param
:
AddParam
)
=>
{
let
func_name
=
"spotPairCtl.
save
"
;
let
cmd
=
req
.
path
;
try
{
ApiAssert
.
notNull
(
'3000'
,
param
.
base
);
...
...
@@ -31,11 +31,26 @@ export const add = async (req: any, param: AddParam) => {
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
Res
ponseUtils
.
success
(
cmd
,
res
);
let
res
=
await
service
.
save
(
param
);
return
Res
3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
ResponseUtils
.
error
(
func_name
,
cmd
,
e
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
export
const
pushToCoreSystem
=
async
(
req
:
any
,
id
:
any
)
=>
{
let
func_name
=
"spotPairCtl.pushToCoreSystem"
;
let
cmd
=
req
.
path
;
try
{
ApiAssert
.
notNull
(
'3000'
,
id
);
let
res
=
await
service
.
pushToCoreSystem
(
id
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
src/functional/mvc/service/coinType.service.ts
View file @
b567f188
...
...
@@ -11,6 +11,8 @@ export interface ListParam {
}
export
interface
AddParam
{
id
:
any
,
symbol
:
string
;
is_active
:
number
;
...
...
@@ -101,8 +103,24 @@ export async function list(param: ListParam) {
return
resList
;
}
export
const
add
=
async
(
param
:
AddParam
)
=>
{
await
coinType
.
prototype
.
create
(
param
);
export
const
save
=
async
(
param
:
AddParam
)
=>
{
let
id
=
param
.
id
;
if
(
id
)
{
delete
param
.
id
await
coinType
.
prototype
.
update
(
param
,{
where
:{
id
:
id
}
})
}
else
{
await
coinType
.
prototype
.
create
(
param
);
}
return
'ok'
;
};
export
const
pushToCoreSystem
=
async
(
id
:
any
)
=>
{
await
coinType
.
prototype
.
update
({
main_status
:
1
},{
where
:{
id
:
id
,
main_status
:
0
}
})
return
'ok'
;
};
src/functional/mvc/service/spotPair.service.ts
View file @
b567f188
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import
{
spotPairs
,
ormDB
}
from
"@madex/ex-ts-dao"
;
import
{
spotPairs
,
ormDB
,
coinType
}
from
"@madex/ex-ts-dao"
;
import
{
NUMBER
}
from
"sequelize"
;
...
...
@@ -10,6 +10,7 @@ export interface ListParam {
}
export
interface
AddParam
{
id
:
any
;
base
:
string
;
quote
:
string
;
symbol
:
string
;
...
...
@@ -36,8 +37,23 @@ export async function list(param: ListParam) {
return
resList
;
}
export
const
add
=
async
(
param
:
AddParam
)
=>
{
await
spotPairs
.
prototype
.
create
(
param
);
export
const
save
=
async
(
param
:
AddParam
)
=>
{
let
id
=
param
.
id
;
if
(
id
)
{
delete
param
.
id
await
spotPairs
.
prototype
.
update
(
param
,{
where
:{
id
:
id
}
})
}
else
{
await
spotPairs
.
prototype
.
create
(
param
);
}
return
'ok'
;
};
export
const
pushToCoreSystem
=
async
(
id
:
any
)
=>
{
await
spotPairs
.
prototype
.
update
({
status
:
1
},{
where
:{
id
:
id
,
status
:
0
}
})
return
'ok'
;
};
src/functional/router/v1/index.ts
View file @
b567f188
...
...
@@ -31,10 +31,13 @@ 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
,
'spotPair/add'
:
spotPairCtrl
.
save
,
'spotPair/list'
:
spotPairCtrl
.
list
,
'spotPair/spotPairCtl'
:
spotPairCtrl
.
pushToCoreSystem
,
'coinType/add'
:
coinTypeCtrl
.
save
,
'coinType/list'
:
coinTypeCtrl
.
list
,
'coinType/spotPairCtl'
:
coinTypeCtrl
.
pushToCoreSystem
,
'acl/user/add'
:
aclUserCtrl
.
add
,
'acl/user/list'
:
aclUserCtrl
.
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