dbs

package
v0.0.0-...-352e39c Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MySQL *gorm.DB
View Source
var MySQLContext = context.Background()

Functions

func Delete

func Delete(db *gorm.DB, entity any)

Delete 物理删除

func FindCache

func FindCache[T any](db *gorm.DB, id uint64) *T

FindCache 获取缓存数据,不存在查询数据库,不包含删除标记的数据

func FindDatabase

func FindDatabase[T any](db *gorm.DB, id uint64) *T

FindDatabase 获取数据库记录,包含删除标记的

func FindOrigin

func FindOrigin[T any](db *gorm.DB, id uint64) *T

FindOrigin 查询数据库记录,不含删除标记的

func FindSnapshot

func FindSnapshot[T any](db *gorm.DB, id uint64) *T

FindSnapshot 获取缓存数据,不存在查询数据库,含删除标记的数据

func InitMySQL

func InitMySQL() error

InitMySQL 初始化MySQL组件

func Remove

func Remove(db *gorm.DB, entity any)

Remove 逻辑删除

func Save

func Save(db *gorm.DB, entity any)

Save 保存

Types

type DBEntity

type DBEntity interface {
	// GetEntity 获取实体基础结构体
	GetEntity() *Entity
	// GetExpire 获取缓存失效时间,0不缓存
	GetExpire() time.Duration
}

DBEntity 实体接口

type Entity

type Entity struct {
	ID            uint64    `gorm:"column:C001;not null;primary_key;autoIncrement:false;comment:数据ID"`
	ZyxVersion    uint64    `gorm:"column:C002;not null;comment:数据版本"`
	ZyxDelete     bool      `gorm:"column:C003;not null;index;comment:删除标记"`
	ZyxCreateTime time.Time `gorm:"column:C004;not null;index;comment:创建时间"`
	ZyxUpdateTime time.Time `gorm:"column:C005;not null;index;comment:修改时间"`
}

Entity 实体基结构体

func (*Entity) GetIDString

func (e *Entity) GetIDString() string

GetIDString 获取数据ID

type Operator

type Operator struct {
	ZyxCreateUid uint64 `gorm:"column:C008;not null;index;comment:创建人ID"`
	ZyxUpdateUid uint64 `gorm:"column:C009;not null;index;comment:修改人ID"`
}

Operator 操作人相关字段

type UmsEmployee

type UmsEmployee struct {
	Entity
	Operator
	Roles    app.GormJSON `gorm:"column:B001;not null;type:json;comment:用户角色"`
	LoginKey string       `gorm:"column:B010;not null;index;size:32;comment:登录账号"`
	LoginPwd string       `gorm:"column:B011;not null;size:128;comment:登录密码"`
	Name     string       `gorm:"column:B020;not null;index;size:128;comment:用户名称"`
	Avatar   string       `gorm:"column:B021;not null;size:255;comment:用户头像地址"`
}

UmsEmployee 平台用户信息表

func UmsEmployeeFindByLoginKey

func UmsEmployeeFindByLoginKey(db *gorm.DB, loginKey string) *UmsEmployee

UmsEmployeeFindByLoginKey 获取指定登录账号的平台用户

func UmsEmployeeFindPager

func UmsEmployeeFindPager(db *gorm.DB, query *app.Query, role string, loginKey string, name string) (*app.Pager, []*UmsEmployee)

UmsEmployeeFindPager 查询分页数据

func (*UmsEmployee) GetEntity

func (e *UmsEmployee) GetEntity() *Entity

GetEntity 实体对象

func (*UmsEmployee) GetExpire

func (e *UmsEmployee) GetExpire() time.Duration

GetExpire 缓存时长

func (*UmsEmployee) TableName

func (e *UmsEmployee) TableName() string

TableName 数据表名称

type UmsMember

type UmsMember struct {
	Entity
	Operator
	Roles    app.GormJSON `gorm:"column:B001;not null;index;type:json;comment:用户角色"`
	LoginKey string       `gorm:"column:B010;not null;index;size:32;comment:登录账号"`
	LoginPwd string       `gorm:"column:B011;not null;size:128;comment:登录密码"`
	Mobile   string       `gorm:"column:B015;not null;index;size:16;comment:手机号"`
	Name     string       `gorm:"column:B020;not null;index;size:128;comment:用户名称"`
	Avatar   string       `gorm:"column:B021;not null;size:255;comment:用户头像地址"`
}

UmsMember 平台用户信息表

func UmsMemberFindByLoginKey

func UmsMemberFindByLoginKey(db *gorm.DB, loginKey string) *UmsMember

UmsMemberFindByLoginKey 获取指定登录账号的平台用户

func UmsMemberFindPager

func UmsMemberFindPager(db *gorm.DB, query *app.Query, loginKey string, name string) (*app.Pager, []*UmsMember)

UmsMemberFindPager 查询分页数据

func (*UmsMember) GetEntity

func (e *UmsMember) GetEntity() *Entity

GetEntity 实体对象

func (*UmsMember) GetExpire

func (e *UmsMember) GetExpire() time.Duration

GetExpire 缓存时长

func (*UmsMember) TableName

func (e *UmsMember) TableName() string

TableName 数据表名称

type UmsUser

type UmsUser struct {
	Entity
	Operator
	Type            int8      `gorm:"column:B001;not null;index;comment:用户类型"`
	Name            string    `gorm:"column:B002;not null;size:128;comment:用户名称"`
	LastLoginTime   time.Time `gorm:"column:B010;not null;comment:最后登录时间"`
	LastLoginIP     string    `gorm:"column:B011;not null;size:64;comment:最后登录IP"`
	LastLoginCity   string    `gorm:"column:B012;not null;size:128;comment:最后登录城市"`
	LastLoginDevice string    `gorm:"column:B013;not null;size:128;comment:最后登录设备"`
	Lock            bool      `gorm:"column:B020;not null;index;comment:是否锁定登录"`
	LockTime        time.Time `gorm:"column:B021;not null;comment:锁定时间"`
	LockResumeTime  time.Time `gorm:"column:B022;not null;comment:解锁时间"`
	LockUserID      uint64    `gorm:"column:B023;not null;comment:锁定人ID"`
	LockCause       string    `gorm:"column:B024;not null;size:256;comment:锁定原因"`
}

UmsUser 用户信息

func (*UmsUser) GetEntity

func (e *UmsUser) GetEntity() *Entity

GetEntity 实体对象

func (*UmsUser) GetExpire

func (e *UmsUser) GetExpire() time.Duration

GetExpire 缓存时长

func (*UmsUser) TableName

func (e *UmsUser) TableName() string

TableName 数据表名称

Jump to

Keyboard shortcuts

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