package entity import ( "time" "github.com/patrickmn/go-cache" ) const BINDING_DB_NAME = "binding" const BUNDLEINFO_DB_NAME = "bundleInfo" const ( BUNDLE_ID_LIMITI = 2 BINGING_PLATFORM_ORGAN = 0 BINGING_PLATFORM_OPER = 1 BINGING_PLATFORM_ALL = 2 BINGING_NOT_AUTO_BIND = 0 BINGING_AUTO_BIND = 1 ) var SdkExiCache *cache.Cache func init() { SdkExiCache = cache.New(24*time.Hour, time.Hour) } type BundleInfo struct { //Id uint64 `json:"id" bson:"id"` BundleID string `json:"bundleId" bson:"bundleId"` Remark string `json:"remark" bson:"remark"` SDKKey string `json:"SDKKey" bson:"SDKKey"` SDKID string `json:"SDKID" bson:"SDKID"` IsFirstCreate bool `json:"isFirstCreate" bson:"isFirstCreate"` //是否第一次创建 CreatedAt int64 `json:"createdAt" bson:"createdAt"` CreatedAccount string `json:"createdAccount" bson:"createdAccount"` CreatedBy string `json:"createdBy" bson:"createdBy"` IsForbidden int `json:"isForbidden" bson:"isForbidden"` IsReview int `json:"-" bson:"-"` } type CreatedInfo struct { CreatedBy string `json:"createdBy" bson:"created_by"` CreatedAt int64 `json:"createdAt" bson:"created_at"` CreatedAccount string `json:"createdAccount" bson:"created_account"` } type AppInfo struct { //Id uint64 `json:"id" bson:"id"` AppID string `json:"appId" bson:"appId"` AssociatedAt int64 `json:"associatedAt" bson:"associatedAt"` AssociatedBy string `json:"associatedBy" bson:"associatedBy"` } //应用维度 type Binding struct { BindingID string `json:"bindingId" bson:"bindingId"` //应用的id Name string `json:"name" bson:"name"` //应用名称 BundleInfos []BundleInfo `json:"bundleInfos" bson:"bundleInfos"` //bundle ids CreatedInfo CreatedInfo `json:"createdInfo" bson:"createdInfo"` //创建信息 GroupID string `json:"groupId" bson:"groupId"` //企业ID GroupName string `json:"groupName" bson:"groupName"` //企业名称(为了查询) CooperateStatus Status `json:"cooperateStatus" bson:"cooperateStatus"` //合作状态 CooperateValidStatus SpecificStatus `json:"cooperateValidStatus" bson:"cooperateValidStatus"` //合作状态详情 CooperateInvalidStatus SpecificStatus `json:"cooperateInvalidStatus" bson:"cooperateInvalidStatus"` //解除合作状态详情 AppInfos []AppInfo `json:"appInfos" bson:"appInfos"` //appid 的信息 Owner string `json:"owner" bson:"owner"` //所属企业 Expire int64 `json:"expire" bson:"expire"` ApiServer string `json:"apiServer" bson:"apiServer"` //子域名 PlatForm int `json:"platform" bson:"platform"` //来源平台 AutoBind int `json:"autoBind" bson:"autoBind"` //自动关联小程序 HiddenBundle int `json:"hiddenBundle" bson:"hiddenBundle"` //隐藏bundle信息 FromBindingID string `json:"fromBindingId" bson:"fromBindingId"` //来源ID } //type IBindingRepo interface { // GetInfo(ctx context.Context, bindingId string) (*Binding, error) // GetByGroupIdAndName(ctx context.Context, groupId string, name string) (*Binding, error) // GetByApiServer(ctx context.Context, apiServer string) (*Binding, error) // GetBindingsByAppIdAndSdkKey(ctx context.Context, appId, sdkKey string) (*Binding, error) // GetInfoBySdkKeyOrganId(ctx context.Context, organId, sdkKey string) (*Binding, error) // GetAllSdkKey(ctx context.Context, organId string) ([]string, error) // GetBindListBySdkKey(ctx context.Context, sdkKey string) ([]Binding, error) // SdkKeyExi(ctx context.Context, sdkKey string) (bool, error) // Insert(ctx context.Context, bind *Binding) error // Count(ctx context.Context) (int, error) // GetBundleIdNum(ctx context.Context) (int, error) // NotFound(err error) bool //} // //func IsAssAppId(info *Binding, appId string) bool { // if info == nil { // return false // } // for _, a := range info.AppInfos { // if a.AppID == appId { // return true // } // } // return false //} type BindingUsed struct { LimitNum int `json:"limitNum"` HasUseNum int `json:"hasUseNum"` RemainNum int `json:"remainNum"` } type ReviewBundleInfo struct { BindingId string `json:"bindingId"` CreatedInfoAt int64 `json:"createdInfoAt"` Name string `json:"name"` Status string `json:"status"` BundleID string `json:"bundleId"` Remark string `json:"remark"` SDKKey string `json:"sdkKey"` SDKID string `json:"sdkId"` IsForbidden int `json:"isForbidden"` //是否禁用 0:未禁用 1:禁用 IsReview int `json:"isReview"` }