/// <summary> /// 更新帖子隐藏状态 /// </summary> /// <param name="ids">帖子ID列表</param> /// <param name="isHide">是否隐藏</param> /// <returns>是否成功更新</returns> public static IMethodResult AdminUpdateForumPostIsHide(String ids, Boolean isHide) { if (!AdminManager.HasPermission(PermissionType.ForumManage)) { throw new NoPermissionException(); } if (!RegexVerify.IsNumericIDs(ids)) { return(MethodResult.InvalidRequest(RequestType.ForumPost)); } Boolean success = ForumPostRepository.Instance.UpdateEntityIsHide(ids, isHide) > 0; if (!success) { return(MethodResult.FailedAndLog("No forum post was {0}!", isHide ? "hided" : "unhided")); } ids.ForEachInIDs(',', id => { ForumPostCache.RemoveForumPostCache(id);//删除缓存 }); return(MethodResult.SuccessAndLog("Admin {1} forum post, id = {0}", ids, isHide ? "hide" : "unhide")); }
/// <summary> /// 根据ID得到一个帖子实体 /// </summary> /// <param name="id">帖子ID</param> /// <returns>帖子实体</returns> public static ForumPostEntity GetForumPost(Int32 id) { if (id <= 0) { throw new InvalidRequstException(RequestType.ForumPost); } ForumPostEntity entity = ForumPostCache.GetForumPostCache(id); if (entity == null) { entity = ForumPostRepository.Instance.GetEntity(id); ForumPostCache.SetForumPostCache(entity); } if (entity == null) { throw new NullResponseException(RequestType.ForumPost); } if (entity.IsHide && !AdminManager.HasPermission(PermissionType.ForumManage)) { throw new NoPermissionException("You have no privilege to view the post!"); } return(entity); }