This commit is contained in:
Jay 2018-09-27 21:43:14 +08:00
commit 28923b4571
3 changed files with 20 additions and 4 deletions

View File

@ -1,6 +1,9 @@
package model package model
import "time" import (
"database/sql"
"time"
)
// LineGroup - struct // LineGroup - struct
type 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) { func GetLineGroup(id string) (g *LineGroup, err error) {
g = &LineGroup{} g = &LineGroup{}
err = x.Get(g, `select * from "public"."line_group" where "id" = $1`, id) err = x.Get(g, `select * from "public"."line_group" where "id" = $1`, id)
if err == sql.ErrNoRows {
return nil, nil
}
return return
} }
@ -49,8 +55,8 @@ func GetLineGroup(id string) (g *LineGroup, err error) {
func AddLineGroup(name, owner string, notify bool) (g *LineGroup, err error) { func AddLineGroup(name, owner string, notify bool) (g *LineGroup, err error) {
g = &LineGroup{} g = &LineGroup{}
err = x.Get(g, `insert into "public"."line_group" ("name", "owner", "notify") values ($1, $2, $3)`, name, owner, notify) err = x.Get(g, `insert into "public"."line_group" ("name", "owner", "notify") values ($1, $2, $3)`, name, owner, notify)
if err != nil { if err == sql.ErrNoRows {
return nil, err return nil, nil
} }
return return
} }

View File

@ -1,6 +1,9 @@
package model package model
import "time" import (
"database/sql"
"time"
)
// LineUser - // LineUser -
type LineUser struct { type LineUser struct {
@ -14,6 +17,9 @@ type LineUser struct {
func GetLineUserByID(id string) (u *LineUser, err error) { func GetLineUserByID(id string) (u *LineUser, err error) {
u = &LineUser{} u = &LineUser{}
err = x.Get(u, `select * from "public"."line_user" where "id" = $1`, id) err = x.Get(u, `select * from "public"."line_user" where "id" = $1`, id)
if err == sql.ErrNoRows {
return nil, nil
}
return return
} }

View File

@ -147,5 +147,9 @@ func GetLineMessageLog(c *context.Context) {
c.Success(map[string]interface{}{ c.Success(map[string]interface{}{
"list": resMap, "list": resMap,
"page": map[string]interface{}{
"cur": page.Page,
"total": page.Total,
},
}) })
} }