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
8d6fa754
Commit
8d6fa754
authored
Dec 25, 2024
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加修改币种icon接口
parent
ecfe0997
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
20 deletions
+65
-20
coinType.control.ts
src/functional/mvc/control/coinType.control.ts
+17
-0
coinType.service.ts
src/functional/mvc/service/coinType.service.ts
+46
-20
index.ts
src/functional/router/v1/index.ts
+1
-0
access-limit.ts
src/setting/access-limit.ts
+1
-0
No files found.
src/functional/mvc/control/coinType.control.ts
View file @
8d6fa754
...
@@ -145,3 +145,20 @@ export const mixinCoinList = async (req: any, param: ListParam) => {
...
@@ -145,3 +145,20 @@ export const mixinCoinList = async (req: any, param: ListParam) => {
}
}
};
};
export
const
updateIconUrl
=
async
(
req
:
any
,
param
:
AddParam
)
=>
{
let
func_name
=
"coinTypeCtl.updateIconUrl"
;
let
cmd
=
req
.
path
;
try
{
ApiAssert
.
notNull
(
'3000'
,
param
.
id
);
ApiAssert
.
notNull
(
'3000'
,
param
.
icon_url
);
let
ip
=
isIp
(
req
.
ip
)
?
req
.
ip
:
'*.*.*.*'
;
let
currentUserId
=
await
getCurrentUserId
(
req
.
cookies
.
session_id
);
let
res
=
await
service
.
updateIconUrl
(
param
,
currentUserId
,
ip
);
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 @
8d6fa754
// @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
,
spotPairs
,
mixinCoin
,
mixinChain
}
from
"@madex/ex-ts-dao"
;
import
{
coinType
,
ormDB
,
spotPairs
,
mixinCoin
,
mixinChain
}
from
"@madex/ex-ts-dao"
;
import
{
addCoin2Core
}
from
"../../../utils/coreSystemUtils"
;
import
{
addCoin2Core
}
from
"../../../utils/coreSystemUtils"
;
import
{
ErrorCode
}
from
"../../../constant/errorCode"
;
import
{
ErrorCode
}
from
"../../../constant/errorCode"
;
import
{
addOptLog
}
from
"./userOptLog.service"
;
import
{
addOptLog
}
from
"./userOptLog.service"
;
const
_
=
require
(
"lodash"
);
const
_
=
require
(
"lodash"
);
let
{
logger
,
datetimeUtils
}
=
require
(
'@madex/ex-js-public'
);
let
{
logger
,
datetimeUtils
}
=
require
(
'@madex/ex-js-public'
);
...
@@ -25,6 +26,7 @@ export interface AddParam {
...
@@ -25,6 +26,7 @@ export interface AddParam {
id
:
any
,
id
:
any
,
symbol
:
string
;
symbol
:
string
;
mixin_id
:
string
;
mixin_id
:
string
;
asset_id
:
number
;
asset_id
:
number
;
...
@@ -133,13 +135,13 @@ export async function list(param: ListParam) {
...
@@ -133,13 +135,13 @@ export async function list(param: ListParam) {
export
async
function
chainList
()
{
export
async
function
chainList
()
{
let
resList
=
await
coinType
.
prototype
.
findAll
({
let
resList
=
await
coinType
.
prototype
.
findAll
({
attributes
:[
'chain_type'
],
attributes
:
[
'chain_type'
],
where
:
{
where
:
{
is_main
:
1
is_main
:
1
},
},
raw
:
true
raw
:
true
});
});
let
chains
:
any
[]
=
[];
let
chains
:
any
[]
=
[];
for
(
let
item
of
resList
)
{
for
(
let
item
of
resList
)
{
let
chainType
=
item
.
chain_type
;
let
chainType
=
item
.
chain_type
;
if
(
chainType
)
{
if
(
chainType
)
{
...
@@ -168,7 +170,8 @@ export const save = async (param: AddParam, currentUserId: any, ip: any) => {
...
@@ -168,7 +170,8 @@ export const save = async (param: AddParam, currentUserId: any, ip: any) => {
param
.
is_main
=
0
;
param
.
is_main
=
0
;
param
.
asset_id
=
exist
.
asset_id
;
param
.
asset_id
=
exist
.
asset_id
;
param
.
main_status
=
exist
.
main_status
;
param
.
main_status
=
exist
.
main_status
;
}
else
{
}
else
{
param
.
is_main
=
1
;
param
.
is_main
=
1
;
param
.
asset_id
=
0
;
param
.
asset_id
=
0
;
param
.
main_status
=
0
;
param
.
main_status
=
0
;
...
@@ -270,17 +273,16 @@ export const audit = async (param: AddParam, currentUserId: any, ip: any) => {
...
@@ -270,17 +273,16 @@ export const audit = async (param: AddParam, currentUserId: any, ip: any) => {
};
};
export
async
function
mixinCoinList
(
param
:
ListParam
)
{
export
async
function
mixinCoinList
(
param
:
ListParam
)
{
let
where
=
{};
let
where
=
{};
if
(
param
.
symbol
)
{
if
(
param
.
symbol
)
{
where
[
"symbol"
]
=
{
[
ormDB
.
Op
.
like
]:
`%
${
param
.
symbol
}
%`
};
where
[
"symbol"
]
=
{
[
ormDB
.
Op
.
like
]:
`%
${
param
.
symbol
}
%`
};
}
}
let
resList
=
await
mixinCoin
.
prototype
.
findAndCount
({
let
resList
=
await
mixinCoin
.
prototype
.
findAndCount
({
attributes
:
[
'symbol'
,
'name'
,
'symbol_id'
,[
'symbol_id'
,
'mixin_id'
],
'display_symbol'
,
'chain_id'
,
attributes
:
[
'symbol'
,
'name'
,
'symbol_id'
,
[
'symbol_id'
,
'mixin_id'
],
'display_symbol'
,
'chain_id'
,
[
'address'
,
'contract'
],[
'precision'
,
'original_decimals'
],[
'dust'
,
'deposit_min'
],[
'dust'
,
'withdraw_min'
],
[
'address'
,
'contract'
],
[
'precision'
,
'original_decimals'
],
[
'dust'
,
'deposit_min'
],
[
'dust'
,
'withdraw_min'
],
[
'confirm'
,
'deposit_confirm_count'
],[
'confirm'
,
'safe_confirm_count'
],
[
'confirm'
,
'deposit_confirm_count'
],
[
'confirm'
,
'safe_confirm_count'
],
'price_btc'
,
'price_usd'
,
'balance'
,
'comment'
],
'price_btc'
,
'price_usd'
,
'balance'
,
'comment'
],
// include:{
// include:{
// model:mixinChain.prototype,
// model:mixinChain.prototype,
// required:true, //INNER JOIN
// required:true, //INNER JOIN
...
@@ -292,19 +294,19 @@ export async function mixinCoinList(param: ListParam) {
...
@@ -292,19 +294,19 @@ export async function mixinCoinList(param: ListParam) {
order
:
[[
"symbol"
,
"asc"
]],
order
:
[[
"symbol"
,
"asc"
]],
raw
:
true
raw
:
true
});
});
let
chainIDs
=
_
.
map
(
resList
.
rows
,
'chain_id'
)
let
chainIDs
=
_
.
map
(
resList
.
rows
,
'chain_id'
)
let
m
=
await
mixinChain
.
prototype
.
findAll
({
let
m
=
await
mixinChain
.
prototype
.
findAll
({
attributes
:
[
'name'
,
'symbol'
,
'threshold'
,
'withdrawal_fee'
,
'is_memo'
,
'chain_id'
],
attributes
:
[
'name'
,
'symbol'
,
'threshold'
,
'withdrawal_fee'
,
'is_memo'
,
'chain_id'
],
where
:{
where
:
{
chain_id
:
chainIDs
chain_id
:
chainIDs
},
},
raw
:
true
,
raw
:
true
,
})
})
let
chainMap
=
_
.
keyBy
(
m
,
'chain_id'
);
let
chainMap
=
_
.
keyBy
(
m
,
'chain_id'
);
for
(
const
item
of
resList
.
rows
)
{
for
(
const
item
of
resList
.
rows
)
{
let
isMainToken
=
(
item
.
symbol_id
==
item
.
chain_id
&&
item
.
chain_id
==
item
.
contract
)
let
isMainToken
=
(
item
.
symbol_id
==
item
.
chain_id
&&
item
.
chain_id
==
item
.
contract
)
if
(
chainMap
[
item
.
chain_id
])
{
if
(
chainMap
[
item
.
chain_id
])
{
item
.
chain_type
=
chainMap
[
item
.
chain_id
].
symbol
item
.
chain_type
=
chainMap
[
item
.
chain_id
].
symbol
item
.
issupport_memo
=
chainMap
[
item
.
chain_id
].
is_memo
;
item
.
issupport_memo
=
chainMap
[
item
.
chain_id
].
is_memo
;
...
@@ -312,10 +314,34 @@ export async function mixinCoinList(param: ListParam) {
...
@@ -312,10 +314,34 @@ export async function mixinCoinList(param: ListParam) {
item
.
withdraw_fee
=
isMainToken
?
chainMap
[
item
.
chain_id
].
withdrawal_fee
:
(
5
/
(
item
.
price_usd
>
0
?
item
.
price_usd
:
0.001
)).
toFixed
(
4
);
item
.
withdraw_fee
=
isMainToken
?
chainMap
[
item
.
chain_id
].
withdrawal_fee
:
(
5
/
(
item
.
price_usd
>
0
?
item
.
price_usd
:
0.001
)).
toFixed
(
4
);
}
}
if
(
item
.
contract
)
{
if
(
item
.
contract
)
{
item
.
is_erc20
=
1
;
item
.
is_erc20
=
1
;
}
else
{
}
item
.
is_erc20
=
0
;
else
{
item
.
is_erc20
=
0
;
}
}
}
}
return
resList
;
return
resList
;
}
}
\ No newline at end of file
export
const
updateIconUrl
=
async
(
param
:
AddParam
,
currentUserId
:
any
,
ip
:
any
)
=>
{
let
id
=
param
.
id
;
let
dbInfo
=
await
coinType
.
prototype
.
findOne
({
where
:
{
id
:
id
},
raw
:
true
});
if
(
!
dbInfo
)
{
throw
ErrorCode
.
DATA_NOT_EXIST
}
let
upInfo
=
{
icon_url
:
param
.
icon_url
,
updatedAt
:
new
Date
(),
}
await
coinType
.
prototype
.
update
(
upInfo
,
{
where
:
{
id
:
id
}
})
//管理后台操作日志
addOptLog
(
currentUserId
,
0
,
'币种管理更新 icon_url'
,
ip
,
JSON
.
stringify
(
param
),
'币种管理'
);
return
'ok'
;
};
\ No newline at end of file
src/functional/router/v1/index.ts
View file @
8d6fa754
...
@@ -90,6 +90,7 @@ const postFunc = {
...
@@ -90,6 +90,7 @@ const postFunc = {
'coinType/audit'
:
coinTypeCtrl
.
audit
,
'coinType/audit'
:
coinTypeCtrl
.
audit
,
'coinType/mixinCoinList'
:
coinTypeCtrl
.
mixinCoinList
,
'coinType/mixinCoinList'
:
coinTypeCtrl
.
mixinCoinList
,
'coinType/chainList'
:
coinTypeCtrl
.
chainList
,
'coinType/chainList'
:
coinTypeCtrl
.
chainList
,
'coinType/updateIconUrl'
:
coinTypeCtrl
.
updateIconUrl
,
//权限管理 - 我的权限
//权限管理 - 我的权限
...
...
src/setting/access-limit.ts
View file @
8d6fa754
...
@@ -39,6 +39,7 @@ let cmdWhiteList = {
...
@@ -39,6 +39,7 @@ let cmdWhiteList = {
'coinType/getAllSubmitSuccess'
:
1
,
'coinType/getAllSubmitSuccess'
:
1
,
'coinType/audit'
:
1
,
'coinType/audit'
:
1
,
'coinType/mixinCoinList'
:
1
,
'coinType/mixinCoinList'
:
1
,
'coinType/updateIconUrl'
:
1
,
//权限管理 - 我的权限
//权限管理 - 我的权限
'user/getInfo'
:
1
,
'user/getInfo'
:
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