components

package
v1.6.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CACHE_FILE = 1 + iota
	CACHE_MEM
)
View Source
const (
	TCPStatusNone = iota
	TCPStatusConnected
	TCPStatusDisconnected
)

TCP状态常量

View Source
const (
	TCPEventConnected = iota
	TCPEventDisconnected
	TCPEventRecv
	TCPEventWritten
	TCPEventError
)

TCP事件常量

View Source
const TreeLimit = 2

Variables

View Source
var CKRedisPool *redis.Pool
View Source
var ImageMime = map[string]string{
	"image/jpeg": "jpg",
	"image/jpg":  "jpg",
	"image/png":  "png",
}

Functions

func CallAction

func CallAction(i interface{}, c *gin.Context)

调用Controller 的 Action 方法

func CallActionGet

func CallActionGet(i interface{}, c *gin.Context)

调用Controller 的 Action 方法 GET

func Cross

func Cross(c *gin.Context, is_cross bool, org string)

是否可以跨域调用

func Display

func Display(c *gin.Context, html []byte)

显示HTML数据

func GetActiveCount added in v1.0.6

func GetActiveCount() int

func GetIdleCount added in v1.0.6

func GetIdleCount() int

func GetProperty

func GetProperty(c *gin.Context) []byte

得到POST原始数据

func InitPprof

func InitPprof(server *gin.Engine)

func InitRedisPool

func InitRedisPool(cfg *RedisConfig)

func Merge added in v1.6.3

func Merge[T any](s ...[]T) (slice []T)

func ReplaceInterface added in v1.5.1

func ReplaceInterface[T any](anyList []T) []interface{}

Types

type BTreePlus added in v1.6.3

type BTreePlus struct {
	// contains filtered or unexported fields
}

b+tree

func NewBTreePlus added in v1.6.3

func NewBTreePlus(limit int) *BTreePlus

func (*BTreePlus) Insert added in v1.6.3

func (b *BTreePlus) Insert(key int, data interface{})

func (*BTreePlus) Print added in v1.6.3

func (b *BTreePlus) Print()

func (*BTreePlus) Remove added in v1.6.3

func (b *BTreePlus) Remove(key int)

func (*BTreePlus) Search added in v1.6.3

func (b *BTreePlus) Search(key int) (interface{}, error)

type CKRedis

type CKRedis struct {
	// contains filtered or unexported fields
}

func NewCKRedis

func NewCKRedis() (*CKRedis, error)

初始一个消息队列

func (*CKRedis) Close

func (m *CKRedis) Close()

关闭连接

func (*CKRedis) Count

func (m *CKRedis) Count() (int, error)

得到队列消息数

func (*CKRedis) Do

func (m *CKRedis) Do(command string, args ...interface{}) (interface{}, error)

执行命令

func (*CKRedis) Exists

func (m *CKRedis) Exists(key string) bool

是否存在一个缓存值

func (*CKRedis) GAdd

func (m *CKRedis) GAdd(key string, lon string, lat string, member string) (bool, error)

添加一个坐标到 GEOHASH

func (*CKRedis) GDist

func (m *CKRedis) GDist(key string, member string, member2 string) (int, error)

计算两个位置的距离,返回米

func (*CKRedis) GPos

func (m *CKRedis) GPos(key string, member string) ([]interface{}, error)

得到一个member 的坐标

func (*CKRedis) GRadius

func (m *CKRedis) GRadius(key string, lon string, lat string, radius int) ([]*RedisGeo, error)

得到传入坐标半径的所有所坐标

func (*CKRedis) Get

func (m *CKRedis) Get(key string) (interface{}, error)

得到一个缓存值

func (*CKRedis) HDel

func (m *CKRedis) HDel(key, field string) (bool, error)

删除一个 hash 值

func (*CKRedis) HExists

func (m *CKRedis) HExists(key, field string) (bool, error)

检查是否存在一个HASH值

func (*CKRedis) HGet

func (m *CKRedis) HGet(key, field string) (interface{}, error)

得到一个HASH值

func (*CKRedis) HKeys

func (m *CKRedis) HKeys(key string) ([]interface{}, error)

得到所有 hash 键

