增加data层,更新model数据表

This commit is contained in:
wolter 2024-07-31 18:38:17 +08:00
parent 89f1c7895a
commit 689b0f80db
6 changed files with 229 additions and 0 deletions

0
app/data/.gitkeep Normal file
View File

View File

@ -0,0 +1,47 @@
package appmodel
import (
"github.com/qit-team/snow-core/db"
"sync"
"time"
)
var (
once sync.Once
m *AppModel
)
// 实体
type App struct {
Id int64 `xorm:"'Id' bigint(20)"`
MerchantId int64 `xorm:"'merchant_id' bigint(20)"`
AppName string `xorm:"'app_name' varchar(128)"`
AppRemark string `xorm:"'app_remark' varchar(255)"`
Status int `xorm:"'status' int(11)"`
KeyType int `xorm:"'key_type' int(11)"`
PublicKey string `xorm:"'public_key' varchar(1024)"`
PrivateKey string `xorm:"'private_key' varchar(1024)"`
MerchantPublicKey string `xorm:"'merchant_public_key' varchar(1024)"`
CreateTime time.Time `xorm:"'create_time' datetime updated"`
UpdateTime time.Time `xorm:"'update_time' timestamp"`
DeleteTime time.Time `xorm:"'delete_time' timestamp"`
}
// 表名
func (m *App) TableName() string {
return "app"
}
// 私有化防止被外部new
type AppModel struct {
db.Model //组合基础Model集成基础Model的属性和方法
}
// 单例模式
func GetInstance() *AppModel {
once.Do(func() {
m = new(AppModel)
//m.DiName = "" //设置数据库实例连接默认db.SingletonMain
})
return m
}

View File

@ -0,0 +1,43 @@
package merchantmodel
import (
"github.com/qit-team/snow-core/db"
"sync"
"time"
)
var (
once sync.Once
m *MerchantModel
)
// 实体
type Merchant struct {
Id int64 `xorm:"'Id' bigint(20)"`
Name string `xorm:"'name' varchar(128)"`
Contact string `xorm:"'contact' varchar(128)"`
Phone string `xorm:"'phone' varchar(11)"`
Remark string `xorm:"'remark' varchar(1024)"`
CreateTime time.Time `xorm:"'create_time' datetime"`
UpdateTime time.Time `xorm:"'update_time' timestamp"`
DeleteTime time.Time `xorm:"'delete_time' timestamp"`
}
// 表名
func (m *Merchant) TableName() string {
return "merchant"
}
// 私有化防止被外部new
type MerchantModel struct {
db.Model //组合基础Model集成基础Model的属性和方法
}
// 单例模式
func GetInstance() *MerchantModel {
once.Do(func() {
m = new(MerchantModel)
//m.DiName = "" //设置数据库实例连接默认db.SingletonMain
})
return m
}

View File

@ -0,0 +1,42 @@
package orderlogmodel
import (
"github.com/qit-team/snow-core/db"
"sync"
"time"
)
var (
once sync.Once
m *OrderLogModel
)
// 实体
type OrderLog struct {
Id int64 `xorm:"'Id' bigint(20)"`
OrderId int64 `xorm:"'order_id' bigint(20)"`
PayCallback string `xorm:"'pay_callback' varchar(255)"`
Status int `xorm:"'status' int(11)"`
MerchantParam string `xorm:"'merchant_param' varchar(255)"`
MerchantCallback string `xorm:"'merchant_callback' varchar(255)"`
CreateTime time.Time `xorm:"'create_time' datetime"`
}
// 表名
func (m *OrderLog) TableName() string {
return "order_log"
}
// 私有化防止被外部new
type OrderLogModel struct {
db.Model //组合基础Model集成基础Model的属性和方法
}
// 单例模式
func GetInstance() *OrderLogModel {
once.Do(func() {
m = new(OrderLogModel)
//m.DiName = "" //设置数据库实例连接默认db.SingletonMain
})
return m
}

View File

@ -0,0 +1,51 @@
package ordersmodel
import (
"github.com/qit-team/snow-core/db"
"sync"
"time"
)
var (
once sync.Once
m *OrdersModel
)
// 实体
type Orders struct {
Id int64 `xorm:"'Id' bigint(20)"`
MerchantId int64 `xorm:"'merchant_id' bigint(20)"`
PayId int64 `xorm:"'pay_id' bigint(20)"`
MerchantOrderId string `xorm:"'merchant_order_id' varchar(128)"`
Status int `xorm:"'status' int(11)"`
OrderType int `xorm:"'order_type' int(11)"`
Amount int `xorm:"'amount' int(11)"`
NotifyUrl string `xorm:"'notify_url' varchar(255)"`
IpAddress string `xorm:"'ip_address' varchar(128)"`
MerchantRequest string `xorm:"'merchant_request' varchar(2048)"`
MerchantResponse string `xorm:"'merchant_response' varchar(255)"`
OrderResponse string `xorm:"'order_response' varchar(255)"`
ExtJson string `xorm:"'ext_json' varchar(1024)"`
CreateTime time.Time `xorm:"'create_time' datetime"`
UpdateTime time.Time `xorm:"'update_time' timestamp"`
DeleteTime time.Time `xorm:"'delete_time' timestamp"`
}
// 表名
func (m *Orders) TableName() string {
return "orders"
}
// 私有化防止被外部new
type OrdersModel struct {
db.Model //组合基础Model集成基础Model的属性和方法
}
// 单例模式
func GetInstance() *OrdersModel {
once.Do(func() {
m = new(OrdersModel)
//m.DiName = "" //设置数据库实例连接默认db.SingletonMain
})
return m
}

View File

@ -0,0 +1,46 @@
package paychannelmodel
import (
"github.com/qit-team/snow-core/db"
"sync"
"time"
)
var (
once sync.Once
m *PayChannelModel
)
// 实体
type PayChannel struct {
Id int64 `xorm:"'Id' bigint(20)"`
PayName string `xorm:"'pay_name' varchar(128)"`
MerchantId int64 `xorm:"'merchant_id' bigint(20)"`
ChannelType int `xorm:"'channel_type' int(11)"`
WhiteIp string `xorm:"'white_ip' varchar(1024)"`
AppId string `xorm:"'app_id' varchar(255)"`
ExtJson string `xorm:"'ext_json' JSON"`
ExpireTime time.Time `xorm:"'expire_time' datetime"`
CreateTime time.Time `xorm:"'create_time' datetime"`
UpdateTime time.Time `xorm:"'update_time' timestamp"`
DeleteTime time.Time `xorm:"'delete_time' timestamp"`
}
// 表名
func (m *PayChannel) TableName() string {
return "pay_channel"
}
// 私有化防止被外部new
type PayChannelModel struct {
db.Model //组合基础Model集成基础Model的属性和方法
}
// 单例模式
func GetInstance() *PayChannelModel {
once.Do(func() {
m = new(PayChannelModel)
//m.DiName = "" //设置数据库实例连接默认db.SingletonMain
})
return m
}