Compare commits
43 Commits
fdee6ecc84
...
MailSender
| Author | SHA1 | Date | |
|---|---|---|---|
| 62a5ad1bc6 | |||
| 8ea5d84779 | |||
| a09603f8cb | |||
| 45c607060a | |||
| 0b85fed4b8 | |||
| d2163e1601 | |||
| f4c8177270 | |||
|
|
9b64dc8da8 | ||
|
|
12cb37127b | ||
|
|
281cc627de | ||
|
|
6363f966f6 | ||
|
|
c642f6f87b | ||
|
|
65524d0f25 | ||
|
|
71fdf1640a | ||
| 8fae9f1e55 | |||
| d869a18901 | |||
|
|
1d55f40753 | ||
| 3d205df038 | |||
|
|
5ccfc6ba2c | ||
|
|
f0e3a129d0 | ||
|
|
cdd31fd6b7 | ||
| 09c15e70d9 | |||
| 3b85b12741 | |||
| 039678b90a | |||
| 025f733362 | |||
| c2f74ab799 | |||
| bf565178f6 | |||
| 7f8f13b115 | |||
| 6b5dded7f8 | |||
| a3d3a01d3a | |||
| 4b5baaa7e3 | |||
| b25bd3dbe9 | |||
| 8fc8473962 | |||
| e60f959dfb | |||
| ba7e82e90c | |||
| f17b97eaf9 | |||
| b0f47b475a | |||
| 4fa138203d | |||
| b826a01a10 | |||
| 686e580f03 | |||
| 4c6d3f9452 | |||
| 01d531aa23 | |||
| f65b10b302 |
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
FROM openjdk:21
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY target/ArtisanConnectBackend-0.0.1-SNAPSHOT.jar app/artisan.jar
|
||||||
|
|
||||||
|
ENTRYPOINT ["java","-jar","app/artisan.jar"]
|
||||||
23
compose.yaml
23
compose.yaml
@@ -1,9 +1,28 @@
|
|||||||
services:
|
services:
|
||||||
postgres:
|
app:
|
||||||
|
container_name: artisan
|
||||||
|
build: .
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
networks:
|
||||||
|
- artisan_network
|
||||||
|
ports:
|
||||||
|
- '8085:8080'
|
||||||
|
|
||||||
|
|
||||||
|
db:
|
||||||
|
container_name: db
|
||||||
image: 'postgres:latest'
|
image: 'postgres:latest'
|
||||||
environment:
|
environment:
|
||||||
- 'POSTGRES_DB=default'
|
- 'POSTGRES_DB=postgres'
|
||||||
- 'POSTGRES_PASSWORD=postgres'
|
- 'POSTGRES_PASSWORD=postgres'
|
||||||
- 'POSTGRES_USER=postgres'
|
- 'POSTGRES_USER=postgres'
|
||||||
ports:
|
ports:
|
||||||
- '5432:5432'
|
- '5432:5432'
|
||||||
|
networks:
|
||||||
|
- artisan_network
|
||||||
|
|
||||||
|
networks:
|
||||||
|
artisan_network:
|
||||||
|
name: artisan_net
|
||||||
|
external: false
|
||||||
44
pom.xml
44
pom.xml
@@ -10,7 +10,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<groupId>_11.asktpk</groupId>
|
<groupId>_11.asktpk</groupId>
|
||||||
<artifactId>ArtisanConnectBackend</artifactId>
|
<artifactId>ArtisanConnectBackend</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>1.0.0</version>
|
||||||
<name>ArtisanConnectBackend</name>
|
<name>ArtisanConnectBackend</name>
|
||||||
<description>ArtisanConnectBackend</description>
|
<description>ArtisanConnectBackend</description>
|
||||||
<url/>
|
<url/>
|
||||||
@@ -34,31 +34,16 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-rest</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
|
||||||
<!-- <artifactId>spring-boot-starter-oauth2-client</artifactId>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-devtools</artifactId>
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
|
||||||
<!-- <artifactId>spring-boot-docker-compose</artifactId>-->
|
|
||||||
<!-- <scope>runtime</scope>-->
|
|
||||||
<!-- <optional>true</optional>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.postgresql</groupId>
|
<groupId>org.postgresql</groupId>
|
||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
@@ -73,16 +58,31 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>org.springframework.security</groupId>-->
|
|
||||||
<!-- <artifactId>spring-security-test</artifactId>-->
|
|
||||||
<!-- <scope>test</scope>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
<artifactId>okhttp</artifactId>
|
<artifactId>okhttp</artifactId>
|
||||||
<version>4.9.3</version>
|
<version>4.12.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.validation</groupId>
|
||||||
|
<artifactId>jakarta.validation-api</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
|
<version>3.3.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -1,13 +1,27 @@
|
|||||||
package _11.asktpk.artisanconnectbackend;
|
package _11.asktpk.artisanconnectbackend;
|
||||||
|
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class ArtisanConnectBackendApplication {
|
public class ArtisanConnectBackendApplication {
|
||||||
|
|
||||||
|
private final Environment environment;
|
||||||
|
|
||||||
|
public ArtisanConnectBackendApplication(Environment environment) {
|
||||||
|
this.environment = environment;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(ArtisanConnectBackendApplication.class, args);
|
SpringApplication.run(ArtisanConnectBackendApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void logDataSourceUrl() {
|
||||||
|
System.out.println("Datasource URL: " + environment.getProperty("spring.datasource.url"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
package _11.asktpk.artisanconnectbackend.Controller;
|
|
||||||
|
|
||||||
import _11.asktpk.artisanconnectbackend.Model.Notice;
|
|
||||||
import _11.asktpk.artisanconnectbackend.Repository.NoticeRepository;
|
|
||||||
import _11.asktpk.artisanconnectbackend.Service.PostgresDatabase;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RequestMapping("/api/v1")
|
|
||||||
@RestController
|
|
||||||
public class ArtisanConnectController {
|
|
||||||
@Autowired
|
|
||||||
private PostgresDatabase postgresDatabase;
|
|
||||||
|
|
||||||
@GetMapping("/notices/all")
|
|
||||||
public List<Notice> getAllNotices() {
|
|
||||||
return postgresDatabase.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ResponseStatus(HttpStatus.CREATED)
|
|
||||||
@PostMapping("/notices/add")
|
|
||||||
public void addNotice(@RequestBody Notice notice) {
|
|
||||||
postgresDatabase.add(notice);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package _11.asktpk.artisanconnectbackend.Model;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.sql.Blob;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
public class Notice {
|
|
||||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Column
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
@Column
|
|
||||||
private String username;
|
|
||||||
|
|
||||||
@Column
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
public Notice() {
|
|
||||||
this.title = "";
|
|
||||||
this.username = "";
|
|
||||||
this.description = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Notice(String nTitle, String nUsername, String nDescription) {
|
|
||||||
this.title = nTitle;
|
|
||||||
this.username = nUsername;
|
|
||||||
this.description = nDescription;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsername(String user) {
|
|
||||||
this.username = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package _11.asktpk.artisanconnectbackend.Repository;
|
|
||||||
|
|
||||||
import _11.asktpk.artisanconnectbackend.Model.Notice;
|
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
|
|
||||||
public interface NoticeRepository extends JpaRepository<Notice, Long> {
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package _11.asktpk.artisanconnectbackend.Service;
|
|
||||||
|
|
||||||
import _11.asktpk.artisanconnectbackend.Model.Notice;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface IDatabase {
|
|
||||||
void add(Notice newNotice);
|
|
||||||
List<Notice> get();
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package _11.asktpk.artisanconnectbackend.Service;
|
|
||||||
|
|
||||||
import _11.asktpk.artisanconnectbackend.Model.Notice;
|
|
||||||
import _11.asktpk.artisanconnectbackend.Repository.NoticeRepository;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class PostgresDatabase implements IDatabase{
|
|
||||||
@Autowired
|
|
||||||
private NoticeRepository noticeRepository;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void add(Notice newNotice) {
|
|
||||||
noticeRepository.save(newNotice);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Notice> get() {
|
|
||||||
return noticeRepository.findAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.config;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.RequestResponseDTO;
|
||||||
|
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import jakarta.servlet.RequestDispatcher;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class CustomErrorController implements ErrorController {
|
||||||
|
|
||||||
|
@RequestMapping("/error")
|
||||||
|
public ResponseEntity<RequestResponseDTO> handleError(HttpServletRequest request) {
|
||||||
|
Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
|
||||||
|
|
||||||
|
if (status != null) {
|
||||||
|
int statusCode = Integer.parseInt(status.toString());
|
||||||
|
|
||||||
|
if (statusCode == HttpStatus.NOT_FOUND.value()) {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||||
|
.body(new RequestResponseDTO("Nie znaleziono zasobu. Sprawdź URL i spróbuj ponownie."));
|
||||||
|
} else if (statusCode == HttpStatus.INTERNAL_SERVER_ERROR.value()) {
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||||
|
.body(new RequestResponseDTO("Wystąpił wewnętrzny błąd serwera. Spróbuj ponownie później."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||||
|
.body(new RequestResponseDTO("Wystąpił nieoczekiwany błąd."));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.service.ClientService;
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.ClientDTO;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/clients")
|
||||||
|
public class ClientController {
|
||||||
|
private final ClientService clientService;
|
||||||
|
|
||||||
|
public ClientController(ClientService clientService) {
|
||||||
|
this.clientService = clientService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get/all")
|
||||||
|
public List<ClientDTO> getAllClients() {
|
||||||
|
return clientService.getAllClients();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get/{id}")
|
||||||
|
public ResponseEntity getClientById(@PathVariable long id) {
|
||||||
|
if(clientService.getClientById(id) != null) {
|
||||||
|
return new ResponseEntity(clientService.getClientById(id), HttpStatus.OK);
|
||||||
|
} else {
|
||||||
|
return new ResponseEntity(HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/add")
|
||||||
|
public ResponseEntity addClient(@RequestBody ClientDTO clientDTO) {
|
||||||
|
if(clientService.clientExists(clientDTO.getId())) {
|
||||||
|
return new ResponseEntity<>(HttpStatus.CONFLICT);
|
||||||
|
} else {
|
||||||
|
return new ResponseEntity<>(clientService.addClient(clientDTO), HttpStatus.CREATED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: do zrobienia walidacja danych
|
||||||
|
@PutMapping("/edit/{id}")
|
||||||
|
public ResponseEntity updateClient(@PathVariable("id") long id, @RequestBody ClientDTO clientDTO) {
|
||||||
|
if(clientService.clientExists(id)) {
|
||||||
|
return new ResponseEntity<>(clientService.updateClient(id, clientDTO),HttpStatus.OK);
|
||||||
|
} else {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete/{id}")
|
||||||
|
public ResponseEntity deleteClient(@PathVariable("id") long id) {
|
||||||
|
if(clientService.clientExists(id)) {
|
||||||
|
clientService.deleteClient(id);
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
} else {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.controller;
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.EmailDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.service.EmailService;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/email")
|
||||||
|
public class EmailController {
|
||||||
|
private final EmailService emailService;
|
||||||
|
|
||||||
|
public EmailController(EmailService emailService) {
|
||||||
|
this.emailService = emailService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/send")
|
||||||
|
public ResponseEntity<String> sendEmail(@RequestBody EmailDTO email) {
|
||||||
|
try {
|
||||||
|
emailService.sendEmail(email);
|
||||||
|
return ResponseEntity.ok("Email wysłany pomyślnie");
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(500).body("Błąd podczas wysyłania emaila");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.controller;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.RequestResponseDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.service.ImageService;
|
||||||
|
import _11.asktpk.artisanconnectbackend.service.NoticeService;
|
||||||
|
import jakarta.persistence.EntityNotFoundException;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/images")
|
||||||
|
public class ImageController {
|
||||||
|
|
||||||
|
private final ImageService imageService;
|
||||||
|
private final NoticeService noticeService;
|
||||||
|
ImageController(ImageService imageService, NoticeService noticeService) {
|
||||||
|
this.imageService = imageService;
|
||||||
|
this.noticeService = noticeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Value("${file.upload-dir}")
|
||||||
|
private String uploadDir;
|
||||||
|
|
||||||
|
@PostMapping("/upload/{id}")
|
||||||
|
public ResponseEntity<RequestResponseDTO> uploadImage(@RequestParam("file") MultipartFile file, @PathVariable("id") Long noticeId) {
|
||||||
|
try {
|
||||||
|
if(file.isEmpty()) {
|
||||||
|
return ResponseEntity.badRequest().body(new RequestResponseDTO("File is empty"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!Objects.equals(file.getContentType(), "image/jpeg") && !Objects.equals(file.getContentType(), "image/png")) {
|
||||||
|
return ResponseEntity.badRequest().body(new RequestResponseDTO("File must be a JPEG or PNG image."));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(noticeId == null || !noticeService.noticeExists(noticeId)) {
|
||||||
|
return ResponseEntity.badRequest().body(new RequestResponseDTO("Notice ID is invalid or does not exist."));
|
||||||
|
}
|
||||||
|
|
||||||
|
String newImageName = imageService.saveImageToStorage(uploadDir, file);
|
||||||
|
imageService.addImageNameToDB(newImageName, noticeId);
|
||||||
|
|
||||||
|
return ResponseEntity.ok(new RequestResponseDTO("Image uploaded successfully with new name: " + newImageName));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.UNSUPPORTED_MEDIA_TYPE).body(new RequestResponseDTO(e.getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get/{filename}")
|
||||||
|
public ResponseEntity<Resource> getImage(@PathVariable String filename) {
|
||||||
|
try {
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.contentType(MediaType.IMAGE_JPEG)
|
||||||
|
.body(imageService.getImage(uploadDir, filename));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list/{id}")
|
||||||
|
public ResponseEntity<?> getImagesNamesList(@PathVariable("id") Long noticeId) {
|
||||||
|
List<String> result;
|
||||||
|
try {
|
||||||
|
noticeService.getNoticeById(noticeId);
|
||||||
|
result = imageService.getImagesList(noticeId);
|
||||||
|
return ResponseEntity.ok(result);
|
||||||
|
} catch (EntityNotFoundException e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new RequestResponseDTO(e.getMessage()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new RequestResponseDTO(e.getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete/{filename}")
|
||||||
|
public ResponseEntity<RequestResponseDTO> deleteImage(@PathVariable("filename") String filename) {
|
||||||
|
if(filename == null) {
|
||||||
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new RequestResponseDTO("Filename is empty."));
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
imageService.deleteImage(uploadDir, filename);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new RequestResponseDTO("Image deleted successfully."));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new RequestResponseDTO(e.getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.controller;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.NoticeAdditionDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.NoticeBoostDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.RequestResponseDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.service.ClientService;
|
||||||
|
import _11.asktpk.artisanconnectbackend.service.NoticeService;
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.NoticeDTO;
|
||||||
|
import jakarta.persistence.EntityNotFoundException;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RequestMapping("/api/v1/notices")
|
||||||
|
@RestController
|
||||||
|
public class NoticeController {
|
||||||
|
private final NoticeService noticeService;
|
||||||
|
private final ClientService clientService;
|
||||||
|
|
||||||
|
public NoticeController(NoticeService noticeService, ClientService clientService) {
|
||||||
|
this.noticeService = noticeService;
|
||||||
|
this.clientService = clientService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get/all")
|
||||||
|
public List<NoticeDTO> getAllNotices() {
|
||||||
|
return noticeService.getAllNotices();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get/{id}")
|
||||||
|
public ResponseEntity<?> getNoticeById(@PathVariable long id) {
|
||||||
|
if (noticeService.noticeExists(id)) {
|
||||||
|
return ResponseEntity.ok(noticeService.getNoticeById(id));
|
||||||
|
} else {
|
||||||
|
return ResponseEntity.notFound().build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/add")
|
||||||
|
public ResponseEntity<NoticeAdditionDTO> addNotice(@RequestBody NoticeDTO dto) {
|
||||||
|
if (!clientService.clientExists(dto.getClientId())) {
|
||||||
|
return ResponseEntity
|
||||||
|
.status(HttpStatus.BAD_REQUEST)
|
||||||
|
.body(new NoticeAdditionDTO("Nie znaleziono klienta o ID: " + dto.getClientId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dto.getCategory() == null) {
|
||||||
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new NoticeAdditionDTO("Nie ma takiej kategorii"));
|
||||||
|
}
|
||||||
|
dto.setPublishDate(java.time.LocalDateTime.now());
|
||||||
|
|
||||||
|
Long newNoticeId = noticeService.addNotice(dto);
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED).body(new NoticeAdditionDTO(newNoticeId ,"Dodano ogłoszenie."));
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: zamiast dodawać tutaj pętlą, musi to robić NoticeService, trzeba zaimplementować odpowienią metodę
|
||||||
|
@PostMapping("/bulk_add")
|
||||||
|
public ResponseEntity<String> addNotices(@RequestBody List<NoticeDTO> notices_list) {
|
||||||
|
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.CREATED);
|
||||||
|
List<String> errors = new ArrayList<>();
|
||||||
|
boolean isError = false;
|
||||||
|
|
||||||
|
if (notices_list.isEmpty()) {
|
||||||
|
return response.status(HttpStatus.BAD_REQUEST).body("Lista ogłoszeń jest pusta.");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (NoticeDTO dto : notices_list) {
|
||||||
|
if (!clientService.clientExists(dto.getClientId())) {
|
||||||
|
isError = true;
|
||||||
|
errors.add(dto.getClientId().toString());
|
||||||
|
} else {
|
||||||
|
if (!isError) {
|
||||||
|
noticeService.addNotice(dto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isError) {
|
||||||
|
return response.status(HttpStatus.BAD_REQUEST).body("Nie znaleziono klientów: " + errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/edit/{id}")
|
||||||
|
public ResponseEntity<Object> editNotice(@PathVariable("id") long id, @RequestBody NoticeDTO dto) {
|
||||||
|
if (noticeService.noticeExists(id)) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(noticeService.updateNotice(id, dto), HttpStatus.OK);
|
||||||
|
} catch (EntityNotFoundException e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Nie znaleziono ogłoszenia o ID: " + id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete/{id}")
|
||||||
|
public ResponseEntity<RequestResponseDTO> deleteNotice(@PathVariable("id") long id) {
|
||||||
|
if (noticeService.noticeExists(id)) {
|
||||||
|
noticeService.deleteNotice(id);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new RequestResponseDTO("Pomyślnie usunięto ogłoszenie o ID: " + id));
|
||||||
|
} else {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new RequestResponseDTO("Nie znaleziono ogłoszenia o ID: " + id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/boost/{id}")
|
||||||
|
public ResponseEntity<RequestResponseDTO> boostNotice(@PathVariable("id") long clientId, @RequestBody NoticeBoostDTO dto) {
|
||||||
|
if (!noticeService.isNoticeOwnedByClient(dto.getNoticeId(), clientId)) {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new RequestResponseDTO("Ogłoszenie nie istnieje lub nie należy do zalogowanego klienta."));
|
||||||
|
}
|
||||||
|
noticeService.boostNotice(dto.getNoticeId());
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new RequestResponseDTO("Ogłoszenie zostało pomyślnie wypromowane."));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.controller;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.*;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Order;
|
||||||
|
import _11.asktpk.artisanconnectbackend.service.ClientService;
|
||||||
|
import _11.asktpk.artisanconnectbackend.service.OrderService;
|
||||||
|
import _11.asktpk.artisanconnectbackend.service.PaymentService;
|
||||||
|
import _11.asktpk.artisanconnectbackend.utils.Enums;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/orders")
|
||||||
|
public class OrderController {
|
||||||
|
|
||||||
|
private final OrderService orderService;
|
||||||
|
private final PaymentService paymentService;
|
||||||
|
|
||||||
|
public OrderController(OrderService orderService, PaymentService paymentService) {
|
||||||
|
this.orderService = orderService;
|
||||||
|
this.paymentService = paymentService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/add")
|
||||||
|
public ResponseEntity addClient(@RequestBody OrderDTO orderDTO) {
|
||||||
|
return new ResponseEntity<>(orderService.addOrder(orderDTO), HttpStatus.CREATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/changeStatus")
|
||||||
|
public ResponseEntity changeStatus(@RequestBody OrderStatusDTO orderStatusDTO) {
|
||||||
|
return new ResponseEntity<>(orderService.changeOrderStatus(orderStatusDTO.getId(),orderStatusDTO.getStatus()), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/token")
|
||||||
|
public ResponseEntity<?> fetchToken() {
|
||||||
|
Order order = orderService.getOrderById(1L);
|
||||||
|
OAuthPaymentResponseDTO authPaymentDTO= paymentService.getOAuthToken();
|
||||||
|
TransactionPaymentRequestDTO.Payer payer = new TransactionPaymentRequestDTO.Payer(
|
||||||
|
"patryk@test.pl", "Patryk Test");
|
||||||
|
|
||||||
|
String paymentDescription = order.getOrderType() == Enums.OrderType.ACTIVATION ? "Aktywacja ogłoszenia" : "Podbicie ogłoszenia";
|
||||||
|
paymentDescription += order.getNotice().getTitle();
|
||||||
|
TransactionPaymentRequestDTO request = new TransactionPaymentRequestDTO(
|
||||||
|
order.getAmount(), paymentDescription, payer);
|
||||||
|
|
||||||
|
String response = paymentService.createTransaction(order,authPaymentDTO.getAccess_token(), request);
|
||||||
|
System.out.println(response);
|
||||||
|
System.out.println(request);
|
||||||
|
|
||||||
|
return ResponseEntity.ok(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.controller;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Notice;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Order;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Payment;
|
||||||
|
import _11.asktpk.artisanconnectbackend.repository.PaymentRepository;
|
||||||
|
import _11.asktpk.artisanconnectbackend.utils.Enums;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.util.DigestUtils;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/payments")
|
||||||
|
public class PaymentController {
|
||||||
|
|
||||||
|
@Value("${tpay.securityCode}")
|
||||||
|
private String sellerSecurityCode;
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(PaymentController.class);
|
||||||
|
|
||||||
|
private final PaymentRepository paymentRepository;
|
||||||
|
|
||||||
|
public PaymentController(PaymentRepository paymentRepository) {
|
||||||
|
this.paymentRepository = paymentRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/notification", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||||
|
public ResponseEntity<String> handleTpayNotification(@RequestParam Map<String, String> params) {
|
||||||
|
log.info("=== ODEBRANO NOTYFIKACJĘ Tpay ===");
|
||||||
|
log.info("Parametry:\n{}", paramsToLogString(params));
|
||||||
|
|
||||||
|
String id = params.get("id");
|
||||||
|
String trId = params.get("tr_id");
|
||||||
|
String trAmount = params.get("tr_amount");
|
||||||
|
String trCrc = params.get("tr_crc");
|
||||||
|
String md5sum = params.get("md5sum");
|
||||||
|
String trStatus = params.get("tr_status");
|
||||||
|
|
||||||
|
String expectedMd5 = DigestUtils.md5DigestAsHex(
|
||||||
|
(id + trId + trAmount + trCrc + sellerSecurityCode).getBytes()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!expectedMd5.equals(md5sum)) {
|
||||||
|
log.warn("❌ Błędna suma kontrolna! Otrzymano: {}, Oczekiwano: {}", md5sum, expectedMd5);
|
||||||
|
return ResponseEntity.status(400).body("INVALID CHECKSUM");
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<Payment> optionalPayment = paymentRepository.findByTransactionId(trId);
|
||||||
|
if (optionalPayment.isPresent()) {
|
||||||
|
Payment payment = optionalPayment.get();
|
||||||
|
|
||||||
|
if ("true".equalsIgnoreCase(trStatus) || "PAID".equalsIgnoreCase(trStatus)) {
|
||||||
|
log.info("✅ Transakcja opłacona: tr_id={}, kwota={}", trId, params.get("tr_paid"));
|
||||||
|
payment.setStatus(Enums.PaymentStatus.CORRECT);
|
||||||
|
|
||||||
|
if (payment.getOrder() != null) {
|
||||||
|
Order order = payment.getOrder();
|
||||||
|
order.setStatus(Enums.OrderStatus.COMPLETED);
|
||||||
|
Notice notice = order.getNotice();
|
||||||
|
if (order.getOrderType() == Enums.OrderType.ACTIVATION) {
|
||||||
|
notice.setStatus(Enums.Status.ACTIVE);
|
||||||
|
} else if (order.getOrderType() == Enums.OrderType.BOOST) {
|
||||||
|
notice.setPublishDate(LocalDateTime.now());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if ("false".equalsIgnoreCase(trStatus)) {
|
||||||
|
log.warn("❌ Transakcja nieudana: {}", trId);
|
||||||
|
payment.setStatus(Enums.PaymentStatus.INCORRECT);
|
||||||
|
|
||||||
|
if (payment.getOrder() != null) {
|
||||||
|
payment.getOrder().setStatus(Enums.OrderStatus.CANCELLED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
paymentRepository.save(payment);
|
||||||
|
} else {
|
||||||
|
log.warn("⚠️ Brak płatności o tr_id={}", trId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.ok("TRUE");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String paramsToLogString(Map<String, String> params) {
|
||||||
|
return params.entrySet().stream()
|
||||||
|
.map(e -> e.getKey() + " = " + e.getValue())
|
||||||
|
.collect(Collectors.joining("\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.controller;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.CategoriesDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.utils.Enums;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/vars")
|
||||||
|
public class VariablesController {
|
||||||
|
|
||||||
|
@GetMapping("/categories")
|
||||||
|
public List<CategoriesDTO> getAllVariables() {
|
||||||
|
List<CategoriesDTO> categoriesDTOList = new ArrayList<>();
|
||||||
|
for (Map.Entry<Enums.Category, String> entry : Enums.categoryPL.entrySet()) {
|
||||||
|
CategoriesDTO categoriesDTO = new CategoriesDTO();
|
||||||
|
categoriesDTO.setLabel(entry.getValue());
|
||||||
|
categoriesDTO.setValue(entry.getKey().toString());
|
||||||
|
categoriesDTOList.add(categoriesDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
return categoriesDTOList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/statuses")
|
||||||
|
public List<Enums.Status> getAllStatuses() {
|
||||||
|
return List.of(Enums.Status.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/roles")
|
||||||
|
public List<Enums.Role> getAllRoles() {
|
||||||
|
return List.of(Enums.Role.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.controller;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.NoticeDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.RequestResponseDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.WishlistDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.service.ClientService;
|
||||||
|
import _11.asktpk.artisanconnectbackend.service.NoticeService;
|
||||||
|
import _11.asktpk.artisanconnectbackend.service.WishlistService;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/wishlist")
|
||||||
|
public class WishlistController {
|
||||||
|
private final WishlistService wishlistService;
|
||||||
|
private final ClientService clientService;
|
||||||
|
private final NoticeService noticeService;
|
||||||
|
|
||||||
|
public WishlistController(WishlistService wishlistService, ClientService clientService, NoticeService noticeService) {
|
||||||
|
this.wishlistService = wishlistService;
|
||||||
|
this.clientService = clientService;
|
||||||
|
this.noticeService = noticeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/toggle/{noticeId}")
|
||||||
|
public ResponseEntity<RequestResponseDTO> toggleWishlist(@PathVariable Long noticeId) {
|
||||||
|
|
||||||
|
Long clientId = 1L;
|
||||||
|
NoticeDTO noticeDTO = noticeService.getNoticeById(noticeId);
|
||||||
|
if (noticeDTO == null) {
|
||||||
|
return ResponseEntity.badRequest().body(new RequestResponseDTO("Notice not found"));
|
||||||
|
}
|
||||||
|
boolean added = wishlistService.toggleWishlist(
|
||||||
|
clientService.getClientById(clientId),
|
||||||
|
noticeService.getNoticeByIdEntity(noticeId)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (added) {
|
||||||
|
return ResponseEntity.ok(new RequestResponseDTO("Wishlist entry added"));
|
||||||
|
} else {
|
||||||
|
return ResponseEntity.ok(new RequestResponseDTO("Wishlist entry removed"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @GetMapping("/{clientId}")
|
||||||
|
// public ResponseEntity<List<WishlistDTO>> getWishlist(@PathVariable Long clientId) {
|
||||||
|
// List<WishlistDTO> wishlist = wishlistService.getWishlistForClientId(clientId);
|
||||||
|
// return ResponseEntity.ok(wishlist);
|
||||||
|
// }
|
||||||
|
|
||||||
|
@GetMapping("/")
|
||||||
|
public List<NoticeDTO> getWishlistForClient() {
|
||||||
|
// TODO: Replace with actual client ID from authentication context
|
||||||
|
Long clientId = 1L;
|
||||||
|
return wishlistService.getNoticesInWishlist(clientId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
//[
|
||||||
|
// { "label": "Meble", "value": "Furniture" },
|
||||||
|
// { "label": "Biżuteria", "value": "Jewelry" },
|
||||||
|
// { "label": "Ceramika", "value": "Ceramics" }
|
||||||
|
//]
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
|
public class CategoriesDTO {
|
||||||
|
String label;
|
||||||
|
String value;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.Email;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.utils.Enums.Role;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
|
public class ClientDTO {
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Email
|
||||||
|
@NotBlank
|
||||||
|
private String email;
|
||||||
|
private String firstName;
|
||||||
|
private String lastName;
|
||||||
|
private String image;
|
||||||
|
private Role role;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import jakarta.validation.constraints.Email;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class EmailDTO {
|
||||||
|
@Email(message = "Podaj poprawny adres email")
|
||||||
|
@NotBlank(message = "Adres email nie może być pusty")
|
||||||
|
private String to;
|
||||||
|
|
||||||
|
@NotBlank(message = "Temat nie może być pusty")
|
||||||
|
private String subject;
|
||||||
|
|
||||||
|
@NotBlank(message = "Treść nie może być pusta")
|
||||||
|
private String body;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
|
||||||
|
public class ImageRequestDTO {
|
||||||
|
public Resource image;
|
||||||
|
public Long noticeId;
|
||||||
|
public boolean isMainImage;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
|
public class NoticeAdditionDTO {
|
||||||
|
public Long noticeId;
|
||||||
|
public String message;
|
||||||
|
|
||||||
|
public NoticeAdditionDTO(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NoticeAdditionDTO(Long noticeId, String message) {
|
||||||
|
this.noticeId = noticeId;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
|
public class NoticeBoostDTO {
|
||||||
|
private Long noticeId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.AttributesNotice;
|
||||||
|
import _11.asktpk.artisanconnectbackend.utils.Enums;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
|
public class NoticeDTO {
|
||||||
|
private long noticeId;
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private Long clientId;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private Double price;
|
||||||
|
|
||||||
|
private Enums.Category category;
|
||||||
|
|
||||||
|
private Enums.Status status;
|
||||||
|
|
||||||
|
private LocalDateTime publishDate;
|
||||||
|
|
||||||
|
private List<AttributesNotice> attributesNotices;
|
||||||
|
|
||||||
|
private boolean isWishlisted;
|
||||||
|
|
||||||
|
public NoticeDTO() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class OAuthPaymentResponseDTO {
|
||||||
|
private long issued_at;
|
||||||
|
private String scope;
|
||||||
|
private String token_type;
|
||||||
|
private int expires_in;
|
||||||
|
private String client_id;
|
||||||
|
private String access_token;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.utils.Enums;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class OrderDTO {
|
||||||
|
private Long clientId;
|
||||||
|
private Long noticeId;
|
||||||
|
private Enums.OrderType orderType;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.utils.Enums;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
|
public class OrderStatusDTO {
|
||||||
|
public long id;
|
||||||
|
public Enums.OrderStatus status;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
|
public class RequestResponseDTO {
|
||||||
|
public String message;
|
||||||
|
|
||||||
|
public RequestResponseDTO(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
|
public class TransactionPaymentRequestDTO {
|
||||||
|
private double amount;
|
||||||
|
private String description;
|
||||||
|
private Payer payer;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class Payer {
|
||||||
|
private String email;
|
||||||
|
private String name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public class TransactionPaymentResponseDTO {
|
||||||
|
private String result;
|
||||||
|
private String requestId;
|
||||||
|
private String transactionId;
|
||||||
|
private String title;
|
||||||
|
private String posId;
|
||||||
|
private String status;
|
||||||
|
private DateInfo date;
|
||||||
|
private double amount;
|
||||||
|
private String currency;
|
||||||
|
private String description;
|
||||||
|
private String hiddenDescription;
|
||||||
|
private Payer payer;
|
||||||
|
private Payments payments;
|
||||||
|
private String transactionPaymentUrl;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public static class DateInfo {
|
||||||
|
private String creation;
|
||||||
|
private String realization;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public static class Payer {
|
||||||
|
private String payerId;
|
||||||
|
private String email;
|
||||||
|
private String name;
|
||||||
|
private String phone;
|
||||||
|
private String address;
|
||||||
|
private String city;
|
||||||
|
private String country;
|
||||||
|
private String postalCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public static class Payments {
|
||||||
|
private String status;
|
||||||
|
private String method;
|
||||||
|
private double amountPaid;
|
||||||
|
private DateInfo date;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "YourClassName{" +
|
||||||
|
"result='" + result + '\'' +
|
||||||
|
", requestId='" + requestId + '\'' +
|
||||||
|
", transactionId='" + transactionId + '\'' +
|
||||||
|
", title='" + title + '\'' +
|
||||||
|
", posId='" + posId + '\'' +
|
||||||
|
", status='" + status + '\'' +
|
||||||
|
", date=" + date +
|
||||||
|
", amount=" + amount +
|
||||||
|
", currency='" + currency + '\'' +
|
||||||
|
", description='" + description + '\'' +
|
||||||
|
", hiddenDescription='" + hiddenDescription + '\'' +
|
||||||
|
", payer=" + payer +
|
||||||
|
", payments=" + payments +
|
||||||
|
", transactionPaymentUrl='" + transactionPaymentUrl + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class WishlistDTO {
|
||||||
|
private Long id;
|
||||||
|
private Long clientId;
|
||||||
|
private Long noticeId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "attribute_values")
|
||||||
|
public class AttributeValues {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "id_attribute")
|
||||||
|
private Attributes attribute;
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
// Getters, setters, and constructors
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "attributes")
|
||||||
|
public class Attributes {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long idAttribute;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "attribute", cascade = CascadeType.ALL)
|
||||||
|
private List<AttributeValues> attributeValues;
|
||||||
|
|
||||||
|
// Getters, setters, and constructors
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "attributes_notice")
|
||||||
|
public class AttributesNotice {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "id_notice")
|
||||||
|
private Notice notice;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "id_value")
|
||||||
|
private AttributeValues attributeValue;
|
||||||
|
|
||||||
|
// Getters, setters, and constructors
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.entities;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.utils.Enums.Role;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "clients")
|
||||||
|
@Getter @Setter
|
||||||
|
public class Client {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private String firstName;
|
||||||
|
|
||||||
|
private String lastName;
|
||||||
|
|
||||||
|
private String image; // Optional field
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private Role role;
|
||||||
|
|
||||||
|
// @OneToMany(mappedBy = "client", cascade = CascadeType.ALL)
|
||||||
|
// private List<Notice> notices;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "client", cascade = CascadeType.ALL)
|
||||||
|
private List<Order> orders;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "global_variables")
|
||||||
|
public class GlobalVariables {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
// Getters, setters, and constructors
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import jdk.jfr.BooleanFlag;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "images")
|
||||||
|
@Getter @Setter
|
||||||
|
public class Image {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long noticeId;
|
||||||
|
|
||||||
|
private String imageName;
|
||||||
|
|
||||||
|
@BooleanFlag
|
||||||
|
private boolean isMainImage;
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.utils.Enums.*;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "notice")
|
||||||
|
@Getter @Setter
|
||||||
|
public class Notice {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long idNotice;
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "client_id")
|
||||||
|
private Client client;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private Double price;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private Category category;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private Status status;
|
||||||
|
|
||||||
|
private LocalDateTime publishDate;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "notice", cascade = CascadeType.ALL)
|
||||||
|
private List<AttributesNotice> attributesNotices;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "notice", cascade = CascadeType.ALL)
|
||||||
|
private List<Order> orders;
|
||||||
|
|
||||||
|
// @OneToMany(mappedBy = "notice", cascade = CascadeType.ALL)
|
||||||
|
// private List<Payment> payment;
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.entities;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.utils.Enums;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "orders")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class Order {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "id_client")
|
||||||
|
private Client client;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "id_notice")
|
||||||
|
private Notice notice;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
@Column(nullable = false)
|
||||||
|
private Enums.OrderType orderType;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
@Column(nullable = false)
|
||||||
|
private Enums.OrderStatus status;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
private Double amount;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
|
||||||
|
private LocalDateTime updatedAt;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.entities;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.utils.Enums;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "payment")
|
||||||
|
@Getter @Setter
|
||||||
|
public class Payment {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long idPayment;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "id_order")
|
||||||
|
private Order order;
|
||||||
|
|
||||||
|
private Double amount;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
@Column(nullable = false)
|
||||||
|
private Enums.PaymentStatus status;
|
||||||
|
|
||||||
|
private String transactionPaymentUrl;
|
||||||
|
|
||||||
|
private String transactionId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "wishlist")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class Wishlist {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "client_id", nullable = false)
|
||||||
|
private Client client;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "notice_id", nullable = false)
|
||||||
|
private Notice notice;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.repository;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Client;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface ClientRepository extends JpaRepository<Client, Long> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.repository;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Image;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ImageRepository extends JpaRepository<Image, Long> {
|
||||||
|
List<Image> findByNoticeId(Long noticeId);
|
||||||
|
|
||||||
|
boolean existsImageByImageNameEqualsIgnoreCase(String imageName);
|
||||||
|
|
||||||
|
void deleteByImageNameEquals(String imageName);
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.repository;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Notice;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface NoticeRepository extends JpaRepository<Notice, Long> {
|
||||||
|
|
||||||
|
boolean existsByIdNoticeAndClientId(long noticeId, long clientId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.repository;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Order;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface OrderRepository extends JpaRepository<Order, Long> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.repository;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Payment;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface PaymentRepository extends JpaRepository<Payment, Long> {
|
||||||
|
Optional<Payment> findByTransactionId(String transactionId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.repository;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Client;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Notice;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Wishlist;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface WishlistRepository extends JpaRepository<Wishlist, Long> {
|
||||||
|
|
||||||
|
List<Wishlist> findAllByClientId(Long clientId);
|
||||||
|
|
||||||
|
Optional<Wishlist> findByClientAndNotice(Client client, Notice notice);
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.service;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.ClientDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Client;
|
||||||
|
import _11.asktpk.artisanconnectbackend.repository.ClientRepository;
|
||||||
|
import jakarta.persistence.EntityNotFoundException;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ClientService {
|
||||||
|
private final ClientRepository clientRepository;
|
||||||
|
|
||||||
|
public ClientService(ClientRepository clientRepository) {
|
||||||
|
this.clientRepository = clientRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClientDTO toDto(Client client) {
|
||||||
|
ClientDTO dto = new ClientDTO();
|
||||||
|
|
||||||
|
dto.setId(client.getId());
|
||||||
|
dto.setFirstName(client.getFirstName());
|
||||||
|
dto.setLastName(client.getLastName());
|
||||||
|
dto.setEmail(client.getEmail());
|
||||||
|
dto.setRole(client.getRole());
|
||||||
|
dto.setImage(client.getImage());
|
||||||
|
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Client fromDto(ClientDTO dto) {
|
||||||
|
Client client = new Client();
|
||||||
|
|
||||||
|
client.setId(dto.getId());
|
||||||
|
client.setFirstName(dto.getFirstName());
|
||||||
|
client.setLastName(dto.getLastName());
|
||||||
|
client.setEmail(dto.getEmail());
|
||||||
|
client.setRole(dto.getRole());
|
||||||
|
client.setImage(dto.getImage());
|
||||||
|
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientDTO> getAllClients() {
|
||||||
|
List<Client> clients = clientRepository.findAll();
|
||||||
|
return clients.stream().map(this::toDto).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Client getClientById(Long id) {
|
||||||
|
return clientRepository.findById(id).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean clientExists(Long id) {
|
||||||
|
return clientRepository.existsById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientDTO addClient(ClientDTO clientDTO) {
|
||||||
|
return toDto(clientRepository.save(fromDto(clientDTO)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientDTO updateClient(long id, ClientDTO clientDTO) {
|
||||||
|
Client existingClient = clientRepository.findById(id)
|
||||||
|
.orElseThrow(() -> new EntityNotFoundException("Nie znaleziono ogłoszenia o ID: " + id));
|
||||||
|
|
||||||
|
existingClient.setEmail(clientDTO.getEmail());
|
||||||
|
existingClient.setFirstName(clientDTO.getFirstName());
|
||||||
|
existingClient.setLastName(clientDTO.getLastName());
|
||||||
|
existingClient.setImage(clientDTO.getImage());
|
||||||
|
existingClient.setRole(clientDTO.getRole());
|
||||||
|
|
||||||
|
return toDto(clientRepository.save(existingClient));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteClient(Long id) {
|
||||||
|
clientRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.service;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.EmailDTO;
|
||||||
|
import org.springframework.mail.SimpleMailMessage;
|
||||||
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class EmailService {
|
||||||
|
private final JavaMailSender mailSender;
|
||||||
|
|
||||||
|
public EmailService(JavaMailSender mailSender) {
|
||||||
|
this.mailSender = mailSender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendEmail(EmailDTO email) {
|
||||||
|
SimpleMailMessage message = new SimpleMailMessage();
|
||||||
|
message.setTo(email.getTo());
|
||||||
|
message.setSubject(email.getSubject());
|
||||||
|
message.setText(email.getBody());
|
||||||
|
message.setFrom("patryk.kania001@gmail.com");
|
||||||
|
mailSender.send(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.service;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Image;
|
||||||
|
import _11.asktpk.artisanconnectbackend.repository.ImageRepository;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.io.UrlResource;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional
|
||||||
|
public class ImageService {
|
||||||
|
private final ImageRepository imageRepository;
|
||||||
|
|
||||||
|
ImageService(ImageRepository imageRepository) {
|
||||||
|
this.imageRepository = imageRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String saveImageToStorage(String uploadDirectory, MultipartFile imageFile) throws IOException {
|
||||||
|
String uniqueFileName = UUID.randomUUID() + imageFile.getOriginalFilename();
|
||||||
|
|
||||||
|
Path uploadPath = Path.of(uploadDirectory);
|
||||||
|
Path filePath = uploadPath.resolve(uniqueFileName);
|
||||||
|
|
||||||
|
if (!Files.exists(uploadPath)) {
|
||||||
|
Files.createDirectories(uploadPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
Files.copy(imageFile.getInputStream(), filePath, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
return uniqueFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addImageNameToDB(String filename, Long noticeId) {
|
||||||
|
Image image = new Image();
|
||||||
|
image.setImageName(filename);
|
||||||
|
image.setNoticeId(noticeId);
|
||||||
|
imageRepository.save(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Resource getImage(String imageDirectory, String imageName) throws IOException {
|
||||||
|
Path filePath = Paths.get(imageDirectory).resolve(imageName);
|
||||||
|
Resource resource = new UrlResource(filePath.toUri());
|
||||||
|
|
||||||
|
if(imageName.isEmpty() || imageDirectory.isEmpty()) {
|
||||||
|
throw new IOException("Filename or folder is empty. Please check your request and try again.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!resource.exists()) {
|
||||||
|
throw new IOException("File not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteImage(String imageDirectory, String imageName) throws IOException {
|
||||||
|
Path imagePath = Path.of(imageDirectory, imageName);
|
||||||
|
|
||||||
|
deleteImageRecordFromDB(imageName);
|
||||||
|
|
||||||
|
if (Files.exists(imagePath)) {
|
||||||
|
Files.delete(imagePath);
|
||||||
|
} else {
|
||||||
|
throw new IOException("File not found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getImagesList(Long noticeID) throws Exception {
|
||||||
|
List<Image> images = imageRepository.findByNoticeId(noticeID);
|
||||||
|
if (images.isEmpty()) {
|
||||||
|
throw new Exception("There is no images for this notice");
|
||||||
|
}
|
||||||
|
|
||||||
|
return images.stream()
|
||||||
|
.map(Image::getImageName)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteImageRecordFromDB(String imageName) {
|
||||||
|
if(imageRepository.existsImageByImageNameEqualsIgnoreCase(imageName)) {
|
||||||
|
imageRepository.deleteByImageNameEquals(imageName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.service;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Client;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Notice;
|
||||||
|
import _11.asktpk.artisanconnectbackend.repository.ClientRepository;
|
||||||
|
import _11.asktpk.artisanconnectbackend.repository.NoticeRepository;
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.NoticeDTO;
|
||||||
|
import jakarta.persistence.EntityNotFoundException;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class NoticeService {
|
||||||
|
private static final Logger logger = LogManager.getLogger(NoticeService.class);
|
||||||
|
|
||||||
|
@Value("${file.upload-dir}")
|
||||||
|
private String uploadDir;
|
||||||
|
|
||||||
|
private final NoticeRepository noticeRepository;
|
||||||
|
private final ClientRepository clientRepository;
|
||||||
|
private final WishlistService wishlistService;
|
||||||
|
private final ImageService imageService;
|
||||||
|
|
||||||
|
public NoticeService(NoticeRepository noticeRepository, ClientRepository clientRepository, WishlistService wishlistService, ImageService imageService) {
|
||||||
|
this.noticeRepository = noticeRepository;
|
||||||
|
this.clientRepository = clientRepository;
|
||||||
|
this.wishlistService = wishlistService;
|
||||||
|
this.imageService = imageService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Notice fromDTO(NoticeDTO dto) {
|
||||||
|
Notice notice = new Notice();
|
||||||
|
notice.setTitle(dto.getTitle());
|
||||||
|
notice.setDescription(dto.getDescription());
|
||||||
|
notice.setPrice(dto.getPrice());
|
||||||
|
notice.setCategory(dto.getCategory());
|
||||||
|
notice.setStatus(dto.getStatus());
|
||||||
|
notice.setPublishDate(dto.getPublishDate());
|
||||||
|
notice.setAttributesNotices(dto.getAttributesNotices());
|
||||||
|
|
||||||
|
Client client = clientRepository.findById(dto.getClientId())
|
||||||
|
.orElseThrow(() -> new EntityNotFoundException("Nie znaleziono klienta o ID: " + dto.getClientId()));
|
||||||
|
notice.setClient(client);
|
||||||
|
|
||||||
|
return notice;
|
||||||
|
}
|
||||||
|
|
||||||
|
private NoticeDTO toDTO(Notice notice) {
|
||||||
|
NoticeDTO dto = new NoticeDTO();
|
||||||
|
// TODO: To be updated using AuthService after implementing authentication.
|
||||||
|
Optional<Client> client = clientRepository.findById(1L);
|
||||||
|
boolean isWishlisted = false;
|
||||||
|
if (client.isPresent()) {
|
||||||
|
Client c = client.get();
|
||||||
|
isWishlisted = wishlistService.isWishlisted(c, notice);
|
||||||
|
}
|
||||||
|
dto.setNoticeId(notice.getIdNotice());
|
||||||
|
dto.setTitle(notice.getTitle());
|
||||||
|
dto.setClientId(notice.getClient().getId());
|
||||||
|
dto.setDescription(notice.getDescription());
|
||||||
|
dto.setPrice(notice.getPrice());
|
||||||
|
dto.setCategory(notice.getCategory());
|
||||||
|
dto.setStatus(notice.getStatus());
|
||||||
|
dto.setPublishDate(notice.getPublishDate());
|
||||||
|
dto.setAttributesNotices(notice.getAttributesNotices());
|
||||||
|
dto.setWishlisted(isWishlisted);
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<NoticeDTO> getAllNotices() {
|
||||||
|
List<NoticeDTO> result = new ArrayList<>();
|
||||||
|
for (Notice notice : noticeRepository.findAll()) {
|
||||||
|
result.add(toDTO(notice));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NoticeDTO getNoticeById(Long id) {
|
||||||
|
Notice notice = noticeRepository.findById(id)
|
||||||
|
.orElseThrow(() -> new EntityNotFoundException("Nie znaleziono ogłoszenia o ID: " + id));
|
||||||
|
return toDTO(notice);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Notice getNoticeByIdEntity(Long id) {
|
||||||
|
return noticeRepository.findById(id)
|
||||||
|
.orElseThrow(() -> new EntityNotFoundException("Nie znaleziono ogłoszenia o ID: " + id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long addNotice(NoticeDTO dto) {
|
||||||
|
return noticeRepository.save(fromDTO(dto)).getIdNotice();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean noticeExists(Long id) {
|
||||||
|
return noticeRepository.existsById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NoticeDTO updateNotice(Long id, NoticeDTO dto) {
|
||||||
|
Notice existingNotice = noticeRepository.findById(id)
|
||||||
|
.orElseThrow(() -> new EntityNotFoundException("Nie znaleziono ogłoszenia o ID: " + id));
|
||||||
|
|
||||||
|
existingNotice.setTitle(dto.getTitle());
|
||||||
|
existingNotice.setDescription(dto.getDescription());
|
||||||
|
existingNotice.setPrice(dto.getPrice());
|
||||||
|
existingNotice.setCategory(dto.getCategory());
|
||||||
|
existingNotice.setStatus(dto.getStatus());
|
||||||
|
existingNotice.setAttributesNotices(dto.getAttributesNotices());
|
||||||
|
|
||||||
|
if (dto.getClientId() != null && !dto.getClientId().equals(existingNotice.getClient().getId())) {
|
||||||
|
Client client = clientRepository.findById(dto.getClientId())
|
||||||
|
.orElseThrow(() -> new EntityNotFoundException("Nie znaleziono klienta o ID: " + dto.getClientId()));
|
||||||
|
existingNotice.setClient(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
return toDTO(noticeRepository.save(existingNotice));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteNotice(Long id) {
|
||||||
|
if (noticeExists(id)) {
|
||||||
|
noticeRepository.deleteById(id);
|
||||||
|
|
||||||
|
List<String> imagesList = new ArrayList<>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
imagesList = imageService.getImagesList(id);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.info("There weren't any images for notice with ID: " + id + ". Skipping deletion of images. Message: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (String imageName : imagesList) {
|
||||||
|
imageService.deleteImage(uploadDir, imageName);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.info("There were some issues while deleting images for notice with ID: " + id + ". Message: " + e.getMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new EntityNotFoundException("Nie znaleziono ogłoszenia o ID: " + id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNoticeOwnedByClient(long noticeId, long clientId) {
|
||||||
|
return noticeRepository.existsByIdNoticeAndClientId(noticeId, clientId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void boostNotice(long noticeId) {
|
||||||
|
Notice notice = noticeRepository.findById(noticeId)
|
||||||
|
.orElseThrow(() -> new EntityNotFoundException("Ogłoszenie o ID " + noticeId + " nie istnieje."));
|
||||||
|
|
||||||
|
notice.setPublishDate(LocalDateTime.now());
|
||||||
|
|
||||||
|
noticeRepository.save(notice);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.service;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.OrderDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Client;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Notice;
|
||||||
|
import _11.asktpk.artisanconnectbackend.repository.ClientRepository;
|
||||||
|
import _11.asktpk.artisanconnectbackend.repository.NoticeRepository;
|
||||||
|
import _11.asktpk.artisanconnectbackend.repository.OrderRepository;
|
||||||
|
import _11.asktpk.artisanconnectbackend.utils.Enums;
|
||||||
|
import jakarta.persistence.EntityNotFoundException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Order;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class OrderService {
|
||||||
|
|
||||||
|
private final OrderRepository orderRepository;
|
||||||
|
private final ClientRepository clientRepository;
|
||||||
|
private final NoticeRepository noticeRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public OrderService(OrderRepository orderRepository, ClientRepository clientRepository, NoticeRepository noticeRepository) {
|
||||||
|
this.orderRepository = orderRepository;
|
||||||
|
this.clientRepository = clientRepository;
|
||||||
|
this.noticeRepository = noticeRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Order fromDTO(OrderDTO orderDTO) {
|
||||||
|
Order order = new Order();
|
||||||
|
order.setOrderType(orderDTO.getOrderType());
|
||||||
|
order.setStatus(Enums.OrderStatus.PENDING);
|
||||||
|
if(orderDTO.getOrderType() == Enums.OrderType.ACTIVATION){
|
||||||
|
order.setAmount(10.00);
|
||||||
|
}else{
|
||||||
|
order.setAmount(8.00);
|
||||||
|
}
|
||||||
|
|
||||||
|
order.setCreatedAt(LocalDateTime.now()
|
||||||
|
);
|
||||||
|
order.setUpdatedAt(LocalDateTime.now()
|
||||||
|
);
|
||||||
|
|
||||||
|
Client client = clientRepository.findById(orderDTO.getClientId())
|
||||||
|
.orElseThrow(() -> new EntityNotFoundException("Nie znaleziono klienta o ID: " + orderDTO.getClientId()));
|
||||||
|
order.setClient(client);
|
||||||
|
|
||||||
|
Notice notice = noticeRepository.findById(orderDTO.getNoticeId())
|
||||||
|
.orElseThrow(() -> new EntityNotFoundException("Nie znaleziono ogłoszenia o ID: " + orderDTO.getNoticeId()));
|
||||||
|
order.setNotice(notice);
|
||||||
|
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Long addOrder(OrderDTO orderDTO) {
|
||||||
|
Order order = fromDTO(orderDTO);
|
||||||
|
return orderRepository.save(order).getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long changeOrderStatus(Long id, Enums.OrderStatus status) {
|
||||||
|
Order order = orderRepository.findById(id)
|
||||||
|
.orElseThrow(() -> new IllegalArgumentException("Nie znaleziono zamówienia o ID: " + id));
|
||||||
|
|
||||||
|
order.setStatus(status);
|
||||||
|
|
||||||
|
order = orderRepository.save(order);
|
||||||
|
|
||||||
|
return order.getId();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Order getOrderById(Long id) {
|
||||||
|
return orderRepository.findById(id)
|
||||||
|
.orElseThrow(() -> new RuntimeException("Nie znaleziono zamówienia o ID: " + id));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.service;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.OAuthPaymentResponseDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.TransactionPaymentRequestDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.TransactionPaymentResponseDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Order;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Payment;
|
||||||
|
import _11.asktpk.artisanconnectbackend.repository.PaymentRepository;
|
||||||
|
import _11.asktpk.artisanconnectbackend.utils.Enums;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.reactive.function.BodyInserters;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class PaymentService {
|
||||||
|
private final WebClient webClient;
|
||||||
|
private final String clientId;
|
||||||
|
private final String clientSecret;
|
||||||
|
private final String authUrl;
|
||||||
|
private final String transactionUrl;
|
||||||
|
private final PaymentRepository paymentRepository;
|
||||||
|
|
||||||
|
public PaymentService(
|
||||||
|
WebClient.Builder webClientBuilder,
|
||||||
|
@Value("${tpay.clientId}") String clientId,
|
||||||
|
@Value("${tpay.clientSecret}") String clientSecret,
|
||||||
|
@Value("${tpay.authUrl}") String authUrl,
|
||||||
|
@Value("${tpay.transactionUrl}") String transactionUrl,
|
||||||
|
PaymentRepository paymentRepository
|
||||||
|
) {
|
||||||
|
this.webClient = webClientBuilder.baseUrl(authUrl).build();
|
||||||
|
this.clientId = clientId;
|
||||||
|
this.clientSecret = clientSecret;
|
||||||
|
this.authUrl = authUrl;
|
||||||
|
this.transactionUrl = transactionUrl;
|
||||||
|
this.paymentRepository = paymentRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OAuthPaymentResponseDTO getOAuthToken() {
|
||||||
|
return webClient.post()
|
||||||
|
.uri("")
|
||||||
|
.contentType(MediaType.MULTIPART_FORM_DATA)
|
||||||
|
.header("accept", "application/json")
|
||||||
|
.body(BodyInserters.fromMultipartData("client_id", clientId)
|
||||||
|
.with("client_secret", clientSecret))
|
||||||
|
.retrieve()
|
||||||
|
.bodyToMono(OAuthPaymentResponseDTO.class)
|
||||||
|
.block();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String createTransaction(Order order, String accessToken, TransactionPaymentRequestDTO transactionPaymentRequestDTO) {
|
||||||
|
TransactionPaymentResponseDTO response = webClient.post()
|
||||||
|
.uri(transactionUrl)
|
||||||
|
.header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.bodyValue(transactionPaymentRequestDTO)
|
||||||
|
.retrieve()
|
||||||
|
.bodyToMono(TransactionPaymentResponseDTO.class)
|
||||||
|
.block();
|
||||||
|
|
||||||
|
if (response != null && "success".equalsIgnoreCase(response.getResult())) {
|
||||||
|
Payment payment = new Payment();
|
||||||
|
payment.setOrder(order);
|
||||||
|
payment.setAmount(response.getAmount());
|
||||||
|
|
||||||
|
payment.setStatus(Enums.PaymentStatus.PENDING);
|
||||||
|
|
||||||
|
payment.setTransactionId(response.getTitle());
|
||||||
|
payment.setTransactionPaymentUrl(response.getTransactionPaymentUrl());
|
||||||
|
paymentRepository.save(payment);
|
||||||
|
|
||||||
|
System.out.println(response);
|
||||||
|
|
||||||
|
return response.getTransactionPaymentUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.service;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.WishlistDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.NoticeDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Client;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Notice;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Wishlist;
|
||||||
|
import _11.asktpk.artisanconnectbackend.repository.WishlistRepository;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class WishlistService {
|
||||||
|
|
||||||
|
private final WishlistRepository wishlistRepository;
|
||||||
|
private final NoticeService noticeService;
|
||||||
|
|
||||||
|
public WishlistService(WishlistRepository wishlistRepository, @Lazy NoticeService noticeService) {
|
||||||
|
this.wishlistRepository = wishlistRepository;
|
||||||
|
this.noticeService = noticeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WishlistDTO> getWishlistForClientId(Long clientId) {
|
||||||
|
List<Wishlist> wishlistEntities = wishlistRepository.findAllByClientId(clientId);
|
||||||
|
return wishlistEntities.stream()
|
||||||
|
.map(this::toDTO)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWishlisted(Client client, Notice notice) {
|
||||||
|
Optional<Wishlist> existingEntry = wishlistRepository.findByClientAndNotice(client, notice);
|
||||||
|
|
||||||
|
return existingEntry.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean toggleWishlist(Client client, Notice notice) {
|
||||||
|
Optional<Wishlist> existingEntry = wishlistRepository.findByClientAndNotice(client, notice);
|
||||||
|
|
||||||
|
if (existingEntry.isPresent()) {
|
||||||
|
wishlistRepository.delete(existingEntry.get());
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Wishlist wishlist = new Wishlist();
|
||||||
|
wishlist.setClient(client);
|
||||||
|
wishlist.setNotice(notice);
|
||||||
|
wishlistRepository.save(wishlist);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private WishlistDTO toDTO(Wishlist wishlist) {
|
||||||
|
WishlistDTO dto = new WishlistDTO();
|
||||||
|
dto.setId(wishlist.getId());
|
||||||
|
dto.setClientId(wishlist.getClient().getId());
|
||||||
|
dto.setNoticeId(wishlist.getNotice().getIdNotice());
|
||||||
|
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<NoticeDTO> getNoticesInWishlist(Long clientId) {
|
||||||
|
List<Wishlist> wishlistEntries = wishlistRepository.findAllByClientId(clientId);
|
||||||
|
|
||||||
|
return wishlistEntries.stream()
|
||||||
|
.map(wishlist -> noticeService.getNoticeById(wishlist.getNotice().getIdNotice()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.utils;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class Enums {
|
||||||
|
public enum Role {
|
||||||
|
ADMIN, USER
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Category {
|
||||||
|
Handmade, Woodworking, Metalworking, Ceramics,
|
||||||
|
Textiles, Jewelry, Leatherwork, Painting, Sculpture,
|
||||||
|
Glasswork, Furniture, Restoration, Tailoring, Weaving,
|
||||||
|
Calligraphy, Pottery, Blacksmithing, Basketry, Embroidery,
|
||||||
|
Knitting, Carpentry, Other
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Map<Category, String> categoryPL = Map.ofEntries(
|
||||||
|
Map.entry(Category.Handmade, "Rękodzieło"),
|
||||||
|
Map.entry(Category.Woodworking, "Stolarstwo"),
|
||||||
|
Map.entry(Category.Metalworking, "Obróbka metalu"),
|
||||||
|
Map.entry(Category.Ceramics, "Ceramika"),
|
||||||
|
Map.entry(Category.Textiles, "Tekstylia"),
|
||||||
|
Map.entry(Category.Jewelry, "Biżuteria"),
|
||||||
|
Map.entry(Category.Leatherwork, "Wyroby skórzane"),
|
||||||
|
Map.entry(Category.Painting, "Malarstwo"),
|
||||||
|
Map.entry(Category.Sculpture, "Rzeźbiarstwo"),
|
||||||
|
Map.entry(Category.Glasswork, "Szklarstwo"),
|
||||||
|
Map.entry(Category.Furniture, "Meble"),
|
||||||
|
Map.entry(Category.Restoration, "Renowacja"),
|
||||||
|
Map.entry(Category.Tailoring, "Krawiectwo"),
|
||||||
|
Map.entry(Category.Weaving, "Tkactwo"),
|
||||||
|
Map.entry(Category.Calligraphy, "Kaligrafia"),
|
||||||
|
Map.entry(Category.Pottery, "Garncarstwo"),
|
||||||
|
Map.entry(Category.Blacksmithing, "Kowalstwo"),
|
||||||
|
Map.entry(Category.Basketry, "Koszykarstwo"),
|
||||||
|
Map.entry(Category.Embroidery, "Hafciarstwo"),
|
||||||
|
Map.entry(Category.Knitting, "Dzierganie"),
|
||||||
|
Map.entry(Category.Carpentry, "Ciesielstwo"),
|
||||||
|
Map.entry(Category.Other, "Inne")
|
||||||
|
);
|
||||||
|
|
||||||
|
public enum Status {
|
||||||
|
ACTIVE, INACTIVE
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum OrderType {
|
||||||
|
ACTIVATION,
|
||||||
|
BOOST
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public enum OrderStatus {
|
||||||
|
PENDING, COMPLETED, CANCELLED
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum PaymentStatus{
|
||||||
|
PENDING, CORRECT, INCORRECT
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,9 +1,35 @@
|
|||||||
spring.application.name=ArtisanConnectBackend
|
spring.application.name=ArtisanConnectBackend
|
||||||
|
|
||||||
## PostgreSQL
|
## PostgreSQL
|
||||||
spring.datasource.url=jdbc:postgresql://localhost:5432/default_db
|
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
|
||||||
|
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||||
spring.datasource.username=postgres
|
spring.datasource.username=postgres
|
||||||
spring.datasource.password=postgres
|
spring.datasource.password=postgres
|
||||||
|
|
||||||
|
#initial data for db injection
|
||||||
|
spring.sql.init.data-locations=classpath:sql/data.sql
|
||||||
|
spring.sql.init.mode=always
|
||||||
|
spring.jpa.defer-datasource-initialization=true
|
||||||
|
|
||||||
# create and drop table, good for testing, production set to none or comment it
|
# create and drop table, good for testing, production set to none or comment it
|
||||||
spring.jpa.hibernate.ddl-auto=create-drop
|
spring.jpa.hibernate.ddl-auto=create-drop
|
||||||
|
|
||||||
|
file.upload-dir=/Users/andsol/Desktop/uploads
|
||||||
|
spring.servlet.multipart.max-file-size=10MB
|
||||||
|
spring.servlet.multipart.max-request-size=10MB
|
||||||
|
|
||||||
|
spring.mail.host=smtp.gmail.com
|
||||||
|
spring.mail.port=587
|
||||||
|
spring.mail.username=patryk.kania001@gmail.com
|
||||||
|
spring.mail.password=pmyd ylwg mbsn hcpp
|
||||||
|
spring.mail.properties.mail.smtp.auth=true
|
||||||
|
spring.mail.properties.mail.smtp.starttls.enable=true
|
||||||
|
|
||||||
|
tpay.clientId = 01JQKC048X62ST9V59HNRSXD92-01JQKC2CQHPYXQFSFX8BKC24BX
|
||||||
|
tpay.clientSecret = 44898642be53381cdcc47f3e44bf5a15e592f5d270fc3a6cf6fb81a8b8ebffb9
|
||||||
|
tpay.authUrl = https://openapi.sandbox.tpay.com/oauth/auth
|
||||||
|
tpay.transactionUrl = https://openapi.sandbox.tpay.com/transactions
|
||||||
|
tpay.securityCode = )IY7E)YSM!A)Q6O-GN#U7U_33s9qObk8
|
||||||
|
|
||||||
|
logging.file.name=logs/payment-notifications.log
|
||||||
|
logging.level.TpayLogger=INFO
|
||||||
|
|||||||
20
src/main/resources/application.properties.prod
Normal file
20
src/main/resources/application.properties.prod
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
spring.application.name=ArtisanConnectBackend
|
||||||
|
|
||||||
|
## PostgreSQL
|
||||||
|
spring.datasource.url=jdbc:postgresql://db:5432/postgres
|
||||||
|
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||||
|
spring.datasource.username=postgres
|
||||||
|
spring.datasource.password=postgres
|
||||||
|
|
||||||
|
#initial data for db injection
|
||||||
|
spring.sql.init.data-locations=classpath:sql/data.sql
|
||||||
|
spring.sql.init.mode=always
|
||||||
|
spring.jpa.defer-datasource-initialization=true
|
||||||
|
|
||||||
|
# create and drop table, good for testing, production set to none or comment it
|
||||||
|
spring.jpa.hibernate.ddl-auto=update
|
||||||
|
|
||||||
|
#file.upload-dir=/Users/andsol/Desktop/uploads
|
||||||
|
file.upload-dir=/app/images
|
||||||
|
spring.servlet.multipart.max-file-size=10MB
|
||||||
|
spring.servlet.multipart.max-request-size=10MB
|
||||||
15
src/main/resources/sql/data.sql
Normal file
15
src/main/resources/sql/data.sql
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
INSERT INTO clients (email, first_name, image, last_name, password, role)
|
||||||
|
VALUES
|
||||||
|
('dignissim.tempor.arcu@aol.ca', 'Diana', 'null', 'Harrison', 'password', 'USER'),
|
||||||
|
('john.doe@example.com', 'John', 'null', 'Doe', 'password123', 'ADMIN'),
|
||||||
|
('jane.smith@example.com', 'Jane', 'null', 'Smith', 'securepass', 'USER'),
|
||||||
|
('michael.brown@example.com', 'Michael', 'null', 'Brown', 'mypassword', 'USER'),
|
||||||
|
('emily.jones@example.com', 'Emily', 'null', 'Jones', 'passw0rd', 'USER');
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO notice (title, description, client_id, price, category, status, publish_date) VALUES
|
||||||
|
('Ręcznie robiona biżuteria', 'Unikalna biżuteria wykonana ręcznie z najwyższej jakości materiałów.', 5, 150.00, 'Jewelry', 'ACTIVE', '2023-10-01'),
|
||||||
|
('Drewniany stół', 'Solidny stół wykonany z litego drewna dębowego.', 3, 1200.00, 'Furniture', 'ACTIVE', '2023-09-15'),
|
||||||
|
('Ceramiczna waza', 'Piękna waza ceramiczna, idealna na prezent.', 2, 300.00, 'Ceramics', 'INACTIVE', '2023-08-20'),
|
||||||
|
('Obraz olejny', 'Obraz olejny przedstawiający krajobraz górski.', 4, 800.00, 'Painting', 'ACTIVE', '2023-07-10'),
|
||||||
|
('Skórzany portfel', 'Ręcznie wykonany portfel ze skóry naturalnej.', 1, 250.00, 'Leatherwork', 'ACTIVE', '2023-06-05');
|
||||||
@@ -1,43 +1,33 @@
|
|||||||
package _11.asktpk.artisanconnectbackend;
|
package _11.asktpk.artisanconnectbackend;
|
||||||
|
|
||||||
import _11.asktpk.artisanconnectbackend.Model.Notice;
|
|
||||||
import _11.asktpk.artisanconnectbackend.Service.PostgresDatabase;
|
|
||||||
import okhttp3.*;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class ArtisanConnectBackendApplicationTests {
|
class ArtisanConnectBackendApplicationTests {
|
||||||
private static final Logger logger = LogManager.getLogger(ArtisanConnectBackendApplicationTests.class);
|
private static final Logger logger = LogManager.getLogger(ArtisanConnectBackendApplicationTests.class);
|
||||||
|
|
||||||
@Autowired
|
// @Test
|
||||||
PostgresDatabase postgresDatabase;
|
// void testPostgresDatabase() {
|
||||||
|
// postgresDatabase.add(new Notice("Test Notice", "Username", "Test Description"));
|
||||||
@Test
|
// Boolean isRecordAvailable = postgresDatabase.get().size() > 0;
|
||||||
void testPostgresDatabase() {
|
// if(isRecordAvailable) {
|
||||||
postgresDatabase.add(new Notice("Test Notice", "Username", "Test Description"));
|
// logger.info("The record is available in the database");
|
||||||
Boolean isRecordAvailable = postgresDatabase.get().size() > 0;
|
// } else {
|
||||||
if(isRecordAvailable) {
|
// logger.error("The record is not available in the database");
|
||||||
logger.info("The record is available in the database");
|
// }
|
||||||
} else {
|
// assert isRecordAvailable;
|
||||||
logger.error("The record is not available in the database");
|
// }
|
||||||
}
|
//
|
||||||
assert isRecordAvailable;
|
// @Test
|
||||||
}
|
// void getAllNotices() throws IOException {
|
||||||
|
// OkHttpClient client = new OkHttpClient().newBuilder()
|
||||||
@Test
|
// .build();
|
||||||
void getAllNotices() throws IOException {
|
// MediaType mediaType = MediaType.parse("text/plain");
|
||||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
// Request request = new Request.Builder()
|
||||||
.build();
|
// .url("http://localhost:8080/api/v1/notices/all")
|
||||||
MediaType mediaType = MediaType.parse("text/plain");
|
// .build();
|
||||||
Request request = new Request.Builder()
|
// Response response = client.newCall(request).execute();
|
||||||
.url("http://localhost:8080/api/v1/notices/all")
|
// }
|
||||||
.build();
|
|
||||||
Response response = client.newCall(request).execute();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
122
stuff/Przepływ danych.drawio
Normal file
122
stuff/Przepływ danych.drawio
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
<mxfile host="Electron" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/26.2.2 Chrome/134.0.6998.178 Electron/35.1.2 Safari/537.36" version="26.2.2">
|
||||||
|
<diagram name="Strona-1" id="y3JY7GFactLq4jGyxg2V">
|
||||||
|
<mxGraphModel dx="2180" dy="884" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||||
|
<root>
|
||||||
|
<mxCell id="0" />
|
||||||
|
<mxCell id="1" parent="0" />
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-3" value="<font style="font-size: 15px;"><b>Backend</b></font>" style="rounded=0;whiteSpace=wrap;html=1;verticalAlign=top;fillColor=#f5f5f5;fillStyle=auto;strokeColor=#666666;shadow=0;glass=0;fontColor=#333333;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="270" y="520" width="534" height="270" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="HPrCYg6BNmEDSauX9FRR-4" value="<font style="font-size: 15px;"><b>Backend</b></font>" style="rounded=0;whiteSpace=wrap;html=1;verticalAlign=top;fillColor=#f5f5f5;fillStyle=auto;strokeColor=#666666;shadow=0;glass=0;fontColor=#333333;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="324" y="100" width="470" height="230" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="HPrCYg6BNmEDSauX9FRR-16" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="HPrCYg6BNmEDSauX9FRR-2" target="HPrCYg6BNmEDSauX9FRR-7" edge="1">
|
||||||
|
<mxGeometry relative="1" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="HPrCYg6BNmEDSauX9FRR-2" value="Postman" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="34" y="250" width="120" height="60" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="HPrCYg6BNmEDSauX9FRR-12" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="HPrCYg6BNmEDSauX9FRR-7" target="HPrCYg6BNmEDSauX9FRR-10" edge="1">
|
||||||
|
<mxGeometry relative="1" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="HPrCYg6BNmEDSauX9FRR-7" value="Controller" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="364" y="250" width="120" height="60" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="HPrCYg6BNmEDSauX9FRR-13" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="HPrCYg6BNmEDSauX9FRR-10" target="HPrCYg6BNmEDSauX9FRR-11" edge="1">
|
||||||
|
<mxGeometry relative="1" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="HPrCYg6BNmEDSauX9FRR-10" value="Service" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="554" y="250" width="120" height="60" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="HPrCYg6BNmEDSauX9FRR-11" value="Repository" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="664" y="130" width="120" height="60" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="HPrCYg6BNmEDSauX9FRR-17" value="DTO" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="504" y="270" width="30" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="HPrCYg6BNmEDSauX9FRR-19" value="Entity" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="704" y="230" width="40" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="HPrCYg6BNmEDSauX9FRR-1" value="DTO" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="224" y="270" width="40" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="HPrCYg6BNmEDSauX9FRR-44" value="Przesyłanie danych na serwer" style="text;strokeColor=none;fillColor=none;html=1;fontSize=24;fontStyle=1;verticalAlign=middle;align=center;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="226" y="40" width="376" height="40" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="HPrCYg6BNmEDSauX9FRR-50" value="" style="sketch=0;pointerEvents=1;shadow=0;dashed=0;html=1;strokeColor=none;fillColor=#DF8C42;labelPosition=center;verticalLabelPosition=bottom;verticalAlign=top;align=center;outlineConnect=0;shape=mxgraph.veeam2.restful_api;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="10" y="10" width="80" height="80" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-1" value="Przesyłanie zdjęć na backend" style="text;strokeColor=none;fillColor=none;html=1;fontSize=24;fontStyle=1;verticalAlign=middle;align=center;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="194" y="460" width="440" height="40" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-6" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="Ht36qwYIb0A0iwGBjog0-2" target="Ht36qwYIb0A0iwGBjog0-4">
|
||||||
|
<mxGeometry relative="1" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-2" value="Postman" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="-20" y="625" width="120" height="60" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-7" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="Ht36qwYIb0A0iwGBjog0-4" target="Ht36qwYIb0A0iwGBjog0-5">
|
||||||
|
<mxGeometry relative="1" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-4" value="ImageController<div>(Validation)</div>" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="307" y="625" width="120" height="60" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-5" value="ImageService" style="rounded=0;whiteSpace=wrap;html=1;verticalAlign=top;align=center;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="550" y="580" width="196" height="150" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-9" value="MultipartFile + PathVariable" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="140" y="640" width="110" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-17" value="saveImageToStorage()" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="580" y="620" width="136" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-18" value="addImageNameToDB()" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="582" y="680" width="132" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-20" value="Pobieranie zdjęć z backendu" style="text;strokeColor=none;fillColor=none;html=1;fontSize=24;fontStyle=1;verticalAlign=middle;align=center;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="194" y="1010" width="440" height="40" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-22" value="<font style="font-size: 15px;"><b>Backend</b></font>" style="rounded=0;whiteSpace=wrap;html=1;verticalAlign=top;fillColor=#f5f5f5;fillStyle=auto;strokeColor=#666666;shadow=0;glass=0;fontColor=#333333;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="260" y="1079" width="534" height="290" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-29" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.75;exitDx=0;exitDy=0;entryX=0;entryY=0.75;entryDx=0;entryDy=0;" edge="1" parent="1" source="Ht36qwYIb0A0iwGBjog0-23" target="Ht36qwYIb0A0iwGBjog0-26">
|
||||||
|
<mxGeometry relative="1" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-30" value="GetRequest" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="Ht36qwYIb0A0iwGBjog0-29">
|
||||||
|
<mxGeometry x="0.2401" relative="1" as="geometry">
|
||||||
|
<mxPoint x="-19" as="offset" />
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-23" value="Postman" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="-110" y="1197" width="120" height="60" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-24" value="/api/v1/images/get/{filename}" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="-135" y="1160" width="170" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-35" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.25;exitDx=0;exitDy=0;entryX=1;entryY=0.25;entryDx=0;entryDy=0;" edge="1" parent="1" source="Ht36qwYIb0A0iwGBjog0-26" target="Ht36qwYIb0A0iwGBjog0-23">
|
||||||
|
<mxGeometry relative="1" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-36" value="MultipartFile(content-type image/jpeg)" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="Ht36qwYIb0A0iwGBjog0-35">
|
||||||
|
<mxGeometry x="0.0779" y="-1" relative="1" as="geometry">
|
||||||
|
<mxPoint as="offset" />
|
||||||
|
</mxGeometry>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-26" value="ImageController" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="294" y="1197" width="120" height="60" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-37" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="Ht36qwYIb0A0iwGBjog0-31" target="Ht36qwYIb0A0iwGBjog0-26">
|
||||||
|
<mxGeometry relative="1" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-31" value="ImageService" style="rounded=0;whiteSpace=wrap;html=1;verticalAlign=top;align=center;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="534" y="1152" width="196" height="150" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-32" value="getImage()" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="564" y="1209" width="136" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="Ht36qwYIb0A0iwGBjog0-38" value="/api/v1/images/upload/{noticeID}" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="-60" y="590" width="200" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
</root>
|
||||||
|
</mxGraphModel>
|
||||||
|
</diagram>
|
||||||
|
</mxfile>
|
||||||
Reference in New Issue
Block a user