func (*CKRedis) HLen

func (m *CKRedis) HLen(key string) (int, error)

得到 hash 长度

func (*CKRedis) HMGet

func (m *CKRedis) HMGet(key string, field ...interface{}) ([]interface{}, error)

得到多个HASH 值

func (*CKRedis) HSet

func (m *CKRedis) HSet(key, field string, val interface{}) (bool, error)

--- HASH --- 设置一个HASH值

func (*CKRedis) Key added in v1.1.9

func (m *CKRedis) Key(key string) string

得到有前缀的key

func (*CKRedis) Keys

func (m *CKRedis) Keys(perm string) ([]string, error)

得到KEYS

func (*CKRedis) LLen

func (m *CKRedis) LLen(key string) (int, error)

得到LIST长度

func (*CKRedis) LPush

func (m *CKRedis) LPush(key string, value string) (int, error)

--- LIST 列表 --- 插入一条记录,或多条记录

func (*CKRedis) LRange

func (m *CKRedis) LRange(key string, start int, stop int) ([]interface{}, error)

得到一个区间的LIST值列表

func (*CKRedis) LSet

func (m *CKRedis) LSet(key string, index int, value string) (int, error)

更新一个下标值

func (*CKRedis) Lock

func (m *CKRedis) Lock()

func (*CKRedis) Push

func (m *CKRedis) Push(msg string) error

PUSH 消息到队列

func (*CKRedis) RPop

func (m *CKRedis) RPop(key string) (string, error)

删除列表尾记录并返回

func (*CKRedis) Receive

func (m *CKRedis) Receive() (string, error)

接收队列消息

func (*CKRedis) Remove

func (m *CKRedis) Remove(key ...string) error

删除一个缓存值

func (*CKRedis) SAdd added in v1.3.3

func (m *CKRedis) SAdd(key string, member ...interface{}) (int, error)

--- SET 集合 --- 添加一个或多个成员到集合

func (*CKRedis) SCard added in v1.3.3

func (m *CKRedis) SCard(key string) (int, error)

获取集合的成员数

func (*CKRedis) SIsMember added in v1.3.3

func (m *CKRedis) SIsMember(key string, member string) (bool, error)

查找是否存在成员

func (*CKRedis) SMembers added in v1.3.3

func (m *CKRedis) SMembers(key string) ([]interface{}, error)

返回所有成员

func (*CKRedis) SPop added in v1.3.3

func (m *CKRedis) SPop(key string) ([]byte, error)

移除并返回集合中的一个随机元素

func (*CKRedis) SRem added in v1.3.3

func (m *CKRedis) SRem(key string, member ...interface{}) (bool, error)

删除一个或多个成员

func (*CKRedis) SScan added in v1.3.3

func (m *CKRedis) SScan(key string, cursor int, match string, count int) (*ScanList, error)

扫描集合

func (*CKRedis) SUnionStore added in v1.3.4

func (m *CKRedis) SUnionStore(keys ...interface{}) (int, error)

复制并集

func (*CKRedis) Set

func (m *CKRedis) Set(key string, val interface{}, exp int) error

设置一个缓存值

func (*CKRedis) SetDB

func (m *CKRedis) SetDB(db_idx int)

设置当前操作的数据ID

func (*CKRedis) SetMessageQueueName

func (m *CKRedis) SetMessageQueueName(name string)

设置当前操作的消息队列名称

func (*CKRedis) SetPrefix added in v1.1.9

func (m *CKRedis) SetPrefix(prefix string)

设置前缀

func (*CKRedis) ZAdd

func (m *CKRedis) ZAdd(key string, score int, member string) (bool, error)

添加一个member有序集合

func (*CKRedis) ZCard

func (m *CKRedis) ZCard(key string) (int, error)

返回有序集合的基数

func (*CKRedis) ZCount

func (m *CKRedis) ZCount(key string, min string, max string) (int, error)

返回指定score 大小之间的成员数量

func (*CKRedis) ZRangeByScore

func (m *CKRedis) ZRangeByScore(key string, min string, max string, with_score bool) ([]string, error)

返回指定 score 大小之间的成员列表

func (*CKRedis) ZRem

