点赞和改造开关加入后台配置
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::creation_entry_config::{CreationEntryEventBannerResponse, UnifiedCreationSpecResponse};
|
||||
use crate::creation_entry_config::{
|
||||
CreationEntryEventBannerResponse, PublicWorkInteractionConfigResponse,
|
||||
UnifiedCreationSpecResponse,
|
||||
};
|
||||
|
||||
// 管理后台协议统一收口在 shared-contracts,避免页面脚本和 Rust handler 各自手拼字段。
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
@@ -20,6 +23,8 @@ pub struct AdminCreationEntryConfigResponse {
|
||||
pub entries: Vec<AdminCreationEntryTypeConfigPayload>,
|
||||
/// 底部加号创作入口页的后台公告列表。
|
||||
pub event_banners: Vec<CreationEntryEventBannerResponse>,
|
||||
/// 公开作品详情页点赞 / 改造能力配置。
|
||||
pub public_work_interactions: Vec<PublicWorkInteractionConfigResponse>,
|
||||
}
|
||||
|
||||
/// 后台单个创作入口开关配置。
|
||||
@@ -69,6 +74,13 @@ pub struct AdminUpsertCreationEntryEventBannersRequest {
|
||||
pub event_banners_json: String,
|
||||
}
|
||||
|
||||
/// 后台保存公开作品点赞 / 改造能力配置请求。
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AdminUpsertPublicWorkInteractionConfigRequest {
|
||||
pub public_work_interactions: Vec<PublicWorkInteractionConfigResponse>,
|
||||
}
|
||||
|
||||
/// 后台作品可见性列表项。
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
||||
@@ -12,6 +12,7 @@ pub struct CreationEntryConfigResponse {
|
||||
pub type_modal: CreationEntryTypeModalResponse,
|
||||
pub event_banner: CreationEntryEventBannerResponse,
|
||||
pub event_banners: Vec<CreationEntryEventBannerResponse>,
|
||||
pub public_work_interactions: Vec<PublicWorkInteractionConfigResponse>,
|
||||
pub creation_types: Vec<CreationEntryTypeResponse>,
|
||||
}
|
||||
|
||||
@@ -57,6 +58,20 @@ pub fn default_creation_entry_event_banner_render_mode() -> String {
|
||||
"structured".to_string()
|
||||
}
|
||||
|
||||
/// 单类公开作品互动能力配置。
|
||||
///
|
||||
/// 后台可以关闭已接入的点赞 / 改造能力;未接入后端动作的玩法即使误开,
|
||||
/// 前端仍会按实际能力矩阵返回不可用提示。
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PublicWorkInteractionConfigResponse {
|
||||
pub source_type: String,
|
||||
pub like_enabled: bool,
|
||||
pub remix_enabled: bool,
|
||||
pub like_disabled_message: String,
|
||||
pub remix_disabled_message: String,
|
||||
}
|
||||
|
||||
/// 单个创作模板入口配置,决定底部加号入口中的分类、排序和开放状态。
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@@ -547,6 +562,13 @@ mod tests {
|
||||
render_mode: "html".to_string(),
|
||||
html_code: Some("<section>ok</section>".to_string()),
|
||||
}],
|
||||
public_work_interactions: vec![PublicWorkInteractionConfigResponse {
|
||||
source_type: "puzzle".to_string(),
|
||||
like_enabled: true,
|
||||
remix_enabled: true,
|
||||
like_disabled_message: "拼图点赞暂不可用。".to_string(),
|
||||
remix_disabled_message: "拼图作品改造暂不可用。".to_string(),
|
||||
}],
|
||||
creation_types: Vec::new(),
|
||||
};
|
||||
let value = serde_json::to_value(response).expect("response should serialize");
|
||||
@@ -558,5 +580,6 @@ mod tests {
|
||||
);
|
||||
assert!(value.get("event_banner").is_none());
|
||||
assert!(value.get("eventBanner").is_some());
|
||||
assert_eq!(value["publicWorkInteractions"][0]["sourceType"], "puzzle");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user