initial commit: Go version of SMS Receiver with fixed template rendering

- Implemented all core features from Python version
- Fixed int64/int type compatibility in template functions
- Added login authentication, SMS receiving, statistics, logs
- Independent database: sms_receiver_go.db
- Fixed frontend display issues for message list and statistics
This commit is contained in:
OpenClaw Agent
2026-02-08 17:15:22 +08:00
commit 4a31cd1115
23 changed files with 3493 additions and 0 deletions

67
models/message.go Normal file
View File

@@ -0,0 +1,67 @@
package models
import (
"database/sql"
"time"
)
// SMSMessage 短信消息模型
type SMSMessage struct {
ID int64 `json:"id"`
FromNumber string `json:"from_number"`
Content string `json:"content"`
Timestamp int64 `json:"timestamp"`
TimestampStr string `json:"timestamp_str,omitempty"` // 显示用
LocalTimestampStr string `json:"local_timestamp_str,omitempty"` // 显示用
DeviceInfo sql.NullString `json:"device_info,omitempty"`
SIMInfo sql.NullString `json:"sim_info,omitempty"`
SignVerified sql.NullBool `json:"sign_verified,omitempty"`
IPAddress string `json:"ip_address"`
CreatedAt time.Time `json:"created_at"`
}
// ReceiveLog 接收日志模型
type ReceiveLog struct {
ID int64 `json:"id"`
FromNumber string `json:"from_number"`
Content string `json:"content"`
Timestamp int64 `json:"timestamp"`
Sign sql.NullString `json:"sign,omitempty"`
SignValid sql.NullBool `json:"sign_valid,omitempty"`
IPAddress string `json:"ip_address"`
Status string `json:"status"`
ErrorMessage sql.NullString `json:"error_message,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
// Statistics 统计信息
type Statistics struct {
Total int64 `json:"total"`
Today int64 `json:"today"`
Week int64 `json:"week"`
Verified int64 `json:"verified"`
Unverified int64 `json:"unverified"`
}
// MessageListResponse 消息列表响应
type MessageListResponse struct {
Success bool `json:"success"`
Data []SMSMessage `json:"data"`
Total int64 `json:"total"`
Page int `json:"page"`
Limit int `json:"limit"`
}
// StatisticsResponse 统计响应
type StatisticsResponse struct {
Success bool `json:"success"`
Data Statistics `json:"data"`
}
// APIResponse API 通用响应
type APIResponse struct {
Success bool `json:"success"`
Message string `json:"message,omitempty"`
MessageID int64 `json:"message_id,omitempty"`
Error string `json:"error,omitempty"`
}