Beispiel #1
0
    def get(self, access_token, user_name_ls=None):
        """
        http get 请求
        :param access_token:访问码
        :param user_name_ls: 用户名列表
        :return:[user_dic,,,,]
        """
        user_name_ls = ujson.loads(user_name_ls)

        if not access_token\
                or not user_name_ls:
            return {'result': error_code.ERROR_PARAMS_ERROR}

        if not TokenMgr.check_expire_access_token(access_token):
            return {'result': error_code.ERROR_ACCESS_TOKEN_ERROR}

        result = {'result': error_code.ERROR_SUCCESS}
        connects = ServiceMgrCacher().get_connections(US_REGISTER_DA, RT_HASH_RING, user_name_ls)
        for connect, name_ls in connects.items():
            params = {"user_name_ls": name_ls}
            user_info_ls = user_select(connect, **params)
            [user_dic.__setitem__('device_type', get_device_type(ParamCacher().sm_rpc, user_dic['device_type']))
             for user_dic in user_info_ls
             if user_dic['device_type']]
            result.setdefault('user_info_ls', []).extend(user_info_ls)
        return result
Beispiel #2
0
    def verify_access_token(self, access_token):
        """
        验证访问码的有效性
        :param access_token:
        :return:{}
        """
        if not access_token:
            return {'result': error_code.ERROR_PARAMS_ERROR}

        return {'result': error_code.ERROR_SUCCESS,
                "validate": TokenMgr.check_expire_access_token(access_token)}
Beispiel #3
0
    def get_users(self, access_token, user_name_ls):
        """
        获取用户信息
        :param access_token: 访问码
        :param user_name_ls: 用户名列表
        :return:[user_dic,,,,]
        """
        if not access_token\
                or not user_name_ls:
            return {'result': error_code.ERROR_PARAMS_ERROR}

        if not TokenMgr.check_expire_access_token(access_token):
            return {'result': error_code.ERROR_ACCESS_TOKEN_ERROR}

        result = {'result': error_code.ERROR_SUCCESS}
        connects = ServiceMgrCacher().get_connections(US_REGISTER_DA, RT_HASH_RING, user_name_ls)
        for connect, name_ls in connects.items():
            params = {"user_name_ls": name_ls}
            user_info_ls = result.setdefault('user_info_ls', [])
            user_info_ls.extend(user_select(connect, **params))
        return result