refactor: Rename AFTN struct field from "Text" to "Body"
The code changes rename the "Text" field in the AFTN struct to "Body" to improve clarity and consistency. This change aligns with the naming convention used in other parts of the codebase and enhances code readability.
This commit is contained in:
@@ -11,7 +11,7 @@ type AFTN struct {
|
||||
Header Header `json:"header"` // 报文头部信息
|
||||
PriorityAndSender PriorityAndSender `json:"priority_and_sender"` // 优先级和发送地址信息
|
||||
TimeAndReceiver TimeAndReceiver `json:"time_and_receiver"` // 时间和接收地址信息
|
||||
Text string `json:"text"` // 报文内容
|
||||
Body string `json:"body"` // 报文内容
|
||||
ReceivedTime time.Time `json:"received_time"` // 收报时间,表示电报接收到的时间
|
||||
Category string `json:"category"`
|
||||
BodyData interface{} `json:"body_data"`
|
||||
|
||||
@@ -26,7 +26,7 @@ var _ = Describe("AFTN", func() {
|
||||
Time: "151524",
|
||||
Receiver: "ZGGGZPZX",
|
||||
},
|
||||
Text: "Test message",
|
||||
Body: "Test message",
|
||||
ReceivedTime: time.Now(),
|
||||
Category: "Test",
|
||||
BodyData: nil,
|
||||
@@ -45,7 +45,7 @@ var _ = Describe("AFTN", func() {
|
||||
Expect(unmarshalled.Header).To(Equal(original.Header))
|
||||
Expect(unmarshalled.PriorityAndSender).To(Equal(original.PriorityAndSender))
|
||||
Expect(unmarshalled.TimeAndReceiver).To(Equal(original.TimeAndReceiver))
|
||||
Expect(unmarshalled.Text).To(Equal(original.Text))
|
||||
Expect(unmarshalled.Body).To(Equal(original.Body))
|
||||
Expect(unmarshalled.Category).To(Equal(original.Category))
|
||||
})
|
||||
})
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"caatsm/pkg/utils"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
/*
|
||||
QU TSNZPCA
|
||||
|
||||
.HAKUOHU 151234
|
||||
|
||||
DISPATCH RELEASE:
|
||||
|
||||
HU7670/15MAY ETD1440 B2113/B733
|
||||
|
||||
DEP:TSN/ALTN:NIL
|
||||
|
||||
ROUTE ALTN:WUH KWL
|
||||
|
||||
DEST:HAK/ALTN:NNG SYX
|
||||
|
||||
FLT RULE:IFR
|
||||
|
||||
TRIP FUEL:9187KGS/20254LBS
|
||||
|
||||
TTL FUEL:13600KGS/29983LBS
|
||||
|
||||
CREW:YANG XIAOHUI/YANG ZHENGYIN
|
||||
|
||||
CREW NUMBER:2/4
|
||||
|
||||
SI:CFP AND CAUTION:MXSH 8/FIR
|
||||
|
||||
TEL:0898-65756523
|
||||
|
||||
FAX:0898-65751587
|
||||
|
||||
DSP SIGN:WUKEYONG
|
||||
|
||||
PIC SINGN:
|
||||
|
||||
(FPL-CHH7670-IS
|
||||
|
||||
-B733/M-SDHIRW/S
|
||||
|
||||
-ZBTJ1440
|
||||
|
||||
-M074S0980 CG A326 VYK A461 LKO R343 LBN/M074S0950 J427 BHY
|
||||
|
||||
W70 NYB
|
||||
|
||||
-ZJHK0323 ZGNN ZJSY
|
||||
|
||||
-EET/ZHWH0038 ZGZU0144 ZJSA0307
|
||||
|
||||
REG/B2113 SEL/DGEH
|
||||
|
||||
RMK/ACAS EQPT)
|
||||
|
||||
NNNN
|
||||
|
||||
|
||||
*/
|
||||
|
||||
// SITA defines the structure of a SITA telegram
|
||||
type SITA struct {
|
||||
Header SITAHeader `json:"header"` // Header information of the telegram
|
||||
PriorityAndSender PrioritySender `json:"priority_sender"` // Priority and sender information
|
||||
TimeAndReceiver TimeReceiver `json:"time_receiver"` // Time and receiver information
|
||||
Text string `json:"text"` // Content of the telegram
|
||||
ReceivedTime time.Time `json:"received_time"` // Time the telegram was received
|
||||
Category string `json:"category"` // Category of the telegram
|
||||
BodyData interface{} `json:"body_data"` // Additional body data
|
||||
}
|
||||
|
||||
// SITAHeader defines the header of a SITA telegram
|
||||
type SITAHeader struct {
|
||||
StartSignal string `json:"start_signal"` // Start signal indicating the beginning of the telegram
|
||||
SendID string `json:"send_id"` // Sending ID uniquely identifying the telegram
|
||||
SendTime string `json:"send_time"` // Sending time in the format DDHHMM
|
||||
}
|
||||
|
||||
// PrioritySender defines priority and sender address
|
||||
type PrioritySender struct {
|
||||
Priority string `json:"priority"` // Priority level
|
||||
Sender string `json:"sender"` // Sending address
|
||||
}
|
||||
|
||||
// TimeReceiver defines time and receiver address
|
||||
type TimeReceiver struct {
|
||||
Time string `json:"time"` // Time of the telegram
|
||||
Receiver string `json:"receiver"` // Receiving address
|
||||
}
|
||||
|
||||
func (h *SITAHeader) Validate() error {
|
||||
// Validate SendTime format (e.g., DDHHMM)
|
||||
if len(h.SendTime) != 6 {
|
||||
err := "invalid send_time format"
|
||||
|
||||
utils.Logger.Error(err)
|
||||
return fmt.Errorf(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SITA) Validate() error {
|
||||
if err := s.Header.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
// Add more validation as needed
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user