Skip to main content

Overview

jshERP implements a robust multi-tenant architecture that allows multiple organizations to use the same system while maintaining complete data isolation. Each tenant operates independently with its own users, data, and configurations.
The tenant system is fundamental to jshERP’s architecture. All users must be associated with a tenant, and data is automatically filtered by tenant ID.

Tenant Types

jshERP supports two types of tenants:
TypeDescriptionFeatures
0 - Free TenantBasic tier for trial or small businessesLimited user count, basic features
1 - Paid TenantPremium tier for full accessExtended user limits, all features

Creating a New Tenant

1

Navigate to Tenant Management

Access the tenant management interface from the admin panel.
2

Click Add Tenant

Click the “New Tenant” button to open the creation form.
3

Configure Tenant Details

Fill in the required information:
loginName
string
required
Primary administrator login name for this tenant
userNumLimit
integer
required
Maximum number of users allowed for this tenant
type
string
required
Tenant type: “0” for free, “1” for paid
expireTime
date
Subscription expiration date (for paid tenants)
enabled
boolean
Whether the tenant is active (default: true)
remark
string
Additional notes about this tenant
4

Save and Activate

Submit the form to create the tenant. The system will generate a unique tenantId.

API Endpoints

The tenant management system exposes the following REST API endpoints:

Get Tenant Information

GET /tenant/info?id={tenantId}
Returns detailed information about a specific tenant. Reference: TenantController.java:36-48

List All Tenants

GET /tenant/list?search={searchParams}
Returns a paginated list of tenants with optional filtering:
  • loginName: Filter by admin login name
  • type: Filter by tenant type (0 or 1)
  • enabled: Filter by enabled status
  • remark: Search in remarks
Reference: TenantController.java:50-60

Create Tenant

POST /tenant/add
Request Body:
{
  "loginName": "[email protected]",
  "userNumLimit": 50,
  "type": "1",
  "expireTime": "2025-12-31",
  "enabled": true,
  "remark": "Enterprise customer"
}
Reference: TenantController.java:62-68

Update Tenant

PUT /tenant/update
Reference: TenantController.java:70-76

Delete Tenant

DELETE /tenant/delete?id={tenantId}
DELETE /tenant/deleteBatch?ids={id1,id2,id3}
Deleting a tenant will mark it as deleted but preserve the data for audit purposes. This operation should be performed with caution.
Reference: TenantController.java:78-92

Batch Operations

Enable/Disable Multiple Tenants

POST /tenant/batchSetStatus
Request Body:
{
  "status": true,
  "ids": "1,2,3"
}
This allows you to enable or disable multiple tenants simultaneously. Reference: TenantController.java:114-127

Tenant Expiration Management

For paid tenants, jshERP automatically checks the expiration date during login:
1

Expiration Check

When a user logs in, the system validates their tenant’s expireTime.
2

Auto-Logout

If the tenant has expired, the user session is automatically terminated and they cannot access the system.
3

Renewal Process

Update the tenant’s expireTime to extend access.
Reference: UserController.java:571-575

User Limit Enforcement

Tenants cannot exceed their configured user limit:
// When adding a new user
if (currentUserCount >= tenant.getUserNumLimit()) {
    throw new BusinessParamCheckingException(
        "USER_OVER_LIMIT",
        "User limit exceeded for this tenant"
    );
}
Reference: UserController.java:320-325

Data Model

The Tenant entity structure:
id
Long
Primary key (auto-generated)
tenantId
Long
Unique tenant identifier used throughout the system
loginName
String
Primary administrator’s login name
userNumLimit
Integer
Maximum allowed users
type
String
Tenant type: “0” (free) or “1” (paid)
enabled
Boolean
Active status
createTime
Date
Tenant creation timestamp
expireTime
Date
Subscription expiration date
remark
String
Additional notes
deleteFlag
String
Soft delete marker
Reference: Tenant.java:1-105

Best Practices

Important Considerations:
  • Always verify tenant status before performing critical operations
  • Monitor user counts against limits to prevent disruption
  • Set appropriate expiration dates for paid tenants
  • Use meaningful remarks to track tenant business information
Multi-Tenant Data Isolation:Every database query in jshERP automatically filters by tenantId to ensure complete data separation. This is handled at the service layer and requires no additional configuration.

Validation

Check Name Uniqueness

GET /tenant/checkIsNameExist?id={id}&name={name}
Validates whether a login name is already in use by another tenant. Reference: TenantController.java:94-106

Monitoring and Reporting

Administrators can monitor tenant usage through:
  1. User Count Tracking: View current vs. limit for each tenant
  2. Expiration Monitoring: Track upcoming tenant expirations
  3. Activity Status: Monitor enabled/disabled tenant states
  4. Type Distribution: Analyze free vs. paid tenant ratios
For detailed user management within each tenant, see User Management.

Build docs developers (and LLMs) love