refactoring fmt + moving utils

This commit is contained in:
sbouaram 2023-10-20 13:47:51 +02:00
parent 6696cd3152
commit b7bba4cdaa
25 changed files with 71 additions and 91 deletions

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/solidarity-service.iml" filepath="$PROJECT_DIR$/.idea/solidarity-service.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -3,7 +3,7 @@ package handler
import (
"github.com/paulmach/orb"
"github.com/paulmach/orb/geojson"
"solidarity-service/servers/utils"
"solidarity-service/utils"
)
func (handler *SolidarityServiceHandler) CalculateDistanceBetweenFeatures(feature1, feature2 *geojson.Feature) int64 {

View File

@ -15,7 +15,7 @@ import (
// Response return a ImplResponse struct filled
func Response(code int, body interface{}) ImplResponse {
return ImplResponse {
return ImplResponse{
Code: code,
Body: body,
}

View File

@ -9,11 +9,7 @@
package openapi
type PassengerPost400Response struct {
Error string `json:"error,omitempty"`
}

View File

@ -9,9 +9,6 @@
package openapi
type BookingRequest struct {
// Booking id is common between both operators, and must be created as a [UUID](https://datatracker.ietf.org/doc/html/rfc4122) by whoever initiates the booking. Usage of a [4 UUID](https://datatracker.ietf.org/doc/html/rfc4122#section-4.4) generation algorithm is advised.
@ -29,11 +26,11 @@ type BookingRequest struct {
// AssertBookingRequestRequired checks if the required fields are not zero-ed
func AssertBookingRequestRequired(obj BookingRequest) error {
elements := map[string]interface{}{
"id": obj.Id,
"id": obj.Id,
"passengerId": obj.PassengerId,
"driverId": obj.DriverId,
"status": obj.Status,
"operator": obj.Operator,
"driverId": obj.DriverId,
"status": obj.Status,
"operator": obj.Operator,
}
for name, el := range elements {
if isZero := IsZeroValue(el); isZero {

View File

@ -9,19 +9,17 @@
package openapi
// BookingStatus : Status of the booking.
type BookingStatus string
// List of BookingStatus
const (
WAITING_DRIVER_CONFIRMATION BookingStatus = "WAITING_DRIVER_CONFIRMATION"
WAITING_DRIVER_CONFIRMATION BookingStatus = "WAITING_DRIVER_CONFIRMATION"
WAITING_PASSENGER_CONFIRMATION BookingStatus = "WAITING_PASSENGER_CONFIRMATION"
CONFIRMED BookingStatus = "CONFIRMED"
CANCELLED BookingStatus = "CANCELLED"
COMPLETED_PENDING_VALIDATION BookingStatus = "COMPLETED_PENDING_VALIDATION"
VALIDATED BookingStatus = "VALIDATED"
CONFIRMED BookingStatus = "CONFIRMED"
CANCELLED BookingStatus = "CANCELLED"
COMPLETED_PENDING_VALIDATION BookingStatus = "COMPLETED_PENDING_VALIDATION"
VALIDATED BookingStatus = "VALIDATED"
)
// AssertBookingStatusRequired checks if the required fields are not zero-ed

View File

@ -9,9 +9,6 @@
package openapi
type Car struct {
// Model of the car.

View File

@ -9,9 +9,6 @@
package openapi
type DriverPunctualAvailabilitiesRequest struct {
// The address or location description.
@ -38,12 +35,12 @@ type DriverPunctualAvailabilitiesRequest struct {
// AssertDriverPunctualAvailabilitiesRequestRequired checks if the required fields are not zero-ed
func AssertDriverPunctualAvailabilitiesRequestRequired(obj DriverPunctualAvailabilitiesRequest) error {
elements := map[string]interface{}{
"address": obj.Address,
"latitude": obj.Latitude,
"longitude": obj.Longitude,
"radius": obj.Radius,
"address": obj.Address,
"latitude": obj.Latitude,
"longitude": obj.Longitude,
"radius": obj.Radius,
"availabilities": obj.Availabilities,
"user": obj.User,
"user": obj.User,
}
for name, el := range elements {
if isZero := IsZeroValue(el); isZero {

View File

@ -9,9 +9,6 @@
package openapi
type DriverRegularAvailabilitiesRequest struct {
// The address or location description.
@ -38,12 +35,12 @@ type DriverRegularAvailabilitiesRequest struct {
// AssertDriverRegularAvailabilitiesRequestRequired checks if the required fields are not zero-ed
func AssertDriverRegularAvailabilitiesRequestRequired(obj DriverRegularAvailabilitiesRequest) error {
elements := map[string]interface{}{
"address": obj.Address,
"latitude": obj.Latitude,
"longitude": obj.Longitude,
"radius": obj.Radius,
"address": obj.Address,
"latitude": obj.Latitude,
"longitude": obj.Longitude,
"radius": obj.Radius,
"availabilities": obj.Availabilities,
"user": obj.User,
"user": obj.User,
}
for name, el := range elements {
if isZero := IsZeroValue(el); isZero {

View File

@ -9,11 +9,7 @@
package openapi
type DriverTrip struct {
User User `json:"user"`
Car Car `json:"car,omitempty"`

View File

@ -9,9 +9,6 @@
package openapi
type GetBookings404Response struct {
// Explain why the request couldn't be processed.

View File

@ -9,9 +9,6 @@
package openapi
type JourneySchedule struct {
// Passenger pickup datetime as a UNIX UTC timestamp in seconds.
@ -28,7 +25,7 @@ type JourneySchedule struct {
func AssertJourneyScheduleRequired(obj JourneySchedule) error {
elements := map[string]interface{}{
"passengerPickupDate": obj.PassengerPickupDate,
"type": obj.Type,
"type": obj.Type,
}
for name, el := range elements {
if isZero := IsZeroValue(el); isZero {

View File

@ -9,11 +9,7 @@
package openapi
type PassengerTripRequest struct {
User User `json:"user"`
DestinationAddress string `json:"destination_address"`
@ -37,14 +33,14 @@ type PassengerTripRequest struct {
// AssertPassengerTripRequestRequired checks if the required fields are not zero-ed
func AssertPassengerTripRequestRequired(obj PassengerTripRequest) error {
elements := map[string]interface{}{
"user": obj.User,
"destination_address": obj.DestinationAddress,
"destination_latitude": obj.DestinationLatitude,
"user": obj.User,
"destination_address": obj.DestinationAddress,
"destination_latitude": obj.DestinationLatitude,
"destination_longitude": obj.DestinationLongitude,
"departure_address": obj.DepartureAddress,
"departure_latitude": obj.DepartureLatitude,
"departure_longitude": obj.DepartureLongitude,
"departure_date": obj.DepartureDate,
"departure_address": obj.DepartureAddress,
"departure_latitude": obj.DepartureLatitude,
"departure_longitude": obj.DepartureLongitude,
"departure_date": obj.DepartureDate,
}
for name, el := range elements {
if isZero := IsZeroValue(el); isZero {

View File

@ -9,11 +9,7 @@
package openapi
type PostConnectionsRequest struct {
From User `json:"from"`
To User `json:"to"`
@ -37,9 +33,9 @@ type PostConnectionsRequest struct {
// AssertPostConnectionsRequestRequired checks if the required fields are not zero-ed
func AssertPostConnectionsRequestRequired(obj PostConnectionsRequest) error {
elements := map[string]interface{}{
"from": obj.From,
"to": obj.To,
"message": obj.Message,
"from": obj.From,
"to": obj.To,
"message": obj.Message,
"recipientCarpoolerType": obj.RecipientCarpoolerType,
}
for name, el := range elements {

View File

@ -9,13 +9,10 @@
package openapi
import (
"errors"
)
type Preferences struct {
// If driver journey, specifies if the driver allows smoking in the car.

View File

@ -9,9 +9,6 @@
package openapi
type Price struct {
// Either « FREE », « PAYING » or « UNKNOWN ». « UNKNOWN » is given when it should be « PAYING » but we cannot set the price yet.

View File

@ -9,9 +9,6 @@
package openapi
type PunctualAvailabilitySlot struct {
// UNIX UTC timestamp in seconds.
@ -27,9 +24,9 @@ type PunctualAvailabilitySlot struct {
// AssertPunctualAvailabilitySlotRequired checks if the required fields are not zero-ed
func AssertPunctualAvailabilitySlotRequired(obj PunctualAvailabilitySlot) error {
elements := map[string]interface{}{
"date": obj.Date,
"date": obj.Date,
"startTime": obj.StartTime,
"endTime": obj.EndTime,
"endTime": obj.EndTime,
}
for name, el := range elements {
if isZero := IsZeroValue(el); isZero {

View File

@ -9,9 +9,6 @@
package openapi
type RegularAvailabilitySlot struct {
// Day of the week for regular scheduling.
@ -29,7 +26,7 @@ func AssertRegularAvailabilitySlotRequired(obj RegularAvailabilitySlot) error {
elements := map[string]interface{}{
"dayOfWeek": obj.DayOfWeek,
"startTime": obj.StartTime,
"endTime": obj.EndTime,
"endTime": obj.EndTime,
}
for name, el := range elements {
if isZero := IsZeroValue(el); isZero {

View File

@ -9,13 +9,10 @@
package openapi
import (
"errors"
)
type User struct {
// User's identifier. It MUST be unique for a given `operator`.
@ -49,9 +46,9 @@ type User struct {
// AssertUserRequired checks if the required fields are not zero-ed
func AssertUserRequired(obj User) error {
elements := map[string]interface{}{
"id": obj.Id,
"id": obj.Id,
"operator": obj.Operator,
"alias": obj.Alias,
"alias": obj.Alias,
}
for name, el := range elements {
if isZero := IsZeroValue(el); isZero {

View File

@ -23,8 +23,8 @@ import (
// A Route defines the parameters for an api endpoint
type Route struct {
Method string
Pattern string
Method string
Pattern string
HandlerFunc http.HandlerFunc
}

View File

@ -12,7 +12,7 @@ import (
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
"solidarity-service/internal"
"solidarity-service/servers/utils"
"solidarity-service/utils"
"strconv"
"strings"
"time"