#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/4/22 0022 下午 2:55
# @Author  : hj
# @File    : online_GetlicenseImage_es.py
# @Software: PyCharm

from db.mod_db import EsBase

class online_Getlicense_Es:
    def __init__(self, es=None):
        if es is None:
            self.esBase = EsBase()
        else:
            self.esBase = es

    def select_GXLicenses(self, companyname):
        query = {"query": {"bool": {"must": {"term": {"companyName.raw": companyname}}}}}
        return self.esBase.select(index="enterprise_chain_gxgy", body=query)

    def select_gameLicenses_1(self, companyname):
        query = {"query": {"bool": {"must": {"term": {"publishing_unit.raw": companyname}}}}}
        return self.esBase.select(index="enterprise_chain_game", body=query)

    def select_gameLicenses_2(self, companyname):
        query = {"query": {"bool": {"must": {"term": {"operation_unit.raw": companyname}}}}}
        return self.esBase.select(index="enterprise_chain_game", body=query)

    def select_ICPLicenses(self, companyname):
        query = {"query": {"bool": {"must": {"term": {"companyName.raw": companyname}}}}}
        return self.esBase.select(index="enterprise_chain_license", body=query)