├── CovidVaccination
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── covid
│ │ │ │ └── vaccination
│ │ │ │ ├── Entity
│ │ │ │ ├── Gender.java
│ │ │ │ ├── Slot.java
│ │ │ │ ├── MyErrorDetails.java
│ │ │ │ ├── DoctorLogin.java
│ │ │ │ ├── UserLogin.java
│ │ │ │ ├── centerAddress.java
│ │ │ │ ├── VaccineStorage.java
│ │ │ │ ├── Doctor.java
│ │ │ │ ├── Appointment.java
│ │ │ │ ├── User.java
│ │ │ │ ├── DoctorDoseGeneration.java
│ │ │ │ ├── Dose1.java
│ │ │ │ └── Dose2.java
│ │ │ │ ├── Service
│ │ │ │ ├── Dose1Service.java
│ │ │ │ ├── DoseGenerationService.java
│ │ │ │ ├── UserLoginService.java
│ │ │ │ ├── VaccineStorageService.java
│ │ │ │ ├── DoctorLoginService.java
│ │ │ │ ├── UserService.java
│ │ │ │ ├── AppointmentService.java
│ │ │ │ ├── DoctorServices.java
│ │ │ │ └── centerAddressService.java
│ │ │ │ ├── Exception
│ │ │ │ ├── AddressException.java
│ │ │ │ ├── DoseException.java
│ │ │ │ ├── IdProofException.java
│ │ │ │ ├── UserException.java
│ │ │ │ ├── DoctorException.java
│ │ │ │ ├── InvalidMobileException.java
│ │ │ │ ├── InvalidPasswordException.java
│ │ │ │ ├── UserAlreadyExistWithMobileNumber.java
│ │ │ │ └── GlobalException.java
│ │ │ │ ├── Repository
│ │ │ │ ├── CenterAddressRepository.java
│ │ │ │ ├── DoseGenerationRepository.java
│ │ │ │ ├── Dose2Repository.java
│ │ │ │ ├── UserLoginRepository.java
│ │ │ │ ├── Dose1Repository.java
│ │ │ │ ├── VaccineStorageRepository.java
│ │ │ │ ├── AppointmentRepository.java
│ │ │ │ ├── DoctorLoginRepository.java
│ │ │ │ ├── DoctorRepository.java
│ │ │ │ └── UserRepository.java
│ │ │ │ ├── Testing
│ │ │ │ ├── doctor-generated-dose-controller
│ │ │ │ ├── AddressController
│ │ │ │ ├── DoctorController
│ │ │ │ ├── doctor-login-controller
│ │ │ │ ├── Tables
│ │ │ │ └── Tested
│ │ │ │ ├── Implementation
│ │ │ │ ├── Dose1ServiceImpl.java
│ │ │ │ ├── VaccineStorageServiceImpl.java
│ │ │ │ ├── CenterCreationServiceImpl.java
│ │ │ │ ├── UserLoginServiceImpl.java
│ │ │ │ ├── DoctorLoginServiceImpl.java
│ │ │ │ ├── UserServiceImpl.java
│ │ │ │ ├── DoseGenerationImpl.java
│ │ │ │ ├── AppointmentServiceImpl.java
│ │ │ │ └── DoctorServicesImp.java
│ │ │ │ ├── CovidVaccinationApplication.java
│ │ │ │ └── Controller
│ │ │ │ ├── WelcomePageController.java
│ │ │ │ ├── UserController.java
│ │ │ │ ├── DoctorController.java
│ │ │ │ └── AdminController.java
│ │ └── resources
│ │ │ ├── META-INF
│ │ │ └── additional-spring-configuration-metadata.json
│ │ │ └── application.properties
│ └── test
│ │ └── java
│ │ └── com
│ │ └── covid
│ │ └── vaccination
│ │ └── CovidVaccinationApplicationTests.java
├── .gitignore
├── pom.xml
├── mvnw.cmd
└── mvnw
├── .idea
├── vcs.xml
├── .gitignore
├── modules.xml
├── misc.xml
└── Covid19-Vaccination.iml
└── README.md
/CovidVaccination/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Abusalem9/Covid19-Vaccination/HEAD/CovidVaccination/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Entity/Gender.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Entity;
2 |
3 | public enum Gender {
4 | Male,MALE,Female,female,FEMALE,male,TransGender,transGender,transgender,TRANSGENDER
5 | }
6 |
--------------------------------------------------------------------------------
/CovidVaccination/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Entity/Slot.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Entity;
2 |
3 | public enum Slot {
4 | SLOT11000TO1030,
5 | SLOT21030TO1100,
6 | SLOT31100TO1130,
7 | SLOT41130TO1200,
8 | SLOT51200TO1230,
9 | SLOT61230TO0100
10 | }
11 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/resources/META-INF/additional-spring-configuration-metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "properties": [
3 | {
4 | "name": "springdoc.swagger-ui.tagsSorter",
5 | "type": "java.lang.String",
6 | "description": "Description for springdoc.swagger-ui.tagsSorter."
7 | }
8 | ] }
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Service/Dose1Service.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Service;
2 |
3 | import com.covid.vaccination.Entity.Dose1;
4 |
5 | import java.util.List;
6 |
7 | public interface Dose1Service {
8 | public List getAllUser();
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Service/DoseGenerationService.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Service;
2 |
3 | import com.covid.vaccination.Entity.DoctorDoseGeneration;
4 |
5 | public interface DoseGenerationService {
6 | public String generatedDose(DoctorDoseGeneration doctorDoseGeneration);
7 | }
8 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Exception/AddressException.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Exception;
2 |
3 | public class AddressException extends RuntimeException {
4 | AddressException(){
5 | }
6 | public AddressException(String message){
7 | super(message);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Exception/DoseException.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Exception;
2 |
3 | public class DoseException extends RuntimeException{
4 |
5 | public DoseException(){
6 |
7 | }
8 | public DoseException(String message){
9 | super(message);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Service/UserLoginService.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Service;
2 |
3 | import com.covid.vaccination.Entity.UserLogin;
4 |
5 | public interface UserLoginService {
6 | public UserLogin login(UserLogin userLogin);
7 | public String logOut(UserLogin userLogin);
8 | }
9 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Exception/IdProofException.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Exception;
2 |
3 | public class IdProofException extends RuntimeException {
4 | IdProofException(){
5 |
6 | }
7 | public IdProofException(String message){
8 | super(message);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Exception/UserException.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Exception;
2 |
3 | public class UserException extends RuntimeException {
4 |
5 | public UserException(String message) {
6 | super(message);
7 | }
8 |
9 | UserException() {
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Exception/DoctorException.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Exception;
2 |
3 | public class DoctorException extends RuntimeException {
4 |
5 | public DoctorException() {
6 | }
7 |
8 | public DoctorException(String message) {
9 | super(message);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Exception/InvalidMobileException.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Exception;
2 |
3 | public class InvalidMobileException extends RuntimeException {
4 | public InvalidMobileException(String message) {
5 |
6 | super(message);
7 | }
8 |
9 | InvalidMobileException() {
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Service/VaccineStorageService.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Service;
2 |
3 | import com.covid.vaccination.Entity.VaccineStorage;
4 |
5 | public interface VaccineStorageService {
6 |
7 | VaccineStorage save(VaccineStorage vaccineStorage);
8 | VaccineStorage updateVaccineStorage(Integer id);
9 | }
10 |
--------------------------------------------------------------------------------
/CovidVaccination/src/test/java/com/covid/vaccination/CovidVaccinationApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class CovidVaccinationApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Exception/InvalidPasswordException.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Exception;
2 |
3 | public class InvalidPasswordException extends RuntimeException {
4 |
5 | public InvalidPasswordException(String message) {
6 | super(message);
7 | }
8 |
9 | InvalidPasswordException() {
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/.idea/Covid19-Vaccination.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Exception/UserAlreadyExistWithMobileNumber.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Exception;
2 |
3 | import lombok.NoArgsConstructor;
4 |
5 | @NoArgsConstructor
6 | public class UserAlreadyExistWithMobileNumber extends RuntimeException {
7 |
8 | public UserAlreadyExistWithMobileNumber(String message) {
9 | super(message);
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Repository/CenterAddressRepository.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Repository;
2 |
3 | import com.covid.vaccination.Entity.centerAddress;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.stereotype.Repository;
6 |
7 | @Repository
8 | public interface CenterAddressRepository extends JpaRepository {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Service/DoctorLoginService.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Service;
2 |
3 | import com.covid.vaccination.Entity.DoctorLogin;
4 | import com.covid.vaccination.Entity.UserLogin;
5 | import org.springframework.stereotype.Service;
6 |
7 |
8 | public interface DoctorLoginService {
9 | public DoctorLogin login(DoctorLogin doctorLogin);
10 | public String logOut(DoctorLogin doctorLogin);
11 | }
12 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Repository/DoseGenerationRepository.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Repository;
2 |
3 | import com.covid.vaccination.Entity.DoctorDoseGeneration;
4 | import com.covid.vaccination.Entity.Dose1;
5 | import org.springframework.data.jpa.repository.JpaRepository;
6 | import org.springframework.stereotype.Repository;
7 |
8 | @Repository
9 | public interface DoseGenerationRepository extends JpaRepository {
10 | }
11 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Testing/doctor-generated-dose-controller:
--------------------------------------------------------------------------------
1 | Doctor Generated Dose Controller
2 | user:
3 | {
4 | "doctorId": 0,
5 | "dose1": {
6 | "doctor_id": 0,
7 | "user_id": 0
8 | },
9 | "dose2": {
10 | "doctor_id": 0,
11 | "user_id": 0
12 | },
13 | "user_id": 0
14 | }
15 | -----------------------------
16 | POST
17 | /Doctor/Dose/CreateDose
18 |
19 |
20 |
21 | Response body:
22 |
23 | You Are Fully Vaccinated
24 | --------------------------------
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Entity/MyErrorDetails.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Entity;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | import lombok.ToString;
7 |
8 | import java.time.LocalDateTime;
9 |
10 | @Data
11 | @ToString
12 | @AllArgsConstructor
13 | @NoArgsConstructor
14 | public class MyErrorDetails {
15 | private LocalDateTime timestamp;
16 | private String message;
17 | private String details;
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Entity/DoctorLogin.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Entity;
2 |
3 | import lombok.Data;
4 |
5 | import javax.persistence.Entity;
6 | import javax.persistence.GeneratedValue;
7 | import javax.persistence.GenerationType;
8 | import javax.persistence.Id;
9 | @Data
10 | @Entity
11 | public class DoctorLogin {
12 | @Id
13 | @GeneratedValue(strategy = GenerationType.AUTO)
14 | private Integer loginRef;
15 | private String mobile;
16 | private String password;
17 | }
18 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Entity/UserLogin.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Entity;
2 |
3 | import lombok.Data;
4 |
5 | import javax.persistence.Entity;
6 | import javax.persistence.GeneratedValue;
7 | import javax.persistence.GenerationType;
8 | import javax.persistence.Id;
9 |
10 | @Entity
11 | @Data
12 | public class UserLogin {
13 | @Id
14 | @GeneratedValue(strategy = GenerationType.AUTO)
15 | private Integer loginRef;
16 | private String mobile;
17 | private String password;
18 | }
19 |
--------------------------------------------------------------------------------
/CovidVaccination/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Entity/centerAddress.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Entity;
2 |
3 | import lombok.Data;
4 |
5 | import javax.persistence.Entity;
6 | import javax.persistence.GeneratedValue;
7 | import javax.persistence.GenerationType;
8 | import javax.persistence.Id;
9 |
10 | @Entity
11 | @Data
12 | public class centerAddress {
13 | @Id
14 | @GeneratedValue(strategy = GenerationType.AUTO)
15 | private Integer centerID;
16 | private String city;
17 | private String state;
18 | private String pinCode;
19 | }
20 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Repository/Dose2Repository.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Repository;
2 |
3 | import com.covid.vaccination.Entity.Dose2;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.data.jpa.repository.Query;
6 | import org.springframework.data.repository.query.Param;
7 |
8 | public interface Dose2Repository extends JpaRepository {
9 |
10 |
11 | @Query("select u from Dose2 u where u.user_id=:n")
12 | Dose2 getDose2ByUser_id(@Param("n") Integer user_id);
13 | }
14 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Service;
2 |
3 | import com.covid.vaccination.Entity.User;
4 | import com.covid.vaccination.Exception.UserException;
5 |
6 | import java.util.List;
7 |
8 | public interface UserService {
9 | User saveUser(User user);
10 |
11 | User getUserById(Integer id) throws UserException;
12 |
13 |
14 | List getAllUsers() throws UserException;
15 |
16 | User deleteUserById(Integer id) throws UserException;
17 |
18 | User updateUser(User user, String password) throws UserException;
19 | }
20 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #changing the server port
2 | server.port=8089
3 |
4 | #db specific properties
5 | spring.datasource.url=jdbc:mysql://localhost:3306/CovidVaccination
6 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
7 | spring.datasource.username=root
8 | spring.datasource.password=root
9 |
10 | #ORM s/w specific properties
11 | spring.jpa.hibernate.ddl-auto=update
12 | spring.jpa.show-sql=true
13 |
14 | spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER
15 |
16 | spring.jackson.date-format=com.fasterxml.jackson.databind.util.ISO8601DateFormat
17 | spring.jackson.time-zone=UTC
18 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Repository/UserLoginRepository.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Repository;
2 |
3 | import com.covid.vaccination.Entity.UserLogin;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.data.jpa.repository.Query;
6 | import org.springframework.data.repository.query.Param;
7 | import org.springframework.stereotype.Repository;
8 |
9 | @Repository
10 | public interface UserLoginRepository extends JpaRepository {
11 | @Query("select u from UserLogin u where u.mobile=:n")
12 | public UserLogin getUserLoginByMobile(@Param("n") String id);
13 | }
14 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Repository/Dose1Repository.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Repository;
2 |
3 | import com.covid.vaccination.Entity.Dose1;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.data.jpa.repository.Query;
6 | import org.springframework.data.repository.query.Param;
7 | import org.springframework.stereotype.Repository;
8 |
9 | import java.util.List;
10 |
11 | @Repository
12 | public interface Dose1Repository extends JpaRepository {
13 | @Query("select u from Dose1 u where u.user_id=:n")
14 | Dose1 getDose1ByUser_id(@Param("n") Integer user_id);
15 | }
16 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Entity/VaccineStorage.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnore;
4 | import lombok.Data;
5 | import lombok.ToString;
6 |
7 | import javax.persistence.Entity;
8 | import javax.persistence.GeneratedValue;
9 | import javax.persistence.GenerationType;
10 | import javax.persistence.Id;
11 |
12 | @ToString
13 | @Entity
14 | @Data
15 | public class VaccineStorage {
16 | @Id
17 | @JsonIgnore
18 | @GeneratedValue(strategy = GenerationType.AUTO)
19 | private Integer id;
20 | private Integer availableStock;
21 | private Integer centerID;
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Repository/VaccineStorageRepository.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Repository;
2 |
3 | import com.covid.vaccination.Entity.VaccineStorage;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.data.jpa.repository.Query;
6 | import org.springframework.data.repository.query.Param;
7 | import org.springframework.stereotype.Repository;
8 |
9 | @Repository
10 | public interface VaccineStorageRepository extends JpaRepository {
11 | @Query("select v from VaccineStorage v where v.centerID=:n")
12 | VaccineStorage findByCenterID(@Param("n")Integer id);
13 | }
14 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Entity/Doctor.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Entity;
2 |
3 | import lombok.Data;
4 | import javax.persistence.*;
5 | import javax.validation.constraints.Email;
6 |
7 | @Entity
8 | @Data
9 | public class Doctor {
10 | @Id
11 | @GeneratedValue(strategy = GenerationType.SEQUENCE)
12 | private Integer doctorId;
13 | private String firstName;
14 | private String lastName;
15 | @Column(unique = true,columnDefinition = "integer default 0")
16 | private String mobile;
17 | private String password;
18 | private String gender;
19 | @Email(message = "Please Enter Correct Email Id.")
20 | private String email;
21 | }
22 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Repository/AppointmentRepository.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Repository;
2 |
3 | import com.covid.vaccination.Entity.Appointment;
4 | import io.swagger.models.auth.In;
5 | import org.springframework.data.jpa.repository.JpaRepository;
6 | import org.springframework.data.jpa.repository.Query;
7 | import org.springframework.data.repository.query.Param;
8 | import org.springframework.stereotype.Repository;
9 |
10 | @Repository
11 | public interface AppointmentRepository extends JpaRepository {
12 | @Query("select u from Appointment u where u.user_id=:n")
13 | public Appointment findByUser_id(@Param("n") Integer id);
14 | }
15 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Implementation/Dose1ServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Implementation;
2 |
3 | import com.covid.vaccination.Entity.Dose1;
4 | import com.covid.vaccination.Repository.Dose1Repository;
5 | import com.covid.vaccination.Service.Dose1Service;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 |
9 | import java.util.List;
10 | @Service
11 | public class Dose1ServiceImpl implements Dose1Service {
12 | @Autowired
13 | public Dose1Repository dose1Repository;
14 | @Override
15 | public List getAllUser() {
16 | return dose1Repository.findAll();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Repository/DoctorLoginRepository.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Repository;
2 |
3 | import com.covid.vaccination.Entity.DoctorLogin;
4 | import com.covid.vaccination.Entity.UserLogin;
5 | import org.springframework.data.jpa.repository.JpaRepository;
6 | import org.springframework.data.jpa.repository.Query;
7 | import org.springframework.data.repository.query.Param;
8 | import org.springframework.stereotype.Repository;
9 |
10 | @Repository
11 | public interface DoctorLoginRepository extends JpaRepository {
12 | @Query("select u from DoctorLogin u where u.mobile=:n")
13 | public DoctorLogin getDoctorLoginByMobile(@Param("n") String id);
14 | }
15 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Service/AppointmentService.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Service;
2 |
3 | import com.covid.vaccination.Entity.Appointment;
4 | import org.springframework.data.jpa.repository.Query;
5 | import org.springframework.http.ResponseEntity;
6 |
7 | import java.util.List;
8 |
9 | public interface AppointmentService {
10 | public ResponseEntity setAppointment(Appointment appointment);
11 |
12 | public ResponseEntity getAppointmentById(Integer id);
13 |
14 | public ResponseEntity deleteAppointmentById(Integer id);
15 |
16 | public ResponseEntity> getAllAppointment();
17 |
18 | }
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Service/DoctorServices.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Service;
2 |
3 | import com.covid.vaccination.Entity.Doctor;
4 | import org.springframework.http.ResponseEntity;
5 |
6 | import java.util.List;
7 |
8 |
9 | public interface DoctorServices {
10 |
11 | ResponseEntity addDoctor(Doctor doctor);
12 |
13 | Doctor getDoctor(Integer did);
14 |
15 | ResponseEntity deleteDoctorById(Integer did);
16 |
17 | ResponseEntity> getAllDoctors();
18 |
19 | ResponseEntity updateDoctorDetails(Doctor doctor,String password) throws Exception;
20 |
21 |
22 | ResponseEntity viewProfile( String Sessionkey );
23 |
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Service/centerAddressService.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Service;
2 |
3 | import com.covid.vaccination.Entity.centerAddress;
4 | import com.covid.vaccination.Exception.AddressException;
5 |
6 | import javax.validation.constraints.Max;
7 | import java.util.List;
8 |
9 | public interface centerAddressService {
10 |
11 | centerAddress saveCenterAddress(centerAddress centeraddress);
12 |
13 | centerAddress getCenterAddressById(Integer id) throws AddressException;
14 | centerAddress deleteCenterById(Integer id)throws AddressException;
15 | centerAddress updateCenterAddress(centerAddress centerAddress)throws AddressException;
16 |
17 | List getAllCenterList();
18 | }
19 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Entity/Appointment.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Entity;
2 |
3 |
4 | import com.fasterxml.jackson.annotation.JsonIgnore;
5 | import lombok.Data;
6 | import javax.persistence.*;
7 | import java.time.LocalDateTime;
8 |
9 |
10 | @Data
11 | @Entity
12 | public class Appointment {
13 | @Id
14 | @JsonIgnore
15 | @GeneratedValue(strategy = GenerationType.AUTO)
16 | private Integer appointId;
17 | @Enumerated(EnumType.STRING)
18 | private Slot s;
19 | @JsonIgnore
20 | private LocalDateTime appointmentDate=LocalDateTime.now();
21 | @Column(unique = true,columnDefinition = "integer default 0")
22 | private Integer user_id;
23 | private String password;
24 | private Integer center_id;
25 | }
26 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Entity/User.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonFormat;
4 | import lombok.Data;
5 | import lombok.ToString;
6 |
7 | import javax.persistence.*;
8 | import java.util.Date;
9 |
10 |
11 | @ToString
12 | @Entity
13 | @Data
14 | public class User {
15 | @Id
16 | @GeneratedValue(strategy = GenerationType.SEQUENCE)
17 | private Integer user_id;
18 | private String firstName;
19 | private String lastName;
20 | private String mobile;
21 | @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="dd-MM-yyyy")
22 | private Date dob;
23 | private String password;
24 | private Gender gender;
25 | private String aadharNo;
26 | private String pinCode;
27 | private String city;
28 | }
29 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Repository/DoctorRepository.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Repository;
2 |
3 | import com.covid.vaccination.Entity.Doctor;
4 | import com.covid.vaccination.Entity.User;
5 | import org.springframework.data.jpa.repository.JpaRepository;
6 | import org.springframework.data.jpa.repository.Query;
7 | import org.springframework.data.repository.query.Param;
8 | import org.springframework.stereotype.Repository;
9 |
10 | import java.util.Optional;
11 | @Repository
12 | public interface DoctorRepository extends JpaRepository {
13 | Doctor findByDoctorId(Integer doctorId);
14 | Optional findByMobile(String mobileNo);
15 | @Query("select d from Doctor d where d.doctorId=:n")
16 | Doctor getDoctorByDoctorId(@Param("n")Integer id);
17 | }
18 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/CovidVaccinationApplication.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.boot.autoconfigure.domain.EntityScan;
6 | import org.springframework.context.MessageSource;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
9 | import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
10 | import springfox.documentation.swagger2.annotations.EnableSwagger2;
11 |
12 | @EnableSwagger2
13 | @SpringBootApplication
14 | public class CovidVaccinationApplication {
15 |
16 | public static void main(String[] args) {
17 | SpringApplication.run(CovidVaccinationApplication.class, args);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Testing/AddressController:
--------------------------------------------------------------------------------
1 | User Create -> User Login -> Appointment Book -> Doctor Create -> Dose 1 Generation -> Return To Appoint ->
2 | ->Dose 2 Generation -> Both Dose Done. -> if Appointment Book -> Return Already Dose Done;
3 | Admin Controller
4 | GetAll Dose Completed
5 | GetAll Dose1 Completed
6 | GetAll Center
7 | VaccineStorage get
8 |
9 |
10 |
11 | GET:
12 |
13 | getUserById : 3
14 | Response body
15 | {
16 | "timestamp": "2022-06-07T18:38:43.3089888",
17 | "message": "Address does not exist with this Id :3",
18 | "details": "uri=/Address/3"
19 | }
20 | ------------------------------------------------
21 | getUserById : 1
22 | Response body
23 | Download
24 | {
25 | "address_id": 1,
26 | "city": "Sangli",
27 | "state": "MH",
28 | "pinCode": "416404"
29 | }
30 | -----------------------------------------------
31 |
32 |
33 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Entity/DoctorDoseGeneration.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnore;
4 | import com.fasterxml.jackson.annotation.JsonManagedReference;
5 | import lombok.*;
6 |
7 | import javax.persistence.*;
8 |
9 | @Setter
10 | @Getter
11 | @AllArgsConstructor
12 | @NoArgsConstructor
13 | @Data
14 | @ToString
15 | @Entity
16 | public class DoctorDoseGeneration {
17 | @Id
18 | @JsonIgnore
19 | @GeneratedValue(strategy = GenerationType.AUTO)
20 | private Integer doseGenerationId;
21 | private Integer doctorId;
22 | private Integer user_id;
23 | private String d_password;
24 | @OneToOne(cascade = CascadeType.ALL)
25 | @JsonManagedReference
26 | private Dose1 dose1;
27 | @OneToOne(cascade = CascadeType.ALL)
28 | @JsonManagedReference
29 | private Dose2 dose2;
30 | }
31 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Entity/Dose1.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonBackReference;
4 | import com.fasterxml.jackson.annotation.JsonIgnore;
5 | import lombok.AllArgsConstructor;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 | import javax.persistence.*;
9 | import java.time.LocalDateTime;
10 |
11 | @Data
12 | @NoArgsConstructor
13 | @AllArgsConstructor
14 | @Entity
15 | public class Dose1 {
16 | @Id
17 | @GeneratedValue(strategy = GenerationType.AUTO)
18 | @JsonIgnore
19 | private Integer countId;
20 | @Column(unique = true,columnDefinition = "integer default 0")
21 | private Integer user_id;
22 | @JsonIgnore
23 | private LocalDateTime date= LocalDateTime.now();
24 | private Integer doctor_id;
25 | @OneToOne(mappedBy = "dose1")
26 | @JsonBackReference
27 | private DoctorDoseGeneration doctorDoseGeneration;
28 | }
29 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Entity/Dose2.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonBackReference;
4 | import com.fasterxml.jackson.annotation.JsonIgnore;
5 | import lombok.AllArgsConstructor;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | import javax.persistence.*;
10 | import java.time.LocalDateTime;
11 |
12 |
13 | @Data
14 | @NoArgsConstructor
15 | @AllArgsConstructor
16 | @Entity
17 | public class Dose2 {
18 | @Id
19 | @GeneratedValue(strategy = GenerationType.AUTO)
20 | @JsonIgnore
21 | private Integer countId;
22 | @Column(unique = true,columnDefinition = "integer default 0")
23 | private Integer user_id;
24 | @JsonIgnore
25 | private LocalDateTime date= LocalDateTime.now();
26 | private Integer doctor_id;
27 | @OneToOne(mappedBy = "dose2")
28 | @JsonBackReference
29 | private DoctorDoseGeneration doctorDoseGeneration;
30 | }
31 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Repository/UserRepository.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Repository;
2 |
3 | import com.covid.vaccination.Entity.User;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.data.jpa.repository.Query;
6 | import org.springframework.data.repository.query.Param;
7 | import org.springframework.stereotype.Repository;
8 |
9 | import java.util.List;
10 | import java.util.Optional;
11 |
12 | @Repository
13 | public interface UserRepository extends JpaRepository {
14 |
15 | @Query("select u from User u where u.aadharNo=:n")
16 | User getUsersByAadharNo(@Param("n")String n);
17 | @Query("select u from User u where u.mobile=:n")
18 | User getUsersByMobileNo(@Param("n")String n);
19 |
20 | @Query("select u from User u,Dose2 d where u.user_id=d.user_id ")
21 | List getAllBothDoseCompleted();
22 |
23 | Optional findByMobile(String mobileNo);
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Controller/WelcomePageController.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Controller;
2 |
3 | import io.swagger.annotations.Api;
4 | import io.swagger.annotations.ApiOperation;
5 | import net.bytebuddy.implementation.bind.annotation.IgnoreForBinding;
6 | import org.springframework.web.bind.annotation.GetMapping;
7 | import org.springframework.web.bind.annotation.RestController;
8 | import springfox.documentation.annotations.ApiIgnore;
9 |
10 | @RestController
11 | @ApiIgnore
12 | public class WelcomePageController {
13 | @GetMapping("/")
14 | @ApiOperation(value = "This method is used to show Home page.", hidden = true)
15 | public String welcome(){
16 | return "\n" +
17 | " Welcome To Our Covid-19 Vaccination Rest Api.\n" +
18 | "
\n" +
19 | "";
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Testing/DoctorController:
--------------------------------------------------------------------------------
1 |
2 | Doctor Controller:
3 |
4 | user:
5 | [
6 | {
7 | "email": "string",
8 | "firstName": "string",
9 | "gender": "string",
10 | "lastName": "string",
11 | "mobile": "string",
12 | "password": "string"
13 | }
14 | ]
15 | -------------------------------
16 |
17 | POST
18 | /addDoctor
19 |
20 | Response body:
21 | Doctor Has Been Added Successfully.
22 |
23 |
24 | ------------------------------
25 | GET
26 | /doctors
27 | getAllDoctors
28 |
29 | Response body:
30 | [
31 | {
32 | "email": "string",
33 | "firstName": "string",
34 | "gender": "string",
35 | "lastName": "string",
36 | "mobile": "string",
37 | "password": "string"
38 | }
39 | ]
40 |
41 | getAllDoctors
42 |
43 | Response body
44 | [
45 | {
46 | "firstName": "string",
47 | "lastName": "string",
48 | "mobile": "string",
49 | "password": "string",
50 | "gender": "string",
51 | "email": "string"
52 | },
53 | {
54 | "firstName": "mohit",
55 | "lastName": "agrawal",
56 | "mobile": "9619753340",
57 | "password": "123456",
58 | "gender": "M",
59 | "email": "mohit@doctor.com"
60 | }
61 | ]
62 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Implementation/VaccineStorageServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Implementation;
2 |
3 | import com.covid.vaccination.Entity.VaccineStorage;
4 | import com.covid.vaccination.Entity.centerAddress;
5 | import com.covid.vaccination.Exception.UserAlreadyExistWithMobileNumber;
6 | import com.covid.vaccination.Exception.UserException;
7 | import com.covid.vaccination.Repository.CenterAddressRepository;
8 | import com.covid.vaccination.Repository.VaccineStorageRepository;
9 | import com.covid.vaccination.Service.VaccineStorageService;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.stereotype.Service;
12 |
13 | import java.util.Optional;
14 |
15 | @Service
16 | public class VaccineStorageServiceImpl implements VaccineStorageService {
17 |
18 | @Autowired
19 | private VaccineStorageRepository vaccineStorageRepository;
20 |
21 | @Autowired
22 | public CenterAddressRepository centerAddressRepository;
23 | @Autowired
24 | public CenterCreationServiceImpl centerCreationService;
25 | @Override
26 | public VaccineStorage save(VaccineStorage vaccineStorage) {
27 | Optional c=centerAddressRepository.findById(vaccineStorage.getCenterID());
28 | if (c.isPresent()) {
29 | return vaccineStorageRepository.save(vaccineStorage);
30 | } else
31 | throw new UserException(" Kindly Enter correct Center ID");
32 | }
33 |
34 | @Override
35 | public VaccineStorage updateVaccineStorage(Integer id) {
36 | VaccineStorage v=vaccineStorageRepository.findByCenterID(id);
37 | if(v!=null) {
38 | v.setAvailableStock(v.getAvailableStock()-1);
39 | return vaccineStorageRepository.save(v);
40 | }else
41 | throw new UserAlreadyExistWithMobileNumber("Please Check Center Id");
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Implementation/CenterCreationServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Implementation;
2 |
3 | import com.covid.vaccination.Entity.centerAddress;
4 | import com.covid.vaccination.Exception.AddressException;
5 | import com.covid.vaccination.Repository.CenterAddressRepository;
6 | import com.covid.vaccination.Service.centerAddressService;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.stereotype.Service;
9 |
10 | import java.util.List;
11 |
12 | @Service
13 | public class CenterCreationServiceImpl implements centerAddressService {
14 |
15 |
16 | @Autowired
17 | public CenterAddressRepository centerAddressRepository;
18 |
19 |
20 |
21 | @Override
22 | public centerAddress saveCenterAddress(centerAddress centeraddress) {
23 |
24 | return centerAddressRepository.save(centeraddress);
25 |
26 | }
27 |
28 | @Override
29 | public centerAddress getCenterAddressById(Integer id) throws AddressException {
30 | return centerAddressRepository.findById(id).orElseThrow(() -> new AddressException("Address does not exist with this Id :" + id));
31 | }
32 |
33 | @Override
34 | public centerAddress deleteCenterById(Integer id) throws AddressException {
35 | centerAddress existingcenterAddress= centerAddressRepository.findById(id).orElseThrow( () -> new AddressException("centerAddress does not exist with this Id :"+id) );
36 | centerAddressRepository.delete(existingcenterAddress);
37 | return existingcenterAddress;
38 | }
39 |
40 | @Override
41 | public centerAddress updateCenterAddress(centerAddress centerAddress) throws AddressException {
42 | centerAddress existingcenterAddress= centerAddressRepository.findById(centerAddress.getCenterID()).orElseThrow( () -> new AddressException("centerAddress does not exist with this Id :"+centerAddress.getCenterID()) );
43 | return centerAddressRepository.save(existingcenterAddress);
44 | }
45 |
46 | @Override
47 | public List getAllCenterList() {
48 | return centerAddressRepository.findAll();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Implementation/UserLoginServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Implementation;
2 |
3 | import com.covid.vaccination.Entity.User;
4 | import com.covid.vaccination.Entity.UserLogin;
5 | import com.covid.vaccination.Exception.UserAlreadyExistWithMobileNumber;
6 | import com.covid.vaccination.Repository.UserLoginRepository;
7 | import com.covid.vaccination.Repository.UserRepository;
8 | import com.covid.vaccination.Service.UserLoginService;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.stereotype.Repository;
11 |
12 | import java.util.Optional;
13 | @Repository
14 | public class UserLoginServiceImpl implements UserLoginService {
15 | @Autowired
16 | public UserLoginRepository userLoginRepository;
17 | @Autowired
18 | public UserRepository userRepository;
19 |
20 | @Override
21 | public UserLogin login(UserLogin userLogin) {
22 | UserLogin userLoginByMobile=userLoginRepository.getUserLoginByMobile(userLogin.getMobile());
23 | if(userLoginByMobile==null){
24 | Optional u=userRepository.findByMobile(userLogin.getMobile());
25 | if(u.isPresent()){
26 | User user= u.get();
27 | if(user.getPassword().equals(userLogin.getPassword())){
28 | return userLoginRepository.save(userLogin);
29 | }
30 | else
31 | throw new UserAlreadyExistWithMobileNumber("Please Check Your Password.");
32 | }
33 | else
34 | throw new UserAlreadyExistWithMobileNumber("User Not Found");
35 | }
36 | else
37 | throw new UserAlreadyExistWithMobileNumber("User Already Logged In.");
38 |
39 | }
40 |
41 | @Override
42 | public String logOut(UserLogin userLogin) {
43 | UserLogin u=userLoginRepository.getUserLoginByMobile(userLogin.getMobile());
44 | if (u!=null){
45 | if(u.getPassword().equals(userLogin.getPassword())){
46 | userLoginRepository.delete(u);
47 | return "User Has Been LogOut From The System.";
48 | }
49 | else
50 | throw new UserAlreadyExistWithMobileNumber("please fill your correct password");
51 | }
52 | else
53 | throw new UserAlreadyExistWithMobileNumber("Please Login First.");
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Controller/UserController.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Controller;
2 |
3 | import com.covid.vaccination.Entity.Appointment;
4 | import com.covid.vaccination.Entity.User;
5 | import com.covid.vaccination.Entity.UserLogin;
6 | import com.covid.vaccination.Entity.centerAddress;
7 | import com.covid.vaccination.Service.AppointmentService;
8 | import com.covid.vaccination.Service.UserLoginService;
9 | import com.covid.vaccination.Service.UserService;
10 | import com.covid.vaccination.Service.centerAddressService;
11 | import org.springframework.beans.factory.annotation.Autowired;
12 | import org.springframework.http.HttpStatus;
13 | import org.springframework.http.ResponseEntity;
14 | import org.springframework.web.bind.annotation.*;
15 |
16 | import java.util.List;
17 |
18 | @RestController
19 | @RequestMapping("/user")
20 | public class UserController {
21 | @Autowired
22 | public UserService usi;
23 |
24 | @Autowired
25 | public AppointmentService appointmentService;
26 | // Create User
27 | @PostMapping("/create")
28 | public ResponseEntity createUser(@RequestBody User user){
29 | return new ResponseEntity<>(usi.saveUser(user),HttpStatus.ACCEPTED);
30 | }
31 |
32 | @PutMapping("/update")
33 | public User updateUserByUsingId(@RequestBody User user,@RequestParam String password){
34 | return usi.updateUser(user,password);
35 | }
36 |
37 | @PostMapping("/book")
38 | public ResponseEntity setAppointmentOfDose(@RequestBody Appointment appointment){
39 |
40 | return appointmentService.setAppointment(appointment);
41 | }
42 |
43 | @Autowired
44 | public UserLoginService userLoginService;
45 | @PostMapping("Login")
46 | public UserLogin userLogin(@RequestBody UserLogin userLogin) {
47 | return userLoginService.login(userLogin);
48 | }
49 |
50 | @PostMapping("Logout")
51 | public String UserLogOut(@RequestBody UserLogin userLogin) {
52 | return userLoginService.logOut(userLogin);
53 | }
54 | @Autowired
55 | public centerAddressService centerCreationService;
56 | @GetMapping("GetAllCenter")
57 | public ResponseEntity> getAllAddress(){
58 | List list = centerCreationService.getAllCenterList();
59 | if(list!=null){
60 | return new ResponseEntity<>(list, HttpStatus.OK);
61 | }
62 | else
63 | return new ResponseEntity<>(null,HttpStatus.BAD_REQUEST);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Implementation/DoctorLoginServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Implementation;
2 |
3 | import com.covid.vaccination.Entity.Doctor;
4 | import com.covid.vaccination.Entity.DoctorLogin;
5 | import com.covid.vaccination.Entity.User;
6 | import com.covid.vaccination.Entity.UserLogin;
7 | import com.covid.vaccination.Exception.UserAlreadyExistWithMobileNumber;
8 | import com.covid.vaccination.Repository.DoctorLoginRepository;
9 | import com.covid.vaccination.Repository.DoctorRepository;
10 | import com.covid.vaccination.Service.DoctorLoginService;
11 | import org.springframework.beans.factory.annotation.Autowired;
12 | import org.springframework.stereotype.Service;
13 |
14 | import java.util.Optional;
15 | @Service
16 | public class DoctorLoginServiceImpl implements DoctorLoginService {
17 | @Autowired
18 | public DoctorLoginRepository doctorLoginRepository;
19 | @Autowired
20 | public DoctorRepository doctorRepository;
21 | @Override
22 | public DoctorLogin login(DoctorLogin doctorLogin) {
23 | DoctorLogin doctorLoginByMobile=doctorLoginRepository.getDoctorLoginByMobile(doctorLogin.getMobile());
24 | if(doctorLoginByMobile==null){
25 | Optional u=doctorRepository.findByMobile(doctorLogin.getMobile());
26 | if(u.isPresent()){
27 | Doctor user= u.get();
28 | if(user.getPassword().equals(doctorLogin.getPassword())){
29 | return doctorLoginRepository.save(doctorLogin);
30 | }
31 | else
32 | throw new UserAlreadyExistWithMobileNumber("Please Check Your Password.");
33 | }
34 | else
35 | throw new UserAlreadyExistWithMobileNumber("Doctor Not Found");
36 | }
37 | else
38 | throw new UserAlreadyExistWithMobileNumber("Doctor Already Logged In.");
39 | }
40 |
41 | @Override
42 | public String logOut(DoctorLogin doctorLogin) {
43 | DoctorLogin u=doctorLoginRepository.getDoctorLoginByMobile(doctorLogin.getMobile());
44 | if (u!=null){
45 | if(u.getPassword().equals(doctorLogin.getPassword())){
46 | doctorLoginRepository.delete(u);
47 | return "Doctor Has Been Successfully Logged Out.";
48 | }
49 | else
50 | throw new UserAlreadyExistWithMobileNumber("please fill your correct password");
51 | }
52 | else
53 | throw new UserAlreadyExistWithMobileNumber("Please Login First.");
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Controller/DoctorController.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Controller;
2 |
3 | import com.covid.vaccination.Entity.Appointment;
4 | import com.covid.vaccination.Entity.Doctor;
5 | import com.covid.vaccination.Entity.DoctorDoseGeneration;
6 | import com.covid.vaccination.Entity.DoctorLogin;
7 | import com.covid.vaccination.Service.AppointmentService;
8 | import com.covid.vaccination.Service.DoctorLoginService;
9 | import com.covid.vaccination.Service.DoctorServices;
10 | import com.covid.vaccination.Service.DoseGenerationService;
11 | import org.springframework.beans.factory.annotation.Autowired;
12 | import org.springframework.http.HttpStatus;
13 | import org.springframework.http.ResponseEntity;
14 | import org.springframework.web.bind.annotation.*;
15 | import java.util.List;
16 |
17 |
18 | @RestController
19 | @RequestMapping("/doctor")
20 | public class DoctorController {
21 | @Autowired
22 | private DoctorServices dsi;
23 | @PostMapping("/addDoctor")
24 | public ResponseEntity createDoctor(@RequestBody Doctor doctor){
25 | return dsi.addDoctor(doctor);
26 | }
27 |
28 | @Autowired
29 | public DoctorLoginService doctorLoginService;
30 | @PostMapping("Login")
31 | public DoctorLogin userLogin(@RequestBody DoctorLogin userLogin) {
32 | return doctorLoginService.login(userLogin);
33 | }
34 |
35 | @PostMapping("Logout")
36 | public String DoctorLogOut(@RequestBody DoctorLogin userLogin) {
37 | return doctorLoginService.logOut(userLogin);
38 | }
39 | @GetMapping("/profile")
40 | public ResponseEntity viewProfile(@RequestParam String key) {
41 | return dsi.viewProfile(key);
42 | }
43 |
44 | @PutMapping("/updateDoctor")
45 | public ResponseEntity updateDoctor(@RequestBody Doctor doctor, @RequestParam String password) throws Exception {
46 | return dsi.updateDoctorDetails(doctor,password);
47 | }
48 | @Autowired
49 | public DoseGenerationService doseGenerationService;
50 | @Autowired
51 | public AppointmentService appointmentService;
52 |
53 | @PostMapping("Dose/CreateDose")
54 | public ResponseEntity createDose(@RequestBody DoctorDoseGeneration doctorDoseGeneration){
55 | return new ResponseEntity<>(doseGenerationService.generatedDose(doctorDoseGeneration), HttpStatus.CREATED);
56 | }
57 | @GetMapping("/getAllAppointment")
58 | public ResponseEntity> getAllAppointments(){
59 | return appointmentService.getAllAppointment();
60 | }
61 |
62 | }
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # REST API for an Covid-19 Vaccination
2 |
3 | * We have developed this REST API for an Covid-19 Vaccination. This API performs all the fundamental CRUD operations of any Online Book Covid Vaccine Slot Near you booking platform with user validation at every step.
4 | * This project is developed by team of 5 Back-end Developers during project week in [Masai School](www.masaischool.com).
5 |
6 | ## Tech Stack
7 |
8 | * Java
9 | * Spring Framework
10 | * Spring Boot
11 | * Spring Data JPA
12 | * Hibernate
13 | * MySQL
14 |
15 | ## Modules
16 |
17 | * Login, Logout Module
18 | * Doctor Module
19 | * User Module
20 | * Admin Module
21 | * Dose Generation Module
22 |
23 | ## Features
24 |
25 | * User, Doctor and Admin authentication & validation with session uuid having.
26 | * Admin Features:
27 | * Administrator Role of the entire application
28 | * Only registered admins with valid session token can add/update/delete driver or user from main database
29 | * Admin can access the details of different Users, Doctors, Center and Dose.
30 | * User Features:
31 | * Registering themselves with application, and logging in to it.
32 | * Viewing list of available Center and booking a Appointment.
33 | * Only logged in user can access profile updation and other features.
34 |
35 | ## Contributors
36 |
37 | * [Akhil Gonde](https://github.com/akhilgonde)
38 | * [Aman Roy](https://github.com/ROY-AMAN)
39 | * [Mohit Agarwal](https://github.com/mohitagrawal22)
40 | * [Ravi Patel](https://github.com/Ravipatel02)
41 | * [Abusalem Mangalwedhe](https://github.com/Abusalem9)
42 | * [Abhishek Chaudhary](https://github.com/Abhicoder01)
43 |
44 |
45 | ## Installation & Run
46 |
47 | * Before running the API server, you should update the database config inside the [application.properties](CovidVaccination\src\main\resources\application.properties) file.
48 | * Update the port number, username and password as per your local database config.
49 |
50 | ```
51 | server.port=8089
52 | spring.datasource.url=jdbc:mysql://localhost:3306/CovidVaccination;
53 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
54 | spring.datasource.username=root
55 | spring.datasource.password=root
56 |
57 | ```
58 |
59 | ## API Root Endpoint
60 |
61 | `http://covid19vaccinationapi-env-1.eba-becpxd2x.ap-south-1.elasticbeanstalk.com/`
62 |
63 | `http://covid19vaccinationapi-env-1.eba-becpxd2x.ap-south-1.elasticbeanstalk.com/v2/api-docs`
64 |
65 | `http://covid19vaccinationapi-env-1.eba-becpxd2x.ap-south-1.elasticbeanstalk.com/swagger-ui.html`
66 |
67 |
68 | ### Sample API Response for user Login
69 |
70 | `POST: http://covid19vaccinationapi-env-1.eba-becpxd2x.ap-south-1.elasticbeanstalk.com/swagger-ui.html#/user-controller/userLoginUsingPOST_1`
71 |
72 | * Request Body
73 |
74 | ```
75 | {
76 | "Mobile": "85022457580",
77 | "password": "pass@12"
78 | }
79 | ```
80 |
81 | * Response
82 |
83 | ```
84 | Login Successful.
85 | ```
86 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Implementation/UserServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Implementation;
2 |
3 | import com.covid.vaccination.Entity.User;
4 | import com.covid.vaccination.Entity.UserLogin;
5 | import com.covid.vaccination.Exception.UserAlreadyExistWithMobileNumber;
6 | import com.covid.vaccination.Exception.UserException;
7 | import com.covid.vaccination.Repository.UserLoginRepository;
8 | import com.covid.vaccination.Repository.UserRepository;
9 | import com.covid.vaccination.Service.UserService;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.data.jpa.repository.Query;
12 | import org.springframework.stereotype.Service;
13 |
14 | import java.util.List;
15 | import java.util.Optional;
16 |
17 | @Service
18 | public class UserServiceImpl implements UserService {
19 | @Autowired
20 | public UserRepository userRepository;
21 |
22 | @Autowired
23 | public UserLoginRepository userLoginRepository;
24 |
25 | @Override
26 | public User saveUser(User user) {
27 | Optional newUser=userRepository.findByMobile(user.getMobile());
28 | User aadhar=userRepository.getUsersByAadharNo(user.getAadharNo());
29 | if(newUser.isPresent()||aadhar!=null){
30 | throw new UserAlreadyExistWithMobileNumber("User Has Been Already Registered With This Mobile Number Or Aadhar Number.");
31 | }
32 | return userRepository.save(user);
33 | }
34 |
35 | @Override
36 | @Query("select u from User as u")
37 | public User getUserById(Integer id) throws UserException {
38 | return userRepository.findById(id).orElseThrow(() -> new UserException("User does not exist with Roll :" + id));
39 | }
40 |
41 | @Override
42 |
43 | public List getAllUsers() throws UserException {
44 | return userRepository.findAll();
45 | }
46 |
47 | @Override
48 | public User deleteUserById(Integer id) throws UserException {
49 |
50 | User existingUser= userRepository.findById(id).orElseThrow( () -> new UserException("User does not exist with this Id :"+id) );
51 | userRepository.delete(existingUser);
52 | return existingUser;
53 | }
54 |
55 | @Override
56 | public User updateUser(User user, String password) throws UserException {
57 | Optional user2 = userRepository.findById(user.getUser_id());
58 | if(user2.isPresent()){
59 | UserLogin u=userLoginRepository.getUserLoginByMobile(user2.get().getMobile());
60 | if(u!=null){
61 | if(u.getPassword().equals(password)){
62 | User updated= userRepository.save(user);
63 | userLoginRepository.delete(u);
64 | return updated;
65 | }
66 | else
67 | throw new UserAlreadyExistWithMobileNumber("Please fill Correct password");
68 | }
69 | else
70 | throw new UserAlreadyExistWithMobileNumber("Please Login First.");
71 | }
72 | else
73 | throw new UserAlreadyExistWithMobileNumber("Please Check User Id");
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/CovidVaccination/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.7.0
9 |
10 |
11 | com.covid.vaccination
12 | CovidVaccination
13 | 0.0.1-SNAPSHOT
14 | CovidVaccination
15 | CovidVaccination
16 |
17 | 1.8
18 |
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter-web
23 |
24 |
25 | io.springfox
26 | springfox-swagger2
27 | 2.9.2
28 |
29 |
30 | io.springfox
31 | springfox-swagger-ui
32 | 2.9.2
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-devtools
37 | runtime
38 | true
39 |
40 |
41 | mysql
42 | mysql-connector-java
43 | runtime
44 |
45 |
46 |
47 |
48 | org.springframework.boot
49 | spring-boot-starter-validation
50 |
51 |
52 |
53 |
54 |
55 | org.projectlombok
56 | lombok
57 | true
58 |
59 |
60 | org.springframework.boot
61 | spring-boot-starter-test
62 | test
63 |
64 |
65 | org.springframework.boot
66 | spring-boot-starter-data-jpa
67 |
68 |
69 | javax.validation
70 | validation-api
71 | 2.0.1.Final
72 |
73 |
74 |
75 |
76 |
77 |
78 | org.springframework.boot
79 | spring-boot-maven-plugin
80 |
81 |
82 |
83 | org.projectlombok
84 | lombok
85 |
86 |
87 |
88 |
89 |
90 | spring-boot-aws-exe
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Testing/doctor-login-controller:
--------------------------------------------------------------------------------
1 | POST (Entered wrong password)
2 | /doctorlogin
3 | logInDoctor
4 |
5 | {
6 | "centerId": {
7 | "centerID": 0,
8 | "pinCode": "string",
9 | "slot": "SLOT11000TO1030",
10 | "user_Id": 0
11 | },
12 | "mobile": "9619753340",
13 | "password": "12345"
14 | }
15 |
16 | Response body
17 | {
18 | "timestamp": "2022-06-08T11:20:17.4019169",
19 | "message": "Please Enter Valid Password",
20 | "details": "uri=/doctorlogin"
21 | }
22 |
23 | ------------------------------------------
24 | POST (Entered Correct password)
25 | /doctorlogin
26 | logInDoctor
27 |
28 | {
29 | "centerId": {
30 | "centerID": 0,
31 | "pinCode": "string",
32 | "slot": "SLOT11000TO1030",
33 | "user_Id": 0
34 | },
35 | "mobile": "9619753340",
36 | "password": "123456"
37 | }
38 |
39 |
40 | Response body:
41 | CurrentDoctorSession(id=14, uuid=pBROeQ, localDateTime=2022-06-08T11:21:38.452664900)
42 | ----------------------------------------------------
43 | POST (Entered wrong Mobile)
44 | /doctorlogin
45 | logInDoctor
46 |
47 | {
48 | "centerId": {
49 | "centerID": 0,
50 | "pinCode": "string",
51 | "slot": "SLOT11000TO1030",
52 | "user_Id": 0
53 | },
54 | "mobile": "961740",
55 | "password": "123456"
56 | }
57 |
58 |
59 |
60 | Response body
61 |
62 | {
63 | "timestamp": "2022-06-08T11:22:57.6121368",
64 | "message": "Please Enter Valid Mobile No",
65 | "details": "uri=/doctorlogin"
66 | }
67 | ----------------------------------------------------------
68 | POST (Entered Correct Mobile)
69 | /doctorlogin
70 | logInDoctor
71 |
72 |
73 | {
74 | "centerId": {
75 | "centerID": 0,
76 | "pinCode": "string",
77 | "slot": "SLOT11000TO1030",
78 | "user_Id": 0
79 | },
80 | "mobile": "9619753340",
81 | "password": "123456"
82 | }
83 |
84 |
85 | Response body
86 | Download
87 | CurrentDoctorSession(id=14, uuid=owGesz, localDateTime=2022-06-08T11:23:39.474162700)
88 |
89 | -----------------------------------------------
90 | POST (Entered Both Wrong Mobile & pass)
91 | /doctorlogin
92 | logInDoctor
93 |
94 |
95 | {
96 | "centerId": {
97 | "centerID": 0,
98 | "pinCode": "string",
99 | "slot": "SLOT11000TO1030",
100 | "user_Id": 0
101 | },
102 | "mobile": "96197530",
103 | "password": "1456"
104 | }
105 |
106 | Response body
107 | {
108 | "timestamp": "2022-06-08T11:24:29.4154009",
109 | "message": "Please Enter Valid Mobile No",
110 | "details": "uri=/doctorlogin"
111 | }
112 | --------------------------------------------
113 | PATCH (Wrong uuid)
114 | /doctorlogout
115 | logOutDoctor
116 |
117 | Key: VO123 //(uuid)
118 |
119 |
120 | Response body
121 |
122 | {
123 | "timestamp": "2022-06-08T11:31:35.7965009",
124 | "message": "Doctor is not logged in with this number",
125 | "details": "uri=/doctorlogout"
126 | }
127 |
128 | --------------------------------------------
129 | PATCH (correct uuid)
130 | /doctorlogout
131 | logOutDoctor
132 |
133 | Key: V7OJPr //(uuid)
134 |
135 |
136 | Response body
137 | Logged Out...
138 | -----------------------------------------
139 |
140 |
141 |
142 |
143 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Testing/Tables:
--------------------------------------------------------------------------------
1 | Hibernate: create table appointment (appoint_id integer not null, appointment_date datetime(6), center_id integer, password varchar(255), s varchar(255), user_id integer default 0, primary key (appoint_id)) engine=InnoDB
2 | Hibernate: create table center_address (centerid integer not null, city varchar(255), pin_code varchar(255), state varchar(255), primary key (centerid)) engine=InnoDB
3 | Hibernate: create table doctor (doctor_id integer not null, email varchar(255), first_name varchar(255), gender varchar(255), last_name varchar(255), mobile integer default 0, password varchar(255), primary key (doctor_id)) engine=InnoDB
4 | Hibernate: create table doctor_dose_generation (dose_generation_id integer not null, d_password varchar(255), doctor_id integer, user_id integer, dose1_count_id integer, dose2_count_id integer, primary key (dose_generation_id)) engine=InnoDB
5 | Hibernate: create table doctor_login (login_ref integer not null, mobile varchar(255), password varchar(255), primary key (login_ref)) engine=InnoDB
6 | Hibernate: create table dose1 (count_id integer not null, date datetime(6), doctor_id integer, user_id integer default 0, primary key (count_id)) engine=InnoDB
7 | Hibernate: create table dose2 (count_id integer not null, date datetime(6), doctor_id integer, user_id integer default 0, primary key (count_id)) engine=InnoDB
8 | Hibernate: create table hibernate_sequence (next_val bigint) engine=InnoDB
9 | Hibernate: insert into hibernate_sequence values ( 1 )
10 | Hibernate: create table user (user_id integer not null, aadhar_no varchar(255), city varchar(255), dob datetime(6), first_name varchar(255), gender integer, last_name varchar(255), mobile varchar(255), password varchar(255), pin_code varchar(255), primary key (user_id)) engine=InnoDB
11 | Hibernate: create table user_login (login_ref integer not null, mobile varchar(255), password varchar(255), primary key (login_ref)) engine=InnoDB
12 | Hibernate: create table vaccine_storage (id integer not null, available_stock integer, centerid integer, primary key (id)) engine=InnoDB
13 | Hibernate: alter table appointment drop index UK_ocj7ys3racy36d4tdauqvvqp2
14 | Hibernate: alter table appointment add constraint UK_ocj7ys3racy36d4tdauqvvqp2 unique (user_id)
15 | Hibernate: alter table doctor drop index UK_5ncr3oof1ftvv6t1ie5ac4qc9
16 | Hibernate: alter table doctor add constraint UK_5ncr3oof1ftvv6t1ie5ac4qc9 unique (mobile)
17 | Hibernate: alter table dose1 drop index UK_h8cx6tww7ys916u4bn81bn8w4
18 | Hibernate: alter table dose1 add constraint UK_h8cx6tww7ys916u4bn81bn8w4 unique (user_id)
19 | Hibernate: alter table dose2 drop index UK_dahpfdw07llfuk0hau9b2pgi1
20 | Hibernate: alter table dose2 add constraint UK_dahpfdw07llfuk0hau9b2pgi1 unique (user_id)
21 | Hibernate: alter table user drop index UK_6uuf6642wus5lwkh9soh2r3v9
22 | Hibernate: alter table user add constraint UK_6uuf6642wus5lwkh9soh2r3v9 unique (aadhar_no)
23 | Hibernate: alter table user drop index UK_cnjwxx5favk5ycqajjt17fwy1
24 | Hibernate: alter table user add constraint UK_cnjwxx5favk5ycqajjt17fwy1 unique (mobile)
25 | Hibernate: alter table doctor_dose_generation add constraint FK8m5yq0mdlmy465hmogx6345vn foreign key (dose1_count_id) references dose1 (count_id)
26 | Hibernate: alter table doctor_dose_generation add constraint FKrpgc7brvr33k0y2to7qap5ucb foreign key (dose2_count_id) references dose2 (count_id)
27 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Exception/GlobalException.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Exception;
2 |
3 | import com.covid.vaccination.Entity.MyErrorDetails;
4 | import org.springframework.http.HttpStatus;
5 | import org.springframework.http.ResponseEntity;
6 | import org.springframework.web.bind.annotation.ControllerAdvice;
7 | import org.springframework.web.bind.annotation.ExceptionHandler;
8 | import org.springframework.web.context.request.WebRequest;
9 | import org.springframework.web.servlet.NoHandlerFoundException;
10 |
11 | import java.time.LocalDateTime;
12 |
13 | @ControllerAdvice
14 | public class GlobalException {
15 |
16 |
17 | @ExceptionHandler({InvalidMobileException.class})
18 | public ResponseEntity handleInvalidMobileException(InvalidMobileException exp, WebRequest req) {
19 | MyErrorDetails err = new MyErrorDetails(LocalDateTime.now(), exp.getMessage(), req.getDescription(false));
20 | return new ResponseEntity<>(err, HttpStatus.NOT_FOUND);
21 | }
22 |
23 | @ExceptionHandler({UserException.class})
24 | public ResponseEntity handleUserException(UserException exp, WebRequest req) {
25 | MyErrorDetails err = new MyErrorDetails(LocalDateTime.now(), exp.getMessage(), req.getDescription(false));
26 | return new ResponseEntity<>(err, HttpStatus.NOT_FOUND);
27 | }
28 |
29 | @ExceptionHandler({InvalidPasswordException.class})
30 | public ResponseEntity handleInvalidPasswordException(InvalidPasswordException exp, WebRequest req) {
31 | MyErrorDetails err = new MyErrorDetails(LocalDateTime.now(), exp.getMessage(), req.getDescription(false));
32 | return new ResponseEntity<>(err, HttpStatus.UNAUTHORIZED);
33 | }
34 |
35 | @ExceptionHandler({UserAlreadyExistWithMobileNumber.class})
36 | public ResponseEntity handleUserAlreadyExistWithMobileNumber(UserAlreadyExistWithMobileNumber exp, WebRequest req) {
37 | MyErrorDetails err = new MyErrorDetails(LocalDateTime.now(), exp.getMessage(), req.getDescription(false));
38 | return new ResponseEntity<>(err, HttpStatus.ALREADY_REPORTED);
39 | }
40 |
41 | @ExceptionHandler({AddressException.class})
42 | public ResponseEntity handleAddressException(AddressException exp, WebRequest req) {
43 | MyErrorDetails err = new MyErrorDetails(LocalDateTime.now(), exp.getMessage(), req.getDescription(false));
44 | return new ResponseEntity<>(err, HttpStatus.NOT_FOUND);
45 | }
46 |
47 | @ExceptionHandler(NoHandlerFoundException.class)
48 | public ResponseEntity mynotFoundHandler(NoHandlerFoundException nfe, WebRequest req) {
49 | System.out.println("Wrong Request");
50 |
51 | MyErrorDetails err = new MyErrorDetails(LocalDateTime.now(), nfe.getMessage(), req.getDescription(false));
52 |
53 | return new ResponseEntity<>(err, HttpStatus.METHOD_NOT_ALLOWED);
54 |
55 | }
56 |
57 |
58 | @ExceptionHandler(Exception.class)
59 | public ResponseEntity myExpHandlerMain(Exception ie, WebRequest wr) {
60 | System.out.println("Please enter correct Details");
61 |
62 |
63 | MyErrorDetails err = new MyErrorDetails(LocalDateTime.now(), ie.getMessage(), wr.getDescription(false));
64 |
65 |
66 | return new ResponseEntity(err, HttpStatus.BAD_REQUEST);
67 |
68 | }
69 | }
70 |
71 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Implementation/DoseGenerationImpl.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Implementation;
2 |
3 | import com.covid.vaccination.Entity.*;
4 | import com.covid.vaccination.Exception.UserAlreadyExistWithMobileNumber;
5 | import com.covid.vaccination.Repository.*;
6 | import com.covid.vaccination.Service.DoseGenerationService;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.stereotype.Service;
9 |
10 |
11 | @Service
12 | public class DoseGenerationImpl implements DoseGenerationService {
13 | @Autowired
14 | public DoseGenerationRepository doseGenerationRepository;
15 | @Autowired
16 | public Dose1Repository dose1Repository;
17 | @Autowired
18 | public Dose2Repository dose2Repository;
19 |
20 | @Autowired
21 | public AppointmentServiceImpl appointmentService;
22 | @Autowired
23 | public AppointmentRepository appointmentRepository;
24 | @Autowired
25 | public DoctorServicesImp doctorServicesImp;
26 | @Autowired
27 | public DoctorRepository doctorRepository;
28 |
29 | @Autowired
30 | public VaccineStorageRepository vaccineStorageRepository;
31 |
32 | @Autowired
33 | public VaccineStorageServiceImpl vaccineStorageService;
34 |
35 | @Autowired
36 | public DoctorLoginRepository doctorLoginRepository;
37 |
38 | public String generatedDose(DoctorDoseGeneration doctorDoseGeneration) {
39 | Doctor d=doctorRepository.getDoctorByDoctorId(doctorDoseGeneration.getDoctorId());
40 | DoctorLogin doctorLogin=doctorLoginRepository.getDoctorLoginByMobile(doctorRepository.getDoctorByDoctorId(doctorDoseGeneration.getDoctorId()).getMobile());
41 | if(doctorLogin!=null){
42 | if(d!=null){
43 | if(doctorDoseGeneration.getD_password().equals(d.getPassword())){
44 | Appointment appointment=appointmentRepository.findByUser_id(doctorDoseGeneration.getUser_id());
45 | Dose1 dose1 = dose1Repository.getDose1ByUser_id(doctorDoseGeneration.getUser_id());
46 | Dose2 dose2 = dose2Repository.getDose2ByUser_id(doctorDoseGeneration.getUser_id());
47 | if (dose1 == null && dose2 == null&&appointment!=null) {
48 | doseGenerationRepository.save(doctorDoseGeneration);
49 | vaccineStorageService.updateVaccineStorage(appointment.getCenter_id());
50 | appointmentRepository.delete(appointment);
51 | return "Dose 1 SuccessFully Vaccinated";
52 | }
53 | else if ((dose1 != null) && dose2 == null && appointment!=null) {
54 | if(doctorDoseGeneration.getDose1()==null){
55 | doseGenerationRepository.save(doctorDoseGeneration);
56 | vaccineStorageService.updateVaccineStorage(appointment.getCenter_id());
57 | appointmentRepository.delete(appointment);
58 | return "Dose 2 Successfully Vaccinated";
59 | }else {
60 | return "Already Dose 1 Completed";
61 | }
62 | } else if(dose1!=null&&dose2!=null&&appointment==null){
63 | return "You Are Fully Vaccinated";
64 | }
65 | else
66 | return "Please Book Your Appointment";
67 | }
68 | else
69 | throw new UserAlreadyExistWithMobileNumber("Please Fill Correct Doctor Password");
70 | }
71 | else
72 | throw new UserAlreadyExistWithMobileNumber("Doctor Not Found/Exist");
73 | }
74 | else
75 | throw new UserAlreadyExistWithMobileNumber("Please Login First.");
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Implementation/AppointmentServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Implementation;
2 |
3 | import com.covid.vaccination.Entity.Appointment;
4 | import com.covid.vaccination.Entity.UserLogin;
5 | import com.covid.vaccination.Entity.VaccineStorage;
6 | import com.covid.vaccination.Exception.UserAlreadyExistWithMobileNumber;
7 | import com.covid.vaccination.Exception.UserException;
8 | import com.covid.vaccination.Repository.*;
9 | import com.covid.vaccination.Service.AppointmentService;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.http.HttpStatus;
12 | import org.springframework.http.ResponseEntity;
13 | import org.springframework.stereotype.Service;
14 | import org.springframework.web.server.ResponseStatusException;
15 |
16 | import java.util.List;
17 |
18 | @Service
19 | public class AppointmentServiceImpl implements AppointmentService {
20 | @Autowired
21 | public AppointmentRepository appointmentRepository;
22 |
23 | @Autowired
24 | public UserServiceImpl userService;
25 |
26 | @Autowired
27 | public Dose1Repository dose1Repository;
28 | @Autowired
29 | public Dose2Repository dose2Repository;
30 |
31 | @Autowired
32 | CenterAddressRepository centerAddressRepository;
33 |
34 | @Autowired
35 | VaccineStorageRepository vaccineStorageRepository;
36 | @Autowired
37 | public UserLoginRepository userLoginRepository;
38 |
39 | @Override
40 | public ResponseEntity setAppointment(Appointment appointment) {
41 | UserLogin userLogin= userLoginRepository.getUserLoginByMobile(userService.getUserById(appointment.getUser_id()).getMobile());
42 | if(userLogin!=null){
43 | if (centerAddressRepository.existsById(appointment.getCenter_id())) {
44 | VaccineStorage v=vaccineStorageRepository.findByCenterID(appointment.getCenter_id());
45 | if(v.getAvailableStock()<=0 || v==null){
46 | throw new UserAlreadyExistWithMobileNumber("No vaccine Available at this Center");
47 | }
48 | if (userService.getUserById(appointment.getUser_id()).getPassword().equals(appointment.getPassword())) {
49 | if (dose2Repository.getDose2ByUser_id(appointment.getUser_id()) != null) {
50 | throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Already User Has Taken Both Doses.");
51 | }
52 | Appointment optional = appointmentRepository.findByUser_id(appointment.getUser_id());
53 | if (optional == null) {
54 | Appointment result = appointmentRepository.save(appointment);
55 | return new ResponseEntity<>(result, HttpStatus.OK);
56 | } else
57 | throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "User Already Generated an Appointment Please Wait for Doctor Approval.");
58 |
59 | } else
60 | throw new UserAlreadyExistWithMobileNumber("Please Fill Correct User Id & Password");
61 | } else {
62 | throw new UserAlreadyExistWithMobileNumber("No center available with this center Id, Kindly enter correct center ID");
63 | }
64 | }
65 | else
66 | throw new UserAlreadyExistWithMobileNumber("Please Login First.");
67 |
68 | }
69 |
70 | @Override
71 | public ResponseEntity getAppointmentById(Integer id) {
72 | Appointment result= appointmentRepository.findById(id).orElseThrow(() -> new UserException("User does not exist with User Id :" + id));
73 |
74 | return new ResponseEntity<>(result, HttpStatus.OK);
75 | }
76 |
77 | @Override
78 | public ResponseEntity deleteAppointmentById(Integer id) {
79 | Appointment existingUser= appointmentRepository.findById(id).orElseThrow( () -> new UserException("User does not exist with this UserId :"+id) );
80 | appointmentRepository.delete(existingUser);
81 | return new ResponseEntity<>(existingUser,HttpStatus.OK);
82 | }
83 |
84 | @Override
85 | public ResponseEntity> getAllAppointment() {
86 |
87 | return new ResponseEntity<>(appointmentRepository.findAll(),HttpStatus.OK);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Testing/Tested:
--------------------------------------------------------------------------------
1 | user:-
2 | {
3 | "address": {
4 | "address_id": 0,
5 | "city": "string",
6 | "pinCode": "string",
7 | "state": "string"
8 | },
9 | "age": 0,
10 | "centerAddress": {
11 | "address_id": 0,
12 | "center": {
13 | "centerID": 0,
14 | "centerName": "string",
15 | "count": 0,
16 | "slot": "SLOT11000TO1030"
17 | },
18 | "city": "string",
19 | "pinCode": "string",
20 | "state": "string"
21 | },
22 | "dob": "dd-MM-yyyy",
23 | "email": "string",
24 | "firstName": "string",
25 | "gender": "string",
26 | "idProof": {
27 | "aadharNo": "string",
28 | "panCardNo": "string",
29 | "refId": 0
30 | },
31 | "lastName": "string",
32 | "mobile": "string",
33 | "password": "string",
34 | "user_id": 0
35 | }
36 |
37 | -----------------------------------------------
38 |
39 | getUserById : 3
40 | Response body:
41 | {
42 | "user_id": 3,
43 | "firstName": "Abusalem",
44 | "lastName": "M",
45 | "age": 19,
46 | "mobile": "86689926820",
47 | "dob": "09-07-2002",
48 | "password": "password@12",
49 | "gender": "male",
50 | "email": "abu@gmail.com",
51 | "address": {
52 | "address_id": 1,
53 | "city": "Sangli",
54 | "state": "MH",
55 | "pinCode": "416404"
56 | },
57 | "idProof": {
58 | "refId": 2,
59 | "aadharNo": "440940605150",
60 | "panCardNo": null
61 | }
62 | }
63 |
64 | Response Header:
65 | connection: keep-alive
66 | content-type: application/json
67 | date: Sun, 05 Jun 2022 19:34:22 GMT
68 | keep-alive: timeout=60
69 | transfer-encoding: chunked
70 |
71 | ---------------------------------------------------
72 |
73 | getUserById : 1
74 |
75 | Response body:
76 | {
77 | "timestamp": "2022-06-06T01:06:20.1132752",
78 | "message": "User does not exist with Roll :1",
79 | "details": "uri=/User/1"
80 | }
81 |
82 | Response Header:
83 | connection: keep-alive
84 | content-type: application/json
85 | date: Sun, 05 Jun 2022 19:36:20 GMT
86 | keep-alive: timeout=60
87 | transfer-encoding: chunked
88 |
89 |
90 |
91 | ------------------------------------------------------------
92 |
93 | getAllUserFromDB
94 |
95 | Response body:
96 |
97 | [
98 | {
99 | "user_id": 3,
100 | "firstName": "Abusalem",
101 | "lastName": "M",
102 | "age": 19,
103 | "mobile": "86689926820",
104 | "dob": "09-07-2002",
105 | "password": "password@12",
106 | "gender": "male",
107 | "email": "abu@gmail.com",
108 | "address": {
109 | "address_id": 1,
110 | "city": "Sangli",
111 | "state": "MH",
112 | "pinCode": "416404"
113 | },
114 | "idProof": {
115 | "refId": 2,
116 | "aadharNo": "440940605150",
117 | "panCardNo": null
118 | }
119 | },
120 | {
121 | "user_id": 6,
122 | "firstName": "Abusalem",
123 | "lastName": "M",
124 | "age": 19,
125 | "mobile": "86689926820",
126 | "dob": "09-07-2002",
127 | "password": "password@12",
128 | "gender": "male",
129 | "email": "abu@gmail.com",
130 | "address": {
131 | "address_id": 4,
132 | "city": "Sangli",
133 | "state": "MH",
134 | "pinCode": "416404"
135 | },
136 | "idProof": {
137 | "refId": 5,
138 | "aadharNo": "440940605150",
139 | "panCardNo": null
140 | }
141 | }
142 | ]
143 |
144 | Response headers:
145 | connection: keep-alive
146 | content-type: application/json
147 | date: Sun, 05 Jun 2022 19:39:36 GMT
148 | keep-alive: timeout=60
149 | transfer-encoding: chunked
150 |
151 | -------------------------------------------------------
152 |
153 | updateUserByUsingId
154 | key = 3
155 |
156 | Response body
157 | Download
158 | {
159 | "timestamp": "2022-06-06T01:13:57.9666292",
160 | "message": "Unauthorized",
161 | "details": "uri=/updateUser"
162 | }
163 | Response headers
164 | connection: keep-alive
165 | content-type: application/json
166 | date: Sun, 05 Jun 2022 19:43:57 GMT
167 | keep-alive: timeout=60
168 | transfer-encoding: chunked
169 |
170 |
171 | -------------------------------------------------
172 |
173 | deleteUserUsingId id=1
174 |
175 | Response body
176 | Download
177 | {
178 | "timestamp": "2022-06-06T01:15:21.7043345",
179 | "message": "User does not exist with this Id :1",
180 | "details": "uri=/deleteUser/1"
181 | }
182 | Response headers
183 | connection: keep-alive
184 | content-type: application/json
185 | date: Sun, 05 Jun 2022 19:45:21 GMT
186 | keep-alive: timeout=60
187 | transfer-encoding: chunked
188 |
189 | ----------------------------------------------------
190 |
191 | deleteUserUsingId id=6
192 |
193 |
194 | Response body
195 | Download
196 | {
197 | "user_id": 6,
198 | "firstName": "Abusalem",
199 | "lastName": "M",
200 | "age": 19,
201 | "mobile": "86689926820",
202 | "dob": "09-07-2002",
203 | "password": "password@12",
204 | "gender": "male",
205 | "email": "abu@gmail.com",
206 | "address": {
207 | "address_id": 4,
208 | "city": "Sangli",
209 | "state": "MH",
210 | "pinCode": "416404"
211 | },
212 | "idProof": {
213 | "refId": 5,
214 | "aadharNo": "440940605150",
215 | "panCardNo": null
216 | }
217 | }
218 | Response headers
219 | connection: keep-alive
220 | content-type: application/json
221 | date: Sun, 05 Jun 2022 19:46:18 GMT
222 | keep-alive: timeout=60
223 | transfer-encoding: chunked
224 |
225 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Controller/AdminController.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Controller;
2 |
3 | import com.covid.vaccination.Entity.*;
4 | import com.covid.vaccination.Repository.UserRepository;
5 | import com.covid.vaccination.Repository.VaccineStorageRepository;
6 | import com.covid.vaccination.Service.*;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.http.HttpStatus;
9 | import org.springframework.http.ResponseEntity;
10 | import org.springframework.web.bind.annotation.*;
11 |
12 | import java.util.List;
13 |
14 | @RestController
15 | @RequestMapping("/admin")
16 | public class AdminController {
17 | @Autowired
18 | public UserService usi;
19 |
20 | @Autowired
21 | public DoctorServices doctorServicesImp;
22 | @Autowired
23 | public Dose1Service dose1Serviceimpl;
24 |
25 | @Autowired
26 | public UserRepository userRepository;
27 |
28 | @Autowired
29 | public VaccineStorageRepository vaccineStorageRepository;
30 |
31 | //Get user by user id.
32 |
33 | @GetMapping("search/user/{id}")
34 | public User getUserById(@PathVariable("id") Integer id) {
35 | return usi.getUserById(id);
36 | }
37 | //Get All Users from the database.
38 | @GetMapping("all/users")
39 | public List getAllUserFromDB() {
40 | return usi.getAllUsers();
41 | }
42 |
43 | @GetMapping("all/doctors")
44 | public ResponseEntity> getAllDoctorFromDB() {
45 | return doctorServicesImp.getAllDoctors();
46 | }
47 | @GetMapping("doctor/{dUserId}")
48 | public Doctor getDoctorFromDB(@PathVariable("dUserId") Integer dUserId) {
49 | return doctorServicesImp.getDoctor(dUserId);
50 | }
51 |
52 |
53 | @GetMapping("Dose1CompletedUsers")
54 | public List getAllDose1CompletedUsers(){
55 | return dose1Serviceimpl.getAllUser();
56 | }
57 | @GetMapping("BothDoseCompleted")
58 | public List getAllDoseCompletedUsers(){
59 | return userRepository.getAllBothDoseCompleted();
60 | }
61 | @GetMapping("search/Aadhar/{AadharNo}")
62 | public User getUserByAadharNo(@PathVariable("AadharNo")String id){
63 | return userRepository.getUsersByAadharNo(id);
64 | }
65 | @GetMapping("search/Mobile/{Mobile}")
66 | public User getUserByMobileNo(@PathVariable("Mobile")String id){
67 | return userRepository.getUsersByMobileNo(id);
68 | }
69 | @PostMapping("create/user")
70 | public String createUser(@RequestBody User user){
71 | usi.saveUser(user);
72 | return "User Has Been Added Into DataBase.";
73 | }
74 | @PostMapping("create/doctor")
75 | public String createDoctor(@RequestBody Doctor doctor) {
76 | doctorServicesImp.addDoctor(doctor);
77 | return "Doctor Has Been Added Into DataBase.";
78 | }
79 | @PutMapping("update/user/")
80 | public User updateUserByUsingId(@RequestBody User user,@RequestParam String key){
81 | return usi.updateUser(user,key);
82 | }
83 |
84 | @DeleteMapping("delete/user/{id}")
85 | public User deleteUserByUserId(@PathVariable("id") Integer id){
86 | return usi.deleteUserById(id);
87 | }
88 |
89 | @DeleteMapping("delete/doctor/{id}")
90 | public ResponseEntity deleteDoctorUsingId(@PathVariable("id") Integer id) {
91 |
92 | return doctorServicesImp.deleteDoctorById(id);
93 | }
94 | @Autowired
95 | public VaccineStorageService vaccineStorageService;
96 | @PostMapping("/center/addVaccine")
97 | public VaccineStorage AddingVaccineToCenter(@RequestBody VaccineStorage vaccineStorage) {
98 | return vaccineStorageService.save(vaccineStorage);
99 | }
100 | @Autowired
101 | public centerAddressService centerCreationService;
102 |
103 | @PostMapping("/create/center")
104 | public ResponseEntity createCenter(@RequestBody centerAddress centerAddress) {
105 |
106 | centerCreationService.saveCenterAddress(centerAddress);
107 |
108 | return new ResponseEntity<>(centerAddress, HttpStatus.OK);
109 | }
110 |
111 | @GetMapping("search/center/{id}")
112 | public ResponseEntity getCenterById(@PathVariable("id")Integer id){
113 | centerAddress c= centerCreationService.getCenterAddressById(id);
114 | if(c!=null){
115 | return new ResponseEntity<>(c,HttpStatus.OK);
116 | }
117 | else
118 | return new ResponseEntity<>(null,HttpStatus.BAD_REQUEST);
119 | }
120 |
121 | @GetMapping("/all/centers")
122 | public ResponseEntity> getAllAddress(){
123 | List list = centerCreationService.getAllCenterList();
124 | if(list!=null){
125 | return new ResponseEntity<>(list,HttpStatus.OK);
126 | }
127 | else
128 | return new ResponseEntity<>(null,HttpStatus.BAD_REQUEST);
129 | }
130 |
131 | @DeleteMapping("delete/center/{id}")
132 | public ResponseEntity deleteCenterById(@PathVariable("id")Integer id){
133 | centerAddress c=centerCreationService.deleteCenterById(id);
134 | if(c!=null){
135 | return new ResponseEntity<>(c,HttpStatus.OK);
136 | }
137 | else
138 | return new ResponseEntity<>(null,HttpStatus.BAD_REQUEST);
139 | }
140 |
141 | @PutMapping("update/center")
142 | public centerAddress updateCenter(@RequestBody centerAddress center) {
143 | centerCreationService.saveCenterAddress(center);
144 | return center;
145 | }
146 |
147 | @GetMapping ("search/centerStorage/{id}")
148 | public VaccineStorage getVaccineStorageByCenterId(@PathVariable("id") Integer id){
149 | return vaccineStorageRepository.findByCenterID(id);
150 | }
151 | @GetMapping("all/centerStorage")
152 | public List getAllCenterVaccineStorage(){
153 | return vaccineStorageRepository.findAll();
154 | }
155 | }
156 |
--------------------------------------------------------------------------------
/CovidVaccination/src/main/java/com/covid/vaccination/Implementation/DoctorServicesImp.java:
--------------------------------------------------------------------------------
1 | package com.covid.vaccination.Implementation;
2 |
3 |
4 | import com.covid.vaccination.Entity.Doctor;
5 | import com.covid.vaccination.Entity.DoctorLogin;
6 | import com.covid.vaccination.Entity.User;
7 | import com.covid.vaccination.Entity.UserLogin;
8 | import com.covid.vaccination.Exception.DoctorException;
9 | import com.covid.vaccination.Exception.UserAlreadyExistWithMobileNumber;
10 | import com.covid.vaccination.Exception.UserException;
11 | import com.covid.vaccination.Repository.DoctorLoginRepository;
12 | import com.covid.vaccination.Repository.DoctorRepository;
13 | import com.covid.vaccination.Service.DoctorServices;
14 | import net.bytebuddy.utility.RandomString;
15 | import org.springframework.beans.factory.annotation.Autowired;
16 | import org.springframework.http.HttpStatus;
17 | import org.springframework.http.ResponseEntity;
18 | import org.springframework.stereotype.Service;
19 |
20 | import java.time.LocalDateTime;
21 | import java.util.List;
22 | import java.util.Objects;
23 | import java.util.Optional;
24 |
25 | @Service
26 | public class DoctorServicesImp implements DoctorServices {
27 |
28 | @Autowired
29 | public DoctorRepository doctorRepo;
30 |
31 | @Autowired
32 | DoctorLoginRepository doctorLoginRepository;
33 |
34 |
35 | @Override
36 | public ResponseEntity addDoctor(Doctor doctor) {
37 |
38 | return new ResponseEntity<>(doctorRepo.save(doctor),HttpStatus.OK);
39 | }
40 |
41 | @Override
42 | public Doctor getDoctor(Integer did) {
43 |
44 | Doctor doctorOpt = doctorRepo.findByDoctorId(did);
45 | if(doctorOpt==null){
46 | throw new DoctorException("Doctor not exist with this ID "+did);
47 | }
48 | return doctorOpt;
49 | }
50 |
51 | @Override
52 | public ResponseEntity deleteDoctorById(Integer did) {
53 |
54 | Doctor existingDoctor = doctorRepo.findById(did).orElseThrow(() -> new UserException("Doctor does not exist with this Id :" + did));
55 | doctorRepo.delete(existingDoctor);
56 | return new ResponseEntity<>(existingDoctor,HttpStatus.OK);
57 | }
58 |
59 | @Override
60 | public ResponseEntity> getAllDoctors() {
61 | return new ResponseEntity<>(doctorRepo.findAll(),HttpStatus.OK);
62 | }
63 |
64 |
65 |
66 | @Override
67 | public ResponseEntity updateDoctorDetails(Doctor doctor, String password) throws Exception {
68 | Doctor doctor2 = doctorRepo.findByDoctorId(doctor.getDoctorId());
69 | if(doctor2!=null){
70 | DoctorLogin u= doctorLoginRepository.getDoctorLoginByMobile(doctor2.getMobile());
71 | if(u!=null){
72 | if(u.getPassword().equals(password)){
73 | Doctor updated= doctorRepo.save(doctor);
74 | doctorLoginRepository.delete(u);
75 | return new ResponseEntity<>(updated,HttpStatus.OK);
76 | }
77 | else
78 | throw new UserAlreadyExistWithMobileNumber("Please fill Correct password");
79 | }
80 | else
81 | throw new UserAlreadyExistWithMobileNumber("Please Login First.");
82 | }
83 | else
84 | throw new UserAlreadyExistWithMobileNumber("Please Check Doctor Id");
85 | }
86 |
87 |
88 | // @Override
89 | // public ResponseEntity updateDoctorDetails(String key, Doctor newdoctor) throws Exception {
90 | // return null;
91 | // }
92 | //
93 | // @Override
94 | // public String logoutAccount(String key) {
95 | // return null;
96 | // }
97 |
98 | @Override
99 | public ResponseEntity viewProfile(String Sessionkey) {
100 | return null;
101 | }
102 |
103 | //@Override
104 | // public ResponseEntity updateDoctorDetails(String key, Doctor newdoctor) {
105 | //
106 | // if (key.equals("1111")){
107 | // return new ResponseEntity<>(doctorRepo.save(newdoctor), HttpStatus.OK);
108 | // }
109 | //
110 | // Optional sessionOpt = doctorSessionRepo.findByUuid(key);
111 | //
112 | // if (!sessionOpt.isPresent()) {
113 | // throw new DoctorException("Can't update, Please try to login first.");
114 | // }
115 | // CurrentDoctorSession session = sessionOpt.get();
116 | //
117 | // Optional doctorOpt = doctorRepo.findById(session.getId());
118 | //
119 | // Integer updaterId = doctorOpt.get().getDoctorId();
120 | //
121 | // if(!Objects.equals(updaterId, newdoctor.getDoctorId())){
122 | // throw new DoctorException("You are not supposed to update others Details..");
123 | // }
124 | //
125 | // Doctor updatedDoc= doctorRepo.save(newdoctor);
126 | // return new ResponseEntity<>(updatedDoc,HttpStatus.OK);
127 | //}
128 | //
129 | //
130 | // // Login and Logout Functionalities..
131 | // // (To take charge of a particular center)
132 | // @Override
133 | // public String loginAccount(DoctorDTO dto) {
134 | //
135 | // Optional doctorOpt = doctorRepo.findByMobile(dto.getMobile());
136 | //
137 | // if (dto.getMobile().length() != 10 || !doctorOpt.isPresent()) {
138 | // throw new InvalidMobileException("Please Enter Valid Mobile No");
139 | // }
140 | //
141 | // Doctor currDoctor = doctorOpt.get();
142 | // Integer did = currDoctor.getDoctorId();
143 | //
144 | // if (!currDoctor.getPassword().equals(dto.getPassword())) {
145 | // throw new DoctorException("Please enter a valid password");
146 | // }
147 | //
148 | // Optional currentDoctorSession = doctorSessionRepo.findById(did);
149 | //
150 | // if (currentDoctorSession.isPresent()) {
151 | // throw new DoctorException("You are already working to a center..");
152 | // }
153 | //
154 | // String key = RandomString.make(7);
155 | //
156 | // CurrentDoctorSession session = new CurrentDoctorSession(currDoctor.getDoctorId(), key, LocalDateTime.now());
157 | //
158 | // doctorSessionRepo.save(session);
159 | //
160 | // return doctorSessionRepo.toString();
161 | //
162 | // }
163 | //
164 | // @Override
165 | // public String logoutAccount(String key) {
166 | //
167 | // Optional session = doctorSessionRepo.findByUuid(key);
168 | //
169 | // if (!session.isPresent()) {
170 | // throw new DoctorException("Invalid key OR Doctor is present in the center");
171 | // }
172 | // doctorSessionRepo.delete(session.get());
173 | //
174 | // return "Doctor is leaving from the center..";
175 | // }
176 | //
177 | //
178 | // // View Profile If logedIn
179 | // @Override
180 | // public ResponseEntity viewProfile(String sessionkey) {
181 | //
182 | // Optional sessionOpt = doctorSessionRepo.findByUuid(sessionkey);
183 | //
184 | // if (!sessionOpt.isPresent()) {
185 | // throw new DoctorException("You are not loggedIn");
186 | // }
187 | // CurrentDoctorSession session = sessionOpt.get();
188 | //
189 | // Optional doctorOpt = doctorRepo.findById(session.getId());
190 | //
191 | // return new ResponseEntity<>(doctorOpt.get(),HttpStatus.OK);
192 | //
193 | // }
194 |
195 | }
196 |
--------------------------------------------------------------------------------
/CovidVaccination/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM https://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM set title of command window
39 | title %0
40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
42 |
43 | @REM set %HOME% to equivalent of $HOME
44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45 |
46 | @REM Execute a user defined script before this one
47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
49 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
50 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
51 | :skipRcPre
52 |
53 | @setlocal
54 |
55 | set ERROR_CODE=0
56 |
57 | @REM To isolate internal variables from possible post scripts, we use another setlocal
58 | @setlocal
59 |
60 | @REM ==== START VALIDATION ====
61 | if not "%JAVA_HOME%" == "" goto OkJHome
62 |
63 | echo.
64 | echo Error: JAVA_HOME not found in your environment. >&2
65 | echo Please set the JAVA_HOME variable in your environment to match the >&2
66 | echo location of your Java installation. >&2
67 | echo.
68 | goto error
69 |
70 | :OkJHome
71 | if exist "%JAVA_HOME%\bin\java.exe" goto init
72 |
73 | echo.
74 | echo Error: JAVA_HOME is set to an invalid directory. >&2
75 | echo JAVA_HOME = "%JAVA_HOME%" >&2
76 | echo Please set the JAVA_HOME variable in your environment to match the >&2
77 | echo location of your Java installation. >&2
78 | echo.
79 | goto error
80 |
81 | @REM ==== END VALIDATION ====
82 |
83 | :init
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122 |
123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
124 |
125 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127 | )
128 |
129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131 | if exist %WRAPPER_JAR% (
132 | if "%MVNW_VERBOSE%" == "true" (
133 | echo Found %WRAPPER_JAR%
134 | )
135 | ) else (
136 | if not "%MVNW_REPOURL%" == "" (
137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
138 | )
139 | if "%MVNW_VERBOSE%" == "true" (
140 | echo Couldn't find %WRAPPER_JAR%, downloading it ...
141 | echo Downloading from: %DOWNLOAD_URL%
142 | )
143 |
144 | powershell -Command "&{"^
145 | "$webclient = new-object System.Net.WebClient;"^
146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148 | "}"^
149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150 | "}"
151 | if "%MVNW_VERBOSE%" == "true" (
152 | echo Finished downloading %WRAPPER_JAR%
153 | )
154 | )
155 | @REM End of extension
156 |
157 | @REM Provide a "standardized" way to retrieve the CLI args that will
158 | @REM work with both Windows and non-Windows executions.
159 | set MAVEN_CMD_LINE_ARGS=%*
160 |
161 | %MAVEN_JAVA_EXE% ^
162 | %JVM_CONFIG_MAVEN_PROPS% ^
163 | %MAVEN_OPTS% ^
164 | %MAVEN_DEBUG_OPTS% ^
165 | -classpath %WRAPPER_JAR% ^
166 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
167 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
168 | if ERRORLEVEL 1 goto error
169 | goto end
170 |
171 | :error
172 | set ERROR_CODE=1
173 |
174 | :end
175 | @endlocal & set ERROR_CODE=%ERROR_CODE%
176 |
177 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
178 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
179 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
180 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
181 | :skipRcPost
182 |
183 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
184 | if "%MAVEN_BATCH_PAUSE%"=="on" pause
185 |
186 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
187 |
188 | cmd /C exit /B %ERROR_CODE%
189 |
--------------------------------------------------------------------------------
/CovidVaccination/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # https://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /usr/local/etc/mavenrc ] ; then
40 | . /usr/local/etc/mavenrc
41 | fi
42 |
43 | if [ -f /etc/mavenrc ] ; then
44 | . /etc/mavenrc
45 | fi
46 |
47 | if [ -f "$HOME/.mavenrc" ] ; then
48 | . "$HOME/.mavenrc"
49 | fi
50 |
51 | fi
52 |
53 | # OS specific support. $var _must_ be set to either true or false.
54 | cygwin=false;
55 | darwin=false;
56 | mingw=false
57 | case "`uname`" in
58 | CYGWIN*) cygwin=true ;;
59 | MINGW*) mingw=true;;
60 | Darwin*) darwin=true
61 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
62 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
63 | if [ -z "$JAVA_HOME" ]; then
64 | if [ -x "/usr/libexec/java_home" ]; then
65 | export JAVA_HOME="`/usr/libexec/java_home`"
66 | else
67 | export JAVA_HOME="/Library/Java/Home"
68 | fi
69 | fi
70 | ;;
71 | esac
72 |
73 | if [ -z "$JAVA_HOME" ] ; then
74 | if [ -r /etc/gentoo-release ] ; then
75 | JAVA_HOME=`java-config --jre-home`
76 | fi
77 | fi
78 |
79 | if [ -z "$M2_HOME" ] ; then
80 | ## resolve links - $0 may be a link to maven's home
81 | PRG="$0"
82 |
83 | # need this for relative symlinks
84 | while [ -h "$PRG" ] ; do
85 | ls=`ls -ld "$PRG"`
86 | link=`expr "$ls" : '.*-> \(.*\)$'`
87 | if expr "$link" : '/.*' > /dev/null; then
88 | PRG="$link"
89 | else
90 | PRG="`dirname "$PRG"`/$link"
91 | fi
92 | done
93 |
94 | saveddir=`pwd`
95 |
96 | M2_HOME=`dirname "$PRG"`/..
97 |
98 | # make it fully qualified
99 | M2_HOME=`cd "$M2_HOME" && pwd`
100 |
101 | cd "$saveddir"
102 | # echo Using m2 at $M2_HOME
103 | fi
104 |
105 | # For Cygwin, ensure paths are in UNIX format before anything is touched
106 | if $cygwin ; then
107 | [ -n "$M2_HOME" ] &&
108 | M2_HOME=`cygpath --unix "$M2_HOME"`
109 | [ -n "$JAVA_HOME" ] &&
110 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
111 | [ -n "$CLASSPATH" ] &&
112 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
113 | fi
114 |
115 | # For Mingw, ensure paths are in UNIX format before anything is touched
116 | if $mingw ; then
117 | [ -n "$M2_HOME" ] &&
118 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
119 | [ -n "$JAVA_HOME" ] &&
120 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
121 | fi
122 |
123 | if [ -z "$JAVA_HOME" ]; then
124 | javaExecutable="`which javac`"
125 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
126 | # readlink(1) is not available as standard on Solaris 10.
127 | readLink=`which readlink`
128 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
129 | if $darwin ; then
130 | javaHome="`dirname \"$javaExecutable\"`"
131 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
132 | else
133 | javaExecutable="`readlink -f \"$javaExecutable\"`"
134 | fi
135 | javaHome="`dirname \"$javaExecutable\"`"
136 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
137 | JAVA_HOME="$javaHome"
138 | export JAVA_HOME
139 | fi
140 | fi
141 | fi
142 |
143 | if [ -z "$JAVACMD" ] ; then
144 | if [ -n "$JAVA_HOME" ] ; then
145 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
146 | # IBM's JDK on AIX uses strange locations for the executables
147 | JAVACMD="$JAVA_HOME/jre/sh/java"
148 | else
149 | JAVACMD="$JAVA_HOME/bin/java"
150 | fi
151 | else
152 | JAVACMD="`\\unset -f command; \\command -v java`"
153 | fi
154 | fi
155 |
156 | if [ ! -x "$JAVACMD" ] ; then
157 | echo "Error: JAVA_HOME is not defined correctly." >&2
158 | echo " We cannot execute $JAVACMD" >&2
159 | exit 1
160 | fi
161 |
162 | if [ -z "$JAVA_HOME" ] ; then
163 | echo "Warning: JAVA_HOME environment variable is not set."
164 | fi
165 |
166 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
167 |
168 | # traverses directory structure from process work directory to filesystem root
169 | # first directory with .mvn subdirectory is considered project base directory
170 | find_maven_basedir() {
171 |
172 | if [ -z "$1" ]
173 | then
174 | echo "Path not specified to find_maven_basedir"
175 | return 1
176 | fi
177 |
178 | basedir="$1"
179 | wdir="$1"
180 | while [ "$wdir" != '/' ] ; do
181 | if [ -d "$wdir"/.mvn ] ; then
182 | basedir=$wdir
183 | break
184 | fi
185 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
186 | if [ -d "${wdir}" ]; then
187 | wdir=`cd "$wdir/.."; pwd`
188 | fi
189 | # end of workaround
190 | done
191 | echo "${basedir}"
192 | }
193 |
194 | # concatenates all lines of a file
195 | concat_lines() {
196 | if [ -f "$1" ]; then
197 | echo "$(tr -s '\n' ' ' < "$1")"
198 | fi
199 | }
200 |
201 | BASE_DIR=`find_maven_basedir "$(pwd)"`
202 | if [ -z "$BASE_DIR" ]; then
203 | exit 1;
204 | fi
205 |
206 | ##########################################################################################
207 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
208 | # This allows using the maven wrapper in projects that prohibit checking in binary data.
209 | ##########################################################################################
210 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
211 | if [ "$MVNW_VERBOSE" = true ]; then
212 | echo "Found .mvn/wrapper/maven-wrapper.jar"
213 | fi
214 | else
215 | if [ "$MVNW_VERBOSE" = true ]; then
216 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
217 | fi
218 | if [ -n "$MVNW_REPOURL" ]; then
219 | jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
220 | else
221 | jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
222 | fi
223 | while IFS="=" read key value; do
224 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
225 | esac
226 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
227 | if [ "$MVNW_VERBOSE" = true ]; then
228 | echo "Downloading from: $jarUrl"
229 | fi
230 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
231 | if $cygwin; then
232 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
233 | fi
234 |
235 | if command -v wget > /dev/null; then
236 | if [ "$MVNW_VERBOSE" = true ]; then
237 | echo "Found wget ... using wget"
238 | fi
239 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
240 | wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
241 | else
242 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
243 | fi
244 | elif command -v curl > /dev/null; then
245 | if [ "$MVNW_VERBOSE" = true ]; then
246 | echo "Found curl ... using curl"
247 | fi
248 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
249 | curl -o "$wrapperJarPath" "$jarUrl" -f
250 | else
251 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
252 | fi
253 |
254 | else
255 | if [ "$MVNW_VERBOSE" = true ]; then
256 | echo "Falling back to using Java to download"
257 | fi
258 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
259 | # For Cygwin, switch paths to Windows format before running javac
260 | if $cygwin; then
261 | javaClass=`cygpath --path --windows "$javaClass"`
262 | fi
263 | if [ -e "$javaClass" ]; then
264 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
265 | if [ "$MVNW_VERBOSE" = true ]; then
266 | echo " - Compiling MavenWrapperDownloader.java ..."
267 | fi
268 | # Compiling the Java class
269 | ("$JAVA_HOME/bin/javac" "$javaClass")
270 | fi
271 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
272 | # Running the downloader
273 | if [ "$MVNW_VERBOSE" = true ]; then
274 | echo " - Running MavenWrapperDownloader.java ..."
275 | fi
276 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
277 | fi
278 | fi
279 | fi
280 | fi
281 | ##########################################################################################
282 | # End of extension
283 | ##########################################################################################
284 |
285 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
286 | if [ "$MVNW_VERBOSE" = true ]; then
287 | echo $MAVEN_PROJECTBASEDIR
288 | fi
289 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
290 |
291 | # For Cygwin, switch paths to Windows format before running java
292 | if $cygwin; then
293 | [ -n "$M2_HOME" ] &&
294 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
295 | [ -n "$JAVA_HOME" ] &&
296 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
297 | [ -n "$CLASSPATH" ] &&
298 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
299 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
300 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
301 | fi
302 |
303 | # Provide a "standardized" way to retrieve the CLI args that will
304 | # work with both Windows and non-Windows executions.
305 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
306 | export MAVEN_CMD_LINE_ARGS
307 |
308 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
309 |
310 | exec "$JAVACMD" \
311 | $MAVEN_OPTS \
312 | $MAVEN_DEBUG_OPTS \
313 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
314 | "-Dmaven.home=${M2_HOME}" \
315 | "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
316 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
317 |
--------------------------------------------------------------------------------