feat: rank community recommendation feed
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
SET @has_post_sort = (
|
||||
SELECT COUNT(*)
|
||||
FROM `information_schema`.`columns`
|
||||
WHERE `table_schema` = DATABASE()
|
||||
AND `table_name` = 'la_community_post'
|
||||
AND `column_name` = 'sort'
|
||||
);
|
||||
SET @sql = IF(
|
||||
@has_post_sort = 0,
|
||||
'ALTER TABLE `la_community_post` ADD COLUMN `sort` int unsigned NOT NULL DEFAULT 0 COMMENT ''推荐流排序值,越大越靠前'' AFTER `is_topic`',
|
||||
'SELECT ''la_community_post.sort already exists'''
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @has_recommend_sort_index = (
|
||||
SELECT COUNT(*)
|
||||
FROM `information_schema`.`statistics`
|
||||
WHERE `table_schema` = DATABASE()
|
||||
AND `table_name` = 'la_community_post'
|
||||
AND `index_name` = 'idx_status_recommend_sort'
|
||||
);
|
||||
SET @sql = IF(
|
||||
@has_recommend_sort_index = 0,
|
||||
'ALTER TABLE `la_community_post` ADD INDEX `idx_status_recommend_sort` (`status`, `is_recommend`, `sort`, `create_time`)',
|
||||
'SELECT ''la_community_post.idx_status_recommend_sort already exists'''
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @post_menu_id = COALESCE(
|
||||
(SELECT `id` FROM `la_system_menu` WHERE `perms` = 'community.communityPost/lists' LIMIT 1),
|
||||
(SELECT `id` FROM `la_system_menu` WHERE `component` = 'community/post/index' LIMIT 1)
|
||||
);
|
||||
|
||||
INSERT INTO `la_system_menu`
|
||||
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_cache`, `is_show`, `is_disable`, `create_time`, `update_time`)
|
||||
SELECT @post_menu_id, 'A', '设置排序', '', 0, 'community.communityPost/setSort', '', '', '', '', 0, 0, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
|
||||
WHERE @post_menu_id IS NOT NULL
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `la_system_menu` WHERE `perms` = 'community.communityPost/setSort'
|
||||
);
|
||||
|
||||
INSERT INTO `la_system_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT 1, menu.`id`
|
||||
FROM `la_system_menu` menu
|
||||
WHERE menu.`perms` = 'community.communityPost/setSort'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM `la_system_role_menu` role_menu
|
||||
WHERE role_menu.`role_id` = 1
|
||||
AND role_menu.`menu_id` = menu.`id`
|
||||
);
|
||||
Reference in New Issue
Block a user