feat: 添加短信验证码发送记录功能

This commit is contained in:
2025-12-23 23:47:39 +08:00
parent a125f15f58
commit 5709255e39
19 changed files with 668 additions and 14 deletions

View File

@@ -0,0 +1,18 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE sms_code_sends(
id SERIAL8 PRIMARY KEY,
phone varchar(20) NOT NULL,
code varchar(20) NOT NULL,
sent_at timestamp NOT NULL DEFAULT now(),
expires_at timestamp NOT NULL
);
CREATE INDEX idx_sms_code_sends_phone ON sms_code_sends(phone);
CREATE INDEX idx_sms_code_sends_sent_at ON sms_code_sends(sent_at);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE sms_code_sends;
-- +goose StatementEnd

View File

@@ -0,0 +1,17 @@
package models
import "time"
const TableNameSmsCodeSend = "sms_code_sends"
// SmsCodeSend mapped from table <sms_code_sends>
type SmsCodeSend struct {
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
Phone string `gorm:"column:phone;type:character varying(20);not null" json:"phone"`
Code string `gorm:"column:code;type:character varying(20);not null" json:"code"`
SentAt time.Time `gorm:"column:sent_at;type:timestamp without time zone;not null;default:now()" json:"sent_at"`
ExpiresAt time.Time `gorm:"column:expires_at;type:timestamp without time zone;not null" json:"expires_at"`
}
func (*SmsCodeSend) TableName() string { return TableNameSmsCodeSend }