Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #1

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.demo.backend.product.Repositories;

import org.springframework.data.repository.CrudRepository;

import com.backend.product.model.Bookking;




public interface BookingRepository extends CrudRepository<Bookking,String> {





Bookking findAllById(String id);

void delete(String id);



}
83 changes: 83 additions & 0 deletions BackEnd/Spring Boot/src/main/java/product/model/Bookking.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.backend.product.model;

import java.time.LocalDateTime;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;


@Entity
@Table(name="Booking")

public class Bookking {

@Id
private Long id;

@Column
private LocalDateTime dt;


@Column(name="user_id")
private Long userId;

@Column(name="business_id")
private Long businessId;

public Long getBusinessId() {
return businessId;
}

public void setBusinessId(Long businessId) {
this.businessId = businessId;
}

@Column(name="service_type")
private String serviceType;



public Bookking() {}

public Bookking(Long id, Long userId, String serviceType) {
this.id = id;

this.userId = userId;
this.serviceType = serviceType;
}

public Long getId() {
return id;
}


public void setId(Long id) {
this.id = id;
}

public LocalDateTime getDt() {
return dt;
}

public void setDt(LocalDateTime dt) {
this.dt = dt;
}

public Long getUserId() {
return userId;
}

public void setUserId(Long userId) {
this.userId = userId;
}

public String getServiceType() {
return serviceType;
}

public void setService(String serviceType) {
this.serviceType = serviceType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.example.demo.backend.product.services;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.backend.product.model.Bookking;
import com.example.demo.backend.product.Repositories.BookingRepository;


@Service
public class BookingServices {


@Autowired
private static BookingRepository bookingRepository;


public static List getAllBookings() {

List Bookings = new ArrayList<>();
bookingRepository.findAll().forEach(Bookings::add);

return Bookings;
}


public static Bookking getBooking(String id) {
return bookingRepository.findAllById(id);

}


public static void addBooking(Bookking booking) {
bookingRepository.save(booking);
}


public static void updateBooking(Long id,Bookking booking) {
bookingRepository.save(booking);
}

public static void deleteBooking(String id) {
bookingRepository.delete(id);
}


public static void updateBooking(String id, Bookking booking) {
// TODO Auto-generated method stub

}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.example.demo.backend.product.api;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.backend.product.model.Bookking;
import com.example.demo.backend.product.services.BookingServices;

@RestController
@RequestMapping("/v1")

public class BookingController {

@RequestMapping(value = "/bookings", method = RequestMethod.GET)
public List getAllBookings() {

return BookingServices.getAllBookings();

}


@RequestMapping(value = "/bookings/{id}", method = RequestMethod.GET)
public Bookking getReservation(@PathVariable String id) {
return BookingServices.getBooking(id);
}


@Autowired
private Bookking BookingService;

@RequestMapping(value = "/bookings", method = RequestMethod.POST)
public void addBooking(@RequestBody Bookking booking) {
BookingServices.addBooking(booking);

}
@RequestMapping(value = "/bookings/{id}", method = RequestMethod.PUT)
public void updateBooking(@RequestBody Bookking booking,@PathVariable String id) {
BookingServices.updateBooking(id, booking);
}


@RequestMapping(value = "/bookings/{id}", method = RequestMethod.DELETE)
public void deleteReservation(@PathVariable String id) {
BookingServices.deleteBooking(id);
}

}