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

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

    # def select_name_dao(self, name_type, name_size, city, cate, size):
    #     # print('select * from check_name_treasure_name  where gsb_city = "%s" and name_size = %s and gsb_company_cate = "%s" and name_type = "%s" and state = 1 limit %s' % (city,name_size,cate,name_type,size))
    #     return self.dataBase.fetch_all(
    #         'select * from check_name_treasure_name  where gsb_city = "%s" and name_size = %s and gsb_company_cate = "%s" and name_type = "%s" and state = 1  order by rand() limit %s' % (city,name_size,cate,name_type,size))

    def select_null_dao(self,size):
        return self.dataBase.fetch_all(
            'select * from check_name_treasure_name  where name_type is null and state = 1 order by rand() limit %s' % (size))

    def select_name_dao(self, name_type, name_size, size):
        # print('select * from check_name_treasure_name  where gsb_city = "%s" and name_size = %s and gsb_company_cate = "%s" and name_type = "%s" and state = 1 limit %s' % (city,name_size,cate,name_type,size))
        return self.dataBase.fetch_all(
            'select * from check_name_treasure_name  where name_size = %s  and name_type = "%s" and state = 1  order by rand() limit %s' % (
             name_size, name_type, size))
