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

Method getUserCity

controller/v2/user.js:296–322  ·  view source on GitHub ↗
(req, res, next)

Source from the content-addressed store, hash-verified

294 }
295 }
296 async getUserCity(req, res, next){
297 const cityArr = ['北京', '上海', '深圳', '杭州'];
298 const filterArr = [];
299 cityArr.forEach(item => {
300 filterArr.push(UserInfoModel.find({city: item}).count())
301 })
302 filterArr.push(UserInfoModel.$where('!"北京上海深圳杭州".includes(this.city)').count())
303 Promise.all(filterArr).then(result => {
304 res.send({
305 status: 1,
306 user_city: {
307 beijing: result[0],
308 shanghai: result[1],
309 shenzhen: result[2],
310 hangzhou: result[3],
311 qita: result[4],
312 }
313 })
314 }).catch(err => {
315 console.log('获取用户分布城市数据失败', err);
316 res.send({
317 status: 0,
318 type: 'ERROR_GET_USER_CITY',
319 message: '获取用户分布城市数据失败'
320 })
321 })
322 }
323}
324
325export default new User()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected