付智勇

用户列表查询

@@ -73,7 +73,7 @@ userController.prototype.login = async(ctx, next) =>{ @@ -73,7 +73,7 @@ userController.prototype.login = async(ctx, next) =>{
73 } 73 }
74 if(!userData.code){ 74 if(!userData.code){
75 return userBack; 75 return userBack;
76 - 76 +
77 }else{ 77 }else{
78 return userData; 78 return userData;
79 } 79 }
@@ -84,12 +84,13 @@ userController.prototype.login = async(ctx, next) =>{ @@ -84,12 +84,13 @@ userController.prototype.login = async(ctx, next) =>{
84 } 84 }
85 85
86 userController.prototype.getStu = async(ctx, next) =>{ 86 userController.prototype.getStu = async(ctx, next) =>{
  87 +
  88 + try {
87 const stuType = ctx.params.type; 89 const stuType = ctx.params.type;
88 if(!stuType){ 90 if(!stuType){
89 return status.paramError('type'); 91 return status.paramError('type');
90 } 92 }
91 93
92 - try {  
93 let stu = await userService.getStu(stuType); 94 let stu = await userService.getStu(stuType);
94 return stu 95 return stu
95 } catch (error) { 96 } catch (error) {
@@ -133,7 +134,7 @@ userController.prototype.delUserByUserId = async(ctx,next) => { @@ -133,7 +134,7 @@ userController.prototype.delUserByUserId = async(ctx,next) => {
133 134
134 userController.prototype.resetPasswordByUserId = async(ctx,next) =>{ 135 userController.prototype.resetPasswordByUserId = async(ctx,next) =>{
135 const userId = ctx.params.userId; 136 const userId = ctx.params.userId;
136 - const pw = saitMd5.md5AddSalt('123056') 137 + const pw = saitMd5.md5AddSalt('123456')
137 138
138 if(!userId){ 139 if(!userId){
139 return status.paramError('userId'); 140 return status.paramError('userId');
@@ -45,10 +45,15 @@ userService.prototype.login = async(name,pw) => { @@ -45,10 +45,15 @@ userService.prototype.login = async(name,pw) => {
45 45
46 userService.prototype.getStu = async(type)=>{ 46 userService.prototype.getStu = async(type)=>{
47 try { 47 try {
48 - let User = await userModel.findAll({where:{userType:type}}); 48 + let sql = `SELECT
  49 + u.*, ug.name
  50 + FROM
  51 + 3m_user u
  52 + LEFT JOIN 3m_user_group ug ON ug.id = u.group_id`
  53 + let User = await sequelize.query(sql);
49 return User 54 return User
50 } catch (error) { 55 } catch (error) {
51 - throw new Error(err); 56 + throw new Error(error);
52 } 57 }
53 } 58 }
54 59