dao

package
v0.0.0-...-d0d6297 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFUALT = "default"
	PHEONIX = "pheonix"
)

Variables

View Source
var MONTH_SECOND_TIME = int64(30 * 24 * 60 * 60)

Functions

This section is empty.

Types

type CacheDao

type CacheDao struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func GetCacheDao

func GetCacheDao(v interface{}) *CacheDao

func NewCacheDao

func NewCacheDao() *CacheDao

采取单例模式

func NewCacheDaoByParam

func NewCacheDaoByParam(datasource string) *CacheDao

采取单例模式

func (*CacheDao) Count

func (cacheDao *CacheDao) Count(obj interface{}, name string, params *SortMap) (int64, error)

func (*CacheDao) DelKeyFromCache

func (cacheDao *CacheDao) DelKeyFromCache(key string) (bool, error)

func (*CacheDao) Delete

func (cacheDao *CacheDao) Delete(obj interface{}) (int64, error)

func (*CacheDao) GetIdList

func (cacheDao *CacheDao) GetIdList(obj interface{}, res interface{}, name string, params *SortMap, orderby []string) ([]int64, error)

func (*CacheDao) GetIdListPage

func (cacheDao *CacheDao) GetIdListPage(obj interface{}, res interface{}, name string, params *SortMap, orderby []string, start int64, count int64) ([]int64, error)

func (*CacheDao) GetList

func (cacheDao *CacheDao) GetList(obj interface{}, res interface{}, name string, params *SortMap, orderby []string) ([]interface{}, error)

func (*CacheDao) GetListByIds

func (cacheDao *CacheDao) GetListByIds(obj interface{}, ids []int64) ([]interface{}, error)

func (*CacheDao) GetListPage

func (cacheDao *CacheDao) GetListPage(obj interface{}, res interface{}, name string, params *SortMap, orderby []string, start int64, count int64) ([]interface{}, error)

分页根据查询条件获取对象列表 返回具体对象

func (*CacheDao) GetMaping

func (cacheDao *CacheDao) GetMaping(obj interface{}, name string, params *SortMap) (interface{}, error)

此方法适用于多个条件对应于数据库唯一一条记录场景,即map映射 返回唯一对象s

func (*CacheDao) GetMapingId

func (cacheDao *CacheDao) GetMapingId(obj interface{}, name string, params *SortMap) (int64, error)

func (*CacheDao) Insert

func (cacheDao *CacheDao) Insert(obj interface{}) (int64, error)

func (*CacheDao) IsExistInCache

func (cacheDao *CacheDao) IsExistInCache(key string) (bool, error)

查询cache中是否存在某个key

func (*CacheDao) MRead

func (cacheDao *CacheDao) MRead(obj interface{}, ids []int64) ([]interface{}, error)

先读cache 如果cache没有数据,从db加载,然后set到cache中

func (*CacheDao) Read

func (cacheDao *CacheDao) Read(obj interface{}, id int64) error

先读cache 如果cache没有数据,从db加载,然后set到cache中

func (*CacheDao) Update

func (cacheDao *CacheDao) Update(obj interface{}) (int64, error)

type DBDao

type DBDao struct {
	// contains filtered or unexported fields
}

func GetDBDao

func GetDBDao(v interface{}) *DBDao

func NewDBDao

func NewDBDao() *DBDao

采取单例模式

func NewDBDaoByParam

func NewDBDaoByParam(datasource string) *DBDao

采取单例模式

func (*DBDao) Count

func (dao *DBDao) Count(obj interface{}, name string, params *SortMap) (int64, error)

func (*DBDao) DelKeyFromCache

func (dao *DBDao) DelKeyFromCache(key string) (bool, error)

func (*DBDao) Delete

func (dao *DBDao) Delete(obj interface{}) (int64, error)

func (*DBDao) GetIdList

func (dao *DBDao) GetIdList(obj interface{}, res interface{}, name string, params *SortMap, orderby []string) ([]int64, error)

func (*DBDao) GetIdListPage

func (dao *DBDao) GetIdListPage(obj interface{}, res interface{}, name string, params *SortMap, orderby []string, start int64, count int64) ([]int64, error)

