BaseDBManager

package
v5.4.12 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	//OpenSub 是否启动订阅
	OpenSub = false
)

Functions

func CreateSQL

func CreateSQL(args *ArgsCreateSQL) (err error)

CreateSQL 创建SQL

func DeleteSQLByID

func DeleteSQLByID(id int64) (err error)

DeleteSQLByID 删除SQL

func Init

func Init() (err error)

func UpdateSQL

func UpdateSQL(args *ArgsUpdateSQL) (err error)

UpdateSQL 修改SQL

Types

type ArgsCreateSQL

type ArgsCreateSQL struct {
	///////////////////////////////////////////////////////////////////////////////////////////////////
	// 来源
	// 如果存在值,尤其是带有FromCode时,应确保数据唯一性
	///////////////////////////////////////////////////////////////////////////////////////////////////
	//来源系统
	// 例如: analysis
	FromSystem string `db:"from_system" json:"fromSystem" index:"true" field_list:"true"`
	//来源模块
	// 例如: index_sql
	FromModule string `db:"from_module" json:"fromModule" index:"true" field_list:"true"`
	//内部标识码
	// 可用于标记内部识别标识码,例如Index中的维度值,或一组维度值组合后的标识码
	FromCode string `db:"from_code" json:"fromCode" index:"true" field_list:"true"`
	///////////////////////////////////////////////////////////////////////////////////////////////////
	// 基础设置
	///////////////////////////////////////////////////////////////////////////////////////////////////
	//定时器设置Carbon编码
	// 例如: 15s
	CarbonCode string `db:"carbon_code" json:"carbonCode" index:"true" field_list:"true"`
	//开始运行时通知中间件地址
	// 用于通知需发起该SQL,将SQL和来源信息传递给对应的中间件
	PostURL string `db:"post_url" json:"postURL" index:"true" field_list:"true"`
	///////////////////////////////////////////////////////////////////////////////////////////////////
	// 数据
	///////////////////////////////////////////////////////////////////////////////////////////////////
	//SQL内容
	SQLData string `db:"sql_data" json:"sqlData"`
}

ArgsCreateSQL 创建SQL参数

type ArgsGetSQLList

type ArgsGetSQLList struct {
	//分页
	Pages CoreSQL2.ArgsPages `json:"pages"`
	//来源系统
	// 例如: analysis
	FromSystem string `db:"from_system" json:"fromSystem" index:"true" field_list:"true"`
	//来源模块
	// 例如: index_sql
	FromModule string `db:"from_module" json:"fromModule" index:"true" field_list:"true"`
	//内部标识码
	// 可用于标记内部识别标识码,例如Index中的维度值,或一组维度值组合后的标识码
	FromCode string `db:"from_code" json:"fromCode" index:"true" field_list:"true"`
	//是否删除
	IsRemove bool `db:"is_remove" json:"isRemove" check:"bool"`
	//搜索
	Search string `json:"search" check:"search" empty:"true"`
}

ArgsGetSQLList 获取SQL列表参数

type ArgsUpdateSQL

type ArgsUpdateSQL struct {
	// ID
	ID int64 `db:"id" json:"id" check:"id" unique:"true"`
	///////////////////////////////////////////////////////////////////////////////////////////////////
	// 基础设置
	///////////////////////////////////////////////////////////////////////////////////////////////////
	//定时器设置Carbon编码
	// 例如: 15s
	CarbonCode string `db:"carbon_code" json:"carbonCode" index:"true" field_list:"true"`
	//开始运行时通知中间件地址
	// 用于通知需发起该SQL,将SQL和来源信息传递给对应的中间件
	PostURL string `db:"post_url" json:"postURL" index:"true" field_list:"true"`
	///////////////////////////////////////////////////////////////////////////////////////////////////
	// 数据
	///////////////////////////////////////////////////////////////////////////////////////////////////
	//SQL内容
	SQLData string `db:"sql_data" json:"sqlData"`
}

ArgsUpdateSQL 修改SQL参数

