Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foodcoop Backend #5

Merged
merged 126 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
3390a93
Update README.md
Chemmic Nov 16, 2023
ae90bd0
Update README.md
Chemmic Nov 16, 2023
caa4dfc
einkauf start
Mar 8, 2024
edd9bca
Update pom.xml
Chemmic Mar 8, 2024
5f2b30c
added application.properties for test
Mar 8, 2024
97bc47b
Merge branch 'feature/swagger-ui' of https://github.com/FoodCoopV3/fo…
Mar 8, 2024
6c2e4de
added application properties
Mar 8, 2024
59ffeb7
changed from MariaDB to Mysql
Mar 11, 2024
c2de520
Added features for discrepancy + fixed shopping
Mar 12, 2024
f8268af
fixed Discrepancy entity
Mar 12, 2024
8d096ba
fixed issues
Mar 12, 2024
a857c4b
d
Mar 13, 2024
edc21a6
einkauf
Mar 13, 2024
64660a4
JPA fixes
Mar 13, 2024
433225f
test
Mar 13, 2024
a81cda8
test
Mar 13, 2024
3fd5524
u
Mar 13, 2024
f0e7066
fix
Mar 13, 2024
76760ac
fix
Mar 13, 2024
be1366f
fix
Mar 13, 2024
228b71e
test
Mar 13, 2024
727fa5d
json
Mar 13, 2024
b3cf810
new Server
Mar 21, 2024
6745626
switchec back to mariadb
Mar 21, 2024
0eb3b75
fixed DTOs
Mar 21, 2024
c7640d5
d
Mar 21, 2024
b837b8d
test
Mar 21, 2024
989a492
Einkauf
Mar 21, 2024
7a06ca9
fixed deadline + Product
Mar 23, 2024
9aabe3a
t
Mar 23, 2024
ce04caa
Fixed Deadline
Mar 25, 2024
9bda4a6
fixed Bestellung controller
Mar 25, 2024
0a0d1bf
Fixed for bread order
Mar 25, 2024
43530c5
fixes
Mar 30, 2024
f6fe28f
fixed BestandRepresentaion
Mar 30, 2024
03ef8ed
Fixed Gebindeproblem
Mar 30, 2024
996de0b
einkaufFix
Mar 31, 2024
0ba27c8
fixed Gebinde
Mar 31, 2024
ae49f50
updatedShopping
Mar 31, 2024
6293141
test
Mar 31, 2024
a59ce00
test
Mar 31, 2024
51ec532
fixing Einkauf
Mar 31, 2024
98b2fc7
d
Mar 31, 2024
238395c
updated Gebindeproblem
Mar 31, 2024
26758e4
uebersicht Controller added
Mar 31, 2024
0dec35f
added Email
Apr 1, 2024
864613f
fixed email stuff
Apr 1, 2024
036012b
t
Apr 1, 2024
f6742b4
email
Apr 1, 2024
e364f58
controller for zuVielzuWenig
Apr 3, 2024
1c18e24
startet added brot
Apr 3, 2024
d2dbbeb
added admin config
Apr 4, 2024
d4e7e82
made BestandRepresentation abstract
Apr 4, 2024
3808294
fixed Timestamp + Deadline
Apr 4, 2024
1999350
fixed timezone
Apr 4, 2024
df42a30
new Controller to edit gebinde Amount
Apr 5, 2024
28039a8
added db init
Apr 8, 2024
b48d530
Update prices of bread in DatenbankInitalizer
eileen522 Apr 8, 2024
78d4d66
versuch pdf erstellung
Apr 8, 2024
335ea1e
pdf stuff and handling auto discrepancy update on checkout
Apr 15, 2024
ae1ae30
added setDone for done bestellungen
Apr 15, 2024
86a9963
done check
Apr 15, 2024
07e56d9
fixed shopping bug
Apr 15, 2024
bb32cf5
potentional einkauf fix
Apr 15, 2024
406d162
debugging
Apr 15, 2024
2ddf2c6
fix
Apr 15, 2024
0947fb7
added done later
Apr 15, 2024
c26423b
fix
Apr 15, 2024
4c38f70
potentionalk fix
Apr 16, 2024
599e08a
test
Apr 16, 2024
6b6dbd1
fixing mapper
Apr 16, 2024
f6966d2
fixing repo
Apr 16, 2024
e408168
fix
Apr 16, 2024
00ecf9e
added tooMuchBuy
Apr 16, 2024
8230aa7
fixed done attribute
Apr 16, 2024
276dd3d
Fixing overview
Apr 17, 2024
ea9f3ec
fixing zuViel einkauf
Apr 18, 2024
01ff08c
adding new controller for PDF download + sending per Email
Apr 18, 2024
0ac1a5e
added zuViel for pdfs
Apr 19, 2024
fa485ed
fixing pdf
Apr 19, 2024
800e752
Fix for files not loaded from classpath
Apr 21, 2024
c6d2e83
fixing bug
Apr 21, 2024
aa433fb
fixing bestelluebersicht
Apr 21, 2024
1ab8941
f
Apr 21, 2024
c926c1f
f
Apr 21, 2024
cf07684
Fixed bug in repo
Apr 21, 2024
8ec6eb7
changed auto update algo
Apr 22, 2024
10aee8f
test
Apr 22, 2024
dcb3150
pdf as byte
Apr 22, 2024
7dc7486
added total order Amount to pdf + Verband
Apr 22, 2024
c3cb0d1
special case added
Apr 22, 2024
a1ea9b2
Fixed pdf
Apr 22, 2024
84b1cac
Fixing order cost
Apr 23, 2024
5ecc041
fixed order cost
Apr 23, 2024
835863b
another fix
Apr 23, 2024
8c57355
added deliverycost save
Apr 23, 2024
96d6422
Merge pull request #1 from FoodCoopV3/feature/swagger-ui
Chemmic Apr 23, 2024
a15cb71
Making Foodcoop Backend ready for production
Apr 23, 2024
4daaddb
test port set
Apr 23, 2024
c2ed4af
Update Dockerfile
Chemmic Apr 23, 2024
ec51c2f
Update Dockerfile
Chemmic Apr 23, 2024
4a73f44
fix
Apr 25, 2024
2d5a9ba
Merge branch 'feature/swagger-ui' of https://github.com/FoodCoopV3/fo…
Apr 25, 2024
e35eb54
Merge pull request #2 from FoodCoopV3/feature/swagger-ui
Chemmic Apr 25, 2024
edf260a
Update application.properties
Chemmic Apr 25, 2024
8a479a1
fixing
Apr 25, 2024
5c7d8b4
Merge pull request #3 from FoodCoopV3/feature/swagger-ui
Chemmic Apr 25, 2024
cd71204
added new config options
Apr 27, 2024
ca8ef2c
added new controller for Einkaufsmanagement
Apr 27, 2024
3f9eaf8
changed zuBestellendeGebinde to double
Apr 27, 2024
dbfca61
added new controller for mails
Apr 29, 2024
0b666e5
fixed sql
Apr 29, 2024
831363a
minor fixes
Apr 30, 2024
d292088
Email anpassen
Apr 30, 2024
c9cc1ea
Merge pull request #4 from FoodCoopV3/feature/swagger-ui
Chemmic Apr 30, 2024
c3d0b0d
ShopperPersonId added
Apr 30, 2024
5adfff4
Update ConstantsUtils.java
Chemmic Apr 30, 2024
06da668
test for pdf
May 2, 2024
0965b96
fix
May 2, 2024
0a69525
test
May 2, 2024
5a3d9f2
potentional fix
May 2, 2024
94b3de5
final changes
May 14, 2024
63a33b5
Update README.md
Chemmic May 23, 2024
c0456e9
controllers changed
May 23, 2024
9b22136
Merge pull request #5 from FoodCoopV3/feature/swagger-ui
Chemmic May 23, 2024
c31c971
Tests for Gebindealgorithmus
Chemmic May 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ syntax: glob
/*/target/*
/*/*.iml
/*.iml
/*/*/*/*/application.properties
.classpath
.project
org.*
application.properties
17 changes: 13 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
FROM adoptopenjdk/openjdk11:alpine-jre
ARG JAR_FILE=/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
FROM maven:3.6.3-jdk-11-slim AS build
WORKDIR /home/app

