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
付智勇
2017-08-28 16:55:06 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7397b16266ffdd2d68ea7d338ad061045ab0dafb
7397b162
1 parent
4f0831fe
用户api
显示空白字符变更
内嵌
并排对比
正在显示
7 个修改的文件
包含
168 行增加
和
9 行删除
controller/userController.js
docs/meeting.md
docs/api.md → docs/user.md
routes/users.js
services/classService.js
services/userService.js
util/emailUtil.js
controller/userController.js
查看文件 @
7397b16
...
...
@@ -114,7 +114,7 @@ userController.prototype.login = async(ctx, next) =>{
userController
.
prototype
.
getStu
=
async
(
ctx
,
next
)
=>
{
try
{
const
stuType
=
ctx
.
params
.
type
;
const
stuType
=
ctx
.
request
.
body
;
if
(
!
stuType
){
return
status
.
paramError
(
'type'
);
}
...
...
docs/meeting.md
0 → 100644
查看文件 @
7397b16
## 课堂管理
### 创建课堂
\ No newline at end of file
...
...
docs/
api
.md → docs/
user
.md
查看文件 @
7397b16
# 网校接口文档
## 用户管理
...
...
@@ -103,4 +102,150 @@
## 用户查询
请求url
post /users/getUser
请求参数:
localhost:3000/users/getUser
查询条件都可以不填就是查询所有
{
"loginName": "尼安德特", // 登录名
"password": "123456", //登录密码
"companyName":"bat", //公司名字
"userName":"尼安德特人", //用户名
"userRole":0, // 用户角色 0超级管理员,1管理员,2监课,3老师,4学生
"userEmail":"kengni@buyouyu.com", // 用户邮箱
"userMobile":123124, // 用户手机号
"content":"2017-09-01", // 用户简介
"groupId":1 //用户组id
}
返回参数:
{
"code": 200,
"returnData": {
"data": {
"users":
[
{
"id": "aMwJvonVWdyL4Em2ZmZDR5AP72YblpkK",
"loginName": "l3989",
"IDcard": "231243",
"password": "4eef3be2f1aa6240ada14d0df9720d05",
"salt": 21,
"companyName": "bat",
"userName": "智人",
"userType": 1,
"userRole": 3,
"userEmail": "42237539@qq.com",
"userMobile": "12328555324",
"createTime": "2017-08-28 06:50:01",
"endTime": "Invalid date",
"content": "2017-09-01",
"serialNo": 0,
"siteId": "3m",
"userStatus": 0,
"groupId": "1"
},
{
"id": "Rv2G3Ay45kjp6B1XyalrMLzEg0DJ9mdQ",
"loginName": "0bk4a",
"IDcard": "231243",
"password": "a071495b74b65a34559c76227e0633a4",
"salt": 5,
"companyName": "bat",
"userName": "智人",
"userType": 1,
"userRole": 3,
"userEmail": "422339@qq.com",
"userMobile": "12328555824",
"createTime": "2017-08-28 06:46:56",
"endTime": "Invalid date",
"content": "2017-09-01",
"serialNo": 0,
"siteId": "3m",
"userStatus": 0,
"groupId": "1"
}
],
"count": 2,
"page": 1,
"pageno": 10
}
}
}
## 用户编辑
请求url
put localhost:3000/users/updateUserByUserId/:id
请求参数(可选填):
{
"loginName": "尼安德特20",
"IDcard": "231243",
"companyName": "bat",
"userName": "小asd明",
"userEmail": "15314352890@163.com",
"userMobile": "123280824",
"createTime": "2017-08-28 06:41:30",
"endTime": "Invalid date",
"content": "2017-09-asd"
}
返回参数:
{
"code": 200,
"returnData": {
"data": {
"id": "GpQKn0yLMda7OVXMZ82PqYvjAxZ5493J",
"loginName": "尼安德特20",
"IDcard": "231243",
"password": "d2322484d96897dca51bef5dc8126ef2",
"salt": 65,
"companyName": "bat",
"userName": "小asd明",
"userType": 1,
"userRole": 4,
"userEmail": "15314352890@163.com",
"userMobile": "123280824",
"createTime": "2017-08-27 22:41:30",
"endTime": "Invalid date",
"content": "2017-09-asd",
"serialNo": 0,
"siteId": "3m",
"userStatus": 0,
"groupId": "1"
}
}
}
## 删除用户
请求url
localhost:3000/users/delUserByUserId/:id
请求参数:
名称|类型|描述
:--|:--|:--
|id |string |必须, 用户ID |
返回参数:
{
"code": 200,
"returnData": {
"data": 1
}
}
...
...
routes/users.js
查看文件 @
7397b16
...
...
@@ -43,7 +43,7 @@ router.get('/authLogin.html', async function(ctx, next){
/**
*获取用户列表
*/
router
.
get
(
'/getStu/:type
'
,
async
(
ctx
,
next
)
=>
{
router
.
post
(
'/getUser
'
,
async
(
ctx
,
next
)
=>
{
try
{
var
data
=
await
userContoller
.
getStu
(
ctx
,
next
);
status
.
successTemp
(
ctx
,
200
,
data
);
...
...
services/classService.js
0 → 100644
查看文件 @
7397b16
// export class Point {
// constructor(x, y) {
// this.x = x;
// this.y = y;
// }
// a() {
// return '(' + this.x + ', ' + this.y + ')';
// }
// }
\ No newline at end of file
...
...
services/userService.js
查看文件 @
7397b16
...
...
@@ -69,8 +69,10 @@ userService.prototype.getStu = async(type,page = 1,pageno =10)=>{
FROM
3
m_user
u
LEFT
JOIN
3
m_user_group
ug
ON
ug
.
id
=
u
.
group_id
`
;
let
users
=
await
userModel
.
findAll
({
where
:
type
,
offset
:
(
page
-
1
)
*
pageno
,
limit
:
pageno
});
let
count
=
await
userModel
.
count
({
where
:
type
})
let
User
=
await
sequelize
.
query
(
sql
);
return
User
return
{
users
:
users
,
count
:
count
,
page
:
page
,
pageno
:
pageno
};
}
catch
(
error
)
{
throw
new
Error
(
error
);
}
...
...
@@ -114,7 +116,7 @@ userService.prototype.updateUserByUserId = async(userId,data)=>{
try
{
var
t
=
await
sequelize
.
transaction
({
autocommit
:
true
})
let
oldUser
=
await
userModel
.
findAll
({
where
:{
id
:
userId
}},{
transaction
:
t
});
if
(
!
oldUser
){
if
(
!
oldUser
[
0
]
){
t
.
rollback
()
return
{
msg
:
'用户不存在'
}
}
...
...
util/emailUtil.js
查看文件 @
7397b16
...
...
@@ -2,10 +2,6 @@
*
* @Description 邮件发送
* 调用方法:sendMail('amor_zhang@qq.com','这是测试邮件', 'Hi Amor,这是一封测试邮件');
* @Author Amor
* @Created 2016/04/26 15:10
* 技术只是解决问题的选择,而不是解决问题的根本...
* 我是Amor,为发骚而生!
*
*/
...
...
请
注册
或
登录
后发表评论