-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* file owners * upload history * but setup-java action version * endpoint descriptions * add migration * fix migration
- Loading branch information
1 parent
e68977a
commit 03de689
Showing
11 changed files
with
256 additions
and
23 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
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
40 changes: 40 additions & 0 deletions
40
spring-app/src/main/kotlin/pl/starchasers/up/controller/UserController.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,40 @@ | ||
package pl.starchasers.up.controller | ||
|
||
import org.springframework.data.domain.Page | ||
import org.springframework.data.domain.Pageable | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
import pl.starchasers.up.data.dto.upload.UploadHistoryEntryDTO | ||
import pl.starchasers.up.exception.AccessDeniedException | ||
import pl.starchasers.up.security.IsUser | ||
import pl.starchasers.up.service.FileService | ||
import pl.starchasers.up.service.UserService | ||
import java.security.Principal | ||
|
||
@RestController | ||
@RequestMapping("/api/user") | ||
class UserController( | ||
val fileService: FileService, | ||
val userService: UserService | ||
) { | ||
|
||
@GetMapping("/history") | ||
@IsUser | ||
fun listUserUploadHistory(principal: Principal, pageable: Pageable): Page<UploadHistoryEntryDTO> { | ||
return fileService.getUploadHistory( | ||
userService.fromPrincipal(principal) ?: throw AccessDeniedException(), | ||
pageable | ||
).map { | ||
UploadHistoryEntryDTO( | ||
it.filename.value, | ||
it.createdDate, | ||
it.permanent, | ||
it.toDeleteDate, | ||
it.size.value, | ||
it.contentType.value, | ||
it.key.value | ||
) | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
spring-app/src/main/kotlin/pl/starchasers/up/data/dto/upload/UploadHistoryEntryDTO.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,34 @@ | ||
package pl.starchasers.up.data.dto.upload | ||
|
||
import java.sql.Timestamp | ||
|
||
data class UploadHistoryEntryDTO( | ||
/** | ||
* Name of the file | ||
*/ | ||
val filename: String, | ||
/** | ||
* When was this file uploaded | ||
*/ | ||
val uploadDate: Timestamp, | ||
/** | ||
* Whether this file will be automatically deleted | ||
*/ | ||
val permanent: Boolean, | ||
/** | ||
* When will this file be automatically deleted. Null if temporary == false | ||
*/ | ||
val deleteDate: Timestamp?, | ||
/** | ||
* File size in bytes | ||
*/ | ||
val size: Long, | ||
/** | ||
* Mime type of this file. This string is used as content-type header when serving file to clients. | ||
*/ | ||
val mimeType: String, | ||
/** | ||
* File key used in file link. | ||
*/ | ||
val key: String | ||
) |
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
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
8 changes: 8 additions & 0 deletions
8
spring-app/src/main/resources/db/migration/V2__file_owners.sql
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,8 @@ | ||
start transaction; | ||
|
||
alter table file_entry | ||
add column owner_id bigint(20) default null, | ||
add key `ix_file_entry__owner_id` (owner_id), | ||
add constraint `fk_user__file_entry` foreign key (owner_id) references `user` (`id`); | ||
|
||
commit; |
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.