付智勇

用户api

... ... @@ -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');
}
... ...
## 课堂管理
### 创建课堂
\ No newline at end of file
... ...
# 网校接口文档
## 用户管理
... ... @@ -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
}
}
... ...
... ... @@ -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);
... ...
// export class Point {
// constructor(x, y) {
// this.x = x;
// this.y = y;
// }
// a() {
// return '(' + this.x + ', ' + this.y + ')';
// }
// }
\ No newline at end of file
... ...
... ... @@ -69,8 +69,10 @@ userService.prototype.getStu = async(type,page = 1,pageno =10)=>{
FROM
3m_user u
LEFT JOIN 3m_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:'用户不存在'}
}
... ...
... ... @@ -2,10 +2,6 @@
*
* @Description 邮件发送
* 调用方法:sendMail('amor_zhang@qq.com','这是测试邮件', 'Hi Amor,这是一封测试邮件');
* @Author Amor
* @Created 2016/04/26 15:10
* 技术只是解决问题的选择,而不是解决问题的根本...
* 我是Amor,为发骚而生!
*
*/
... ...