mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 07:15:43 +00:00
fix length type varchar for purchase vehicle_number
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
commonRepo "gitlab.com/mbugroup/lti-api.git/internal/common/repository"
|
||||
commonSvc "gitlab.com/mbugroup/lti-api.git/internal/common/service"
|
||||
@@ -46,7 +47,8 @@ type PurchaseService interface {
|
||||
}
|
||||
|
||||
const (
|
||||
priceTolerance = 0.0001
|
||||
priceTolerance = 0.0001
|
||||
purchaseVehicleNumberMaxLength = 15
|
||||
)
|
||||
|
||||
type purchaseService struct {
|
||||
@@ -1158,6 +1160,15 @@ func (s *purchaseService) ReceiveProducts(c *fiber.Ctx, id uint, req *validation
|
||||
if payload.VehicleNumber != nil {
|
||||
val := strings.TrimSpace(*payload.VehicleNumber)
|
||||
if val != "" {
|
||||
if utf8.RuneCountInString(val) > purchaseVehicleNumberMaxLength {
|
||||
return nil, utils.BadRequest(
|
||||
fmt.Sprintf(
|
||||
"vehicle_number for item %d must be at most %d characters",
|
||||
payload.PurchaseItemID,
|
||||
purchaseVehicleNumberMaxLength,
|
||||
),
|
||||
)
|
||||
}
|
||||
vehicleNumber = &val
|
||||
} else {
|
||||
clearVehicle = true
|
||||
|
||||
Reference in New Issue
Block a user