明树Git Lab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
L
letian_backend
Project
Project
Details
Activity
Releases
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
zengfanpei
letian_backend
Commits
e392c54c
Commit
e392c54c
authored
Sep 13, 2024
by
zengfanpei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
43dcb978
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
13 deletions
+16
-13
departController.js
controller/departController.js
+3
-3
menuController.js
controller/menuController.js
+2
-2
statisticsController.js
controller/statisticsController.js
+1
-1
userController.js
controller/userController.js
+4
-4
zoneController.js
controller/zoneController.js
+2
-2
userModule.js
module/userModule.js
+4
-1
No files found.
controller/departController.js
View file @
e392c54c
...
...
@@ -21,7 +21,7 @@ async function createDepart(req, res, next) {
if
(
req
.
body
.
parentId
)
{
let
parentDepart
=
await
departModule
.
findOne
({
_id
:
req
.
body
.
parentId
});
if
(
!
(
parentDepart
&&
parentDepart
.
_id
))
{
res
.
sendError
(
errorMessage
.
resourceNotFound
);
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
parentIds
=
parentDepart
.
parentIds
||
[];
parentIds
.
push
(
parentDepart
.
_id
);
...
...
@@ -56,7 +56,7 @@ async function getDepartInfo(req, res, next) {
async
function
updateDepart
(
req
,
res
,
next
)
{
try
{
if
(
!
req
.
body
.
_id
)
{
res
.
sendError
(
errorMessage
.
resourceNotFound
)
re
turn
re
s
.
sendError
(
errorMessage
.
resourceNotFound
)
}
let
updateObj
=
{
...
req
.
body
,
...
...
@@ -67,7 +67,7 @@ async function updateDepart(req, res, next) {
if
(
req
.
body
.
parentId
)
{
let
parentDepart
=
await
departModule
.
findOne
({
_id
:
req
.
body
.
parentId
});
if
(
!
(
parentDepart
&&
parentDepart
.
_id
))
{
res
.
sendError
(
errorMessage
.
resourceNotFound
);
re
turn
re
s
.
sendError
(
errorMessage
.
resourceNotFound
);
}
parentIds
=
parentDepart
.
parentIds
||
[];
parentIds
.
push
(
parentDepart
.
_id
);
...
...
controller/menuController.js
View file @
e392c54c
...
...
@@ -15,7 +15,7 @@ async function createMenu(req, res, next) {
if
(
req
.
body
.
parentId
)
{
let
parentDepart
=
await
DB
.
Menu
.
findOne
({
_id
:
req
.
body
.
parentId
});
if
(
!
(
parentDepart
&&
parentDepart
.
_id
))
{
res
.
sendError
(
errorMessage
.
resourceNotFound
);
re
turn
re
s
.
sendError
(
errorMessage
.
resourceNotFound
);
}
parentIds
=
parentDepart
.
parentIds
||
[];
parentIds
.
push
(
parentDepart
.
_id
);
...
...
@@ -42,7 +42,7 @@ async function updateMenu(req, res, next) {
if
(
req
.
body
.
parentId
)
{
let
parentDepart
=
await
DB
.
Menu
.
findOne
({
_id
:
req
.
body
.
parentId
});
if
(
!
(
parentDepart
&&
parentDepart
.
_id
))
{
res
.
sendError
(
errorMessage
.
resourceNotFound
);
re
turn
re
s
.
sendError
(
errorMessage
.
resourceNotFound
);
}
parentIds
=
parentDepart
.
parentIds
||
[];
parentIds
.
push
(
parentDepart
.
_id
);
...
...
controller/statisticsController.js
View file @
e392c54c
...
...
@@ -211,7 +211,7 @@ async function getAreaDistribution(req, res, next) {
// 跟前端约定 传递对应区域名称
let
zonePre
=
await
DB
.
Zone
.
findOne
({
name
:
req
.
body
.
name
,
del
:
0
});
if
(
!
zonePre
)
{
res
.
sendError
(
errorMessage
.
resourceNotFound
);
re
turn
re
s
.
sendError
(
errorMessage
.
resourceNotFound
);
}
//往下取一层
let
len
=
zonePre
.
parentIds
&&
zonePre
.
parentIds
.
length
||
0
;
...
...
controller/userController.js
View file @
e392c54c
...
...
@@ -42,7 +42,7 @@ async function login(req, res, next) {
const
{
mobile
,
password
}
=
req
.
body
;
const
user
=
await
userModule
.
findUserByMobile
(
mobile
);
if
(
!
user
)
{
res
.
sendError
(
errorMessage
.
loginError
);
re
turn
re
s
.
sendError
(
errorMessage
.
loginError
);
}
const
check
=
utils
.
checkUserPassword
({
reqPw
:
password
,
...
...
@@ -50,7 +50,7 @@ async function login(req, res, next) {
userPw
:
user
.
password
,
});
if
(
!
check
)
{
res
.
sendError
(
errorMessage
.
loginError
)
re
turn
re
s
.
sendError
(
errorMessage
.
loginError
)
}
// 生成一个串 返回前端
let
token
=
crypto
.
randomUUID
();
...
...
@@ -196,7 +196,7 @@ async function getRole(req, res, next) {
let
ret
=
await
DB
.
Role
.
findOne
({
_id
:
req
.
body
.
_id
}).
lean
().
exec
();
if
(
!
(
ret
&&
ret
.
_id
))
{
res
.
sendError
(
errorMessage
.
resourceNotFound
);
re
turn
re
s
.
sendError
(
errorMessage
.
resourceNotFound
);
}
// /**
// * 将role拥有的menus、buttons标记(permission)到菜单树结构中 返回给前端
...
...
@@ -332,7 +332,7 @@ async function updateRole(req, res, next) {
async
function
deleteRole
(
req
,
res
,
next
)
{
try
{
if
(
!
req
.
body
.
_id
)
{
res
.
sendError
(
errorMessage
.
resourceNotFound
)
re
turn
re
s
.
sendError
(
errorMessage
.
resourceNotFound
)
}
// 角色删除 将用户中的角色去掉。$pull 从数组中删除一个指定元素
await
DB
.
User
.
updateMany
({},
{
$pull
:
{
roles
:
(
req
.
body
.
_id
)}});
...
...
controller/zoneController.js
View file @
e392c54c
...
...
@@ -17,7 +17,7 @@ async function create(req, res, next) {
if
(
req
.
body
.
parentId
)
{
let
parentDepart
=
await
DB
.
Zone
.
findOne
({
_id
:
req
.
body
.
parentId
});
if
(
!
(
parentDepart
&&
parentDepart
.
_id
))
{
res
.
sendError
(
errorMessage
.
resourceNotFound
);
re
turn
re
s
.
sendError
(
errorMessage
.
resourceNotFound
);
}
parentIds
=
parentDepart
.
parentIds
||
[];
parentIds
.
push
(
parentDepart
.
_id
);
...
...
@@ -43,7 +43,7 @@ async function update(req, res, next) {
if
(
req
.
body
.
parentId
)
{
let
parentDepart
=
await
DB
.
Zone
.
findOne
({
_id
:
req
.
body
.
parentId
});
if
(
!
(
parentDepart
&&
parentDepart
.
_id
))
{
res
.
sendError
(
errorMessage
.
resourceNotFound
);
re
turn
re
s
.
sendError
(
errorMessage
.
resourceNotFound
);
}
parentIds
=
parentDepart
.
parentIds
||
[];
parentIds
.
push
(
parentDepart
.
_id
);
...
...
module/userModule.js
View file @
e392c54c
...
...
@@ -11,7 +11,10 @@ async function findUserByMobile(mobile) {
if
(
!
mobile
)
{
return
null
;
}
const
user
=
await
DB
.
User
.
findOne
({
mobile
}).
populate
({
path
:
"roles depart avatar"
}).
lean
();
const
user
=
await
DB
.
User
.
findOne
({
mobile
}).
populate
({
path
:
"roles"
,
select
:
"name key"
,
match
:
{
del
:
0
}})
.
populate
({
path
:
"depart"
,
select
:
"name"
,
match
:
{
del
:
0
}})
.
populate
({
path
:
"avatar"
})
.
lean
().
exec
();
//{ path: "roles depart avatar" }
return
user
;
}
...
...
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