getting started

This commit is contained in:
androidlover5842
2026-01-24 14:42:07 +05:30
commit a5a6aa4999
29 changed files with 1133 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package com.android.trisolarisserver.component
import com.android.trisolarisserver.db.repo.PropertyUserRepo
import com.android.trisolarisserver.models.property.Role
import org.springframework.security.access.AccessDeniedException
import org.springframework.stereotype.Component
import java.util.UUID
@Component
class PropertyAccess(
private val repo: PropertyUserRepo
) {
fun requireMember(propertyId: UUID, userId: UUID) {
if (!repo.existsByIdPropertyIdAndIdUserId(propertyId, userId))
throw AccessDeniedException("No access to property")
}
fun requireAnyRole(propertyId: UUID, userId: UUID, vararg roles: Role) {
if (!repo.hasAnyRole(propertyId, userId, roles.toSet()))
throw AccessDeniedException("Missing role")
}
}