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

Product List #31

Merged
merged 50 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a084586
[Backend] Add product, category and attribute model & controller
jerzabek Apr 18, 2024
7079dc0
[Backend] Added Category rest api
jerzabek Apr 27, 2024
1cdfd87
[Backend] Added thumbnail to products
jerzabek Apr 27, 2024
fd081f2
[Frontend] Add products page
jerzabek Apr 28, 2024
58ddd59
[Frontend] Add Product & category model & api
jerzabek Apr 28, 2024
c3d8ec1
[Frontend] Product list page, model, reducer
jerzabek Apr 28, 2024
6c2ab11
[Frontend] WIP product page
jerzabek Apr 28, 2024
177f093
[Backend] Added localhost origin
jerzabek Apr 29, 2024
4e1df5b
[Backend] forgot the port
jerzabek Apr 29, 2024
a48bd2c
[Frontend] Rm suspense for SSR
jerzabek Apr 29, 2024
0393ba7
[Frontend] Added pagination
jerzabek Apr 29, 2024
3bdf619
[Frontend] Filter by price
jerzabek Apr 29, 2024
1dc82b6
[Backend] Create product API
jerzabek May 4, 2024
efa3fce
[Backend] Slugify
jerzabek May 4, 2024
3d598cd
[Backend] Attribute controller, correctly implemented views
jerzabek May 8, 2024
5ec698e
[Frontend] Added product sort by price
jerzabek May 1, 2024
b486dc9
[Frontend] Product attributes
jerzabek May 8, 2024
2b5eac7
[Backend] Image controller
jerzabek May 12, 2024
9b57e06
[Frontend] Product attribute options
jerzabek May 8, 2024
d058f0b
[Frontend] WIP product form
jerzabek May 8, 2024
bf1dacf
[Frontend] Edit product form
jerzabek May 12, 2024
cf09dfc
[Workflows:Backend] Add mapping to CDN dir
jerzabek May 12, 2024
7d72b0f
[Frontend] Fix eslint
jerzabek May 12, 2024
f929b81
[Docker:Frontend] Remove prettier from dockerignore
jerzabek May 12, 2024
17a0d87
[Frontend] Fix google fonts failing??
jerzabek May 12, 2024
14a3393
[Workflows] Update actions to v4, node 20
jerzabek May 12, 2024
a2f5323
[Frontend] Multiple select on product attribute options
jerzabek May 18, 2024
094c168
[Frontend:Product] Remove redundant listing
jerzabek May 18, 2024
8538f47
[Frontend:Product] Linking between edit and product page
jerzabek May 18, 2024
25a0bad
[Frontend] Migrate product form to product components
jerzabek May 18, 2024
bebae8a
[Frontend] fix exports
jerzabek May 18, 2024
2b6b645
[Frontend] Sizing
jerzabek May 19, 2024
374f636
[Frontend] Create product page
jerzabek May 19, 2024
cc7c3aa
[Backend:Product] Fix persisting product
jerzabek May 19, 2024
70cba8d
[Frontend] Add delete json
jerzabek May 19, 2024
a94f719
[Frontend:Product] Delete product
jerzabek May 19, 2024
4e93ba0
[Frontend] RM unused import
jerzabek May 19, 2024
1912325
[Backend:Images] UUID for name
jerzabek May 19, 2024
4f14582
[Backend:Product] Delete product
jerzabek May 19, 2024
cc9be11
[Frontend] Responsive
jerzabek May 19, 2024
a779783
[Frontend:Products] Edit product thumbnail
jerzabek May 19, 2024
6e0e070
[Backend:Product] Fix maybe need that persist too
jerzabek May 19, 2024
1b80cd0
[Backend:Product] Fix err
jerzabek May 19, 2024
431f8af
[Frontend] Next config update
jerzabek May 19, 2024
47cf5e4
[Frontend] Revalidate cache??? or smthng
jerzabek May 19, 2024
2853be3
[Frontend] Revalidate fetch tag
jerzabek May 19, 2024
3433013
[Frontend] Product list initial filter query
jerzabek May 20, 2024
d74b843
[Frontend] Labels
jerzabek May 20, 2024
8fb79cd
[Frontend] Google sign in rerender fix
jerzabek May 20, 2024
58c59b0
[Frontend] Design adjustment
jerzabek May 20, 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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ BACKEND_DATASOURCE_URL=jdbc:postgresql://pinehaus-database-staging:5432/database
BACKEND_DATASOURCE_USERNAME=admin
BACKEND_DATASOURCE_PASSWORD=123
GOOGLE_CLIENT_ID=id.apps.googleusercontent.com
IMAGE_PATH=C:\Users\jerza\Documents\code\test

FRONTEND_COOKIE_DOMAIN=localhost
FRONTEND_URL=https://localhost:3000
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/backend.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
runs-on: [self-hosted]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "corretto"
Expand All @@ -32,7 +32,7 @@ jobs:
maven-version: 3.9.6

