otp resend otp, user activity implemented

Nabeel-DG-BS
Raja Nabeel 2 years ago
parent c512fedf60
commit 31ff361e90

@ -7,6 +7,7 @@ public interface UCOURI {
String FETCH_ACCOUNT_STATEMENT = "/accountStatement"; String FETCH_ACCOUNT_STATEMENT = "/accountStatement";
String FETCH_ACCOUNT_INQUIRY = "/accountInquiry"; String FETCH_ACCOUNT_INQUIRY = "/accountInquiry";
String GENERATE_TRANSACTIONS_REPORT = "/generateReport"; String GENERATE_TRANSACTIONS_REPORT = "/generateReport";
String RESEND_OTP = "/resend-otp";
String CREATE_TRAN_PIN = "/createTransactionPin"; String CREATE_TRAN_PIN = "/createTransactionPin";
String VERIFY_TRAN_PIN = "/verifyTransactionPin"; String VERIFY_TRAN_PIN = "/verifyTransactionPin";
String CHANGE_TRAN_PIN = "/changeTransactionPin"; String CHANGE_TRAN_PIN = "/changeTransactionPin";
@ -19,4 +20,6 @@ public interface UCOURI {
String ACCOUNT_STATEMENT = "/fetchDepositAccountStatement"; String ACCOUNT_STATEMENT = "/fetchDepositAccountStatement";
String BANKING_CASH_IN = "/deposit/transactions/uco/cash-in"; String BANKING_CASH_IN = "/deposit/transactions/uco/cash-in";
String BANKING_CASH_OUT = "/deposit/transactions/uco/cash-out"; String BANKING_CASH_OUT = "/deposit/transactions/uco/cash-out";
String ACCOUNT_ACTIVITY = "/account/activity/organization/{porOrgacode}/customer/{cmpCustcode}/customertype/{pctCstycode}/fromdate/{fdate}/todate/{tdate}";
} }

@ -26,8 +26,8 @@ public class WebClientconfiguration {
@Bean @Bean
public WebClient webClientCrm() { public WebClient webClientCrm() {
return WebClient.create(ciihive); // return WebClient.create(ciihive);
// return WebClient.create("http://localhost:9096"); return WebClient.create("http://localhost:9096");
} }
} }

@ -0,0 +1,78 @@
package com.mfsys.uco.constants;
import com.mfsys.uco.model.CustomerAccountActivity;
import com.mfsys.uco.model.CustomerProfile;
import com.mfsys.uco.repository.CustomerProfileRepository;
import com.mfsys.uco.service.CustomerAccountActivityService;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.util.ContentCachingResponseWrapper;
import java.io.IOException;
import java.net.URLDecoder;
import java.time.LocalDateTime;
@Component
public class LoggingActivityFilter extends OncePerRequestFilter {
private static final Logger LOGGER = LoggerFactory.getLogger(LoggingActivityFilter.class);
private final CustomerProfileRepository customerProfileRepository;
private final CustomerAccountActivityService custAccActivityService;
public LoggingActivityFilter(CustomerProfileRepository customerProfileRepository, CustomerAccountActivityService custAccActivityService) {
this.customerProfileRepository = customerProfileRepository;
this.custAccActivityService = custAccActivityService;
}
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Headers", "*");
response.setHeader("Access-Control-Expose-Headers", "*");
response.setHeader("Access-Control-Allow-Methods", "GET, POST, PATCH, PUT, DELETE, OPTIONS");
if (!(request.getMethod().equals("OPTIONS"))) {
filterChain.doFilter(request, response);
}
ContentCachingResponseWrapper responseWrapper = new ContentCachingResponseWrapper(response);
LOGGER.info(
"FINISHED PROCESSING: METHOD={}; REQUESTURI={}; RESPONSE CODE={}; IP={};",
request.getMethod(),
request.getRequestURI(),
response.getStatus(),
request.getRemoteAddr()
);
CustomerProfile cust;
String susUsercode = "";
if(request.getHeader("cmpUserId")!=null) {
susUsercode = URLDecoder.decode(request.getHeader("cmpUserId"), "UTF-8");
}
String porOrgacode = request.getHeader("porOrgacode");
String email = request.getHeader("email");
String channalCode = request.getHeader("channelCode");
String deviceName = request.getHeader("deviceName");
String userActivity = request.getHeader("userActivity");
cust = customerProfileRepository.findbyEmail(porOrgacode,email);
LocalDateTime date = LocalDateTime.now();
if (cust != null && userActivity!=null) {
CustomerAccountActivity activity = new CustomerAccountActivity(
null,
porOrgacode,
cust.getCmpCustcode(),
date,
channalCode,
deviceName,
userActivity,
cust
);
custAccActivityService.postCustomerAccountActivity(activity);;
}
}
}

