/*
 * Copyright (c) 京北方信息技术股份有限公司 Corporation 2021 . All rights reserved.
 *
 */
package net.northking.cctp.common.saas.db;

import net.northking.cctp.common.security.authentication.NKSecurityContext;

/**
 * 租户模式数据库服务接口
 *
 * @author : xiusong.xie
 * @version : 1.0
 */
public interface TenantDBService
{
  default void initTenantId(Object record)
  {
    if (record instanceof TenantPartition)
    {
      ((TenantPartition) record).setTenantId(NKSecurityContext.getTenantId());
      ((TenantPartition) record).setSchemaSuffix(NKSecurityContext.getDomains());
    } else
    {
      String err = record.getClass() + " is not extends TenantPartition";
      throw new ClassCastException(err);
    }
  }

}
