Commit[2]:Revamping User Controller

development
Omar Shahbaz 2 weeks ago
parent 6e877435d5
commit 92235ead51

@ -86,6 +86,18 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId> <artifactId>spring-boot-starter-webflux</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>7.2.5</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>layout</artifactId>
<version>7.2.5</version>
</dependency>
</dependencies> </dependencies>

@ -0,0 +1,66 @@
package com.mfsys.uco.compositeKeys;
import java.io.Serializable;
public class CustomerProfileId implements Serializable {
private static final long serialVersionUID = 1L;
private String porOrgacode;
private String cmpCustcode;
public CustomerProfileId() {
}
public CustomerProfileId(String porOrgacode, String cmpCustcode) {
this.porOrgacode = porOrgacode;
this.cmpCustcode = cmpCustcode;
}
public String getPorOrgacode() {
return porOrgacode;
}
public void setPorOrgacode(String porOrgacode) {
this.porOrgacode = porOrgacode;
}
public String getCmpCustcode() {
return cmpCustcode;
}
public void setCmpCustcode(String cmpCustcode) {
this.cmpCustcode = cmpCustcode;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((cmpCustcode == null) ? 0 : cmpCustcode.hashCode());
result = prime * result + ((porOrgacode == null) ? 0 : porOrgacode.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CustomerProfileId other = (CustomerProfileId) obj;
if (cmpCustcode == null) {
if (other.cmpCustcode != null)
return false;
} else if (!cmpCustcode.equals(other.cmpCustcode))
return false;
if (porOrgacode == null) {
if (other.porOrgacode != null)
return false;
} else if (!porOrgacode.equals(other.porOrgacode))
return false;
return true;
}
}

@ -3,4 +3,21 @@ package com.mfsys.uco.constants;
public interface UCOURI { public interface UCOURI {
String ONBOARD_CUSTOMER = "/auth/user/authenticate/onboardCutomer"; String ONBOARD_CUSTOMER = "/auth/user/authenticate/onboardCutomer";
String VIEW_BALANCE = "/user/viewBalance";
String FETCH_LOGIIN_DATA = "/fetchlogindata";
String FETCH_DEPOSITACCOUNTS = "/depositAccounts";
String FETCH_ACCOUNT_STATEMENT = "/accountStatement";
String FETCH_ACCOUNT_INQUIRY = "/accountInquiry";
String GENERATE_TRANSACTIONS_REPORT = "/generateReport";
String CREATE_TRAN_PIN = "/createTransactionPin";
String VERIFY_TRAN_PIN = "/verifyTransactionPin";
String CHANGE_TRAN_PIN = "/changeTransactionPin";
String FETCH_EXCHANGE_RATE = "/fetchExchangeRate";
String ACCOUNT_ACTIVITY = "/account/activity/organization/{porOrgacode}/customer/{cmpCustcode}/fromdate/{fdate}/todate/{tdate}";
String RESEND_OTP = "/resend-otp";
String ADD_UCO_CUSTOMER_ACCOUNT = "/createUcoAccount";
String UPDATE_CUSTOMER_PROFILE = "/updateCustomerProfile";
String ADD_BENEFICIARY = "/addBeneficary";
String GET_BENEFICIARY = "/getBeneficary";
String DELETE_BENEFICIARY = "/deleteBeneficary";
} }

@ -1,23 +1,46 @@
package com.mfsys.uco.controller; package com.mfsys.uco.controller;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.layout.element.Paragraph;
import com.itextpdf.layout.Document;
import com.mfsys.uco.constants.UCOURI; import com.mfsys.uco.constants.UCOURI;
import com.mfsys.uco.request.SignupStep3Request; import com.mfsys.uco.model.AccountDetail;
import com.mfsys.uco.service.UcoAccountService; import com.mfsys.uco.model.CustomerProfile;
import com.mfsys.uco.request.*;
import com.mfsys.uco.response.*;
import com.mfsys.uco.service.*;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
@RestController @RestController
@RequestMapping @RequestMapping
public class UserController { public class UserController {
private final UcoAccountService ucoAccountService; private final UcoAccountService ucoAccountService;
private final CustomerProfileService customerProfileService;
private final TransactionPinService transactionPinService;
private final CustomerAccountActivityService customerAccountActivityService;
private final NotificationService notificationService;
public UserController(UcoAccountService ucoAccountService) { public UserController(
UcoAccountService ucoAccountService,
CustomerProfileService customerProfileService,
TransactionPinService transactionPinService,
CustomerAccountActivityService customerAccountActivityService,
NotificationService notificationService) {
this.ucoAccountService = ucoAccountService; this.ucoAccountService = ucoAccountService;
this.customerProfileService = customerProfileService;
this.transactionPinService = transactionPinService;
this.customerAccountActivityService = customerAccountActivityService;
this.notificationService = notificationService;
} }
@PostMapping(UCOURI.ONBOARD_CUSTOMER) @PostMapping(UCOURI.ONBOARD_CUSTOMER)
@ -26,5 +49,142 @@ public class UserController {
return ResponseEntity.ok(HttpStatus.OK); return ResponseEntity.ok(HttpStatus.OK);
} }
@PostMapping(UCOURI.VIEW_BALANCE)
public ViewBalanceResponse viewBalance(@RequestBody ViewBalanceRequest viewBalanceRequest) {
ViewBalanceResponse viewBalanceResponse = new ViewBalanceResponse();
viewBalanceResponse.setMbmBkmsbalance(ucoAccountService.fetchAccountBalance(viewBalanceRequest.getPorOrgacode(), viewBalanceRequest.getMbmBkmsNumber()));
return viewBalanceResponse;
}
@GetMapping(UCOURI.FETCH_LOGIIN_DATA)
public CustomerProfile fetchlogindata(@RequestParam String porOrgacode, @RequestParam String email) {
return customerProfileService.fetchCustcodeBasedOnEmail(porOrgacode, email);
}
@GetMapping(UCOURI.FETCH_DEPOSITACCOUNTS)
public List<AccountDetail> getDepositAccounts(
@RequestParam String porOrgacode,
@RequestParam String cmpCustcode,
@RequestParam String pctCstycode) {
return ucoAccountService.fetchdepositAccountFromCiihive(porOrgacode, cmpCustcode);
}
@GetMapping(UCOURI.FETCH_ACCOUNT_STATEMENT)
public List<DepositAccountTransactionResponse> getAccountStatement(
@RequestParam String porOrgacode,
@RequestParam String mbmBkmsnumber,
@RequestParam String sgtGntrvaluedatefrom,
@RequestParam String sgtGntrvaluedateto
) {
List<DepositAccountTransactionResponse> transactions = new ArrayList<>();
DepositAccountTransactionResponse transaction = new DepositAccountTransactionResponse();
transaction.setTranID("12345");
transaction.setSgtGntrCreatedAt("2024-03-17");
transaction.setSgtGntrNarration("Sample Transaction");
transaction.setSgtGntrvaluedate("2024-03-17");
transaction.setDeposit("100.00");
transaction.setWithdrawal("0.00");
transaction.setStatus("approved");
transaction.setSgtGntramt("1000.00");
transactions.add(transaction);
return transactions;
}
@GetMapping(UCOURI.FETCH_ACCOUNT_INQUIRY)
public List<AccountInquiryResponse> getAccountInquiry(
@RequestParam String acntTypeCode,
@RequestParam String acntTypeValue,
@RequestParam String porOrgacode,
@RequestParam String channelCode) {
return ucoAccountService.fetchAccountTitile(porOrgacode, acntTypeCode, acntTypeValue);
}
@PostMapping(UCOURI.GENERATE_TRANSACTIONS_REPORT)
public String generateReport(@RequestBody TransactionHistoryRequest request) {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
PdfWriter writer = new PdfWriter(baos);
PdfDocument pdf = new PdfDocument(writer);
Document document = new Document(pdf);
document.add(new Paragraph("Account Transaction History Report"));
document.add(new Paragraph("Organization Code: " + request.getPorOrgacode()));
document.add(new Paragraph("Account Number: " + request.getMbmBkmsnumber()));
document.add(new Paragraph("From: " + request.getSgtGntrvaluedatefrom() + " To: " + request.getSgtGntrvaluedateto()));
document.close();
return Base64.getEncoder().encodeToString(baos.toByteArray());
} catch (Exception e) {
return "Error generating report";
}
}
@PostMapping(UCOURI.CREATE_TRAN_PIN)
public ResponseEntity<HttpStatus> createTransactionPin(@RequestBody CreateTransactionPinRequest request) {
transactionPinService.createTransactionPin(request);
return ResponseEntity.ok(HttpStatus.OK);
}
@PostMapping(UCOURI.VERIFY_TRAN_PIN)
public ResponseEntity<?> verifyPin(@RequestBody VerifyPinRequest request) {
transactionPinService.verifyOTPAndSavePin(request);
return ResponseEntity.ok(HttpStatus.OK);
}
@PutMapping(UCOURI.CHANGE_TRAN_PIN)
public ResponseEntity<String> updateTransactionPin(@RequestBody ChangeTransactionPinRequest request) {
transactionPinService.updateTransactionPin(request);
return ResponseEntity.ok("OTP sent");
}
@GetMapping(UCOURI.FETCH_EXCHANGE_RATE)
public Object fetchExchangeRate(@RequestParam String porOrgacode) {
return ucoAccountService.fetchExchangeRate(porOrgacode);
}
@GetMapping(UCOURI.ACCOUNT_ACTIVITY)
public ResponseEntity<List<CustomerAccountActivityResponse>> getCustomerAccountActivity(
@PathVariable String porOrgacode,
@PathVariable String cmpCustcode,
@PathVariable String fdate,
@PathVariable String tdate) {
return new ResponseEntity<>(customerAccountActivityService.getCustomerAccountActivity(porOrgacode, cmpCustcode, 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");
}
@PostMapping(UCOURI.ADD_UCO_CUSTOMER_ACCOUNT)
public ResponseEntity<HttpStatus> addUcoCustomerAccount(@RequestBody AddAccountRequest addAccountRequest) {
ucoAccountService.addUcoAccount(addAccountRequest);
return ResponseEntity.ok(HttpStatus.OK);
}
@PostMapping(UCOURI.UPDATE_CUSTOMER_PROFILE)
public ResponseEntity<HttpStatus> updateCustomerProfile(@RequestBody UpdateProfileRequest updateProfileRequest) {
customerProfileService.updateCustomerProfile(updateProfileRequest);
return ResponseEntity.ok(HttpStatus.OK);
}
@PostMapping(UCOURI.ADD_BENEFICIARY)
public ResponseEntity<HttpStatus> updateCustomerProfile(@RequestBody BeneficiaryRequest beneficiaryRequest) {
customerProfileService.addBeneficiary(beneficiaryRequest);
return ResponseEntity.ok(HttpStatus.OK);
}
@GetMapping(UCOURI.GET_BENEFICIARY)
public List<BeneficiaryResponse> updateCustomerProfile(@RequestParam String porOrgacode, @RequestParam String email) {
return customerProfileService.fetchBeneficiaryBasedOnEmail(porOrgacode,email);
}
@DeleteMapping(UCOURI.DELETE_BENEFICIARY)
public ResponseEntity<Void> deleteBeneficiary(
@RequestParam String mbmBkmsnumberRef,
@RequestParam String porOrgacode,
@RequestParam String email) {
customerProfileService.deleteBeneficiary(porOrgacode,email,mbmBkmsnumberRef);
return ResponseEntity.noContent().build();
}
} }

@ -0,0 +1,86 @@
package com.mfsys.uco.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Map;
@Data
@RequiredArgsConstructor
@AllArgsConstructor
@Builder
public class AccountDetail {
protected String porOrgacode;
protected String mbmBkmsnumber;
protected String mbmBkmstitle;
protected String dmpProddesc;
protected String plcLocadesc;
protected String pcrCurrcode;
protected String pcrCurrshort;
protected String mbmBkmsopendate;
protected String pcrCurrdesc;
protected String cmpCustcode;
protected boolean mbmBkmsclosed;
protected String pctCstycode;
protected BigDecimal mbmBkmsbalance;
protected Map<String, BigDecimal> charges = Map.of();
protected String dmpProdcode;
protected boolean cmpBlacklisted;
protected String plcLocacode;
protected boolean mbmNotificationService;
protected String dmpCredittype;
protected BigDecimal perEratrateact;
protected LocalDate kycRenewalDate;
protected String padAdrsmobphone;
protected boolean btaRolloverSpecialRate;
private String pasAcstcode;
private BigDecimal btaBookingamount;
private BigDecimal bdaDpacblockamt;
private boolean bdaDpacblocked;
private String pbdBankname;
private String pbbBranchname;
private String pbbBranchcountry;
private String pbbBranchcity;
private String pcaGlaccode;
private String accJointStatus;
private String accAttortype;
}

@ -1,5 +1,6 @@
package com.mfsys.uco.model; package com.mfsys.uco.model;
import com.mfsys.uco.compositeKeys.CustomerProfileId;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
@ -11,6 +12,7 @@ import java.time.LocalDate;
@Entity @Entity
@Table(name = "BN_CS_MP_CUSTOMERPROFILE") @Table(name = "BN_CS_MP_CUSTOMERPROFILE")
@Data @Data
@IdClass(CustomerProfileId.class)
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ -20,6 +22,7 @@ public class CustomerProfile {
@Column(name = "POR_ORGACODE") @Column(name = "POR_ORGACODE")
protected String porOrgacode; protected String porOrgacode;
@Id
@Column(name = "CMP_CUSTCODE") @Column(name = "CMP_CUSTCODE")
protected String cmpCustcode; protected String cmpCustcode;

@ -1,12 +1,13 @@
package com.mfsys.uco.repository; package com.mfsys.uco.repository;
import com.mfsys.uco.compositeKeys.CustomerProfileId;
import com.mfsys.uco.model.CustomerProfile; import com.mfsys.uco.model.CustomerProfile;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@Repository @Repository
public interface CustomerProfileRepository extends JpaRepository<CustomerProfile, String> { public interface CustomerProfileRepository extends JpaRepository<CustomerProfile, CustomerProfileId> {
@Query("SELECT c FROM CustomerProfile c WHERE c.porOrgacode =:porOrgacode and c.cmpEmail = :email") @Query("SELECT c FROM CustomerProfile c WHERE c.porOrgacode =:porOrgacode and c.cmpEmail = :email")
CustomerProfile findbyEmail(String porOrgacode, String email); CustomerProfile findbyEmail(String porOrgacode, String email);

@ -0,0 +1,14 @@
package com.mfsys.uco.service;
import com.mfsys.uco.response.CustomerAccountActivityResponse;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CustomerAccountActivityService {
public List<CustomerAccountActivityResponse> getCustomerAccountActivity(String porOrgacode, String cmpCustcode, String fdate, String tdate) {
return null;
}
}

@ -2,7 +2,14 @@ package com.mfsys.uco.service;
import com.mfsys.uco.model.CustomerProfile; import com.mfsys.uco.model.CustomerProfile;
import com.mfsys.uco.repository.CustomerProfileRepository; import com.mfsys.uco.repository.CustomerProfileRepository;
import com.mfsys.uco.request.BeneficiaryRequest;
import com.mfsys.uco.request.UpdateProfileRequest;
import com.mfsys.uco.response.BeneficiaryResponse;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CustomerProfileService { public class CustomerProfileService {
private final CustomerProfileRepository customerProfileRepository; private final CustomerProfileRepository customerProfileRepository;
@ -14,4 +21,17 @@ public class CustomerProfileService {
public CustomerProfile fetchCustcodeBasedOnEmail(String porOrgacode, String email) { public CustomerProfile fetchCustcodeBasedOnEmail(String porOrgacode, String email) {
return customerProfileRepository.findbyEmail(porOrgacode, email); return customerProfileRepository.findbyEmail(porOrgacode, email);
} }
public void updateCustomerProfile(UpdateProfileRequest updateProfileRequest) {
}
public void addBeneficiary(BeneficiaryRequest beneficiaryRequest) {
}
public List<BeneficiaryResponse> fetchBeneficiaryBasedOnEmail(String porOrgacode, String email) {
return null;
}
public void deleteBeneficiary(String porOrgacode, String email, String mbmBkmsnumberRef) {
}
} }

@ -0,0 +1,11 @@
package com.mfsys.uco.service;
import com.mfsys.uco.request.OTPRequest;
import org.springframework.stereotype.Service;
@Service
public class NotificationService {
public void sendOtp(OTPRequest otpRequest) {
}
}

@ -0,0 +1,20 @@
package com.mfsys.uco.service;
import com.mfsys.uco.request.ChangeTransactionPinRequest;
import com.mfsys.uco.request.CreateTransactionPinRequest;
import com.mfsys.uco.request.VerifyPinRequest;
import org.springframework.stereotype.Service;
@Service
public class TransactionPinService {
public void createTransactionPin(CreateTransactionPinRequest request) {
}
public void verifyOTPAndSavePin(VerifyPinRequest request) {
}
public void updateTransactionPin(ChangeTransactionPinRequest request) {
}
}

@ -1,8 +1,13 @@
package com.mfsys.uco.service; package com.mfsys.uco.service;
import com.mfsys.uco.model.AccountDetail;
import com.mfsys.uco.request.AddAccountRequest;
import com.mfsys.uco.request.SignupStep3Request; import com.mfsys.uco.request.SignupStep3Request;
import com.mfsys.uco.response.AccountInquiryResponse;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
@Service @Service
public class UcoAccountService { public class UcoAccountService {
public void onBoardCustomer(SignupStep3Request signupStep3Request) { public void onBoardCustomer(SignupStep3Request signupStep3Request) {
@ -14,4 +19,24 @@ public class UcoAccountService {
//call updateCustomerApplication using arguments of map email and porOrgacode //call updateCustomerApplication using arguments of map email and porOrgacode
} }
public Double fetchAccountBalance(String porOrgacode, String mbmBkmsNumber) {
return null;
}
public List<AccountDetail> fetchdepositAccountFromCiihive(String porOrgacode, String cmpCustcode) {
return null;
}
public List<AccountInquiryResponse> fetchAccountTitile(String porOrgacode, String acntTypeCode, String acntTypeValue) {
return null;
}
public Object fetchExchangeRate(String porOrgacode) {
return null;
}
public void addUcoAccount(AddAccountRequest addAccountRequest) {
}
} }

Loading…
Cancel
Save