@ -7,13 +7,11 @@ import com.itextpdf.layout.element.Paragraph;
import com.mfsys.uco.UCOURI; import com.mfsys.uco.UCOURI;
import com.mfsys.uco.dto.*; import com.mfsys.uco.dto.*;
import com.mfsys.uco.dto.webclientdto.AccountDetail; import com.mfsys.uco.dto.webclientdto.AccountDetail;
import com.mfsys.uco.model.CustomerAccountActivity;
import com.mfsys.uco.model.CustomerProfile; import com.mfsys.uco.model.CustomerProfile;
import com.mfsys.uco.model.UcoAccount; import com.mfsys.uco.model.UcoAccount;
import com.mfsys.uco.repository.UCOAccountRepository; import com.mfsys.uco.repository.UCOAccountRepository;
import com.mfsys.uco.service.CustomerProfileService; import com.mfsys.uco.service.*;
import com.mfsys.uco.service.TransactionPinService;
import com.mfsys.uco.service.TransactionService;
import com.mfsys.uco.service.UcoAccountService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -32,8 +30,10 @@ public class UserController {
private final TransactionPinService transactionPinService; private final TransactionPinService transactionPinService;
private final TransactionService transactionService; private final TransactionService transactionService;
private final NotificationService notificationService;
private final UcoAccountService ucoAccountService; private final UcoAccountService ucoAccountService;
private final CustomerProfileService customerProfileService; private final CustomerProfileService customerProfileService;
private final CustomerAccountActivityService customerAccountActivityService;
@PostMapping(UCOURI.ONBOARD_CUSTOMER) @PostMapping(UCOURI.ONBOARD_CUSTOMER)
public ResponseEntity<HttpStatus> customerOnBoarding(@RequestBody SignupStep3RequestModel signupStep3RequestModel) { public ResponseEntity<HttpStatus> customerOnBoarding(@RequestBody SignupStep3RequestModel signupStep3RequestModel) {
@ -160,4 +160,19 @@ public class UserController {
@RequestParam String porOrgacode) { @RequestParam String porOrgacode) {
return ucoAccountService.fetchExchangeRate(porOrgacode); return ucoAccountService.fetchExchangeRate(porOrgacode);
} }
@GetMapping(UCOURI.ACCOUNT_ACTIVITY)
public ResponseEntity<List<CustomerAccountActivity>> getCustomerAccountActivity(
@PathVariable String porOrgacode, @PathVariable String cmpCustcode,@RequestHeader String cmpUserId , @PathVariable String pctCstycode,@PathVariable String fdate,@PathVariable String tdate) {
return new ResponseEntity<List<CustomerAccountActivity>>(
customerAccountActivityService.getCustomerAccountActivity(porOrgacode, pctCstycode, cmpCustcode,cmpUserId, fdate, tdate),
HttpStatus.OK);
}
@PostMapping(UCOURI.RESEND_OTP)
@ResponseStatus(HttpStatus.OK)
public ResponseEntity<String> sendSignUpOtp(@RequestBody OTPRequest otpRequest) {
notificationService.sendOtp(otpRequest);
return ResponseEntity.ok("OTP sent");
}
} }

@ -0,0 +1,44 @@
package com.mfsys.uco.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.mfsys.comm.util.FieldNameLength;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.time.LocalDateTime;
@Entity
@Data
@AllArgsConstructor
public class CustomerAccountActivity {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
private Long id;
@Column(name = "POR_ORGACODE", nullable = false, updatable = false, columnDefinition = FieldNameLength.POR_ORGACODE)
private String porOrgacode;
@Column(name = "CMP_CUSTCODE", nullable = false, updatable = false, columnDefinition = FieldNameLength.CUSTOMER_CODE)
private String cmpCustcode;
private LocalDateTime date;
private String channal;
private String deviceName;
private String activity;
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns({
@JoinColumn(name = "POR_ORGACODE", referencedColumnName = "POR_ORGACODE", insertable = false, updatable = false),
@JoinColumn(name = "CMP_CUSTCODE", referencedColumnName = "CMP_CUSTCODE", insertable = false, updatable = false)})
private CustomerProfile customer;
public CustomerAccountActivity() {
}
}

@ -0,0 +1,17 @@
package com.mfsys.uco.repository;
import com.mfsys.uco.model.CustomerAccountActivity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface CustomerAccountActivityRepository extends JpaRepository<CustomerAccountActivity, Integer> {
@Query("SELECT cust FROM CustomerAccountActivity cust WHERE cust.cmpCustcode = :cmpUserId AND DATE(cust.date) BETWEEN DATE(:fdate) AND DATE(:tdate)")
List<CustomerAccountActivity> findAllByCmpUserIdAndDateBetween(String cmpUserId, String fdate, String tdate);
}

@ -0,0 +1,31 @@
package com.mfsys.uco.service;
import com.mfsys.uco.model.CustomerAccountActivity;
import com.mfsys.uco.repository.CustomerAccountActivityRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CustomerAccountActivityService {
private CustomerAccountActivityRepository customerAccountActivityRepository;
@Autowired
public CustomerAccountActivityService(CustomerAccountActivityRepository customerAccountActivityRepository) {
this.customerAccountActivityRepository = customerAccountActivityRepository;
}
public List<CustomerAccountActivity> getCustomerAccountActivity(String porOrgacode, String pctCstycode,
String cmpCustcode, String cmpUserId, String fdate, String tdate) {
return customerAccountActivityRepository.findAllByCmpUserIdAndDateBetween(cmpUserId, fdate, tdate);
}
public void postCustomerAccountActivity(CustomerAccountActivity customerAccountActivity) {
// TODO Auto-generated method stub
customerAccountActivityRepository.save(customerAccountActivity);
}
}
Loading…
Cancel
Save