Skip to content

Commit

Permalink
Fixed Redis + various webserver changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad45123 committed May 14, 2024
1 parent a7d4651 commit 223468d
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import com.workup.shared.enums.payments.WalletTransactionType;
import java.util.Date;
import lombok.Data;
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;

@SuperBuilder(setterPrefix = "with")
@Jacksonized
@Data
public class WalletTransactionDTO {

private String id;
Expand Down
11 changes: 10 additions & 1 deletion shared/src/main/java/com/workup/shared/redis/RedisConfig.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.workup.shared.redis;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
Expand All @@ -10,9 +12,16 @@
@Configuration
public class RedisConfig {

@Value("${spring.cache.host}")
private String REDIS_HOST;

@Value("${spring.cache.port}")
private Integer REDIS_PORT;

@Bean
public JedisConnectionFactory jedisConnectionFactory() {
return new JedisConnectionFactory();
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration(REDIS_HOST, REDIS_PORT);
return new JedisConnectionFactory(config);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
.hasAuthority(ROLE_FREELANCER)
.requestMatchers(HttpMethod.GET, "/api/v1/jobs/me/proposals")
.hasAuthority(ROLE_FREELANCER)
.requestMatchers(HttpMethod.POST, "/api/v1/jobs/proposals/{id}/accept")
.requestMatchers(
HttpMethod.POST, "/api/v1/jobs/{jobId}/proposals/{proposalId}/accept")
.hasAuthority(ROLE_CLIENT)
.requestMatchers("/api/v1/payments/clients/**")
.hasAuthority(ROLE_CLIENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public ResponseEntity<GetMilestoneResponse> getMilestoneById(
return ResponseEntity.status(response.getStatusCode().getValue()).body(response);
}

@GetMapping("/{id}")
@GetMapping("/{id}/terminations")
public ResponseEntity<GetPendingTerminationsResponse> getContractTermination(
@PathVariable String id, @RequestAttribute(name = "userId") String userId) {
GetPendingTerminationsRequest request =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ public ResponseEntity<CreateProposalResponse> createProposal(
@PathVariable String id,
@RequestBody CreateProposalRequest request,
@RequestAttribute(name = "userId") String userId) {
System.out.println("Setting CreateProposalResponse");

request.setUserId(userId);
request.setJobId(id);

CreateProposalResponse response =
(CreateProposalResponse)
rabbitTemplate.convertSendAndReceive(ServiceQueueNames.JOBS, request);
Expand Down Expand Up @@ -117,7 +120,7 @@ public ResponseEntity<GetMyProposalsResponse> getMyProposals(
return ResponseEntity.status(response.getStatusCode().getValue()).body(response);
}

@GetMapping("/{jobId}/proposals/{proposalId}/accept")
@PostMapping("/{jobId}/proposals/{proposalId}/accept")
public ResponseEntity<AcceptProposalResponse> acceptProposal(
@PathVariable(name = "jobId") String jobId,
@PathVariable(name = "proposalId") String proposalId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
import com.workup.shared.commands.payments.paymenttransaction.responses.GetFreelancerPaymentTransactionsResponse;
import com.workup.shared.commands.payments.wallet.requests.GetWalletRequest;
import com.workup.shared.commands.payments.wallet.responses.GetWalletResponse;
import com.workup.shared.commands.payments.wallettransaction.requests.GetWalletTransactionRequest;
import com.workup.shared.commands.payments.wallettransaction.requests.GetWalletTransactionsRequest;
import com.workup.shared.commands.payments.wallettransaction.requests.WithdrawFromWalletRequest;
import com.workup.shared.commands.payments.wallettransaction.responses.GetWalletTransactionResponse;
import com.workup.shared.commands.payments.wallettransaction.responses.GetWalletTransactionsResponse;
import com.workup.shared.commands.payments.wallettransaction.responses.WithdrawFromWalletResponse;
import com.workup.shared.enums.ServiceQueueNames;
import org.springframework.amqp.core.AmqpTemplate;
Expand Down Expand Up @@ -81,6 +85,25 @@ public ResponseEntity<GetFreelancerPaymentTransactionsResponse> getFreelancerPay
return processRequest(request);
}

@GetMapping("/freelancers/me/wallet/transactions")
public ResponseEntity<GetWalletTransactionsResponse> getFreelancerWalletTransactions(
@RequestAttribute(name = "userId") String userId) {
GetWalletTransactionsRequest request =
GetWalletTransactionsRequest.builder().withFreelancerId(userId).withUserId(userId).build();
return processRequest(request);
}

@GetMapping("/freelancers/me/wallet/transactions/{id}")
public ResponseEntity<GetWalletTransactionResponse> getFreelancerWalletTransaction(
@PathVariable String id, @RequestAttribute(name = "userId") String userId) {
GetWalletTransactionRequest request =
GetWalletTransactionRequest.builder()
.withWalletTransactionId(id)
.withUserId(userId)
.build();
return processRequest(request);
}

@GetMapping("/freelancers/me/wallet")
public ResponseEntity<GetWalletResponse> getFreelancerWallet(
@RequestAttribute(name = "userId") String userId) {
Expand Down

0 comments on commit 223468d

Please sign in to comment.