func (m *CKRedis) ZRem(key, member string) (bool, error)

删除有序集合里面的成员

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache(cache_type int) *Cache

func (*Cache) Delete

func (this *Cache) Delete(key string) bool

func (*Cache) Get

func (this *Cache) Get(key string) (interface{}, error)

*

  • Cache Functions

func (*Cache) Set

func (this *Cache) Set(key string, v interface{}, expire int64) bool

type CacheData

type CacheData struct {
	Expire  int64  `json:"expire"`
	Content string `json:"content"`
}

type CacheIn

type CacheIn interface {
	Get(key string) (interface{}, error)
	Set(key string, value interface{}, expire int64) bool
	Delete(key string) bool
}

type ConnEvent

type ConnEvent struct {
	EventType int
	Conn      *Connection
	Data      []byte
}

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(c net.Conn, sendBufferSize int, eq IEventQueue) *Connection

func (*Connection) Close

func (this *Connection) Close()

func (*Connection) GetConnId

func (this *Connection) GetConnId() int

func (*Connection) GetReadTimeoutSec

func (this *Connection) GetReadTimeoutSec() int

func (*Connection) GetStatus

func (this *Connection) GetStatus() int

func (*Connection) GetUserdata

func (this *Connection) GetUserdata() interface{}

func (*Connection) Send

func (this *Connection) Send(msg []byte, cpy bool)

func (*Connection) SetConnId

func (this *Connection) SetConnId(id int)

func (*Connection) SetReadTimeoutSec

func (this *Connection) SetReadTimeoutSec(sec int)

func (*Connection) SetUserdata

func (this *Connection) SetUserdata(ud interface{})

type FileCache

type FileCache struct {
	CacheIn
	// contains filtered or unexported fields
}

func (*FileCache) Delete

func (this *FileCache) Delete(key string) bool

func (*FileCache) Get

func (this *FileCache) Get(key string) (interface{}, error)

*

  • FileCache Functions

func (*FileCache) GetName

func (this *FileCache) GetName(key string) string

func (*FileCache) Set

func (this *FileCache) Set(key string, v interface{}, expire int64) bool

type GoroutinePool

type GoroutinePool struct {
	Queue  chan interface{} //队列池
	Number int              //并发协程数
	Total  int              //处理数据量
	Worker func(obj ...interface{}) bool
	// contains filtered or unexported fields
}

协程池

func NewPoll

func NewPoll(number int, worker func(obj ...interface{}) bool) *GoroutinePool

新建一个协程池

func NewPool added in v1.5.1

func NewPool(number int, worker func(obj ...interface{}) bool) *GoroutinePool

NewPool 新建一个协程池

func (*GoroutinePool) AddTask

func (g *GoroutinePool) AddTask(task interface{})

func (*GoroutinePool) AddTaskInterface

func (g *GoroutinePool) AddTaskInterface(tasks []interface{})

func (*GoroutinePool) AddTaskStrings

func (g *GoroutinePool) AddTaskStrings(tasks []string)

func (*GoroutinePool) SetFinishCallback

func (g *GoroutinePool) SetFinishCallback(callback func())

func (*GoroutinePool) Start

func (g *GoroutinePool) Start()

func (*GoroutinePool) Stop

func (g *GoroutinePool) Stop()

type IEventHandler

type IEventHandler interface {
	OnConnected(evt *ConnEvent)
	OnDisconnected(evt *ConnEvent)
	OnRecv(evt *ConnEvent)
}

type IEventQueue

type IEventQueue interface {
	Push(*ConnEvent)
	Pop() *ConnEvent
}

type IEventTCP

type IEventTCP interface {
	OnConnected(evt *TCPConnEvent)
	OnDisconnected(evt *TCPConnEvent)
	OnRecv(evt *TCPConnEvent)
	OnWritten(evt *TCPConnEvent)
	OnError(evt *TCPConnEvent)
}

type IStreamProtocol

type IStreamProtocol interface {
	//  Init
	Init()
	//  get the header length of the stream
	GetHeaderLength() int
	//  read the header length of the stream
	UnserializeHeader([]byte) int
	//  format header
	SerializeHeader([]byte) []byte
}

type KeysData added in v1.6.3

