Skip to content
This repository was archived by the owner on Apr 14, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
bc3ac2b
vibrationAdded
piyushkumar12111111 Apr 1, 2024
bb439cd
hotelapiAdded
piyushkumar12111111 Apr 1, 2024
d556943
tripapiAdded
piyushkumar12111111 Apr 4, 2024
d5dfbde
populatapiintegrated
piyushkumar12111111 Apr 4, 2024
94d0de7
headerDynamic
piyushkumar12111111 Apr 4, 2024
fd9040d
citywiseCodeupdate
piyushkumar12111111 Apr 4, 2024
50182d1
bookingapiAdded
piyushkumar12111111 Apr 4, 2024
e6bcd84
bookingApiintegrated
piyushkumar12111111 Apr 4, 2024
05d778b
srinkwrapAdded
piyushkumar12111111 Apr 4, 2024
320ac1a
shimmerAdded
piyushkumar12111111 Apr 4, 2024
aedc2c4
profiledataupdated
piyushkumar12111111 Apr 4, 2024
358a1d5
editapiIntegrated
piyushkumar12111111 Apr 4, 2024
a7da73c
RazorpayIntegrated
piyushkumar12111111 Apr 4, 2024
f8cc1da
shimmerEffectAdded
piyushkumar12111111 Apr 5, 2024
0cb2dbf
notificationServiceAdded
piyushkumar12111111 Apr 5, 2024
2ed263b
notificationServiceUpdate
piyushkumar12111111 Apr 5, 2024
2329151
streambuilder added
piyushkumar12111111 Apr 6, 2024
69f3478
notificatonErrorResolved
piyushkumar12111111 Apr 6, 2024
f7e64a8
filterIntegrated
piyushkumar12111111 Apr 6, 2024
38eb983
serachapi
piyushkumar12111111 Apr 6, 2024
afc15be
searchApiUpdate
piyushkumar12111111 Apr 7, 2024
1e1ee02
Create README.md
piyushkumar12111111 Apr 7, 2024
2bcba69
websocket Implement
piyushkumar12111111 Apr 7, 2024
99b070f
Merge branch 'main' of https://github.com/piyushkumar12111111/FullSta…
piyushkumar12111111 Apr 7, 2024
fc881c8
Update README.md
piyushkumar12111111 Apr 8, 2024
ed63333
notificationupdate
piyushkumar12111111 Apr 9, 2024
6abaa82
permissionadded
piyushkumar12111111 Apr 9, 2024
cfbfc90
conflict
piyushkumar12111111 Apr 9, 2024
f0bc835
Livechating
piyushkumar12111111 Apr 9, 2024
0fa33bc
constRemoved
piyushkumar12111111 Apr 9, 2024
409420d
Update README.md
piyushkumar12111111 Apr 13, 2024
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
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"cSpell.words": [
"bottomnavbar"
]
],
"dart.enableCompletionCommitCharacters": true
}
4 changes: 3 additions & 1 deletion Backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
github.com/gobwas/glob v0.2.3 // indirect
github.com/gohugoio/hugo v0.124.1 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/hashstructure v1.1.0 // indirect
Expand All @@ -23,7 +24,8 @@ require (
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/tdewolff/parse/v2 v2.7.12 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
)
6 changes: 6 additions & 0 deletions Backend/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
Expand Down Expand Up @@ -93,6 +95,8 @@ golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -103,6 +107,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
Expand Down
29 changes: 29 additions & 0 deletions Backend/handlers/bookinghandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package handlers

import (
"encoding/json"
"net/http"

"github.com/piyushkumar/hotelsystem/models"
)

// GetBookings returns the list of bookings
func GetBookings(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(models.Bookings)
}



func CreateBooking(w http.ResponseWriter, r *http.Request) {
var newBooking models.Booking
err := json.NewDecoder(r.Body).Decode(&newBooking)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}

models.Bookings = append(models.Bookings, newBooking)
w.WriteHeader(http.StatusCreated)
json.NewEncoder(w).Encode(newBooking)
}
23 changes: 23 additions & 0 deletions Backend/handlers/cityHotelHandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package handlers

import (
"encoding/json"
"net/http"

"github.com/gorilla/mux"
"github.com/piyushkumar/hotelsystem/models"
)

