ID转换为int
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"main/configs"
|
"main/configs"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,20 +20,33 @@ type Account struct {
|
|||||||
LikeList interface{} `json:"likes" gorm:"-"`
|
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() {
|
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 {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ms, err := LikeModel.GetA(string(rune(account.ID)))
|
ms, err := LikeModel.GetA(fmt.Sprintf("%d", account.ID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
account.LikeList = map[string]interface{}{
|
account.LikeList = map[string]interface{}{
|
||||||
"images": is,
|
"images": toInt(is),
|
||||||
"models": ms,
|
"models": toInt(ms),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user