MCPcopy Create free account
hub / github.com/bailicangdu/node-elm / getAdminInfo

Method getAdminInfo

controller/admin/admin.js:211–240  ·  view source on GitHub ↗
(req, res, next)

Source from the content-addressed store, hash-verified

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)) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected