80 lines
2.8 KiB
Go
80 lines
2.8 KiB
Go
package beans
|
||
|
||
import (
|
||
"github.com/gogf/gf/v2/os/gtime"
|
||
)
|
||
|
||
// ModuleAssetId 模块资产ID映射(key-value结构)
|
||
// Key: 服务名,Value: 资产ID
|
||
var ModuleAssetId = map[string]string{
|
||
"assets": "696b4acd1be1c8b76c4b4c15", // 资产模块
|
||
"cid": "696f423705e496ba4ccbe665", // 广告模块
|
||
"customerService": "696f421205e496ba4ccbe662", // AI客服模块
|
||
}
|
||
|
||
// 模块类型(值从ModuleAssetId map获取)
|
||
var (
|
||
TenantModuleAssets = ModuleAssetId["assets"] // 资产模块
|
||
TenantModuleAd = ModuleAssetId["cid"] // 广告模块
|
||
TenantModuleAICs = ModuleAssetId["customerService"] // AI客服模块
|
||
)
|
||
|
||
// TenantModuleType 租户类型
|
||
type TenantModuleType struct {
|
||
Key string
|
||
Value string
|
||
}
|
||
|
||
// TenantModuleTypesAssets 资产模块租户类型
|
||
var TenantModuleTypesAssets = []TenantModuleType{
|
||
{Key: "private_cloud", Value: "私有云租户"},
|
||
{Key: "supplier", Value: "供应商"},
|
||
{Key: "small_shop", Value: "电商小店"},
|
||
}
|
||
|
||
// TenantModuleTypesAd 广告模块租户类型(待定)
|
||
var TenantModuleTypesAd []TenantModuleType
|
||
|
||
// TenantModuleTypesAICs AI客服模块租户类型(待定)
|
||
var TenantModuleTypesAICs []TenantModuleType
|
||
|
||
// GetTenantModuleTypes 获取模块的租户类型列表
|
||
func GetTenantModuleTypes(module string) []TenantModuleType {
|
||
switch module {
|
||
case TenantModuleAssets:
|
||
return TenantModuleTypesAssets
|
||
case TenantModuleAd:
|
||
return TenantModuleTypesAd
|
||
case TenantModuleAICs:
|
||
return TenantModuleTypesAICs
|
||
default:
|
||
return []TenantModuleType{}
|
||
}
|
||
}
|
||
|
||
type ModuleTenantCheckReq struct {
|
||
ModuleKey string `p:"moduleKey" v:"required#模块Key不能为空"`
|
||
TenantId uint64 `p:"tenantId" v:"required#租户ID不能为空"`
|
||
}
|
||
|
||
// ModuleTenantCheckRes 调用admin-go设置模块租户关系的响应
|
||
type ModuleTenantCheckRes struct {
|
||
Status string `json:"status"` // 开通状态:activated(已开通)、expired(已到期)、not_activated(未开通)
|
||
Message string `json:"message"` // 状态描述
|
||
OpenStatus bool `json:"openStatus"` // 开通状态
|
||
}
|
||
|
||
// ModuleTenant 模块租户关系实体(引用自admin-go)
|
||
type ModuleTenant struct {
|
||
Id uint64 `json:"id" description:""`
|
||
CreateBy uint64 `json:"createBy" description:"创建者"`
|
||
UpdateBy uint64 `json:"updateBy" description:"更新者"`
|
||
CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"`
|
||
UpdatedAt *gtime.Time `json:"updatedAt" description:"更新时间"`
|
||
ModuleKey string `json:"moduleKey" description:"模块Key"`
|
||
TenantId uint64 `json:"tenantId" description:"租户ID"`
|
||
ExpireAt *gtime.Time `json:"expireAt" description:"到期时间"`
|
||
AssetId string `json:"assetId" description:"资产ID"`
|
||
AssetSkuId string `json:"assetSkuId" description:"资产SKU ID"`
|
||
}
|