From a6c260096a31fd2c70f7cbe54cf83fe13bdc75f7 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 26 Sep 2018 11:04:06 +0800 Subject: [PATCH 1/2] add page obj --- router/api/api.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/router/api/api.go b/router/api/api.go index 605f228..693295e 100644 --- a/router/api/api.go +++ b/router/api/api.go @@ -147,5 +147,9 @@ func GetLineMessageLog(c *context.Context) { c.Success(map[string]interface{}{ "list": resMap, + "page": map[string]interface{}{ + "cur": page.Page, + "total": page.Total, + }, }) } From a3534d7b0472e3a95546da106533ce898694a03b Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 26 Sep 2018 16:17:54 +0800 Subject: [PATCH 2/2] modify --- model/line_group.go | 12 +++++++++--- model/line_user.go | 8 +++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/model/line_group.go b/model/line_group.go index cc8a577..28666c4 100644 --- a/model/line_group.go +++ b/model/line_group.go @@ -1,6 +1,9 @@ package model -import "time" +import ( + "database/sql" + "time" +) // LineGroup - struct type LineGroup struct { @@ -42,6 +45,9 @@ func CheckGroupOwner(user, g string) (exists bool, err error) { func GetLineGroup(id string) (g *LineGroup, err error) { g = &LineGroup{} err = x.Get(g, `select * from "public"."line_group" where "id" = $1`, id) + if err == sql.ErrNoRows { + return nil, nil + } return } @@ -49,8 +55,8 @@ func GetLineGroup(id string) (g *LineGroup, err error) { func AddLineGroup(name, owner string, notify bool) (g *LineGroup, err error) { g = &LineGroup{} err = x.Get(g, `insert into "public"."line_group" ("name", "owner", "notify") values ($1, $2, $3)`, name, owner, notify) - if err != nil { - return nil, err + if err == sql.ErrNoRows { + return nil, nil } return } diff --git a/model/line_user.go b/model/line_user.go index 36dba05..fef4700 100644 --- a/model/line_user.go +++ b/model/line_user.go @@ -1,6 +1,9 @@ package model -import "time" +import ( + "database/sql" + "time" +) // LineUser - type LineUser struct { @@ -14,6 +17,9 @@ type LineUser struct { func GetLineUserByID(id string) (u *LineUser, err error) { u = &LineUser{} err = x.Get(u, `select * from "public"."line_user" where "id" = $1`, id) + if err == sql.ErrNoRows { + return nil, nil + } return }