This commit is contained in:
2023-07-18 08:21:23 +08:00
parent cfa3224302
commit eca23bce6f

View File

@@ -20,6 +20,7 @@ type Account struct {
LikeList interface{} `json:"likes" gorm:"-"` LikeList interface{} `json:"likes" gorm:"-"`
} }
// 将字符串数组转换为整数数组
func toInt(list []string) (result []int) { func toInt(list []string) (result []int) {
for _, v := range list { for _, v := range list {
i, err := strconv.Atoi(v) i, err := strconv.Atoi(v)
@@ -29,9 +30,14 @@ func toInt(list []string) (result []int) {
} }
result = append(result, i) result = append(result, i)
} }
// 如果沒有喜歡的圖片, 則返回空數組
if len(result) == 0 {
result = []int{}
}
return return
} }
// 獲取當前賬戶的喜歡列表
func (account *Account) ReadLikeList() { func (account *Account) ReadLikeList() {
log.Println("ReadLikeList: account.ID = ", account.ID) log.Println("ReadLikeList: account.ID = ", account.ID)
is, err := LikeImage.GetA(fmt.Sprintf("%d", 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)) { func AccountRead(w http.ResponseWriter, r *http.Request, cb func(account *Account)) {
// 獲取Cookie // 獲取Cookie