Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 0 additions & 91 deletions logs/pms-application.log

This file was deleted.

11 changes: 6 additions & 5 deletions src/main/java/org/hsbc/controller/PmsController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.hsbc.controller;

import org.hsbc.entity.PmsEntity;
import org.hsbc.exception.InvalidPmsIdException;
import org.hsbc.service.PmsService;
import org.hsbc.service.PmsServiceimp;
import org.slf4j.Logger;
Expand All @@ -26,7 +27,7 @@ public List<PmsEntity> getAllAssets() {
return service.getAllAssets();
}
@GetMapping("/{id}")
public PmsEntity getAssetById(@PathVariable Long id) {
public PmsEntity getAssetById(@PathVariable Long id) throws InvalidPmsIdException {
return service.getAssetById(id);
}

Expand All @@ -39,25 +40,25 @@ public PmsEntity addAsset(@RequestBody PmsEntity asset) {
}

@DeleteMapping("/remove/{id}")
public String removeAsset(@PathVariable Long id) {
public String removeAsset(@PathVariable Long id) throws InvalidPmsIdException {
service.removeAsset(id);
return "Asset removed successfully";
}

@PutMapping("/update-quantity/{id}")
public PmsEntity updateQuantity(
@PathVariable Long id,
@RequestParam int quantity) {
@RequestParam int quantity) throws InvalidPmsIdException {
return service.updateQuantity(id, quantity);
}

@GetMapping("/pl/{id}")
public double getPL(@PathVariable Long id) {
public double getPL(@PathVariable Long id) throws InvalidPmsIdException {
return service.calculatePL(id);
}

@GetMapping("/pl-percentage/{id}")
public double getPLPercentage(@PathVariable Long id) {
public double getPLPercentage(@PathVariable Long id) throws InvalidPmsIdException {
return service.calculatePLPercentage(id);
}

Expand Down
26 changes: 0 additions & 26 deletions src/main/java/org/hsbc/exception/InvalidException.java

This file was deleted.

25 changes: 25 additions & 0 deletions src/main/java/org/hsbc/exception/InvalidPmsIdException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.hsbc.exception;

public class InvalidPmsIdException extends Exception {

public InvalidPmsIdException() {
}

public InvalidPmsIdException(String message) {
super(message);
}

public InvalidPmsIdException(Throwable cause) {
super(cause);
}

public InvalidPmsIdException(String message, Throwable cause) {
super(message, cause);
}

public InvalidPmsIdException(String message, Throwable cause, boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.hsbc.exception;

public class InvalidTransactionIdException extends Exception {

public InvalidTransactionIdException() {
}

public InvalidTransactionIdException(String message) {
super(message);
}

public InvalidTransactionIdException(Throwable cause) {
super(cause);
}

public InvalidTransactionIdException(String message, Throwable cause) {
super(message, cause);
}

public InvalidTransactionIdException(String message, Throwable cause, boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}

}
18 changes: 10 additions & 8 deletions src/main/java/org/hsbc/service/PmsService.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
package org.hsbc.service;

import org.hsbc.entity.PmsEntity;

import java.util.List;
import org.hsbc.entity.PmsEntity;
import org.hsbc.exception.InvalidPmsIdException;

public interface PmsService {

PmsEntity addAsset(PmsEntity asset);

void removeAsset(Long id);
void removeAsset(Long id) throws InvalidPmsIdException;

PmsEntity updateQuantity(Long id, int newQuantity);
PmsEntity updateQuantity(Long id, int newQuantity) throws InvalidPmsIdException;

double calculatePL(Long id);
double calculatePL(Long id) throws InvalidPmsIdException;

double calculatePLPercentage(Long id);
double calculatePLPercentage(Long id) throws InvalidPmsIdException;

double getTotalPortfolioValue();

List<PmsEntity> getAllAssets();
PmsEntity getAssetById(Long id);

PmsEntity getAssetById(Long id) throws InvalidPmsIdException;

}
}
Loading