type KeysData [][]byte

func (*KeysData) Insert added in v1.6.3

func (a *KeysData) Insert(index int, val ...[]byte)

func (KeysData) Len added in v1.6.3

func (a KeysData) Len() int

func (KeysData) Less added in v1.6.3

func (a KeysData) Less(i, j int) bool

func (*KeysData) Pop added in v1.6.3

func (a *KeysData) Pop() []byte

func (*KeysData) Push added in v1.6.3

func (a *KeysData) Push(val ...[]byte)

func (KeysData) Swap added in v1.6.3

func (a KeysData) Swap(i, j int)

type KeysInt added in v1.6.3

type KeysInt []int

func (*KeysInt) Insert added in v1.6.3

func (a *KeysInt) Insert(index int, val ...int)

func (KeysInt) Len added in v1.6.3

func (a KeysInt) Len() int

func (KeysInt) Less added in v1.6.3

func (a KeysInt) Less(i, j int) bool

func (*KeysInt) Pop added in v1.6.3

func (a *KeysInt) Pop() int

func (*KeysInt) Push added in v1.6.3

func (a *KeysInt) Push(val ...int)

func (KeysInt) Swap added in v1.6.3

func (a KeysInt) Swap(i, j int)

type MediaData

type MediaData struct {
	FileType string
	FileName string
	Content  []byte
}

type MemCache

type MemCache struct {
	CacheIn
	// contains filtered or unexported fields
}

GO本地内存数据缓存

func NewMemCache

func NewMemCache() *MemCache

新创建一个内存缓存

func (*MemCache) Delete

func (m *MemCache) Delete(key string) bool

删除缓存

func (*MemCache) Dump

func (m *MemCache) Dump()

func (*MemCache) Get

func (m *MemCache) Get(key string) (interface{}, error)

*

  • MemCache Functions

func (*MemCache) Keys added in v1.3.2

func (m *MemCache) Keys(pattern string) ([]string, error)

得到所有key值,按指定条件 * 为得到所有

func (*MemCache) LoadLocal added in v1.6.7

func (m *MemCache) LoadLocal(name string) error

加载本地缓存数据

func (*MemCache) Set

func (m *MemCache) Set(key string, v interface{}, expire int64) bool

设置数据

func (*MemCache) Stat

func (m *MemCache) Stat()

func (*MemCache) StopStore added in v1.6.7

func (m *MemCache) StopStore()

func (*MemCache) Store added in v1.6.7

func (m *MemCache) Store() error

type MemCacheData

type MemCacheData struct {
	Data   interface{}
	Expire int64
}

func (*MemCacheData) IsExpire

func (mc *MemCacheData) IsExpire() bool

数据是否过期

type Nodes added in v1.6.3

type Nodes []*TreeNode

func (*Nodes) Insert added in v1.6.3

func (a *Nodes) Insert(index int, val ...*TreeNode)

func (Nodes) Len added in v1.6.3

func (a Nodes) Len() int

func (*Nodes) Pop added in v1.6.3

func (a *Nodes) Pop() *TreeNode

func (*Nodes) Push added in v1.6.3

func (a *Nodes) Push(val ...*TreeNode)

func (a Nodes) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a Nodes) Less(i, j int) bool { return a[i].Data < a[j].Data }

type RedisConfig

type RedisConfig struct {
	RDServer   string `json:"rd_server" yaml:"rd_server"`
	RDPort     string `json:"rd_port" yaml:"rd_port"`
	RDDb       int    `json:"rd_db" yaml:"rd_db"`
	RDPassword string `json:"rd_password" yaml:"rd_password"`
	RDListName string `json:"rd_list_name" yaml:"rd_list_name"`
	RDPoolSize int    `json:"rd_pool_size" yaml:"rd_pool_size"`
	RDIdleSize int    `json:"rd_idle_size" yaml:"rd_idle_size"`
}

redis 配置

type RedisGeo

type RedisGeo struct {
	Member string  `json:"member"`
	Lon    float64 `json:"lon"`
	Lat    float64 `json:"lat"`
	Dist   float64 `json:"dist"`
}

GEO地理位置

type ScanList added in v1.3.3

