def comment_post(user_id, post_id, post_type): """ 收藏帖子 :param user_id: :param post_id: :param post_type: :return: """ post = get_post_by_id(post_id) if not post: return 1, u'不存在该帖子' db_manager.create_post_comment_db(user_id, post_id, post_type) return 0, u''
def like_post(user_id, post_id, post_type): """ 点赞帖子 :param user_id: :param post_id: :param post_type: :return: """ post = get_post_by_id(post_id) if not post: return 1, u'不存在该帖子' like, created = db_manager.create_like_post_db(user_id, post_id, post_type) if not created: return 1, u'已经点赞' return 0, u''
def del_comment_post(user_id, post_id, post_type): """ 取消收藏 :param user_id: :param post_id: :param post_type: :return: """ post = get_post_by_id(post_id) if not post: return 1, u'不存在该帖子' comment = db_manager.get_comment_by_id(user_id, post_id, post_type) if not comment: return 1, u'没有评论过' db_manager.delete_post_comment_db(comment) return 0, u''
def favor_post(user_id, post_id, post_type): """ 收藏帖子 :param user_id: :param post_id: :param post_type: :return: """ post = get_post_by_id(post_id) if not post: return 1, u'不存在该帖子' favor, created = db_manager.create_favor_post_db(user_id, post_id, post_type) if not created: return 1, u'已经收藏' return 0, u''
def un_favor_post(user_id, post_id, post_type): """ 取消收藏 :param user_id: :param post_id: :param post_type: :return: """ post = get_post_by_id(post_id) if not post: return 1, u'不存在该帖子' favor = db_manager.get_favor_by_id(user_id, post_id, post_type) if not favor: return 1, u'没有收藏过' db_manager.delete_favor_post_db(favor) return 0, u''
def un_like_post(user_id, post_id, post_type): """ 取消点赞 :param user_id: :param post_id: :param post_type: :return: """ post = get_post_by_id(post_id) if not post: return 1, u'不存在该帖子' like = db_manager.get_like_by_id(user_id, post_id, post_type) if not like: return 1, u'没有点赞过' db_manager.delete_like_post_db(like) return 0, u''
def create_post_tag(tag_id, post_id, post_type): """ 创建帖子的标签 :param tag_id: :param post_id: :param post_type: :return: """ post = get_post_by_id(post_id) if not post: return 1, u'不存在该帖子' tag = db_manager.get_tag_by_id(tag_id) if not tag: return 1, u'不存在该标签' post_tag, created = db_manager.create_post_tag_db(tag, post, post_type) if not created: return 1, u'已经创建' return 0, u''
def delete_post_tag(tag_id, post_id, post_type): """ 删除帖子的标签 :param tag_id: :param post_id: :param post_type: :return: """ post = get_post_by_id(post_id) if not post: return 1, u'不存在该帖子' tag = db_manager.get_tag_by_id(tag_id) if not tag: return 1, u'不存在该标签' post_tag = db_manager.get_post_tag_by_id(tag_id, post, post_type) if not post_tag: return 1, u'没有为该文章创建过该标签' db_manager.delete_post_tag_db(post_tag) return 0, u''