From e4d767373af2500cf3da8711bb528cc771c92418 Mon Sep 17 00:00:00 2001 From: Jay Date: Mon, 16 Sep 2019 13:15:15 +0000 Subject: [PATCH] update , refactory model --- models/public/instagram.go | 15 +++++++++++++++ route/private/private.go | 27 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/models/public/instagram.go b/models/public/instagram.go index 28c46de..1e44d99 100644 --- a/models/public/instagram.go +++ b/models/public/instagram.go @@ -86,6 +86,21 @@ func GetInstagramByID(id string) (ig *InstagramModel, err error) { return } +// GetAllInstagram - +func GetAllInstagram() (list []Instagram, err error) { + db := models.GetConn() + query := ` + select id, lastpost, ctime, mtime + from "public"."instagram" + order by ctime + ` + err = db.Select(&list, query) + if err != nil { + return nil, err + } + return list, nil +} + // GetInstagramByChannelAndID - func GetInstagramByChannelAndID(id, channel string) (ig *InstagramModel, err error) { if len(channel) == 0 || len(id) == 0 { diff --git a/route/private/private.go b/route/private/private.go index 26eeea6..90df0d4 100644 --- a/route/private/private.go +++ b/route/private/private.go @@ -37,3 +37,30 @@ func GetFacebookIDs(c *context.Context) { c.Success(map[string]interface{}{"list": ids}) } + +// UpdateFacebookPost - +func UpdateFacebookPost(c *context.Context) { + var err error + type pageStruct struct { + ID string `json:"id"` + PostID string `json:"post_id"` + Link string `json:"link"` + Text string `json:"text"` + } + + bodyArg := struct { + Pages []pageStruct `json:"pages"` + }{} + + err = c.BindData(&bodyArg) + if err != nil { + c.DataFormat() + return + } + + for _, v := range bodyArg.Pages { + if len(v.ID) == 0 || len(v.PostID) == 0 { + continue + } + } +}