type ScanList struct {
	Cursor  int      `json:"cursor"`
	Members []string `json:"members"`
}

扫描返回的集合数据

type SysLog

type SysLog struct {
	Prefix string
}

func NewSysLog

func NewSysLog(prefix string) *SysLog

func (*SysLog) Error

func (l *SysLog) Error(err interface{})

记录错误

func (*SysLog) Info

func (l *SysLog) Info(msg string)

func (*SysLog) PrintError added in v1.1.7

func (l *SysLog) PrintError(err interface{})

func (*SysLog) Write

func (l *SysLog) Write(p []byte) (n int, err error)

func (*SysLog) WriteFile

func (l *SysLog) WriteFile(filename string, data []byte, perm os.FileMode) error

type TCPConnEvent

type TCPConnEvent struct {
	EventType int
	Conn      *TCPConnect
	Data      interface{}
}

事件类型结构数据

type TCPConnect

type TCPConnect struct {
	// contains filtered or unexported fields
}

TCP连接

func NewTCPConnect

func NewTCPConnect(c net.Conn, evt IEventTCP) *TCPConnect

新建TCP服务连接

func (*TCPConnect) Close

func (tp *TCPConnect) Close()

关闭连接

func (*TCPConnect) RemoteAddr added in v1.4.2

func (tp *TCPConnect) RemoteAddr() string

func (*TCPConnect) Run

func (tp *TCPConnect) Run()

运行

func (*TCPConnect) SetDebug

func (tp *TCPConnect) SetDebug(yes bool)

设置DEBUG状态

func (*TCPConnect) SetReadTimeout

func (tp *TCPConnect) SetReadTimeout(step time.Duration)

设置读取超时

func (*TCPConnect) SetWriteTimeout added in v1.4.2

func (tp *TCPConnect) SetWriteTimeout(step time.Duration)

设置写入超时时间

func (*TCPConnect) Status

func (tp *TCPConnect) Status() int

得到当前TCP状态

func (*TCPConnect) WriteData

func (tp *TCPConnect) WriteData(data []byte)

写入数据到TCP

type TagList added in v1.2.5

type TagList struct {
	Tags []*UserTag `json:"tags"`
}

type Template

type Template struct {
	// contains filtered or unexported fields
}

func NewTemplate

func NewTemplate(tempDir string) *Template

func (*Template) Assign

func (t *Template) Assign(key string, val interface{})

设置模板变量

func (*Template) Display

func (t *Template) Display(resp http.ResponseWriter, html []byte)

向浏览器输出内容

func (*Template) Parse

func (t *Template) Parse(tempName string) (string, error)

编辑输出模块内容

type TemplateCon

type TemplateCon struct {
	Content []byte
	ModTime int64
}

type TreeNode added in v1.6.3

type TreeNode struct {
	KeyNum      int         //存放KEY数量
	Key         KeysInt     //实际数据
	Parent      *TreeNode   //父节点
	ParentIndex int         //父节点位置
	Next        *TreeNode   //相连兄弟节点
	Child       Nodes       //儿子节点
	IsLeaf      bool        //是否叶子节点
	Data        interface{} //数据
	// contains filtered or unexported fields
}

func NewTreeNode added in v1.6.3

func NewTreeNode(nodeLimit int) *TreeNode

func (*TreeNode) ChangeParentIndex added in v1.6.3

func (t *TreeNode) ChangeParentIndex()

改变父节点索引值

func (*TreeNode) GetBytes added in v1.6.3

func (t *TreeNode) GetBytes() ([]byte, error)

func (*TreeNode) GetLeftNode added in v1.6.3

func (t *TreeNode) GetLeftNode() (key int, node *TreeNode)

得到最左节点

func (*TreeNode) GetRightNode added in v1.6.3

func (t *TreeNode) GetRightNode() (key int, node *TreeNode)

得到最右节点

func (*TreeNode) Insert added in v1.6.3

func (t *TreeNode) Insert(key int, data interface{}, node *TreeNode)

插入一个键值

