mirror of
https://github.com/go-home-admin/toolset.git
synced 2026-04-23 00:27:03 +08:00
Merge branch 'feature/pgsql' into develop
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/ctfang/command"
|
||||
"github.com/go-home-admin/toolset/console/commands/orm"
|
||||
"github.com/go-home-admin/toolset/console/commands/pgorm"
|
||||
"github.com/joho/godotenv"
|
||||
"gopkg.in/yaml.v2"
|
||||
"os"
|
||||
@@ -51,9 +52,9 @@ func (OrmCommand) Execute(input command.Input) {
|
||||
fileContext = SetEnv(fileContext)
|
||||
m := make(map[string]interface{})
|
||||
err = yaml.Unmarshal(fileContext, &m)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
//if err != nil {
|
||||
// panic(err)
|
||||
//}
|
||||
|
||||
connections := m["connections"].(map[interface{}]interface{})
|
||||
for s, confT := range connections {
|
||||
@@ -63,8 +64,8 @@ func (OrmCommand) Execute(input command.Input) {
|
||||
switch driver {
|
||||
case "mysql":
|
||||
orm.GenMysql(s.(string), conf, out)
|
||||
case "postgresql":
|
||||
|
||||
case "pgsql":
|
||||
pgorm.GenSql(s.(string), conf, out)
|
||||
}
|
||||
|
||||
cmd := exec.Command("go", []string{"fmt", out}...)
|
||||
|
||||
@@ -0,0 +1,448 @@
|
||||
package pgorm
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"github.com/go-home-admin/home/bootstrap/services"
|
||||
"github.com/go-home-admin/toolset/parser"
|
||||
_ "github.com/lib/pq"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// IsExist checks whether a file or directory exists.
|
||||
// It returns false when the file or directory does not exist.
|
||||
func IsExist(f string) bool {
|
||||
_, err := os.Stat(f)
|
||||
return err == nil || os.IsExist(err)
|
||||
}
|
||||
|
||||
type Conf map[interface{}]interface{}
|
||||
|
||||
func GenSql(name string, conf Conf, out string) {
|
||||
if !IsExist(out) {
|
||||
os.MkdirAll(out, 0766)
|
||||
}
|
||||
|
||||
db := NewDb(conf)
|
||||
tableColumns := db.tableColumns()
|
||||
|
||||
// 计算import
|
||||
imports := getImports(tableColumns)
|
||||
for table, columns := range tableColumns {
|
||||
tableName := parser.StringToSnake(table)
|
||||
file := out + "/" + tableName
|
||||
|
||||
str := "package " + name
|
||||
str += "\nimport (" + imports[table] + "\n)"
|
||||
str += "\n" + genOrmStruct(table, columns, conf)
|
||||
|
||||
baseFunStr := baseMysqlFuncStr
|
||||
for old, newStr := range map[string]string{
|
||||
"{orm_table_name}": parser.StringToHump(table),
|
||||
"{table_name}": table,
|
||||
"{db}": name,
|
||||
} {
|
||||
baseFunStr = strings.ReplaceAll(baseFunStr, old, newStr)
|
||||
}
|
||||
|
||||
str += baseFunStr
|
||||
str += genFieldFunc(table, columns)
|
||||
str += genListFunc(table, columns)
|
||||
str += genWithFunc(table, columns, conf)
|
||||
err := os.WriteFile(file+"_gen.go", []byte(str), 0766)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func genListFunc(table string, columns []tableColumn) string {
|
||||
TableName := parser.StringToHump(table)
|
||||
str := "\ntype " + TableName + "List []*" + TableName
|
||||
for _, column := range columns {
|
||||
// 索引,或者枚举字段
|
||||
if strInStr(column.ColumnName, []string{"id", "code"}) {
|
||||
str += "\nfunc (l " + TableName + "List) Get" + column.ColumnName + "List() []" + column.GoType + " {" +
|
||||
"\n\tgot := make([]" + column.GoType + ", 0)\n\tfor _, val := range l {" +
|
||||
"\n\t\tgot = append(got, val." + column.ColumnName + ")" +
|
||||
"\n\t}" +
|
||||
"\n\treturn got" +
|
||||
"\n}"
|
||||
|
||||
str += "\nfunc (l " + TableName + "List) Get" + column.ColumnName + "Map() map[" + column.GoType + "]*" + TableName + " {" +
|
||||
"\n\tgot := make(map[" + column.GoType + "]*" + TableName + ")\n\tfor _, val := range l {" +
|
||||
"\n\t\tgot[val." + column.ColumnName + "] = val" +
|
||||
"\n\t}" +
|
||||
"\n\treturn got" +
|
||||
"\n}"
|
||||
}
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
func genWithFunc(table string, columns []tableColumn, conf Conf) string {
|
||||
TableName := parser.StringToHump(table)
|
||||
str := ""
|
||||
if helper, ok := conf["helper"]; ok {
|
||||
helperConf := helper.(map[interface{}]interface{})
|
||||
tableConfig, ok := helperConf[table].([]interface{})
|
||||
if ok {
|
||||
for _, c := range tableConfig {
|
||||
cf := c.(map[interface{}]interface{})
|
||||
with := cf["with"]
|
||||
tbName := parser.StringToHump(cf["table"].(string))
|
||||
switch with {
|
||||
case "many2many":
|
||||
|
||||
default:
|
||||
str += "\nfunc (orm *Orm" + TableName + ") Joins" + tbName + "(args ...interface{}) *Orm" + TableName + " {" +
|
||||
"\n\torm.db.Joins(\"" + cf["alias"].(string) + "\", args...)" +
|
||||
"\n\treturn orm" +
|
||||
"\n}"
|
||||
str += "\nfunc (orm *Orm" + TableName + ") Preload" + tbName + "(args ...interface{}) *Orm" + TableName + " {" +
|
||||
"\n\torm.db.Preload(\"" + cf["alias"].(string) + "\", args...)" +
|
||||
"\n\treturn orm" +
|
||||
"\n}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
func genFieldFunc(table string, columns []tableColumn) string {
|
||||
TableName := parser.StringToHump(table)
|
||||
|
||||
str := ""
|
||||
for _, column := range columns {
|
||||
// 等于函数
|
||||
str += "\nfunc (orm *Orm" + TableName + ") Where" + column.ColumnName + "(val " + column.GoType + ") *Orm" + TableName + " {" +
|
||||
"\n\torm.db.Where(\"`" + column.ColumnName + "` = ?\", val)" +
|
||||
"\n\treturn orm" +
|
||||
"\n}"
|
||||
|
||||
if column.IsPKey {
|
||||
// if 主键, 生成In, > <
|
||||
str += "\nfunc (orm *Orm" + TableName + ") InsertGet" + column.ColumnName + "(row *" + TableName + ") " + column.GoType + " {" +
|
||||
"\n\torm.db.Create(row)" +
|
||||
"\n\treturn row." + column.ColumnName +
|
||||
"\n}"
|
||||
|
||||
str += "\nfunc (orm *Orm" + TableName + ") Where" + column.ColumnName + "In(val []" + column.GoType + ") *Orm" + TableName + " {" +
|
||||
"\n\torm.db.Where(\"`" + column.ColumnName + "` IN ?\", val)" +
|
||||
"\n\treturn orm" +
|
||||
"\n}"
|
||||
|
||||
str += "\nfunc (orm *Orm" + TableName + ") Where" + column.ColumnName + "Gt(val " + column.GoType + ") *Orm" + TableName + " {" +
|
||||
"\n\torm.db.Where(\"`" + column.ColumnName + "` > ?\", val)" +
|
||||
"\n\treturn orm" +
|
||||
"\n}"
|
||||
str += "\nfunc (orm *Orm" + TableName + ") Where" + column.ColumnName + "Gte(val " + column.GoType + ") *Orm" + TableName + " {" +
|
||||
"\n\torm.db.Where(\"`" + column.ColumnName + "` >= ?\", val)" +
|
||||
"\n\treturn orm" +
|
||||
"\n}"
|
||||
|
||||
str += "\nfunc (orm *Orm" + TableName + ") Where" + column.ColumnName + "Lt(val " + column.GoType + ") *Orm" + TableName + " {" +
|
||||
"\n\torm.db.Where(\"`" + column.ColumnName + "` < ?\", val)" +
|
||||
"\n\treturn orm" +
|
||||
"\n}"
|
||||
str += "\nfunc (orm *Orm" + TableName + ") Where" + column.ColumnName + "Lte(val " + column.GoType + ") *Orm" + TableName + " {" +
|
||||
"\n\torm.db.Where(\"`" + column.ColumnName + "` <= ?\", val)" +
|
||||
"\n\treturn orm" +
|
||||
"\n}"
|
||||
} else {
|
||||
// 索引,或者枚举字段
|
||||
if strInStr(column.ColumnName, []string{"id", "code", "status", "state"}) {
|
||||
// else if 名称存在 id, code, status 生成in操作
|
||||
str += "\nfunc (orm *Orm" + TableName + ") Where" + column.ColumnName + "In(val []" + column.GoType + ") *Orm" + TableName + " {" +
|
||||
"\n\torm.db.Where(\"`" + column.ColumnName + "` IN ?\", val)" +
|
||||
"\n\treturn orm" +
|
||||
"\n}"
|
||||
|
||||
str += "\nfunc (orm *Orm" + TableName + ") Where" + column.ColumnName + "Ne(val " + column.GoType + ") *Orm" + TableName + " {" +
|
||||
"\n\torm.db.Where(\"`" + column.ColumnName + "` <> ?\", val)" +
|
||||
"\n\treturn orm" +
|
||||
"\n}"
|
||||
}
|
||||
// 时间字段
|
||||
if strInStr(column.ColumnName, []string{"created", "updated", "time", "_at"}) || (column.GoType == "database.Time") {
|
||||
str += "\nfunc (orm *Orm" + TableName + ") Where" + column.ColumnName + "Between(begin " + column.GoType + ", end " + column.GoType + ") *Orm" + TableName + " {" +
|
||||
"\n\torm.db.Where(\"`" + column.ColumnName + "` BETWEEN ? AND ?\", begin, end)" +
|
||||
"\n\treturn orm" +
|
||||
"\n}"
|
||||
|
||||
str += "\nfunc (orm *Orm" + TableName + ") Where" + column.ColumnName + "Lte(val " + column.GoType + ") *Orm" + TableName + " {" +
|
||||
"\n\torm.db.Where(\"`" + column.ColumnName + "` <= ?\", val)" +
|
||||
"\n\treturn orm" +
|
||||
"\n}"
|
||||
|
||||
str += "\nfunc (orm *Orm" + TableName + ") Where" + column.ColumnName + "Gte(val " + column.GoType + ") *Orm" + TableName + " {" +
|
||||
"\n\torm.db.Where(\"`" + column.ColumnName + "` >= ?\", val)" +
|
||||
"\n\treturn orm" +
|
||||
"\n}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
func strInStr(s string, in []string) bool {
|
||||
for _, sub := range in {
|
||||
if strings.Index(s, sub) != -1 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
//go:embed pgsql.go.text
|
||||
var baseMysqlFuncStr string
|
||||
|
||||
// 字段类型引入
|
||||
var alias = map[string]string{
|
||||
"database": "github.com/go-home-admin/home/bootstrap/services/database",
|
||||
"datatypes": "gorm.io/datatypes",
|
||||
}
|
||||
|
||||
// 获得 table => map{alias => github.com/*}
|
||||
func getImports(tableColumns map[string][]tableColumn) map[string]string {
|
||||
got := make(map[string]string)
|
||||
for table, columns := range tableColumns {
|
||||
// 初始引入
|
||||
tm := map[string]string{
|
||||
"gorm.io/gorm": "gorm",
|
||||
"github.com/go-home-admin/home/bootstrap/providers": "providers",
|
||||
"github.com/sirupsen/logrus": "logrus",
|
||||
"database/sql": "sql",
|
||||
}
|
||||
for _, column := range columns {
|
||||
index := strings.Index(column.GoType, ".")
|
||||
if index != -1 && column.GoType[:index] != "gorm" {
|
||||
as := strings.Replace(column.GoType[:index], "*", "", 1)
|
||||
importStr := alias[as]
|
||||
tm[importStr] = as
|
||||
}
|
||||
}
|
||||
got[table] = parser.GetImportStrForMap(tm)
|
||||
}
|
||||
|
||||
return got
|
||||
}
|
||||
|
||||
func genOrmStruct(table string, columns []tableColumn, conf Conf) string {
|
||||
TableName := parser.StringToHump(table)
|
||||
|
||||
hasField := make(map[string]bool)
|
||||
str := `type {TableName} struct {`
|
||||
for _, column := range columns {
|
||||
p := ""
|
||||
if column.IsNullable {
|
||||
p = "*"
|
||||
}
|
||||
hasField[column.ColumnName] = true
|
||||
fieldName := parser.StringToHump(column.ColumnName)
|
||||
str += fmt.Sprintf("\n\t%v %v%v`%v` // %v", fieldName, p, column.GoType, genGormTag(column), strings.ReplaceAll(column.Comment, "\n", " "))
|
||||
}
|
||||
// 表依赖
|
||||
if helper, ok := conf["helper"]; ok {
|
||||
helperConf := helper.(map[interface{}]interface{})
|
||||
tableConfig, ok := helperConf[table].([]interface{})
|
||||
if ok {
|
||||
for _, c := range tableConfig {
|
||||
cf := c.(map[interface{}]interface{})
|
||||
with := cf["with"]
|
||||
tbName := parser.StringToHump(cf["table"].(string))
|
||||
switch with {
|
||||
case "belongs_to":
|
||||
str += fmt.Sprintf("\n\t%v %v `gorm:\"%v\"`", parser.StringToHump(cf["alias"].(string)), tbName, cf["gorm"])
|
||||
case "has_one":
|
||||
str += fmt.Sprintf("\n\t%v %v `gorm:\"%v\"`", parser.StringToHump(cf["alias"].(string)), tbName, cf["gorm"])
|
||||
case "has_many":
|
||||
str += fmt.Sprintf("\n\t%v []%v `gorm:\"%v\"`", parser.StringToHump(cf["alias"].(string)), tbName, cf["gorm"])
|
||||
case "many2many":
|
||||
str += fmt.Sprintf("\n\t%v []%v `gorm:\"%v\"`", parser.StringToHump(cf["alias"].(string)), tbName, cf["gorm"])
|
||||
default:
|
||||
panic("with: belongs_to,has_one,has_many,many2many")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
str = strings.ReplaceAll(str, "{TableName}", TableName)
|
||||
return "\n" + str + "\n}"
|
||||
}
|
||||
|
||||
func genGormTag(column tableColumn) string {
|
||||
var arr []string
|
||||
// 字段
|
||||
arr = append(arr, "column:"+column.ColumnName)
|
||||
if column.ColumnDefault == "CURRENT_TIMESTAMP" {
|
||||
arr = append(arr, "autoUpdateTime")
|
||||
}
|
||||
if strings.Contains(column.ColumnDefault, "nextval") {
|
||||
arr = append(arr, "autoIncrement")
|
||||
}
|
||||
// 类型ing
|
||||
arr = append(arr, "type:"+column.PgType)
|
||||
// 主键
|
||||
if column.IsPKey {
|
||||
arr = append(arr, "primaryKey")
|
||||
}
|
||||
// default
|
||||
if column.ColumnDefault != "" {
|
||||
arr = append(arr, "default:"+column.ColumnDefault)
|
||||
}
|
||||
|
||||
if column.Comment != "" {
|
||||
arr = append(arr, fmt.Sprintf("comment:'%v'", strings.ReplaceAll(column.Comment, "'", "")))
|
||||
}
|
||||
str := ""
|
||||
for i := 0; i < len(arr)-1; i++ {
|
||||
str += arr[i] + ";"
|
||||
}
|
||||
str += "" + arr[len(arr)-1]
|
||||
return "gorm:\"" + str + "\""
|
||||
}
|
||||
|
||||
type DB struct {
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
func (d *DB) tableColumns() map[string][]tableColumn {
|
||||
var sqlStr = "SELECT tablename FROM pg_tables WHERE schemaname = 'public'"
|
||||
|
||||
rows, err := d.db.Query(sqlStr)
|
||||
if err != nil {
|
||||
log.Println("Error reading table information: ", err.Error())
|
||||
return nil
|
||||
}
|
||||
defer rows.Close()
|
||||
ormColumns := make(map[string][]tableColumn)
|
||||
for rows.Next() {
|
||||
var tableName string
|
||||
var pkey string
|
||||
_ = rows.Scan(
|
||||
&tableName,
|
||||
)
|
||||
_rows, _ := d.db.Query(`
|
||||
SELECT i.column_name, i.column_default, i.is_nullable, i.udt_name, col_description(a.attrelid,a.attnum) as comment
|
||||
FROM information_schema.columns as i
|
||||
LEFT JOIN pg_class as c on c.relname = i.table_name
|
||||
LEFT JOIN pg_attribute as a on a.attrelid = c.oid and a.attname = i.column_name
|
||||
WHERE table_schema = 'public' and i.table_name = $1;
|
||||
`, tableName)
|
||||
defer _rows.Close()
|
||||
//获取主键
|
||||
__rows, _ := d.db.Query(`
|
||||
SELECT pg_attribute.attname
|
||||
FROM pg_constraint
|
||||
INNER JOIN pg_class ON pg_constraint.conrelid = pg_class.oid
|
||||
INNER JOIN pg_attribute ON pg_attribute.attrelid = pg_class.oid
|
||||
AND pg_attribute.attnum = pg_constraint.conkey [ 1 ]
|
||||
INNER JOIN pg_type ON pg_type.oid = pg_attribute.atttypid
|
||||
WHERE pg_class.relname = $1 AND pg_constraint.contype = 'p'
|
||||
`, tableName)
|
||||
defer __rows.Close()
|
||||
for __rows.Next() {
|
||||
_ = __rows.Scan(&pkey)
|
||||
}
|
||||
for _rows.Next() {
|
||||
var (
|
||||
column_name string
|
||||
column_default *string
|
||||
is_nullable string
|
||||
udt_name string
|
||||
comment *string
|
||||
)
|
||||
err = _rows.Scan(&column_name, &column_default, &is_nullable, &udt_name, &comment)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
var columnComment string
|
||||
if comment != nil {
|
||||
columnComment = *comment
|
||||
}
|
||||
var ColumnDefault string
|
||||
if column_default != nil {
|
||||
ColumnDefault = *column_default
|
||||
}
|
||||
|
||||
ormColumns[tableName] = append(ormColumns[tableName], tableColumn{
|
||||
ColumnName: parser.StringToHump(column_name),
|
||||
ColumnDefault: ColumnDefault,
|
||||
PgType: udt_name,
|
||||
GoType: PgTypeToGoType(udt_name, column_name),
|
||||
IsNullable: is_nullable == "YES",
|
||||
IsPKey: false,
|
||||
Comment: columnComment,
|
||||
})
|
||||
}
|
||||
}
|
||||
return ormColumns
|
||||
}
|
||||
|
||||
type tableColumn struct {
|
||||
// 驼峰命名的字段
|
||||
ColumnName string
|
||||
ColumnDefault string
|
||||
PgType string
|
||||
GoType string
|
||||
IsNullable bool
|
||||
IsPKey bool
|
||||
Comment string
|
||||
}
|
||||
|
||||
func PgTypeToGoType(pgType string, columnName string) string {
|
||||
switch pgType {
|
||||
case "int2", "int4":
|
||||
return "int32"
|
||||
case "int8":
|
||||
return "int64"
|
||||
case "date":
|
||||
return "datatypes.Date"
|
||||
case "json", "jsonb":
|
||||
return "database.JSON"
|
||||
case "time", "timetz":
|
||||
return "database.Time"
|
||||
case "numeric":
|
||||
return "float64"
|
||||
default:
|
||||
if strings.Contains(pgType, "timestamp") {
|
||||
if columnName == "deleted_at" {
|
||||
return "gorm.DeletedAt"
|
||||
} else {
|
||||
return "database.Time"
|
||||
}
|
||||
}
|
||||
return "string"
|
||||
}
|
||||
}
|
||||
|
||||
func NewDb(conf map[interface{}]interface{}) *DB {
|
||||
config := services.NewConfig(conf)
|
||||
connStr := fmt.Sprintf(
|
||||
"postgres://%s:%s@%s:%d/%s?sslmode=disable",
|
||||
config.GetString("username", "root"),
|
||||
config.GetString("password", "123456"),
|
||||
config.GetString("host", "localhost:"),
|
||||
config.GetInt("port", 5432),
|
||||
config.GetString("database", "demo"),
|
||||
)
|
||||
db, err := sql.Open("postgres", connStr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// See "Important settings" section.
|
||||
db.SetConnMaxLifetime(time.Minute * 3)
|
||||
db.SetMaxOpenConns(10)
|
||||
db.SetMaxIdleConns(10)
|
||||
|
||||
return &DB{
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
|
||||
func (receiver *{orm_table_name}) TableName() string {
|
||||
return "{table_name}"
|
||||
}
|
||||
|
||||
type Orm{orm_table_name} struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewOrm{orm_table_name}() *Orm{orm_table_name} {
|
||||
orm := &Orm{orm_table_name}{}
|
||||
orm.db = providers.NewMysqlProvider().GetBean("{db}").(*gorm.DB)
|
||||
return orm
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) GetDB() *gorm.DB {
|
||||
return orm.db
|
||||
}
|
||||
|
||||
// Create insert the value into database
|
||||
func (orm *Orm{orm_table_name}) Create(value interface{}) *gorm.DB {
|
||||
return orm.db.Create(value)
|
||||
}
|
||||
|
||||
// CreateInBatches insert the value in batches into database
|
||||
func (orm *Orm{orm_table_name}) CreateInBatches(value interface{}, batchSize int) *gorm.DB {
|
||||
return orm.db.CreateInBatches(value, batchSize)
|
||||
}
|
||||
|
||||
// Save update value in database, if the value doesn't have primary key, will insert it
|
||||
func (orm *Orm{orm_table_name}) Save(value interface{}) *gorm.DB {
|
||||
return orm.db.Save(value)
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) Row() *sql.Row {
|
||||
return orm.db.Row()
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) Rows() (*sql.Rows, error) {
|
||||
return orm.db.Rows()
|
||||
}
|
||||
|
||||
// Scan scan value to a struct
|
||||
func (orm *Orm{orm_table_name}) Scan(dest interface{}) *gorm.DB {
|
||||
return orm.db.Scan(dest)
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) ScanRows(rows *sql.Rows, dest interface{}) error {
|
||||
return orm.db.ScanRows(rows, dest)
|
||||
}
|
||||
|
||||
// Connection use a db conn to execute Multiple commands,this conn will put conn pool after it is executed.
|
||||
func (orm *Orm{orm_table_name}) Connection(fc func(tx *gorm.DB) error) (err error) {
|
||||
return orm.db.Connection(fc)
|
||||
}
|
||||
|
||||
// Transaction start a transaction as a block, return error will rollback, otherwise to commit.
|
||||
func (orm *Orm{orm_table_name}) Transaction(fc func(tx *gorm.DB) error, opts ...*sql.TxOptions) (err error) {
|
||||
return orm.db.Transaction(fc, opts...)
|
||||
}
|
||||
|
||||
// Begin begins a transaction
|
||||
func (orm *Orm{orm_table_name}) Begin(opts ...*sql.TxOptions) *gorm.DB {
|
||||
return orm.db.Begin(opts...)
|
||||
}
|
||||
|
||||
// Commit commit a transaction
|
||||
func (orm *Orm{orm_table_name}) Commit() *gorm.DB {
|
||||
return orm.db.Commit()
|
||||
}
|
||||
|
||||
// Rollback rollback a transaction
|
||||
func (orm *Orm{orm_table_name}) Rollback() *gorm.DB {
|
||||
return orm.db.Rollback()
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) SavePoint(name string) *gorm.DB {
|
||||
return orm.db.SavePoint(name)
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) RollbackTo(name string) *gorm.DB {
|
||||
return orm.db.RollbackTo(name)
|
||||
}
|
||||
|
||||
// Exec execute raw sql
|
||||
func (orm *Orm{orm_table_name}) Exec(sql string, values ...interface{}) *gorm.DB {
|
||||
return orm.db.Exec(sql, values...)
|
||||
}
|
||||
|
||||
// ------------ 以下是单表独有的函数, 便捷字段条件, Laravel风格操作 ---------
|
||||
|
||||
func (orm *Orm{orm_table_name}) Insert(row *{orm_table_name}) *gorm.DB {
|
||||
return orm.db.Create(row)
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) Inserts(rows []*{orm_table_name}) *gorm.DB {
|
||||
return orm.db.Create(rows)
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) Order(value interface{}) *Orm{orm_table_name} {
|
||||
orm.db.Order(value)
|
||||
return orm
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) Limit(limit int) *Orm{orm_table_name} {
|
||||
orm.db.Limit(limit)
|
||||
return orm
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) Offset(offset int) *Orm{orm_table_name} {
|
||||
orm.db.Offset(offset)
|
||||
return orm
|
||||
}
|
||||
// 直接查询列表, 如果需要条数, 使用Find()
|
||||
func (orm *Orm{orm_table_name}) Get() {orm_table_name}List {
|
||||
got, _ := orm.Find()
|
||||
return got
|
||||
}
|
||||
|
||||
// Pluck used to query single column from a model as a map
|
||||
// var ages []int64
|
||||
// db.Model(&users).Pluck("age", &ages)
|
||||
func (orm *Orm{orm_table_name}) Pluck(column string, dest interface{}) *gorm.DB {
|
||||
return orm.db.Model(&{orm_table_name}{}).Pluck(column, dest)
|
||||
}
|
||||
|
||||
// Delete 有条件删除
|
||||
func (orm *Orm{orm_table_name}) Delete(conds ...interface{}) *gorm.DB {
|
||||
return orm.db.Delete(&{orm_table_name}{}, conds...)
|
||||
}
|
||||
|
||||
// DeleteAll 删除所有
|
||||
func (orm *Orm{orm_table_name}) DeleteAll() *gorm.DB {
|
||||
return orm.db.Exec("DELETE FROM {table_name}")
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) Count() int64 {
|
||||
var count int64
|
||||
orm.db.Model(&{orm_table_name}{}).Count(&count)
|
||||
return count
|
||||
}
|
||||
|
||||
// First 检索单个对象
|
||||
func (orm *Orm{orm_table_name}) First(conds ...interface{}) (*{orm_table_name}, bool) {
|
||||
dest := &{orm_table_name}{}
|
||||
db := orm.db.Limit(1).Find(dest, conds...)
|
||||
return dest, db.RowsAffected == 1
|
||||
}
|
||||
|
||||
// Take return a record that match given conditions, the order will depend on the database implementation
|
||||
func (orm *Orm{orm_table_name}) Take(conds ...interface{}) (*{orm_table_name}, int64) {
|
||||
dest := &{orm_table_name}{}
|
||||
db := orm.db.Take(dest, conds...)
|
||||
return dest, db.RowsAffected
|
||||
}
|
||||
|
||||
// Last find last record that match given conditions, order by primary key
|
||||
func (orm *Orm{orm_table_name}) Last(conds ...interface{}) (*{orm_table_name}, int64) {
|
||||
dest := &{orm_table_name}{}
|
||||
db := orm.db.Last(dest, conds...)
|
||||
return dest, db.RowsAffected
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) Find(conds ...interface{}) ({orm_table_name}List, int64) {
|
||||
list := make([]*{orm_table_name}, 0)
|
||||
tx := orm.db.Model(&{orm_table_name}{}).Find(&list, conds...)
|
||||
if tx.Error != nil {
|
||||
logrus.Error(tx.Error)
|
||||
}
|
||||
return list, tx.RowsAffected
|
||||
}
|
||||
|
||||
// FindInBatches find records in batches
|
||||
func (orm *Orm{orm_table_name}) FindInBatches(dest interface{}, batchSize int, fc func(tx *gorm.DB, batch int) error) *gorm.DB {
|
||||
return orm.db.FindInBatches(dest, batchSize, fc)
|
||||
}
|
||||
|
||||
// FirstOrInit gets the first matched record or initialize a new instance with given conditions (only works with struct or map conditions)
|
||||
func (orm *Orm{orm_table_name}) FirstOrInit(dest *{orm_table_name}, conds ...interface{}) (*{orm_table_name}, *gorm.DB) {
|
||||
return dest, orm.db.FirstOrInit(dest, conds...)
|
||||
}
|
||||
|
||||
// FirstOrCreate gets the first matched record or create a new one with given conditions (only works with struct, map conditions)
|
||||
func (orm *Orm{orm_table_name}) FirstOrCreate(dest interface{}, conds ...interface{}) *gorm.DB {
|
||||
return orm.db.FirstOrCreate(dest, conds...)
|
||||
}
|
||||
|
||||
// Update update attributes with callbacks, refer: https://gorm.io/docs/update.html#Update-Changed-Fields
|
||||
func (orm *Orm{orm_table_name}) Update(column string, value interface{}) *gorm.DB {
|
||||
return orm.db.Model(&{orm_table_name}{}).Update(column, value)
|
||||
}
|
||||
|
||||
// Updates update attributes with callbacks, refer: https://gorm.io/docs/update.html#Update-Changed-Fields
|
||||
func (orm *Orm{orm_table_name}) Updates(values interface{}) *gorm.DB {
|
||||
return orm.db.Model(&{orm_table_name}{}).Updates(values)
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) UpdateColumn(column string, value interface{}) *gorm.DB {
|
||||
return orm.db.Model(&{orm_table_name}{}).UpdateColumn(column, value)
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) UpdateColumns(values interface{}) *gorm.DB {
|
||||
return orm.db.Model(&{orm_table_name}{}).UpdateColumns(values)
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) Where(query interface{}, args ...interface{}) *Orm{orm_table_name} {
|
||||
orm.db.Where(query, args...)
|
||||
return orm
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) And(fuc func(orm *Orm{orm_table_name})) *Orm{orm_table_name} {
|
||||
ormAnd := NewOrm{orm_table_name}()
|
||||
fuc(ormAnd)
|
||||
orm.db.Where(ormAnd.db)
|
||||
return orm
|
||||
}
|
||||
|
||||
func (orm *Orm{orm_table_name}) Or(fuc func(orm *Orm{orm_table_name})) *Orm{orm_table_name} {
|
||||
ormOr := NewOrm{orm_table_name}()
|
||||
fuc(ormOr)
|
||||
orm.db.Or(ormOr.db)
|
||||
return orm
|
||||
}
|
||||
@@ -4,8 +4,15 @@ go 1.16
|
||||
|
||||
require (
|
||||
github.com/ctfang/command v1.0.0
|
||||
github.com/gin-gonic/gin v1.8.0 // indirect
|
||||
github.com/go-home-admin/home v0.0.3
|
||||
github.com/go-playground/validator/v10 v10.11.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.6.0
|
||||
github.com/joho/godotenv v1.4.0
|
||||
github.com/lib/pq v1.10.6
|
||||
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
|
||||
golang.org/x/net v0.0.0-20220531201128-c960675eff93 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
gorm.io/driver/mysql v1.3.4 // indirect
|
||||
gorm.io/gorm v1.23.5 // indirect
|
||||
)
|
||||
|
||||
@@ -16,8 +16,9 @@ github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWo
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs=
|
||||
github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U=
|
||||
github.com/gin-gonic/gin v1.8.0 h1:4WFH5yycBMA3za5Hnl425yd9ymdw1XPm4666oab+hv4=
|
||||
github.com/gin-gonic/gin v1.8.0/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk=
|
||||
github.com/go-home-admin/home v0.0.3 h1:ioBzk1jDna7mIbDtBafYrqQubSEStvELIN2b7YUNS2g=
|
||||
github.com/go-home-admin/home v0.0.3/go.mod h1:jT6EDGpkTBWfLOt14W2Gg462sqn1sleQknFYQAVb4Ro=
|
||||
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
|
||||
@@ -29,13 +30,17 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+
|
||||
github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
|
||||
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
|
||||
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
||||
github.com/go-playground/validator/v10 v10.10.1 h1:uA0+amWMiglNZKZ9FJRKUAe9U3RX91eVn1JYXMWt7ig=
|
||||
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
|
||||
github.com/go-playground/validator/v10 v10.10.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
|
||||
github.com/go-playground/validator/v10 v10.11.0 h1:0W+xRM511GY47Yy3bZUbJVitCNg2BOGlCyvTqsp/xIw=
|
||||
github.com/go-playground/validator/v10 v10.11.0/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
|
||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||
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/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/goccy/go-json v0.9.7 h1:IcB+Aqpx/iMHu5Yooh7jEzJk1JZ7Pjtmys2ukPr7EeM=
|
||||
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
@@ -45,7 +50,6 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
@@ -78,6 +82,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
|
||||
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
|
||||
github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs=
|
||||
github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
@@ -101,6 +107,8 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
|
||||
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
||||
github.com/pelletier/go-toml/v2 v2.0.1 h1:8e3L2cCQzLFi2CR4g7vGFuFxX7Jl1kKX8gW+iV0GUKU=
|
||||
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
@@ -118,8 +126,9 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo=
|
||||
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
|
||||
@@ -130,18 +139,22 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd h1:XcWmESyNjXJMLahc3mqVQJcgSTDxFxhETVlfk9uGc38=
|
||||
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM=
|
||||
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220531201128-c960675eff93 h1:MYimHLfoXEpOhqd/zgoA/uoXzHB86AEky4LAx5ij9xA=
|
||||
golang.org/x/net v0.0.0-20220531201128-c960675eff93/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -163,9 +176,11 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs=
|
||||
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
@@ -188,8 +203,9 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
@@ -207,8 +223,11 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/mysql v1.3.2 h1:QJryWiqQ91EvZ0jZL48NOpdlPdMjdip1hQ8bTgo4H7I=
|
||||
gorm.io/driver/mysql v1.3.2/go.mod h1:ChK6AHbHgDCFZyJp0F+BmVGb06PSIoh9uVYKAlRbb2U=
|
||||
gorm.io/driver/mysql v1.3.4 h1:/KoBMgsUHC3bExsekDcmNYaBnfH2WNeFuXqqrqMc98Q=
|
||||
gorm.io/driver/mysql v1.3.4/go.mod h1:s4Tq0KmD0yhPGHbZEwg1VPlH0vT/GBHJZorPzhcxBUE=
|
||||
gorm.io/gorm v1.23.1/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
||||
gorm.io/gorm v1.23.3 h1:jYh3nm7uLZkrMVfA8WVNjDZryKfr7W+HTlInVgKFJAg=
|
||||
gorm.io/gorm v1.23.3/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
||||
gorm.io/gorm v1.23.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
||||
gorm.io/gorm v1.23.5 h1:TnlF26wScKSvknUC/Rn8t0NLLM22fypYBlvj1+aH6dM=
|
||||
gorm.io/gorm v1.23.5/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
||||
|
||||
Reference in New Issue
Block a user