|
1 | 1 | package alist_v3 |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "encoding/json" |
4 | 5 | "time" |
5 | 6 |
|
6 | 7 | "github.com/alist-org/alist/v3/internal/model" |
@@ -72,15 +73,15 @@ type LoginResp struct { |
72 | 73 | } |
73 | 74 |
|
74 | 75 | type MeResp struct { |
75 | | - Id int `json:"id"` |
76 | | - Username string `json:"username"` |
77 | | - Password string `json:"password"` |
78 | | - BasePath string `json:"base_path"` |
79 | | - Role []int `json:"role"` |
80 | | - Disabled bool `json:"disabled"` |
81 | | - Permission int `json:"permission"` |
82 | | - SsoId string `json:"sso_id"` |
83 | | - Otp bool `json:"otp"` |
| 76 | + Id int `json:"id"` |
| 77 | + Username string `json:"username"` |
| 78 | + Password string `json:"password"` |
| 79 | + BasePath string `json:"base_path"` |
| 80 | + Role IntSlice `json:"role"` |
| 81 | + Disabled bool `json:"disabled"` |
| 82 | + Permission int `json:"permission"` |
| 83 | + SsoId string `json:"sso_id"` |
| 84 | + Otp bool `json:"otp"` |
84 | 85 | } |
85 | 86 |
|
86 | 87 | type ArchiveMetaReq struct { |
@@ -168,3 +169,17 @@ type DecompressReq struct { |
168 | 169 | PutIntoNewDir bool `json:"put_into_new_dir"` |
169 | 170 | SrcDir string `json:"src_dir"` |
170 | 171 | } |
| 172 | + |
| 173 | +type IntSlice []int |
| 174 | + |
| 175 | +func (s *IntSlice) UnmarshalJSON(data []byte) error { |
| 176 | + if len(data) > 0 && data[0] == '[' { |
| 177 | + return json.Unmarshal(data, (*[]int)(s)) |
| 178 | + } |
| 179 | + var single int |
| 180 | + if err := json.Unmarshal(data, &single); err != nil { |
| 181 | + return err |
| 182 | + } |
| 183 | + *s = []int{single} |
| 184 | + return nil |
| 185 | +} |
0 commit comments