cs_Folder_MoveFolder
ALTER PROC [dbo].cs_Folder_MoveFolder
@FolderId INT,
@NewParentFolderId INT = NULL
AS
/**//*更新那个ParentFolderId*/
UPDATE cs_Folder
SET ParentFolderId = @NewParentFolderId
WHERE FolderId = @FolderId
ALTER PROC [dbo].cs_Folder_MoveFolder
@FolderId INT,
@NewParentFolderId INT = NULL
AS
/**//*更新那个ParentFolderId*/
UPDATE cs_Folder
SET ParentFolderId = @NewParentFolderId
WHERE FolderId = @FolderId
cs_Folder_GetSummary
ALTER PROC [dbo].cs_Folder_GetSummary
@UserId INT,
@SettingsID INT,
@FolderId INT = NULL
AS
BEGIN
IF (@FolderId IS NULL)
BEGIN
SET @FolderId = -1
END
-- Give me the top 10 most active blog posts
--获取前10条最活跃的博客(应该是显示显示在主页上的吧)
SELECT TOP 10
fp.FeedPostId,
fp.FeedId,
fp.Author,
fp.Title,
fp.Description,
fp.Source,
fp.GuidName,
fp.GuidIsPermaLink,
fp.Link,
fp.PubDate,
fp.CommentsUrl,
fp.EnclosureUrl,
fp.EnclosureLength,
fp.EnclosureType,
fp.Creator,
fp.CommentApiUrl,
fp.CommentRssUrl,
fp.CommentCount
FROM cs_Feed f,
cs_FeedPost fp,
cs_FolderFeed ff
WHERE f.FeedId = fp.FeedId
AND fp.PubDate >= DATEADD(day, -15, GetDate())
AND f.FeedId = ff.FeedId
AND ff.UserId = @UserId
AND IsNull(ff.FolderId,-1) = @FolderId
AND f.SettingsID = @SettingsID AND ff.SettingsID = @SettingsID
ORDER BY fp.CommentCount DESC
SELECT top 100 fp.FeedPostId,
fp.FeedId,
fp.Author,
fp.Title,
fp.Description,
fp.Source,
fp.GuidName,
fp.GuidIsPermaLink,
fp.Link,
fp.PubDate,
fp.CommentsUrl,
fp.EnclosureUrl,
fp.EnclosureLength,
fp.EnclosureType,
fp.Creator,
fp.CommentApiUrl,
fp.CommentRssUrl,
fp.CommentCount
FROM cs_Feed f,
cs_FeedPost fp,
cs_FolderFeed ff
WHERE f.FeedId = fp.FeedId
AND f.FeedId = ff.FeedId
AND ff.UserId = @UserId
AND IsNull(ff.FolderId,-1) = @FolderId
AND f.SettingsID = @SettingsID AND ff.SettingsID = @SettingsID
ORDER BY fp.FeedPostId DESC
END
ALTER PROC [dbo].cs_Folder_GetSummary
@UserId INT,
@SettingsID INT,
@FolderId INT = NULL
AS
BEGIN
IF (@FolderId IS NULL)
BEGIN
SET @FolderId = -1
END
-- Give me the top 10 most active blog posts
--获取前10条最活跃的博客(应该是显示显示在主页上的吧)
SELECT TOP 10
fp.FeedPostId,
fp.FeedId,
fp.Author,
fp.Title,
fp.Description,
fp.Source,
fp.GuidName,
fp.GuidIsPermaLink,
fp.Link,
fp.PubDate,
fp.CommentsUrl,
fp.EnclosureUrl,
fp.EnclosureLength,
fp.EnclosureType,
fp.Creator,
fp.CommentApiUrl,
fp.CommentRssUrl,
fp.CommentCount
FROM cs_Feed f,
cs_FeedPost fp,
cs_FolderFeed ff
WHERE f.FeedId = fp.FeedId
AND fp.PubDate >= DATEADD(day, -15, GetDate())
AND f.FeedId = ff.FeedId
AND ff.UserId = @UserId
AND IsNull(ff.FolderId,-1) = @FolderId
AND f.SettingsID = @SettingsID AND ff.SettingsID = @SettingsID
ORDER BY fp.CommentCount DESC
SELECT top 100 fp.FeedPostId,
fp.FeedId,
fp.Author,
fp.Title,
fp.Description,
fp.Source,
fp.GuidName,
fp.GuidIsPermaLink,
fp.Link,
fp.PubDate,
fp.CommentsUrl,
fp.EnclosureUrl,
fp.EnclosureLength,
fp.EnclosureType,
fp.Creator,
fp.CommentApiUrl,
fp.CommentRssUrl,
fp.CommentCount
FROM cs_Feed f,
cs_FeedPost fp,
cs_FolderFeed ff
WHERE f.FeedId = fp.FeedId
AND f.FeedId = ff.FeedId
AND ff.UserId = @UserId
AND IsNull(ff.FolderId,-1) = @FolderId
AND f.SettingsID = @SettingsID AND ff.SettingsID = @SettingsID
ORDER BY fp.FeedPostId DESC
END
cs_Folder_GetFolders
ALTER PROC [dbo].cs_Folder_GetFolders
@UserId INT,
@SettingsID INT,
@ParentFolderId INT = -1
AS
Begin
/**//*创建临时表,然后删除,语句有点负责的样子,不过认真看就没问题了。*/
Create Table #Temp ( FeedId int, FolderId int, CNT int )
Insert #Temp (FeedId, FolderId, CNT)
Select FeedId, cf.FolderId,
(
select count(*) from (Select top 50 f.FeedPostID, f.FeedId FROM cs_FeedPost f where f.FeedId = cf.FeedId order by PubDate DESC) fp left outer join cs_UserReadPost urp on fp.FeedPostID = urp.FeedPostID where fp.FeedId = cf.FeedId and urp.UserId IS NULL
) as [CNT] FROM cs_FolderFeed cf, cs_Folder ff where cf.FolderId = ff.FolderId and IsNull(ff.ParentFolderId, -1) = @ParentFolderId and cf.UserId = @UserId and cf.SettingsID = @SettingsID and ff.SettingsID = @SettingsID
SELECT FolderId,
UserId,
FolderName,
ParentFolderId
,[UnreadCount] = (Select Sum(CNT) FROM #Temp where #Temp.FolderId = cs_Folder.FolderID)
FROM cs_Folder
WHERE UserId = @UserId
AND IsNull(ParentFolderId,-1) = @ParentFolderId
AND cs_Folder.SettingsID = @SettingsID
ORDER BY FolderName
DROP Table #Temp
END
ALTER PROC [dbo].cs_Folder_GetFolders
@UserId INT,
@SettingsID INT,
@ParentFolderId INT = -1
AS
Begin
/**//*创建临时表,然后删除,语句有点负责的样子,不过认真看就没问题了。*/
Create Table #Temp ( FeedId int, FolderId int, CNT int )
Insert #Temp (FeedId, FolderId, CNT)
Select FeedId, cf.FolderId,
(
select count(*) from (Select top 50 f.FeedPostID, f.FeedId FROM cs_FeedPost f where f.FeedId = cf.FeedId order by PubDate DESC) fp left outer join cs_UserReadPost urp on fp.FeedPostID = urp.FeedPostID where fp.FeedId = cf.FeedId and urp.UserId IS NULL
) as [CNT] FROM cs_FolderFeed cf, cs_Folder ff where cf.FolderId = ff.FolderId and IsNull(ff.ParentFolderId, -1) = @ParentFolderId and cf.UserId = @UserId and cf.SettingsID = @SettingsID and ff.SettingsID = @SettingsID
SELECT FolderId,
UserId,
FolderName,
ParentFolderId
,[UnreadCount] = (Select Sum(CNT) FROM #Temp where #Temp.FolderId = cs_Folder.FolderID)
FROM cs_Folder
WHERE UserId = @UserId
AND IsNull(ParentFolderId,-1) = @ParentFolderId
AND cs_Folder.SettingsID = @SettingsID
ORDER BY FolderName
DROP Table #Temp
END