Skip to content

Commit

Permalink
feat!: add UUID
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin-Guillemin committed Mar 14, 2024
1 parent 0c8a5ef commit 9cfb77d
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@types/lodash.isempty": "^4",
"@types/lodash.throttle": "^4",
"@types/node": "^20",
"@types/uuid": "^9",
"@types/xml2js": "^0",
"@uportal/open-id-connect": "^1.40.2",
"@vitejs/plugin-vue": "^5.0.4",
Expand All @@ -74,6 +75,7 @@
"sass": "^1.71.1",
"standard-version": "^9.5.0",
"typescript": "~5.4.2",
"uuid": "^9.0.1",
"vite": "^5.1.5",
"vite-plugin-vuetify": "^2.0.3",
"vitest": "^1.3.1",
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/fr/recia/collabsoft/db/entity/File.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package fr.recia.collabsoft.db.entity;

import lombok.AllArgsConstructor;
import lombok.Generated;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
Expand All @@ -38,6 +39,7 @@
import java.util.Calendar;
import java.util.Date;
import java.util.Objects;
import java.util.UUID;

@Entity
@Getter
Expand All @@ -55,6 +57,10 @@ public class File implements Serializable {
@ToString.Include
private Long id;

@Column(name = "uuid", nullable = false)
@ToString.Include
private String uuid;

@Column(name = "title", nullable = false)
@ToString.Include
private String title;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/fr/recia/collabsoft/service/db/FileService.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Slf4j
@Service
Expand Down Expand Up @@ -118,6 +119,7 @@ public File saveFile(JsonFileBody body) {
if (associatedApp == null) return null;

File file = new File();
file.setUuid(UUID.randomUUID().toString());
file.setTitle(body.getTitle());
file.setDescription(body.getDescription());
file.setBlob(body.getBlob().getBytes());
Expand Down
1 change: 1 addition & 0 deletions src/main/webapp/src/types/fileType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { User } from '@/types/userType.ts';

export type File = {
id: number;
uuid: string;
title: string;
description: string | null;
blob: any;
Expand Down
13 changes: 7 additions & 6 deletions src/test/java/fr/recia/collabsoft/test/DatabaseUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.UUID;

public class DatabaseUtils {

Expand Down Expand Up @@ -141,27 +142,27 @@ public void initDatabase() {
userRepository.saveAllAndFlush(List.of(user1, user2, user3));

final File file1 = new File(
file1Id, "file1", null, "".getBytes(), user1, null, user1, null,
file1Id, UUID.randomUUID().toString(), "file1", null, "".getBytes(), user1, null, user1, null,
associatedApp1, false
);
final File file2 = new File(
file2Id, "file2", null, "".getBytes(), user1, null, user1, null,
file2Id, UUID.randomUUID().toString(), "file2", null, "".getBytes(), user1, null, user1, null,
associatedApp1, false
);
final File file3 = new File(
file3Id, "file3", null, "".getBytes(), user2, null, user2, null,
file3Id, UUID.randomUUID().toString(), "file3", null, "".getBytes(), user2, null, user2, null,
associatedApp1, false
);
final File file4 = new File(
file4Id, "file4", null, "".getBytes(), user2, null, user2, null,
file4Id, UUID.randomUUID().toString(), "file4", null, "".getBytes(), user2, null, user2, null,
associatedApp1, true
);
final File file5 = new File(
file5Id, "file5", null, "".getBytes(), user3, null, user3, null,
file5Id, UUID.randomUUID().toString(), "file5", null, "".getBytes(), user3, null, user3, null,
associatedApp1, false
);
final File file6 = new File(
file6Id, "file6", null, "".getBytes(), user3, null, user3, null,
file6Id, UUID.randomUUID().toString(), "file6", null, "".getBytes(), user3, null, user3, null,
associatedApp1, false
);
fileRepository.saveAllAndFlush(List.of(file1, file2, file3, file4, file5, file6));
Expand Down
18 changes: 18 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,13 @@ __metadata:
languageName: node
linkType: hard

"@types/uuid@npm:^9":
version: 9.0.8
resolution: "@types/uuid@npm:9.0.8"
checksum: 10/b8c60b7ba8250356b5088302583d1704a4e1a13558d143c549c408bf8920535602ffc12394ede77f8a8083511b023704bc66d1345792714002bfa261b17c5275
languageName: node
linkType: hard

"@types/web-bluetooth@npm:^0.0.20":
version: 0.0.20
resolution: "@types/web-bluetooth@npm:0.0.20"
Expand Down Expand Up @@ -2143,6 +2150,7 @@ __metadata:
"@types/lodash.isempty": "npm:^4"
"@types/lodash.throttle": "npm:^4"
"@types/node": "npm:^20"
"@types/uuid": "npm:^9"
"@types/xml2js": "npm:^0"
"@uportal/open-id-connect": "npm:^1.40.2"
"@vitejs/plugin-vue": "npm:^5.0.4"
Expand Down Expand Up @@ -2171,6 +2179,7 @@ __metadata:
sass: "npm:^1.71.1"
standard-version: "npm:^9.5.0"
typescript: "npm:~5.4.2"
uuid: "npm:^9.0.1"
vite: "npm:^5.1.5"
vite-plugin-vuetify: "npm:^2.0.3"
vitest: "npm:^1.3.1"
Expand Down Expand Up @@ -6750,6 +6759,15 @@ __metadata:
languageName: node
linkType: hard

"uuid@npm:^9.0.1":
version: 9.0.1
resolution: "uuid@npm:9.0.1"
bin:
uuid: dist/bin/uuid
checksum: 10/9d0b6adb72b736e36f2b1b53da0d559125ba3e39d913b6072f6f033e0c87835b414f0836b45bcfaf2bdf698f92297fea1c3cc19b0b258bc182c9c43cc0fab9f2
languageName: node
linkType: hard

"validate-npm-package-license@npm:^3.0.1":
version: 3.0.4
resolution: "validate-npm-package-license@npm:3.0.4"
Expand Down

0 comments on commit 9cfb77d

Please sign in to comment.