-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
289 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
49 changes: 49 additions & 0 deletions
49
...ain/kotlin/com/sphereon/oid/fed/server/admin/controllers/SubordinateMetadataController.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.sphereon.oid.fed.server.admin.controllers | ||
|
||
import com.sphereon.oid.fed.openapi.models.CreateMetadataDTO | ||
import com.sphereon.oid.fed.openapi.models.SubordinateMetadataDTO | ||
import com.sphereon.oid.fed.services.SubordinateService | ||
import org.springframework.web.bind.annotation.DeleteMapping | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PathVariable | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
@RequestMapping("/accounts/{accountUsername}/subordinates/{subordinateId}/metadata") | ||
class SubordinateMetadataController { | ||
private val subordinateService = SubordinateService() | ||
|
||
@GetMapping | ||
fun get( | ||
@PathVariable accountUsername: String, | ||
@PathVariable subordinateId: Int | ||
): Array<SubordinateMetadataDTO> { | ||
return subordinateService.findSubordinateMetadata(accountUsername, subordinateId) | ||
} | ||
|
||
@PostMapping | ||
fun create( | ||
@PathVariable accountUsername: String, | ||
@PathVariable subordinateId: Int, | ||
@RequestBody body: CreateMetadataDTO | ||
): SubordinateMetadataDTO { | ||
return subordinateService.createMetadata( | ||
accountUsername, | ||
subordinateId, | ||
body.key, | ||
body.metadata | ||
) | ||
} | ||
|
||
@DeleteMapping("/{id}") | ||
fun delete( | ||
@PathVariable accountUsername: String, | ||
@PathVariable subordinateId: Int, | ||
@PathVariable id: Int | ||
): SubordinateMetadataDTO { | ||
return subordinateService.deleteSubordinateMetadata(accountUsername, subordinateId, id) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
12 changes: 12 additions & 0 deletions
12
modules/persistence/src/commonMain/sqldelight/com/sphereon/oid/fed/persistence/models/10.sqm
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CREATE TABLE SubordinateMetadata ( | ||
id SERIAL PRIMARY KEY, | ||
account_id INT NOT NULL, | ||
subordinate_id INT NOT NULL, | ||
key TEXT NOT NULL, | ||
metadata TEXT NOT NULL, | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
deleted_at TIMESTAMP, | ||
CONSTRAINT FK_ParentEntityConfigurationMetadata FOREIGN KEY (account_id) REFERENCES Account (id) | ||
); | ||
|
||
CREATE INDEX subordinate_metadata_account_id_index ON SubordinateMetadata (account_id); |
This file contains 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
28 changes: 28 additions & 0 deletions
28
.../src/commonMain/sqldelight/com/sphereon/oid/fed/persistence/models/SubordinateMetadata.sq
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
create: | ||
INSERT INTO SubordinateMetadata ( | ||
account_id, | ||
subordinate_id, | ||
key, | ||
metadata | ||
) VALUES (?, ?, ?, ?) RETURNING *; | ||
|
||
delete: | ||
UPDATE SubordinateMetadata SET deleted_at = CURRENT_TIMESTAMP WHERE id = ? AND deleted_at IS NULL RETURNING *; | ||
|
||
findByAccountId: | ||
SELECT * FROM SubordinateMetadata WHERE account_id = ? AND deleted_at IS NULL; | ||
|
||
findByAccountIdAndSubordinateId: | ||
SELECT * FROM SubordinateMetadata WHERE account_id = ? AND subordinate_id = ? AND deleted_at IS NULL; | ||
|
||
findByAccountIdAndSubordinateIdAndKey: | ||
SELECT * FROM SubordinateMetadata WHERE account_id = ? AND subordinate_id = ? AND key = ? AND deleted_at IS NULL; | ||
|
||
findByAccountIdAndSubordinateIdAndId: | ||
SELECT * FROM SubordinateMetadata WHERE account_id = ? AND subordinate_id = ? AND id = ? AND deleted_at IS NULL; | ||
|
||
findByAccountIdAndKey: | ||
SELECT * FROM SubordinateMetadata WHERE account_id = ? AND key = ? AND deleted_at IS NULL; | ||
|
||
findById: | ||
SELECT * FROM SubordinateMetadata WHERE id = ? AND deleted_at IS NULL; |
This file contains 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
This file contains 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
Oops, something went wrong.