feat: 添加短信验证码发送记录功能
This commit is contained in:
@@ -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
|
||||
|
||||
17
backend_v1/database/models/sms_code_send.go
Normal file
17
backend_v1/database/models/sms_code_send.go
Normal 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 }
|
||||
|
||||
Reference in New Issue
Block a user