like list
This commit is contained in:
		@@ -1,19 +1,38 @@
 | 
			
		||||
package models
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"log"
 | 
			
		||||
	"main/configs"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Account struct {
 | 
			
		||||
	ID        int       `json:"id"`
 | 
			
		||||
	Name      string    `json:"name"`
 | 
			
		||||
	Email     string    `json:"email"`
 | 
			
		||||
	Admin     bool      `json:"admin"`
 | 
			
		||||
	SessionID string    `json:"session_id"`
 | 
			
		||||
	CreatedAt time.Time `json:"created_at"`
 | 
			
		||||
	UpdatedAt time.Time `json:"updated_at"`
 | 
			
		||||
	ID        int         `json:"id"`
 | 
			
		||||
	Name      string      `json:"name"`
 | 
			
		||||
	Email     string      `json:"email"`
 | 
			
		||||
	Admin     bool        `json:"admin"`
 | 
			
		||||
	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)) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user