You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
136 lines
3.4 KiB
136 lines
3.4 KiB
package models
|
|
|
|
import (
|
|
"time"
|
|
config "automatedtesting/usecases_server/config"
|
|
log "automatedtesting/usecases_server/utils/cyllib/log"
|
|
|
|
"gorm.io/driver/mysql"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
var db *gorm.DB
|
|
|
|
func init() {
|
|
var err error
|
|
username := config.GetConfig().Database.Username
|
|
userpass := config.GetConfig().Database.Password
|
|
host := config.GetConfig().Database.Host
|
|
port := config.GetConfig().Database.Port
|
|
name := config.GetConfig().Database.Name
|
|
other := config.GetConfig().Database.Other
|
|
dsn := username + ":" + userpass + "@tcp(" + host + ":" + port + ")/" + name + other
|
|
db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{}) //Logger: logger.Default.LogMode(logger.Info)
|
|
if err != nil {
|
|
log.WriteErr(err)
|
|
}
|
|
}
|
|
func GetDb() *gorm.DB {
|
|
return db
|
|
}
|
|
|
|
type Users struct {
|
|
Id int //`orm:"pk:auto"` //设置主键并自动增长,可以不写,自动是这个配置
|
|
Name string //`orm:"null;colummn(name)"` //允许为null,指定名字
|
|
Username string
|
|
Password string //`orm:"index:unrque"` //索引
|
|
Power bool
|
|
Token string //`orm:"-"` //如果某些字段不需要迁移,这里加一个-就行
|
|
|
|
}
|
|
|
|
func (u *Users) TableName() string {
|
|
return "users"
|
|
}
|
|
|
|
type Groups struct {
|
|
Id int `json:"id"`
|
|
Uid int `json:"uid"`
|
|
Name string `json:"name"`
|
|
CreateTime time.Time `json:"create_time"`
|
|
ExeTime time.Time `json:"exe_time"`
|
|
DefWaitTime int `json:"def_wait_time"`
|
|
DefBetweenTime int `json:"def_between_time"`
|
|
DefSingleNum int `json:"def_single_num"`
|
|
DefSingleFailNum int `json:"def_single_fail_num"`
|
|
AllNum int `json:"all_num"`
|
|
|
|
Version string `json:"version"`
|
|
}
|
|
|
|
func (u *Groups) TableName() string {
|
|
return "groups"
|
|
}
|
|
|
|
// omitempty
|
|
type Cases struct {
|
|
Id int `json:"id"`
|
|
Gid int `json:"gid"`
|
|
Indexes int `json:"indexes"`
|
|
Module string `json:"module"`
|
|
ChildModule string `json:"child_module"`
|
|
Title string `json:"title"`
|
|
Step string `json:"step"`
|
|
Expect string `json:"expect"`
|
|
SingleNum string `json:"single_num"`
|
|
Real string `json:"real"`
|
|
Result string `json:"result"`
|
|
Note string `json:"note"`
|
|
}
|
|
|
|
func (u *Cases) TableName() string {
|
|
return "cases"
|
|
}
|
|
|
|
// type Step struct {
|
|
// Id int `json:"id"`
|
|
// Gid int `json:"gid"`
|
|
// Cid int `json:"cid"`
|
|
// Indexes int `json:"indexes"`
|
|
// Step string `json:"step"`
|
|
// Expect string `json:"expect"`
|
|
// // Cache int `grom:"cache,omitempty"`
|
|
// }
|
|
|
|
// func (u *Step) TableName() string {
|
|
// return "step"
|
|
// }
|
|
|
|
type WaitTime struct {
|
|
Id int `json:"id"`
|
|
Gid int `json:"gid"`
|
|
Indexes int `json:"indexes"`
|
|
ChildModule string `json:"child_module"`
|
|
WaitTime int `json:"waittime"`
|
|
BetweenTime int `json:"between_time"`
|
|
}
|
|
|
|
func (u *WaitTime) TableName() string {
|
|
return "waittime"
|
|
}
|
|
|
|
type Task struct {
|
|
Id int `json:"id"`
|
|
Gid int `json:"gid"`
|
|
BeginTime int `json:"begin_time"`
|
|
EndTime string `json:"end_time"`
|
|
}
|
|
|
|
func (u *Task) TableName() string {
|
|
return "task"
|
|
}
|
|
|
|
type TaskLog struct {
|
|
Id int `json:"id"`
|
|
Tid int `json:"tid"`
|
|
Sid int `json:"sid"`
|
|
Title string `json:"title"`
|
|
Duration string `json:"duration"`
|
|
RealResult int `json:"real_result"`
|
|
Step string `json:"step"`
|
|
Expect string `json:"expect"`
|
|
}
|
|
|
|
func (u *TaskLog) TableName() string {
|
|
return "tasklog"
|
|
}
|
|
|