From eca23bce6ff74a4168c0a5393a6ef1adfe356ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=9C=E8=8F=AF?= Date: Tue, 18 Jul 2023 08:21:23 +0800 Subject: [PATCH] DEBUG --- models/account.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/models/account.go b/models/account.go index 9f4e8fd..8d4cb6f 100644 --- a/models/account.go +++ b/models/account.go @@ -20,6 +20,7 @@ type Account struct { LikeList interface{} `json:"likes" gorm:"-"` } +// 将字符串数组转换为整数数组 func toInt(list []string) (result []int) { for _, v := range list { i, err := strconv.Atoi(v) @@ -29,9 +30,14 @@ func toInt(list []string) (result []int) { } result = append(result, i) } + // 如果沒有喜歡的圖片, 則返回空數組 + if len(result) == 0 { + result = []int{} + } return } +// 獲取當前賬戶的喜歡列表 func (account *Account) ReadLikeList() { log.Println("ReadLikeList: account.ID = ", account.ID) is, err := LikeImage.GetA(fmt.Sprintf("%d", account.ID)) @@ -50,6 +56,7 @@ func (account *Account) ReadLikeList() { } } +// 獲取當前賬戶信息 func AccountRead(w http.ResponseWriter, r *http.Request, cb func(account *Account)) { // 獲取Cookie