明树Git Lab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
J
jt_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
jt_backend
Commits
1b44a342
Commit
1b44a342
authored
Oct 28, 2025
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
ec88b47b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
69 deletions
+14
-69
roleController.js
controller/roleController.js
+6
-1
userController.js
controller/userController.js
+8
-11
userModule.js
module/userModule.js
+0
-54
userRouter.js
router/userRouter.js
+0
-3
No files found.
controller/roleController.js
View file @
1b44a342
...
...
@@ -10,7 +10,12 @@ async function createRole(req, res, next) {
}
async
function
updateRole
(
req
,
res
,
next
)
{
try
{
let
body
=
req
.
body
;
if
(
!
body
.
id
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
)
}
const
ret
=
await
userModule
.
updateOne
({
id
:
body
.
id
},
body
);
return
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
}
...
...
controller/userController.js
View file @
1b44a342
const
crypto
=
require
(
'crypto'
);
const
_
=
require
(
'lodash'
);
const
CryptoJS
=
require
(
'crypto-js'
);
const
{
Op
}
=
require
(
'sequelize'
);
const
{
Op
,
where
}
=
require
(
'sequelize'
);
const
userModule
=
require
(
'../module/userModule'
);
...
...
@@ -10,7 +10,7 @@ const errorMessage = require('../utils/errorMessage');
async
function
regist
(
req
,
res
,
next
)
{
try
{
const
{
salt
,
passwordHash
}
=
utils
.
saltHashPassword
(
req
.
body
.
password
);
const
ret
=
await
userModule
.
create
({
const
ret
=
await
DB
.
User
.
create
({
...
req
.
body
,
salt
,
password
:
passwordHash
,
...
...
@@ -31,7 +31,7 @@ async function login(req, res, next) {
req
.
body
.
password
=
encArr
[
1
];
}
const
{
mobile
,
password
}
=
req
.
body
;
const
user
=
await
userModule
.
findOne
({
mobile
,
del
:
0
,
enable
:
0
});
const
user
=
await
DB
.
User
.
findOne
({
where
:
{
mobile
,
del
:
0
,
enable
:
0
},
raw
:
true
});
console
.
log
(
"----------------------"
,
user
)
if
(
!
user
)
{
return
res
.
sendError
(
errorMessage
.
loginError
);
...
...
@@ -67,7 +67,7 @@ async function login(req, res, next) {
async
function
addUser
(
req
,
res
,
next
)
{
try
{
const
body
=
req
.
body
;
const
ret
=
await
userModule
.
create
(
body
);
const
ret
=
await
DB
.
User
.
create
(
body
);
return
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
...
...
@@ -84,7 +84,7 @@ async function getUserInfo(req, res, next) {
if
(
mobile
)
{
query
.
mobile
=
mobile
;
}
const
ret
=
await
userModule
.
findOne
(
query
);
const
ret
=
await
DB
.
User
.
findOne
({
where
:
query
,
raw
:
true
}
);
return
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
...
...
@@ -97,7 +97,7 @@ async function updateUser(req, res, next) {
if
(
!
body
.
id
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
)
}
const
ret
=
await
userModule
.
updateOne
({
id
:
body
.
id
},
body
);
const
ret
=
await
DB
.
User
.
update
(
body
,
{
where
:
{
id
:
body
.
id
}
}
);
return
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
...
...
@@ -123,7 +123,7 @@ async function listUser(req, res, next) {
search
.
limit
=
limit
;
search
.
offset
=
offset
;
// console.log(JSON.stringify(search), "===")
let
ret
=
await
userModule
.
findAndCountAll
(
search
);
let
ret
=
await
DB
.
User
.
findAndCountAll
(
search
);
return
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
...
...
@@ -143,7 +143,7 @@ async function deleteUser(req, res, next) {
if
(
_
.
isEmpty
(
search
))
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
);
}
const
ret
=
await
userModule
.
updateOne
(
search
,
{
del
:
1
}
);
//删除标记
const
ret
=
await
DB
.
User
.
update
({
del
:
1
},
{
where
:
search
}
);
//删除标记
return
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
...
...
@@ -162,7 +162,4 @@ module.exports = {
getUserInfo
,
updateUser
,
deleteUser
,
// checkUserToken,
// changePassword,
// changePwd,
}
\ No newline at end of file
module/userModule.js
deleted
100644 → 0
View file @
ec88b47b
const
_
=
require
(
"lodash"
);
const
{
where
}
=
require
(
"sequelize"
);
const
errorMessage
=
require
(
"../utils/errorMessage"
);
async
function
create
(
params
)
{
return
DB
.
User
.
create
(
params
);
}
async
function
findOne
(
params
)
{
if
(
_
.
isEmpty
(
params
))
{
return
null
;
}
return
DB
.
User
.
findOne
(
{
where
:
params
,
raw
:
true
}
);
}
async
function
updateOne
(
condition
,
params
)
{
if
(
_
.
isEmpty
(
condition
))
{
return
null
;
}
return
DB
.
User
.
update
(
params
,
{
where
:
condition
});
}
async
function
findAndCountAll
(
condition
)
{
return
DB
.
User
.
findAndCountAll
(
condition
);
}
module
.
exports
=
{
create
,
findOne
,
updateOne
,
findAndCountAll
,
}
\ No newline at end of file
router/userRouter.js
View file @
1b44a342
...
...
@@ -9,14 +9,11 @@ const roleController = require('../controller/roleController');
router
.
post
(
'/regist'
,
userController
.
regist
);
router
.
post
(
'/login'
,
userController
.
login
);
// router.post('/checkUserToken', userController.checkUserToken);
// router.post('/changePassword', userController.changePassword);
router
.
post
(
'/manage/listUser'
,
userController
.
listUser
);
router
.
post
(
'/manage/addUser'
,
userController
.
addUser
);
router
.
post
(
'/manage/updateUser'
,
userController
.
updateUser
);
//更新 enable用户
router
.
post
(
'/manage/getUserInfo'
,
userController
.
getUserInfo
);
router
.
post
(
'/manage/deleteUser'
,
userController
.
deleteUser
);
// 删除
// router.post('/manage/changePwd', userController.changePwd);
/**
...
...
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