Compare commits
1 Commits
71fdf1640a
...
initNotice
| Author | SHA1 | Date | |
|---|---|---|---|
| d869a18901 |
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>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,15 +58,10 @@
|
|||||||
<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>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
@@ -93,11 +73,6 @@
|
|||||||
<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,6 +1,8 @@
|
|||||||
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;
|
||||||
@@ -29,7 +31,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 {
|
||||||
@@ -98,23 +100,22 @@ public class NoticeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
public ResponseEntity deleteNotice(@PathVariable("id") long id) {
|
public ResponseEntity<RequestResponseDTO> deleteNotice(@PathVariable("id") long id) {
|
||||||
if (noticeService.noticeExists(id)) {
|
if (noticeService.noticeExists(id)) {
|
||||||
noticeService.deleteNotice(id);
|
noticeService.deleteNotice(id);
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return ResponseEntity.status(HttpStatus.OK).body(new RequestResponseDTO("Pomyślnie usunięto ogłoszenie o ID: " + id));
|
||||||
} else {
|
} else {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new RequestResponseDTO("Nie znaleziono ogłoszenia o ID: " + id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/boost/{id}")
|
@PostMapping("/boost/{id}")
|
||||||
public ResponseEntity boostNotice(@PathVariable("id") long id) {
|
public ResponseEntity<RequestResponseDTO> boostNotice(@PathVariable("id") long clientId, @RequestBody NoticeBoostDTO dto) {
|
||||||
long clientId = 1L;
|
if (!noticeService.isNoticeOwnedByClient(dto.getNoticeId(), clientId)) {
|
||||||
if (!noticeService.isNoticeOwnedByClient(id, clientId)) {
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new RequestResponseDTO("Ogłoszenie nie istnieje lub nie należy do zalogowanego klienta."));
|
||||||
throw new EntityNotFoundException("Ogłoszenie nie istnieje lub nie należy do zalogowanego klienta.");
|
|
||||||
}
|
}
|
||||||
noticeService.boostNotice(id);
|
noticeService.boostNotice(dto.getNoticeId());
|
||||||
|
|
||||||
return ResponseEntity.ok("Ogłoszenie zostało pomyślnie wypromowane.");
|
return ResponseEntity.status(HttpStatus.OK).body(new RequestResponseDTO("Ogłoszenie zostało pomyślnie wypromowane."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
|
public class NoticeBoostDTO {
|
||||||
|
private Long noticeId;
|
||||||
|
}
|
||||||
@@ -1,25 +1,18 @@
|
|||||||
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 id;
|
private Long idOrder;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "id_client")
|
@JoinColumn(name = "id_user")
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@@ -27,18 +20,7 @@ public class Orders {
|
|||||||
private Notice notice;
|
private Notice notice;
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
@Column(nullable = false)
|
private Status status;
|
||||||
private Enums.OrderType orderType;
|
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
// Getters, setters, and constructors
|
||||||
@Column(nullable = false)
|
|
||||||
private Enums.OrderStatus status;
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
private Double amount;
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
private LocalDateTime createdAt;
|
|
||||||
|
|
||||||
private LocalDateTime updatedAt;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,20 +43,4 @@ 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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,4 @@ 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