func (t *TreeNode) Insert(key int, data interface{}, node *TreeNode) {
	//未满状态
	//没有值的时候直接插入
	if t.KeyNum == 0 {
		if node == nil {
			node = NewTreeNode()
			node.Data = data
		}
		t.insert(key, node, 0)
		t.ChangeParentIndex()
		return
	}

	i := 0
	for i < TreeLimit {
		//没有值的时候直接插入
		if i >= t.KeyNum {
			//如果当前节点不是叶子节点,并且位置大于0
			if i > 0 && !t.IsLeaf && node == nil {
				t.Child[i-1].Insert(key, data, node)
				return
			}
			if node == nil {
				node = NewTreeNode()
				node.Data = data
			}
			t.insert(key, node, i)
			t.ChangeParentIndex()
			return
		}
		//KEY值相等就把数据插入到相等KEY的数据里
		if key == t.Key[i] {
			if !t.IsLeaf {
				t.Child[i].Insert(key, data, nil)
				return
			}
			t.Child[i].SetValue(data)
			return
		}
		//KEY值小于一个节点内的值
		if key < t.Key[i] {
			if !t.IsLeaf && node == nil {
				t.Child[i].Insert(key, data, nil)
				return
			}
			if node == nil {
				node = NewTreeNode()
				node.Data = data
			}
			kickKey, kickNode := t.insert(key, node, i)
			t.ChangeParentIndex()
			//如果要分裂新兄弟节点
			if kickNode != nil {
				siblingNode := t.Next
				if siblingNode != nil {
					t.Next.Insert(kickKey, kickNode.Data, nil)
					return
				}
				t.SplitNode(kickKey, kickNode.Data, kickNode)
				return
			}

			return
		}
		i++
	}
	//如果没有找到小于的值,就插入到最后一个子节点里面
	if t.IsLeaf || node != nil {
		t.SplitNode(key, data, node)
		return
	}
	t.Child[i-1].Insert(key, data, node)
	return
}

func (*TreeNode) IsFull added in v1.6.3

func (t *TreeNode) IsFull() bool

是否满了

func (*TreeNode) SearchIndex added in v1.6.3

func (t *TreeNode) SearchIndex(idx int) (interface{}, error)

搜索索引值,得到存储的数据

func (*TreeNode) SetValue added in v1.6.3

func (t *TreeNode) SetValue(data interface{})

设置节点数据

func (*TreeNode) SplitNode added in v1.6.3

func (t *TreeNode) SplitNode(key int, data interface{}, node *TreeNode)

分裂兄弟节点

type Upload

type Upload struct {
}

func NewUpload

func NewUpload() *Upload

func (*Upload) ImageBase64

func (*Upload) ImageBase64(base64_str string) string

func (*Upload) MoveTmpToSave

func (*Upload) MoveTmpToSave(tmp_file string) string

type UserTag added in v1.2.5

type UserTag struct {
	Id    int    `json:"id"`
	Name  string `json:"name"`
	Count int    `json:"count"`
}

/微信标签管理 用户标签JSON

type Weixin

type Weixin struct {
	// contains filtered or unexported fields
}

func NewWeixin

func NewWeixin(app_id, app_secret string) *Weixin

func (*Weixin) CancelUserTag added in v1.2.4

func (w *Weixin) CancelUserTag(token string, tagId int, openIdList []string) (string, error)

批量为用户取消标签

func (*Weixin) CreateQrCode

func (w *Weixin) CreateQrCode(token, content string) (*WxQrCode, error)

创建永久二维码

func (*Weixin) CreateTag added in v1.2.4

func (w *Weixin) CreateTag(token, name string) (string, error)

创建用户标签

func (*Weixin) CreateTempQrCode

func (w *Weixin) CreateTempQrCode(token, content string, time_s int) (*WxQrCode, error)

创建临时二维码

func (*Weixin) CreateWxAppQrCode

func (w *Weixin) CreateWxAppQrCode(token, scene, page string, width int) (string, error)

创建微信小程序二维码

func (*Weixin) DeleteTag added in v1.2.4

func (w *Weixin) DeleteTag(token string, id int) (string, error)

删除标签

func (*Weixin) GetAccessToken

func (w *Weixin) GetAccessToken() (*WxAccessToken, error)

得到公众号全局 ACCESS_TOKEN

func (*Weixin) GetJsapiTicket

