用户提取记录表增加批次字段
This commit is contained in:
@@ -22,6 +22,15 @@ services:
|
||||
- redis_data:/data
|
||||
restart: unless-stopped
|
||||
|
||||
postgres-migrate:
|
||||
image: postgres:17
|
||||
environment:
|
||||
POSTGRES_USER: ${DB_USERNAME}
|
||||
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||
POSTGRES_DB: ${DB_NAME}
|
||||
ports:
|
||||
- "5433:5432"
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
|
||||
@@ -63,6 +63,7 @@ create table logs_user_usage (
|
||||
id int generated by default as identity primary key,
|
||||
user_id int not null,
|
||||
resource_id int not null,
|
||||
batch_no text not null,
|
||||
count int not null,
|
||||
prov text,
|
||||
city text,
|
||||
@@ -72,13 +73,14 @@ create table logs_user_usage (
|
||||
);
|
||||
create index idx_logs_user_usage_user_id on logs_user_usage (user_id);
|
||||
create index idx_logs_user_usage_resource_id on logs_user_usage (resource_id);
|
||||
create index idx_logs_user_usage_time on logs_user_usage (time);
|
||||
create index idx_logs_user_usage_batch_no on logs_user_usage (batch_no);
|
||||
|
||||
-- logs_user_usage表字段注释
|
||||
comment on table logs_user_usage is '用户使用日志表';
|
||||
comment on column logs_user_usage.id is '日志ID';
|
||||
comment on column logs_user_usage.user_id is '用户ID';
|
||||
comment on column logs_user_usage.resource_id is '套餐ID';
|
||||
comment on column logs_user_usage.batch_no is '批次编号';
|
||||
comment on column logs_user_usage.count is '数量';
|
||||
comment on column logs_user_usage.prov is '省份';
|
||||
comment on column logs_user_usage.city is '城市';
|
||||
|
||||
@@ -10,6 +10,7 @@ type LogsUserUsage struct {
|
||||
ID int32 `json:"id" gorm:"column:id"` // 日志ID
|
||||
UserID int32 `json:"user_id" gorm:"column:user_id"` // 用户ID
|
||||
ResourceID int32 `json:"resource_id" gorm:"column:resource_id"` // 套餐ID
|
||||
BatchNo string `json:"batch_no" gorm:"column:batch_no"` // 批次编号
|
||||
Count int32 `json:"count" gorm:"column:count"` // 数量
|
||||
Prov *string `json:"prov" gorm:"column:prov"` // 省份
|
||||
City *string `json:"city" gorm:"column:city"` // 城市
|
||||
|
||||
@@ -30,6 +30,7 @@ func newLogsUserUsage(db *gorm.DB, opts ...gen.DOOption) logsUserUsage {
|
||||
_logsUserUsage.ID = field.NewInt32(tableName, "id")
|
||||
_logsUserUsage.UserID = field.NewInt32(tableName, "user_id")
|
||||
_logsUserUsage.ResourceID = field.NewInt32(tableName, "resource_id")
|
||||
_logsUserUsage.BatchNo = field.NewString(tableName, "batch_no")
|
||||
_logsUserUsage.Count_ = field.NewInt32(tableName, "count")
|
||||
_logsUserUsage.Prov = field.NewString(tableName, "prov")
|
||||
_logsUserUsage.City = field.NewString(tableName, "city")
|
||||
@@ -49,6 +50,7 @@ type logsUserUsage struct {
|
||||
ID field.Int32
|
||||
UserID field.Int32
|
||||
ResourceID field.Int32
|
||||
BatchNo field.String
|
||||
Count_ field.Int32
|
||||
Prov field.String
|
||||
City field.String
|
||||
@@ -74,6 +76,7 @@ func (l *logsUserUsage) updateTableName(table string) *logsUserUsage {
|
||||
l.ID = field.NewInt32(table, "id")
|
||||
l.UserID = field.NewInt32(table, "user_id")
|
||||
l.ResourceID = field.NewInt32(table, "resource_id")
|
||||
l.BatchNo = field.NewString(table, "batch_no")
|
||||
l.Count_ = field.NewInt32(table, "count")
|
||||
l.Prov = field.NewString(table, "prov")
|
||||
l.City = field.NewString(table, "city")
|
||||
@@ -96,10 +99,11 @@ func (l *logsUserUsage) GetFieldByName(fieldName string) (field.OrderExpr, bool)
|
||||
}
|
||||
|
||||
func (l *logsUserUsage) fillFieldMap() {
|
||||
l.fieldMap = make(map[string]field.Expr, 9)
|
||||
l.fieldMap = make(map[string]field.Expr, 10)
|
||||
l.fieldMap["id"] = l.ID
|
||||
l.fieldMap["user_id"] = l.UserID
|
||||
l.fieldMap["resource_id"] = l.ResourceID
|
||||
l.fieldMap["batch_no"] = l.BatchNo
|
||||
l.fieldMap["count"] = l.Count_
|
||||
l.fieldMap["prov"] = l.Prov
|
||||
l.fieldMap["city"] = l.City
|
||||
|
||||
@@ -143,11 +143,13 @@ func (s *channelBaiyinService) CreateChannels(source netip.Addr, resourceId int3
|
||||
actions[i] = &m.LogsUserUsage{
|
||||
UserID: user.ID,
|
||||
ResourceID: resourceId,
|
||||
BatchNo: batch,
|
||||
Count: int32(count),
|
||||
ISP: u.P(filter.Isp.String()),
|
||||
Prov: filter.Prov,
|
||||
City: filter.City,
|
||||
IP: orm.Inet{Addr: source},
|
||||
Time: now,
|
||||
}
|
||||
|
||||
// 通道数据
|
||||
|
||||
Reference in New Issue
Block a user