コード例 #1
0
class NewsService(object):
    __news_dao = NewsDao()

    # 查询待审批新闻列表
    def seaech_unteview_list(self, page):
        result = self.__news_dao.search_unreview_list(page)
        return result

    # 查询待审批新闻列表页数
    def search_unreview_count_page(self):
        count_page = self.__news_dao.search_unreview_count_page()
        return count_page

    def update_unreview_news(self, id):
        self.__news_dao.update_unreview_news(id)

    # 查询新闻列表
    def search_list(self, page):
        result = self.__news_dao.search_list(page)
        return result

    # 查询新闻总页数
    def search_count_page(self):
        count_page = self.__news_dao.search_count_page()
        return count_page

    # 删除新闻
    def delete_by_id(self, id):
        self.__news_dao.delete_by_id(id)
コード例 #2
0
ファイル: new_service.py プロジェクト: 1759298301/python
class NewsService:
    __news_dao = NewsDao()

    # 查询待审批的新闻
    def search_unreview_news(self, page):
        result = self.__news_dao.search_unreview_news(page)
        return result

    # 查询待审批新闻总页数
    def search_unreview_news_page_count(self):
        count = self.__news_dao.search_unreview_news_page_count()
        return count

    # 更新待审批新闻为已审批
    def update_unreview_news(self, id):
        self.__news_dao.update_unreview_news(id)

    # 查看新闻的页数
    def search_news_page_count(self):
        count = self.__news_dao.search_news_page_count()
        return count

    # 分页查询新闻
    def search_news(self, page):
        result = self.__news_dao.search_news(page)
        return result

    # 删除指定的新闻
    def delete_news_by_id(self, id):
        self.__news_dao.delete_news_by_id(id)
コード例 #3
0
ファイル: news_service.py プロジェクト: jayce2424/py
class NewsService:
    __news_dao = NewsDao()
    __redis_news_dao = RedisNewsDao()

    #查询待审批新闻列表
    def search_unreview_list(self, page):
        result = self.__news_dao.search_unreview_list(page)
        return result

    #查询待审批新闻的总页数
    def search_unreview_count_page(self):
        count_page = self.__news_dao.search_unreview_count_page()
        return count_page

    #审批新闻
    def update_unreview_news(self, id):
        self.__news_dao.update_unreview_news(id)

    # 查询新闻列表
    def search_list(self, page):
        result = self.__news_dao.search_list(page)
        return result

    # 查询新闻的总页数
    def search_count_page(self):
        count_page = self.__news_dao.search_count_page()
        return count_page

    # 删除新闻
    def delete_by_id(self, id):
        self.__news_dao.delete_by_id(id)

    # 添加新闻
    def insert(self, title, editor_id, type_id, content_id, is_top):
        self.__news_dao.insert(title, editor_id, type_id, content_id, is_top)

    # 查找用于缓存的记录
    def search_cache(self, id):
        result = self.__news_dao.search_cache(id)
        return result

    #向redis保存缓存的新闻
    def cache_news(self, id, title, username, type, content, is_top,
                   create_time):
        self.__redis_news_dao.insert(id, title, username, type, content,
                                     is_top, create_time)


#测试
# service=NewsService()
# result=service.search_cache(1)
# print(result)
コード例 #4
0
ファイル: news_service.py プロジェクト: HYu61/news_management
 def get_newslist_by_state_page(news_state, page, num_per_page=10):
     """
     select the news by news state limited by page
     :param news_state: news state
     :param page: which page
     :param num_per_page: how many news need to display in one page
     :return: the news list , if not found return None
     """
     result = NewsDao.get_newslist_by_state_page(news_state, page,
                                                 num_per_page)
     if len(result) != 0:
         return result
     else:
         return None
