def get_user_profile(): res = {'code': 1000, 'msg': '成功'} data = request.json data = data.get('data') if data else None if not data: return handle_param_error() user_id = data.get("userid") or 0 if not user_id: return handle_param_error() service = ProfileService() try: result = service.get_user_profile(user_id) res = handle_success(result, 1000, '成功') except: res = handle_failure() logger.error('fail|exception|user profile request serve error|%s' % traceback.format_exc()) finally: service.close() return res
def get_user_profile(): logger.info('rec a user profile get request') res = {'code': 1000, 'msg': '成功'} data = request.json command = data.get("cmd") or '' logger.info('request data => {0}'.format(data)) data = data.get('data') if not check_param(data): return handle_param_error() user_id = data.get("userid") or 0 if not command or not user_id or not check_param(data): return handle_param_error() service = ProfileService() try: result = service.get_user_profile(user_id) res = handle_success(result, 1000, '成功') logger.info('success|user profile request serve success') except: res = handle_failure() logger.error('fail|exception|user profile request serve error|%s' % traceback.format_exc()) finally: service.close() return res