#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time     : 2020/5/26 14:36
# @Author   : hj
# @File     :business_job_dao.py
# @software :PyCharm

from db.mod_db import DataBase


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

    def jobInsert(self, company_name, job_type, start_date, end_date, product_name,job_status):
        return self.dataBase.insert_batch(
            'insert into tj_business_job(company_name,job_type,start_date,end_date,product_name,job_status) values ("%s","%s","%s","%s","%s","%s")' % (
                company_name, job_type, start_date, end_date, product_name,job_status))

    def jobSelect(self,pagesize,currentpage):
        start = (currentpage - 1) * pagesize
        return self.dataBase.fetch_all('select * from tj_business_job where job_status = "已处理" LIMIT %s,%s' % (start,pagesize))

    def jobTotal(self):
            return self.dataBase.fetch_all('select count(*) as total from tj_business_job where job_status = "已处理"')