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
3d6790b2
Commit
3d6790b2
authored
Sep 18, 2024
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
逻辑调整
parent
35310c78
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
81 additions
and
73 deletions
+81
-73
aclRoleAuth.control.ts
src/functional/mvc/control/aclRoleAuth.control.ts
+3
-3
aclUser.control.ts
src/functional/mvc/control/aclUser.control.ts
+2
-0
aclRoleAuth.service.ts
src/functional/mvc/service/aclRoleAuth.service.ts
+69
-62
mUserManage.service.ts
src/functional/mvc/service/mUserManage.service.ts
+3
-6
userOpt.service.ts
src/functional/mvc/service/userOpt.service.ts
+2
-0
index.ts
src/functional/router/v1/index.ts
+1
-1
access-limit.ts
src/setting/access-limit.ts
+1
-1
No files found.
src/functional/mvc/control/aclRoleAuth.control.ts
View file @
3d6790b2
...
@@ -217,7 +217,7 @@ export const delRole = async (req: any, aclRoleVO: AclRoleVO) => {
...
@@ -217,7 +217,7 @@ export const delRole = async (req: any, aclRoleVO: AclRoleVO) => {
/**
/**
* 修改角色权限
* 修改角色权限
-接口逻辑合并到保存角色接口中-此接口目前无用
* @param req
* @param req
* @param infoVO
* @param infoVO
*/
*/
...
@@ -226,8 +226,8 @@ export const changeRoleAuth = async (req: any, aclAuthVO: AclAuthVO) => {
...
@@ -226,8 +226,8 @@ export const changeRoleAuth = async (req: any, aclAuthVO: AclAuthVO) => {
let
cmd
=
req
.
path
;
let
cmd
=
req
.
path
;
try
{
try
{
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
aclAuthVO
.
id
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
aclAuthVO
.
id
);
let
res
=
await
aclRoleAuthService
.
changeRoleAuth
(
aclAuthVO
.
id
,
aclAuthVO
.
authIds
,
req
.
cookies
.
session_id
);
//
let res = await aclRoleAuthService.changeRoleAuth(aclAuthVO.id, aclAuthVO.authIds, req.cookies.session_id);
return
Res3Utils
.
result
(
res
);
//
return Res3Utils.result(res);
}
}
catch
(
e
)
{
catch
(
e
)
{
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
logger
.
error
(
`
${
func_name
}
error:
${
e
}
`
);
...
...
src/functional/mvc/control/aclUser.control.ts
View file @
3d6790b2
...
@@ -130,6 +130,7 @@ async function preCheck(aclUserInfoVO: AclUserInfoVO) {
...
@@ -130,6 +130,7 @@ async function preCheck(aclUserInfoVO: AclUserInfoVO) {
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
aclUserInfoVO
.
position_id
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
aclUserInfoVO
.
position_id
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
aclUserInfoVO
.
role_ids
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
aclUserInfoVO
.
role_ids
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
aclUserInfoVO
.
totp_encrypt
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
aclUserInfoVO
.
totp_encrypt
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
aclUserInfoVO
.
pwd
);
if
(
aclUserInfoVO
.
pwd
&&
(
aclUserInfoVO
.
pwd
.
length
<
8
||
aclUserInfoVO
.
pwd
.
length
>
30
))
{
if
(
aclUserInfoVO
.
pwd
&&
(
aclUserInfoVO
.
pwd
.
length
<
8
||
aclUserInfoVO
.
pwd
.
length
>
30
))
{
throw
ErrorCode
.
PWD_ILLEGAL
;
throw
ErrorCode
.
PWD_ILLEGAL
;
}
}
...
@@ -142,6 +143,7 @@ async function updatePreCheck(aclUserInfoVO: AclUserInfoVO) {
...
@@ -142,6 +143,7 @@ async function updatePreCheck(aclUserInfoVO: AclUserInfoVO) {
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
aclUserInfoVO
.
position_id
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
aclUserInfoVO
.
position_id
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
aclUserInfoVO
.
role_ids
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
aclUserInfoVO
.
role_ids
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
aclUserInfoVO
.
totp_encrypt
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
aclUserInfoVO
.
totp_encrypt
);
ApiAssert
.
notNull
(
ErrorCode
.
PARAM_MISS
,
aclUserInfoVO
.
pwd
);
if
(
aclUserInfoVO
.
pwd
&&
(
aclUserInfoVO
.
pwd
.
length
<
8
||
aclUserInfoVO
.
pwd
.
length
>
30
))
{
if
(
aclUserInfoVO
.
pwd
&&
(
aclUserInfoVO
.
pwd
.
length
<
8
||
aclUserInfoVO
.
pwd
.
length
>
30
))
{
throw
ErrorCode
.
PWD_ILLEGAL
;
throw
ErrorCode
.
PWD_ILLEGAL
;
}
}
...
...
src/functional/mvc/service/aclRoleAuth.service.ts
View file @
3d6790b2
...
@@ -55,7 +55,9 @@ export interface AclRoleVO {
...
@@ -55,7 +55,9 @@ export interface AclRoleVO {
updatedAt
?:
Date
|
any
;
updatedAt
?:
Date
|
any
;
roleIds
?:
any
roleIds
?:
any
;
authIds
?:
any
;
}
}
export
interface
AclRolePageVO
extends
AclRoleVO
{
export
interface
AclRolePageVO
extends
AclRoleVO
{
...
@@ -155,6 +157,7 @@ export const saveAuth = async (aclAuthVO: AclAuthVO, session_id: any) => {
...
@@ -155,6 +157,7 @@ export const saveAuth = async (aclAuthVO: AclAuthVO, session_id: any) => {
url
:
aclAuthVO
.
url
,
url
:
aclAuthVO
.
url
,
type
:
aclAuthVO
.
type
,
type
:
aclAuthVO
.
type
,
idx_number
:
aclAuthVO
.
idx_number
,
idx_number
:
aclAuthVO
.
idx_number
,
opt_type
:
aclAuthVO
.
opt_type
?
aclAuthVO
.
opt_type
:
4
,
remark
:
aclAuthVO
.
remark
remark
:
aclAuthVO
.
remark
},
{
},
{
where
:
{
id
:
aclAuthVO
.
id
}
where
:
{
id
:
aclAuthVO
.
id
}
...
@@ -162,6 +165,9 @@ export const saveAuth = async (aclAuthVO: AclAuthVO, session_id: any) => {
...
@@ -162,6 +165,9 @@ export const saveAuth = async (aclAuthVO: AclAuthVO, session_id: any) => {
}
}
else
{
else
{
await
_checkUrl
(
aclAuthVO
.
url
);
await
_checkUrl
(
aclAuthVO
.
url
);
if
(
!
aclAuthVO
.
opt_type
){
aclAuthVO
.
opt_type
=
4
;
}
aclAuth
.
prototype
.
create
(
aclAuthVO
);
aclAuth
.
prototype
.
create
(
aclAuthVO
);
}
}
addOptLog
(
null
,
0
,
'新增/修改权限'
,
""
,
JSON
.
stringify
(
aclAuthVO
),
'权限管理'
,
session_id
);
addOptLog
(
null
,
0
,
'新增/修改权限'
,
""
,
JSON
.
stringify
(
aclAuthVO
),
'权限管理'
,
session_id
);
...
@@ -255,29 +261,56 @@ export const getRoleByUser = async (userId: number | any) => {
...
@@ -255,29 +261,56 @@ export const getRoleByUser = async (userId: number | any) => {
};
};
export
const
saveRole
=
async
(
aclRoleVO
:
AclRoleVO
)
=>
{
export
const
saveRole
=
async
(
aclRoleVO
:
AclRoleVO
)
=>
{
let
roleId
=
Number
(
aclRoleVO
.
id
);
if
(
aclRoleVO
.
id
)
{
let
authIds
=
aclRoleVO
.
authIds
;
await
aclRole
.
prototype
.
update
({
let
tx
;
name
:
aclRoleVO
.
name
,
try
{
remark
:
aclRoleVO
.
remark
tx
=
await
madAdminOrmDB
.
transaction
();
},
{
if
(
roleId
)
{
where
:
{
let
role
=
await
aclRole
.
prototype
.
find
({
id
:
aclRoleVO
.
id
,
where
:
{
creator
:
aclRoleVO
.
creator
id
:
roleId
,
},
raw
:
true
});
if
(
!
role
)
{
throw
ErrorCode
.
ROLE_NOT_EXIST
}
}
})
await
aclRole
.
prototype
.
update
({
name
:
aclRoleVO
.
name
,
remark
:
aclRoleVO
.
remark
},
{
where
:
{
id
:
roleId
,
creator
:
aclRoleVO
.
creator
},
transaction
:
tx
})
}
else
{
// 创建
let
insertInfo
=
await
aclRole
.
prototype
.
create
({
name
:
aclRoleVO
.
name
,
remark
:
aclRoleVO
.
remark
,
creator
:
aclRoleVO
.
creator
,
type
:
aclRoleVO
.
type
?
aclRoleVO
.
type
:
0
,
},
{
transaction
:
tx
});
roleId
=
insertInfo
.
id
}
await
changeRoleAuth
(
roleId
,
authIds
,
tx
);
await
tx
.
commit
();
}
}
else
{
catch
(
e
)
{
// 创建
if
(
tx
)
{
await
aclRole
.
prototype
.
create
({
await
tx
.
rollback
();
name
:
aclRoleVO
.
name
,
}
remark
:
aclRoleVO
.
remark
,
logger
.
error
(
'saveRole.error:'
+
e
);
creator
:
aclRoleVO
.
creator
,
throw
e
;
type
:
aclRoleVO
.
type
?
aclRoleVO
.
type
:
0
,
})
}
}
addOptLog
(
aclRoleVO
.
creator
,
0
,
'保存角色
'
,
""
,
JSON
.
stringify
(
aclRoleVO
)
,
'后台角色管理'
);
addOptLog
(
aclRoleVO
.
creator
,
0
,
'保存角色
和权限'
,
""
,
`role_id:
${
roleId
}
,authIds:
${
authIds
}
`
,
'后台角色管理'
);
return
"ok"
;
return
"ok"
;
};
};
...
@@ -339,30 +372,21 @@ export const delRole = async (id: number | any, currentUserId: number) => {
...
@@ -339,30 +372,21 @@ export const delRole = async (id: number | any, currentUserId: number) => {
};
};
export
const
changeRoleAuth
=
async
(
id
:
number
|
any
,
authIds
:
any
,
session_id
:
any
)
=>
{
const
changeRoleAuth
=
async
(
id
:
number
|
any
,
authIds
:
any
,
tx
:
any
)
=>
{
let
sp
=
authIds
.
split
(
","
);
let
sp
=
authIds
.
split
(
","
);
let
role
=
await
aclRole
.
prototype
.
find
({
where
:
{
id
:
id
,
},
raw
:
true
});
if
(
!
role
)
{
throw
ErrorCode
.
ROLE_NOT_EXIST
}
let
authIDArr
:
any
[]
=
[];
let
authIDArr
:
any
[]
=
[];
for
(
let
i
of
sp
)
{
for
(
let
i
of
sp
)
{
if
(
!
isNaN
(
i
))
{
if
(
!
isNaN
(
i
))
{
authIDArr
.
push
(
i
)
authIDArr
.
push
(
i
)
}
}
}
}
if
(
!
authIDArr
.
length
)
{
if
(
!
authIDArr
.
length
)
{
// 没有指定权限的,直接删除角色对应的所有权限。
// 没有指定权限的,直接删除角色对应的所有权限。
await
aclRoleAuth
.
prototype
.
destroy
({
await
aclRoleAuth
.
prototype
.
destroy
({
where
:
{
where
:
{
role_id
:
id
role_id
:
id
}
},
transaction
:
tx
})
})
}
}
else
{
else
{
...
@@ -401,40 +425,23 @@ export const changeRoleAuth = async (id: number | any, authIds: any, session_id:
...
@@ -401,40 +425,23 @@ export const changeRoleAuth = async (id: number | any, authIds: any, session_id:
addData
.
push
(
item
)
addData
.
push
(
item
)
}
}
}
}
let
tx
;
if
(
deleteIDArr
.
length
)
{
try
{
await
aclRoleAuth
.
prototype
.
destroy
({
tx
=
await
madAdminOrmDB
.
transaction
()
where
:
{
if
(
deleteIDArr
.
length
)
{
role_id
:
id
,
await
aclRoleAuth
.
prototype
.
destroy
({
auth_id
:
{
[
madAdminOrmDB
.
Op
.
in
]:
deleteIDArr
}
where
:
{
},
role_id
:
id
,
transaction
:
tx
auth_id
:
{
[
madAdminOrmDB
.
Op
.
in
]:
deleteIDArr
}
})
},
transaction
:
tx
})
}
if
(
addData
.
length
)
{
await
aclRoleAuth
.
prototype
.
bulkCreate
(
addData
,
{
transaction
:
tx
})
}
await
tx
.
commit
();
tx
=
null
;
}
}
catch
(
e
)
{
if
(
addData
.
length
)
{
if
(
tx
)
{
await
aclRoleAuth
.
prototype
.
bulkCreate
(
addData
,
{
await
tx
.
rollback
();
transaction
:
tx
}
})
throw
e
}
}
}
addOptLog
(
null
,
0
,
'修改角色权限'
,
""
,
`role_id:
${
id
}
,authIds:
${
authIds
}
`
,
'后台角色管理'
,
session_id
);
return
"ok"
}
};
};
...
...
src/functional/mvc/service/mUserManage.service.ts
View file @
3d6790b2
...
@@ -418,21 +418,18 @@ async function buildReturnData(pageData: any, fill_user_info: boolean, fill_coin
...
@@ -418,21 +418,18 @@ async function buildReturnData(pageData: any, fill_user_info: boolean, fill_coin
//初始化
//初始化
let
wallet_account_balance
=
new
BigNumber
(
String
(
walletAssetMap
[
item
.
user_id
].
balance_usdt
)).
add
(
new
BigNumber
(
String
(
walletAssetMap
[
item
.
user_id
].
holds_usdt
)));
let
wallet_account_balance
=
new
BigNumber
(
String
(
walletAssetMap
[
item
.
user_id
].
balance_usdt
)).
add
(
new
BigNumber
(
String
(
walletAssetMap
[
item
.
user_id
].
holds_usdt
)));
let
trade_account_balance
=
new
BigNumber
(
String
(
tradeAssetMap
[
item
.
user_id
].
balance_usdt
)).
add
(
new
BigNumber
(
String
(
tradeAssetMap
[
item
.
user_id
].
holds_usdt
)));
let
trade_account_balance
=
new
BigNumber
(
String
(
tradeAssetMap
[
item
.
user_id
].
balance_usdt
)).
add
(
new
BigNumber
(
String
(
tradeAssetMap
[
item
.
user_id
].
holds_usdt
)));
let
assets_total
=
wallet_account_balance
.
add
(
trade_account_balance
);
let
oneRealName
=
realNameMap
[
item
.
user_id
];
let
oneRealName
=
realNameMap
[
item
.
user_id
];
let
one
=
{
let
one
=
{
user_id
:
user_id
,
user_id
:
user_id
,
real_name
:
item
.
real_name
?
item
.
real_name
:
""
,
real_name
:
item
.
real_name
?
item
.
real_name
:
""
,
email
:
item
.
email
?
item
.
email
:
""
,
email
:
item
.
email
?
item
.
email
:
""
,
register_date
:
item
.
createdAt
?
item
.
createdAt
:
""
,
register_date
:
item
.
createdAt
?
item
.
createdAt
:
""
,
spot_trade_total
:
0
,
//TODO:现货交易总量
contract_trade_total
:
0
,
//TODO:永续合约交易总量
spot_balance
:
0
,
//TODO:现货余额
spot_balance
:
0
,
//TODO:现货余额
contract_balance
:
0
,
//TODO:永续合约余额
contract_balance
:
0
,
//TODO:永续合约余额
assets_total
:
0
,
//TODO: 总资产
assets_total
:
assets_total
,
//总资产
spot_order
:
0
,
//TODO: 现货订单数量
contract_order
:
0
,
//TODO: 永续合约订单数量
wallet_account_balance
:
wallet_account_balance
,
//钱包账户余额
wallet_account_balance
:
wallet_account_balance
,
//钱包账户余额
trade_account_balance
:
trade_account_balance
,
//
TODO:
交易账户余额
trade_account_balance
:
trade_account_balance
,
//交易账户余额
kyc_status
:
oneRealName
?
oneRealName
.
status
:
0
,
//0未提交,1审核中,2审核不通过,3审核通过
kyc_status
:
oneRealName
?
oneRealName
.
status
:
0
,
//0未提交,1审核中,2审核不通过,3审核通过
kyc_type
:
oneRealName
?
oneRealName
.
type
:
0
,
//1身份证,2护照,3驾驶证
kyc_type
:
oneRealName
?
oneRealName
.
type
:
0
,
//1身份证,2护照,3驾驶证
kyc_identity
:
item
.
kyc_identity
?
item
.
kyc_identity
:
""
,
kyc_identity
:
item
.
kyc_identity
?
item
.
kyc_identity
:
""
,
...
...
src/functional/mvc/service/userOpt.service.ts
View file @
3d6790b2
...
@@ -95,6 +95,8 @@ export const getInfoDetailByUserId = async (user_id: number | any) => {
...
@@ -95,6 +95,8 @@ export const getInfoDetailByUserId = async (user_id: number | any) => {
user_status
:
dbUserInfo
.
user_status
,
user_status
:
dbUserInfo
.
user_status
,
account
:
dbUserInfo
.
account
,
account
:
dbUserInfo
.
account
,
pwd
:
dbUserInfo
.
pwd
,
pwd
:
dbUserInfo
.
pwd
,
pwd_salt
:
dbUserInfo
.
pwd_salt
,
pwd_status
:
dbUserInfo
.
pwd_status
,
roleSet
:
roleSet
,
roleSet
:
roleSet
,
authSet
:
authSet
,
authSet
:
authSet
,
hasTotp
:
dbUserInfo
&&
dbUserInfo
.
totp_encrypt
?
1
:
0
,
hasTotp
:
dbUserInfo
&&
dbUserInfo
.
totp_encrypt
?
1
:
0
,
...
...
src/functional/router/v1/index.ts
View file @
3d6790b2
...
@@ -70,7 +70,7 @@ const postFunc = {
...
@@ -70,7 +70,7 @@ const postFunc = {
'acl/role/getAll'
:
aclRoleAuthCtrl
.
getAllRole
,
'acl/role/getAll'
:
aclRoleAuthCtrl
.
getAllRole
,
'acl/role/save'
:
aclRoleAuthCtrl
.
saveRole
,
'acl/role/save'
:
aclRoleAuthCtrl
.
saveRole
,
'acl/role/del'
:
aclRoleAuthCtrl
.
delRole
,
'acl/role/del'
:
aclRoleAuthCtrl
.
delRole
,
'acl/changeRoleAuth'
:
aclRoleAuthCtrl
.
changeRoleAuth
,
//
'acl/changeRoleAuth': aclRoleAuthCtrl.changeRoleAuth,
'acl/auth/list'
:
aclRoleAuthCtrl
.
authList
,
'acl/auth/list'
:
aclRoleAuthCtrl
.
authList
,
'acl/auth/tree'
:
aclRoleAuthCtrl
.
getAuthTree
,
'acl/auth/tree'
:
aclRoleAuthCtrl
.
getAuthTree
,
'acl/auth/getByUser'
:
aclRoleAuthCtrl
.
getAuthByUser
,
'acl/auth/getByUser'
:
aclRoleAuthCtrl
.
getAuthByUser
,
...
...
src/setting/access-limit.ts
View file @
3d6790b2
...
@@ -43,7 +43,7 @@ let cmdWhiteList = {
...
@@ -43,7 +43,7 @@ let cmdWhiteList = {
'acl/role/getAll'
:
1
,
'acl/role/getAll'
:
1
,
'acl/role/save'
:
1
,
'acl/role/save'
:
1
,
'acl/role/del'
:
1
,
'acl/role/del'
:
1
,
'acl/changeRoleAuth'
:
1
,
//
'acl/changeRoleAuth': 1,
'acl/auth/list'
:
1
,
'acl/auth/list'
:
1
,
'acl/auth/tree'
:
1
,
'acl/auth/tree'
:
1
,
'acl/auth/getByUser'
:
1
,
'acl/auth/getByUser'
:
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