Commit 44574c5e authored by Ramakanth Dhane's avatar Ramakanth Dhane

Merge branch 'hari_new' into 'master'

omd-dashboard backend files

See merge request !14
parents 5e5d25aa bbfdf82c
package com.nisum.omd.controllers;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.omd.models.OrdersSummary;
import com.nisum.omd.models.WeeklyOrders;
import com.nisum.omd.security.services.OrderService;
import com.nisum.omd.security.services.UserDetailsImpl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@CrossOrigin(origins = "*", maxAge = 3600)
......@@ -19,7 +28,11 @@ public class OrdersController {
static Long hoursOrders=new Long(0);
static Long minutesOrders=new Long(0);
static Long customers=new Long(100);
@GetMapping(value= "/getOrdersSummary", produces= "application/vnd.jcg.api.v1+json")
@Autowired
OrderService service;
@GetMapping(value= "/getOrdersSummary", produces= "application/vnd.jcg.api.v1+json")
public OrdersSummary getOrdersCount()
{
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
......@@ -37,5 +50,30 @@ public class OrdersController {
return ordersSummary;
}
@GetMapping(value= "/getTopOrders", produces= "application/json")
public List<OrdersSummary> getTopOrders() {
System.out.println("getTopOrders Called.");
return service.getTopOrders();
}
@GetMapping(value= "/getWeekOrders", produces= "application/json")
public List<WeeklyOrders> getWeekOrders() {
System.out.println("getWeekOrders Called.");
List<WeeklyOrders> list = new ArrayList<WeeklyOrders>();
WeeklyOrders weeklyOrders1= new WeeklyOrders(new Date(), new Long(12548));
WeeklyOrders weeklyOrders2= new WeeklyOrders(new Date(), new Long(25415));
list.add(weeklyOrders1);
list.add(weeklyOrders2);
return list;
}
}
package com.nisum.omd.models;
import java.math.BigDecimal;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
@Document(collection = "orders")
public class OrdersSummary {
private Long id;
private Long _id;
private Long today_orders;
private String today_date;
private String current_hour;
......@@ -11,6 +18,26 @@ public class OrdersSummary {
private Long current_minute_orders;
private Long customers_count;
private String orderNum;
private String customerId;
private BigDecimal orderPrice;
private String orderDate;
private String productName;
private int orderedQty;
public OrdersSummary(String orderNum, String customerId, BigDecimal orderPrice, String orderDate, String productName,
int orderedQty) {
super();
this.orderNum = orderNum;
this.customerId = customerId;
this.orderPrice = orderPrice;
this.orderDate = orderDate;
this.productName = productName;
this.orderedQty = orderedQty;
}
public Long getToday_orders() {
return today_orders;
}
......@@ -20,6 +47,9 @@ public class OrdersSummary {
public String getToday_date() {
return today_date;
}
public OrdersSummary() {
super();
}
public void setToday_date(String today_date) {
this.today_date = today_date;
}
......@@ -53,6 +83,49 @@ public class OrdersSummary {
public void setCustomers_count(Long customers_count) {
this.customers_count = customers_count;
}
public Long getId() {
return _id;
}
public void setId(Long _id) {
this._id = _id;
}
public String getOrderNum() {
return orderNum;
}
public void setOrderNum(String orderNum) {
this.orderNum = orderNum;
}
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
public BigDecimal getOrderPrice() {
return orderPrice;
}
public void setOrderPrice(BigDecimal orderPrice) {
this.orderPrice = orderPrice;
}
public String getOrderDate() {
return orderDate;
}
public void setOrderDate(String orderDate) {
this.orderDate = orderDate;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public int getOrderedQty() {
return orderedQty;
}
public void setOrderedQty(int orderedQty) {
this.orderedQty = orderedQty;
}
}
package com.nisum.omd.models;
import java.util.Date;
public class WeeklyOrders {
private Date oderDate;
private Long orderCount;
public WeeklyOrders(Date oderDate, Long orderCount) {
super();
this.oderDate = oderDate;
this.orderCount = orderCount;
}
@Override
public String toString() {
return "WeeklyOrders [oderDate=" + oderDate + ", orderCount=" + orderCount + "]";
}
public Date getOderDate() {
return oderDate;
}
public void setOderDate(Date oderDate) {
this.oderDate = oderDate;
}
public Long getOrderCount() {
return orderCount;
}
public void setOrderCount(Long orderCount) {
this.orderCount = orderCount;
}
}
......@@ -2,11 +2,12 @@ package com.nisum.omd.repository;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;
import com.nisum.omd.models.OrdersSummary;
public interface OrderRepository extends MongoRepository<OrdersSummary, Long> {
@Repository
public interface OrderRepository extends MongoRepository<OrdersSummary, String> {
}
package com.nisum.omd.security.services;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nisum.omd.models.OrdersSummary;
import com.nisum.omd.repository.OrderRepository;
@Service
public class OrderService {
@Autowired
OrderRepository orderRepository;
public List<OrdersSummary> getTopOrders()
{
return orderRepository.findAll();
}
}
package com.nisum.omd.security.services;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
......@@ -7,7 +9,9 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.nisum.omd.models.OrdersSummary;
import com.nisum.omd.models.User;
import com.nisum.omd.repository.OrderRepository;
import com.nisum.omd.repository.UserRepository;
......@@ -15,6 +19,7 @@ import com.nisum.omd.repository.UserRepository;
public class UserDetailsServiceImpl implements UserDetailsService {
@Autowired
UserRepository userRepository;
@Override
@Transactional
......@@ -25,4 +30,5 @@ public class UserDetailsServiceImpl implements UserDetailsService {
return UserDetailsImpl.build(user);
}
}
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