mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-11 05:06:52 +00:00
### TL;DR
Reorganized booking service code and removed unused BookingRequest model
### What changed?
- Moved Payment model from payment.go to models.go
- Relocated payment-related service methods from service.go to payment.go
- Removed unused BookingRequest struct
- Updated dependencies to their latest versions
### How to test?
1. Run database migrations to verify removal of BookingRequest model
2. Test all payment-related endpoints to ensure functionality remains intact:
- GET /payments/{id}
- POST /payments
- PUT /payments/{id}
### Why make this change?
- Improves code organization by grouping payment-related code together
- Removes unused BookingRequest model to reduce technical debt
- Keeps dependencies up to date for security and performance improvements
34 lines
661 B
Go
34 lines
661 B
Go
package booking
|
|
|
|
import (
|
|
"log"
|
|
)
|
|
|
|
func (bs Service) OnePayment(id int) *Payment {
|
|
p, err := bs.store.GetPayment(id)
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
return p
|
|
}
|
|
|
|
func (bs Service) CreatePayment(bid int, amount float64, paymentMethod string) (*Payment, error) {
|
|
p, err := bs.store.CreatePayment(&Payment{
|
|
BookingID: uint(bid),
|
|
Amount: amount,
|
|
PaymentMethod: paymentMethod,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return p, nil
|
|
}
|
|
|
|
func (bs Service) UpdatePayment(id int, amount float64, paymentMethod string) *Payment {
|
|
p, err := bs.store.UpdatePayment(id, amount, paymentMethod)
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
return p
|
|
}
|