restructured packages for spring boot auto scanning
This commit is contained in:
parent
2a711aad9c
commit
6e44c099d3
46 changed files with 147 additions and 165 deletions
|
|
@ -25,6 +25,10 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package repositories;
|
||||
package edu.cpp.brcm;
|
||||
|
||||
import entities.Activity;
|
||||
import edu.cpp.brcm.entities.Activity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package repositories;
|
||||
package edu.cpp.brcm;
|
||||
|
||||
import entities.Appointment;
|
||||
import edu.cpp.brcm.entities.Appointment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
|
@ -8,6 +8,12 @@ public class BrcmApplication {
|
|||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BrcmApplication.class, args);
|
||||
// StudentRepository sr = new StudentRepositoryImpl();
|
||||
// CustomerRepository cr = new CustomerRepositoryImpl();
|
||||
// ProfessorRepository pr = new ProfessorRepositoryImpl();
|
||||
// CustomerManagementServiceImpl s = new CustomerManagementServiceImpl(sr, pr, cr);
|
||||
// s.saveStudent(new StudentDto(123, LocalDate.now(), "maj", "min", LocalDate.MAX, "fname", "lname", LocalDate.MIN, "12345567"));
|
||||
// System.out.println( "Hello World!" );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
11
brcm/src/main/java/edu/cpp/brcm/CustomerRepository.java
Normal file
11
brcm/src/main/java/edu/cpp/brcm/CustomerRepository.java
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package edu.cpp.brcm;
|
||||
|
||||
import edu.cpp.brcm.entities.Customer;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CustomerRepository extends JpaRepository<Customer, Integer> {
|
||||
// Customer getCustomerById(int id);
|
||||
// Customer saveCustomer(Customer customer);
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package repositories;
|
||||
package edu.cpp.brcm;
|
||||
|
||||
import entities.Discountscheme;
|
||||
import edu.cpp.brcm.entities.Discountscheme;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package repositories;
|
||||
package edu.cpp.brcm;
|
||||
|
||||
import entities.Lineitem;
|
||||
import edu.cpp.brcm.entities.Lineitem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package repositories;
|
||||
package edu.cpp.brcm;
|
||||
|
||||
import entities.Order;
|
||||
import edu.cpp.brcm.entities.Order;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package repositories;
|
||||
package edu.cpp.brcm;
|
||||
|
||||
import entities.Historicalprice;
|
||||
import edu.cpp.brcm.entities.Historicalprice;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package repositories;
|
||||
package edu.cpp.brcm;
|
||||
|
||||
import entities.Professor;
|
||||
import edu.cpp.brcm.entities.Professor;
|
||||
import java.util.List;
|
||||
public interface ProfessorRepository {
|
||||
Professor saveProfessor(Professor Professor);
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package repositories;
|
||||
package edu.cpp.brcm;
|
||||
|
||||
import entities.Student;
|
||||
import edu.cpp.brcm.entities.Student;
|
||||
import java.util.List;
|
||||
|
||||
public interface StudentRepository {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package common;
|
||||
package edu.cpp.brcm.common;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package edu.cpp.brcm.controllers;
|
||||
|
||||
import edu.cpp.brcm.entities.Customer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import edu.cpp.brcm.CustomerRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1")
|
||||
public class CustomerController {
|
||||
@Autowired
|
||||
private CustomerRepository repository;
|
||||
@GetMapping("/customers")
|
||||
public List<Customer> getAllCustomers() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
@GetMapping("/customers/{id}")
|
||||
public ResponseEntity<Customer> getCustomerById(@PathVariable(value = "id") int CustomerId)
|
||||
throws Exception {
|
||||
Customer Customer = repository.findById(CustomerId)
|
||||
.orElseThrow(() -> new Exception("Customer not found for this id :: " + CustomerId));
|
||||
return ResponseEntity.ok().body(Customer);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package dtos;
|
||||
package edu.cpp.brcm.dtos;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* A DTO for the {@link entities.Activity} entity
|
||||
* A DTO for the {@link edu.cpp.brcm.entities.Activity} entity
|
||||
*/
|
||||
public class ActivityDto implements Serializable {
|
||||
private final Integer id;
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package dtos;
|
||||
package edu.cpp.brcm.dtos;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* A DTO for the {@link entities.Address} entity
|
||||
* A DTO for the {@link edu.cpp.brcm.entities.Address} entity
|
||||
*/
|
||||
public class AddressDto implements Serializable {
|
||||
private final Integer id;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package dtos;
|
||||
package edu.cpp.brcm.dtos;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* A DTO for the {@link entities.Appointment} entity
|
||||
* A DTO for the {@link edu.cpp.brcm.entities.Appointment} entity
|
||||
*/
|
||||
public class AppointmentDto implements Serializable {
|
||||
private final Integer id;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package dtos;
|
||||
package edu.cpp.brcm.dtos;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* A DTO for the {@link entities.Customer} entity
|
||||
* A DTO for the {@link edu.cpp.brcm.entities.Customer} entity
|
||||
*/
|
||||
public class CustomerDto implements Serializable {
|
||||
private final Integer id;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package dtos;
|
||||
package edu.cpp.brcm.dtos;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* A DTO for the {@link entities.Discountscheme} entity
|
||||
* A DTO for the {@link edu.cpp.brcm.entities.Discountscheme} entity
|
||||
*/
|
||||
public class DiscountschemeDto implements Serializable {
|
||||
private final Integer id;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package dtos;
|
||||
package edu.cpp.brcm.dtos;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* A DTO for the {@link entities.Historicalprice} entity
|
||||
* A DTO for the {@link edu.cpp.brcm.entities.Historicalprice} entity
|
||||
*/
|
||||
public class HistoricalpriceDto implements Serializable {
|
||||
private final Integer id;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dtos;
|
||||
package edu.cpp.brcm.dtos;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dtos;
|
||||
package edu.cpp.brcm.dtos;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dtos;
|
||||
package edu.cpp.brcm.dtos;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dtos;
|
||||
package edu.cpp.brcm.dtos;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package entities;
|
||||
package edu.cpp.brcm.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package entities;
|
||||
package edu.cpp.brcm.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package entities;
|
||||
package edu.cpp.brcm.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.Instant;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package entities;
|
||||
package edu.cpp.brcm.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDate;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package entities;
|
||||
package edu.cpp.brcm.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDate;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package entities;
|
||||
package edu.cpp.brcm.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDate;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package entities;
|
||||
package edu.cpp.brcm.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package entities;
|
||||
package edu.cpp.brcm.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDate;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package entities;
|
||||
package edu.cpp.brcm.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package entities;
|
||||
package edu.cpp.brcm.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDate;
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
package impl;
|
||||
package edu.cpp.brcm.impl;
|
||||
|
||||
import dtos.ProfessorDto;
|
||||
import dtos.StudentDto;
|
||||
import entities.Customer;
|
||||
import entities.Student;
|
||||
import repositories.CustomerRepository;
|
||||
import repositories.ProfessorRepository;
|
||||
import repositories.StudentRepository;
|
||||
import services.CustomerManagementService;
|
||||
import edu.cpp.brcm.dtos.ProfessorDto;
|
||||
import edu.cpp.brcm.dtos.StudentDto;
|
||||
import edu.cpp.brcm.entities.Customer;
|
||||
import edu.cpp.brcm.entities.Student;
|
||||
import edu.cpp.brcm.CustomerRepository;
|
||||
import edu.cpp.brcm.ProfessorRepository;
|
||||
import edu.cpp.brcm.StudentRepository;
|
||||
import edu.cpp.brcm.services.CustomerManagementService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
//package edu.cpp.brcm.impl;
|
||||
//
|
||||
//import common.Hibernate;
|
||||
//import edu.cpp.brcm.entities.Customer;
|
||||
//import org.hibernate.Session;
|
||||
//import edu.cpp.brcm.repositories.CustomerRepository;
|
||||
//
|
||||
//import java.util.Optional;
|
||||
//
|
||||
//public class CustomerRepositoryImpl implements CustomerRepository {
|
||||
// private Session session;
|
||||
//
|
||||
// public CustomerRepositoryImpl(){
|
||||
// session = Hibernate.getSession();
|
||||
// }
|
||||
// @Override
|
||||
// public Customer getCustomerById(int id) {
|
||||
// Customer customer = (Customer)session.get(Customer.class, id);
|
||||
// return customer;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Customer saveCustomer(Customer customer) {
|
||||
// int id = (Integer)session.save(customer);
|
||||
// session.flush();
|
||||
// customer.setId(id);
|
||||
// return customer;
|
||||
// }
|
||||
//}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package impl;
|
||||
package edu.cpp.brcm.impl;
|
||||
|
||||
import entities.Professor;
|
||||
import repositories.ProfessorRepository;
|
||||
import edu.cpp.brcm.entities.Professor;
|
||||
import edu.cpp.brcm.ProfessorRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package impl;
|
||||
package edu.cpp.brcm.impl;
|
||||
|
||||
import common.Hibernate;
|
||||
import entities.Student;
|
||||
import edu.cpp.brcm.common.Hibernate;
|
||||
import edu.cpp.brcm.entities.Student;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.query.Query;
|
||||
import repositories.StudentRepository;
|
||||
import edu.cpp.brcm.StudentRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package services;
|
||||
package edu.cpp.brcm.services;
|
||||
|
||||
public interface ActivityRegistrationService {
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package services;
|
||||
package edu.cpp.brcm.services;
|
||||
|
||||
import dtos.ProfessorDto;
|
||||
import dtos.StudentDto;
|
||||
import edu.cpp.brcm.dtos.ProfessorDto;
|
||||
import edu.cpp.brcm.dtos.StudentDto;
|
||||
import java.util.List;
|
||||
|
||||
public interface CustomerManagementService {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package services;
|
||||
package edu.cpp.brcm.services;
|
||||
|
||||
public interface DiscountManagementService {
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package services;
|
||||
package edu.cpp.brcm.services;
|
||||
|
||||
public interface PriceHistoryService {
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package services;
|
||||
package edu.cpp.brcm.services;
|
||||
|
||||
public interface RevenueReportService {
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package services;
|
||||
package edu.cpp.brcm.services;
|
||||
|
||||
public interface VisitRegistrationService {
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
package impl;
|
||||
|
||||
import common.Hibernate;
|
||||
import entities.Customer;
|
||||
import org.hibernate.Session;
|
||||
import repositories.CustomerRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class CustomerRepositoryImpl implements CustomerRepository {
|
||||
private Session session;
|
||||
|
||||
public CustomerRepositoryImpl(){
|
||||
session = Hibernate.getSession();
|
||||
}
|
||||
@Override
|
||||
public Customer getCustomerById(int id) {
|
||||
Customer customer = (Customer)session.get(Customer.class, id);
|
||||
return customer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Customer saveCustomer(Customer customer) {
|
||||
int id = (Integer)session.save(customer);
|
||||
session.flush();
|
||||
customer.setId(id);
|
||||
return customer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends Customer> S save(S entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends Customer> Iterable<S> saveAll(Iterable<S> entities) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Customer> findById(Integer integer) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existsById(Integer integer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findAll() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Customer> findAllById(Iterable<Integer> integers) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long count() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(Integer integer) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Customer entity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAllById(Iterable<? extends Integer> integers) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Iterable<? extends Customer> entities) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
package repositories;
|
||||
|
||||
import entities.Customer;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface CustomerRepository extends CrudRepository<Customer, Integer> {
|
||||
Customer getCustomerById(int id);
|
||||
Customer saveCustomer(Customer customer);
|
||||
}
|
||||
|
|
@ -5,3 +5,5 @@ spring.datasource.driver-class-name=org.postgresql.Driver
|
|||
spring.jpa.database-platform = org.hibernate.dialect.PostgreSQLDialect
|
||||
spring.jpa.generate-ddl=true
|
||||
spring.jpa.hibernate.ddl-auto = update
|
||||
management.endpoints.jmx.exposure.include=health,info,env,beans
|
||||
management.endpoints.web.exposure.include=health,info,env,beans
|
||||
|
|
|
|||
Loading…
Reference in a new issue