22#ifndef mirai_cpp_defs_group_file_hpp_H_
33#define mirai_cpp_defs_group_file_hpp_H_
44#include < memory>
5+ #include < optional>
56#include " mirai/third-party/nlohmann/json.hpp"
67#include " mirai/defs/qq_types.hpp"
78#include " serializable.hpp"
9+ #include " FileDownloadInfo.hpp"
810using std::shared_ptr;
911
1012namespace Cyan
@@ -18,6 +20,11 @@ namespace Cyan
1820 */
1921 bool IsDirectory = false ;
2022
23+ /* *
24+ * @brief 文件大小
25+ */
26+ int Size = 0 ;
27+
2128 /* *
2229 * @brief 文件名称
2330 */
@@ -43,8 +50,14 @@ namespace Cyan
4350 */
4451 std::shared_ptr<GroupFile> ParentDirectory = nullptr ;
4552
53+ /* *
54+ * @brief 文件下载信息
55+ */
56+ std::optional<FileDownloadInfo> DownloadInfo = std::nullopt ;
57+
4658 virtual bool Set (const json& j) override
4759 {
60+ Size = j[" size" ].get <int64_t >();
4861 Name = j[" name" ].get <string>();
4962 Id = j[" id" ].get <string>();
5063 Path = j[" path" ].get <string>();
@@ -55,6 +68,12 @@ namespace Cyan
5568 ParentDirectory = std::make_shared<GroupFile>();
5669 ParentDirectory->Set (j[" parent" ]);
5770 }
71+ if (!j[" downloadInfo" ].is_null ())
72+ {
73+ FileDownloadInfo t;
74+ t.Set (j[" downloadInfo" ]);
75+ DownloadInfo = t;
76+ }
5877 return true ;
5978 }
6079 virtual json ToJson () const override
@@ -64,10 +83,12 @@ namespace Cyan
6483 { " name" , Name },
6584 { " id" , Id },
6685 { " path" , Path },
86+ { " size" , Size },
6787 { " contact" , Group.ToJson () },
6888 { " isFile" , !IsDirectory },
69- { " isDictionary" , IsDirectory },
70- { " parent" , ParentDirectory != nullptr ? ParentDirectory->ToJson () : RootDirectoryJson () }
89+ { " isDirectory" , IsDirectory },
90+ { " parent" , ParentDirectory != nullptr ? ParentDirectory->ToJson () : RootDirectoryJson () },
91+ { " downloadInfo" , DownloadInfo ? DownloadInfo->ToJson () : json (nullptr ) }
7192 };
7293 }
7394 private:
@@ -77,10 +98,12 @@ namespace Cyan
7798 {
7899 { " id" , json (nullptr ) },
79100 { " parent" , json (nullptr ) },
101+ { " downloadInfo" , json (nullptr ) },
80102 { " name" , " " },
81103 { " path" , " /" },
104+ { " Size" , 0 },
82105 { " isFile" , false },
83- { " isDictionary " , true },
106+ { " isDirectory " , true },
84107 { " contact" , Group.ToJson () }
85108 };
86109 }
0 commit comments