コード例 #5
0
class NewsService():
    __news_dao = NewsDao()

    def search_unreview_list(self, page):
        result = self.__news_dao.search_unreview_list(page)
        return result

    def search_unreview_count_page(self):
        count_page = self.__news_dao.search_unreview_count_page()
        return count_page

    def update_unreview_news(self, id):
        self.__news_dao.update_unreview_news(id)

    def search_list(self, page):
        result = self.__news_dao.search_list(page)
        return result

    def search_count_page(self):
        result = self.__news_dao.search_count_page()
        return result

    def delete_by_id(self, id):
        self.__news_dao.delete_by_id(id)
コード例 #6
0
class NewsService:
    __news_dao = NewsDao()

    def search_unapproved_list(self, page):
        result = self.__news_dao.search_unapproved_list(page=page)
        return result

    def search_unapproved_count_page(self):
        count_page = self.__news_dao.search_unapproved_count_page()
        return count_page

    def update_unapproved_news(self, news_id):
        self.__news_dao.update_unapproved_news(news_id=news_id)

    def search_list(self, page):
        result = self.__news_dao.search_list(page=page)
        return result

    def search_count_page(self):
        total_page = self.__news_dao.search_count_page()
        return total_page

    def delete_news(self, news_id):
        self.__news_dao.delete_news(news_id=news_id)
コード例 #7
0
class NewsService:
    __news_dao = NewsDao()
    __redis_news_dao = RedisNewsDao()
    __mongo_news_dao = MongoNewsDao()

    # 查询待审批新闻列表
    def search_unreview_list(self, page):
        result = self.__news_dao.search_unreview_list(page)
        return result

    # 查询待审批新闻的总页数
    def search_unreview_count_page(self):
        count_page = self.__news_dao.search_unreview_count_page()
        return count_page

    # 审批新闻
    def update_unreview_news(self, id):
        self.__news_dao.update_unreview_news(id)

    # 查询新闻列表
    def search_list(self, page):
        result = self.__news_dao.search_list(page)
        return result

    # 查询新闻总页数
    def search_count_page(self):
        count_page = self.__news_dao.search_count_page()
        return count_page

    # 删除新闻
    def delete_by_id(self, id):
        content_id = self.__news_dao.search_content_id(id)
        self.__news_dao.delete_by_id(id)
        self.__mongo_news_dao.delete_by_id(content_id)

    # 添加新闻
    def insert(self, title, editor_id, type_id, content, is_top):
        self.__mongo_news_dao.insert(title, content)
        content_id = self.__mongo_news_dao.search_id(title)
        self.__news_dao.insert(title, editor_id, type_id, content_id, is_top)

    # 查询用户缓存的记录
    def search_cache(self, id):
        result = self.__news_dao.search_cache(id)
        return result

    # 向Redis保存缓存的新闻
    def cache_news(self, id, title, username, type, content, is_top, create_time):
        self.__redis_news_dao.insert(id, title, username, type, content, is_top, create_time)

    # 删除缓存新闻
    def delete_cache(self, id):
        self.__redis_news_dao.delete_cache(id)

    # 根据id查找新闻
    def search_by_id(self, id):
        result = self.__news_dao.search_by_id(id)
        return result

    # 更改新闻
    def update(self, id, title, type_id, content, is_top):
        content_id = self.__news_dao.search_content_id(id)
        self.__mongo_news_dao.update(content_id, title, content)
        self.__news_dao.update(id, title, type_id, content_id, is_top)
        self.delete_cache(id)

    # 查找新闻正文
    def search_content_by_id(self, id):
        content = self.__mongo_news_dao.search_content_by_id(id)
        return content
コード例 #8
0
ファイル: news_service.py プロジェクト: HYu61/news_management
 def update_news_state(news_id, news_state):
     NewsDao.update_news_state(news_id, news_state)
コード例 #9
0
ファイル: news_service.py プロジェクト: HYu61/news_management
 def get_news_total_page_by_state(news_state, num_per_page=10):
     total_page = NewsDao.get_news_total_page_by_state(
         news_state, num_per_page)
     return total_page