Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tikeyi
Overview
Overview
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
node_server
tikeyi
Commits
981f14b1
Commit
981f14b1
authored
Jul 07, 2022
by
maguoliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
s
parent
3a86157a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
454 additions
and
32 deletions
+454
-32
platform.json
mock/platform.json
+335
-2
pagePermissions.ts
src/biz/pagePermissions.ts
+23
-0
crod.ts
src/data/crod.ts
+10
-0
data.ts
src/data/interface/data.ts
+12
-17
pagePermissions.ts
src/data/interface/pagePermissions.ts
+64
-0
router.ts
src/routers/router.ts
+9
-2
serverConfig.ts
src/serverConfig.ts
+1
-11
No files found.
mock/platform.json
View file @
981f14b1
{
"data"
:[{
"id"
:
"aiunsdiunfknd1"
,
"name"
:
"张31"
,
"phoneNumber"
:
"17173887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
],
"userId"
:
"aiunsdiunfknd1"
},{
"id"
:
"aiunsdiunfknd2"
,
"name"
:
"李四2"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
,
"重要活动保障"
],
"userId"
:
"aiunsdiunfknd2"
},{
"id"
:
"aiunsdiunfknd3"
,
"name"
:
"王五3"
,
"phoneNumber"
:
"17373887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
,
"重要活动保障"
],
"userId"
:
"aiunsdiunfknd3"
},{
"userId"
:
"aiunsdiunfknd4"
,
"id"
:
"aiunsdiunfknd4"
,
"name"
:
"王五4"
,
"phoneNumber"
:
"17473887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
]},{
"userId"
:
"aiunsdiunfknd5"
,
"id"
:
"aiunsdiunfknd5"
,
"name"
:
"王五5"
,
"phoneNumber"
:
"17573887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
]},{
"userId"
:
"aiunsdiunfknd6"
,
"id"
:
"aiunsdiunfknd6"
,
"name"
:
"王五6"
,
"phoneNumber"
:
"17673887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
]},{
"userId"
:
"aiunsdiunfknd7"
,
"id"
:
"aiunsdiunfknd7"
,
"name"
:
"王五7"
,
"phoneNumber"
:
"17773887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
]},{
"id"
:
"aiunsdiunfknd8"
,
"name"
:
"王五8"
,
"phoneNumber"
:
"18723887481"
,
"allow"
:[
"整体运行态势"
],
"userId"
:
"aiunsdiunfknd8"
},{
"id"
:
"aiunsdiunfknd9"
,
"name"
:
"王五9"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
,
"重要活动保障"
],
"userId"
:
"aiunsdiunfknd9"
},{
"id"
:
"aiunsdiunfknd10"
,
"name"
:
"王五10"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
],
"userId"
:
"aiunsdiunfknd10"
},{
"id"
:
"aiunsdiunfknd11"
,
"name"
:
"张三11"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"重要活动保障"
],
"userId"
:
"aiunsdiunfknd11"
},{
"id"
:
"aiunsdiunfknd12"
,
"name"
:
"李四12"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
,
"重要活动保障"
],
"userId"
:
"aiunsdiunfknd12"
},{
"id"
:
"aiunsdiunfknd13"
,
"name"
:
"王五13"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"整体运行态势"
],
"userId"
:
"aiunsdiunfknd13"
},{
"userId"
:
"aiunsdiunfknd14"
,
"id"
:
"aiunsdiunfknd14"
,
"name"
:
"王五14"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
]},{
"userId"
:
"aiunsdiunfknd15"
,
"id"
:
"aiunsdiunfknd15"
,
"name"
:
"王五15"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
]},{
"userId"
:
"aiunsdiunfknd16"
,
"id"
:
"aiunsdiunfknd16"
,
"name"
:
"王五16"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
]},{
"userId"
:
"aiunsdiunfknd17"
,
"id"
:
"aiunsdiunfknd17"
,
"name"
:
"王五17"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
]},{
"userId"
:
"aiunsdiunfknd18"
,
"id"
:
"aiunsdiunfknd18"
,
"name"
:
"王五18"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
]},{
"id"
:
"aiunsdiunfknd19"
,
"name"
:
"王五19"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
,
"重要活动保障"
],
"userId"
:
"aiunsdiunfknd19"
},{
"userId"
:
"aiunsdiunfknd20"
,
"id"
:
"aiunsdiunfknd20"
,
"name"
:
"王五20"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
]},{
"userId"
:
"aiunsdiunfknd21"
,
"id"
:
"aiunsdiunfknd21"
,
"name"
:
"张三21"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
,
"重要活动保障"
]},{
"userId"
:
"aiunsdiunfknd22"
,
"id"
:
"aiunsdiunfknd22"
,
"name"
:
"李四22--"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"重要活动保障"
]},{
"userId"
:
"aiunsdiunfknd23"
,
"id"
:
"aiunsdiunfknd23"
,
"name"
:
"王五23"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
]},{
"userId"
:
"aiunsdiunfknd24"
,
"id"
:
"aiunsdiunfknd24"
,
"name"
:
"王五24"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
]},{
"userId"
:
"aiunsdiunfknd25"
,
"id"
:
"aiunsdiunfknd25"
,
"name"
:
"王五25"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
]},{
"userId"
:
"aiunsdiunfknd26"
,
"id"
:
"aiunsdiunfknd26"
,
"name"
:
"王五26"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
]},{
"userId"
:
"aiunsdiunfknd27"
,
"id"
:
"aiunsdiunfknd27"
,
"name"
:
"王五27"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
]},{
"userId"
:
"aiunsdiunfknd28"
,
"id"
:
"aiunsdiunfknd28"
,
"name"
:
"王五28"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
,
"整体运行态势"
]},{
"userId"
:
"aiunsdiunfknd29"
,
"id"
:
"aiunsdiunfknd29"
,
"name"
:
"王五29"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
]},{
"userId"
:
"aiunsdiunfknd30"
,
"name"
:
"王五30"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:[
"数字治理体系"
]}]}
\ No newline at end of file
{
"data"
:
[
{
"id"
:
"aiunsdiunfknd1"
,
"name"
:
"张31"
,
"phoneNumber"
:
"17173887481"
,
"allow"
:
[
"数字治理体系"
],
"hasPermission"
:
false
,
"userId"
:
"aiunsdiunfknd1"
},
{
"id"
:
"aiunsdiunfknd2"
,
"name"
:
"李四2"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
,
"重要活动保障"
],
"hasPermission"
:
true
,
"userId"
:
"aiunsdiunfknd2"
},
{
"id"
:
"aiunsdiunfknd3"
,
"name"
:
"王五3"
,
"phoneNumber"
:
"17373887481"
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
,
"重要活动保障"
],
"hasPermission"
:
true
,
"userId"
:
"aiunsdiunfknd3"
},
{
"userId"
:
"aiunsdiunfknd4"
,
"id"
:
"aiunsdiunfknd4"
,
"name"
:
"王五4"
,
"phoneNumber"
:
"17473887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
]
},
{
"userId"
:
"aiunsdiunfknd5"
,
"id"
:
"aiunsdiunfknd5"
,
"name"
:
"王五5"
,
"phoneNumber"
:
"17573887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
]
},
{
"userId"
:
"aiunsdiunfknd6"
,
"id"
:
"aiunsdiunfknd6"
,
"name"
:
"王五6"
,
"phoneNumber"
:
"17673887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
]
},
{
"userId"
:
"aiunsdiunfknd7"
,
"id"
:
"aiunsdiunfknd7"
,
"name"
:
"王五7"
,
"phoneNumber"
:
"17773887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
]
},
{
"id"
:
"aiunsdiunfknd8"
,
"name"
:
"王五8"
,
"phoneNumber"
:
"18723887481"
,
"allow"
:
[
"整体运行态势"
],
"hasPermission"
:
true
,
"userId"
:
"aiunsdiunfknd8"
},
{
"id"
:
"aiunsdiunfknd9"
,
"name"
:
"王五9"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
,
"重要活动保障"
],
"hasPermission"
:
true
,
"userId"
:
"aiunsdiunfknd9"
},
{
"id"
:
"aiunsdiunfknd10"
,
"name"
:
"王五10"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:
[
"数字治理体系"
],
"hasPermission"
:
true
,
"userId"
:
"aiunsdiunfknd10"
},
{
"id"
:
"aiunsdiunfknd11"
,
"name"
:
"张三11"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
,
"重要活动保障"
],
"hasPermission"
:
true
,
"userId"
:
"aiunsdiunfknd11"
},
{
"id"
:
"aiunsdiunfknd12"
,
"name"
:
"李四12"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
,
"重要活动保障"
],
"hasPermission"
:
true
,
"userId"
:
"aiunsdiunfknd12"
},
{
"id"
:
"aiunsdiunfknd13"
,
"name"
:
"王五13"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:
[
"整体运行态势"
],
"hasPermission"
:
true
,
"userId"
:
"aiunsdiunfknd13"
},
{
"userId"
:
"aiunsdiunfknd14"
,
"id"
:
"aiunsdiunfknd14"
,
"name"
:
"王五14"
,
"phoneNumber"
:
"17273887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
]
},
{
"userId"
:
"aiunsdiunfknd15"
,
"id"
:
"aiunsdiunfknd15"
,
"name"
:
"王五15"
,
"phoneNumber"
:
"17273887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
]
},
{
"userId"
:
"aiunsdiunfknd16"
,
"id"
:
"aiunsdiunfknd16"
,
"name"
:
"王五16"
,
"phoneNumber"
:
"17273887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
]
},
{
"userId"
:
"aiunsdiunfknd17"
,
"id"
:
"aiunsdiunfknd17"
,
"name"
:
"王五17"
,
"phoneNumber"
:
"17273887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
]
},
{
"userId"
:
"aiunsdiunfknd18"
,
"id"
:
"aiunsdiunfknd18"
,
"name"
:
"王五18"
,
"phoneNumber"
:
"17273887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
]
},
{
"id"
:
"aiunsdiunfknd19"
,
"name"
:
"王五19"
,
"phoneNumber"
:
"17273887481"
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
,
"重要活动保障"
],
"hasPermission"
:
true
,
"userId"
:
"aiunsdiunfknd19"
},
{
"userId"
:
"aiunsdiunfknd20"
,
"id"
:
"aiunsdiunfknd20"
,
"name"
:
"王五20"
,
"phoneNumber"
:
"17273887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
]
},
{
"userId"
:
"aiunsdiunfknd21"
,
"id"
:
"aiunsdiunfknd21"
,
"name"
:
"张三21"
,
"phoneNumber"
:
"17273887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
,
"重要活动保障"
]
},
{
"userId"
:
"aiunsdiunfknd22"
,
"id"
:
"aiunsdiunfknd22"
,
"name"
:
"李四22--"
,
"phoneNumber"
:
"17273887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"重要活动保障"
]
},
{
"userId"
:
"aiunsdiunfknd23"
,
"id"
:
"aiunsdiunfknd23"
,
"name"
:
"王五23"
,
"phoneNumber"
:
"17273887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
]
},
{
"userId"
:
"aiunsdiunfknd24"
,
"id"
:
"aiunsdiunfknd24"
,
"name"
:
"王五24"
,
"phoneNumber"
:
"17273887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
]
},
{
"userId"
:
"aiunsdiunfknd25"
,
"id"
:
"aiunsdiunfknd25"
,
"name"
:
"王五25"
,
"phoneNumber"
:
"17273887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
]
},
{
"userId"
:
"aiunsdiunfknd26"
,
"id"
:
"aiunsdiunfknd26"
,
"name"
:
"王五26"
,
"phoneNumber"
:
"17273887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
]
},
{
"userId"
:
"aiunsdiunfknd27"
,
"id"
:
"aiunsdiunfknd27"
,
"name"
:
"王五27"
,
"phoneNumber"
:
"17273887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
]
},
{
"userId"
:
"aiunsdiunfknd28"
,
"id"
:
"aiunsdiunfknd28"
,
"name"
:
"王五28"
,
"phoneNumber"
:
"17273887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
,
"整体运行态势"
]
},
{
"userId"
:
"aiunsdiunfknd29"
,
"id"
:
"aiunsdiunfknd29"
,
"name"
:
"王五29"
,
"phoneNumber"
:
"17273887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
]
},
{
"userId"
:
"aiunsdiunfknd30"
,
"id"
:
"aiunsdiunfknd30"
,
"name"
:
"王五30"
,
"phoneNumber"
:
"17273887481"
,
"hasPermission"
:
true
,
"allow"
:
[
"数字治理体系"
]
}
]
}
\ No newline at end of file
src/biz/pagePermissions.ts
0 → 100644
View file @
981f14b1
import
{
getUserPermission
,
getManagePermission
}
from
"../data/interface/pagePermissions"
;
import
{
BizError
}
from
"../util/bizError"
;
export
async
function
getUserPer
(
req
,
res
)
{
let
{
sessionid
,
userId
}
=
req
.
body
console
.
log
(
userId
,
"userId"
)
// sessionid等接入统一认证后,再校验
if
(
!
userId
)
throw
new
BizError
(
"请求参数错误"
);
let
ret
=
await
getUserPermission
(
sessionid
,
userId
);
res
.
send
(
ret
);
}
export
async
function
managePermission
(
req
,
res
)
{
let
{
sessionid
,
userId
}
=
req
.
body
console
.
log
(
userId
,
"userId"
)
// sessionid等接入统一认证后,再校验
if
(
!
userId
)
throw
new
BizError
(
"请求参数错误"
);
let
ret
=
await
getManagePermission
(
sessionid
,
userId
);
res
.
send
(
ret
);
}
src/data/crod.ts
View file @
981f14b1
const
fs
=
require
(
"fs"
);
const
path
=
require
(
"path"
);
// 读取json文件数据
export
async
function
readFile
(
fileUrl
)
{
let
url
=
path
.
join
(
__dirname
.
substring
(
0
,
__dirname
.
indexOf
(
"out"
)),
fileUrl
);
let
data
=
fs
.
readFileSync
(
url
);
let
person
=
data
.
toString
();
//二进制转化为字符串
person
=
JSON
.
parse
(
person
);
//将字符串转换为json对象
return
person
}
/**
* 对json文件进行添加的操作
* @param fileUrl 文件路径
...
...
src/data/interface/data.ts
View file @
981f14b1
...
...
@@ -198,16 +198,17 @@ export async function getActivityListData() {
return
dataList
||
[];
}
//数字
换管理平台数据
//数字
管理平台列表
export
async
function
getManagePlatformData
(
currentpage
,
allow
,
search
)
{
// await get获取token();
let
{
data
}
=
await
readFile
(
userUrl
)
let
{
data
}
=
await
cord
.
readFile
(
userUrl
)
//全量的数据
let
array
=
[]
// 第一层遍历拿到arr[i].allow所有用户能看到的页面数组。
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
data
[
i
].
number
=
i
+
1
// 第二层遍历拿到所有用户能看到的页面名称。
for
(
let
j
=
0
;
j
<
data
[
i
].
allow
.
length
;
j
++
)
{
...
...
@@ -230,6 +231,7 @@ export async function getManagePlatformData(currentpage, allow, search) {
let
searchArr
=
[]
if
(
search
!==
""
)
{
for
(
let
i
=
0
;
i
<
newArr
.
length
;
i
++
)
{
// 如果某条名称和姓名包含同一个字符,这条数据会重复push到searchArr。 在第242行数组去重。
if
(
newArr
[
i
].
name
.
indexOf
(
search
)
!==
-
1
)
searchArr
.
push
(
newArr
[
i
])
if
(
newArr
[
i
].
phoneNumber
.
indexOf
(
search
)
!==
-
1
)
searchArr
.
push
(
newArr
[
i
])
}
...
...
@@ -237,11 +239,14 @@ export async function getManagePlatformData(currentpage, allow, search) {
searchArr
=
newArr
}
// 经过页面权限、姓名、手机号筛选、去重过后最终返回的数据
const
resArr
=
[...
new
Set
(
searchArr
)]
// 每页10条数据,totalPage一共多少页
const
totalPage
=
Math
.
ceil
(
search
Arr
.
length
/
10
)
const
totalPage
=
Math
.
ceil
(
res
Arr
.
length
/
10
)
// 每页十条数据,用slice处理原数据做分页
const
dataList
=
[...
new
Set
(
searchArr
)]
.
slice
((
currentpage
-
1
)
*
10
,
currentpage
*
10
)
const
dataList
=
resArr
.
slice
((
currentpage
-
1
)
*
10
,
currentpage
*
10
)
let
ret
:
any
=
{
userName
:
"王小虎"
,
...
...
@@ -250,33 +255,24 @@ export async function getManagePlatformData(currentpage, allow, search) {
pagenation
:
{
currentPage
:
currentpage
,
totalPage
,
totalNum
:
search
Arr
.
length
,
totalNum
:
res
Arr
.
length
,
}
}
return
ret
;
}
//
数字换管理平台数据
//
更新数字管理平台数据,用户权限
export
async
function
updateManagePlatform
(
params
)
{
// await get获取token();
//更新json里面的数据
await
cord
.
updataJson
(
userUrl
,
params
.
id
,
params
)
await
readFile
(
userUrl
)
await
cord
.
readFile
(
userUrl
)
return
{
code
:
200
,
msg
:
"修改成功"
,
success
:
true
};
}
// 读取json文件数据
function
readFile
(
fileUrl
)
{
let
url
=
path
.
join
(
__dirname
.
substring
(
0
,
__dirname
.
indexOf
(
"out"
)),
fileUrl
);
let
data
=
fs
.
readFileSync
(
url
);
let
person
=
data
.
toString
();
//二进制转化为字符串
person
=
JSON
.
parse
(
person
);
//将字符串转换为json对象
return
person
}
\ No newline at end of file
src/data/interface/pagePermissions.ts
0 → 100644
View file @
981f14b1
// 二级页面 it服务管理模块 用户权限(当前登录用户可以看到那些大屏页面)
import
*
as
cord
from
"../crod"
const
userUrl
=
'./mock/platform.json'
;
export
async
function
getUserPermission
(
sessionid
:
string
,
userId
:
string
)
{
// 暂不校验sessionid。 接入统一认证后,需要校验sessionid是否有效。
let
ret
:
any
=
{
code
:
200
,
success
:
true
,
}
let
{
data
}
=
await
cord
.
readFile
(
userUrl
)
let
idArr
=
[]
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
idArr
.
push
(
data
[
i
].
id
)
}
if
(
idArr
.
indexOf
(
userId
)
===
-
1
)
{
ret
.
msg
=
"userId不存在!"
}
else
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
userId
===
data
[
i
].
id
)
{
ret
.
allow
=
data
[
i
].
allow
}
}
}
return
ret
;
}
export
async
function
getManagePermission
(
sessionid
:
string
,
userId
:
string
)
{
// 暂不校验sessionid。 接入统一认证后,需要校验sessionid是否有效。
let
ret
:
any
=
{
code
:
200
,
success
:
true
,
}
let
{
data
}
=
await
cord
.
readFile
(
userUrl
)
let
idArr
=
[]
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
idArr
.
push
(
data
[
i
].
id
)
}
if
(
idArr
.
indexOf
(
userId
)
===
-
1
)
{
ret
.
hasPermission
=
false
ret
.
code
=
500
ret
.
success
=
false
}
else
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
userId
===
data
[
i
].
id
)
{
ret
.
hasPermission
=
data
[
i
].
hasPermission
}
}
}
return
ret
;
}
\ No newline at end of file
src/routers/router.ts
View file @
981f14b1
...
...
@@ -3,6 +3,7 @@ import * as sjzltxBiz from '../biz/sjzltx';
import
*
as
ztyxtsBiz
from
'../biz/ztyxts'
;
import
*
as
zyhdbzBiz
from
'../biz/zyhdbz'
;
import
*
as
glptlb
from
'../biz/glptlb'
;
import
*
as
pagePermission
from
'../biz/pagePermissions'
;
export
function
setRouter
(
httpServer
){
httpServer
.
get
(
'/sjzltx'
,
asyncHandler
(
sjzltxBiz
.
getData
));
...
...
@@ -17,9 +18,14 @@ export function setRouter(httpServer){
httpServer
.
get
(
'/zyhdbzpop'
,
asyncHandler
(
zyhdbzBiz
.
getPopData
));
httpServer
.
post
(
'/zyhdbzpop'
,
asyncHandler
(
zyhdbzBiz
.
getPopData
));
httpServer
.
get
(
'/glptlb'
,
asyncHandler
(
glptlb
.
getData
));
//
httpServer.get('/glptlb', asyncHandler(glptlb.getData));
httpServer
.
post
(
'/glptlb'
,
asyncHandler
(
glptlb
.
getData
));
httpServer
.
get
(
'/glptlb/update'
,
asyncHandler
(
glptlb
.
update
));
//
httpServer.get('/glptlb/update', asyncHandler(glptlb.update));
httpServer
.
post
(
'/glptlb/update'
,
asyncHandler
(
glptlb
.
update
));
httpServer
.
post
(
'/getUserPermission'
,
asyncHandler
(
pagePermission
.
getUserPer
));
// httpServer.get('/getUserPermission', asyncHandler(pagePermission.getUserPer));
httpServer
.
post
(
'/managePermission'
,
asyncHandler
(
pagePermission
.
managePermission
));
}
\ No newline at end of file
src/serverConfig.ts
View file @
981f14b1
//端口
export
function
getPort
()
:
number
{
return
Number
(
process
.
env
.
PORT
)
||
Number
(
process
.
argv
[
3
])
||
999
;
//测试环境7474
return
Number
(
process
.
env
.
PORT
)
||
Number
(
process
.
argv
[
3
])
||
7474
;
//测试环境7474
}
// sit 测试环境 prod 生产环境 dem 演示环境(测试数据,前端无密码访问)
...
...
@@ -14,12 +14,3 @@ export let requestConfig = {
client_id
:
'75cb2a016ec640a886f681b2d3ae6f3c'
,
client_secret
:
'df795bea090e441fba6361645d18d5de'
};
function
getDBUrl
(){
return
'mongodb://127.0.0.1:27017/keyi_platform'
;
}
//mongo数据库连接字符
export
const
mongoServerConstVal
=
{
platformDBUrl
:
getDBUrl
()
}
\ No newline at end of file
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