Documentation ¶
Index ¶
- Constants
- Variables
- func ApiCallStatistics(w http.ResponseWriter, r *http.Request) bool
- func DelQunMember(qunUsers []QunUser) bool
- func DeleteApnsMsgById(id string) bool
- func DeleteApnsMsgByTenantId(tenantId string) bool
- func DeleteFile(fileId string) bool
- func DeleteResourceById(resourceId string) bool
- func ExistFileLink(fileLink *FileLink) bool
- func InitConfig() error
- func InitQuotaAll()
- func InitRedisStorage()
- func LoadQuotaAll()
- func RetPWrite(w http.ResponseWriter, r *http.Request, res map[string]interface{}, ...)
- func RetPWriteJSON(w http.ResponseWriter, r *http.Request, res map[string]interface{}, ...)
- func RetWrite(w http.ResponseWriter, r *http.Request, res map[string]interface{}, ...)
- func SaveFileLinK(fileLink *FileLink) bool
- func ScanExpireFileLink()
- func SessionStat(w http.ResponseWriter, r *http.Request)
- func StatisticsPush(pushCnt *PushCnt)
- func UserErWeiMa(w http.ResponseWriter, r *http.Request)
- func ValidApiCall(apiCall *ApiCall) bool
- func ValidPush(pushCnt *PushCnt) bool
- type ApiCall
- type ApnsMsg
- type ApnsToken
- type BySort
- type Client
- type ClientVerUpdateMsg
- type ClientVerUpdateObjectContent
- type ClientVersion
- type Config
- type ExternalInterface
- type FileLink
- type Name
- type PushCnt
- type Qun
- type QunUser
- type Quota
- type Resource
- type Tenant
- type UserUser
Constants ¶
View Source
const ( APICALL_EXIST = "" /* 127-byte string literal not displayed */ APICALL_ADD = "" /* 152-byte string literal not displayed */ INSERT_APICALL = "" /* 131-byte string literal not displayed */ GET_APICALL_COUNT = "select sum(count) as count from api_call WHERE customer_id = ? and tenant_id = ? and api_name = ? " GET_CUSTOMER_COUNT = "select sum(count) as count from api_call WHERE customer_id = ? and api_name = ? " SELECT_EXIST = "select id from quota where customer_id = ? and tenant_id=? and api_name=? and type = ?" SELECT_QUOTA = "" /* 135-byte string literal not displayed */ UPDATE_QUOTA = "update quota set value=? , updated =? where customer_id = ? and tenant_id=? and api_name=? and type = ?" INSERT_QUOTA = "insert into quota(id , customer_id,tenant_id,api_name,type,value,created,updated) values(?,?,?,?,?,?,?,?)" SELECT_QUOTA_ALL = "select id , customer_id,tenant_id,api_name,type,value,created,updated from quota" /*配额类型*/ EXPIRE = "expire" API_CNT = "api_cnt" )
View Source
const ( // 租户资源插入 SQL. InsertApnsMsgSQL = "" /* 135-byte string literal not displayed */ // 根据资源id 获取资源 SelectApnsMsgByIdSQL = "SELECT * FROM `apns_msg` where `id` = ?" // 根据租户 id 查询租户的资源. SelectApnsMsgByTenantIdSQL = "SELECT * FROM `apns_msg` where `tenant_id` = ?" // 根据apns_token 查询租户的资源. SelectApnsMsgByApnsTokenSQL = "SELECT * FROM `apns_msg` where `apns_token` = ?" //根据id修改资源 UpdateApnsMsgByIdSQL = "" /* 145-byte string literal not displayed */ //根据id删除资源 DelApnsMsgByIdSQL = "DELETE FROM `apns_msg` WHERE `id` =? " //根据tenant_id删除资源 DelApnsMsgByTenantIdSQL = "DELETE FROM `apns_msg` where `tenant_id` = ?" )
View Source
const ( // 根据 id 查询应用记录. SelectApplicationById = "SELECT * FROM `application` WHERE `id` = ?" // 查询应用记录. SelectAllApplication = "SELECT `id`, `name`, `name`,`status`, `sort`,`avatar`, `tenant_id`, `name_py`, `name_quanpin` FROM `application`" // 根据 token 获取应用记录. SelectApplicationByToken = "SELECT * FROM `application` WHERE `token` = ?" //根据应用ID查询应用操作项列表 SelectAppOpertionByAppId = "" /* 148-byte string literal not displayed */ //根据操作项父ID查询应用操作项列表 SelectAppOpertionByParentId = "SELECT `id`, `app_id`, `content`,`action`, `operation_type`,`sort` FROM `operation` WHERE `parent_id` = ? order by sort " )
View Source
const ( // 获取最新的客户端版本 SelectLatestClientVerByType = "SELECT * FROM `client_version` WHERE `type` = ? ORDER BY `ver_code` DESC LIMIT 1" //持久话apns_token InsertApnsToken = "INSERT INTO `apns_token`(`id`,`user_id`,`device_id`,`apns_token`,`created`,`updated`) VALUES(?,?,?,?,?,?)" SelectApnsTokenByUserId = "SELECT `id`,`user_id`,`device_id`,`apns_token`,`created`,`updated` FROM `apns_token` WHERE `user_id`=? " SelectApnsTokenByUserIdTokens = "SELECT `id`,`user_id`,`device_id`,`apns_token`,`created`,`updated` FROM `apns_token` WHERE `user_id`=? AND `apns_token`=?" DeleteApnsToken = "DELETE FROM apns_token where apns_token = ?" DeleteApnsTokenByUid = "DELETE FROM apns_token where apns_token = ? and user_id = ? " DeleteApnsTokenByDeviceId = "DELETE FROM apns_token where device_id = ?" )
View Source
const ( /*后缀信息*/ TENANT_SUFFIX = "@tenant" ORG_SUFFIX = "@org" QUN_SUFFIX = "@qun" USER_SUFFIX = "@user" APP_SUFFIX = "@app" )
View Source
const ( // 添加联系人. InsertUserUserSQL = "INSERT INTO `user_user` (`id`, `from_user_id`, `to_user_id`, `remark_name`, `sort`,`created`, `updated`) VALUES " + "(?, ?, ?, ?, ?, ?, ?)" // 删除联系人. DeleteUserUserSQL = "DELETE FROM `user_user` WHERE `from_user_id` = ? AND `to_user_id` = ?" )
View Source
const ( DEVICE_TYPE_IOS = "ios" DEVICE_TYPE_ANDROID = "android" )
View Source
const ( INSERT_FILELINK = "insert into file_link (id , sender_id,file_id ,file_name,file_url,size,created,updated) values(?,?,?,?,?,?,?,?)" UPDATE_FILELINK_TIME = "update file_link set updated =? where sender_id =? and file_id =?" EXIST_FILELINK = "select id from file_link where sender_id =? and file_id =?" SELECT_EXPIRE_FILELINK = "select id, file_id from file_link where updated < ?" )
View Source
const ( SELECT_PUSHCNT = "" /* 198-byte string literal not displayed */ INSERT_PUSHCNT = "" /* 131-byte string literal not displayed */ ADD_PUSH_COUNT = "" /* 134-byte string literal not displayed */ GET_PUSH_COUNT = "select sum(count) as count from push_cnt WHERE customer_id = ? tenantId = ?" GET_CUSTOMER_PUSH_COUNT = "select sum(count) as count from push_cnt WHERE customer_id = ? " PUSH_CNT = "push_cnt" )
View Source
const ( // 群插入 SQL. InsertQunSQL = "INSERT INTO `qun` (`id`, `creator_id`, `name`, `description`, `max_member`, `avatar`, `tenant_id`, `created`, `updated`) VALUES " + "(?, ?, ?, ?, ?, ?, ?, ?, ?)" // 群-用户关联插入 SQL. InsertQunUserSQL = "" /* 204-byte string literal not displayed */ // 根据群 id 查询群内用户. SelectQunUserSQL = "" /* 189-byte string literal not displayed */ // 根据群 id 查询群内用户 id. SelectQunUserIdSQL = "SELECT `user_id` FROM `qun_user` where `qun_id` = ?" // 根据群 id 获取群 SelectQunById = "SELECT * FROM `qun` where `id` = ?" //根据群id修改群topic UpdateQunTopicByIdSQL = "UPDATE `qun` SET `name` = ? WHERE `id` = ?" //根据群id和用户id删除群成员 DelQunMemberByQunidAndUserid = "DELETE FROM `qun_user` WHERE `qun_id` =? AND `user_id` =?" )
View Source
const ( // 租户资源插入 SQL. InsertResourceSQL = "INSERT INTO `resource` (`id`, `customer_id`, `name`, `description`, `type`, `content`, `created`, `updated`) VALUES " + "(?, ?, ?, ?, ?, ?, ?, ?)" // 根据资源id 获取资源 SelectResourceByIdSQL = "SELECT * FROM `resource` where `id` = ?" // 根据租户 id 查询租户的资源. SelectResourceByTenantIdSQL = "SELECT * FROM `resource` where `customer_id` = (select customer_id from tenant where id = ?)" //根据id修改资源 UpdateResourceByIdSQL = "" /* 150-byte string literal not displayed */ //根据id删除资源 DelResourceByIdSQL = "DELETE FROM `resource` WHERE `id` =? " )
View Source
const ( OK = 0 NotFoundServer = 1001 NotFound = 65531 TooLong = 65532 AuthErr = 65533 ParamErr = 65534 InternalErr = 65535 OverQuotaApicall = 65536 OverQuotaPush = 65537 DeleteUser = 65538 LoginErr = 65539 )
View Source
const (
APPWEB_TYPE = "appWeb"
)
Variables ¶
View Source
var App = app{}
声明应用端操作接口.
View Source
var AppWeb = appWeb{}
声明网页端操作接口.
View Source
var Device = device{}
声明移动端操作接口.
View Source
var LoadQuotaTime = time.NewTicker(5 * time.Minute)
View Source
var QuotaAll = make(map[string]Quota)
View Source
var RedisNoConnErr = errors.New("can't get a redis conn")
Functions ¶
func ApiCallStatistics ¶ added in v1.1.0
func ApiCallStatistics(w http.ResponseWriter, r *http.Request) bool
记录api调用次数
func DeleteApnsMsgById ¶
func DeleteApnsMsgByTenantId ¶
func InitRedisStorage ¶
func InitRedisStorage()
initRedisStorage initialize the redis pool and consistency hash ring.
func RetPWrite ¶
func RetPWrite(w http.ResponseWriter, r *http.Request, res map[string]interface{}, body *string, start time.Time)
retPWrite marshal the result and write to client(post).
func RetPWriteJSON ¶
func RetPWriteJSON(w http.ResponseWriter, r *http.Request, res map[string]interface{}, body *string, start time.Time)
带 Content-Type=application/json 头 写 JSON 数据,为了保持原有 gopush-cluster 的兼容性,所以新加了这个函数.
func RetWrite ¶
func RetWrite(w http.ResponseWriter, r *http.Request, res map[string]interface{}, callback string, start time.Time)
retWrite marshal the result and write to client(get).
func ScanExpireFileLink ¶ added in v1.2.0
func ScanExpireFileLink()
定时扫描过期的文件链接,如果过期侧删除该文件记录和文件服务器中的文件
func SessionStat ¶
func SessionStat(w http.ResponseWriter, r *http.Request)
请求参数
baseRequest: { "uid": "", "deviceID": "", "deviceType": "", // iOS / Android "token": "" }
state:"active" sessionId:"1111" 设置会话状态(active/inactive)
Types ¶
type ApnsMsg ¶
type ApnsMsg struct { Id string `json:"id"` Type string `json:"type"` ApnsToken string `json:"apns_token"` Cnt int `json:"cnt"` TenantId string `json:"tenant_id"` Pushed string `json:"pushed"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` }
* APNS消息 *
func GetApnsMsgByApnsToken ¶
在数据库中查询资源.
func GetApnsMsgByTenantId ¶
在数据库中查询资源.
type ApnsToken ¶
type ApnsToken struct { Id string `json:"id"` UserId string `json:"userId"` DeviceId string `json:"deviceId"` ApnsToken string `json:"apnsToken"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` }
apns_token证书
type Client ¶
type Client struct { Id string UserId string Type string DeviceId string LatestLoginTime time.Time Created time.Time Updated time.Time }
客户端结构.
设备登录的时候会记录.
type ClientVerUpdateMsg ¶
type ClientVerUpdateMsg struct { MsgType int `json:"msgType"` Content string `json:"content"` ObjectContent *ClientVerUpdateObjectContent `json:"objectContent"` }
客户端版本更新消息结构.
type ClientVerUpdateObjectContent ¶
type ClientVerUpdateObjectContent struct { VersionCode int `json:"versionCode"` VersionName string `json:"versionName"` URL string `json:"url"` FileName string `json:"fileName"` }
客户端版本更新消息内嵌对象内容结构.
type ClientVersion ¶
type ClientVersion struct { Id string `json:"id"` Type string `json:"type"` VersionCode int `json:"versionCode"` VersionName string `json:"versionName"` VersionDescription string `json:"versionDesc"` DownloadURL string `json:"url"` FileName string `json:"fileName"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` }
客户端版本结构.
type Config ¶
type Config struct { HttpBind []string `goconf:"base:http.bind:,"` AdminBind []string `goconf:"base:admin.bind:,"` AppBind []string `goconf:"base:app.bind:,"` MaxProc int `goconf:"base:maxproc"` PprofBind []string `goconf:"base:pprof.bind:,"` User string `goconf:"base:user"` PidFile string `goconf:"base:pidfile"` Dir string `goconf:"base:dir"` Router string `goconf:"base:router"` QQWryPath string `goconf:"res:qqwry.path"` ZookeeperAddr []string `goconf:"zookeeper:addr:,"` ZookeeperTimeout time.Duration `goconf:"zookeeper:timeout:time"` ZookeeperCometPath string `goconf:"zookeeper:comet.path"` ZookeeperMessagePath string `goconf:"zookeeper:message.path"` RPCRetry time.Duration `goconf:"rpc:retry:time"` RPCPing time.Duration `goconf:"rpc:ping:time"` RedisSource map[string]string `goconf:"-"` RedisIdleTimeout time.Duration `goconf:"redis:timeout:time"` RedisMaxIdle int `goconf:"redis:idle"` RedisMaxActive int `goconf:"redis:active"` RedisMaxStore int `goconf:"redis:store"` RedisKetamaBase int `goconf:"redis:ketama.base"` TokenExpire int `goconf:"token:expire"` ApnsType string `goconf:"apns:type"` }
var (
Conf *Config
)
type ExternalInterface ¶ added in v1.2.0
type ExternalInterface struct { Id string `json:"id"` CustomerId string `json:"customerId"` Type string `json:"type"` Owner int `json:"owner"` HttpUrl string `json:"httpUrl"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` }
func GetExtInterface ¶ added in v1.2.0
func GetExtInterface(customer_id, Type string) *ExternalInterface
根据customer_id 和type获取客户 提供的结构地址
type Qun ¶
type Qun struct { Id string `json:"id"` CreatorId string `json:"creatorId"` CreatorUserName string `json:"creatorUserName"` Name string `json:"name"` Description string `json:"description"` MaxMember int `json:"maxMember"` Avatar string `json:"avatar"` TenantId string `json:"tenantId"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` }
群结构.
type QunUser ¶
type QunUser struct { Id string QunId string UserId string Sort int Role int Created time.Time Updated time.Time }
群-用户关联结构.
type Quota ¶ added in v1.1.0
type Resource ¶
type Resource struct { Id string `json:"id"` CustomerId string `json:"customerId"` Name string `json:"name"` Description string `json:"description"` Type string `json:"type"` Content string `json:"content"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` }
租户证书资源结构
func GetResourceByTenantId ¶
在数据库中查询资源.
Click to show internal directories.
Click to hide internal directories.