finclip-app-manager/domain/repository/binding.go

138 lines
7.8 KiB
Go
Raw Normal View History

2023-10-31 14:07:26 +08:00
package repository
import (
"context"
"finclip-app-manager/domain/entity"
"finclip-app-manager/domain/entity/proto/apiproto"
)
//const BINDING_DB_NAME = "binding"
//const BUNDLEINFO_DB_NAME = "bundleInfo"
//
//const (
// BUNDLE_ID_LIMITI = 2
//)
//
//var SdkExiCache *cache.Cache
//
//type Status struct {
// Value string `json:"value" bson:"value"`
// Reason string `json:"reason" bson:"reason"`
// LastUpdated int64 `json:"lastUpdated" bson:"last_updated"`
// ModifiedBy string `json:"modifiedBy" bson:"modified_by"`
//}
//
//type SpecificStatus struct {
// Reason string `json:"reason" bson:"reson"`
// LastUpdated int64 `json:"lastUpdated" bson:"last_updated"`
// ModifiedBy string `json:"modifiedBy" bson:"modified_by"`
//}
//
//type UnpublishedStatus struct {
// Reason string `json:"reason" bson:"reson"`
// LastUpdated int64 `json:"lastUpdated" bson:"last_ipdated"`
// ModifiedBy string `json:"modifiedBy" bson:"modified_by"`
// Type string `json:"type" bson:"type"`
//}
//
//type BundleInfo struct {
// BundleID string `json:"bundleId" bson:"bundle_id"`
// Remark string `json:"remark" bson:"remark"`
// SDKKey string `json:"SDKKey" bson:"sdk_key"`
// SDKID string `json:"SDKID" bson:"sdk_id"`
// IsFirstCreate bool `json:"isFirstCreate" bson:"is_first_create"` //是否第一次创建
// CreatedAt int64 `json:"createdAt" bson:"created_at"`
// CreatedAccount string `json:"createdAccount" bson:"created_account"`
// CreatedBy string `json:"createdBy" bson:"created_by"`
//}
//
//type CreatedInfo struct {
// CreatedBy string `json:"createdBy" bson:"created_by"`
// CreatedAt int64 `json:"createdAt" bson:"created_at"`
//}
//
//type AppInfo struct {
// AppID string `json:"appId" bson:"app_id"`
// AssociatedAt int64 `json:"associatedAt" bson:"associated_at"`
// AssociatedBy string `json:"associatedBy" bson:"associated_by"`
//}
//
////应用维度
//type Binding struct {
// BindingID string `json:"bindingId" bson:"binding_id"` //应用的id
// Name string `json:"name" bson:"name"` //应用名称
// BundleInfos []BundleInfo `json:"bundleInfos" bson:"bundle_infos"` //bundle ids
// CreatedInfo CreatedInfo `json:"createdInfo" bson:"created_info"` //创建信息
// GroupID string `json:"groupId" bson:"group_id"` //企业ID
// GroupName string `json:"groupName" bson:"group_name"` //企业名称(为了查询)
// CooperateStatus Status `json:"cooperateStatus" bson:"cooperate_status"` //合作状态
// CooperateValidStatus SpecificStatus `json:"cooperateValidStatus" bson:"cooperate_valid_status"` //合作状态详情
// CooperateInvalidStatus SpecificStatus `json:"cooperateInvalidStatus" bson:"cooperate_invalid_status"` //解除合作状态详情
// AppInfos []AppInfo `json:"appInfos" bson:"app_infos"` //appid 的信息
// Owner string `json:"owner" bson:"owner"` //所属企业
// Expire int64 `json:"expire" bson:"expire"`
// ApiServer string `json:"apiServer" bson:"api_server"` //子域名
//}
type IBindingRepo interface {
GetInfo(ctx context.Context, bindingId string) (*entity.Binding, error)
GetByGroupIdAndName(ctx context.Context, groupId string, name string, isAdmin bool) (*entity.Binding, error)
GetByApiServer(ctx context.Context, apiServer string) (entity.Binding, error)
GetInfoByParams(ctx context.Context, sdkKey, organId, appId string) (*entity.Binding, error)
GetInfoBySdkKeyOrganId(ctx context.Context, organId, sdkKey string) (*entity.Binding, error)
GetAllSdkKey(ctx context.Context, organId string) ([]string, error)
GetBindListBySdkKey(ctx context.Context, sdkKey string) ([]entity.Binding, error)
SdkKeyExi(ctx context.Context, sdkKey string) (bool, error)
Insert(ctx context.Context, bind *entity.Binding) error
Count(ctx context.Context) (int, error)
GetCountByStatus(ctx context.Context, status string, platform int) (int, error)
GetBundleIdNum(ctx context.Context) (int, error)
GetBundleIdLimitHand(ctx context.Context, groupId string) (int, error)
GetBundleLimit(ctx context.Context) (int, error)
GetBindingByGroupIdAndBindingId(ctx context.Context, groupId string, bindingId string) (*entity.Binding, error)
GetBindingByGroupIdAndSdkKey(ctx context.Context, groupId string, sdkKey string) (*entity.Binding, error)
UpdateBundleInfosByGroupIdAndBindId(ctx context.Context, groupId string, bindingId string, infos []entity.BundleInfo) error
AppendBundles(ctx context.Context, bindingId, groupId string, bundles []entity.BundleInfo) error
UpdateBundles(ctx context.Context, bindingId, groupId string, bundles []entity.BundleInfo) error
GetByBindIdList(ctx context.Context, ids []string) ([]entity.Binding, error)
GetBindListByGroupId(ctx context.Context, groupId string, pageSize int, pageNo int) ([]entity.Binding, int, error)
UpdateByBindId(ctx context.Context, bindingId string, bind *entity.Binding) error
UpdateExpire(ctx context.Context, bindingId string, expire int64) error
BundleIdCount(ctx context.Context, groupId string) (int, error)
GetBundleByGroupIdAndBundleId(ctx context.Context, groupId string, bundleId string) (*entity.Binding, error)
GetbundlesByBundleId(ctx context.Context, bundleId string) (*entity.Binding, error)
GetBindingsBySearch(ctx context.Context, pageSize int, pageNo int, sort string, searchText string, searchFields string, cooperateStatus string, platform int) ([]entity.Binding, int, error)
GetBindingsByAppId(ctx context.Context, pageSize int, pageNo int, appId string) ([]entity.Binding, int, error)
GetDevListBinding(ctx context.Context, pageSize int, pageNo int, sort string, searchText string, pullType string, groupId string, bindStatus string, platform int) ([]entity.Binding, int, error)
GetBindingBySdkKey(ctx context.Context, sdkKey string) (*entity.Binding, error)
ListBindings(ctx context.Context, groupId string, searchText string, pageNo int, pageSize int) ([]entity.Binding, int, error)
GetAllAssBinds(ctx context.Context, appId string) ([]entity.Binding, error)
UpdateBundleIdIsForbidden(ctx context.Context, bundleId string) error
UpdateBundleIdPlatform(ctx context.Context, bundleId, platform string) error
UpdateRelatedBindingCooperate(ctx context.Context, bindingId string, status entity.Status, specificStatus entity.SpecificStatus, cooperate bool) error
UpdateBindingInfo(ctx context.Context, bindingId string, info map[string]interface{}, platform int) error
UpdateBindingGroupName(ctx context.Context, groupId, groupName string) error
ListAutoBindAppBinding(ctx context.Context, groupId string) ([]string, error)
ListCopyOperBinding(ctx context.Context, bindingId string) ([]string, []entity.Binding, error)
AppendApps(ctx context.Context, bindingId string, apps []entity.AppInfo) error
RemoveApps(ctx context.Context, bindingId string, appIds []string) error
UpdateBundleIsView(ctx context.Context, reviews []apiproto.BundleReviewItem, isReview int) error
ListReviewBundle(ctx context.Context, pageSize int, pageNo int, searchText string, isReview int) (int64, []entity.ReviewBundleInfo, error)
CheckReviewBySdkKey(ctx context.Context, sdkKey string) bool
GetReviewBindBySdkKey(ctx context.Context, sdkKey string) (*entity.ReviewBundleInfo, error)
UpdateBundleBindingId(ctx context.Context, bundleId, bindingId, toBindingId string) error
NotFound(err error) bool
}
func IsAssAppId(info *entity.Binding, appId string) bool {
if info == nil {
return false
}
for _, a := range info.AppInfos {
if a.AppID == appId {
return true
}
}
return false
}