(req, res, next)
| 209 | } |
| 210 | } |
| 211 | async getAdminInfo(req, res, next){ |
| 212 | const admin_id = req.session.admin_id; |
| 213 | if (!admin_id || !Number(admin_id)) { |
| 214 | // console.log('获取管理员信息的session失效'); |
| 215 | res.send({ |
| 216 | status: 0, |
| 217 | type: 'ERROR_SESSION', |
| 218 | message: '获取管理员信息失败' |
| 219 | }) |
| 220 | return |
| 221 | } |
| 222 | try{ |
| 223 | const info = await AdminModel.findOne({id: admin_id}, '-_id -__v -password'); |
| 224 | if (!info) { |
| 225 | throw new Error('未找到当前管理员') |
| 226 | }else{ |
| 227 | res.send({ |
| 228 | status: 1, |
| 229 | data: info |
| 230 | }) |
| 231 | } |
| 232 | }catch(err){ |
| 233 | console.log('获取管理员信息失败'); |
| 234 | res.send({ |
| 235 | status: 0, |
| 236 | type: 'GET_ADMIN_INFO_FAILED', |
| 237 | message: '获取管理员信息失败' |
| 238 | }) |
| 239 | } |
| 240 | } |
| 241 | async updateAvatar(req, res, next){ |
| 242 | const admin_id = req.params.admin_id; |
| 243 | if (!admin_id || !Number(admin_id)) { |
nothing calls this directly
no outgoing calls
no test coverage detected