func (w *Weixin) GetJsapiTicket(access_token string) (*WxJsapiTicket, error)

获取JsTicket

func (*Weixin) GetMedia

func (w *Weixin) GetMedia(access_token string, media_id string) (*MediaData, error)

得到临时素材

func (*Weixin) GetTagUsers added in v1.2.4

func (w *Weixin) GetTagUsers(token string, tagId int, nextOpenid string) (string, error)

获取标签下粉丝列表

func (*Weixin) GetTags added in v1.2.4

func (w *Weixin) GetTags(token string) (*TagList, error)

获取已创建标签

func (*Weixin) GetUserAccessToken

func (w *Weixin) GetUserAccessToken(code string) (*WxUserAccessToken, error)

使用code获取用户access token

func (*Weixin) GetUserInfo

func (w *Weixin) GetUserInfo(access_token string, openid string) (*WxUserInfo, error)

拉取用户信息

func (*Weixin) GetUserInfoAccessToken

func (w *Weixin) GetUserInfoAccessToken(access_token string, openid string) (*WxUser, error)

使用用户access token 获取用户信息

func (*Weixin) GetUserTags added in v1.2.4

func (w *Weixin) GetUserTags(token, openId string) (string, error)

获取用户身上的标签列表

func (*Weixin) Http

func (w *Weixin) Http(uri string) (string, error)

发起HTTP连接

func (*Weixin) SendCustomMessage

func (w *Weixin) SendCustomMessage(token, openid, msg_type string, data utils.M) (string, error)

向用户发送客户消息

func (*Weixin) SendTemplateMessage

func (w *Weixin) SendTemplateMessage(access_token string, data utils.M) error

发送模板消息

func (*Weixin) SetUserTag added in v1.2.4

func (w *Weixin) SetUserTag(token string, tagId int, openIdList []string) (string, error)

批量为用户打标签

func (*Weixin) SignJsTicket

func (w *Weixin) SignJsTicket(data map[string]interface{}) string

进行JSTICKET签名

func (*Weixin) UpdateTag added in v1.2.4

func (w *Weixin) UpdateTag(token string, id int, name string) (string, error)

修改标签名

func (*Weixin) WebAuth

func (w *Weixin) WebAuth(redirect_uri string, mpid string, base bool) string

发起 WEB 验证受权

type WxAccessToken

type WxAccessToken struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
}

type WxError

type WxError struct {
	ErrorCode int    `json:"errcode"`
	ErrorMsg  string `json:"errmsg"`
}

type WxJsapiTicket

type WxJsapiTicket struct {
	Ticket    string `json:"ticket"`
	ExpiresIn int    `json:"expires_in"`
}

type WxQrCode

type WxQrCode struct {
	Ticket        string `json:"ticket"`
	ExpireSeconds int    `json:"expire_seconds"`
	Url           string `json:"url"`
}

微信二维码结构

type WxUser

type WxUser struct {
	NickName string `json:"nickname"`
	OpenId   string `json:"openid"`
	Sex      int    `json:"sex"`
	Province string `json:"province"`
	City     string `json:"city"`
	Country  string `json:"country"`
	HeadImg  string `json:"headimgurl"`
	UnionId  string `json:"unionid"`
}

网页受权接口获取用户数据

type WxUserAccessToken

type WxUserAccessToken struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	OpenId       string `json:"openid"`
	Scope        string `json:"scope"`
	UnionId      string `json:"unionid"`
}

用户ACCESS

type WxUserInfo

type WxUserInfo struct {
	Subscribe      int    `json:"subscribe"`
	Subscribe_time int    `json:"subscribe_time"`
	Nickname       string `json:"nickname"`
	OpenId         string `json:"openid"`
	Sex            int    `json:"sex"`
	Province       string `json:"province"`
	City           string `json:"city"`
	Country        string `json:"country"`
	HeadImg        string `json:"headimgurl"`
	Language       string `json:"language"`
	UnionId        string `json:"unionid"`
	Remark         string `json:"remark"`
	Groupid        int    `json:"groupid"`
	Tagid_list     []int  `json:"tagid_list"`
}

用公众号接口获取的用户数据

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL