13 changed files with 485 additions and 1 deletions
@ -0,0 +1,27 @@ |
|||||
|
package config |
||||
|
|
||||
|
import ( |
||||
|
"fmt" |
||||
|
|
||||
|
"github.com/go-ini/ini" |
||||
|
) |
||||
|
|
||||
|
var ( |
||||
|
Appconfig = &appConfig{} |
||||
|
) |
||||
|
|
||||
|
func LoadSystemConfig(initPath string) (err error) { |
||||
|
fmt.Println("启动程序,开始加载基础配置......") |
||||
|
configSetUp, err := ini.Load(initPath) |
||||
|
if err != nil { |
||||
|
fmt.Printf("app配置加载失败!\n错误:%v\n", err) |
||||
|
return |
||||
|
} |
||||
|
err = configSetUp.Section("App").MapTo(Appconfig) |
||||
|
if err != nil { |
||||
|
fmt.Printf("app配置读取失败!\n错误:%v\n", err) |
||||
|
return |
||||
|
} |
||||
|
fmt.Println("app基础配置全部加载完成!") |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
package config |
||||
|
|
||||
|
type appConfig struct { |
||||
|
ListenPort string //监听端口
|
||||
|
AppKey string //App加密密钥
|
||||
|
DataBaseType string //采用数据库类型
|
||||
|
MasterDatabase string //主数据库配置
|
||||
|
} |
||||
|
|
||||
|
//数据库配置
|
||||
|
type MysqlConfig struct { |
||||
|
DB_Host string //数据库地址
|
||||
|
DB_User string //数据库用户名
|
||||
|
DB_Pwds string //数据库密码
|
||||
|
DB_Port string //数据库端口
|
||||
|
DB_Name string //数据库名称
|
||||
|
Master_Slave int //1:主库;0:从库
|
||||
|
ReadWriteSeparation bool //读写分离
|
||||
|
DB_Config string //后缀
|
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
;基础配置 |
||||
|
[App] |
||||
|
;监听端口 |
||||
|
ListenPort = :14438 |
||||
|
;App密钥 |
||||
|
AppKey = 'heng_xin_gao_ke_AppKey' |
||||
|
;App默认密码 |
||||
|
DefaultPassword = 1234567890 |
||||
|
;数据库类型 |
||||
|
DataBaseType = mysql |
||||
|
;默认数据库 |
||||
|
MasterDatabase = Master |
||||
@ -0,0 +1,171 @@ |
|||||
|
;主数据库 |
||||
|
[Master] |
||||
|
;数据库类型 |
||||
|
DB_Type = Mysql |
||||
|
;数据库地址 |
||||
|
DB_Host = 127.0.0.1 |
||||
|
;数据库用户名 |
||||
|
DB_User = root |
||||
|
;数据库密码 |
||||
|
DB_Pwds = root |
||||
|
;数据库名称 |
||||
|
DB_Name = hengxingaoke_tes |
||||
|
;数据库端口 |
||||
|
DB_Port = 3306 |
||||
|
;主从(1:主库;0:从库) |
||||
|
Master_Slave = 1 |
||||
|
;后缀 |
||||
|
DB_Config = "charset=utf8mb4&parseTime=True&loc=Local" |
||||
|
|
||||
|
;文档属性数据库 |
||||
|
[BookDate] |
||||
|
;数据库类型 |
||||
|
DB_Type = Mysql |
||||
|
;数据库地址 |
||||
|
DB_Host = 127.0.0.1 |
||||
|
;数据库用户名 |
||||
|
DB_User = root |
||||
|
;数据库密码 |
||||
|
DB_Pwds = root |
||||
|
;数据库名称 |
||||
|
DB_Name = learn_message |
||||
|
;数据库端口 |
||||
|
DB_Port = 3306 |
||||
|
;主从(1:主库;0:从库) |
||||
|
Master_Slave = 1 |
||||
|
;后缀 |
||||
|
DB_Config = "charset=utf8mb4&parseTime=True&loc=Local" |
||||
|
|
||||
|
;微信员工信息表 |
||||
|
[WatchDate] |
||||
|
;数据库类型 |
||||
|
DB_Type = Mysql |
||||
|
;数据库地址 |
||||
|
DB_Host = 127.0.0.1 |
||||
|
;数据库用户名 |
||||
|
DB_User = root |
||||
|
;数据库密码 |
||||
|
DB_Pwds = root |
||||
|
;数据库名称 |
||||
|
DB_Name = wechatuser |
||||
|
;数据库端口 |
||||
|
DB_Port = 3306 |
||||
|
;主从(1:主库;0:从库) |
||||
|
Master_Slave = 1 |
||||
|
;后缀 |
||||
|
DB_Config = "charset=utf8mb4&parseTime=True&loc=Local" |
||||
|
|
||||
|
;错题库 |
||||
|
[ErrorSubjectDate] |
||||
|
;数据库类型 |
||||
|
DB_Type = Mysql |
||||
|
;数据库地址 |
||||
|
DB_Host = 127.0.0.1 |
||||
|
;数据库用户名 |
||||
|
DB_User = root |
||||
|
;数据库密码 |
||||
|
DB_Pwds = root |
||||
|
;数据库名称 |
||||
|
DB_Name = wrong_question_bank |
||||
|
;数据库端口 |
||||
|
DB_Port = 3306 |
||||
|
;主从(1:主库;0:从库) |
||||
|
Master_Slave = 1 |
||||
|
;后缀 |
||||
|
DB_Config = "charset=utf8mb4&parseTime=True&loc=Local" |
||||
|
|
||||
|
;自我测验 |
||||
|
[MyTestDate] |
||||
|
;数据库类型 |
||||
|
DB_Type = Mysql |
||||
|
;数据库地址 |
||||
|
DB_Host = 127.0.0.1 |
||||
|
;数据库用户名 |
||||
|
DB_User = root |
||||
|
;数据库密码 |
||||
|
DB_Pwds = root |
||||
|
;数据库名称 |
||||
|
DB_Name = selftestdatabase |
||||
|
;数据库端口 |
||||
|
DB_Port = 3306 |
||||
|
;主从(1:主库;0:从库) |
||||
|
Master_Slave = 1 |
||||
|
;后缀 |
||||
|
DB_Config = "charset=utf8mb4&parseTime=True&loc=Local" |
||||
|
|
||||
|
|
||||
|
;图文信息数据库 |
||||
|
[BooImgkDate] |
||||
|
;数据库类型 |
||||
|
DB_Type = Mysql |
||||
|
;数据库地址 |
||||
|
DB_Host = 127.0.0.1 |
||||
|
;数据库用户名 |
||||
|
DB_User = root |
||||
|
;数据库密码 |
||||
|
DB_Pwds = root |
||||
|
;数据库名称 |
||||
|
DB_Name = readdocument |
||||
|
;数据库端口 |
||||
|
DB_Port = 3306 |
||||
|
;主从(1:主库;0:从库) |
||||
|
Master_Slave = 1 |
||||
|
;后缀 |
||||
|
DB_Config = "charset=utf8mb4&parseTime=True&loc=Local" |
||||
|
|
||||
|
;计分明细数据库 |
||||
|
[IntegralDate] |
||||
|
;数据库类型 |
||||
|
DB_Type = Mysql |
||||
|
;数据库地址 |
||||
|
DB_Host = 127.0.0.1 |
||||
|
;数据库用户名 |
||||
|
DB_User = root |
||||
|
;数据库密码 |
||||
|
DB_Pwds = root |
||||
|
;数据库名称 |
||||
|
DB_Name = league_table_data |
||||
|
;数据库端口 |
||||
|
DB_Port = 3306 |
||||
|
;主从(1:主库;0:从库) |
||||
|
Master_Slave = 1 |
||||
|
;后缀 |
||||
|
DB_Config = "charset=utf8mb4&parseTime=True&loc=Local" |
||||
|
|
||||
|
;趣味问答 |
||||
|
[QADate] |
||||
|
;数据库类型 |
||||
|
DB_Type = Mysql |
||||
|
;数据库地址 |
||||
|
DB_Host = 127.0.0.1 |
||||
|
;数据库用户名 |
||||
|
DB_User = root |
||||
|
;数据库密码 |
||||
|
DB_Pwds = root |
||||
|
;数据库名称 |
||||
|
DB_Name = ques_and_answers |
||||
|
;数据库端口 |
||||
|
DB_Port = 3306 |
||||
|
;主从(1:主库;0:从库) |
||||
|
Master_Slave = 1 |
||||
|
;后缀 |
||||
|
DB_Config = "charset=utf8mb4&parseTime=True&loc=Local" |
||||
|
|
||||
|
;风云榜统计数据库 |
||||
|
[BillboardDate] |
||||
|
;数据库类型 |
||||
|
DB_Type = Mysql |
||||
|
;数据库地址 |
||||
|
DB_Host = 127.0.0.1 |
||||
|
;数据库用户名 |
||||
|
DB_User = root |
||||
|
;数据库密码 |
||||
|
DB_Pwds = root |
||||
|
;数据库名称 |
||||
|
DB_Name = statisticsing |
||||
|
;数据库端口 |
||||
|
DB_Port = 3306 |
||||
|
;主从(1:主库;0:从库) |
||||
|
Master_Slave = 1 |
||||
|
;后缀 |
||||
|
DB_Config = "charset=utf8mb4&parseTime=True&loc=Local" |
||||
@ -0,0 +1,5 @@ |
|||||
|
package database |
||||
|
|
||||
|
var ( |
||||
|
DataBaseLoadName string |
||||
|
) |
||||
@ -0,0 +1,89 @@ |
|||||
|
package database |
||||
|
|
||||
|
import ( |
||||
|
"flag" |
||||
|
"fmt" |
||||
|
"gorm_test/config" |
||||
|
|
||||
|
"github.com/go-ini/ini" |
||||
|
"gorm.io/driver/mysql" |
||||
|
"gorm.io/gorm" |
||||
|
) |
||||
|
|
||||
|
var ( |
||||
|
databaseConfig = flag.String("sqlConfig", "configIni/mysqlConfig.ini", "数据库配置文件") |
||||
|
MysqlConfigSet = &config.MysqlConfig{} |
||||
|
) |
||||
|
|
||||
|
type SetDb struct{} |
||||
|
|
||||
|
func readConfig(dataName string) { |
||||
|
if dataName != "" { |
||||
|
DataBaseLoadName = dataName |
||||
|
} else { |
||||
|
DataBaseLoadName = config.Appconfig.MasterDatabase |
||||
|
} |
||||
|
dataBaseSetUp, err := ini.Load(*databaseConfig) |
||||
|
if err != nil { |
||||
|
fmt.Printf("%v=>数据库配置加载失败", dataName) |
||||
|
|
||||
|
} |
||||
|
err = dataBaseSetUp.Section(dataName).MapTo(MysqlConfigSet) |
||||
|
if err != nil { |
||||
|
fmt.Printf("%v=>数据库配置读取失败", dataName) |
||||
|
|
||||
|
} |
||||
|
// fmt.Printf("%v=>数据库配置读取失败", MysqlConfigSet)
|
||||
|
} |
||||
|
func SwitchDatabase(dataBaseName string) (db *gorm.DB) { |
||||
|
readConfig(dataBaseName) |
||||
|
db = InitDB() |
||||
|
DataBaseLoadName = config.Appconfig.MasterDatabase |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
func InitDB() (db *gorm.DB) { |
||||
|
readConfig(DataBaseLoadName) |
||||
|
|
||||
|
// dsn := MysqlConfigSet.DB_User + ":" + MysqlConfigSet.DB_Pwds + "@tcp(" + MysqlConfigSet.DB_Host + ":" + MysqlConfigSet.DB_Port
|
||||
|
dsn := MysqlConfigSet.DB_User + ":" + MysqlConfigSet.DB_Pwds + "@tcp(" + MysqlConfigSet.DB_Host + ":" + MysqlConfigSet.DB_Port + ")/" + MysqlConfigSet.DB_Name + "?" + MysqlConfigSet.DB_Config |
||||
|
fmt.Printf("==>%v-----------%v====%v\n", MysqlConfigSet.DB_Name, DataBaseLoadName, dsn) |
||||
|
mysqlConfig := mysql.Config{ |
||||
|
DSN: dsn, // DSN data source name
|
||||
|
DefaultStringSize: 191, // string 类型字段的默认长度
|
||||
|
DisableDatetimePrecision: true, // 禁用 datetime 精度,MySQL 5.6 之前的数据库不支持
|
||||
|
DontSupportRenameIndex: true, // 重命名索引时采用删除并新建的方式,MySQL 5.7 之前的数据库和 MariaDB 不支持重命名索引
|
||||
|
DontSupportRenameColumn: false, // 用 `change` 重命名列,MySQL 8 之前的数据库和 MariaDB 不支持重命名列
|
||||
|
SkipInitializeWithVersion: false, // 根据版本自动配置
|
||||
|
} |
||||
|
db, _ = gorm.Open(mysql.New(mysqlConfig), gormConfig()) |
||||
|
// if db, _ = gorm.Open(mysql.New(mysqlConfig), gormConfig()); err != nil {
|
||||
|
// //global.GVA_LOG.Error("MySQL启动异常", zap.Any("err", err))
|
||||
|
// //os.Exit(0)
|
||||
|
// //return nil
|
||||
|
// return
|
||||
|
// }
|
||||
|
// } else {
|
||||
|
// sqlDB, _ := db.DB()
|
||||
|
// sqlDB.SetMaxIdleConns(m.MaxIdleConns)
|
||||
|
// sqlDB.SetMaxOpenConns(m.MaxOpenConns)
|
||||
|
// // return db
|
||||
|
// }
|
||||
|
return |
||||
|
} |
||||
|
func gormConfig() *gorm.Config { |
||||
|
config := &gorm.Config{DisableForeignKeyConstraintWhenMigrating: true} |
||||
|
// switch global.GVA_CONFIG.Mysql.LogMode {
|
||||
|
// case "silent", "Silent":
|
||||
|
// config.Logger = internal.Default.LogMode(logger.Silent)
|
||||
|
// case "error", "Error":
|
||||
|
// config.Logger = internal.Default.LogMode(logger.Error)
|
||||
|
// case "warn", "Warn":
|
||||
|
// config.Logger = internal.Default.LogMode(logger.Warn)
|
||||
|
// case "info", "Info":
|
||||
|
// config.Logger = internal.Default.LogMode(logger.Info)
|
||||
|
// default:
|
||||
|
// config.Logger = internal.Default.LogMode(logger.Info)
|
||||
|
// }
|
||||
|
return config |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
module gorm_test |
||||
|
|
||||
|
go 1.16 |
||||
|
|
||||
|
require ( |
||||
|
github.com/go-ini/ini v1.63.2 |
||||
|
github.com/stretchr/testify v1.7.0 // indirect |
||||
|
gopkg.in/ini.v1 v1.63.2 |
||||
|
gorm.io/driver/mysql v1.1.3 |
||||
|
gorm.io/gorm v1.22.2 |
||||
|
) |
||||
@ -0,0 +1,25 @@ |
|||||
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= |
||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
||||
|
github.com/go-ini/ini v1.63.2 h1:kwN3umicd2HF3Tgvap4um1ZG52/WyKT9GGdPx0CJk6Y= |
||||
|
github.com/go-ini/ini v1.63.2/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= |
||||
|
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= |
||||
|
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= |
||||
|
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= |
||||
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= |
||||
|
github.com/jinzhu/now v1.1.2 h1:eVKgfIdy9b6zbWBMgFpfDPoAMifwSZagU9HmEU6zgiI= |
||||
|
github.com/jinzhu/now v1.1.2/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= |
||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= |
||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= |
||||
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= |
||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= |
||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
||||
|
gopkg.in/ini.v1 v1.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c= |
||||
|
gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= |
||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= |
||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
||||
|
gorm.io/driver/mysql v1.1.3 h1:+5g1UElqN0sr2gZqmg9djlu1zT3cErHiscc6+IbLHgw= |
||||
|
gorm.io/driver/mysql v1.1.3/go.mod h1:4P/X9vSc3WTrhTLZ259cpFd6xKNYiSSdSZngkSBGIMM= |
||||
|
gorm.io/gorm v1.21.12/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= |
||||
|
gorm.io/gorm v1.22.2 h1:1iKcvyJnR5bHydBhDqTwasOkoo6+o4Ms5cknSt6qP7I= |
||||
|
gorm.io/gorm v1.22.2/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= |
||||
@ -1,3 +1,65 @@ |
|||||
package main |
package main |
||||
|
|
||||
func main() {} |
import ( |
||||
|
"flag" |
||||
|
"fmt" |
||||
|
"gorm_test/config" |
||||
|
"gorm_test/database" |
||||
|
"gorm_test/model" |
||||
|
"os" |
||||
|
) |
||||
|
|
||||
|
var ( |
||||
|
appConfig = flag.String("appConfig", "configIni/appConfig.ini", "app配置文件") |
||||
|
) |
||||
|
|
||||
|
func main() { |
||||
|
flag.Parse() |
||||
|
getAppConfig := config.LoadSystemConfig(*appConfig) |
||||
|
if getAppConfig != nil { |
||||
|
os.Exit(3) |
||||
|
} |
||||
|
database.DataBaseLoadName = config.Appconfig.MasterDatabase |
||||
|
// DataBaseLoadName = config.Appconfig.MasterDatabase
|
||||
|
// fmt.Printf("%v\n", config.Appconfig)
|
||||
|
|
||||
|
// fmt.Printf("%v\n", database.InitDB())
|
||||
|
// fmt.Printf("%v\n", database.SwitchDatabase("BookDate"))
|
||||
|
// fmt.Printf("%v\n", database.InitDB())
|
||||
|
|
||||
|
db1 := database.InitDB() |
||||
|
db2 := database.SwitchDatabase("BookDate") |
||||
|
db3 := database.InitDB() |
||||
|
var answer model.Answer |
||||
|
err := db1.First(&answer).Error |
||||
|
var searchlog model.Searchlog |
||||
|
err = db2.First(&searchlog).Error |
||||
|
var carType model.CarType |
||||
|
err = db3.First(&carType).Error |
||||
|
if err != nil { |
||||
|
fmt.Println("查询失败!") |
||||
|
} |
||||
|
// fmt.Printf("%v\n", answer)
|
||||
|
fmt.Printf("------->%v\n+++++++++++%v\n@@@@@@@@@@%v\n", &answer, &searchlog, &carType) |
||||
|
// db, err := gorm.Open(mysql.New(mysql.Config{
|
||||
|
// DSN: "root:root@tcp(127.0.0.1:3306)/ceshi?charset=utf8mb4&parseTime=True&loc=Local",
|
||||
|
// DefaultStringSize: 171,
|
||||
|
// }), &gorm.Config{
|
||||
|
// SkipDefaultTransaction: false,
|
||||
|
// NamingStrategy: schema.NamingStrategy{
|
||||
|
// TablePrefix: "",
|
||||
|
// SingularTable: true,
|
||||
|
// },
|
||||
|
// DisableForeignKeyConstraintWhenMigrating: true,
|
||||
|
// })
|
||||
|
|
||||
|
// // type AnswerTestingw struct {
|
||||
|
// // Id int64 `json:"a_id" gorm:"column:a_id"`
|
||||
|
// // Text string `json:"a_text" gorm:"column:a_text"` //'答案',
|
||||
|
// // TrueOrFalse int8 //'是否为正确答案(1:正确;2:错误)',
|
||||
|
// // Type int8 //'类型(1:单选;2:多选;3:判断)',
|
||||
|
// // Key int64 //'唯一识别符',
|
||||
|
// // }
|
||||
|
// errs := db.AutoMigrate(&model.Subjecting{})
|
||||
|
// fmt.Printf("%v=>%v=>%v", db, err, errs)
|
||||
|
} |
||||
|
|||||
@ -0,0 +1,13 @@ |
|||||
|
package model |
||||
|
|
||||
|
type Answer struct { |
||||
|
Id int64 `json:"id" gorm:"column:a_id;type:bigint(20);;primaryKey;unique;not null;autoIncrement;index"` |
||||
|
Text string `json:"text" gorm:"column:a_text;type:text;not null;comment:答案"` //'答案',
|
||||
|
TrueFalse int8 `json:"truefalse" gorm:"column:a_true_false;type:tinyint(1) unsigned;default:1;not null;comment:是否为正确答案(1:正确;2:错误)"` //'是否为正确答案(1:正确;2:错误)',
|
||||
|
Type int8 `json:"type" gorm:"column:a_type;type:tinyint(1) unsigned;default:1;not null;comment:是否为正确答案(1:正确;2:错误)"` //'类型(1:单选;2:多选;3:判断)',
|
||||
|
Key int64 `json:"key" gorm:"column:a_key;type:bigint(50) unsigned;default:0;not null;comment:创建人"` //'唯一识别符',
|
||||
|
} |
||||
|
|
||||
|
func (Answer *Answer) TableName() string { |
||||
|
return "answer" |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
package model |
||||
|
|
||||
|
type CarType struct { |
||||
|
Id int64 `json:"id" gorm:"column:ct_id;type:bigint(20);;primaryKey;unique;not null;autoIncrement;index"` |
||||
|
Type string `json:"type" gorm:"column:ct_type;type:text;not null;comment:答案"` //'类型名称',
|
||||
|
State int8 `json:"state" gorm:"column:ct_state;type:tinyint(1) unsigned;default:1;not null;comment:'状态(1:启用;2:禁用)'"` //'状态(1:启用;2:禁用)',
|
||||
|
Time int64 `json:"time" gorm:"column:ct_time;type:bigint(20) unsigned;default:0;not null;comment:时间"` //'时间',
|
||||
|
} |
||||
|
|
||||
|
func (cartype *CarType) TableName() string { |
||||
|
return "car_type" |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
package model |
||||
|
|
||||
|
type Searchlog struct { |
||||
|
Id int64 `json:"id" gorm:"column:sea_id;type:bigint(20);;primaryKey;unique;not null;autoIncrement;index"` |
||||
|
Cont string `json:"cont" gorm:"column:sea_cont;type:varchar(255);not null;comment:关键词"` //'关键词',
|
||||
|
UserKey int64 `json:"userkey" gorm:"column:sea_user_key;type:bigint(20) unsigned;default:0;not null;comment:搜索人"` //'搜索人',
|
||||
|
Num int8 `json:"num" gorm:"column:sea_num;type:int(5) unsigned;default:1;not null;comment:'搜索次数'"` //'搜索次数',
|
||||
|
Time int64 `json:"time" gorm:"column:sea_time;type:bigint(20) unsigned;default:0;not null;comment:时间"` //'时间',
|
||||
|
State int8 `json:"state" gorm:"column:sea_state;type:tinyint(1) unsigned;default:1;not null;comment:'状态(1:启用,2:删除)'"` //'1:启用,2:删除',
|
||||
|
} |
||||
|
|
||||
|
func (searchlog *Searchlog) TableName() string { |
||||
|
return "searchlog" |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
package model |
||||
|
|
||||
|
type Subjecting struct { |
||||
|
Id int64 `json:"id" gorm:"column:s_id;type:bigint(20);;primaryKey;unique;not null;autoIncrement;index"` |
||||
|
Title string `json:"title" gorm:"column:s_title;type:text;not null;comment:题目"` //'题目',
|
||||
|
State int8 `json:"state" gorm:"column:s_state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除"` //'状态(1:启用;2:禁用;3:删除)',
|
||||
|
Examination int64 `json:"examination" gorm:"column:s_examination;type:bigint(20) unsigned;default:0;not null;comment:分厂"` //'分厂',
|
||||
|
Set int8 `json:"set" gorm:"column:s_set;type:tinyint(1) unsigned;default:1;not null;comment:是否为共享(1:非共享;2:共享)"` //'是否为共享(1:非共享;2:共享)',
|
||||
|
Time int64 `json:"time" gorm:"column:s_time;type:bigint(30) unsigned;default:0;not null;comment:创建时间"` //'创建时间',
|
||||
|
EiteTime int64 `json:"eitetime" gorm:"column:s_eite_time;type:bigint(30) unsigned;default:0;not null;comment:修改时间"` //'修改时间',
|
||||
|
SystemUser int64 `json:"systemuser" gorm:"column:s_system_user;type:bigint(50) unsigned;default:0;not null;comment:创建人"` //'创建人',
|
||||
|
SetType int8 `json:"type" gorm:"column:s_type;type:tinyint(1) unsigned;default:1;not null;comment:类型(1:单选;2:多选;3:判断)"` //'类型(1:单选;2:多选;3:判断)',
|
||||
|
Work int64 `json:"work" gorm:"column:s_work;type:bigint(20) unsigned;default:0;not null;comment:工段"` //'工段',
|
||||
|
Postiton int64 `json:"postiton" gorm:"column:s_postiton;type:bigint(20) unsigned;default:0;not null;comment:职务"` //'职务',
|
||||
|
Weight int `json:"weight" gorm:"column:s_weight;type:smallint(4) unsigned;default:0;not null;comment:权重"` //'权重',
|
||||
|
Key int64 `json:"key" gorm:"column:s_key;type:bigint(50) unsigned;default:1;not null;comment:唯一识别符"` //'唯一识别符',
|
||||
|
Text string `json:"text" gorm:"column:s_text;type:text;not null;comment:题目解释"` //'题目解释',
|
||||
|
ShareNumber int64 `json:"sharenumber" gorm:"column:s_share_number;type:bigint(50) unsigned;default:0;not null;comment:共享识别符"` //'共享识别符',
|
||||
|
SpaceNum int8 `json:"spacenum" gorm:"column:s_space_num;type:tinyint(2) unsigned;default:1;not null;comment:空格"` //空格',
|
||||
|
OneExam int64 `json:"oneexam" gorm:"column:s_one_exam;type:bigint(20) unsigned;default:0;not null;comment:单一考试试题"` //'单一考试试题',
|
||||
|
Special int8 `json:"special" gorm:"column:s_special;type:tinyint(1) unsigned;default:1;not null;comment:专项考试(1:不是;2:是)"` //'专项考试(1:不是;2:是)',
|
||||
|
Group int64 `json:"group" gorm:"column:s_group;type:int(10) unsigned;default:3;not null;comment:归属集团"` //'归属集团',
|
||||
|
} |
||||
Loading…
Reference in new issue