-
Notifications
You must be signed in to change notification settings - Fork 13
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
1 parent
8189036
commit ec392a6
Showing
9 changed files
with
188 additions
and
1 deletion.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
backend/src/main/java/ch/xxx/aidoclibchat/adapter/repository/ImageRepositoryBean.java
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,52 @@ | ||
/** | ||
* Copyright 2023 Sven Loesekann | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package ch.xxx.aidoclibchat.adapter.repository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
import org.springframework.stereotype.Repository; | ||
|
||
import ch.xxx.aidoclibchat.domain.model.entity.Image; | ||
import ch.xxx.aidoclibchat.domain.model.entity.ImageRepository; | ||
|
||
@Repository | ||
public class ImageRepositoryBean implements ImageRepository { | ||
private final JpaImageRepository jpaImageRepository; | ||
|
||
public ImageRepositoryBean(JpaImageRepository jpaImageRepository) { | ||
this.jpaImageRepository = jpaImageRepository; | ||
} | ||
|
||
@Override | ||
public Optional<Image> findById(UUID id) { | ||
return this.findById(id); | ||
} | ||
|
||
@Override | ||
public Image save(Image document) { | ||
return this.jpaImageRepository.save(document); | ||
} | ||
|
||
@Override | ||
public List<Image> findAll() { | ||
return this.jpaImageRepository.findAll(); | ||
} | ||
|
||
@Override | ||
public List<Image> findAllById(Iterable<UUID> ids) { | ||
return this.jpaImageRepository.findAllById(ids); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
backend/src/main/java/ch/xxx/aidoclibchat/adapter/repository/JpaImageRepository.java
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,23 @@ | ||
/** | ||
* Copyright 2023 Sven Loesekann | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package ch.xxx.aidoclibchat.adapter.repository; | ||
|
||
import java.util.UUID; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import ch.xxx.aidoclibchat.domain.model.entity.Image; | ||
|
||
public interface JpaImageRepository extends JpaRepository<Image, UUID> { | ||
|
||
} |
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
61 changes: 61 additions & 0 deletions
61
backend/src/main/java/ch/xxx/aidoclibchat/domain/model/entity/Image.java
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,61 @@ | ||
/** | ||
* Copyright 2023 Sven Loesekann | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package ch.xxx.aidoclibchat.domain.model.entity; | ||
|
||
import java.util.UUID; | ||
|
||
import ch.xxx.aidoclibchat.domain.common.MetaData.ImageType; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Lob; | ||
|
||
@Entity | ||
public class Image { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.UUID) | ||
private UUID id; | ||
private String imageName; | ||
@Enumerated(EnumType.STRING) | ||
private ImageType imageType; | ||
@Lob | ||
private byte[] imageContent; | ||
|
||
public UUID getId() { | ||
return id; | ||
} | ||
public void setId(UUID id) { | ||
this.id = id; | ||
} | ||
public String getImageName() { | ||
return imageName; | ||
} | ||
public void setImageName(String imageName) { | ||
this.imageName = imageName; | ||
} | ||
public ImageType getImageType() { | ||
return imageType; | ||
} | ||
public void setImageType(ImageType imageType) { | ||
this.imageType = imageType; | ||
} | ||
public byte[] getImageContent() { | ||
return imageContent; | ||
} | ||
public void setImageContent(byte[] imageContent) { | ||
this.imageContent = imageContent; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
backend/src/main/java/ch/xxx/aidoclibchat/domain/model/entity/ImageRepository.java
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,24 @@ | ||
/** | ||
* Copyright 2023 Sven Loesekann | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package ch.xxx.aidoclibchat.domain.model.entity; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
public interface ImageRepository { | ||
Optional<Image> findById(UUID id); | ||
Image save(Image document); | ||
List<Image> findAll(); | ||
List<Image> findAllById(Iterable<UUID> ids); | ||
} |
24 changes: 24 additions & 0 deletions
24
backend/src/main/resources/dbchangelog/changes/db.changelog-3.xml
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,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- Copyright 2019 Sven Loesekann Licensed under the Apache License, Version | ||
2.0 (the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed | ||
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
OR CONDITIONS OF ANY KIND, either express or implied. See the License for | ||
the specific language governing permissions and limitations under the License. --> | ||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd"> | ||
<changeSet author="angular2guy" id="19"> | ||
<createTable tableName="image"> | ||
<column name="id" type="uuid"> | ||
<constraints primaryKey="true" /> | ||
</column> | ||
<column name="image_name" type="varchar(120)" /> | ||
<column name="image_type" type="varchar(10)" /> | ||
<column name="image_content" type="blob" /> | ||
</createTable> | ||
</changeSet> | ||
</databaseChangeLog> |
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