Compare commits
11 Commits
refactor-a
...
environmen
| Author | SHA1 | Date | |
|---|---|---|---|
| a7c8f22658 | |||
| f31885c795 | |||
| edeb36cb8c | |||
| bacfd529aa | |||
| 8656ececf1 | |||
| 1d104493b5 | |||
| d51161221c | |||
|
|
422daeb99e | ||
|
|
3204b921c4 | ||
| f56ffacec3 | |||
|
|
1ec6e62c04 |
@@ -26,7 +26,7 @@ public class SecurityConfig {
|
|||||||
.cors(cors -> cors.configure(http))
|
.cors(cors -> cors.configure(http))
|
||||||
.csrf(AbstractHttpConfigurer::disable)
|
.csrf(AbstractHttpConfigurer::disable)
|
||||||
.authorizeHttpRequests(auth -> auth
|
.authorizeHttpRequests(auth -> auth
|
||||||
.requestMatchers("/api/v1/auth/**").permitAll()
|
.requestMatchers("/api/v1/auth/**", "/api/v1/payments/notification").permitAll()
|
||||||
.anyRequest().authenticated())
|
.anyRequest().authenticated())
|
||||||
.sessionManagement(session -> session
|
.sessionManagement(session -> session
|
||||||
.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
|
.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import _11.asktpk.artisanconnectbackend.service.NoticeService;
|
|||||||
import jakarta.persistence.EntityNotFoundException;
|
import jakarta.persistence.EntityNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@@ -29,7 +30,7 @@ public class ImageController {
|
|||||||
private String uploadDir;
|
private String uploadDir;
|
||||||
|
|
||||||
@PostMapping("/upload/{id}")
|
@PostMapping("/upload/{id}")
|
||||||
public ResponseEntity<RequestResponseDTO> uploadImage(@RequestParam("file") MultipartFile file, @PathVariable("id") Long noticeId) {
|
public ResponseEntity<RequestResponseDTO> uploadImage(@RequestParam("file") MultipartFile file, @PathVariable("id") Long noticeId, @Param("isMainImage") Boolean isMainImage) {
|
||||||
try {
|
try {
|
||||||
if(file.isEmpty()) {
|
if(file.isEmpty()) {
|
||||||
return ResponseEntity.badRequest().body(new RequestResponseDTO("File is empty"));
|
return ResponseEntity.badRequest().body(new RequestResponseDTO("File is empty"));
|
||||||
@@ -44,10 +45,11 @@ public class ImageController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String newImageName = imageService.saveImageToStorage(uploadDir, file);
|
String newImageName = imageService.saveImageToStorage(uploadDir, file);
|
||||||
imageService.addImageNameToDB(newImageName, noticeId);
|
imageService.addImageNameToDB(newImageName, noticeId, isMainImage);
|
||||||
|
|
||||||
return ResponseEntity.ok(new RequestResponseDTO("Image uploaded successfully with new name: " + newImageName));
|
return ResponseEntity.ok(new RequestResponseDTO("Image uploaded successfully with new name: " + newImageName));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
return ResponseEntity.status(HttpStatus.UNSUPPORTED_MEDIA_TYPE).body(new RequestResponseDTO(e.getMessage()));
|
return ResponseEntity.status(HttpStatus.UNSUPPORTED_MEDIA_TYPE).body(new RequestResponseDTO(e.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package _11.asktpk.artisanconnectbackend.controller;
|
package _11.asktpk.artisanconnectbackend.controller;
|
||||||
|
|
||||||
import _11.asktpk.artisanconnectbackend.dto.*;
|
import _11.asktpk.artisanconnectbackend.dto.*;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Client;
|
||||||
import _11.asktpk.artisanconnectbackend.entities.Order;
|
import _11.asktpk.artisanconnectbackend.entities.Order;
|
||||||
|
import _11.asktpk.artisanconnectbackend.entities.Payment;
|
||||||
import _11.asktpk.artisanconnectbackend.service.OrderService;
|
import _11.asktpk.artisanconnectbackend.service.OrderService;
|
||||||
import _11.asktpk.artisanconnectbackend.service.PaymentService;
|
import _11.asktpk.artisanconnectbackend.service.PaymentService;
|
||||||
import _11.asktpk.artisanconnectbackend.utils.Enums;
|
import _11.asktpk.artisanconnectbackend.utils.Enums;
|
||||||
@@ -11,6 +13,8 @@ import org.springframework.http.HttpStatus;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/orders")
|
@RequestMapping("/api/v1/orders")
|
||||||
@@ -38,21 +42,95 @@ public class OrderController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/token")
|
@PostMapping("/token")
|
||||||
public ResponseEntity<?> fetchToken() {
|
public ResponseEntity<?> fetchToken(@RequestParam Long orderId) {
|
||||||
Order order = orderService.getOrderById(1L);
|
Order order = orderService.getOrderById(orderId);
|
||||||
|
Client client = order.getClient();
|
||||||
OAuthPaymentResponseDTO authPaymentDTO = paymentService.getOAuthToken();
|
OAuthPaymentResponseDTO authPaymentDTO = paymentService.getOAuthToken();
|
||||||
TransactionPaymentRequestDTO.Payer payer = new TransactionPaymentRequestDTO.Payer(
|
TransactionPaymentRequestDTO.Payer payer = new TransactionPaymentRequestDTO.Payer(
|
||||||
"patryk@test.pl", "Patryk Test");
|
client.getEmail(), client.getFirstName()+' '+client.getLastName());
|
||||||
|
|
||||||
String paymentDescription = order.getOrderType() == Enums.OrderType.ACTIVATION ? "Aktywacja ogłoszenia" : "Podbicie ogłoszenia";
|
String paymentDescription = order.getOrderType() == Enums.OrderType.ACTIVATION ? "Aktywacja ogłoszenia" : "Podbicie ogłoszenia";
|
||||||
paymentDescription += order.getNotice().getTitle();
|
paymentDescription += order.getNotice().getTitle();
|
||||||
TransactionPaymentRequestDTO request = new TransactionPaymentRequestDTO(
|
|
||||||
order.getAmount(), paymentDescription, payer);
|
|
||||||
|
|
||||||
String response = paymentService.createTransaction(order, authPaymentDTO.getAccess_token(), request);
|
TransactionPaymentRequestDTO.Callbacks callbacks = new TransactionPaymentRequestDTO.Callbacks();
|
||||||
System.out.println(response);
|
TransactionPaymentRequestDTO.PayerUrls payerUrls = new TransactionPaymentRequestDTO.PayerUrls();
|
||||||
System.out.println(request);
|
payerUrls.setSuccess("com.hamx.artisanconnect://dashboard/userNotices");
|
||||||
|
payerUrls.setError("com.hamx.artisanconnect://dashboard/userNotices");
|
||||||
|
callbacks.setPayerUrls(payerUrls);
|
||||||
|
|
||||||
|
TransactionPaymentRequestDTO paymentRequest = new TransactionPaymentRequestDTO(
|
||||||
|
order.getAmount(), paymentDescription, payer, callbacks);
|
||||||
|
|
||||||
|
String response = paymentService.createTransaction(order, authPaymentDTO.getAccess_token(), paymentRequest);
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(response);
|
return ResponseEntity.status(HttpStatus.OK).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get/all")
|
||||||
|
public ResponseEntity<List<OrderWithPaymentsDTO>> getOrders(HttpServletRequest request) {
|
||||||
|
Long clientId = tools.getClientIdFromRequest(request);
|
||||||
|
List<Order> orders = orderService.getOrdersByClientId(clientId);
|
||||||
|
|
||||||
|
List<OrderWithPaymentsDTO> dtoList = orders.stream().map(order -> {
|
||||||
|
OrderWithPaymentsDTO dto = new OrderWithPaymentsDTO();
|
||||||
|
dto.setOrderId(order.getId());
|
||||||
|
dto.setOrderType(order.getOrderType().name());
|
||||||
|
dto.setStatus(order.getStatus().name());
|
||||||
|
dto.setAmount(order.getAmount());
|
||||||
|
dto.setCreatedAt(order.getCreatedAt());
|
||||||
|
|
||||||
|
List<Payment> payments = paymentService.getPaymentsByOrderId(order.getId());
|
||||||
|
|
||||||
|
List<PaymentDTO> paymentDTOs = payments.stream().map(payment -> {
|
||||||
|
PaymentDTO pDto = new PaymentDTO();
|
||||||
|
pDto.setPaymentId(payment.getIdPayment());
|
||||||
|
pDto.setAmount(payment.getAmount());
|
||||||
|
pDto.setStatus(payment.getStatus().name());
|
||||||
|
pDto.setTransactionPaymentUrl(payment.getTransactionPaymentUrl());
|
||||||
|
pDto.setTransactionId(payment.getTransactionId());
|
||||||
|
return pDto;
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
dto.setPayments(paymentDTOs);
|
||||||
|
return dto;
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
return ResponseEntity.ok(dtoList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get/{orderId}")
|
||||||
|
public ResponseEntity<OrderWithPaymentsDTO> getOrderById(HttpServletRequest request,
|
||||||
|
@PathVariable Long orderId) {
|
||||||
|
Long clientId = tools.getClientIdFromRequest(request);
|
||||||
|
|
||||||
|
Order order = orderService.getOrderById(orderId);
|
||||||
|
|
||||||
|
if (!order.getClient().getId().equals(clientId)) {
|
||||||
|
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
OrderWithPaymentsDTO dto = new OrderWithPaymentsDTO();
|
||||||
|
dto.setOrderId(order.getId());
|
||||||
|
dto.setOrderType(order.getOrderType().name());
|
||||||
|
dto.setStatus(order.getStatus().name());
|
||||||
|
dto.setAmount(order.getAmount());
|
||||||
|
dto.setCreatedAt(order.getCreatedAt());
|
||||||
|
|
||||||
|
List<Payment> payments = paymentService.getPaymentsByOrderId(order.getId());
|
||||||
|
List<PaymentDTO> paymentDTOs = payments.stream().map(payment -> {
|
||||||
|
PaymentDTO pDto = new PaymentDTO();
|
||||||
|
pDto.setPaymentId(payment.getIdPayment());
|
||||||
|
pDto.setAmount(payment.getAmount());
|
||||||
|
pDto.setStatus(payment.getStatus().name());
|
||||||
|
pDto.setTransactionPaymentUrl(payment.getTransactionPaymentUrl());
|
||||||
|
pDto.setTransactionId(payment.getTransactionId());
|
||||||
|
return pDto;
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
dto.setPayments(paymentDTOs);
|
||||||
|
|
||||||
|
return ResponseEntity.ok(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,9 +39,6 @@ public class PaymentController {
|
|||||||
|
|
||||||
@PostMapping(value = "/notification", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
@PostMapping(value = "/notification", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||||
public ResponseEntity<String> handleTpayNotification(@RequestParam Map<String, String> params) {
|
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 id = params.get("id");
|
||||||
String trId = params.get("tr_id");
|
String trId = params.get("tr_id");
|
||||||
String trAmount = params.get("tr_amount");
|
String trAmount = params.get("tr_amount");
|
||||||
@@ -54,7 +51,6 @@ public class PaymentController {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!expectedMd5.equals(md5sum)) {
|
if (!expectedMd5.equals(md5sum)) {
|
||||||
log.warn("❌ Błędna suma kontrolna! Otrzymano: {}, Oczekiwano: {}", md5sum, expectedMd5);
|
|
||||||
return ResponseEntity.status(400).body("INVALID CHECKSUM");
|
return ResponseEntity.status(400).body("INVALID CHECKSUM");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +59,6 @@ public class PaymentController {
|
|||||||
Payment payment = optionalPayment.get();
|
Payment payment = optionalPayment.get();
|
||||||
|
|
||||||
if ("true".equalsIgnoreCase(trStatus) || "PAID".equalsIgnoreCase(trStatus)) {
|
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);
|
payment.setStatus(Enums.PaymentStatus.CORRECT);
|
||||||
|
|
||||||
if (payment.getOrder() != null) {
|
if (payment.getOrder() != null) {
|
||||||
@@ -78,7 +73,6 @@ public class PaymentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if ("false".equalsIgnoreCase(trStatus)) {
|
} else if ("false".equalsIgnoreCase(trStatus)) {
|
||||||
log.warn("❌ Transakcja nieudana: {}", trId);
|
|
||||||
payment.setStatus(Enums.PaymentStatus.INCORRECT);
|
payment.setStatus(Enums.PaymentStatus.INCORRECT);
|
||||||
|
|
||||||
if (payment.getOrder() != null) {
|
if (payment.getOrder() != null) {
|
||||||
@@ -87,10 +81,7 @@ public class PaymentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
paymentRepository.save(payment);
|
paymentRepository.save(payment);
|
||||||
} else {
|
|
||||||
log.warn("⚠️ Brak płatności o tr_id={}", trId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseEntity.ok("TRUE");
|
return ResponseEntity.ok("TRUE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
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,17 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
|
public class OrderWithPaymentsDTO {
|
||||||
|
private Long orderId;
|
||||||
|
private String orderType;
|
||||||
|
private String status;
|
||||||
|
private Double amount;
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
private List<PaymentDTO> payments;
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class PaymentDTO {
|
||||||
|
private Long paymentId;
|
||||||
|
private Double amount;
|
||||||
|
private String status;
|
||||||
|
private String transactionPaymentUrl;
|
||||||
|
private String transactionId;
|
||||||
|
|
||||||
|
public void setPaymentId(Long paymentId) {
|
||||||
|
this.paymentId = paymentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmount(Double amount) {
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransactionPaymentUrl(String transactionPaymentUrl) {
|
||||||
|
this.transactionPaymentUrl = transactionPaymentUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransactionId(String transactionId) {
|
||||||
|
this.transactionId = transactionId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ public class TransactionPaymentRequestDTO {
|
|||||||
private double amount;
|
private double amount;
|
||||||
private String description;
|
private String description;
|
||||||
private Payer payer;
|
private Payer payer;
|
||||||
|
private Callbacks callbacks;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@@ -20,4 +21,21 @@ public class TransactionPaymentRequestDTO {
|
|||||||
private String email;
|
private String email;
|
||||||
private String name;
|
private String name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class Callbacks {
|
||||||
|
private PayerUrls payerUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class PayerUrls {
|
||||||
|
private String success;
|
||||||
|
private String error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import _11.asktpk.artisanconnectbackend.entities.Order;
|
|||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface OrderRepository extends JpaRepository<Order, Long> {
|
public interface OrderRepository extends JpaRepository<Order, Long> {
|
||||||
|
List<Order> findByClientId(Long clientId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,12 @@ import _11.asktpk.artisanconnectbackend.entities.Payment;
|
|||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface PaymentRepository extends JpaRepository<Payment, Long> {
|
public interface PaymentRepository extends JpaRepository<Payment, Long> {
|
||||||
Optional<Payment> findByTransactionId(String transactionId);
|
Optional<Payment> findByTransactionId(String transactionId);
|
||||||
|
|
||||||
|
List<Payment> findAllByOrderId(Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import _11.asktpk.artisanconnectbackend.dto.ClientDTO;
|
|||||||
import _11.asktpk.artisanconnectbackend.entities.Client;
|
import _11.asktpk.artisanconnectbackend.entities.Client;
|
||||||
import _11.asktpk.artisanconnectbackend.security.JwtUtil;
|
import _11.asktpk.artisanconnectbackend.security.JwtUtil;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -23,10 +22,10 @@ public class AuthService {
|
|||||||
private final PasswordEncoder passwordEncoder;
|
private final PasswordEncoder passwordEncoder;
|
||||||
private final JwtUtil jwtUtil;
|
private final JwtUtil jwtUtil;
|
||||||
|
|
||||||
public AuthService(ClientService clientService, JwtUtil jwtUtil) {
|
public AuthService(ClientService clientService, JwtUtil jwtUtil, PasswordEncoder passwordEncoder) {
|
||||||
this.clientService = clientService;
|
this.clientService = clientService;
|
||||||
this.jwtUtil = jwtUtil;
|
this.jwtUtil = jwtUtil;
|
||||||
this.passwordEncoder = new BCryptPasswordEncoder();
|
this.passwordEncoder = passwordEncoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthResponseDTO login(String email, String password) throws Exception {
|
public AuthResponseDTO login(String email, String password) throws Exception {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import _11.asktpk.artisanconnectbackend.entities.Role;
|
|||||||
import _11.asktpk.artisanconnectbackend.repository.ClientRepository;
|
import _11.asktpk.artisanconnectbackend.repository.ClientRepository;
|
||||||
import _11.asktpk.artisanconnectbackend.repository.RolesRepository;
|
import _11.asktpk.artisanconnectbackend.repository.RolesRepository;
|
||||||
import jakarta.persistence.EntityNotFoundException;
|
import jakarta.persistence.EntityNotFoundException;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -15,12 +14,10 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public class ClientService {
|
public class ClientService {
|
||||||
private final ClientRepository clientRepository;
|
private final ClientRepository clientRepository;
|
||||||
private final PasswordEncoder passwordEncoder;
|
|
||||||
private final RolesRepository rolesRepository;
|
private final RolesRepository rolesRepository;
|
||||||
|
|
||||||
public ClientService(ClientRepository clientRepository, PasswordEncoder passwordEncoder, RolesRepository rolesRepository) {
|
public ClientService(ClientRepository clientRepository, RolesRepository rolesRepository) {
|
||||||
this.clientRepository = clientRepository;
|
this.clientRepository = clientRepository;
|
||||||
this.passwordEncoder = passwordEncoder;
|
|
||||||
this.rolesRepository = rolesRepository;
|
this.rolesRepository = rolesRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +123,6 @@ public class ClientService {
|
|||||||
|
|
||||||
public ClientDTO registerClient(Client client) {
|
public ClientDTO registerClient(Client client) {
|
||||||
client.setRole(getUserRole()); // ID 1 - USER role
|
client.setRole(getUserRole()); // ID 1 - USER role
|
||||||
client.setPassword(passwordEncoder.encode(client.getPassword()));
|
|
||||||
return toDto(clientRepository.save(client));
|
return toDto(clientRepository.save(client));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ public class EmailService {
|
|||||||
|
|
||||||
public void sendEmail(EmailDTO email) {
|
public void sendEmail(EmailDTO email) {
|
||||||
SimpleMailMessage message = new SimpleMailMessage();
|
SimpleMailMessage message = new SimpleMailMessage();
|
||||||
|
message.setFrom("noreply@zikor.pl");
|
||||||
message.setTo(email.getTo());
|
message.setTo(email.getTo());
|
||||||
message.setSubject(email.getSubject());
|
message.setSubject(email.getSubject());
|
||||||
message.setText(email.getBody());
|
message.setText(email.getBody());
|
||||||
message.setFrom("patryk.kania001@gmail.com");
|
|
||||||
mailSender.send(message);
|
mailSender.send(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,10 +40,11 @@ public class ImageService {
|
|||||||
return uniqueFileName;
|
return uniqueFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addImageNameToDB(String filename, Long noticeId) {
|
public void addImageNameToDB(String filename, Long noticeId, boolean isMainImage) {
|
||||||
Image image = new Image();
|
Image image = new Image();
|
||||||
image.setImageName(filename);
|
image.setImageName(filename);
|
||||||
image.setNoticeId(noticeId);
|
image.setNoticeId(noticeId);
|
||||||
|
image.setMainImage(isMainImage);
|
||||||
imageRepository.save(image);
|
imageRepository.save(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import _11.asktpk.artisanconnectbackend.entities.Order;
|
import _11.asktpk.artisanconnectbackend.entities.Order;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class OrderService {
|
public class OrderService {
|
||||||
@@ -75,4 +76,8 @@ public class OrderService {
|
|||||||
return orderRepository.findById(id)
|
return orderRepository.findById(id)
|
||||||
.orElseThrow(() -> new RuntimeException("Nie znaleziono zamówienia o ID: " + id));
|
.orElseThrow(() -> new RuntimeException("Nie znaleziono zamówienia o ID: " + id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Order> getOrdersByClientId(Long clientId) {
|
||||||
|
return orderRepository.findByClientId(clientId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import org.springframework.web.reactive.function.BodyInserters;
|
|||||||
import org.springframework.web.reactive.function.client.WebClient;
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class PaymentService {
|
public class PaymentService {
|
||||||
private final WebClient webClient;
|
private final WebClient webClient;
|
||||||
@@ -80,4 +82,10 @@ public class PaymentService {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Payment> getPaymentsByOrderId(Long id) {
|
||||||
|
return paymentRepository.findAllByOrderId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +1,41 @@
|
|||||||
spring.application.name=ArtisanConnectBackend
|
spring.application.name=ArtisanConnectBackend
|
||||||
|
|
||||||
## PostgreSQL
|
## PostgreSQL
|
||||||
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
|
spring.datasource.url=${DB_URL:jdbc:postgresql://db:5432/postgres}
|
||||||
|
spring.datasource.username=${DB_USER:postgres}
|
||||||
|
spring.datasource.password=${DB_PASS:postgres}
|
||||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||||
spring.datasource.username=postgres
|
|
||||||
spring.datasource.password=postgres
|
|
||||||
|
|
||||||
#initial data for db injection
|
#Injekcja danych przyk?adowych przy starcie bazy
|
||||||
spring.sql.init.data-locations=classpath:sql/data.sql
|
spring.sql.init.data-locations=classpath:sql/data.sql
|
||||||
spring.sql.init.mode=always
|
spring.sql.init.mode=always
|
||||||
spring.jpa.defer-datasource-initialization=true
|
spring.jpa.defer-datasource-initialization=true
|
||||||
|
|
||||||
# create and drop table, good for testing, production set to none or comment it
|
#Sposób zachowania JPA
|
||||||
spring.jpa.hibernate.ddl-auto=create-drop
|
spring.jpa.hibernate.ddl-auto=create-drop
|
||||||
|
|
||||||
file.upload-dir=/Users/andsol/Desktop/uploads
|
#Gdzie uploadujemy zdj?cia i maksymalny rozmiar
|
||||||
spring.servlet.multipart.max-file-size=10MB
|
file.upload-dir=${IMAGES_UPLOAD_DIR:/app/images}
|
||||||
spring.servlet.multipart.max-request-size=10MB
|
spring.servlet.multipart.max-file-size=${MAX_FILE_SIZE:10MB}
|
||||||
|
spring.servlet.multipart.max-request-size=${MAX_REQUEST_SIZE:10MB}
|
||||||
|
|
||||||
spring.mail.host=smtp.gmail.com
|
#Ustawienia wysy?ania maili
|
||||||
spring.mail.port=587
|
spring.mail.host=${MAIL_HOST}
|
||||||
spring.mail.username=patryk.kania001@gmail.com
|
spring.mail.port=${MAIL_PORT}
|
||||||
spring.mail.password=pmyd ylwg mbsn hcpp
|
spring.mail.username=${MAIL_USER}
|
||||||
spring.mail.properties.mail.smtp.auth=true
|
spring.mail.password=${MAIL_PASSWORD}
|
||||||
spring.mail.properties.mail.smtp.starttls.enable=true
|
|
||||||
|
|
||||||
tpay.clientId = 01JQKC048X62ST9V59HNRSXD92-01JQKC2CQHPYXQFSFX8BKC24BX
|
#Ustawienia TPay
|
||||||
tpay.clientSecret = 44898642be53381cdcc47f3e44bf5a15e592f5d270fc3a6cf6fb81a8b8ebffb9
|
tpay.clientId=${TPAY_CLIENT_ID}
|
||||||
tpay.authUrl = https://openapi.sandbox.tpay.com/oauth/auth
|
tpay.clientSecret=${TPAY_SECRET}
|
||||||
tpay.transactionUrl = https://openapi.sandbox.tpay.com/transactions
|
tpay.authUrl=${TPAY_AUTH_URL}
|
||||||
tpay.securityCode = )IY7E)YSM!A)Q6O-GN#U7U_33s9qObk8
|
tpay.transactionUrl=${TPAY_TRANSACTION_URL}
|
||||||
|
tpay.securityCode = ${TPAY_SECURITY_CODE}
|
||||||
|
|
||||||
#jwt settings
|
#Ustawienia JWT
|
||||||
jwt.secret=DIXLsOs3FKmCAQwISd0SKsHMXJrPl3IKIRkVlkOvYW7kEcdUTbxh8zFe1B3eZWkY
|
jwt.secret=${JWT_SECRET}
|
||||||
jwt.expiration=300000
|
jwt.expiration=1200000
|
||||||
|
|
||||||
|
#Ustawienia logowania
|
||||||
logging.file.name=logs/payment-notifications.log
|
logging.file.name=logs/payment-notifications.log
|
||||||
logging.level.TpayLogger=INFO
|
logging.level.TpayLogger=INFO
|
||||||
Reference in New Issue
Block a user