svc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ENTITY_MONGO_FIELD_TAG = "bson"
	ENTITY_MONGO_BASE      = "MongoBaseEntity"
)
View Source
const (
	ENTITY_MYSQL_FIELD_TAG = "mysql"
)
View Source
const (
	ENTITY_REDIS_HASH_FIELD_TAG = "redis"
)

Variables

View Source
var LogKindRedisBaseSvc = []byte("RedisBaseSvc")
View Source
var LogKindSqlBaseSvc = []byte("SqlBaseSvc")
View Source
var LogKindSqlRedisBindSvc = []byte("SqlRedisBindSvc")

Functions

func ReflectColNames

func ReflectColNames(ret reflect.Type) []string

func ReflectMongoColNames

func ReflectMongoColNames(ret reflect.Type) []string

Types

type BaseSvc

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

func NewBaseSvc

func NewBaseSvc() *BaseSvc

func (*BaseSvc) AccessLogger

func (b *BaseSvc) AccessLogger() golog.ILogger

func (*BaseSvc) AlertLog

func (b *BaseSvc) AlertLog(kind, msg []byte)

func (*BaseSvc) CriticalLog

func (b *BaseSvc) CriticalLog(kind, msg []byte)

func (*BaseSvc) DebugLog

func (b *BaseSvc) DebugLog(kind, msg []byte)

func (*BaseSvc) EmergencyLog

func (b *BaseSvc) EmergencyLog(kind, msg []byte)

func (*BaseSvc) ErrorLog

func (b *BaseSvc) ErrorLog(kind, msg []byte)

func (*BaseSvc) InfoLog

func (b *BaseSvc) InfoLog(kind, msg []byte)

func (*BaseSvc) NoticeLog

func (b *BaseSvc) NoticeLog(kind, msg []byte)

func (*BaseSvc) SetAccessLogger

func (b *BaseSvc) SetAccessLogger(logger golog.ILogger) *BaseSvc

func (*BaseSvc) WarningLog

func (b *BaseSvc) WarningLog(kind, msg []byte)

type MongoBaseEntity

type MongoBaseEntity struct {
	Id       interface{} `bson:"_id" json:"_id"`
	AddTime  time.Time   `bson:"add_time" json:"add_time"`
	EditTime time.Time   `bson:"edit_time" json:"edit_time"`
}

type MongoBaseSvc

type MongoBaseSvc struct {
	*BaseSvc

	Mclient *mongo.Client
	Mlogger golog.ILogger

	EntityName string

	Dao      *dao.MongoDao
	IdGenter *idgen.MongoIdGenter
}

func NewMongoBaseSvc

func NewMongoBaseSvc(bs *BaseSvc, mclient *mongo.Client, entityName string) *MongoBaseSvc

func (*MongoBaseSvc) DeleteById

func (s *MongoBaseSvc) DeleteById(tableName string, id interface{}) (bool, error)

func (*MongoBaseSvc) FillBaseEntityForInsert

func (s *MongoBaseSvc) FillBaseEntityForInsert(baseEntity *MongoBaseEntity, rev reflect.Value) error

func (*MongoBaseSvc) GetById

func (s *MongoBaseSvc) GetById(entityPtr interface{}, tableName string, id interface{}) (bool, error)

func (*MongoBaseSvc) Insert

func (s *MongoBaseSvc) Insert(tableName string, colNames []string, entities ...interface{}) ([]interface{}, error)

func (*MongoBaseSvc) ReflectQuerySetItems

func (s *MongoBaseSvc) ReflectQuerySetItems(rev reflect.Value, exists map[string]bool, conditions map[string]string) map[string]interface{}

func (*MongoBaseSvc) SelectAll

func (s *MongoBaseSvc) SelectAll(entityListPtr interface{}, tableName string, mqp *MongoQueryParams, setItems map[string]interface{}) error

func (*MongoBaseSvc) UpdateById

func (s *MongoBaseSvc) UpdateById(tableName string, id interface{}, newEntityPtr interface{}, updateFields map[string]bool) (error, error)

type MongoQueryParams

type MongoQueryParams struct {
	ParamsStructPtr interface{}
	Exists          map[string]bool
	Conditions      map[string]string

	OrderBy []string
	Offset  int
	Cnt     int
}

type RedisBaseSvc

type RedisBaseSvc struct {
	*BaseSvc

	Rclient *redis.Client
}

func NewRedisBaseSvc

func NewRedisBaseSvc(bs *BaseSvc, rclient *redis.Client) *RedisBaseSvc

func (*RedisBaseSvc) GetHashEntityFromRedis

