orm

package
v1.5.23 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: MIT Imports: 19 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 ConversionMapKeyToLower added in v1.4.21

func ConversionMapKeyToLower(struMap map[string]interface{}) map[string]interface{}

将 map 中的 key 全部转化成小写

func ConversionMapKeyToLowerForJsonStru added in v1.4.21

func ConversionMapKeyToLowerForJsonStru(stru interface{}) map[string]interface{}

将 json struct 中的 key 全部转化成小写

func ConversionMapKeyToLowerForXmlStru added in v1.4.21

func ConversionMapKeyToLowerForXmlStru(stru interface{}) map[string]interface{}

将 xml struct 中的 key 全部转化成小写

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(colName string, colValue interface{}) string

生成sql 列语句

func GenerateTableSqlForCol added in v1.4.21

func GenerateTableSqlForCol(v interface{}) string

建表列类型判断

func GetAllSqlServerDB added in v1.3.14

func GetAllSqlServerDB() map[string]*gorm.DB

分公司

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

本部oa

func GetSqlServerDBOfCGY

func GetSqlServerDBOfCGY() *gorm.DB

城规院

func GetSqlServerDBOfDSJ

func GetSqlServerDBOfDSJ() *gorm.DB

大数据

func GetSqlServerDBOfDZPT added in v1.5.23

func GetSqlServerDBOfDZPT() *gorm.DB

地质平台 zjsjcx_dba

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 NewClauses added in v1.4.18

func NewClauses[T any](lenNum int) *column[T]

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 CommonModelV1 added in v1.4.18

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

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 SqlAttributes added in v1.4.21

type SqlAttributes struct {
	CreateTableSql string
	PrimaryKey     string
	TableName      string
}

============================================= 自动建表语句

func NewSqlAttributes added in v1.4.21

func NewSqlAttributes(primaryKey, tableName string) *SqlAttributes

func (*SqlAttributes) ExecCreateTable added in v1.4.21

func (sa *SqlAttributes) ExecCreateTable(colValMap map[string]interface{}, db *gorm.DB) error

根据 map 创建表

func (*SqlAttributes) ExecCreateTableByJsonStru added in v1.4.21

func (sa *SqlAttributes) ExecCreateTableByJsonStru(colValStru interface{}, db *gorm.DB) error

根据 结构体 创建表

func (*SqlAttributes) ExecCreateTableByXmlStru added in v1.4.21

func (sa *SqlAttributes) ExecCreateTableByXmlStru(colValStru interface{}, db *gorm.DB) error

根据 结构体 创建表

func (*SqlAttributes) GenerateCreateSql added in v1.4.21

func (sa *SqlAttributes) GenerateCreateSql(colValMap map[string]interface{})

生成sql语句

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