like list
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"log"
|
||||
"main/configs"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -14,6 +15,24 @@ type Account struct {
|
||||
SessionID string `json:"session_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
LikeList interface{} `json:"likes" gorm:"-"`
|
||||
}
|
||||
|
||||
func (account *Account) ReadLikeList() {
|
||||
is, err := LikeImage.GetA(string(rune(account.ID)))
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
ms, err := LikeModel.GetA(string(rune(account.ID)))
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
account.LikeList = map[string]interface{}{
|
||||
"images": is,
|
||||
"models": ms,
|
||||
}
|
||||
}
|
||||
|
||||
func AccountRead(w http.ResponseWriter, r *http.Request, cb func(account *Account)) {
|
||||
|
@@ -9,6 +9,7 @@ import (
|
||||
// 獲取當前賬戶信息(重寫, 爲輸出增加sid字段)
|
||||
func AccountGet(w http.ResponseWriter, r *http.Request) {
|
||||
models.AccountRead(w, r, func(account *models.Account) {
|
||||
account.ReadLikeList()
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
w.Write(utils.ToJSON(account))
|
||||
})
|
||||
|
Reference in New Issue
Block a user