Compare commits
1 Commits
initNotice
...
71fdf1640a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71fdf1640a |
29
pom.xml
29
pom.xml
@@ -10,7 +10,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<groupId>_11.asktpk</groupId>
|
<groupId>_11.asktpk</groupId>
|
||||||
<artifactId>ArtisanConnectBackend</artifactId>
|
<artifactId>ArtisanConnectBackend</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<name>ArtisanConnectBackend</name>
|
<name>ArtisanConnectBackend</name>
|
||||||
<description>ArtisanConnectBackend</description>
|
<description>ArtisanConnectBackend</description>
|
||||||
<url/>
|
<url/>
|
||||||
@@ -34,16 +34,31 @@
|
|||||||
<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>
|
||||||
@@ -58,10 +73,15 @@
|
|||||||
<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.12.0</version>
|
<version>4.9.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
@@ -73,6 +93,11 @@
|
|||||||
<artifactId>jakarta.validation-api</artifactId>
|
<artifactId>jakarta.validation-api</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.springdoc</groupId>-->
|
||||||
|
<!-- <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>-->
|
||||||
|
<!-- <version>2.8.5</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package _11.asktpk.artisanconnectbackend.controller;
|
package _11.asktpk.artisanconnectbackend.controller;
|
||||||
|
|
||||||
import _11.asktpk.artisanconnectbackend.dto.NoticeAdditionDTO;
|
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.ClientService;
|
||||||
import _11.asktpk.artisanconnectbackend.service.NoticeService;
|
import _11.asktpk.artisanconnectbackend.service.NoticeService;
|
||||||
import _11.asktpk.artisanconnectbackend.dto.NoticeDTO;
|
import _11.asktpk.artisanconnectbackend.dto.NoticeDTO;
|
||||||
@@ -31,7 +29,7 @@ public class NoticeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get/{id}")
|
@GetMapping("/get/{id}")
|
||||||
public ResponseEntity<?> getNoticeById(@PathVariable long id) {
|
public ResponseEntity getNoticeById(@PathVariable long id) {
|
||||||
if (noticeService.noticeExists(id)) {
|
if (noticeService.noticeExists(id)) {
|
||||||
return ResponseEntity.ok(noticeService.getNoticeById(id));
|
return ResponseEntity.ok(noticeService.getNoticeById(id));
|
||||||
} else {
|
} else {
|
||||||
@@ -100,22 +98,23 @@ public class NoticeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
public ResponseEntity<RequestResponseDTO> deleteNotice(@PathVariable("id") long id) {
|
public ResponseEntity deleteNotice(@PathVariable("id") long id) {
|
||||||
if (noticeService.noticeExists(id)) {
|
if (noticeService.noticeExists(id)) {
|
||||||
noticeService.deleteNotice(id);
|
noticeService.deleteNotice(id);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new RequestResponseDTO("Pomyślnie usunięto ogłoszenie o ID: " + id));
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
} else {
|
} else {
|
||||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new RequestResponseDTO("Nie znaleziono ogłoszenia o ID: " + id));
|
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/boost/{id}")
|
@PostMapping("/boost/{id}")
|
||||||
public ResponseEntity<RequestResponseDTO> boostNotice(@PathVariable("id") long clientId, @RequestBody NoticeBoostDTO dto) {
|
public ResponseEntity boostNotice(@PathVariable("id") long id) {
|
||||||
if (!noticeService.isNoticeOwnedByClient(dto.getNoticeId(), clientId)) {
|
long clientId = 1L;
|
||||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new RequestResponseDTO("Ogłoszenie nie istnieje lub nie należy do zalogowanego klienta."));
|
if (!noticeService.isNoticeOwnedByClient(id, clientId)) {
|
||||||
|
throw new EntityNotFoundException("Ogłoszenie nie istnieje lub nie należy do zalogowanego klienta.");
|
||||||
}
|
}
|
||||||
noticeService.boostNotice(dto.getNoticeId());
|
noticeService.boostNotice(id);
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new RequestResponseDTO("Ogłoszenie zostało pomyślnie wypromowane."));
|
return ResponseEntity.ok("Ogłoszenie zostało pomyślnie wypromowane.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
package _11.asktpk.artisanconnectbackend.dto;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Getter @Setter
|
|
||||||
public class NoticeBoostDTO {
|
|
||||||
private Long noticeId;
|
|
||||||
}
|
|
||||||
@@ -1,18 +1,25 @@
|
|||||||
package _11.asktpk.artisanconnectbackend.entities;
|
package _11.asktpk.artisanconnectbackend.entities;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.utils.Enums;
|
||||||
import _11.asktpk.artisanconnectbackend.utils.Enums.Status;
|
import _11.asktpk.artisanconnectbackend.utils.Enums.Status;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "orders")
|
@Table(name = "orders")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
public class Orders {
|
public class Orders {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long idOrder;
|
private Long id;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "id_user")
|
@JoinColumn(name = "id_client")
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@@ -20,7 +27,18 @@ public class Orders {
|
|||||||
private Notice notice;
|
private Notice notice;
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private Status status;
|
@Column(nullable = false)
|
||||||
|
private Enums.OrderType orderType;
|
||||||
|
|
||||||
// Getters, setters, and constructors
|
@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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,4 +43,20 @@ public class Enums {
|
|||||||
public enum Status {
|
public enum Status {
|
||||||
ACTIVE, INACTIVE
|
ACTIVE, INACTIVE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum OrderType {
|
||||||
|
ACTIVATION,
|
||||||
|
BOOST
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public enum OrderStatus {
|
||||||
|
PENDING, COMPLETED, CANCELLED
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum PaymentStatus{
|
||||||
|
PENDING, CORRECT, INCORRECT
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,3 +17,6 @@ spring.jpa.hibernate.ddl-auto=create-drop
|
|||||||
file.upload-dir=/Users/andsol/Desktop/uploads
|
file.upload-dir=/Users/andsol/Desktop/uploads
|
||||||
spring.servlet.multipart.max-file-size=10MB
|
spring.servlet.multipart.max-file-size=10MB
|
||||||
spring.servlet.multipart.max-request-size=10MB
|
spring.servlet.multipart.max-request-size=10MB
|
||||||
|
|
||||||
|
tpay.clientId = 01JQKC048X62ST9V59HNRSXD92-01JQKC2CQHPYXQFSFX8BKC24BX
|
||||||
|
tpay.secret = e701f2feee2b9c967bf3e67a4e71c76377701f4b1e9d92f6af2e75c97e7df210
|
||||||
|
|||||||
Reference in New Issue
Block a user