Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
付智勇
/
koa2_Sequelize_project
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
付智勇
8 years ago
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a577857bdcbab68a2b481a5fc2cdb1a2a30620b7
a577857b
1 parent
a1c281d0
用户列表查询
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
11 行增加
和
5 行删除
controller/userController.js
services/userService.js
controller/userController.js
查看文件 @
a577857
...
...
@@ -73,7 +73,7 @@ userController.prototype.login = async(ctx, next) =>{
}
if
(
!
userData
.
code
){
return
userBack
;
}
else
{
return
userData
;
}
...
...
@@ -84,12 +84,13 @@ userController.prototype.login = async(ctx, next) =>{
}
userController
.
prototype
.
getStu
=
async
(
ctx
,
next
)
=>
{
try
{
const
stuType
=
ctx
.
params
.
type
;
if
(
!
stuType
){
return
status
.
paramError
(
'type'
);
}
try
{
let
stu
=
await
userService
.
getStu
(
stuType
);
return
stu
}
catch
(
error
)
{
...
...
@@ -133,7 +134,7 @@ userController.prototype.delUserByUserId = async(ctx,next) => {
userController
.
prototype
.
resetPasswordByUserId
=
async
(
ctx
,
next
)
=>
{
const
userId
=
ctx
.
params
.
userId
;
const
pw
=
saitMd5
.
md5AddSalt
(
'123
0
56'
)
const
pw
=
saitMd5
.
md5AddSalt
(
'123
4
56'
)
if
(
!
userId
){
return
status
.
paramError
(
'userId'
);
...
...
services/userService.js
查看文件 @
a577857
...
...
@@ -45,10 +45,15 @@ userService.prototype.login = async(name,pw) => {
userService
.
prototype
.
getStu
=
async
(
type
)
=>
{
try
{
let
User
=
await
userModel
.
findAll
({
where
:{
userType
:
type
}});
let
sql
=
`
SELECT
u
.
*
,
ug
.
name
FROM
3
m_user
u
LEFT
JOIN
3
m_user_group
ug
ON
ug
.
id
=
u
.
group_id
`
let
User
=
await
sequelize
.
query
(
sql
);
return
User
}
catch
(
error
)
{
throw
new
Error
(
err
);
throw
new
Error
(
err
or
);
}
}
...
...
请
注册
或
登录
后发表评论