func GetHotelsByCity(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
city := vars["city"]

hotels, ok := models.Cities[city]
if !ok {
http.Error(w, "City not found", http.StatusNotFound)
return
}

w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(hotels)
}
17 changes: 17 additions & 0 deletions Backend/handlers/getprofileHandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package handlers

import (
"encoding/json"
"net/http"

"github.com/piyushkumar/hotelsystem/models"
)

// For simplicity, we're using a package-level variable. In a real application, this could be a database.
var userProfile = models.Profile{}

// GetProfile sends the user's profile as a JSON response.
func GetProfile(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(userProfile)
}
68 changes: 67 additions & 1 deletion Backend/handlers/listhotelHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package handlers

import (
"encoding/json"
"log"
"net/http"

"github.com/piyushkumar/hotelsystem/models"
Expand All @@ -11,10 +12,75 @@ import (
var hotels = []models.Hotel{
{ID: "1", Name: "Hotel Sunshine", Location: "California", Rating: 5},
{ID: "2", Name: "Grand Plaza", Location: "New York", Rating: 4},
{ID: "3", Name: "Hyat Plaza", Location: "Australia", Rating: 3},
{ID: "4", Name: "Grinding Plaza", Location: "Hamburg", Rating: 2},
}


var recommendHotels = []models.ReccHotel{

{ID: "1", Name: "Hotel Ramuplaz", Location: "California", Distance: 5, Rating: 5},
{ID: "2", Name: "Plaza", Location: "New York", Distance: 4, Rating: 4},
{ID: "3", Name: "Huluk Plaza", Location: "Australia", Distance: 3, Rating: 3},
{ID: "4", Name: "Indus Plaza", Location: "Hamburg", Distance: 2, Rating: 2},


}

var popullarHotels = []models.PopHotel{

{Name: "Hotel Oceana", Location: "California", Distance: 5, Price: 5000, Rating: 5},
{Name: "Placo", Location: "New York", Distance: 4, Price: 4000, Rating: 4},
{Name: "Pizza Put Plaza", Location: "Australia", Distance: 3, Price: 3000, Rating: 3},
{Name: "PakLand Plaza", Location: "Hamburg", Distance: 2, Price: 2000, Rating: 2},


}

// ListHotels sends a list of hotels as a JSON response.
func ListHotels(w http.ResponseWriter, r *http.Request) {
func WishListHotels(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(hotels)
}

func RecommendHotels(w http.ResponseWriter, r *http.Request) {
log.Println("RecommendHotels handler called")
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(recommendHotels)
}

func PopHotels(w http.ResponseWriter, r *http.Request) {
log.Println("PopHotels handler called")
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(popullarHotels)
}

//! handler for searching hotels by name

func SearchHotels(w http.ResponseWriter, r *http.Request) {
log.Println("SearchHotels handler called")
w.Header().Set("Content-Type", "application/json")
var searchResults []models.Hotel
query := r.URL.Query().Get("name")
for _, hotel := range hotels {
if hotel.Name == query {
searchResults = append(searchResults, hotel)
}
}
json.NewEncoder(w).Encode(searchResults)
}

//! handler for searching hotels by location

func SearchHotelsByLocation(w http.ResponseWriter, r *http.Request) {
log.Println("SearchHotelsByLocation handler called")
w.Header().Set("Content-Type", "application/json")
var searchResults []models.Hotel
query := r.URL.Query().Get("location")
for _, hotel := range hotels {
if hotel.Location == query {
searchResults = append(searchResults, hotel)
}
}
json.NewEncoder(w).Encode(searchResults)
}
26 changes: 26 additions & 0 deletions Backend/handlers/liveChatHandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package handlers

import (
"github.com/piyushkumar/hotelsystem/websocket"
"net/http"
)

type ChatHandler struct {
hub *websocket.Hub
}

func NewChatHandler() *ChatHandler {
hub := websocket.NewHub()
go hub.Run()
return &ChatHandler{hub: hub}
}

func (c *ChatHandler) HandleConnections(w http.ResponseWriter, r *http.Request) {
websocket.ServeWs(c.hub, w, r)
}

func (c *ChatHandler) HandleMessages() {
// Here you would handle incoming messages. This example doesn't implement it.


}
19 changes: 19 additions & 0 deletions Backend/handlers/popHandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package handlers

import (
"encoding/json"
"net/http"

"github.com/piyushkumar/hotelsystem/models"
)

// GetPopularHotels handles the request for retrieving popular hotels
func GetPopularHotels(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
popularHotels := []models.PopHotels{
{"Hotel California", "Los Angeles", 5.0},
{"The Great Northern", "Twin Peaks", 15.0},
{"The Overlook Hotel", "Colorado Rockies", 20.0},
}
json.NewEncoder(w).Encode(popularHotels)
}
32 changes: 32 additions & 0 deletions Backend/handlers/searchHandlers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package handlers

// import (
// "encoding/json"
// "net/http"

// "github.com/gorilla/mux"
// "github.com/piyushkumar/hotelsystem/models"

// )

// func findHotelHandler(w http.ResponseWriter, r *http.Request) {



// vars := mux.Vars(r)

// city := vars["city"]
// bedroom := vars["bedroom"]
// bathroom := vars["bathroom"]
// services := vars["services"]
// payment := vars["payment"]

// for _, hotel := range models.SearchHotel {
// if hotel. == city && hotel.Bedrooms == bedroom && hotel.Bathrooms == bathroom && hotel.Service == services && hotel.Payment == payment {
// json.NewEncoder(w).Encode(hotel)
// return
// }
// }
// }

// SearchHotels handler function
23 changes: 23 additions & 0 deletions Backend/handlers/setprofileHandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package handlers

import (
"encoding/json"
"net/http"

"github.com/piyushkumar/hotelsystem/models"
)

// SetProfile updates the user's profile.
func SetProfile(w http.ResponseWriter, r *http.Request) {
var profile models.Profile
if err := json.NewDecoder(r.Body).Decode(&profile); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}

// Update the global userProfile variable with the new data
userProfile = profile

w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(profile)
}
19 changes: 19 additions & 0 deletions Backend/handlers/tripHandlers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package handlers

import (
"encoding/json"
"net/http"

"github.com/piyushkumar/hotelsystem/models"
)

// GetPlaces displays all the places
func GetPlaces(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
places := []models.Place{
{"Paris", 3000.0, 4.5, 200.0},
{"Bali", 12000.0, 4.8, 150.0},
{"Tokyo", 8000.0, 4.6, 300.0},
}
json.NewEncoder(w).Encode(places)
}
39 changes: 35 additions & 4 deletions Backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,54 @@ func main() {
//! Register the OTP checking handler
r.HandleFunc("/checkotp", handlers.CheckOTP).Methods("POST")



//! Forgot password route
r.HandleFunc("/forgot-password", handlers.ForgotPassword).Methods("POST")

log.Println("Server starting on port 9080...")

//! hotel apis
//! hotel apis

r.HandleFunc("/hotels", handlers.WishListHotels).Methods("GET")
r.HandleFunc("/rechotels", handlers.RecommendHotels).Methods("GET")
r.HandleFunc("/pophotels", handlers.PopHotels).Methods("GET")

r.HandleFunc("/hotels", handlers.ListHotels).Methods("GET")
r.HandleFunc("/hotel", handlers.AddHotel).Methods("POST")
r.HandleFunc("/hotel/{id}", handlers.DeleteHotel).Methods("DELETE")

// Start the server

//! trip routes

r.HandleFunc("/places", handlers.GetPlaces).Methods("GET")
r.HandleFunc("/popularhotels", handlers.GetPopularHotels).Methods("GET")

//! hotel by city
r.HandleFunc("/city/{city}", handlers.GetHotelsByCity).Methods("GET")

//! profile routes

r.HandleFunc("/profile", handlers.GetProfile).Methods("GET")
r.HandleFunc("/profile", handlers.SetProfile).Methods("POST")

//! search hotels by name
r.HandleFunc("/search", handlers.SearchHotels).Methods("GET")





//! booking apis

r.HandleFunc("/bookings", handlers.GetBookings).Methods("GET")
r.HandleFunc("/booking", handlers.CreateBooking).Methods("POST")

//! live chat api
r.HandleFunc("/chat", handlers.NewChatHandler().HandleConnections).Methods("GET")

log.Fatal(http.ListenAndServe(":9080", r))
//log.Fatal(http.ListenAndServe(":8080", r))
}
//! frontend port is 9080

// package main

Expand Down
Loading