- name: Set up the Maven dependencies caching
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Expand All @@ -52,7 +52,7 @@ jobs:
runs-on: [self-hosted]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup .env file
env:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/backend.staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
runs-on: [self-hosted]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "corretto"
Expand All @@ -32,7 +32,7 @@ jobs:
maven-version: 3.9.6

- name: Set up the Maven dependencies caching
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Expand All @@ -52,7 +52,7 @@ jobs:
runs-on: [self-hosted]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup .env file
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/frontend.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
runs-on: [self-hosted]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.17

Expand All @@ -42,7 +42,7 @@ jobs:
runs-on: [self-hosted]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup .env file
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/frontend.staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
runs-on: [self-hosted]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.17

Expand All @@ -43,7 +43,7 @@ jobs:
runs-on: [self-hosted]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup .env file
env:
Expand Down
3 changes: 3 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ WORKDIR /app

COPY --from=builder /app/target/*.jar app.jar

# Directory that is mapped to CDN on host machine
RUN mkdir -p /pinehaus/images

EXPOSE 8080

ENTRYPOINT ["java", "--enable-preview", "-jar", "app.jar" ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.pinehaus.backend.attribute.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.RequiredArgsConstructor;
import net.pinehaus.backend.attribute.model.Attribute;
import net.pinehaus.backend.attribute.service.AttributeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/attributes")
@Tag(name = "Product attributes")
@RequiredArgsConstructor
public class AttributeController {

private final AttributeService attributeService;

@GetMapping
public List<Attribute> getAllAttributes() {
return attributeService.getAllAttributes();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package net.pinehaus.backend.attribute.dto;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@RequiredArgsConstructor
public class AttributeValueDTO {

private int attributeId;
private String value;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package net.pinehaus.backend.attribute.model;

import com.fasterxml.jackson.annotation.JsonView;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import java.util.List;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;

@Entity
@RequiredArgsConstructor
@JsonView(AttributeViews.Public.class)
public class Attribute {

@Id
@Getter
@Setter
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;

@Setter
@Getter
@Column(nullable = false)
private String name;

@Setter
@Getter
@Column(nullable = false)
private AttributeType type;

/**
* Options for the attribute. Only used if the attribute type is ENUM. Contains a comma-separated
* list of options.
*/
@Column
private String options;

public List<String> getOptions() {
if (options == null) {
return null;
}

return List.of(options.split(","));
}

public void setOptions(List<String> options) {
this.options = String.join(",", options);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package net.pinehaus.backend.attribute.model;

public enum AttributeType {
ENUM, NUMBER, BOOLEAN, STRING
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package net.pinehaus.backend.attribute.model;

import com.fasterxml.jackson.annotation.JsonView;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.IdClass;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import java.io.Serializable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import net.pinehaus.backend.product.model.Product;

@Entity
@Getter
@Setter
@RequiredArgsConstructor
@IdClass(AttributeValue.AttributeValueId.class)
public class AttributeValue {

@Id
@ManyToOne
@JoinColumn
@JsonView(AttributeValueViews.Public.class)
private Attribute attribute;

@Id
@ManyToOne
@JoinColumn
private Product product;

@Column
@JsonView(AttributeValueViews.Public.class)
private String value;

@Getter
@Setter
@RequiredArgsConstructor
public static class AttributeValueId implements Serializable {

private int attribute;
private int product;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.pinehaus.backend.attribute.model;

public class AttributeValueViews {

public interface Public extends AttributeViews.Public {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.pinehaus.backend.attribute.model;

public class AttributeViews {

public interface Public {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package net.pinehaus.backend.attribute.repository;

import java.util.Optional;
import net.pinehaus.backend.attribute.model.Attribute;
import org.springframework.data.jpa.repository.JpaRepository;

public interface AttributeRepository extends JpaRepository<Attribute, Integer> {

Optional<Attribute> findById(int id);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package net.pinehaus.backend.attribute.repository;

import java.util.List;
import java.util.Optional;
import net.pinehaus.backend.attribute.model.Attribute;
import net.pinehaus.backend.attribute.model.AttributeValue;
import net.pinehaus.backend.product.model.Product;
import org.springframework.data.jpa.repository.JpaRepository;

public interface AttributeValueRepository extends
JpaRepository<AttributeValue, AttributeValue.AttributeValueId> {

void deleteByAttributeAndProduct(Attribute attribute, Product product);

void deleteByAttributeIdAndProductId(int attributeId, int productId);

Optional<AttributeValue> findByAttributeIdAndProductId(int attributeId, int productId);

List<AttributeValue> findByProductId(int productId);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package net.pinehaus.backend.attribute.service;

import java.util.List;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import net.pinehaus.backend.attribute.model.Attribute;
import net.pinehaus.backend.attribute.repository.AttributeRepository;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class AttributeService {

private final AttributeRepository attributeRepository;

public List<Attribute> getAllAttributes() {
return attributeRepository.findAll();
}

public Optional<Attribute> getById(int id) {
return attributeRepository.findById(id);
}

}
Loading