orm

package
v1.3.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectMySql

func ConnectMySql(MySqlUserName, Password, Address string, Port int, dbName string) *gorm.DB

func ConnectSqlServer

func ConnectSqlServer(MySqlUserName, Password, Address string, Port int, dbName string) *gorm.DB

func Create

func Create(db *gorm.DB, value interface{}) error

Create

func CreateOrUpdate

func CreateOrUpdate(db *gorm.DB, tableName string, MapFieldValue map[string]interface{}, query interface{}, args ...interface{}) error

数据存在更新,不存在创建 根据条件判断数据是否存在是否存在 存在 创建 不存在 更新指定字段 true:数据存在,false:数据不存在

func CreateOrUpdateOfSpecial

func CreateOrUpdateOfSpecial(db *gorm.DB, tableName string, MapFieldValue map[string]interface{}, query interface{}, args ...interface{}) error

特殊处理:更新map中不存在的字段 数据存在更新,不存在创建 根据条件判断数据是否存在是否存在 存在 创建 不存在 更新指定字段 true:数据存在,false:数据不存在

func DeleteByID

func DeleteByID(db *gorm.DB, model interface{}, id string) (count int64, err error)

Delete

func DeleteByIDS

func DeleteByIDS(db *gorm.DB, model interface{}, ids []string) (count int64, err error)

Delete

func DeleteByModel

func DeleteByModel(db *gorm.DB, model interface{}) (count int64, err error)

Delete

func DeleteByWhere

func DeleteByWhere(db *gorm.DB, model, where interface{}) (count int64, err error)

Delete

func DeleteByWhereTx

func DeleteByWhereTx(db *gorm.DB, model, where interface{}) (count int64, err error, tx *gorm.DB)

Delete

func Find

func Find(db *gorm.DB, where interface{}, out interface{}, orders ...string) error

Find

func First

func First(db *gorm.DB, where interface{}, out interface{}) (notFound bool, err error)

First

func FirstByID

func FirstByID(db *gorm.DB, out interface{}, id string) (notFound bool, err error)

First

func GenerateElementCreateSql

func GenerateElementCreateSql(reqMap map[string]interface{}, tableName string) createTableSql

生成桩基/盖梁等表机构

func GenerateTableSql

func GenerateTableSql(k string, v interface{}) string

建表sql语句。通用建表

func GetColumnNameList

func GetColumnNameList(db *gorm.DB, DBName, TableName string, out *[]DictionaryInfo) error

func GetDBRepo

func GetDBRepo() *dbRepo

func GetDbTableList

func GetDbTableList(db *gorm.DB, DBName string, out *[]TableInfo) error

func GetDesignDB added in v1.3.4

func GetDesignDB() *gorm.DB

func GetMysqlDB

func GetMysqlDB() *gorm.DB

get db

func GetPage

func GetPage(db *gorm.DB, model, where interface{}, out interface{}, indexPage *IndexPage, order string, whereOrder ...PageWhere) error

GetPage

func GetPageToMap

func GetPageToMap(db *gorm.DB, tableName string, out interface{}, indexPage *IndexPage, order string, whereOrder ...PageWhere) error

GetPage

func GetSqlServerDB

func GetSqlServerDB() *gorm.DB

func GetSqlServerDBOfCGY

func GetSqlServerDBOfCGY() *gorm.DB

城规院

func GetSqlServerDBOfDSJ

func GetSqlServerDBOfDSJ() *gorm.DB

大数据

func GetSqlServerDBOfFGS

func GetSqlServerDBOfFGS() *gorm.DB

分公司

func GetSqlServerDBOfJL

func GetSqlServerDBOfJL() *gorm.DB

监理

func GetSqlServerDBOfQJ

func GetSqlServerDBOfQJ() *gorm.DB

桥监

func GetUserIdsByAdminAllDelartUser

func GetUserIdsByAdminAllDelartUser(db *gorm.DB, orgId int, out interface{}) error

func GetUserTypeByAppUserId

func GetUserTypeByAppUserId(db *gorm.DB, appId int, out interface{}) error

func GormPgSql added in v1.3.1

func GormPgSql(PgSqlUserName, Password, Address string, Port string, DbName string) *gorm.DB

GormPgSql 初始化 Postgresql 数据库

func InitDesignDB added in v1.3.4

func InitDesignDB() *gorm.DB

func LikeStr

func LikeStr(keyStr string) string

Like

func PluckList

func PluckList(db *gorm.DB, model, where interface{}, fieldName string, out interface{}) error

PluckList

func Save

func Save(db *gorm.DB, value interface{}) error

Save

func Scan

func Scan(db *gorm.DB, model, where interface{}, out interface{}) (notFound bool, err error)

Scan

func ScanList

func ScanList(db *gorm.DB, model, where interface{}, out interface{}, orders ...string) error

ScanList

func SelectByWhere

func SelectByWhere(db *gorm.DB, whereMap map[string]string, columnList []string, out interface{}) error

out 指针类型

func SetSqlServerDb added in v1.2.5

func SetSqlServerDb(key string, db *gorm.DB)

func Updates

func Updates(db *gorm.DB, where interface{}, value interface{}) error

Updates

Types

type CommonModel

type CommonModel struct {
	ID        int64          `gorm:"column:id;primary_key;AUTO_INCREMENT" form:"id"   json:"id"`
	CreatedAt time.Time      `gorm:"column:createdAt" form:"createdAt"  json:"createdAt"`
	UpdatedAt time.Time      `gorm:"column:updatedAt" form:"updatedAt"  json:"updatedAt"`
	DeletedAt gorm.DeletedAt `gorm:"column:deletedAt" form:"deletedAt"  sql:"index" json:"deletedAt"`
}

type DictionaryInfo

type DictionaryInfo struct {
	ColumnName    string `json:"column_name"`    // 字段名称
	DataType      string `json:"data_type"`      // 类型
	IsNullable    string `json:"is_nullable"`    // 是否为空
	ColumnComment string `json:"column_comment"` // 描述
}

type GinModel

type GinModel struct {
	ID        int64          `gorm:"column:id;primary_key;AUTO_INCREMENT" form:"id"   json:"id"`
	CreatedAt time.Time      `gorm:"column:created_at" form:"createdAt"  json:"createdAt"`
	UpdatedAt time.Time      `gorm:"column:updated_at" form:"updatedAt"  json:"updatedAt"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" form:"deletedAt"  sql:"index" json:"deletedAt"`
}

type IndexPage

type IndexPage struct {
	Total int `json:"total"`  //总数
	Page  int `json:"page"  ` //页数
	Num   int `json:"num"   ` //数量
}

分页参数返回

type PageWhere

type PageWhere struct {
	Where string
	Value []interface{}
}

分页条件

type Repo

type Repo interface {
	GetDbR() *gorm.DB
	GetDbW() *gorm.DB
	GetSeafileDb() *gorm.DB
	DbRClose() error
	DbWClose() error
	// contains filtered or unexported methods
}

type TableInfo

type TableInfo struct {
	CreateTime   string `json:"create_time"`   // 创建时间
	TableName    string `json:"table_name"`    // 表名
	TableComment string `json:"table_comment"` // 表中文名
}

type Writer

type Writer struct {
}

func (Writer) Printf

func (w Writer) Printf(format string, args ...interface{})

type WriterSqlServer

type WriterSqlServer struct {
}

func (WriterSqlServer) Printf

func (w WriterSqlServer) Printf(format string, args ...interface{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL