恢复被删除的代码
This commit is contained in:
1
soul-api/internal/model/README.txt
Normal file
1
soul-api/internal/model/README.txt
Normal file
@@ -0,0 +1 @@
|
||||
在此目录放置 GORM 模型与请求/响应结构体,例如 User、Order、Withdrawal、Config 等。
|
||||
24
soul-api/internal/model/chapter.go
Normal file
24
soul-api/internal/model/chapter.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// Chapter 对应表 chapters(mid 为自增主键,id 保留业务标识如 1.1、preface)
|
||||
type Chapter struct {
|
||||
MID int `gorm:"column:mid;primaryKey;autoIncrement" json:"mid"`
|
||||
ID string `gorm:"column:id;size:20;uniqueIndex" json:"id"`
|
||||
PartID string `gorm:"column:part_id;size:20" json:"partId"`
|
||||
PartTitle string `gorm:"column:part_title;size:100" json:"partTitle"`
|
||||
ChapterID string `gorm:"column:chapter_id;size:20" json:"chapterId"`
|
||||
ChapterTitle string `gorm:"column:chapter_title;size:200" json:"chapterTitle"`
|
||||
SectionTitle string `gorm:"column:section_title;size:200" json:"sectionTitle"`
|
||||
Content string `gorm:"column:content;type:longtext" json:"content,omitempty"`
|
||||
WordCount *int `gorm:"column:word_count" json:"wordCount,omitempty"`
|
||||
IsFree *bool `gorm:"column:is_free" json:"isFree,omitempty"`
|
||||
Price *float64 `gorm:"column:price;type:decimal(10,2)" json:"price,omitempty"`
|
||||
SortOrder *int `gorm:"column:sort_order" json:"sortOrder,omitempty"`
|
||||
Status *string `gorm:"column:status;size:20" json:"status,omitempty"`
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Chapter) TableName() string { return "chapters" }
|
||||
18
soul-api/internal/model/match_record.go
Normal file
18
soul-api/internal/model/match_record.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// MatchRecord 匹配记录,每次用户成功匹配时写入
|
||||
type MatchRecord struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:50" json:"id"`
|
||||
UserID string `gorm:"column:user_id;index;size:50;not null" json:"userId"`
|
||||
MatchType string `gorm:"column:match_type;index;size:50" json:"matchType"`
|
||||
Phone *string `gorm:"column:phone;size:20" json:"phone"`
|
||||
WechatID *string `gorm:"column:wechat_id;size:100" json:"wechatId"`
|
||||
MatchedUserID string `gorm:"column:matched_user_id;index;size:50" json:"matchedUserId"`
|
||||
MatchScore *int `gorm:"column:match_score" json:"matchScore"`
|
||||
Status *string `gorm:"column:status;size:20" json:"status"`
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||||
}
|
||||
|
||||
func (MatchRecord) TableName() string { return "match_records" }
|
||||
24
soul-api/internal/model/order.go
Normal file
24
soul-api/internal/model/order.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// Order 对应表 orders,JSON 输出与现网接口 1:1(小写驼峰)
|
||||
type Order struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:50" json:"id"`
|
||||
OrderSN string `gorm:"column:order_sn;uniqueIndex;size:50" json:"orderSn"`
|
||||
UserID string `gorm:"column:user_id;size:50" json:"userId"`
|
||||
OpenID string `gorm:"column:open_id;size:100" json:"openId"`
|
||||
ProductType string `gorm:"column:product_type;size:50" json:"productType"`
|
||||
ProductID *string `gorm:"column:product_id;size:50" json:"productId,omitempty"`
|
||||
Amount float64 `gorm:"column:amount;type:decimal(10,2)" json:"amount"`
|
||||
Description *string `gorm:"column:description;size:200" json:"description,omitempty"`
|
||||
Status *string `gorm:"column:status;size:20" json:"status,omitempty"`
|
||||
TransactionID *string `gorm:"column:transaction_id;size:100" json:"transactionId,omitempty"`
|
||||
PayTime *time.Time `gorm:"column:pay_time" json:"payTime,omitempty"`
|
||||
ReferralCode *string `gorm:"column:referral_code;size:255" json:"referralCode,omitempty"`
|
||||
ReferrerID *string `gorm:"column:referrer_id;size:255" json:"referrerId,omitempty"`
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Order) TableName() string { return "orders" }
|
||||
20
soul-api/internal/model/reading_progress.go
Normal file
20
soul-api/internal/model/reading_progress.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// ReadingProgress 对应表 reading_progress
|
||||
type ReadingProgress struct {
|
||||
ID int `gorm:"column:id;primaryKey;autoIncrement"`
|
||||
UserID string `gorm:"column:user_id;size:50"`
|
||||
SectionID string `gorm:"column:section_id;size:50"`
|
||||
Progress int `gorm:"column:progress"`
|
||||
Duration int `gorm:"column:duration"`
|
||||
Status string `gorm:"column:status;size:20"`
|
||||
CompletedAt *time.Time `gorm:"column:completed_at"`
|
||||
FirstOpenAt *time.Time `gorm:"column:first_open_at"`
|
||||
LastOpenAt *time.Time `gorm:"column:last_open_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at"`
|
||||
}
|
||||
|
||||
func (ReadingProgress) TableName() string { return "reading_progress" }
|
||||
22
soul-api/internal/model/referral_binding.go
Normal file
22
soul-api/internal/model/referral_binding.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// ReferralBinding 对应表 referral_bindings
|
||||
type ReferralBinding struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:50"`
|
||||
ReferrerID string `gorm:"column:referrer_id;size:50"`
|
||||
RefereeID string `gorm:"column:referee_id;size:50"`
|
||||
ReferralCode string `gorm:"column:referral_code;size:20"`
|
||||
Status *string `gorm:"column:status;size:20"`
|
||||
BindingDate time.Time `gorm:"column:binding_date"`
|
||||
ExpiryDate time.Time `gorm:"column:expiry_date"`
|
||||
CommissionAmount *float64 `gorm:"column:commission_amount;type:decimal(10,2)"`
|
||||
PurchaseCount *int `gorm:"column:purchase_count"` // 购买次数
|
||||
TotalCommission *float64 `gorm:"column:total_commission;type:decimal(10,2)"` // 累计佣金
|
||||
LastPurchaseDate *time.Time `gorm:"column:last_purchase_date"` // 最后购买日期
|
||||
CreatedAt time.Time `gorm:"column:created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at"`
|
||||
}
|
||||
|
||||
func (ReferralBinding) TableName() string { return "referral_bindings" }
|
||||
16
soul-api/internal/model/referral_visit.go
Normal file
16
soul-api/internal/model/referral_visit.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// ReferralVisit 对应表 referral_visits
|
||||
type ReferralVisit struct {
|
||||
ID int `gorm:"column:id;primaryKey;autoIncrement"`
|
||||
ReferrerID string `gorm:"column:referrer_id;size:50"`
|
||||
VisitorID *string `gorm:"column:visitor_id;size:50"`
|
||||
VisitorOpenID *string `gorm:"column:visitor_openid;size:100"`
|
||||
Source *string `gorm:"column:source;size:50"`
|
||||
Page *string `gorm:"column:page;size:200"`
|
||||
CreatedAt time.Time `gorm:"column:created_at"`
|
||||
}
|
||||
|
||||
func (ReferralVisit) TableName() string { return "referral_visits" }
|
||||
35
soul-api/internal/model/system_config.go
Normal file
35
soul-api/internal/model/system_config.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ConfigValue 存 system_config.config_value(JSON 列,可为 object 或 array)
|
||||
type ConfigValue []byte
|
||||
|
||||
func (c ConfigValue) Value() (driver.Value, error) { return []byte(c), nil }
|
||||
func (c *ConfigValue) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
*c = nil
|
||||
return nil
|
||||
}
|
||||
b, ok := value.([]byte)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
*c = append((*c)[0:0], b...)
|
||||
return nil
|
||||
}
|
||||
|
||||
// SystemConfig 对应表 system_config,JSON 输出与现网 1:1(小写驼峰)
|
||||
type SystemConfig struct {
|
||||
ID int `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
||||
ConfigKey string `gorm:"column:config_key;uniqueIndex;size:100" json:"configKey"`
|
||||
ConfigValue ConfigValue `gorm:"column:config_value;type:json" json:"configValue"`
|
||||
Description *string `gorm:"column:description;size:200" json:"description,omitempty"`
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (SystemConfig) TableName() string { return "system_config" }
|
||||
30
soul-api/internal/model/user.go
Normal file
30
soul-api/internal/model/user.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// User 对应表 users,JSON 输出与现网接口 1:1(小写驼峰)
|
||||
type User struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:50" json:"id"`
|
||||
OpenID *string `gorm:"column:open_id;size:100" json:"openId,omitempty"`
|
||||
SessionKey *string `gorm:"column:session_key;size:200" json:"-"` // 微信 session_key,不输出到 JSON
|
||||
Nickname *string `gorm:"column:nickname;size:100" json:"nickname,omitempty"`
|
||||
Avatar *string `gorm:"column:avatar;size:500" json:"avatar,omitempty"`
|
||||
Phone *string `gorm:"column:phone;size:20" json:"phone,omitempty"`
|
||||
WechatID *string `gorm:"column:wechat_id;size:100" json:"wechatId,omitempty"`
|
||||
ReferralCode *string `gorm:"column:referral_code;size:20" json:"referralCode,omitempty"`
|
||||
HasFullBook *bool `gorm:"column:has_full_book" json:"hasFullBook,omitempty"`
|
||||
PurchasedSections *string `gorm:"column:purchased_sections;type:json" json:"-"` // 内部字段,实际数据从 orders 表查
|
||||
Earnings *float64 `gorm:"column:earnings;type:decimal(10,2)" json:"earnings,omitempty"`
|
||||
PendingEarnings *float64 `gorm:"column:pending_earnings;type:decimal(10,2)" json:"pendingEarnings,omitempty"`
|
||||
ReferralCount *int `gorm:"column:referral_count" json:"referralCount,omitempty"`
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
|
||||
IsAdmin *bool `gorm:"column:is_admin" json:"isAdmin,omitempty"`
|
||||
WithdrawnEarnings *float64 `gorm:"column:withdrawn_earnings;type:decimal(10,2)" json:"withdrawnEarnings,omitempty"`
|
||||
Source *string `gorm:"column:source;size:50" json:"source,omitempty"`
|
||||
|
||||
// 以下为接口返回时从订单/绑定表实时计算的字段,不入库
|
||||
PurchasedSectionCount int `gorm:"-" json:"purchasedSectionCount,omitempty"`
|
||||
}
|
||||
|
||||
func (User) TableName() string { return "users" }
|
||||
20
soul-api/internal/model/user_address.go
Normal file
20
soul-api/internal/model/user_address.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// UserAddress 对应表 user_addresses
|
||||
type UserAddress struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:50"`
|
||||
UserID string `gorm:"column:user_id;size:50"`
|
||||
Name string `gorm:"column:name;size:50"`
|
||||
Phone string `gorm:"column:phone;size:20"`
|
||||
Province string `gorm:"column:province;size:50"`
|
||||
City string `gorm:"column:city;size:50"`
|
||||
District string `gorm:"column:district;size:50"`
|
||||
Detail string `gorm:"column:detail;size:200"`
|
||||
IsDefault bool `gorm:"column:is_default"`
|
||||
CreatedAt time.Time `gorm:"column:created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at"`
|
||||
}
|
||||
|
||||
func (UserAddress) TableName() string { return "user_addresses" }
|
||||
16
soul-api/internal/model/user_track.go
Normal file
16
soul-api/internal/model/user_track.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// UserTrack 对应表 user_tracks
|
||||
type UserTrack struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:50"`
|
||||
UserID string `gorm:"column:user_id;size:100"`
|
||||
Action string `gorm:"column:action;size:50"`
|
||||
ChapterID *string `gorm:"column:chapter_id;size:100"`
|
||||
Target *string `gorm:"column:target;size:200"`
|
||||
ExtraData []byte `gorm:"column:extra_data;type:json"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at"`
|
||||
}
|
||||
|
||||
func (UserTrack) TableName() string { return "user_tracks" }
|
||||
21
soul-api/internal/model/wechat_callback_log.go
Normal file
21
soul-api/internal/model/wechat_callback_log.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// WechatCallbackLog 微信回调日志(转账结果通知、支付通知等)
|
||||
// 表名 wechat_callback_logs
|
||||
type WechatCallbackLog struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
||||
CallbackType string `gorm:"column:callback_type;size:32;index" json:"callbackType"` // transfer | pay
|
||||
OutBatchNo string `gorm:"column:out_batch_no;size:64;index" json:"outBatchNo"` // 商家批次单号
|
||||
OutDetailNo string `gorm:"column:out_detail_no;size:64;index" json:"outDetailNo"` // 商家明细单号(转账即 out_bill_no)
|
||||
TransferBillNo string `gorm:"column:transfer_bill_no;size:64" json:"transferBillNo"` // 微信转账单号
|
||||
State string `gorm:"column:state;size:32" json:"state"` // SUCCESS | FAIL | CANCELLED 等
|
||||
FailReason string `gorm:"column:fail_reason;size:500" json:"failReason"`
|
||||
HandlerResult string `gorm:"column:handler_result;size:20" json:"handlerResult"` // success | fail
|
||||
HandlerError string `gorm:"column:handler_error;size:1000" json:"handlerError"` // 业务处理错误信息
|
||||
RequestBody string `gorm:"column:request_body;type:text" json:"-"` // 原始/解密后 body(可选,不输出 JSON)
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||||
}
|
||||
|
||||
func (WechatCallbackLog) TableName() string { return "wechat_callback_logs" }
|
||||
24
soul-api/internal/model/withdrawal.go
Normal file
24
soul-api/internal/model/withdrawal.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// Withdrawal 对应表 withdrawals
|
||||
type Withdrawal struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:50" json:"id"`
|
||||
UserID string `gorm:"column:user_id;size:50" json:"userId"`
|
||||
Amount float64 `gorm:"column:amount;type:decimal(10,2)" json:"amount"`
|
||||
Status *string `gorm:"column:status;size:20" json:"status"`
|
||||
WechatID *string `gorm:"column:wechat_id;size:100" json:"wechatId"`
|
||||
WechatOpenid *string `gorm:"column:wechat_openid;size:100" json:"wechatOpenid"`
|
||||
BatchNo *string `gorm:"column:batch_no;size:100" json:"batchNo,omitempty"` // 商家批次单号
|
||||
DetailNo *string `gorm:"column:detail_no;size:100" json:"detailNo,omitempty"` // 商家明细单号
|
||||
BatchID *string `gorm:"column:batch_id;size:100" json:"batchId,omitempty"` // 微信批次单号
|
||||
PackageInfo *string `gorm:"column:package_info;size:500" json:"packageInfo,omitempty"` // 微信返回的 package_info,供小程序 wx.requestMerchantTransfer
|
||||
Remark *string `gorm:"column:remark;size:200" json:"remark,omitempty"` // 提现备注
|
||||
FailReason *string `gorm:"column:fail_reason;size:500" json:"failReason,omitempty"` // 失败原因
|
||||
UserConfirmedAt *time.Time `gorm:"column:user_confirmed_at" json:"userConfirmedAt,omitempty"` // 用户点击「确认收款」时间
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||||
ProcessedAt *time.Time `gorm:"column:processed_at" json:"processedAt"`
|
||||
}
|
||||
|
||||
func (Withdrawal) TableName() string { return "withdrawals" }
|
||||
Reference in New Issue
Block a user