#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/4/22 0022 上午 10:25
# @Author  : hj
# @File    : Dataoper_dao.py
# @Software: PyCharm

from db.mod_db import DataBase


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


    def select_sql_1(self,cate_name):
        return self.dataBase.fetch_all('select * from tj_policycycle  where cate_name = "%s" order by life_cycle' % cate_name)

    def select_sql_2(self,cate_name,policy_name):
        return self.dataBase.fetch_one('select * from tj_policycycle where  cate_name = "%s" and policy_name = "%s"' % cate_name, policy_name)

    def updateData(self,life_cycle, id):
        return self.dataBase.update('update tj_policycycle set life_cycle = %s  where id = %s' % (life_cycle, id),None)

    def insertData(self,cate_name, policy_name, life_cycle):
        return self.dataBase.insert_batch('INSERT INTO `ent_data`.`tj_policycycle` (`cate_name`, `policy_name`, `life_cycle`) VALUES (%s, %s, %s)' % cate_name, policy_name, life_cycle)


