(req, res, next)
| 93 | }) |
| 94 | } |
| 95 | async getInfo(req, res, next){ |
| 96 | const sid = req.session.user_id; |
| 97 | const qid = req.query.user_id; |
| 98 | const user_id = sid || qid; |
| 99 | if (!user_id || !Number(user_id)) { |
| 100 | // console.log('获取用户信息的参数user_id无效', user_id) |
| 101 | res.send({ |
| 102 | status: 0, |
| 103 | type: 'GET_USER_INFO_FAIELD', |
| 104 | message: '通过session获取用户信息失败', |
| 105 | }) |
| 106 | return |
| 107 | } |
| 108 | try{ |
| 109 | const userinfo = await UserInfoModel.findOne({user_id}, '-_id'); |
| 110 | res.send(userinfo) |
| 111 | }catch(err){ |
| 112 | console.log('通过session获取用户信息失败', err); |
| 113 | res.send({ |
| 114 | status: 0, |
| 115 | type: 'GET_USER_INFO_FAIELD', |
| 116 | message: '通过session获取用户信息失败', |
| 117 | }) |
| 118 | } |
| 119 | } |
| 120 | async getInfoById(req, res, next){ |
| 121 | const user_id = req.params.user_id; |
| 122 | if (!user_id || !Number(user_id)) { |
nothing calls this directly
no outgoing calls
no test coverage detected