@@ -110,30 +110,36 @@ impl UpdateCollectionData {
110110// ==================== 设置相关 DTO ====================
111111
112112/// 用于更新设置的数据结构
113- #[ derive( Clone , Debug , Default , Serialize , Deserialize ) ]
114- #[ serde( default ) ]
113+ #[ derive( Clone , Debug , Default , Serialize , Deserialize ) ]
114+ #[ serde( default , rename_all = "camelCase" ) ]
115115pub struct UpdateSettingsData {
116- pub bgm_token : Option < String > ,
117- pub vndb_token : Option < String > ,
118- pub save_root_path : Option < String > ,
119- pub db_backup_path : Option < String > ,
120- pub le_path : Option < String > ,
121- pub magpie_path : Option < String > ,
116+ #[ serde( default , deserialize_with = "double_option" ) ]
117+ pub bgm_token : Option < Option < String > > ,
118+ #[ serde( default , deserialize_with = "double_option" ) ]
119+ pub vndb_token : Option < Option < String > > ,
120+ #[ serde( default , deserialize_with = "double_option" ) ]
121+ pub save_root_path : Option < Option < String > > ,
122+ #[ serde( default , deserialize_with = "double_option" ) ]
123+ pub db_backup_path : Option < Option < String > > ,
124+ #[ serde( default , deserialize_with = "double_option" ) ]
125+ pub le_path : Option < Option < String > > ,
126+ #[ serde( default , deserialize_with = "double_option" ) ]
127+ pub magpie_path : Option < Option < String > > ,
122128}
123129
124130/// 清洗 UpdateSettingsData 中的空字符串
125- impl UpdateSettingsData {
126- /// 返回清洗后的数据,将空字符串转换为 None
131+ impl UpdateSettingsData {
132+ /// 返回清洗后的数据,将空字符串转换为 None
127133 pub fn cleaned ( mut self ) -> Self {
128- self . bgm_token = self . bgm_token . filter ( |s| !s . trim ( ) . is_empty ( ) ) ;
129- self . vndb_token = self . vndb_token . filter ( |s| !s . trim ( ) . is_empty ( ) ) ;
130- self . save_root_path = self . save_root_path . filter ( |s| !s . trim ( ) . is_empty ( ) ) ;
131- self . db_backup_path = self . db_backup_path . filter ( |s| !s . trim ( ) . is_empty ( ) ) ;
132- self . le_path = self . le_path . filter ( |s| !s . trim ( ) . is_empty ( ) ) ;
133- self . magpie_path = self . magpie_path . filter ( |s| !s . trim ( ) . is_empty ( ) ) ;
134+ self . bgm_token = clean_double_option_string ( self . bgm_token ) ;
135+ self . vndb_token = clean_double_option_string ( self . vndb_token ) ;
136+ self . save_root_path = clean_double_option_string ( self . save_root_path ) ;
137+ self . db_backup_path = clean_double_option_string ( self . db_backup_path ) ;
138+ self . le_path = clean_double_option_string ( self . le_path ) ;
139+ self . magpie_path = clean_double_option_string ( self . magpie_path ) ;
134140 self
135- }
136- }
141+ }
142+ }
137143
138144/// 用于插入游戏的数据结构(单表架构)
139145///
0 commit comments