feat(tenant): TenantService + DB-backed tenant CRUD (planning §6.7)#12
Merged
Conversation
Phase A2 of the admin console plan — closes the long-standing
TenantService gap so the admin-ui Tenants page has something to call.
tenant-api:
- TenantMetadata (record: id + name + mode + active + createdAt)
- TenantService (interface: create / rename / activate / deactivate /
delete / findById / findAll)
tenant-core:
- PlatformTenantEntity (id varchar(64) PK = TenantId slug,
name, mode (SINGLE/MULTI), active, created_at)
- JpaPlatformTenantRepository
- DefaultTenantService implementation
- new deps: spring-boot-starter-data-jpa, lombok (compileOnly)
- db/migration/V7__platform_tenant.sql
autoconfigure:
- TenantAutoConfiguration grows a @ConditionalOnBean(JpaPlatformTenantRepository.class)
+ @ConditionalOnMissingBean TenantService bean. Apps without JPA on
the classpath still get TenantContextHolder + TenantResolver but no
TenantService.
admin-api:
- TenantAdminController under /admin/api/v1/tenants:
POST / create
GET / list
GET /{id} fetch
PUT /{id} rename
PUT /{id}/activate, /deactivate
DELETE /{id}
- CreateTenantRequest, RenameTenantRequest DTOs (Jakarta Validation)
Design note: platform_tenant.id stays a varchar(64) slug rather than
UUID so existing tables that already carry tenant_id as a string slug
keep working without FK migration churn. Consumer apps that want strict
referential integrity can add the FK in their own migration.
Verified: ./gradlew :devslab-kit-sample-app:test -> BUILD SUCCESSFUL in 56s
- V7 applies cleanly on top of V1-V6
- TenantService bean wires (JpaPlatformTenantRepository present)
- All previous beans, login flow, admin-api controllers still green
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase A2 of the admin console plan. Closes the long-standing TenantService gap so the admin-ui Tenants page has something to call.
tenant-api
TenantMetadatarecord —id+name+mode+active+createdAtTenantServiceinterface —create/rename/activate/deactivate/delete/findById/findAlltenant-core
PlatformTenantEntity—id varchar(64) PK(=TenantIdslug, not UUID; keeps existing string-basedtenant_idcolumns working without FK churn)JpaPlatformTenantRepositoryDefaultTenantServiceimplementationspring-boot-starter-data-jpa, Lombok (compileOnly)db/migration/V7__platform_tenant.sqlautoconfigure
TenantAutoConfigurationgrows a@ConditionalOnBean(JpaPlatformTenantRepository.class)+@ConditionalOnMissingBean TenantServicebean. Apps without JPA still getTenantContextHolder+TenantResolverbut noTenantService.admin-api
TenantAdminControllerunder/admin/api/v1/tenants:///{id}/{id}/{id}/activate/{id}/deactivate/{id}CreateTenantRequest+RenameTenantRequestDTOs (Jakarta Validation)Design note
platform_tenant.idis avarchar(64)slug rather than UUID so existing tables that already carrytenant_idas a string slug keep working without FK migration churn. Consumer apps that want strict referential integrity can add the FK in their own migration on top.Verified
TenantServicebean wires