1+ use std:: fmt:: { Debug , Formatter , Result as fmtResult} ;
12use super :: schema:: { file_groups, files, group_tags, groups, tags} ;
23use chrono;
34use diesel:: prelude:: * ;
@@ -18,6 +19,16 @@ pub struct File {
1819 pub group_id : i32 ,
1920}
2021
22+ impl Debug for File {
23+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmtResult {
24+ write ! (
25+ f,
26+ "File {{ id: {}, type_: {}, path: {}, reference_count: {}, group_id: {} }}" ,
27+ self . id, self . type_, self . path, self . reference_count, self . group_id
28+ )
29+ }
30+ }
31+
2132#[ derive( Insertable ) ]
2233#[ diesel( table_name = files) ]
2334pub struct CreateFileDTO {
@@ -119,13 +130,29 @@ pub struct Group {
119130 pub modify_time : chrono:: NaiveDateTime ,
120131}
121132
133+ impl Debug for Group {
134+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmtResult {
135+ write ! (
136+ f,
137+ "Group {{ id: {}, name: {}, reference_count: {}, is_primary: {}, click_count: {}, share_count: {}, create_time: {}, modify_time: {} }}" ,
138+ self . id,
139+ self . name,
140+ self . reference_count,
141+ self . is_primary,
142+ self . click_count,
143+ self . share_count,
144+ self . create_time,
145+ self . modify_time
146+ )
147+ }
148+ }
149+
122150#[ derive( Insertable , Deserialize , Serialize ) ]
123151#[ diesel( table_name = groups) ]
124152pub struct CreateGroupDTO {
125153 pub name : String ,
126154}
127155
128-
129156#[ derive( Deserialize , Clone ) ]
130157pub enum GroupCondition {
131158 Id ( i32 ) ,
@@ -242,6 +269,16 @@ pub struct Tag {
242269 pub reference_count : i32 ,
243270}
244271
272+ impl Debug for Tag {
273+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmtResult {
274+ write ! (
275+ f,
276+ "Tag {{ id: {}, name: {}, reference_count: {} }}" ,
277+ self . id, self . name, self . reference_count
278+ )
279+ }
280+ }
281+
245282#[ derive( Insertable , Deserialize , Serialize ) ]
246283#[ diesel( table_name = tags) ]
247284pub struct CreateTagDTO {
@@ -319,6 +356,12 @@ pub struct FileGroupDTO {
319356 pub group_id : i32 ,
320357}
321358
359+ impl Debug for FileGroupDTO {
360+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmtResult {
361+ write ! ( f, "FileGroup {{ file_id: {}, group_id: {} }}" , self . file_id, self . group_id)
362+ }
363+ }
364+
322365#[ derive( serde:: Deserialize , Clone ) ]
323366pub enum FileGroupCondition {
324367 FileId ( i32 ) ,
@@ -360,6 +403,12 @@ pub struct GroupTagDTO {
360403 pub tag_id : i32 ,
361404}
362405
406+ impl Debug for GroupTagDTO {
407+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmtResult {
408+ write ! ( f, "GroupTag {{ group_id: {}, tag_id: {} }}" , self . group_id, self . tag_id)
409+ }
410+ }
411+
363412#[ derive( serde:: Deserialize , Clone ) ]
364413pub enum GroupTagCondition {
365414 GroupId ( i32 ) ,
0 commit comments