forked from kuznetsovin/go_tachograph_card
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidation.go
77 lines (58 loc) · 2.3 KB
/
validation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"time"
)
// проверка на пустую запись об использовании ТС
func VehicleRecordIsEmpty(vr *сardVehicleRecord) bool {
var result bool
result = vr.VehicleFirstUse == time.Unix(0, 0).UTC()
result = result && vr.VehicleLastUse == time.Unix(0, 0).UTC()
result = result && vr.VehicleOdometerBegin == 0
result = result && vr.VehicleOdometerEnd == 0
return result
}
// проверка на пустую запись о неисправности
func FaultRecordIsEmpty(fault *cardFaultRecord) bool {
var result bool
result = fault.FaultBeginTime == time.Unix(0, 0).UTC()
result = result && fault.FaultEndTime == time.Unix(0, 0).UTC()
result = result && fault.FaultTypeId == 0
return result
}
// проверка на пустую запись о событии
func EventRecordIsEmpty(event *cardEventRecord) bool {
var result bool
result = event.EventBeginTime == time.Unix(0, 0).UTC()
result = result && event.EventEndTime == time.Unix(0, 0).UTC()
result = result && event.EventTypeId == 0
return result
}
// проверка на пустую запись о месте
func PlaceRecordIsEmpty(place *placeRecord) bool {
var result bool
result = place.EntryTime == time.Unix(0, 0).UTC()
result = result && place.DailyWorkPeriodCountry == 0
result = result && place.DailyWorkPeriodRegion == 0
result = result && place.TypePeriodId == 0
result = result && place.VehicleOdometerValue == 0
return result
}
// проверка на пустую запись о специальных условиях
func SpecificConditionIsEmpty(sc *specificConditionRecord) bool {
var result bool
result = sc.EntryTime == time.Unix(0, 0).UTC()
result = result && sc.SpecificConditionTypeId == 0
return result
}
// проверка на пустую запись о контроле
func ControlActivityDataIsEmpty(cad *cardControlActivityDataRecord) bool {
var result bool
result = cad.ControlTypeId == 0
result = result && cad.ControlTime == time.Unix(0, 0).UTC()
result = result && cad.CardTypeId == 0
result = result && cad.CardIssuingMemberState == 0
result = result && cad.ControlCardNumber == ""
result = result && cad.ControlDownloadPeriodBegin == time.Unix(0, 0).UTC()
result = result && cad.ControlDownloadPeriodEnd == time.Unix(0, 0).UTC()
return result
}