Esempio n. 1
0
    async def query_user_range(self, data):
        content = await self._database_client.query_all(
            self.stmt_query_user_range, parameter=data)

        # content 值 ((7026, '42489ff329f4456a8f241df79de797f1', b'python2的pickle编码的二进制', '510000', '511102', '511100'),)
        for c in content:
            if isinstance(c["pic_md5"], bytes):
                c["pic_md5"] = base64.b64encode(c["pic_md5"]).decode()

        return common_result(data=content)
Esempio n. 2
0
    async def update_feature_model_0330(self, data):
        values = data.get("values")
        if values["feature"] is not None:
            values["feature"] = values["feature"].encode()

        row_count, _ = await self._database_client.execute(
            self.stmt_update_feature_model_0330, parameter=values)
        assert row_count > 0, "fail to update feature_model_0330:{}".format(
            values)

        logger.debug("update data {} success".format(values))
        return common_result(data=row_count)
Esempio n. 3
0
    async def update_user(self, data):
        values = data.get("values")

        # 为了方便传输,values["pic_md5"] 是经过编码的 base64.b64encode(c["pic_md5"]).decode(),这里解码
        if values["pic_md5"] is not None:
            values["pic_md5"] = base64.b64decode(values["pic_md5"].encode())

        row_count, _ = await self._database_client.execute(
            self.stmt_update_user, parameter=values)
        assert row_count > 0, "fail to update user:{}".format(values)

        logger.debug("update data {} success".format(values))
        return common_result(data=row_count)
Esempio n. 4
0
    async def del_user_by_id(self, data):
        user_id = data.get("id")
        feature_obj = await self._database_client.query_one(
            self.stmt_get_feature_model_0330_by_user_id,
            parameter=dict(user_id=user_id))
        if feature_obj:
            logger.warn(
                "exists feature model 0330 record for user: {}, so skip del user: {}"
                .format(user_id, data))
            return

        row_count, _ = await self._database_client.execute(
            self.stmt_del_user_by_id, parameter=data)
        assert row_count > 0, "not found user row with id: {}".format(data)

        logger.debug("delete data {} success".format(data))
        return common_result(data=row_count)
Esempio n. 5
0
    async def get_sync_status(self, data):
        """
        获取同步状态
        :return:
        """
        max_feature_model_0330_id = await self._database_client.query_one(
            self.stmt_get_max_feature_model_0330_id, parameter=data)
        max_feature_model_0330_id = max_feature_model_0330_id["id"]
        if max_feature_model_0330_id is None:
            max_feature_model_0330_id = -1

        max_user_id = await self._database_client.query_one(
            self.stmt_get_max_user_id, parameter=data)
        max_user_id = max_user_id["id"]
        if max_user_id is None:
            max_user_id = -1

        ret = {
            'user_id': max_user_id,
            'feature_model_0330_id': max_feature_model_0330_id
        }
        return common_result(data=ret)
Esempio n. 6
0
 async def del_feature_model_0330_by_id(self, data):
     row_count, _ = await self._database_client.execute(
         self.stmt_del_feature_model_0330_by_id, parameter=data)
     assert row_count > 0, "not found feature_model_0330 row with id: {}".format(
         data)
     return common_result(data=row_count)
Esempio n. 7
0
    async def query_feature_model_0330_time_range(self, data):
        content = await self._database_client.query_all(
            self.stmt_query_feature_model_0330_time_range, parameter=data)

        return common_result(data=content)
Esempio n. 8
0
    async def query_user_id_range(self, data):
        content = await self._database_client.query_all(
            self.stmt_query_user_id_range, parameter=data)

        return common_result(data=content)
Esempio n. 9
0
 async def handler_default(self, data):
     return common_result(code=101,
                          desc="no support command <{}>".format(
                              data.get("command", "")),
                          data=data)