Commit 0e8f73b8 authored by gourav.malhotra2's avatar gourav.malhotra2

apis added to stock quote

parent 36fac598
Pipeline #2286 failed with stages
in 1 minute and 20 seconds
package com.altimetrik.ee.demo.bean;
import java.util.Date;
public class StockBean {
private String stockQuote;
private String companyName;
private Date date;
private String currency;
private String price;
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getStockQuote() {
return stockQuote;
}
public void setStockQuote(String stockQuote) {
this.stockQuote = stockQuote;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
}
......@@ -4,18 +4,22 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.altimetrik.ee.demo.bean.StockBean;
import com.altimetrik.ee.demo.entity.Stock;
import com.altimetrik.ee.demo.service.StockDetailsService;
@RestController
@RequestMapping(value = "/stockQuote")
@RequestMapping(value = "/stockQuote/")
public class ServiceController {
protected static Logger logger = LoggerFactory.getLogger(ServiceController.class.getName());
......@@ -26,10 +30,21 @@ public class ServiceController {
@Autowired
private StockDetailsService detailsService;
@GetMapping(value = "/queryQuote")
@GetMapping(value = "queryQuote")
public java.util.List<Stock> search(@RequestParam String symbols) {
return detailsService.getStockQuotes(symbols);
}
@PostMapping(value = "addQuote")
public Stock save(@RequestBody StockBean stock) {
return detailsService.save(stock);
}
@DeleteMapping(value = "removeQuote")
public String save(@RequestParam String id) {
return detailsService.delete(id);
}
}
......@@ -4,12 +4,16 @@ import java.util.List;
import org.springframework.stereotype.Service;
import com.altimetrik.ee.demo.bean.StockBean;
import com.altimetrik.ee.demo.entity.Stock;
@Service
public interface StockDetailsService {
List<Stock> getStockQuotes(String quotesCSV);
Stock save(StockBean bean);
String delete(String id);
}
......@@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.altimetrik.ee.demo.bean.StockBean;
import com.altimetrik.ee.demo.entity.Stock;
import com.altimetrik.ee.demo.repository.StockDetailsRepository;
import com.altimetrik.ee.demo.service.StockDetailsService;
......@@ -30,6 +31,24 @@ public class StockDetailsServiceImpl implements StockDetailsService {
}
@Override
public Stock save(StockBean bean) {
Stock obj = new Stock();
obj.setCompanyName(bean.getCompanyName());
obj.setCurrency(bean.getCurrency());
obj.setDate(bean.getDate());
obj.setPrice(bean.getPrice());
detailsRepository.save(obj);
return obj;
}
@Override
public String delete(String id) {
detailsRepository.deleteById(Long.parseLong(id));
return "Record Deleted";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment