list silvermobiBooking by silvermobiUsers
This commit is contained in:
parent
5a89c8b24a
commit
0cfa78e938
|
@ -30,8 +30,10 @@ import (
|
||||||
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||||
solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
|
solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
|
||||||
|
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
"google.golang.org/protobuf/types/known/emptypb"
|
||||||
"google.golang.org/protobuf/types/known/structpb"
|
"google.golang.org/protobuf/types/known/structpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -118,9 +120,17 @@ func (h *ApplicationHandler) BeneficiariesList(w http.ResponseWriter, r *http.Re
|
||||||
|
|
||||||
sort.Sort(sorting.BeneficiariesByName(accounts))
|
sort.Sort(sorting.BeneficiariesByName(accounts))
|
||||||
|
|
||||||
|
accountssolidarity, err := h.services.GRPC.SolidarityService.GetAllPassengers(context.TODO(), &emptypb.Empty{})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
cacheid := uuid.NewString()
|
cacheid := uuid.NewString()
|
||||||
|
h.cache.PutWithTTL(cacheid, accountssolidarity, 1*time.Hour)
|
||||||
h.cache.PutWithTTL(cacheid, accounts, 1*time.Hour)
|
h.cache.PutWithTTL(cacheid, accounts, 1*time.Hour)
|
||||||
h.Renderer.BeneficiariesList(w, r, accounts, cacheid)
|
h.Renderer.BeneficiariesList(w, r, accounts,accountssolidarity, cacheid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ApplicationHandler) BeneficiaryCreate(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) BeneficiaryCreate(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -327,6 +337,39 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
||||||
organizations = append(organizations, o.ToStorageType())
|
organizations = append(organizations, o.ToStorageType())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beneficiaries_file_types := h.config.GetStringSlice("modules.beneficiaries.documents_types")
|
||||||
|
file_types_map := h.config.GetStringMapString("storage.files.file_types")
|
||||||
|
|
||||||
|
h.Renderer.BeneficiaryDisplay(w, r, resp.Account.ToStorageType(), bookings, organizations, beneficiaries_file_types, file_types_map, documents, events_list)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *ApplicationHandler) BeneficiarySolidarityDisplay(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
accounts, err := h.beneficiaries(r)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Sort(sorting.BeneficiariesByName(accounts))
|
||||||
|
|
||||||
|
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
beneficiaryID := vars["beneficiaryid"]
|
||||||
|
|
||||||
|
passenger := solidarity_service.GetPassengerRequest{
|
||||||
|
Passenger: &solidarity_service.User{
|
||||||
|
Id: beneficiaryID,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
accountssolidarity, err := h.services.GRPC.SolidarityService.GetPassenger(context.TODO(), &passenger)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
solidarity_booking := &solidarity_service.GetBookingsByStatusRequest{
|
solidarity_booking := &solidarity_service.GetBookingsByStatusRequest{
|
||||||
Status : 0, /// 0 : pending
|
Status : 0, /// 0 : pending
|
||||||
|
@ -342,10 +385,13 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
beneficiaries_file_types := h.config.GetStringSlice("modules.beneficiaries.documents_types")
|
cacheid := uuid.NewString()
|
||||||
file_types_map := h.config.GetStringMapString("storage.files.file_types")
|
h.cache.PutWithTTL(cacheid, accounts, 1*time.Hour)
|
||||||
|
h.cache.PutWithTTL(cacheid, solidarity_bookings_list, 1*time.Hour)
|
||||||
|
|
||||||
|
|
||||||
|
h.Renderer.BeneficiarySolidarityDisplay(w, r ,accounts, accountssolidarity , solidarity_bookings_list, cacheid)
|
||||||
|
|
||||||
h.Renderer.BeneficiaryDisplay(w, r, resp.Account.ToStorageType(), bookings, organizations, beneficiaries_file_types, file_types_map, documents, events_list, solidarity_bookings_list)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ApplicationHandler) BeneficiaryUpdate(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) BeneficiaryUpdate(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
@ -132,8 +132,6 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
|
||||||
BookingData.bookingData.Booking.DriverId = driverId
|
BookingData.bookingData.Booking.DriverId = driverId
|
||||||
BookingData.bookingData.Booking.Id = id
|
BookingData.bookingData.Booking.Id = id
|
||||||
|
|
||||||
fmt.Println(BookingData.bookingData, "booking")
|
|
||||||
|
|
||||||
booking, err := h.services.GRPC.SolidarityService.CreateBookingSolidarity(context.TODO(), &BookingData.bookingData)
|
booking, err := h.services.GRPC.SolidarityService.CreateBookingSolidarity(context.TODO(), &BookingData.bookingData)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
2
main.go
2
main.go
|
@ -139,6 +139,8 @@ func main() {
|
||||||
|
|
||||||
//=================================silvermobi====================================
|
//=================================silvermobi====================================
|
||||||
application.HandleFunc("/solidarity_service/", applicationHandler.DriversJourney)
|
application.HandleFunc("/solidarity_service/", applicationHandler.DriversJourney)
|
||||||
|
application.HandleFunc("/beneficiaries/solidarity_service/{beneficiaryid}", applicationHandler.BeneficiarySolidarityDisplay)
|
||||||
|
|
||||||
|
|
||||||
appGroup := application.PathPrefix("/group_module").Subrouter()
|
appGroup := application.PathPrefix("/group_module").Subrouter()
|
||||||
appGroup.HandleFunc("/", applicationHandler.Groups)
|
appGroup.HandleFunc("/", applicationHandler.Groups)
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
fleetsstorage "git.coopgo.io/coopgo-platform/fleets/storage"
|
fleetsstorage "git.coopgo.io/coopgo-platform/fleets/storage"
|
||||||
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||||
|
solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,6 +17,16 @@ type BeneficiariesListState struct {
|
||||||
Count int `json:"count"`
|
Count int `json:"count"`
|
||||||
CacheId string `json:"cache_id"`
|
CacheId string `json:"cache_id"`
|
||||||
Beneficiaries []mobilityaccountsstorage.Account `json:"beneficiaries"`
|
Beneficiaries []mobilityaccountsstorage.Account `json:"beneficiaries"`
|
||||||
|
BeneficiariesSolidarity *solidarity_service.GetAllPassengersResponse `json:"beneficiariessolidarity"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type BeneficiarySolidarityState struct {
|
||||||
|
Count int `json:"count"`
|
||||||
|
CacheId string `json:"cache_id"`
|
||||||
|
Beneficiaries []mobilityaccountsstorage.Account `json:"beneficiaries"`
|
||||||
|
BeneficiarySolidarity *solidarity_service.GetPassengerResponse `json:"beneficiarysolidarity"`
|
||||||
|
BookingSolidarity *solidarity_service.GetBookingsByStatusResponse `json:"bookingsolidarity"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s BeneficiariesListState) JSON() template.JS {
|
func (s BeneficiariesListState) JSON() template.JS {
|
||||||
|
@ -30,7 +41,19 @@ func (s BeneficiariesListState) JSONWithLimits(a int, b int) template.JS {
|
||||||
return s.JSON()
|
return s.JSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (renderer *Renderer) BeneficiariesList(w http.ResponseWriter, r *http.Request, accounts []mobilityaccountsstorage.Account, cacheid string) {
|
func (s BeneficiarySolidarityState) JSON() template.JS {
|
||||||
|
result, _ := json.Marshal(s)
|
||||||
|
return template.JS(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s BeneficiarySolidarityState) JSONWithLimits(a int, b int) template.JS {
|
||||||
|
if b < 5 {
|
||||||
|
s.Beneficiaries = s.Beneficiaries[a:b]
|
||||||
|
}
|
||||||
|
return s.JSON()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (renderer *Renderer) BeneficiariesList(w http.ResponseWriter, r *http.Request, accounts []mobilityaccountsstorage.Account, accountssolidarity *solidarity_service.GetAllPassengersResponse, cacheid string) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.beneficiaries.list.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.beneficiaries.list.files")
|
||||||
|
|
||||||
state := NewState(r, renderer.ThemeConfig, beneficiariesMenu)
|
state := NewState(r, renderer.ThemeConfig, beneficiariesMenu)
|
||||||
|
@ -38,6 +61,7 @@ func (renderer *Renderer) BeneficiariesList(w http.ResponseWriter, r *http.Reque
|
||||||
Count: len(accounts),
|
Count: len(accounts),
|
||||||
CacheId: cacheid,
|
CacheId: cacheid,
|
||||||
Beneficiaries: accounts,
|
Beneficiaries: accounts,
|
||||||
|
BeneficiariesSolidarity : accountssolidarity,
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.Render("beneficiaries_list", w, r, files, state)
|
renderer.Render("beneficiaries_list", w, r, files, state)
|
||||||
|
@ -54,7 +78,7 @@ type BeneficiariesDisplayState struct {
|
||||||
Beneficiary any
|
Beneficiary any
|
||||||
}
|
}
|
||||||
|
|
||||||
func (renderer *Renderer) BeneficiaryDisplay(w http.ResponseWriter, r *http.Request, beneficiary any, bookings []fleetsstorage.Booking, organizations []any, beneficiaries_file_types []string, file_types_map map[string]string, documents any, event interface{}, solidarity_bookings_list interface{}) {
|
func (renderer *Renderer) BeneficiaryDisplay(w http.ResponseWriter, r *http.Request, beneficiary any, bookings []fleetsstorage.Booking, organizations []any, beneficiaries_file_types []string, file_types_map map[string]string, documents any, event interface{}) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.beneficiaries.display.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.beneficiaries.display.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, beneficiariesMenu)
|
state := NewState(r, renderer.ThemeConfig, beneficiariesMenu)
|
||||||
state.ViewState = map[string]any{
|
state.ViewState = map[string]any{
|
||||||
|
@ -65,7 +89,20 @@ func (renderer *Renderer) BeneficiaryDisplay(w http.ResponseWriter, r *http.Requ
|
||||||
"documents": documents,
|
"documents": documents,
|
||||||
"organizations": organizations,
|
"organizations": organizations,
|
||||||
"event": event,
|
"event": event,
|
||||||
"solidarity_bookings": solidarity_bookings_list,
|
}
|
||||||
|
renderer.Render("beneficiaries_display", w, r, files, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (renderer *Renderer) BeneficiarySolidarityDisplay(w http.ResponseWriter, r *http.Request, accounts []mobilityaccountsstorage.Account, beneficiary *solidarity_service.GetPassengerResponse, solidarity_bookings_list *solidarity_service.GetBookingsByStatusResponse, cacheid string) {
|
||||||
|
files := renderer.ThemeConfig.GetStringSlice("views.beneficiaries.display.files")
|
||||||
|
state := NewState(r, renderer.ThemeConfig, beneficiariesMenu)
|
||||||
|
state.ViewState = BeneficiarySolidarityState{
|
||||||
|
Count : len(accounts),
|
||||||
|
CacheId : cacheid,
|
||||||
|
Beneficiaries: accounts,
|
||||||
|
BeneficiarySolidarity : beneficiary,
|
||||||
|
BookingSolidarity : solidarity_bookings_list,
|
||||||
|
|
||||||
}
|
}
|
||||||
renderer.Render("beneficiaries_display", w, r, files, state)
|
renderer.Render("beneficiaries_display", w, r, files, state)
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,18 @@ func (s SolidarityListState) JSONWithLimits(a int, b int) template.JS {
|
||||||
return s.JSON()
|
return s.JSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s SolidarityBookingsState) JSON() template.JS {
|
||||||
|
result, _ := json.Marshal(s)
|
||||||
|
return template.JS(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s SolidarityBookingsState) JSONWithLimits(a int, b int) template.JS {
|
||||||
|
if b < 5 {
|
||||||
|
s.Beneficiaries = s.Beneficiaries[a:b]
|
||||||
|
}
|
||||||
|
return s.JSON()
|
||||||
|
}
|
||||||
|
|
||||||
func (renderer *Renderer) SolidarityService(w http.ResponseWriter, r *http.Request, accounts *solidarity_service.GetAllPassengersResponse, parcourmobAccounts []mobilityaccountsstorage.Account, cacheid string) {
|
func (renderer *Renderer) SolidarityService(w http.ResponseWriter, r *http.Request, accounts *solidarity_service.GetAllPassengersResponse, parcourmobAccounts []mobilityaccountsstorage.Account, cacheid string) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
||||||
|
|
Loading…
Reference in New Issue