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
f33d26a7
Commit
f33d26a7
authored
Aug 13, 2024
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
热门币种搜索
parent
9b18f9a7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
221 additions
and
3 deletions
+221
-3
package-lock.json
package-lock.json
+3
-3
hotPairConfig.control.ts
src/functional/mvc/control/hotPairConfig.control.ts
+81
-0
hotPairConfig.service.ts
src/functional/mvc/service/hotPairConfig.service.ts
+127
-0
index.ts
src/functional/router/v1/index.ts
+6
-0
access-limit.ts
src/setting/access-limit.ts
+4
-0
No files found.
package-lock.json
View file @
f33d26a7
...
...
@@ -1068,9 +1068,9 @@
}
},
"node_modules/@madex/ex-ts-dao"
:
{
"version"
:
"0.0.1
0
"
,
"resolved"
:
"https://packages.aliyun.com/646341b481b284e28f47a25b/npm/npm-registry/@madex/ex-ts-dao/-/@madex/ex-ts-dao-0.0.1
0
.tgz"
,
"integrity"
:
"sha512-
+mmRCR86JvKs0bx0UfrA1Ld5NzOjvh7fkCCs4h7mbTzJJUirUlgFE3/wsM1e4xTyURpJ0hsROkNvahkn1yrClQ
=="
,
"version"
:
"0.0.1
2
"
,
"resolved"
:
"https://packages.aliyun.com/646341b481b284e28f47a25b/npm/npm-registry/@madex/ex-ts-dao/-/@madex/ex-ts-dao-0.0.1
2
.tgz"
,
"integrity"
:
"sha512-
Ig1DpxD+GO+bAHQ+IE6ZoZxpVQhUHx66beoJE+S9awrWZxMywHI0PcreC33MDN1emt2ccm3VZjFBnzKG6PcPoA
=="
,
"license"
:
"ISC"
,
"dependencies"
:
{
"@madex/ex-js-public"
:
"git+ssh://git@bitbucket.org/biiigle/ex-js-public.git#master"
,
...
...
src/functional/mvc/control/hotPairConfig.control.ts
0 → 100644
View file @
f33d26a7
import
*
as
hotPairConfigService
from
"../service/hotPairConfig.service"
;
import
{
HotPairConfigVO
,
HotPairConfigPageVO
}
from
"../service/hotPairConfig.service"
;
let
{
logger
,
Res3Utils
,
optionalUtils
:
Optional
,
apiAssertUtils
:
ApiAssert
}
=
require
(
'@madex/ex-js-public'
);
import
{
ErrorCode
}
from
"../../../constant/errorCode"
;
import
{
getCurrentUserId
,
isAdminUserBySessionId
}
from
"../../../utils/aclUserUtils"
;
/**
* 分页查询热门交易对配置列表
* @param req
* @param infoVO
*/
export
const
list
=
async
(
req
:
any
,
hotPairConfigPageVO
:
HotPairConfigPageVO
)
=>
{
let
func_name
=
"hotPairConfigCtrl.list"
;
try
{
hotPairConfigPageVO
.
page
=
Optional
.
opt
(
hotPairConfigPageVO
,
'page'
,
1
);
hotPairConfigPageVO
.
size
=
Optional
.
opt
(
hotPairConfigPageVO
,
'size'
,
20
);
let
res
=
await
hotPairConfigService
.
list
(
hotPairConfigPageVO
.
pair
,
Number
(
hotPairConfigPageVO
.
page
),
Number
(
hotPairConfigPageVO
.
size
));
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
/**
* 添加热门交易对
* @param req
* @param infoVO
*/
export
const
add
=
async
(
req
:
any
,
hotPairConfigVO
:
HotPairConfigVO
)
=>
{
let
func_name
=
"hotPairConfigCtrl.add"
;
try
{
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
hotPairConfigVO
.
pair
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
hotPairConfigVO
.
weight
);
let
res
=
await
hotPairConfigService
.
add
(
hotPairConfigVO
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
/**
* 修改热门交易对
* @param req
* @param infoVO
*/
export
const
update
=
async
(
req
:
any
,
hotPairConfigVO
:
HotPairConfigVO
)
=>
{
let
func_name
=
"hotPairConfigCtrl.update"
;
try
{
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
hotPairConfigVO
.
id
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
hotPairConfigVO
.
pair
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
hotPairConfigVO
.
weight
);
let
res
=
await
hotPairConfigService
.
update
(
hotPairConfigVO
);
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
/**
* 删除门交易对
* @param req
* @param authConfigVO
*/
export
const
del
=
async
(
req
:
any
,
hotPairConfigVO
:
HotPairConfigVO
)
=>
{
let
func_name
=
"hotPairConfigCtrl.del"
;
try
{
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
hotPairConfigVO
.
id
);
let
res
=
await
hotPairConfigService
.
del
(
Number
(
hotPairConfigVO
.
id
));
return
Res3Utils
.
result
(
res
);
}
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
return
Res3Utils
.
getErrorResult
(
e
);
}
};
\ No newline at end of file
src/functional/mvc/service/hotPairConfig.service.ts
0 → 100644
View file @
f33d26a7
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import
{
ormDB
,
hotPairConfig
}
from
"@madex/ex-ts-dao"
;
import
{
AclUserInfoConst
}
from
"../../../constant/aclUserConstant"
;
import
{
CryptUtils
}
from
"../../../utils/crypt-utils"
;
import
{
ErrorCode
}
from
"../../../constant/errorCode"
;
import
*
as
aclRoleAuthService
from
"../service/aclRoleAuth.service"
;
import
*
as
aclUserService
from
"../service/aclUser.service"
;
import
{
getOneAclUserByAccount
,
getOneAclUserByUid
}
from
"../../../utils/aclUserUtils"
;
import
{
RedisVal
}
from
"../../../constant/redis-val"
;
import
Config
from
"../../../../config"
;
import
{
AuthConfigConst
}
from
"../../../constant/aclUserAuthConfigConstant"
;
import
*
as
userOptLogService
from
"./userOptLog.service"
;
let
{
apiAssertUtils
:
ApiAssert
,
datetimeUtils
:
DatetimeUtils
}
=
require
(
'@madex/ex-js-public'
);
let
{
authCommon
:
AuthCommon
,
redisUtilsCommon
:
RedisClient
,
BigNumberUtils
}
=
require
(
'@madex/ex-js-common'
);
let
_
=
require
(
'lodash'
);
let
{
logger
}
=
require
(
'@madex/ex-js-public'
);
export
interface
HotPairConfigVO
{
id
?:
number
;
pair
?:
string
|
any
;
weight
?:
number
;
createdAt
?:
Date
|
any
;
updatedAt
?:
Date
|
any
;
}
export
interface
HotPairConfigPageVO
extends
HotPairConfigVO
{
page
?:
number
,
size
?:
number
}
export
async
function
list
(
pair
:
any
,
page
:
number
,
size
:
number
)
{
let
where
=
Object
.
create
(
null
);
if
(
pair
)
{
where
.
pair
=
{
[
ormDB
.
Op
.
like
]:
`
${
pair
}
%`
};
}
let
resList
=
await
hotPairConfig
.
prototype
.
findAndCount
({
where
:
where
,
limit
:
size
,
offset
:
(
page
-
1
)
*
size
,
order
:
[[
"weight"
,
"desc"
]],
raw
:
true
});
return
resList
;
}
export
async
function
add
(
hotPairConfigVO
:
HotPairConfigVO
)
{
let
dbInfo
=
await
hotPairConfig
.
prototype
.
findOne
({
where
:
{
pair
:
hotPairConfigVO
.
pair
},
raw
:
true
});
if
(
dbInfo
)
{
throw
ErrorCode
.
DATA_EXIST
;
}
hotPairConfigVO
.
createdAt
=
new
Date
();
hotPairConfigVO
.
updatedAt
=
new
Date
();
await
hotPairConfig
.
prototype
.
create
(
hotPairConfigVO
);
return
'success'
}
export
async
function
update
(
hotPairConfigVO
:
HotPairConfigVO
)
{
let
dbInfo
=
await
hotPairConfig
.
prototype
.
findOne
({
where
:
{
pair
:
hotPairConfigVO
.
pair
,
id
:
{
[
ormDB
.
Op
.
ne
]:
hotPairConfigVO
.
id
}
},
raw
:
true
});
if
(
dbInfo
)
{
throw
ErrorCode
.
DATA_EXIST
;
}
hotPairConfigVO
.
updatedAt
=
new
Date
();
await
hotPairConfig
.
prototype
.
update
({
pair
:
hotPairConfigVO
.
pair
,
weight
:
hotPairConfigVO
.
weight
},
{
where
:
{
id
:
Number
(
hotPairConfigVO
.
id
)
}
});
return
'success'
}
export
async
function
del
(
id
:
number
)
{
let
dbInfo
=
await
hotPairConfig
.
prototype
.
findOne
({
where
:
{
id
:
id
},
raw
:
true
});
if
(
!
dbInfo
)
{
throw
ErrorCode
.
DATA_NOT_EXIST
;
}
await
hotPairConfig
.
prototype
.
destroy
({
where
:
{
id
:
Number
(
id
)
}
});
return
'success'
}
src/functional/router/v1/index.ts
View file @
f33d26a7
...
...
@@ -14,6 +14,7 @@ import * as aclUserCtrl from "../../mvc/control/aclUser.control";
import
*
as
aclRoleAuthCtrl
from
"../../mvc/control/aclRoleAuth.control"
;
import
*
as
userOptCtrl
from
"../../mvc/control/userOpt.control"
;
import
*
as
userAuthConfigCtrl
from
"../../mvc/control/userAuthConfig.control"
;
import
*
as
hotPairConfigCtrl
from
"../../mvc/control/hotPairConfig.control"
;
import
*
as
ReqUtils
from
"../../../utils/req-utils"
;
import
*
as
spotPairCtrl
from
"../../mvc/control/spotPair.control"
;
...
...
@@ -72,6 +73,11 @@ const postFunc = {
'user/auth/change/locked/status'
:
userAuthConfigCtrl
.
changeLockedStatus
,
'user/auth/reset/totp'
:
userAuthConfigCtrl
.
resetTotp
,
'hot/pair/config/list'
:
hotPairConfigCtrl
.
list
,
'hot/pair/config/add'
:
hotPairConfigCtrl
.
add
,
'hot/pair/config/update'
:
hotPairConfigCtrl
.
update
,
'hot/pair/config/del'
:
hotPairConfigCtrl
.
del
,
};
...
...
src/setting/access-limit.ts
View file @
f33d26a7
...
...
@@ -44,6 +44,10 @@ let cmdWhiteList = {
'user/auth/change/force/status'
:
1
,
'user/auth/change/locked/status'
:
1
,
'user/auth/reset/totp'
:
1
,
'hot/pair/config/list'
:
1
,
'hot/pair/config/add'
:
1
,
'hot/pair/config/update'
:
1
,
'hot/pair/config/del'
:
1
,
};
...
...
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