public static GetPostInfo ( string postTableId, int pid ) : Discuz.Entity.PostInfo | ||
postTableId | string | |
pid | int | |
return | Discuz.Entity.PostInfo |
/// <summary> /// 删除指定ID的帖子 /// </summary> /// <param name="postTableId">帖子所在分表Id</param> /// <param name="pid">帖子ID</param> /// <param name="chanagePostStatistic">是否更新帖子数量统计</param> /// <returns>删除数量</returns> public static int DeletePost(string postTableId, int pid, bool chanagePostStatistic) { if (Users.appDBCache && Users.IUserService != null) { PostInfo postInfo = GetPostInfo(postTableId, pid); if (postInfo != null) { Users.IUserService.DeleteUsers(postInfo.Posterid.ToString()); } } int tid = 0;//该变量用于获取帖子所属TID,用于后面的CACHE缓存更新 if (Topics.appDBCache && Topics.ITopicService != null) { PostInfo postInfo = Posts.GetPostInfo(postTableId, pid); if (postInfo != null) { tid = postInfo.Tid; } } int result = DatabaseProvider.GetInstance().DeletePost(postTableId, pid, chanagePostStatistic); if (Topics.appDBCache && Topics.ITopicService != null && tid > 0) { Topics.ITopicService.ResetTopicByTid(tid); } //更新Cache缓存中的帖子信息 if (appDBCache && IPostService != null) { IPostService.DeletePost(postTableId, pid); } return(result); }
/// <summary> /// 删除指定附件id的附件同时更新主题和帖子中的附件个数 /// </summary> /// <param name="aid">附件id</param> /// <param name="pid">附件所属帖子id</param> /// <param name="tid">附件所属主题id</param> private static void DeleteAttachment(string aidlist, int pid, int tid) { if (appDBCache) { IAttachmentService.DeleteAttachment(aidlist); } DatabaseProvider.GetInstance().DelMyAttachmentByAid(aidlist); if (tid > 0) { if (DatabaseProvider.GetInstance().GetAttachmentCountByPid(pid) <= 0) { string postTableId = PostTables.GetPostTableId(tid); DatabaseProvider.GetInstance().UpdatePostAttachment(pid, postTableId, 0); if (Posts.appDBCache) { PostInfo postInfo = Posts.GetPostInfo(postTableId, pid); postInfo.Attachment = 0; Posts.IPostService.UpdatePost(postInfo, postTableId); } } if (DatabaseProvider.GetInstance().GetAttachmentCountByTid(tid) <= 0) { DatabaseProvider.GetInstance().UpdateTopicAttachment(tid, 0); if (Topics.appDBCache) { TopicInfo topicInfo = Topics.GetTopicInfo(tid, 0, 0); topicInfo.Attachment = 0; Topics.ITopicService.UpdateTopic(topicInfo); } } } }