add facebook page api

This commit is contained in:
Jay
2018-09-21 21:37:33 +08:00
parent cd877b21e3
commit 8504a8c708
9 changed files with 271 additions and 6 deletions
+1
View File
@@ -14,6 +14,7 @@ import (
type Config struct {
Port int `yaml:"port"`
URL string `yaml:"url"`
SelfKey string `yaml:"self_key"`
ImageRoot string `yaml:"image_root"`
Line struct {
Secret string `yaml:"secret"`
+6
View File
@@ -53,6 +53,12 @@ func (c *Context) DataFormat(msg interface{}) {
c.AbortWithStatusJSON(obj.Status, obj.Obj)
}
// Forbidden -
func (c *Context) Forbidden(msg interface{}) {
obj := apimsg.GetRes("Forbidden", msg)
c.AbortWithStatusJSON(obj.Status, obj.Obj)
}
// Success -
func (c *Context) Success(msg interface{}) {
obj := apimsg.GetRes("Success", msg)
-4
View File
@@ -86,10 +86,6 @@ func JoinChannel(ch string) {
return
}
if indexOf(channels, ch) != -1 {
return
}
m := &MsgObj{
Command: "JOIN",
Params: []string{
+43
View File
@@ -1,6 +1,7 @@
package utils
import (
"math"
"os"
"path"
"reflect"
@@ -9,6 +10,48 @@ import (
"strings"
)
// PageObject -
type PageObject struct {
Page int `json:"page" cc:"page"`
Total int `json:"total" cc:"total"`
Offset int `json:"offset" cc:"offset"`
Limit int `json:"limit" cc:"limit"`
}
// CalcPage -
func CalcPage(count, page, max int) (po PageObject) {
if count < 0 {
count = 0
}
if page < 1 {
page = 1
}
if max < 1 {
max = 1
}
total := int(math.Ceil(float64(count) / float64(max)))
if total < 1 {
total = 1
}
if page > total {
page = total
}
offset := (page - 1) * max
if offset > count {
offset = count
}
limit := max
po = PageObject{}
po.Limit = limit
po.Page = page
po.Offset = offset
po.Total = total
return
}
// ToMap struct to map[string]interface{}
func ToMap(ss interface{}) map[string]interface{} {
t := reflect.ValueOf(ss)