예제 #1
0
class DetailModel:
    def __init__(self):
        self.request_data_dao = RequestDataDao()

    def getRequestDatas(self, request_id):
        return self.request_data_dao.select_request_data_by_requestid(request_id)

    def getRequestDataDetail(self, data_id):
        return self.request_data_dao.select_request_data_by_requestid(data_id)
예제 #2
0
class ListModel:
    def __init__(self):
        self.request_record_dao = RequestRecordDao()
        self.request_data_dao = RequestDataDao()

    def get_data_from_url(self, request_url):
        resp = requests.get(request_url)
        return resp.text

    def new_request(self, user_id, request_url, request_interval):
        try:
            request_record = RequestRecord(user_id, request_url, request_interval)
            request_id = self.request_record_dao.insert_request_record(request_record.as_dictionary())

            data_content = self.get_data_from_url(request_url)

            request_data = RequestData(request_id, data_content)
            self.request_data_dao.insert_request_data(request_data.as_dictionary())

            return request_id
        except:
            return 0

    def list_all_records(self, user_id):
        try:
            results = self.request_record_dao.select_request_record_by_userid(user_id)
            return results

        except:
            return None

    def update_request(self, request_id, request_url, request_interval):
        try:

            request_record = {"request_id": request_id, "request_url": request_url,
                              "request_interval": request_interval}

            return True if self.request_record_dao.update_request(request_record) else False

        except:
            return False

    def delete_request(self, request_id):
        try:
            self.request_record_dao.delete_request_by_requestid(request_id)
            self.request_data_dao.delete_request_data_by_request_id(request_id)
            return True
        except:
            return False
예제 #3
0
 def __init__(self):
     self.request_data_dao = RequestDataDao()
예제 #4
0
 def __init__(self):
     self.request_record_dao = RequestRecordDao()
     self.request_data_dao = RequestDataDao()