Files
common/beans/module_tenant.go
qhd d1f80c3109 refactor: 重构SQL基础实体并集成雪花ID生成器
将主键ID类型从uint64改为int64,移除Bid和Deleter字段;在insertHook中集成Snowflake算法自动生成ID;更新ModuleAssetId为int64类型。
2026-03-19 17:07:01 +08:00

82 lines
2.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package beans
import (
"github.com/gogf/gf/v2/os/gtime"
)
// ModuleAssetId 模块资产ID映射key-value结构
// Key: 服务名Value: 资产ID
var ModuleAssetId = map[string]int64{
"assets": 1, // 资产模块
"cid": 2, // 广告模块
"customerService": 3, // AI客服模块
}
// 模块类型值从ModuleAssetId map获取
var (
TenantModuleAssets = ModuleAssetId["assets"] // 资产模块
TenantModuleAd = ModuleAssetId["cid"] // 广告模块
TenantModuleAICs = ModuleAssetId["customerService"] // AI客服模块
)
type TenantModuleType string
const (
TenantModuleTypePlatform TenantModuleType = "platform"
TenantModuleTypePrivate TenantModuleType = "private"
TenantModuleTypeSupplier TenantModuleType = "supplier"
TenantModuleTypeSmallShop TenantModuleType = "small_shop"
)
// TenantModuleTypeKV 租户类型
type TenantModuleTypeKV struct {
Key string
Value string
}
// TenantModuleTypesAssets 资产模块租户类型
var TenantModuleTypesAssets = []TenantModuleTypeKV{
{Key: string(TenantModuleTypePrivate), Value: "私域租户"},
{Key: string(TenantModuleTypeSupplier), Value: "供应商"},
{Key: string(TenantModuleTypeSmallShop), Value: "电商小店"},
}
// TenantModuleTypesAd 广告模块租户类型(待定)
var TenantModuleTypesAd []TenantModuleTypeKV
// TenantModuleTypesAICs AI客服模块租户类型待定
var TenantModuleTypesAICs []TenantModuleTypeKV
// GetTenantModuleTypes 获取模块的租户类型列表
func GetTenantModuleTypes(module int64) []TenantModuleTypeKV {
switch module {
case TenantModuleAssets:
return TenantModuleTypesAssets
case TenantModuleAd:
return TenantModuleTypesAd
case TenantModuleAICs:
return TenantModuleTypesAICs
default:
return []TenantModuleTypeKV{}
}
}
type ModuleTenantCheckReq struct {
ModuleKey string `p:"moduleKey" v:"required#模块Key不能为空"`
TenantId uint64 `p:"tenantId" v:"required#租户ID不能为空"`
}
// ModuleTenantCheckRes 调用admin-go设置模块租户关系的响应
type ModuleTenantCheckRes struct {
Status bool `json:"status"`
CertificationStatus bool `json:"certificationStatus"`
Message string `json:"message"` // 状态描述
}
// ModuleTenant 模块租户关系实体(引用自admin-go)
type ModuleTenant struct {
ExpireAt *gtime.Time `json:"expireAt" description:"到期时间"`
TenantModuleType TenantModuleType `json:"tenantModuleType" description:"租户模块类型"`
CertificationStatus int `json:"certificationStatus" description:"认证状态"`
}