Documentation ¶
Index ¶
- Constants
- Variables
- func ApiCallStatistics(w http.ResponseWriter, r *http.Request) bool
- func DeleteFile(fileId string) bool
- func DeleteResourceById(resourceId string) bool
- func ExistFileLink(fileLink *FileLink) bool
- func GetUserByME(key string) *member
- 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 ApnsToken
- type BySort
- type Client
- type ClientVerUpdateMsg
- type ClientVerUpdateObjectContent
- type ClientVersion
- type Config
- type ExternalInterface
- type FileLink
- type PushCnt
- 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 ( // 根据 id 查询应用记录. SelectApplicationById = "SELECT * FROM `application` WHERE `id` = ?" // 查询应用记录. //SelectAllApplication = "select t.id, t.name, t.name, t.status, t.sort,t.avatar, t.tenant_id,t.name_py,t.name_quanpin ,t.description, IF( isnull(a.follow) ,t.follow,a.follow) as follow from (SELECT * from application where tenant_id = ? ) t left join app_user a on t.id = a.appId and a.uid = ? " SelectAllApplication = "" /* 536-byte string literal not displayed */ // 根据 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 " //插入用户关注的应用 InsertAppUser = "INSERT INTO `app_user`(`id`,`appid`,`uid`,`follow`) VALUES(?,?,?,?)" //删除用户关注应用信息 UpdateAppUser = "UPDATE app_user set follow = ? where id = ? " //查询用户是否关注该企业号 SelectAppUser = "SELECT `id`,`appid`,`uid`,`follow` FROM `app_user` where appid = ? and uid = ? " )
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_PC = "pc" 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 < ?" UPDATE_USER_AVATAR = "update user set avatar = ? where id = ?" UPDATE_APP_AVATAR = "update application set avatar = ? where id = ?" )
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. InsertResourceSQL = "INSERT INTO `resource` (`id`, `customer_id`, `name`, `description`, `type`, `content`, `created`, `updated`) VALUES " + "(?, ?, ?, ?, ?, ?, ?, ?)" // 根据资源id 获取资源 SelectResourceByIdSQL = "SELECT * FROM `resource` where `id` = ?" //根据nam查资源 SelectResourceByNameSQL = "SELECT * FROM `resource` where `name` = ?" // 根据租户 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 ¶
func ApiCallStatistics(w http.ResponseWriter, r *http.Request) bool
记录api调用次数
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 SessionStat ¶
func SessionStat(w http.ResponseWriter, r *http.Request)
请求参数
baseRequest: { "uid": "", "deviceID": "", "deviceType": "", // iOS / Android "token": "" }
state:"active" sessionId:"1111" 设置会话状态(active/inactive)
Types ¶
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:,"` AppPush []string `goconf:"base:app.push:,"` 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"` WeedfsAddr string `goconf:"weedfs:address:"` WeedfsLocalAddr string `goconf:"weedfs:localAddress:"` }
var (
Conf *Config
)
type ExternalInterface ¶
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 ¶
func GetExtInterface(customer_id, Type string) *ExternalInterface
根据customer_id 和type获取客户 提供的结构地址
type Quota ¶
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.