type FieldsSQL

type FieldsSQL struct {
	// ID
	ID int64 `db:"id" json:"id" check:"id" unique:"true"`
	//创建时间
	CreateAt time.Time `db:"create_at" json:"createAt" default:"now()"`
	//更新时间
	UpdateAt time.Time `db:"update_at" json:"updateAt" default:"now()"`
	//删除时间
	DeleteAt time.Time `db:"delete_at" json:"deleteAt" default:"0" index:"true"`
	///////////////////////////////////////////////////////////////////////////////////////////////////
	// 来源
	// 如果存在值,尤其是带有FromCode时,应确保数据唯一性
	///////////////////////////////////////////////////////////////////////////////////////////////////
	//来源系统
	// 例如: analysis
	FromSystem string `db:"from_system" json:"fromSystem" index:"true" field_list:"true"`
	//来源模块
	// 例如: index_sql
	FromModule string `db:"from_module" json:"fromModule" index:"true" field_list:"true"`
	//内部标识码
	// 可用于标记内部识别标识码,例如Index中的维度值,或一组维度值组合后的标识码
	FromCode string `db:"from_code" json:"fromCode" index:"true" field_list:"true"`
	///////////////////////////////////////////////////////////////////////////////////////////////////
	// 基础设置
	///////////////////////////////////////////////////////////////////////////////////////////////////
	//定时器设置Carbon编码
	// 例如: 15s
	CarbonCode string `db:"carbon_code" json:"carbonCode" index:"true" field_list:"true"`
	//开始运行时通知中间件地址
	// 用于通知需发起该SQL,将SQL和来源信息传递给对应的中间件
	PostURL string `db:"post_url" json:"postURL" index:"true" field_list:"true"`
	///////////////////////////////////////////////////////////////////////////////////////////////////
	// 数据
	///////////////////////////////////////////////////////////////////////////////////////////////////
	//SQL内容
	SQLData string `db:"sql_data" json:"sqlData"`
}

func GetSQLByCode

func GetSQLByCode(fromSystem, fromModule, fromCode string) (data FieldsSQL, err error)

GetSQLByCode 通过Code获取指定SQL

func GetSQLByID

func GetSQLByID(id int64) (data FieldsSQL, err error)

GetSQLByID 通过ID获取指定SQL

func GetSQLList

func GetSQLList(args *ArgsGetSQLList) (dataList []FieldsSQL, dataCount int64, err error)

GetSQLList 获取SQL列表

type SQLClient

type SQLClient struct {
	//DB数据库句柄
	DB CoreSQL2.Client
	//表名称
	// eg: base_db_manager
	TableName string
	//主表缓冲标识码前缀
	// eg: xxx:xxx:xxx
	CacheName string
	//默认缓冲时效性
	// eg: 3600
	CacheTime int
	//结构映射关系
	// eg: &FieldsXXX{}
	FieldsAny any
	//是否存在更新时间
	HaveUpdateTime bool
	//是否存在软删除
	HaveSoftDelete bool
}

func (*SQLClient) Create

func (t *SQLClient) Create(params map[string]any) (id int64, err error)

Create 创建数据

func (*SQLClient) DeleteByID

func (t *SQLClient) DeleteByID(id int64) (err error)

DeleteByID 通过ID删除数据

func (*SQLClient) GetByID

func (t *SQLClient) GetByID(id int64, data any) (err error)

GetByID 获取指定的ID

func (*SQLClient) Init

func (t *SQLClient) Init() (err error)

Init 初始化数据库

func (*SQLClient) UpdateByID

func (t *SQLClient) UpdateByID(id int64, setFields []string, params map[string]any) (err error)

UpdateByID 通过ID更新数据

func (*SQLClient) UpdateDefaultFieldsByID

func (t *SQLClient) UpdateDefaultFieldsByID(id int64, params map[string]any) (err error)

UpdateDefaultFieldsByID 通过ID更新全量数据

Jump to

Keyboard shortcuts

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