# -*- coding:UTF-8 -*-

from db.mod_db import DataBase
from common.sql_utils import to_sql_in


class ProvideDao:
    def __init__(self, db=None):
        if db is None:
            self.dataBase = DataBase()
        else:
            self.dataBase = db

    def select(self):
        return self.dataBase.fetch_all(
            "select * from `tj_provide_company` where provide_status is null limit 100")
    # def select(self):
    #     return self.dataBase.fetch_all(
    #         "SELECT * FROM `tj_provide_company` WHERE create_time > '2020-06-02'")

    def update_status(self, company_list):
        # print(" update tj_provide_company set provide_status = 1 where id in (%s)" % to_sql_in(company_list))
        self.dataBase.update(
            " update tj_provide_company set provide_status = 1 where id in (%s)" % to_sql_in(company_list), None)

    def select_id(self, business_id):
        return self.dataBase.fetch_all(
            "select * from `tj_product_depth_final` where business_opportunity_id = '%s' " % (business_id))
