Compare commits
1 Commits
71fdf1640a
...
initNotice
| Author | SHA1 | Date | |
|---|---|---|---|
| d869a18901 |
29
pom.xml
29
pom.xml
@@ -10,7 +10,7 @@
|
||||
</parent>
|
||||
<groupId>_11.asktpk</groupId>
|
||||
<artifactId>ArtisanConnectBackend</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<version>1.0.0</version>
|
||||
<name>ArtisanConnectBackend</name>
|
||||
<description>ArtisanConnectBackend</description>
|
||||
<url/>
|
||||
@@ -34,31 +34,16 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</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>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-docker-compose</artifactId>-->
|
||||
<!-- <scope>runtime</scope>-->
|
||||
<!-- <optional>true</optional>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
@@ -73,15 +58,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.security</groupId>-->
|
||||
<!-- <artifactId>spring-security-test</artifactId>-->
|
||||
<!-- <scope>test</scope>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.9.3</version>
|
||||
<version>4.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
@@ -93,11 +73,6 @@
|
||||
<artifactId>jakarta.validation-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springdoc</groupId>-->
|
||||
<!-- <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>-->
|
||||
<!-- <version>2.8.5</version>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
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;
|
||||
@@ -29,7 +31,7 @@ public class NoticeController {
|
||||
}
|
||||
|
||||
@GetMapping("/get/{id}")
|
||||
public ResponseEntity getNoticeById(@PathVariable long id) {
|
||||
public ResponseEntity<?> getNoticeById(@PathVariable long id) {
|
||||
if (noticeService.noticeExists(id)) {
|
||||
return ResponseEntity.ok(noticeService.getNoticeById(id));
|
||||
} else {
|
||||
@@ -98,23 +100,22 @@ public class NoticeController {
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity deleteNotice(@PathVariable("id") long id) {
|
||||
public ResponseEntity<RequestResponseDTO> deleteNotice(@PathVariable("id") long id) {
|
||||
if (noticeService.noticeExists(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 {
|
||||
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}")
|
||||
public ResponseEntity boostNotice(@PathVariable("id") long id) {
|
||||
long clientId = 1L;
|
||||
if (!noticeService.isNoticeOwnedByClient(id, clientId)) {
|
||||
throw new EntityNotFoundException("Ogłoszenie nie istnieje lub nie należy do zalogowanego klienta.");
|
||||
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(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;
|
||||
|
||||
import _11.asktpk.artisanconnectbackend.utils.Enums;
|
||||
import _11.asktpk.artisanconnectbackend.utils.Enums.Status;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "orders")
|
||||
@Getter
|
||||
@Setter
|
||||
public class Orders {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private Long idOrder;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "id_client")
|
||||
@JoinColumn(name = "id_user")
|
||||
private Client client;
|
||||
|
||||
@ManyToOne
|
||||
@@ -27,18 +20,7 @@ public class Orders {
|
||||
private Notice notice;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private Enums.OrderType orderType;
|
||||
private Status status;
|
||||
|
||||
@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;
|
||||
// Getters, setters, and constructors
|
||||
}
|
||||
|
||||
@@ -43,20 +43,4 @@ public class Enums {
|
||||
public enum Status {
|
||||
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
|
||||
spring.servlet.multipart.max-file-size=10MB
|
||||
spring.servlet.multipart.max-request-size=10MB
|
||||
|
||||
tpay.clientId = 01JQKC048X62ST9V59HNRSXD92-01JQKC2CQHPYXQFSFX8BKC24BX
|
||||
tpay.secret = e701f2feee2b9c967bf3e67a4e71c76377701f4b1e9d92f6af2e75c97e7df210
|
||||
spring.servlet.multipart.max-request-size=10MB
|
||||
Reference in New Issue
Block a user