From cfa322430269140b836fa9ac5392a2d6abd257b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=9C=E8=8F=AF?= Date: Tue, 18 Jul 2023 08:19:48 +0800 Subject: [PATCH] =?UTF-8?q?ID=E8=BD=AC=E6=8D=A2=E4=B8=BAint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/account.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/models/account.go b/models/account.go index dc67efd..9f4e8fd 100644 --- a/models/account.go +++ b/models/account.go @@ -1,9 +1,11 @@ package models import ( + "fmt" "log" "main/configs" "net/http" + "strconv" "time" ) @@ -18,20 +20,33 @@ type Account struct { LikeList interface{} `json:"likes" gorm:"-"` } +func toInt(list []string) (result []int) { + for _, v := range list { + i, err := strconv.Atoi(v) + if err != nil { + log.Println(err) + continue + } + result = append(result, i) + } + return +} + func (account *Account) ReadLikeList() { - is, err := LikeImage.GetA(string(rune(account.ID))) + log.Println("ReadLikeList: account.ID = ", account.ID) + is, err := LikeImage.GetA(fmt.Sprintf("%d", account.ID)) if err != nil { log.Println(err) return } - ms, err := LikeModel.GetA(string(rune(account.ID))) + ms, err := LikeModel.GetA(fmt.Sprintf("%d", account.ID)) if err != nil { log.Println(err) return } account.LikeList = map[string]interface{}{ - "images": is, - "models": ms, + "images": toInt(is), + "models": toInt(ms), } }