func (r *RedisBaseSvc) GetHashEntityFromRedis(key string, entityPtr interface{}) (bool, error)

func (*RedisBaseSvc) GetJsonDataFromRedis

func (r *RedisBaseSvc) GetJsonDataFromRedis(key string, v interface{}) (bool, error)

func (*RedisBaseSvc) SaveHashEntityToRedis

func (r *RedisBaseSvc) SaveHashEntityToRedis(key string, entityPtr interface{}, expireSeconds int64) error

func (*RedisBaseSvc) SaveJsonDataToRedis

func (r *RedisBaseSvc) SaveJsonDataToRedis(key string, v interface{}, expireSeconds int64) error

type SqlBaseEntity

type SqlBaseEntity struct {
	Id       int64  `mysql:"id" json:"id" redis:"id"`
	AddTime  string `mysql:"add_time" json:"add_time" redis:"add_time"`
	EditTime string `mysql:"edit_time" json:"edit_time" redis:"edit_time"`
}

type SqlBaseSvc

type SqlBaseSvc struct {
	*BaseSvc

	Mclient *mysql.Client
	Mlogger golog.ILogger

	EntityName string

	Dao      *mysql.SqlDao
	IdGenter *idgen.SqlIdGenter
}

func NewSqlBaseSvc

func NewSqlBaseSvc(bs *BaseSvc, mclient *mysql.Client, entityName string) *SqlBaseSvc

func (*SqlBaseSvc) FillBaseEntityForInsert

func (s *SqlBaseSvc) FillBaseEntityForInsert(entity *SqlBaseEntity) error

func (*SqlBaseSvc) GetById

func (s *SqlBaseSvc) GetById(tableName string, id int64, entityPtr interface{}) (bool, error)

func (*SqlBaseSvc) Insert

func (s *SqlBaseSvc) Insert(tableName string, colNames []string, entities ...interface{}) ([]int64, error)

func (*SqlBaseSvc) ListByIds

func (s *SqlBaseSvc) ListByIds(tableName string, ids []int64, orderBy string, entityType reflect.Type, listPtr interface{}) error

func (*SqlBaseSvc) ReflectQueryRowsToEntityList

func (s *SqlBaseSvc) ReflectQueryRowsToEntityList(rows *sql.Rows, ret reflect.Type, listPtr interface{}) error

func (*SqlBaseSvc) SimpleQueryAnd

func (s *SqlBaseSvc) SimpleQueryAnd(tableName string, sqp *SqlQueryParams, entityType reflect.Type, listPtr interface{}) error

func (*SqlBaseSvc) SimpleTotalAnd

func (s *SqlBaseSvc) SimpleTotalAnd(tableName string, sqp *SqlQueryParams) (int64, error)

func (*SqlBaseSvc) UpdateById

func (s *SqlBaseSvc) UpdateById(tableName string, id int64, newEntityPtr interface{}, updateFields map[string]bool) ([]*mysql.SqlColQueryItem, error)

type SqlQueryParams

type SqlQueryParams struct {
	ParamsStructPtr interface{}
	Exists          map[string]bool
	Conditions      map[string]string

	OrderBy string
	Offset  int64
	Cnt     int64
}

type SqlRedisBindSvc

type SqlRedisBindSvc struct {
	*BaseSvc
	*SqlBaseSvc
	*RedisBaseSvc

	RedisKeyPrefix string
}

func NewSqlRedisBindSvc

func NewSqlRedisBindSvc(bs *BaseSvc, ss *SqlBaseSvc, rs *RedisBaseSvc, redisKeyPrefix string) *SqlRedisBindSvc

func (*SqlRedisBindSvc) DeleteById

func (s *SqlRedisBindSvc) DeleteById(tableName string, id int64) (bool, error)

func (*SqlRedisBindSvc) GetById

func (s *SqlRedisBindSvc) GetById(tableName string, id, expireSeconds int64, entityPtr interface{}) (bool, error)

func (*SqlRedisBindSvc) Insert

func (s *SqlRedisBindSvc) Insert(tableName string, colNames []string, expireSeconds int64, entities ...interface{}) ([]int64, error)

func (*SqlRedisBindSvc) RedisKeyForEntity

func (s *SqlRedisBindSvc) RedisKeyForEntity(id int64) string

func (*SqlRedisBindSvc) TotalRows

func (s *SqlRedisBindSvc) TotalRows(tableName string, expireSeconds int64) (int64, error)

func (*SqlRedisBindSvc) UpdateById

func (s *SqlRedisBindSvc) UpdateById(tableName string, id int64, newEntityPtr interface{}, updateFields map[string]bool, expireSeconds int64) (bool, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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