func (*DBDao) GetList

func (dao *DBDao) GetList(obj interface{}, res interface{}, name string, params *SortMap, orderby []string) ([]interface{}, error)

func (*DBDao) GetListByIds

func (dao *DBDao) GetListByIds(obj interface{}, ids []int64) ([]interface{}, error)

func (*DBDao) GetListPage

func (dao *DBDao) GetListPage(obj interface{}, res interface{}, name string, params *SortMap, orderby []string, start int64, count int64) ([]interface{}, error)

分页根据查询条件获取对象列表 返回具体对象

func (*DBDao) GetMaping

func (dao *DBDao) GetMaping(obj interface{}, name string, params *SortMap) (interface{}, error)

此方法适用于多个条件对应于数据库唯一一条记录场景,即map映射 返回唯一对象s

func (*DBDao) GetMapingId

func (dao *DBDao) GetMapingId(obj interface{}, name string, params *SortMap) (int64, error)

func (*DBDao) Insert

func (dao *DBDao) Insert(obj interface{}) (int64, error)

func (*DBDao) IsExistInCache

func (dao *DBDao) IsExistInCache(key string) (bool, error)

查询cache中是否存在某个key

func (*DBDao) Read

func (dao *DBDao) Read(obj interface{}, id int64) error

func (*DBDao) Update

func (dao *DBDao) Update(obj interface{}) (int64, error)

type Dao

type Dao interface {

	// 插入对象
	// 返回对象Id,Id在数据为此对象对应的表的主键
	Insert(obj interface{}) (int64, error)

	// 更新对象
	// 返回对象Id
	Update(obj interface{}) (int64, error)

	// 查询对象,注意:查询前需要设置对象Id字段值
	Read(obj interface{}, id int64) error

	// 删除对象,注意:查询前需要设置对象Id字段值
	// 返回删除对象Id
	Delete(obj interface{}) (int64, error)

	//计算记录数量
	Count(obj interface{}, name string, params *SortMap) (int64, error)

	//查询cache中是否存在某个key
	IsExistInCache(key string) (bool, error)

	//从cache中删除key
	DelKeyFromCache(key string) (bool, error)

	// 获取查询条件对应的对象Id列表
	// 返回满足查询条件的Id列表
	GetIdList(obj interface{}, res interface{}, name string, params *SortMap, orderby []string) ([]int64, error)

	// 分页获取查询条件对应的对象Id列表
	// 分页返回满足查询条件的Id列表
	GetIdListPage(obj interface{}, res interface{}, name string, params *SortMap, orderby []string, start int64, count int64) ([]int64, error)

	// 根据查询条件获取对象列表
	// 返回具体对象
	GetList(obj interface{}, res interface{}, name string, params *SortMap, orderby []string) ([]interface{}, error)

	// 根据现有的ids列表,查询对象
	// 返回为对象列表
	GetListByIds(obj interface{}, ids int64) ([]interface{}, error)

	// 分页根据查询条件获取对象列表
	// 返回具体对象
	GetListPage(name string, params *SortMap, orderby []string, start int64, count int64) ([]interface{}, error)

	// 此方法适用于多个条件对应于数据库唯一一条记录场景,即map映射
	// 返回唯一对象的Id
	GetMapingId(obj interface{}, name string, params *SortMap) (int64, error)

	// 此方法适用于多个条件对应于数据库唯一一条记录场景,即map映射
	// 返回唯一对象
	GetMaping(obj interface{}, name string, params *SortMap) (interface{}, error)
}

type SortMap

type SortMap struct {

	// 保存所有key
	Keys []interface{}

	// k v存储
	Values map[interface{}]interface{}
	sync.Mutex
}

func NewSortMap

func NewSortMap() *SortMap

func (*SortMap) Get

func (sortMap *SortMap) Get(key interface{}) interface{}

func (*SortMap) KeySet

func (sortMap *SortMap) KeySet() []interface{}

func (*SortMap) Set

func (sortMap *SortMap) Set(key interface{}, value interface{})

func (*SortMap) ValueSet

func (sortMap *SortMap) ValueSet() []interface{}

Jump to

Keyboard shortcuts

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