From a781bc559b983e87412345fe0a6f84ad78b4ab32 Mon Sep 17 00:00:00 2001 From: xiaomai Date: Thu, 7 May 2026 15:38:32 +0800 Subject: [PATCH] refactor(life): remove life categories and ratings Drop life_tags and life_post_ratings tables and related schema Remove category selection and rating UI from Life posts Simplify Life feed filters and API endpoints --- DESIGN.md | 32 +- backend/db/schema.sql | 88 +++--- backend/src/queries.ts | 310 ++----------------- backend/src/server.ts | 22 -- frontend/src/components/EditHistoryPanel.vue | 4 - frontend/src/services/api.ts | 35 +-- frontend/src/views/AdminView.vue | 30 +- frontend/src/views/LifePostDetail.vue | 55 +--- frontend/src/views/LifeView.vue | 168 +--------- frontend/src/views/UserProfileView.vue | 7 +- system-wordings.ts | 34 -- 11 files changed, 89 insertions(+), 696 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 06833cd..9223b6e 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -64,7 +64,6 @@ - 地图 - 栖息地 - 每日 CheckList Task - - Life Category - Game Version - Dish Category - Dish Flavor @@ -484,13 +483,6 @@ - 名称 - 用于栖息地中 Pokemon 出现地点。 -### Life Category - -- 名称 -- 是否默认选中:最多一个 Life Category 可设为默认;新建 Life Post 时默认选中该分类。 -- 是否可评分:Rateable Life Category 下的 Life Post 可由用户进行 1-5 星评分。 -- 用于 Life Post 分类展示和 Feed 筛选。 - ### Game Version - 版本号 / 名称 @@ -887,13 +879,11 @@ Life 是社区生活分享信息流,类似轻量社交动态。 Life Post 可配置: - Post 内容正文 -- Category:使用 Life Category 配置,必须且只能选择 1 个 - Game Version:可为空,使用 Game Version 配置;有值时在 Post 卡片展示版本号。 - 创建者、最后编辑者、创建时间、最后编辑时间 - 评论 - 评论回复:仅支持回复顶层评论,不做无限嵌套 - Reactions:`like`、`helpful`、`fun`、`thanks` -- Ratings:Rateable Category 下的 Post 支持 1-5 星评分;每个用户每条 Post 最多一条评分,重复评分会替换原评分。 前台行为: @@ -903,10 +893,9 @@ Life Post 可配置: - 已注册并完成邮箱验证且拥有 `life.posts.create` 权限的用户可以发布 Life Post。 - 作者本人拥有 `life.posts.update` / `life.posts.delete` 权限时可以编辑、删除自己的 Life Post;删除 Life Post 使用软删除。 - 拥有 `life.posts.update-any` / `life.posts.delete-any` 权限的用户可以管理其他用户的 Life Post。 -- 已注册并完成邮箱验证且拥有 `life.posts.create` 或 `life.posts.update` 权限的用户发布或编辑 Life Post 时必须选择 1 个 Life Category。 - 已注册并完成邮箱验证且拥有 `life.comments.create` 权限的用户可以评论 Life Post,并回复顶层评论。 - 评论作者拥有 `life.comments.delete` 权限时可以删除自己的评论;拥有 `life.comments.delete-any` 权限的用户可以删除其他用户评论;删除后的 Life Comment 仅对该评论作者本人可见并保留正文,作者可通过 Undo 恢复;其他用户不可见,不显示 Deleted Comment 占位,不出现在评论列表、评论预览或评论数量中。 -- 已软删除的 Life Post 不出现在信息流、搜索或 Category 筛选结果中,也不能继续编辑、评论或设置 Reaction。 +- 已软删除的 Life Post 不出现在信息流或搜索结果中,也不能继续编辑、评论或设置 Reaction。 - 已软删除的 Life Post 详情页返回未找到,不公开软删除字段。 - 每条 Life Post 默认只展示评论入口与评论数量;评论列表、回复和评论输入默认折叠,用户点击后展开。 - Life Post 详情页默认展示该 Post 的评论区,并使用独立分页接口继续加载完整评论列表。 @@ -916,15 +905,11 @@ Life Post 可配置: - 已注册并完成邮箱验证且拥有 `life.reactions.set` 权限的用户可以对每条 Life Post 选择一个 Reaction;普通点击默认设置 `like`,再次点击 `like` 会取消,当前为其他 Reaction 时普通点击会替换为 `like`。 - Life Reaction 的其他类型通过右键 / context menu 或可见展开按钮打开 Popup 选择;再次选择当前 Reaction 会取消,选择其他 Reaction 会替换原 Reaction。 - 用户可在 Life Post 的 Reaction 汇总处打开 Modal 查看公开 Reaction 用户列表;列表支持按 Reaction 类型筛选并分页加载。 -- 已注册并完成邮箱验证且拥有 `life.ratings.set` 权限的用户可以对 Rateable Life Post 设置或取消 1-5 星评分;非 Rateable Category 下的 Post 不显示评分控件,也不能通过 API 评分。 -- Life Post 展示评分时只展示平均分、评分人数和当前用户自己的评分;不展示其他用户的评分明细。 - 支持按 Life Post 正文搜索;用户按 Enter 或点击 Search 按钮后提交搜索,不随输入实时请求;搜索结果仍按创建时间倒序展示并分页加载。 -- Feed 使用 Tabs 展示 Life Category 筛选;包含 All 和后台配置的 Life Category;点击 Category 后按该 Category 筛选,搜索和 Category 筛选可以同时生效。 -- Feed 使用语言筛选展示 All languages 和启用语言;语言区筛选独立于系统 UI 语言,搜索、Category 和语言筛选可以同时生效。 +- Feed 使用语言筛选展示 All languages 和启用语言;语言区筛选独立于系统 UI 语言,搜索和语言筛选可以同时生效。 - Feed 支持按 Game Version 筛选;All versions 表示不过滤版本。 -- Feed 支持 Rateable 筛选;All 表示不过滤,Rateable only 只展示可评分 Category 下的 Post。 -- Feed 支持排序:Latest 默认按创建时间倒序;Oldest 按创建时间正序;Top rated 按平均评分倒序,同分时按创建时间倒序。 -- 登录用户可切换 All Feed 和 Following Feed;Following Feed 只展示当前用户已 Follow 用户发布且当前用户可见的 Life Post,并继续支持 Life Category、语言、Game Version、Rateable 和排序筛选。 +- Feed 支持排序:Latest 默认按创建时间倒序;Oldest 按创建时间正序。 +- 登录用户可切换 All Feed 和 Following Feed;Following Feed 只展示当前用户已 Follow 用户发布且当前用户可见的 Life Post,并继续支持搜索、语言、Game Version 和排序筛选。 - 信息流分页加载,初始展示最新一页,滚动到底部自动加载更多。 - 当前没有图片上传、转发或置顶。 - Life Post 和 Life Comment 必须进入 AI 审核;未审核通过的内容不向普通访客公开。 @@ -940,9 +925,7 @@ Life Post 可配置: API 暴露边界: - Life Post 作者信息只返回 `id` 和 `displayName`。 -- Life Post Category 只返回 `id` 和按当前语言解析后的 `name`。 - Life Post Game Version 只返回 `id`、展示用 `name` 和可展示 `changeLog`;未选择版本时返回 `null`。 -- Life Post Rating 只返回 `ratingAverage`、`ratingCount` 和当前用户自己的 `myRating`;不返回其他用户的评分明细。 - Life Post 可返回面向用户展示所需的审核状态、审核语言区、审核原因详情和是否可重审;审核原因详情仅用于 `rejected` / `failed`,不返回内部错误、AI prompt、模型响应、错误堆栈或 retry 细节。 - Life Comment 作者信息只返回 `id` 和 `displayName`。 - Life Comment 只返回 `likeCount`、`replyCount` 和当前用户自己的 `myLiked`;不返回点赞用户列表、邮箱、角色、权限或内部审计。 @@ -1224,8 +1207,8 @@ API 暴露边界: - `GET /api/recipes`:公开页面支持 `cursor` / `limit` 分页读取;未传分页参数时返回完整数组以兼容排序。 - `GET /api/recipes/:id` - `GET /api/dish` -- `GET /api/life-posts`:支持 `cursor` / `limit` 分页读取;支持 `search` 按 Life Post 正文搜索;支持 `categoryId` 按 Life Category 筛选;支持 `language` 按审核语言区筛选,`all` 表示全部语言区;支持 `gameVersionId` 按 Game Version 筛选;支持 `rateable` 按可评分 Category 筛选;支持 `sort` 为 `latest`、`oldest` 或 `top-rated`。 -- `GET /api/life-posts/following`:需要登录;分页读取当前用户已 Follow 用户发布的 Life Post 动态,支持与 Life Feed 相同的 `cursor` / `limit`、搜索、Category、语言、Game Version、Rateable 和排序筛选。 +- `GET /api/life-posts`:支持 `cursor` / `limit` 分页读取;支持 `search` 按 Life Post 正文搜索;支持 `language` 按审核语言区筛选,`all` 表示全部语言区;支持 `gameVersionId` 按 Game Version 筛选;支持 `sort` 为 `latest` 或 `oldest`。 +- `GET /api/life-posts/following`:需要登录;分页读取当前用户已 Follow 用户发布的 Life Post 动态,支持与 Life Feed 相同的 `cursor` / `limit`、搜索、语言、Game Version 和排序筛选。 - `GET /api/life-posts/:id`:读取单条 Life Post 详情,遵守软删除和审核可见性规则。 - `GET /api/life-posts/:id/reactions`:分页读取该 Life Post 的公开 Reaction 用户列表;支持 `cursor` / `limit` 和 `reactionType` 筛选。 - `GET /api/life-posts/:postId/comments`:支持 `cursor` / `limit` 分页读取 Life Post 评论;支持 `language` 按审核语言区筛选;支持 `sort` 为 `oldest`、`latest`、`most-liked` 或 `most-replied`。 @@ -1333,9 +1316,6 @@ API 暴露边界: - Life Reaction 的设置、替换和取消。 - `PUT /api/life-posts/:id/reaction` - `DELETE /api/life-posts/:id/reaction` -- Life Rating 的设置、替换和取消。 - - `PUT /api/life-posts/:id/rating` - - `DELETE /api/life-posts/:id/rating` - 每日 CheckList 的创建、更新、删除、排序需要对应 `checklist.*` 权限。 - 全局配置项的查看、创建、更新、删除、排序需要对应 `admin.config.*` 权限。 - 限流设置的查看和更新通过 Access 权限控制: diff --git a/backend/db/schema.sql b/backend/db/schema.sql index 35a377b..5f85cd2 100644 --- a/backend/db/schema.sql +++ b/backend/db/schema.sql @@ -32,7 +32,6 @@ CREATE TABLE IF NOT EXISTS entity_translations ( 'maps', 'habitats', 'daily-checklist-items', - 'life-tags', 'game-versions', 'dish-categories', 'dish-flavors', @@ -46,6 +45,31 @@ CREATE TABLE IF NOT EXISTS entity_translations ( PRIMARY KEY (entity_type, entity_id, locale, field_name) ); +DELETE FROM entity_translations +WHERE entity_type = 'life-tags'; + +ALTER TABLE entity_translations + DROP CONSTRAINT IF EXISTS entity_translations_entity_type_check, + ADD CONSTRAINT entity_translations_entity_type_check CHECK ( + entity_type IN ( + 'pokemon', + 'pokemon-types', + 'skills', + 'environments', + 'favorite-things', + 'acquisition-methods', + 'items', + 'ancient-artifacts', + 'maps', + 'habitats', + 'daily-checklist-items', + 'game-versions', + 'dish-categories', + 'dish-flavors', + 'dishes' + ) + ); + CREATE INDEX IF NOT EXISTS entity_translations_lookup_idx ON entity_translations (entity_type, entity_id, field_name, locale); @@ -266,7 +290,6 @@ VALUES ('life.comments.delete-any', 'Delete any Life comment', 'Delete any Life comment.', 'Life', true), ('life.comments.like', 'Like Life comments', 'Like and unlike Life comments.', 'Life', true), ('life.reactions.set', 'Set Life reactions', 'Set and remove Life reactions.', 'Life', true), - ('life.ratings.set', 'Set Life ratings', 'Set and remove Life star ratings.', 'Life', true), ('threads.create', 'Create Threads', 'Create forum threads.', 'Threads', true), ('threads.messages.create', 'Create Thread messages', 'Create chat messages inside Threads.', 'Threads', true), ('threads.follow', 'Follow Threads', 'Follow Threads and manage read state.', 'Threads', true), @@ -288,6 +311,9 @@ ON CONFLICT (key) DO NOTHING; DELETE FROM permissions WHERE key = 'pokemon.order'; +DELETE FROM permissions +WHERE key = 'life.ratings.set'; + INSERT INTO roles (key, name, description, level, enabled, system_role) VALUES ('owner', 'Owner', 'Highest-level system owner with all permissions.', 1000, true, true), @@ -377,7 +403,6 @@ JOIN permissions p ON p.key = ANY (ARRAY[ 'life.comments.delete-any', 'life.comments.like', 'life.reactions.set', - 'life.ratings.set', 'threads.create', 'threads.messages.create', 'threads.follow', @@ -461,7 +486,6 @@ JOIN permissions p ON p.key = ANY (ARRAY[ 'life.comments.delete', 'life.comments.like', 'life.reactions.set', - 'life.ratings.set', 'threads.create', 'threads.messages.create', 'threads.follow', @@ -538,7 +562,6 @@ JOIN permissions p ON p.key = ANY (ARRAY[ 'life.comments.delete', 'life.comments.like', 'life.reactions.set', - 'life.ratings.set', 'threads.create', 'threads.messages.create', 'threads.follow', @@ -556,13 +579,6 @@ WHERE r.key = 'member' ) ON CONFLICT DO NOTHING; -INSERT INTO role_permissions (role_id, permission_id) -SELECT r.id, p.id -FROM roles r -JOIN permissions p ON p.key = 'life.ratings.set' -WHERE r.key IN ('admin', 'editor', 'member') -ON CONFLICT DO NOTHING; - INSERT INTO role_permissions (role_id, permission_id) SELECT r.id, p.id FROM roles r @@ -725,18 +741,6 @@ CREATE TABLE IF NOT EXISTS daily_checklist_items ( CREATE INDEX IF NOT EXISTS daily_checklist_items_sort_order_idx ON daily_checklist_items(sort_order, id); -CREATE TABLE IF NOT EXISTS life_tags ( - id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, - name text NOT NULL UNIQUE, - is_default boolean NOT NULL DEFAULT false, - is_rateable boolean NOT NULL DEFAULT false, - sort_order integer NOT NULL DEFAULT 0 CHECK (sort_order >= 0), - created_by_user_id integer REFERENCES users(id) ON DELETE SET NULL, - updated_by_user_id integer REFERENCES users(id) ON DELETE SET NULL, - created_at timestamptz NOT NULL DEFAULT now(), - updated_at timestamptz NOT NULL DEFAULT now() -); - CREATE TABLE IF NOT EXISTS game_versions ( id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, name text NOT NULL UNIQUE, @@ -754,7 +758,6 @@ CREATE INDEX IF NOT EXISTS game_versions_sort_order_idx CREATE TABLE IF NOT EXISTS life_posts ( id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, body text NOT NULL CHECK (length(body) BETWEEN 1 AND 2000), - category_id integer REFERENCES life_tags(id) ON DELETE RESTRICT, game_version_id integer REFERENCES game_versions(id) ON DELETE SET NULL, ai_moderation_status text NOT NULL DEFAULT 'unreviewed' CHECK (ai_moderation_status IN ('unreviewed', 'reviewing', 'approved', 'rejected', 'failed')), ai_moderation_language_code text REFERENCES languages(code) ON DELETE SET NULL, @@ -782,14 +785,14 @@ CREATE INDEX IF NOT EXISTS life_posts_user_created_at_idx ON life_posts(created_by_user_id, created_at DESC, id DESC) WHERE deleted_at IS NULL; -CREATE TABLE IF NOT EXISTS life_post_tags ( - post_id integer NOT NULL REFERENCES life_posts(id) ON DELETE CASCADE, - tag_id integer NOT NULL REFERENCES life_tags(id) ON DELETE CASCADE, - PRIMARY KEY (post_id, tag_id) -); +DROP INDEX IF EXISTS life_posts_category_idx; +DROP TABLE IF EXISTS life_post_ratings; +DROP TABLE IF EXISTS life_post_tags; -CREATE INDEX IF NOT EXISTS life_post_tags_tag_idx - ON life_post_tags(tag_id, post_id); +ALTER TABLE life_posts + DROP COLUMN IF EXISTS category_id; + +DROP TABLE IF EXISTS life_tags; CREATE TABLE IF NOT EXISTS life_post_comments ( id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, @@ -847,21 +850,6 @@ CREATE INDEX IF NOT EXISTS life_post_reactions_post_idx CREATE INDEX IF NOT EXISTS life_post_reactions_user_idx ON life_post_reactions(user_id, updated_at DESC, post_id DESC); -CREATE TABLE IF NOT EXISTS life_post_ratings ( - post_id integer NOT NULL REFERENCES life_posts(id) ON DELETE CASCADE, - user_id integer NOT NULL REFERENCES users(id) ON DELETE CASCADE, - rating integer NOT NULL CHECK (rating BETWEEN 1 AND 5), - created_at timestamptz NOT NULL DEFAULT now(), - updated_at timestamptz NOT NULL DEFAULT now(), - PRIMARY KEY (post_id, user_id) -); - -CREATE INDEX IF NOT EXISTS life_post_ratings_post_idx - ON life_post_ratings(post_id, rating); - -CREATE INDEX IF NOT EXISTS life_post_ratings_user_idx - ON life_post_ratings(user_id, updated_at DESC, post_id DESC); - CREATE TABLE IF NOT EXISTS thread_channels ( id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, name text NOT NULL UNIQUE, @@ -1344,8 +1332,6 @@ CREATE INDEX IF NOT EXISTS favorite_things_sort_order_idx ON favorite_things(sor CREATE INDEX IF NOT EXISTS pokemon_types_sort_order_idx ON pokemon_types(sort_order, id); CREATE INDEX IF NOT EXISTS pokemon_sort_order_idx ON pokemon(sort_order, id); CREATE UNIQUE INDEX IF NOT EXISTS pokemon_display_event_item_key ON pokemon(display_id, is_event_item); -CREATE INDEX IF NOT EXISTS life_tags_sort_order_idx ON life_tags(sort_order, id); -CREATE UNIQUE INDEX IF NOT EXISTS life_tags_single_default_idx ON life_tags(is_default) WHERE is_default = true; CREATE INDEX IF NOT EXISTS acquisition_methods_sort_order_idx ON acquisition_methods(sort_order, id); CREATE INDEX IF NOT EXISTS items_sort_order_idx ON items(sort_order, id); CREATE INDEX IF NOT EXISTS recipes_sort_order_idx ON recipes(sort_order, id); @@ -1506,10 +1492,6 @@ CREATE TABLE IF NOT EXISTS notification_ws_tickets ( CREATE INDEX IF NOT EXISTS notification_ws_tickets_user_idx ON notification_ws_tickets(user_id, expires_at DESC); -CREATE INDEX IF NOT EXISTS life_posts_category_idx - ON life_posts(category_id, created_at DESC, id DESC) - WHERE deleted_at IS NULL; - CREATE INDEX IF NOT EXISTS life_posts_game_version_idx ON life_posts(game_version_id, created_at DESC, id DESC) WHERE deleted_at IS NULL; diff --git a/backend/src/queries.ts b/backend/src/queries.ts index 39e940c..27a4b5b 100644 --- a/backend/src/queries.ts +++ b/backend/src/queries.ts @@ -136,7 +136,6 @@ type EntityType = | 'maps' | 'habitats' | 'daily-checklist-items' - | 'life-tags' | 'game-versions' | 'dish-categories' | 'dish-flavors' @@ -149,7 +148,6 @@ type ConfigType = | 'favorite-things' | 'acquisition-methods' | 'maps' - | 'life-tags' | 'game-versions' | 'dish-flavors'; @@ -158,8 +156,6 @@ type ConfigDefinition = { entityType: EntityType; hasItemDrop?: boolean; hasTrading?: boolean; - hasDefault?: boolean; - hasRateable?: boolean; hasChangeLog?: boolean; }; type SortableContentType = 'items' | 'ancient-artifacts' | 'recipes' | 'habitats'; @@ -330,7 +326,6 @@ type DailyChecklistPayload = { type LifePostPayload = { body: string; - categoryId: number; gameVersionId: number | null; languageCode: string | null; }; @@ -427,10 +422,7 @@ type LifePostRow = { updatedAt: Date; author: { id: number; displayName: string } | null; updatedBy: { id: number; displayName: string } | null; - category: { id: number; name: string; isRateable: boolean } | null; gameVersion: { id: number; name: string; changeLog: string } | null; - ratingAverage: number | null; - ratingCount: number; }; type LifePost = Omit & { @@ -438,16 +430,14 @@ type LifePost = Omit & { commentCount: number; reactionCounts: LifeReactionCounts; myReaction: LifeReactionType | null; - myRating: number | null; }; type LifePostCursor = { createdAt: string; id: number; - ratingAverage?: number; }; -type LifePostSort = 'latest' | 'oldest' | 'top-rated'; +type LifePostSort = 'latest' | 'oldest'; type CommentSort = 'oldest' | 'latest' | 'most-liked' | 'most-replied'; type CommentCursor = { createdAt: string; @@ -668,8 +658,6 @@ type ConfigChangeSource = { name: string; hasItemDrop?: boolean; hasTrading?: boolean; - isDefault?: boolean; - isRateable?: boolean; changeLog?: string; } & TranslationChangeSource; @@ -738,7 +726,6 @@ const configDefinitions: Record = { 'favorite-things': { table: 'favorite_things', entityType: 'favorite-things' }, 'acquisition-methods': { table: 'acquisition_methods', entityType: 'acquisition-methods' }, maps: { table: 'maps', entityType: 'maps' }, - 'life-tags': { table: 'life_tags', entityType: 'life-tags', hasDefault: true, hasRateable: true }, 'game-versions': { table: 'game_versions', entityType: 'game-versions', hasChangeLog: true }, 'dish-flavors': { table: 'dish_flavors', entityType: 'dish-flavors' } }; @@ -1081,13 +1068,6 @@ function systemListJsonSql(expression: string, options: readonly SystemListOptio return `json_build_object('id', ${systemListIdSql(expression, options)}, 'key', ${expression}, 'name', ${systemListNameSql(expression, options, locale)})`; } -function lifeCategoryOptions(locale: string): Promise> { - const name = localizedName('life-tags', 'lc', locale); - return query( - `SELECT lc.id, ${name} AS name, lc.is_default AS "isDefault", lc.is_rateable AS "isRateable" FROM life_tags lc ORDER BY ${orderByEntity('lc')}` - ); -} - function gameVersionOptions(locale: string): Promise> { const name = localizedName('game-versions', 'gv', locale); return query(`SELECT gv.id, ${name} AS name, gv.change_log AS "changeLog" FROM game_versions gv ORDER BY ${orderByEntity('gv')}`); @@ -1136,12 +1116,6 @@ function configSelect(definition: ConfigDefinition, locale: string): string { if (definition.hasTrading) { columns.push(`c.has_trading AS "hasTrading"`); } - if (definition.hasDefault) { - columns.push(`c.is_default AS "isDefault"`); - } - if (definition.hasRateable) { - columns.push(`c.is_rateable AS "isRateable"`); - } if (definition.hasChangeLog) { columns.push(`c.change_log AS "changeLog"`); } @@ -2096,7 +2070,7 @@ async function ensurePokemonTypeCatalog( const changes = configEditChanges( { table: 'pokemon_types', entityType: 'pokemon-types' }, existing.rows[0], - { name, translations, hasItemDrop: false, hasTrading: false, isDefault: false, isRateable: false, changeLog: '' } + { name, translations, hasItemDrop: false, hasTrading: false, changeLog: '' } ); if (changes.length) { await client.query( @@ -2665,8 +2639,6 @@ function configEditChanges( translations: TranslationInput; hasItemDrop: boolean; hasTrading: boolean; - isDefault: boolean; - isRateable: boolean; changeLog: string; } ): EditChange[] { @@ -2679,12 +2651,6 @@ function configEditChanges( if (definition.hasTrading) { pushChange(changes, 'Has trading', boolValue(Boolean(before.hasTrading)), boolValue(after.hasTrading)); } - if (definition.hasDefault) { - pushChange(changes, 'Default category', boolValue(Boolean(before.isDefault)), boolValue(after.isDefault)); - } - if (definition.hasRateable) { - pushChange(changes, 'Rateable', boolValue(Boolean(before.isRateable)), boolValue(after.isRateable)); - } if (definition.hasChangeLog) { pushChange(changes, 'ChangeLog', before.changeLog, after.changeLog); } @@ -2782,7 +2748,6 @@ export async function getOptions(locale = defaultLocale) { favoriteThings, acquisitionMethods, maps, - lifeCategories, gameVersions, dishFlavors ] = await Promise.all([ @@ -2792,7 +2757,6 @@ export async function getOptions(locale = defaultLocale) { optionSelect('favorite_things', 'favorite-things', locale), optionSelect('acquisition_methods', 'acquisition-methods', locale), optionSelect('maps', 'maps', locale), - lifeCategoryOptions(locale), gameVersionOptions(locale), optionSelect('dish_flavors', 'dish-flavors', locale) ]); @@ -2808,7 +2772,6 @@ export async function getOptions(locale = defaultLocale) { acquisitionMethods, itemTags: favoriteThings, maps, - lifeCategories, gameVersions, dishFlavors }; @@ -2851,8 +2814,6 @@ export async function globalSearch(paramsQuery: QueryParams = {}, locale = defau const recipeItemName = localizedName('items', 'result_item', locale); const recipeMaterialName = localizedName('items', 'material_item', locale); const checklistTitle = localizedField('daily-checklist-items', 'c.id', 'c.title', 'title', locale); - const lifeCategoryName = localizedName('life-tags', 'lc', locale); - const [pokemon, habitats, items, artifacts, recipes, checklist, life, users] = await Promise.all([ query( ` @@ -2981,10 +2942,9 @@ export async function globalSearch(paramsQuery: QueryParams = {}, locale = defau LEFT(lp.body, 120) AS title, '/life/' || lp.id AS url, NULL AS summary, - ${lifeCategoryName} AS meta, + NULL AS meta, NULL AS image FROM life_posts lp - LEFT JOIN life_tags lc ON lc.id = lp.category_id WHERE lp.deleted_at IS NULL AND lp.ai_moderation_status = 'approved' AND lp.body ILIKE $1 @@ -3153,12 +3113,10 @@ function cleanLifePostPayload(payload: Record): LifePostPayload if (body.length > 2000) { throw validationError('server.validation.postTooLong'); } - const categoryId = requirePositiveInteger(payload.categoryId, 'server.validation.lifeCategoryRequired'); const gameVersionId = optionalPositiveInteger(payload.gameVersionId, 'server.validation.gameVersionInvalid'); return { body, - categoryId, gameVersionId, languageCode: cleanModerationLanguageCode(payload.languageCode) }; @@ -3203,15 +3161,6 @@ function cleanLifeReactionFilter(value: QueryValue): LifeReactionType | null { return cleanLifeReactionType(reactionType); } -function cleanLifeRating(value: unknown): number { - const rating = Number(value); - if (!Number.isInteger(rating) || rating < 1 || rating > 5) { - throw validationError('server.validation.ratingInvalid'); - } - - return rating; -} - function cleanUserCommentActivitySourceFilter(value: QueryValue): UserCommentActivitySource | null { const source = asString(value); if (!source) { @@ -3279,7 +3228,6 @@ function addModerationLanguageCondition( } function lifePostProjection(locale = defaultLocale): string { - const categoryName = localizedName('life-tags', 'lc', locale); const gameVersionName = localizedName('game-versions', 'gv', locale); return ` @@ -3300,29 +3248,12 @@ function lifePostProjection(locale = defaultLocale): string { WHEN updated_user.id IS NULL THEN NULL ELSE json_build_object('id', updated_user.id, 'displayName', updated_user.display_name) END AS "updatedBy", - CASE - WHEN lc.id IS NULL THEN NULL - ELSE json_build_object('id', lc.id, 'name', ${categoryName}, 'isRateable', lc.is_rateable) - END AS category, CASE WHEN gv.id IS NULL THEN NULL ELSE json_build_object('id', gv.id, 'name', ${gameVersionName}, 'changeLog', gv.change_log) - END AS "gameVersion", - CASE - WHEN rating_stats.rating_count = 0 THEN NULL - ELSE rating_stats.rating_average::double precision - END AS "ratingAverage", - rating_stats.rating_count AS "ratingCount" + END AS "gameVersion" FROM life_posts lp - LEFT JOIN life_tags lc ON lc.id = lp.category_id LEFT JOIN game_versions gv ON gv.id = lp.game_version_id - LEFT JOIN LATERAL ( - SELECT - ROUND(AVG(lpr.rating)::numeric, 2) AS rating_average, - COUNT(*)::integer AS rating_count - FROM life_post_ratings lpr - WHERE lpr.post_id = lp.id - ) rating_stats ON true LEFT JOIN users created_user ON created_user.id = lp.created_by_user_id LEFT JOIN users updated_user ON updated_user.id = lp.updated_by_user_id `; @@ -3340,18 +3271,7 @@ function cleanLifePostLimit(value: QueryValue): number { function cleanLifePostSort(value: QueryValue): LifePostSort { const sort = asString(value); - return sort === 'oldest' || sort === 'top-rated' ? sort : 'latest'; -} - -function cleanRateableFilter(value: QueryValue): boolean | null { - const rateable = asString(value); - if (rateable === 'true') { - return true; - } - if (rateable === 'false') { - return false; - } - return null; + return sort === 'oldest' ? sort : 'latest'; } function cleanCommentLimit(value: QueryValue): number { @@ -3460,19 +3380,17 @@ function decodeLifePostCursor(value: QueryValue): LifePostCursor | null { const cursor = JSON.parse(Buffer.from(rawCursor, 'base64url').toString('utf8')) as Partial; const createdAt = typeof cursor.createdAt === 'string' ? cursor.createdAt : ''; const id = Number(cursor.id); - const ratingAverage = cursor.ratingAverage === undefined ? undefined : Number(cursor.ratingAverage); if ( !createdAt || Number.isNaN(new Date(createdAt).getTime()) || !Number.isInteger(id) || - id <= 0 || - (ratingAverage !== undefined && (Number.isNaN(ratingAverage) || ratingAverage < 0)) + id <= 0 ) { throw validationError('server.validation.cursorInvalid'); } - return { createdAt, id, ratingAverage }; + return { createdAt, id }; } catch (error) { if (error instanceof Error && 'statusCode' in error) { throw error; @@ -3482,10 +3400,7 @@ function decodeLifePostCursor(value: QueryValue): LifePostCursor | null { } function encodeLifePostCursor(post: LifePostRow): string { - return Buffer.from( - JSON.stringify({ createdAt: post.createdAtCursor, id: post.id, ratingAverage: post.ratingAverage ?? 0 }), - 'utf8' - ).toString('base64url'); + return Buffer.from(JSON.stringify({ createdAt: post.createdAtCursor, id: post.id }), 'utf8').toString('base64url'); } function encodeProfileCursor(cursor: LifePostCursor): string { @@ -3560,8 +3475,7 @@ function hydrateLifePost( commentPreviewByPost: Map, commentCountsByPost: Map, countsByPost: Map, - myReactionsByPost: Map, - myRatingsByPost: Map + myReactionsByPost: Map ): LifePost { return { id: post.id, @@ -3573,15 +3487,11 @@ function hydrateLifePost( updatedAt: post.updatedAt, author: post.author, updatedBy: post.updatedBy, - category: post.category, gameVersion: post.gameVersion, - ratingAverage: post.ratingAverage, - ratingCount: post.ratingCount, commentPreview: commentPreviewByPost.get(post.id) ?? [], commentCount: commentCountsByPost.get(post.id) ?? 0, reactionCounts: countsByPost.get(post.id) ?? emptyLifeReactionCounts(), - myReaction: myReactionsByPost.get(post.id) ?? null, - myRating: myRatingsByPost.get(post.id) ?? null + myReaction: myReactionsByPost.get(post.id) ?? null }; } @@ -4004,30 +3914,6 @@ export async function listLifePostReactionUsers( }; } -async function lifeRatingsForPosts(postIds: number[], userId: number | null): Promise> { - const myRatingsByPost = new Map(); - - if (postIds.length === 0 || userId === null) { - return myRatingsByPost; - } - - const rows = await query<{ postId: number; rating: number }>( - ` - SELECT post_id AS "postId", rating - FROM life_post_ratings - WHERE post_id = ANY($1::integer[]) - AND user_id = $2 - `, - [postIds, userId] - ); - - for (const row of rows) { - myRatingsByPost.set(row.postId, row.rating); - } - - return myRatingsByPost; -} - async function getLifeCommentById(id: number, userId: number | null = null, canViewAll = false): Promise { const row = await queryOne( ` @@ -4055,9 +3941,7 @@ async function listLifePostsWithFilters( const limit = cleanLifePostLimit(paramsQuery.limit); const sort = cleanLifePostSort(paramsQuery.sort); const search = asString(paramsQuery.search)?.trim(); - const categoryIdValue = asString(paramsQuery.categoryId)?.trim(); const gameVersionIdValue = asString(paramsQuery.gameVersionId)?.trim(); - const rateable = cleanRateableFilter(paramsQuery.rateable); const languageCode = cleanModerationLanguageFilter(paramsQuery.language); const params: unknown[] = []; const conditions: string[] = ['lp.deleted_at IS NULL']; @@ -4087,41 +3971,20 @@ async function listLifePostsWithFilters( conditions.push(`lp.body ILIKE $${params.length}`); } - if (categoryIdValue) { - const categoryId = requirePositiveInteger(categoryIdValue, 'server.validation.lifeCategoryInvalid'); - params.push(categoryId); - conditions.push(`lp.category_id = $${params.length}`); - } - if (gameVersionIdValue && gameVersionIdValue !== 'all') { const gameVersionId = requirePositiveInteger(gameVersionIdValue, 'server.validation.gameVersionInvalid'); params.push(gameVersionId); conditions.push(`lp.game_version_id = $${params.length}`); } - if (rateable !== null) { - params.push(rateable); - conditions.push(`lc.is_rateable = $${params.length}`); - } - if (cursor) { - if (sort === 'top-rated') { - params.push(cursor.ratingAverage ?? 0, cursor.createdAt, cursor.id); - conditions.push( - `(COALESCE(rating_stats.rating_average, 0), lp.created_at, lp.id) < ($${params.length - 2}::numeric, $${params.length - 1}::timestamptz, $${params.length}::integer)` - ); - } else { - params.push(cursor.createdAt, cursor.id); - conditions.push( - `(lp.created_at, lp.id) ${sort === 'oldest' ? '>' : '<'} ($${params.length - 1}::timestamptz, $${params.length}::integer)` - ); - } + params.push(cursor.createdAt, cursor.id); + conditions.push( + `(lp.created_at, lp.id) ${sort === 'oldest' ? '>' : '<'} ($${params.length - 1}::timestamptz, $${params.length}::integer)` + ); } - const orderClause = - sort === 'top-rated' - ? 'ORDER BY COALESCE(rating_stats.rating_average, 0) DESC, lp.created_at DESC, lp.id DESC' - : `ORDER BY lp.created_at ${sort === 'oldest' ? 'ASC' : 'DESC'}, lp.id ${sort === 'oldest' ? 'ASC' : 'DESC'}`; + const orderClause = `ORDER BY lp.created_at ${sort === 'oldest' ? 'ASC' : 'DESC'}, lp.id ${sort === 'oldest' ? 'ASC' : 'DESC'}`; const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : ''; params.push(limit + 1); const rows = await query( @@ -4140,11 +4003,10 @@ async function listLifePostsWithFilters( const commentPreviewByPost = await lifeCommentPreviewForPosts(postIds, userId, canViewAll); const commentCountsByPost = await lifeCommentCountsForPosts(postIds, userId, canViewAll); const { countsByPost, myReactionsByPost } = await lifeReactionsForPosts(postIds, userId); - const myRatingsByPost = await lifeRatingsForPosts(postIds, userId); return { items: posts.map((post) => - hydrateLifePost(post, commentPreviewByPost, commentCountsByPost, countsByPost, myReactionsByPost, myRatingsByPost) + hydrateLifePost(post, commentPreviewByPost, commentCountsByPost, countsByPost, myReactionsByPost) ), nextCursor: hasMore && posts.length > 0 ? encodeLifePostCursor(posts[posts.length - 1]) : null, hasMore @@ -4429,10 +4291,9 @@ async function hydrateLifePostsById( const commentPreviewByPost = await lifeCommentPreviewForPosts(postIds, viewerUserId, canViewAll); const commentCountsByPost = await lifeCommentCountsForPosts(postIds, viewerUserId, canViewAll); const { countsByPost, myReactionsByPost } = await lifeReactionsForPosts(postIds, viewerUserId); - const myRatingsByPost = await lifeRatingsForPosts(postIds, viewerUserId); for (const post of posts) { - postById.set(post.id, hydrateLifePost(post, commentPreviewByPost, commentCountsByPost, countsByPost, myReactionsByPost, myRatingsByPost)); + postById.set(post.id, hydrateLifePost(post, commentPreviewByPost, commentCountsByPost, countsByPost, myReactionsByPost)); } return postById; @@ -4693,8 +4554,7 @@ async function getLifePostById( const commentPreviewByPost = await lifeCommentPreviewForPosts([post.id], userId, canViewAll); const commentCountsByPost = await lifeCommentCountsForPosts([post.id], userId, canViewAll); const { countsByPost, myReactionsByPost } = await lifeReactionsForPosts([post.id], userId); - const myRatingsByPost = await lifeRatingsForPosts([post.id], userId); - return hydrateLifePost(post, commentPreviewByPost, commentCountsByPost, countsByPost, myReactionsByPost, myRatingsByPost); + return hydrateLifePost(post, commentPreviewByPost, commentCountsByPost, countsByPost, myReactionsByPost); } export async function getLifePost( @@ -4707,13 +4567,6 @@ export async function getLifePost( return getLifePostById(id, userId, locale, { enforceVisibility: true, canViewAll }); } -async function ensureLifeCategory(client: DbClient, categoryId: number): Promise { - const result = await client.query<{ id: number }>('SELECT id FROM life_tags WHERE id = $1', [categoryId]); - if (result.rowCount === 0) { - throw validationError('server.validation.lifeCategoryInvalid'); - } -} - async function ensureGameVersion(client: DbClient, gameVersionId: number | null): Promise { if (gameVersionId === null) { return; @@ -4725,43 +4578,28 @@ async function ensureGameVersion(client: DbClient, gameVersionId: number | null) } } -async function replaceLifePostCategoryLink(client: DbClient, postId: number, categoryId: number): Promise { - await client.query('DELETE FROM life_post_tags WHERE post_id = $1', [postId]); - await client.query( - ` - INSERT INTO life_post_tags (post_id, tag_id) - VALUES ($1, $2) - `, - [postId, categoryId] - ); -} - export async function createLifePost(payload: Record, userId: number, locale = defaultLocale) { const cleanPayload = cleanLifePostPayload(payload); const id = await withTransaction(async (client) => { - await ensureLifeCategory(client, cleanPayload.categoryId); await ensureGameVersion(client, cleanPayload.gameVersionId); const result = await client.query<{ id: number }>( ` INSERT INTO life_posts ( body, - category_id, game_version_id, ai_moderation_status, ai_moderation_language_code, created_by_user_id, updated_by_user_id ) - VALUES ($1, $2, $3, 'reviewing', NULL, $4, $4) + VALUES ($1, $2, 'reviewing', NULL, $3, $3) RETURNING id `, - [cleanPayload.body, cleanPayload.categoryId, cleanPayload.gameVersionId, userId] + [cleanPayload.body, cleanPayload.gameVersionId, userId] ); - const createdId = result.rows[0].id; - await replaceLifePostCategoryLink(client, createdId, cleanPayload.categoryId); - return createdId; + return result.rows[0].id; }); await requestAiModerationReview({ type: 'life-post', id }, { languageCode: cleanPayload.languageCode, resetRetries: true }); @@ -4778,37 +4616,29 @@ export async function updateLifePost( const cleanPayload = cleanLifePostPayload(payload); const updatedId = await withTransaction(async (client) => { - await ensureLifeCategory(client, cleanPayload.categoryId); await ensureGameVersion(client, cleanPayload.gameVersionId); const result = await client.query<{ id: number }>( ` UPDATE life_posts SET body = $1, - category_id = $2, - game_version_id = $3, + game_version_id = $2, ai_moderation_status = 'reviewing', ai_moderation_language_code = NULL, ai_moderation_content_hash = NULL, ai_moderation_checked_at = NULL, ai_moderation_retry_count = 0, ai_moderation_updated_at = now(), - updated_by_user_id = $4, + updated_by_user_id = $3, updated_at = now() - WHERE id = $5 - AND ($6 = true OR created_by_user_id = $4) + WHERE id = $4 + AND ($5 = true OR created_by_user_id = $3) AND deleted_at IS NULL RETURNING id `, - [cleanPayload.body, cleanPayload.categoryId, cleanPayload.gameVersionId, userId, id, allowAny] + [cleanPayload.body, cleanPayload.gameVersionId, userId, id, allowAny] ); - const resultId = result.rows[0]?.id ?? null; - if (resultId === null) { - return null; - } - - await replaceLifePostCategoryLink(client, resultId, cleanPayload.categoryId); - return resultId; + return result.rows[0]?.id ?? null; }); if (updatedId) { @@ -4916,57 +4746,6 @@ export async function deleteLifePostReaction(postId: number, userId: number, loc return getLifePostById(postId, userId, locale); } -export async function setLifePostRating( - postId: number, - payload: Record, - userId: number, - locale = defaultLocale -) { - const rating = cleanLifeRating(payload.rating); - - const result = await queryOne<{ postId: number }>( - ` - INSERT INTO life_post_ratings (post_id, user_id, rating) - SELECT $1, $2, $3 - FROM life_posts lp - JOIN life_tags lt ON lt.id = lp.category_id - WHERE lp.id = $1 - AND lp.deleted_at IS NULL - AND lp.ai_moderation_status = 'approved' - AND lt.is_rateable = true - ON CONFLICT (post_id, user_id) - DO UPDATE SET rating = EXCLUDED.rating, updated_at = now() - RETURNING post_id AS "postId" - `, - [postId, userId, rating] - ); - - return result ? getLifePostById(result.postId, userId, locale) : null; -} - -export async function deleteLifePostRating(postId: number, userId: number, locale = defaultLocale) { - const result = await queryOne<{ postId: number }>( - ` - DELETE FROM life_post_ratings - WHERE post_id = $1 - AND user_id = $2 - AND EXISTS ( - SELECT 1 - FROM life_posts lp - JOIN life_tags lt ON lt.id = lp.category_id - WHERE lp.id = $1 - AND lp.deleted_at IS NULL - AND lp.ai_moderation_status = 'approved' - AND lt.is_rateable = true - ) - RETURNING post_id AS "postId" - `, - [postId, userId] - ); - - return result ? getLifePostById(postId, userId, locale) : null; -} - export async function createLifeComment(postId: number, payload: Record, userId: number) { const cleanPayload = cleanLifeCommentPayload(payload); @@ -5609,18 +5388,10 @@ export async function createConfig(type: ConfigType, payload: Record { const sortOrder = await nextSortOrder(client, definition.table); - if (definition.hasDefault && isDefault) { - await client.query( - `UPDATE ${definition.table} SET is_default = false, updated_by_user_id = $1, updated_at = now() WHERE is_default = true`, - [userId] - ); - } const columns = ['name']; const values: unknown[] = [name]; if (definition.hasItemDrop) { @@ -5631,14 +5402,6 @@ export async function createConfig(type: ConfigType, payload: Record { - if (definition.hasDefault && isDefault) { - await client.query( - `UPDATE ${definition.table} SET is_default = false, updated_by_user_id = $2, updated_at = now() WHERE id <> $1 AND is_default = true`, - [id, userId] - ); - } - const assignments = ['name = $1']; const values: unknown[] = [name]; if (definition.hasItemDrop) { @@ -5713,14 +5467,6 @@ export async function updateConfig( values.push(hasTrading); assignments.push(`has_trading = $${values.length}`); } - if (definition.hasDefault) { - values.push(isDefault); - assignments.push(`is_default = $${values.length}`); - } - if (definition.hasRateable) { - values.push(isRateable); - assignments.push(`is_rateable = $${values.length}`); - } if (definition.hasChangeLog) { values.push(changeLog); assignments.push(`change_log = $${values.length}`); @@ -5768,7 +5514,7 @@ export async function updateConfig( await replaceEntityTranslations(client, definition.entityType, id, translations, ['name']); const changes = before - ? configEditChanges(definition, before as ConfigChangeSource, { name, translations, hasItemDrop, hasTrading, isDefault, isRateable, changeLog }) + ? configEditChanges(definition, before as ConfigChangeSource, { name, translations, hasItemDrop, hasTrading, changeLog }) : []; await recordEditLog(client, type, id, 'update', userId, changes); return true; diff --git a/backend/src/server.ts b/backend/src/server.ts index 8fac34c..97b6d71 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -68,7 +68,6 @@ import { deleteLifeComment, deleteLifeCommentLike, deleteLifePost, - deleteLifePostRating, deleteLifePostReaction, deletePokemon, deleteRecipe, @@ -133,7 +132,6 @@ import { retryLifePostModeration, retryThreadMessageModeration, restoreLifeComment, - setLifePostRating, setLifePostReaction, setEntityDiscussionCommentLike, setLifeCommentLike, @@ -1502,26 +1500,6 @@ app.delete('/api/life-posts/:id/reaction', async (request, reply) => { return post ? post : notFound(reply, request); }); -app.put('/api/life-posts/:id/rating', async (request, reply) => { - const user = await requirePermissionWithRateLimits(request, reply, 'life.ratings.set', 'communityReaction'); - if (!user) { - return; - } - const { id } = request.params as { id: string }; - const post = await setLifePostRating(Number(id), request.body as Record, user.id, requestLocale(request)); - return post ? post : notFound(reply, request); -}); - -app.delete('/api/life-posts/:id/rating', async (request, reply) => { - const user = await requirePermissionWithRateLimits(request, reply, 'life.ratings.set', 'communityReaction'); - if (!user) { - return; - } - const { id } = request.params as { id: string }; - const post = await deleteLifePostRating(Number(id), user.id, requestLocale(request)); - return post ? post : notFound(reply, request); -}); - app.delete('/api/life-posts/:id', async (request, reply) => { const user = await requireAnyPermissionWithRateLimits( request, diff --git a/frontend/src/components/EditHistoryPanel.vue b/frontend/src/components/EditHistoryPanel.vue index dfdcf92..c75dad5 100644 --- a/frontend/src/components/EditHistoryPanel.vue +++ b/frontend/src/components/EditHistoryPanel.vue @@ -85,10 +85,6 @@ const changeLabelKeys: Record = { 有掉落物: 'pages.admin.hasItemDrop', 'Has trading': 'pages.admin.hasTrading', '有 Trading': 'pages.admin.hasTrading', - 'Default category': 'pages.admin.defaultCategory', - 默认分类: 'pages.admin.defaultCategory', - Rateable: 'pages.admin.rateableCategory', - 可评分: 'pages.admin.rateableCategory', ChangeLog: 'pages.admin.changeLog' }; diff --git a/frontend/src/services/api.ts b/frontend/src/services/api.ts index 9c716f0..5e80a76 100644 --- a/frontend/src/services/api.ts +++ b/frontend/src/services/api.ts @@ -74,11 +74,6 @@ export interface NamedEntity { translations?: TranslationMap; } -export interface LifeCategory extends NamedEntity { - isDefault: boolean; - isRateable: boolean; -} - export interface GameVersion extends NamedEntity { changeLog: string; } @@ -494,11 +489,7 @@ export interface LifePost { updatedAt: string; author: UserSummary | null; updatedBy: UserSummary | null; - category: (NamedEntity & { isRateable: boolean }) | null; gameVersion: GameVersion | null; - ratingAverage: number | null; - ratingCount: number; - myRating: number | null; commentPreview: LifeComment[]; commentCount: number; reactionCounts: LifeReactionCounts; @@ -515,11 +506,9 @@ export interface LifePostsParams { cursor?: string | null; limit?: number; search?: string; - categoryId?: string | number; language?: string; gameVersionId?: string | number; - rateable?: boolean | null; - sort?: 'latest' | 'oldest' | 'top-rated'; + sort?: 'latest' | 'oldest'; } export interface CommentPageParams { @@ -775,7 +764,6 @@ export interface Options { acquisitionMethods: NamedEntity[]; itemTags: NamedEntity[]; maps: NamedEntity[]; - lifeCategories: LifeCategory[]; gameVersions: GameVersion[]; dishFlavors: NamedEntity[]; } @@ -935,7 +923,6 @@ export type ConfigType = | 'favorite-things' | 'acquisition-methods' | 'maps' - | 'life-tags' | 'game-versions' | 'dish-flavors'; @@ -1059,7 +1046,6 @@ export interface DailyChecklistPayload { export interface LifePostPayload { body: string; - categoryId: number; gameVersionId?: number | null; languageCode?: string | null; } @@ -1395,10 +1381,8 @@ export const api = { cursor: params.cursor ?? undefined, limit: params.limit, search: params.search, - categoryId: params.categoryId, language: params.language, gameVersionId: params.gameVersionId, - rateable: params.rateable === null ? undefined : params.rateable, sort: params.sort })}` ), @@ -1456,10 +1440,8 @@ export const api = { cursor: params.cursor ?? undefined, limit: params.limit, search: params.search?.trim(), - categoryId: params.categoryId, language: params.language, gameVersionId: params.gameVersionId, - rateable: params.rateable === null ? undefined : params.rateable, sort: params.sort })}` ), @@ -1531,9 +1513,6 @@ export const api = { sendJson(`/api/admin/threads/${id}/lock`, 'PUT', { locked }), deleteThread: (id: string | number) => deleteJson(`/api/admin/threads/${id}`), deleteThreadMessage: (id: string | number) => deleteJson(`/api/admin/thread-messages/${id}`), - setLifeRating: (id: string | number, rating: number) => - sendJson(`/api/life-posts/${id}/rating`, 'PUT', { rating }), - deleteLifeRating: (id: string | number) => deleteAndGetJson(`/api/life-posts/${id}/rating`), createLifeComment: (postId: string | number, payload: LifeCommentPayload) => sendJson(`/api/life-posts/${postId}/comments`, 'POST', payload), lifeComments: (postId: string | number, params: CommentPageParams = {}) => @@ -1599,20 +1578,20 @@ export const api = { reorderDailyChecklistItems: (ids: number[]) => sendJson('/api/admin/daily-checklist/order', 'PUT', { ids }), deleteDailyChecklistItem: (id: string | number) => deleteJson(`/api/admin/daily-checklist/${id}`), - config: (type: ConfigType) => getJson>(`/api/admin/config/${type}`), + config: (type: ConfigType) => getJson>(`/api/admin/config/${type}`), createConfig: ( type: ConfigType, - payload: { name: string; translations?: TranslationMap; hasItemDrop?: boolean; hasTrading?: boolean; isDefault?: boolean; isRateable?: boolean; changeLog?: string } + payload: { name: string; translations?: TranslationMap; hasItemDrop?: boolean; hasTrading?: boolean; changeLog?: string } ) => - sendJson(`/api/admin/config/${type}`, 'POST', payload), + sendJson(`/api/admin/config/${type}`, 'POST', payload), reorderConfig: (type: ConfigType, ids: number[]) => - sendJson>(`/api/admin/config/${type}/order`, 'PUT', { ids }), + sendJson>(`/api/admin/config/${type}/order`, 'PUT', { ids }), updateConfig: ( type: ConfigType, id: number, - payload: { name: string; translations?: TranslationMap; hasItemDrop?: boolean; hasTrading?: boolean; isDefault?: boolean; isRateable?: boolean; changeLog?: string } + payload: { name: string; translations?: TranslationMap; hasItemDrop?: boolean; hasTrading?: boolean; changeLog?: string } ) => - sendJson(`/api/admin/config/${type}/${id}`, 'PUT', payload), + sendJson(`/api/admin/config/${type}/${id}`, 'PUT', payload), deleteConfig: (type: ConfigType, id: number) => deleteJson(`/api/admin/config/${type}/${id}`), pokemon: (params: Record) => getJson(`/api/pokemon${buildQuery(params)}`), diff --git a/frontend/src/views/AdminView.vue b/frontend/src/views/AdminView.vue index f285fd3..1427d40 100644 --- a/frontend/src/views/AdminView.vue +++ b/frontend/src/views/AdminView.vue @@ -53,7 +53,6 @@ import { type Habitat, type Item, type Language, - type LifeCategory, type NamedEntity, type Permission, type PermissionPayload, @@ -93,11 +92,9 @@ type AdminTab = type AdminGroup = 'content' | 'configuration' | 'localization' | 'access'; type AdminNavItem = { key: AdminTab; label: string; permission: string | string[] }; type AdminNavGroup = { key: AdminGroup; label: string; items: AdminNavItem[] }; -type EditableConfig = (NamedEntity | Skill | LifeCategory | GameVersion) & { +type EditableConfig = (NamedEntity | Skill | GameVersion) & { hasItemDrop?: boolean; hasTrading?: boolean; - isDefault?: boolean; - isRateable?: boolean; changeLog?: string; }; type RateLimitPolicyForm = { @@ -207,8 +204,6 @@ const configTypes = computed< label: string; supportsItemDrop?: boolean; supportsTrading?: boolean; - supportsDefault?: boolean; - supportsRateable?: boolean; supportsChangeLog?: boolean; }> >(() => [ @@ -218,7 +213,6 @@ const configTypes = computed< { key: 'favorite-things', label: t('config.favoriteThings') }, { key: 'acquisition-methods', label: t('config.acquisitionMethods') }, { key: 'maps', label: t('config.maps') }, - { key: 'life-tags', label: t('config.lifeCategories'), supportsDefault: true, supportsRateable: true }, { key: 'game-versions', label: t('config.gameVersions'), supportsChangeLog: true }, { key: 'dish-flavors', label: t('config.dishFlavors') } ]); @@ -255,8 +249,6 @@ const configForm = ref({ translations: {} as TranslationMap, hasItemDrop: false, hasTrading: false, - isDefault: false, - isRateable: false, changeLog: '' }); const checklistForm = ref({ id: 0, title: '', translations: {} as TranslationMap }); @@ -618,7 +610,7 @@ async function loadLanguages() { } function resetConfigForm() { - configForm.value = { id: 0, name: '', translations: {}, hasItemDrop: false, hasTrading: false, isDefault: false, isRateable: false, changeLog: '' }; + configForm.value = { id: 0, name: '', translations: {}, hasItemDrop: false, hasTrading: false, changeLog: '' }; } function resetChecklistForm() { @@ -729,8 +721,6 @@ function editConfig(item: EditableConfig) { translations: item.translations ?? {}, hasItemDrop: item.hasItemDrop === true, hasTrading: item.hasTrading === true, - isDefault: item.isDefault === true, - isRateable: item.isRateable === true, changeLog: item.changeLog ?? '' }; configModalOpen.value = true; @@ -1115,8 +1105,6 @@ async function saveConfig() { translations: configForm.value.translations, hasItemDrop: selectedConfig.value.supportsItemDrop ? configForm.value.hasItemDrop : undefined, hasTrading: selectedConfig.value.supportsTrading ? configForm.value.hasTrading : undefined, - isDefault: selectedConfig.value.supportsDefault ? configForm.value.isDefault : undefined, - isRateable: selectedConfig.value.supportsRateable ? configForm.value.isRateable : undefined, changeLog: selectedConfig.value.supportsChangeLog ? configForm.value.changeLog : undefined }; @@ -2172,8 +2160,6 @@ onMounted(() => { {{ item.name }} {{ t('pages.admin.hasItemDrop') }} {{ t('pages.admin.hasTrading') }} - {{ t('pages.admin.defaultCategory') }} - {{ t('pages.admin.rateableCategory') }}