(req, res, next)
| 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 | |
| 325 | export default new User() |
nothing calls this directly
no outgoing calls
no test coverage detected