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


class qualificationsProductDao:
    def __init__(self, db=None):
        if db is None:
            self.dataBase = Database()
        else:
            self.dataBase = db
    def get_recommend(self,product_list):
        print("select * from ent_recommend_product join ent_product_comments on "
                                       "ent_recommend_product.recommendation_business_code = ent_product_comments.product_name where qualification_comments in (%s)" % to_sql_in(product_list))
        return self.dataBase.sqlResult("select * from ent_recommend_product left join ent_product_comments on "
                                       "ent_recommend_product.recommendation_business = ent_product_comments.product_name where qualification_comments in (%s)" % to_sql_in(product_list))

    def random_recommend(self):
        return self.dataBase.sqlResult("select * from ent_product_comments where status = 1 order by rand() limit 4")