# Kopiere das gesamte Projektverzeichnis
COPY . .

# Baue das Projekt mit Maven Wrapper
RUN mvn clean install -DskipTests

# Verwende das offizielle OpenJDK Image, um die Jar auszuführen
FROM openjdk:11-jre-slim
COPY --from=build /home/app/plugins/target/*.jar /usr/local/lib/app.jar
ENTRYPOINT ["java","-jar","/usr/local/lib/app.jar"]
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,82 @@
Food-coop warehouse management software.


## Instructions for local setup

If you want to setup the Backend for your localhost you need to create an application.properties in plugins/src/main/resources and you need a local Keycloak & MariaDB instance.<br>
In the application.properties you have to define your MariaDB Datasource and Keycloak instance.<br>
This is needed because for production the application.properties is created & written to via GitHub Actions (see [GitHub workflows](https://github.com/FoodCoopV3/foodcoops-backend/blob/main/.github/workflows/ssh_deployment.yml))<br>
The reason for this is, that the private Data of the official Keycloak/MariaDB instances like passwords, secrets etc. is not exposed in the propertie file and is being filled in when build by GitHub Actions.<br>
An example applications.properties could look like this:
```java
spring.datasource.url=jdbc:mariadb://{ip_of_db}:3306/{dbname}
spring.datasource.username={username}
spring.datasource.password={password}
spring.datasource.driver−class−name=org.mariadb.jdbc.Driver
spring.jpa.hibernate.ddl−auto=none
spring.jpa.generate−ddl=true
spring.datasource.initialization−mode=always
spring.jpa.show−sql=true
server.port=8081

keycloak.realm={Realm Name}
keycloak.auth−server−url=http://{keycloak_ip}:{port}/
keycloak.ssl−required=none
keycloak.credentials.secret={Client Secrent}
keycloak.use−resource−role−mappings = true
keycloak.resource={Client Name}

spring.mail.host=smtp.ionos.de
spring.mail.port=587
spring.mail.username=foodcoop@orat.de
spring.mail.password={password}
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
```
(@Oliver got the mail password, Keycloak + db have to be setup before)

If you want to setup Keycloak etc you can use the following docker-compose.yml

```
version: '1'
services:
frontend:
image: frontend
restart: always
volumes:
- nginx_cfg:/etc/nginx/conf.d
ports:
- 80:80
keycloak:
image: quay.io/keycloak/keycloak:19.0.1
restart: always
ports:
- 8089:8080
volumes:
- /root/foodcoop/keycloak_data/dataTest:/opt/jboss/keycloak/standalone/data/
environment:
- KEYCLOAK_ADMIN={admin username}
- KC_HTTP_ENABLED=true
- KEYCLOAK_ADMIN_PASSWORD={admin passwort}
- DB_VENDOR=mariadb
- KC_DB=mariadb
- KC_DB_USERNAME={db username}
- KC_DB_PASSWORD={db passwort}
- KC_DB_URL=jdbc:mariadb://{ip}:3306/{dbname}?allowPublicKeyRetrieval=true&useSSL=FALSE
command:
- start-dev
app:
image: foodcoops-backend
restart: always
ports:
- "8080:8080"
volumes:
nginx_cfg:
```
Change Keycloak http enabled to false asap. (after you added https support.)
MariaDB is NOT included, checkout the paper for the reason & how to set it up.

After setup, swagger is running at: http://{server ip}:8080/swagger-ui/
## Installing, starting and stopping the application

Food-coop warehouse comes prepackaged with its maven wrapper. Go to the project directory.<br>
Expand Down
42 changes: 42 additions & 0 deletions abstraction/bin/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>warehouse</artifactId>
<groupId>de.dhbw.foodcoop</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>abstraction</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<debug>true</debug>
<release>11</release>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
49 changes: 49 additions & 0 deletions abstraction/bin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>warehouse</artifactId>
<groupId>de.dhbw.foodcoop</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>abstraction</artifactId>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<debug>true</debug>
<release>11</release>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.4</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
</dependencies>


</project>
18 changes: 18 additions & 0 deletions abstraction/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,25 @@
<artifactId>spring-context</artifactId>
<version>5.3.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.13.0</version>
</dependency>

<!-- Jackson Annotations -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.13.0</version>
</dependency>

<!-- Jackson Databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package de.dhbw.foodcoop.warehouse.adapters.representations;

public class BestandBuyRepresentation {

private String id;
private ProduktRepresentation bestand;
private double amount;
public BestandBuyRepresentation(String id, ProduktRepresentation bestand, double amount) {
super();
this.id = id;
this.bestand = bestand;
this.amount = amount;
}

public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public ProduktRepresentation getBestand() {
return bestand;
}
public void setBestand(ProduktRepresentation bestand) {
this.bestand = bestand;
}
public double getAmount() {
return amount;
}
public void setAmount(double amount) {
this.amount = amount;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package de.dhbw.foodcoop.warehouse.adapters.representations;

import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

import de.dhbw.foodcoop.warehouse.domain.entities.BrotBestand;
import de.dhbw.foodcoop.warehouse.domain.entities.FrischBestand;
import de.dhbw.foodcoop.warehouse.domain.entities.Produkt;

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = FrischBestandRepresentation.class, name = "frisch"),
@JsonSubTypes.Type(value = BrotBestandRepresentation.class, name ="brot"),
@JsonSubTypes.Type(value = ProduktRepresentation.class, name="lager")
// Andere Subtypen hier
})
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class BestandRepresentation {
protected String id;
protected String name;
private boolean verfuegbarkeit;
private float preis;

public BestandRepresentation(String id, String name, boolean verfuegbarkeit, float preis) {
this.id = id;
this.name = name;
this.verfuegbarkeit = verfuegbarkeit;
this.preis = preis;
}

public BestandRepresentation() {
// TODO Auto-generated constructor stub
}
public String getId() {
return id;
}

public String getName() {
return name;
}

public boolean getVerfuegbarkeit() {
return verfuegbarkeit;
}



public float getPreis() {
return preis;
}

public void setId(String id) {
this.id = id;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package de.dhbw.foodcoop.warehouse.adapters.representations;

public class BestellungBuyRepresentation {
private String id;
private BestellungRepresentation bestellung;
private double amount;
public BestellungBuyRepresentation(String id, BestellungRepresentation bestellung, double amount) {
super();
this.id = id;
this.bestellung = bestellung;
this.amount = amount;
}

public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}



public BestellungRepresentation getBestellung() {
return bestellung;
}

public void setBestellung(BestellungRepresentation bestellung) {
this.bestellung = bestellung;
}

public double getAmount() {
return amount;
}
public void setAmount(double amount) {
this.amount = amount;
}

}
Loading
Loading