Commit 36a43c46 authored by szh's avatar szh

update

parent f408015e
......@@ -23,11 +23,11 @@ is_out_file_by_table_name: false # 是否根据表名生成多个model
is_out_page: true # 是否输出分页函数
db_info:
host : 127.0.0.1 # type=1的时候,host为yml文件全路径
port : 3306
host : 192.168.122.131 # type=1的时候,host为yml文件全路径
port : 13306
username : root
password : root
database : elf
password :
database : elfGame
type: 0 # 数据库类型:0:mysql , 1:sqlite , 2:mssql
self_type_define: # 自定义数据类型映射
datetime: time.Time
......
File deleted
This diff is collapsed.
package model
import (
"context"
"fmt"
"gorm.io/gorm"
)
type _AirDropTxMgr struct {
*_BaseMgr
}
// AirDropTxMgr open func
func AirDropTxMgr(db *gorm.DB) *_AirDropTxMgr {
if db == nil {
panic(fmt.Errorf("AirDropTxMgr need init by db"))
}
ctx, cancel := context.WithCancel(context.Background())
return &_AirDropTxMgr{_BaseMgr: &_BaseMgr{DB: db.Table("air_drop_tx"), isRelated: globalIsRelated, ctx: ctx, cancel: cancel, timeout: -1}}
}
// Debug open debug.打开debug模式查看sql语句
func (obj *_AirDropTxMgr) Debug() *_AirDropTxMgr {
obj._BaseMgr.DB = obj._BaseMgr.DB.Debug()
return obj
}
// GetTableName get sql table name.获取数据库名字
func (obj *_AirDropTxMgr) GetTableName() string {
return "air_drop_tx"
}
// Reset 重置gorm会话
func (obj *_AirDropTxMgr) Reset() *_AirDropTxMgr {
obj.New()
return obj
}
// Get 获取
func (obj *_AirDropTxMgr) Get() (result AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).First(&result).Error
return
}
// Gets 获取批量结果
func (obj *_AirDropTxMgr) Gets() (results []*AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Find(&results).Error
return
}
// //////////////////////////////// gorm replace /////////////////////////////////
func (obj *_AirDropTxMgr) Count(count *int64) (tx *gorm.DB) {
return obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Count(count)
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////option case ////////////////////////////////////////////
// WithID id获取
func (obj *_AirDropTxMgr) WithID(id int) Option {
return optionFunc(func(o *options) { o.query["id"] = id })
}
// WithHash hash获取
func (obj *_AirDropTxMgr) WithHash(hash string) Option {
return optionFunc(func(o *options) { o.query["hash"] = hash })
}
// WithHeight height获取
func (obj *_AirDropTxMgr) WithHeight(height int) Option {
return optionFunc(func(o *options) { o.query["height"] = height })
}
// WithUserID user_id获取
func (obj *_AirDropTxMgr) WithUserID(userID int) Option {
return optionFunc(func(o *options) { o.query["user_id"] = userID })
}
// WithToID to_id获取
func (obj *_AirDropTxMgr) WithToID(toID int) Option {
return optionFunc(func(o *options) { o.query["to_id"] = toID })
}
// WithTo to获取
func (obj *_AirDropTxMgr) WithTo(to string) Option {
return optionFunc(func(o *options) { o.query["to"] = to })
}
// WithAmount amount获取
func (obj *_AirDropTxMgr) WithAmount(amount int) Option {
return optionFunc(func(o *options) { o.query["amount"] = amount })
}
// WithBlocktime blocktime获取
func (obj *_AirDropTxMgr) WithBlocktime(blocktime int) Option {
return optionFunc(func(o *options) { o.query["blocktime"] = blocktime })
}
// GetByOption 功能选项模式获取
func (obj *_AirDropTxMgr) GetByOption(opts ...Option) (result AirDropTx, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where(options.query).First(&result).Error
return
}
// GetByOptions 批量功能选项模式获取
func (obj *_AirDropTxMgr) GetByOptions(opts ...Option) (results []*AirDropTx, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where(options.query).Find(&results).Error
return
}
// SelectPage 分页查询
func (obj *_AirDropTxMgr) SelectPage(page IPage, opts ...Option) (resultPage IPage, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
resultPage = page
results := make([]AirDropTx, 0)
var count int64 // 统计总的记录数
query := obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where(options.query)
query.Count(&count)
resultPage.SetTotal(count)
if len(page.GetOrederItemsString()) > 0 {
query = query.Order(page.GetOrederItemsString())
}
err = query.Limit(int(page.GetSize())).Offset(int(page.Offset())).Find(&results).Error
resultPage.SetRecords(results)
return
}
//////////////////////////enume case ////////////////////////////////////////////
// GetFromID 通过id获取内容
func (obj *_AirDropTxMgr) GetFromID(id int) (result AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`id` = ?", id).First(&result).Error
return
}
// GetBatchFromID 批量查找
func (obj *_AirDropTxMgr) GetBatchFromID(ids []int) (results []*AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`id` IN (?)", ids).Find(&results).Error
return
}
// GetFromHash 通过hash获取内容
func (obj *_AirDropTxMgr) GetFromHash(hash string) (results []*AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`hash` = ?", hash).Find(&results).Error
return
}
// GetBatchFromHash 批量查找
func (obj *_AirDropTxMgr) GetBatchFromHash(hashs []string) (results []*AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`hash` IN (?)", hashs).Find(&results).Error
return
}
// GetFromHeight 通过height获取内容
func (obj *_AirDropTxMgr) GetFromHeight(height int) (results []*AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`height` = ?", height).Find(&results).Error
return
}
// GetBatchFromHeight 批量查找
func (obj *_AirDropTxMgr) GetBatchFromHeight(heights []int) (results []*AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`height` IN (?)", heights).Find(&results).Error
return
}
// GetFromUserID 通过user_id获取内容
func (obj *_AirDropTxMgr) GetFromUserID(userID int) (results []*AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`user_id` = ?", userID).Find(&results).Error
return
}
// GetBatchFromUserID 批量查找
func (obj *_AirDropTxMgr) GetBatchFromUserID(userIDs []int) (results []*AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`user_id` IN (?)", userIDs).Find(&results).Error
return
}
// GetFromToID 通过to_id获取内容
func (obj *_AirDropTxMgr) GetFromToID(toID int) (results []*AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`to_id` = ?", toID).Find(&results).Error
return
}
// GetBatchFromToID 批量查找
func (obj *_AirDropTxMgr) GetBatchFromToID(toIDs []int) (results []*AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`to_id` IN (?)", toIDs).Find(&results).Error
return
}
// GetFromAmount 通过amount获取内容
func (obj *_AirDropTxMgr) GetFromAmount(amount int) (results []*AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`amount` = ?", amount).Find(&results).Error
return
}
// GetBatchFromAmount 批量查找
func (obj *_AirDropTxMgr) GetBatchFromAmount(amounts []int) (results []*AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`amount` IN (?)", amounts).Find(&results).Error
return
}
// GetFromBlocktime 通过blocktime获取内容
func (obj *_AirDropTxMgr) GetFromBlocktime(blocktime int) (results []*AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`blocktime` = ?", blocktime).Find(&results).Error
return
}
// GetBatchFromBlocktime 批量查找
func (obj *_AirDropTxMgr) GetBatchFromBlocktime(blocktimes []int) (results []*AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`blocktime` IN (?)", blocktimes).Find(&results).Error
return
}
//////////////////////////primary index case ////////////////////////////////////////////
// FetchByPrimaryKey primary or index 获取唯一内容
func (obj *_AirDropTxMgr) FetchByPrimaryKey(id int) (result AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`id` = ?", id).First(&result).Error
return
}
// FetchIndexByIndex2 获取多个内容
func (obj *_AirDropTxMgr) FetchIndexByIndex2(hash string) (results []*AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`hash` = ?", hash).Find(&results).Error
return
}
// FetchIndexByIndex1 获取多个内容
func (obj *_AirDropTxMgr) FetchIndexByIndex1(toID int) (results []*AirDropTx, err error) {
err = obj.DB.WithContext(obj.ctx).Model(AirDropTx{}).Where("`to_id` = ?", toID).Find(&results).Error
return
}
This diff is collapsed.
This diff is collapsed.
package model
import (
"context"
"fmt"
"gorm.io/gorm"
)
type _ConfigGroupMgr struct {
*_BaseMgr
}
// ConfigGroupMgr open func
func ConfigGroupMgr(db *gorm.DB) *_ConfigGroupMgr {
if db == nil {
panic(fmt.Errorf("ConfigGroupMgr need init by db"))
}
ctx, cancel := context.WithCancel(context.Background())
return &_ConfigGroupMgr{_BaseMgr: &_BaseMgr{DB: db.Table("config_group"), isRelated: globalIsRelated, ctx: ctx, cancel: cancel, timeout: -1}}
}
// Debug open debug.打开debug模式查看sql语句
func (obj *_ConfigGroupMgr) Debug() *_ConfigGroupMgr {
obj._BaseMgr.DB = obj._BaseMgr.DB.Debug()
return obj
}
// GetTableName get sql table name.获取数据库名字
func (obj *_ConfigGroupMgr) GetTableName() string {
return "config_group"
}
// Reset 重置gorm会话
func (obj *_ConfigGroupMgr) Reset() *_ConfigGroupMgr {
obj.New()
return obj
}
// Get 获取
func (obj *_ConfigGroupMgr) Get() (result ConfigGroup, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ConfigGroup{}).First(&result).Error
return
}
// Gets 获取批量结果
func (obj *_ConfigGroupMgr) Gets() (results []*ConfigGroup, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ConfigGroup{}).Find(&results).Error
return
}
// //////////////////////////////// gorm replace /////////////////////////////////
func (obj *_ConfigGroupMgr) Count(count *int64) (tx *gorm.DB) {
return obj.DB.WithContext(obj.ctx).Model(ConfigGroup{}).Count(count)
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////option case ////////////////////////////////////////////
// WithID id获取 配置分组ID
func (obj *_ConfigGroupMgr) WithID(id int64) Option {
return optionFunc(func(o *options) { o.query["id"] = id })
}
// WithName name获取 分组关键字
func (obj *_ConfigGroupMgr) WithName(name string) Option {
return optionFunc(func(o *options) { o.query["name"] = name })
}
// WithTitle title获取 分组信息描述
func (obj *_ConfigGroupMgr) WithTitle(title string) Option {
return optionFunc(func(o *options) { o.query["title"] = title })
}
// GetByOption 功能选项模式获取
func (obj *_ConfigGroupMgr) GetByOption(opts ...Option) (result ConfigGroup, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(ConfigGroup{}).Where(options.query).First(&result).Error
return
}
// GetByOptions 批量功能选项模式获取
func (obj *_ConfigGroupMgr) GetByOptions(opts ...Option) (results []*ConfigGroup, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(ConfigGroup{}).Where(options.query).Find(&results).Error
return
}
// SelectPage 分页查询
func (obj *_ConfigGroupMgr) SelectPage(page IPage, opts ...Option) (resultPage IPage, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
resultPage = page
results := make([]ConfigGroup, 0)
var count int64 // 统计总的记录数
query := obj.DB.WithContext(obj.ctx).Model(ConfigGroup{}).Where(options.query)
query.Count(&count)
resultPage.SetTotal(count)
if len(page.GetOrederItemsString()) > 0 {
query = query.Order(page.GetOrederItemsString())
}
err = query.Limit(int(page.GetSize())).Offset(int(page.Offset())).Find(&results).Error
resultPage.SetRecords(results)
return
}
//////////////////////////enume case ////////////////////////////////////////////
// GetFromID 通过id获取内容 配置分组ID
func (obj *_ConfigGroupMgr) GetFromID(id int64) (result ConfigGroup, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ConfigGroup{}).Where("`id` = ?", id).First(&result).Error
return
}
// GetBatchFromID 批量查找 配置分组ID
func (obj *_ConfigGroupMgr) GetBatchFromID(ids []int64) (results []*ConfigGroup, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ConfigGroup{}).Where("`id` IN (?)", ids).Find(&results).Error
return
}
// GetFromName 通过name获取内容 分组关键字
func (obj *_ConfigGroupMgr) GetFromName(name string) (result ConfigGroup, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ConfigGroup{}).Where("`name` = ?", name).First(&result).Error
return
}
// GetBatchFromName 批量查找 分组关键字
func (obj *_ConfigGroupMgr) GetBatchFromName(names []string) (results []*ConfigGroup, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ConfigGroup{}).Where("`name` IN (?)", names).Find(&results).Error
return
}
// GetFromTitle 通过title获取内容 分组信息描述
func (obj *_ConfigGroupMgr) GetFromTitle(title string) (results []*ConfigGroup, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ConfigGroup{}).Where("`title` = ?", title).Find(&results).Error
return
}
// GetBatchFromTitle 批量查找 分组信息描述
func (obj *_ConfigGroupMgr) GetBatchFromTitle(titles []string) (results []*ConfigGroup, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ConfigGroup{}).Where("`title` IN (?)", titles).Find(&results).Error
return
}
//////////////////////////primary index case ////////////////////////////////////////////
// FetchByPrimaryKey primary or index 获取唯一内容
func (obj *_ConfigGroupMgr) FetchByPrimaryKey(id int64) (result ConfigGroup, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ConfigGroup{}).Where("`id` = ?", id).First(&result).Error
return
}
// FetchUniqueByConfigGroupUn primary or index 获取唯一内容
func (obj *_ConfigGroupMgr) FetchUniqueByConfigGroupUn(name string) (result ConfigGroup, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ConfigGroup{}).Where("`name` = ?", name).First(&result).Error
return
}
This diff is collapsed.
This diff is collapsed.
package model
import (
"context"
"fmt"
"gorm.io/gorm"
"time"
)
type _ItemDataDefineMgr struct {
*_BaseMgr
}
// ItemDataDefineMgr open func
func ItemDataDefineMgr(db *gorm.DB) *_ItemDataDefineMgr {
if db == nil {
panic(fmt.Errorf("ItemDataDefineMgr need init by db"))
}
ctx, cancel := context.WithCancel(context.Background())
return &_ItemDataDefineMgr{_BaseMgr: &_BaseMgr{DB: db.Table("item_data_define"), isRelated: globalIsRelated, ctx: ctx, cancel: cancel, timeout: -1}}
}
// Debug open debug.打开debug模式查看sql语句
func (obj *_ItemDataDefineMgr) Debug() *_ItemDataDefineMgr {
obj._BaseMgr.DB = obj._BaseMgr.DB.Debug()
return obj
}
// GetTableName get sql table name.获取数据库名字
func (obj *_ItemDataDefineMgr) GetTableName() string {
return "item_data_define"
}
// Reset 重置gorm会话
func (obj *_ItemDataDefineMgr) Reset() *_ItemDataDefineMgr {
obj.New()
return obj
}
// Get 获取
func (obj *_ItemDataDefineMgr) Get() (result ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).First(&result).Error
return
}
// Gets 获取批量结果
func (obj *_ItemDataDefineMgr) Gets() (results []*ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Find(&results).Error
return
}
// //////////////////////////////// gorm replace /////////////////////////////////
func (obj *_ItemDataDefineMgr) Count(count *int64) (tx *gorm.DB) {
return obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Count(count)
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////option case ////////////////////////////////////////////
// WithID id获取 精灵道具表ID
func (obj *_ItemDataDefineMgr) WithID(id int64) Option {
return optionFunc(func(o *options) { o.query["id"] = id })
}
// WithItemType item_type获取 道具类别:baby, normal
func (obj *_ItemDataDefineMgr) WithItemType(itemType string) Option {
return optionFunc(func(o *options) { o.query["item_type"] = itemType })
}
// WithURL url获取 图片url
func (obj *_ItemDataDefineMgr) WithURL(url string) Option {
return optionFunc(func(o *options) { o.query["url"] = url })
}
// WithAllocateOrder allocate_order获取 分配顺序
func (obj *_ItemDataDefineMgr) WithAllocateOrder(allocateOrder int64) Option {
return optionFunc(func(o *options) { o.query["allocate_order"] = allocateOrder })
}
// WithAllocateType allocate_type获取 有没分配,0:未分配, 1:已分配
func (obj *_ItemDataDefineMgr) WithAllocateType(allocateType int) Option {
return optionFunc(func(o *options) { o.query["allocate_type"] = allocateType })
}
// WithCreateTime create_time获取 创建时间
func (obj *_ItemDataDefineMgr) WithCreateTime(createTime time.Time) Option {
return optionFunc(func(o *options) { o.query["create_time"] = createTime })
}
// WithUpdateTime update_time获取 更新时间
func (obj *_ItemDataDefineMgr) WithUpdateTime(updateTime time.Time) Option {
return optionFunc(func(o *options) { o.query["update_time"] = updateTime })
}
// GetByOption 功能选项模式获取
func (obj *_ItemDataDefineMgr) GetByOption(opts ...Option) (result ItemDataDefine, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where(options.query).First(&result).Error
return
}
// GetByOptions 批量功能选项模式获取
func (obj *_ItemDataDefineMgr) GetByOptions(opts ...Option) (results []*ItemDataDefine, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where(options.query).Find(&results).Error
return
}
// SelectPage 分页查询
func (obj *_ItemDataDefineMgr) SelectPage(page IPage, opts ...Option) (resultPage IPage, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
resultPage = page
results := make([]ItemDataDefine, 0)
var count int64 // 统计总的记录数
query := obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where(options.query)
query.Count(&count)
resultPage.SetTotal(count)
if len(page.GetOrederItemsString()) > 0 {
query = query.Order(page.GetOrederItemsString())
}
err = query.Limit(int(page.GetSize())).Offset(int(page.Offset())).Find(&results).Error
resultPage.SetRecords(results)
return
}
//////////////////////////enume case ////////////////////////////////////////////
// GetFromID 通过id获取内容 精灵道具表ID
func (obj *_ItemDataDefineMgr) GetFromID(id int64) (result ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where("`id` = ?", id).First(&result).Error
return
}
// GetBatchFromID 批量查找 精灵道具表ID
func (obj *_ItemDataDefineMgr) GetBatchFromID(ids []int64) (results []*ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where("`id` IN (?)", ids).Find(&results).Error
return
}
// GetFromItemType 通过item_type获取内容 道具类别:baby, normal
func (obj *_ItemDataDefineMgr) GetFromItemType(itemType string) (results []*ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where("`item_type` = ?", itemType).Find(&results).Error
return
}
// GetBatchFromItemType 批量查找 道具类别:baby, normal
func (obj *_ItemDataDefineMgr) GetBatchFromItemType(itemTypes []string) (results []*ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where("`item_type` IN (?)", itemTypes).Find(&results).Error
return
}
// GetFromURL 通过url获取内容 图片url
func (obj *_ItemDataDefineMgr) GetFromURL(url string) (results []*ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where("`url` = ?", url).Find(&results).Error
return
}
// GetBatchFromURL 批量查找 图片url
func (obj *_ItemDataDefineMgr) GetBatchFromURL(urls []string) (results []*ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where("`url` IN (?)", urls).Find(&results).Error
return
}
// GetFromAllocateOrder 通过allocate_order获取内容 分配顺序
func (obj *_ItemDataDefineMgr) GetFromAllocateOrder(allocateOrder int64) (results []*ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where("`allocate_order` = ?", allocateOrder).Find(&results).Error
return
}
// GetBatchFromAllocateOrder 批量查找 分配顺序
func (obj *_ItemDataDefineMgr) GetBatchFromAllocateOrder(allocateOrders []int64) (results []*ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where("`allocate_order` IN (?)", allocateOrders).Find(&results).Error
return
}
// GetFromAllocateType 通过allocate_type获取内容 有没分配,0:未分配, 1:已分配
func (obj *_ItemDataDefineMgr) GetFromAllocateType(allocateType int) (results []*ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where("`allocate_type` = ?", allocateType).Find(&results).Error
return
}
// GetBatchFromAllocateType 批量查找 有没分配,0:未分配, 1:已分配
func (obj *_ItemDataDefineMgr) GetBatchFromAllocateType(allocateTypes []int) (results []*ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where("`allocate_type` IN (?)", allocateTypes).Find(&results).Error
return
}
// GetFromCreateTime 通过create_time获取内容 创建时间
func (obj *_ItemDataDefineMgr) GetFromCreateTime(createTime time.Time) (results []*ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where("`create_time` = ?", createTime).Find(&results).Error
return
}
// GetBatchFromCreateTime 批量查找 创建时间
func (obj *_ItemDataDefineMgr) GetBatchFromCreateTime(createTimes []time.Time) (results []*ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where("`create_time` IN (?)", createTimes).Find(&results).Error
return
}
// GetFromUpdateTime 通过update_time获取内容 更新时间
func (obj *_ItemDataDefineMgr) GetFromUpdateTime(updateTime time.Time) (results []*ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where("`update_time` = ?", updateTime).Find(&results).Error
return
}
// GetBatchFromUpdateTime 批量查找 更新时间
func (obj *_ItemDataDefineMgr) GetBatchFromUpdateTime(updateTimes []time.Time) (results []*ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where("`update_time` IN (?)", updateTimes).Find(&results).Error
return
}
//////////////////////////primary index case ////////////////////////////////////////////
// FetchByPrimaryKey primary or index 获取唯一内容
func (obj *_ItemDataDefineMgr) FetchByPrimaryKey(id int64) (result ItemDataDefine, err error) {
err = obj.DB.WithContext(obj.ctx).Model(ItemDataDefine{}).Where("`id` = ?", id).First(&result).Error
return
}
package model
import (
"context"
"fmt"
"gorm.io/gorm"
)
type _LocalAuthMgr struct {
*_BaseMgr
}
// LocalAuthMgr open func
func LocalAuthMgr(db *gorm.DB) *_LocalAuthMgr {
if db == nil {
panic(fmt.Errorf("LocalAuthMgr need init by db"))
}
ctx, cancel := context.WithCancel(context.Background())
return &_LocalAuthMgr{_BaseMgr: &_BaseMgr{DB: db.Table("local_auth"), isRelated: globalIsRelated, ctx: ctx, cancel: cancel, timeout: -1}}
}
// Debug open debug.打开debug模式查看sql语句
func (obj *_LocalAuthMgr) Debug() *_LocalAuthMgr {
obj._BaseMgr.DB = obj._BaseMgr.DB.Debug()
return obj
}
// GetTableName get sql table name.获取数据库名字
func (obj *_LocalAuthMgr) GetTableName() string {
return "local_auth"
}
// Reset 重置gorm会话
func (obj *_LocalAuthMgr) Reset() *_LocalAuthMgr {
obj.New()
return obj
}
// Get 获取
func (obj *_LocalAuthMgr) Get() (result LocalAuth, err error) {
err = obj.DB.WithContext(obj.ctx).Model(LocalAuth{}).First(&result).Error
if err == nil && obj.isRelated {
if err = obj.NewDB().Table("users").Where("id = ?", result.ID).Find(&result.Users).Error; err != nil { //
if err != gorm.ErrRecordNotFound { // 非 没找到
return
}
}
}
return
}
// Gets 获取批量结果
func (obj *_LocalAuthMgr) Gets() (results []*LocalAuth, err error) {
err = obj.DB.WithContext(obj.ctx).Model(LocalAuth{}).Find(&results).Error
if err == nil && obj.isRelated {
for i := 0; i < len(results); i++ {
if err = obj.NewDB().Table("users").Where("id = ?", results[i].ID).Find(&results[i].Users).Error; err != nil { //
if err != gorm.ErrRecordNotFound { // 非 没找到
return
}
}
}
}
return
}
// //////////////////////////////// gorm replace /////////////////////////////////
func (obj *_LocalAuthMgr) Count(count *int64) (tx *gorm.DB) {
return obj.DB.WithContext(obj.ctx).Model(LocalAuth{}).Count(count)
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////option case ////////////////////////////////////////////
// WithID id获取 用户唯一ID
func (obj *_LocalAuthMgr) WithID(id int64) Option {
return optionFunc(func(o *options) { o.query["id"] = id })
}
// WithAccountID account_id获取 账户标识
func (obj *_LocalAuthMgr) WithAccountID(accountID string) Option {
return optionFunc(func(o *options) { o.query["account_id"] = accountID })
}
// GetByOption 功能选项模式获取
func (obj *_LocalAuthMgr) GetByOption(opts ...Option) (result LocalAuth, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(LocalAuth{}).Where(options.query).First(&result).Error
if err == nil && obj.isRelated {
if err = obj.NewDB().Table("users").Where("id = ?", result.ID).Find(&result.Users).Error; err != nil { //
if err != gorm.ErrRecordNotFound { // 非 没找到
return
}
}
}
return
}
// GetByOptions 批量功能选项模式获取
func (obj *_LocalAuthMgr) GetByOptions(opts ...Option) (results []*LocalAuth, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(LocalAuth{}).Where(options.query).Find(&results).Error
if err == nil && obj.isRelated {
for i := 0; i < len(results); i++ {
if err = obj.NewDB().Table("users").Where("id = ?", results[i].ID).Find(&results[i].Users).Error; err != nil { //
if err != gorm.ErrRecordNotFound { // 非 没找到
return
}
}
}
}
return
}
// SelectPage 分页查询
func (obj *_LocalAuthMgr) SelectPage(page IPage, opts ...Option) (resultPage IPage, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
resultPage = page
results := make([]LocalAuth, 0)
var count int64 // 统计总的记录数
query := obj.DB.WithContext(obj.ctx).Model(LocalAuth{}).Where(options.query)
query.Count(&count)
resultPage.SetTotal(count)
if len(page.GetOrederItemsString()) > 0 {
query = query.Order(page.GetOrederItemsString())
}
err = query.Limit(int(page.GetSize())).Offset(int(page.Offset())).Find(&results).Error
if err == nil && obj.isRelated {
for i := 0; i < len(results); i++ {
if err = obj.NewDB().Table("users").Where("id = ?", results[i].ID).Find(&results[i].Users).Error; err != nil { //
if err != gorm.ErrRecordNotFound { // 非 没找到
return
}
}
}
}
resultPage.SetRecords(results)
return
}
//////////////////////////enume case ////////////////////////////////////////////
// GetFromID 通过id获取内容 用户唯一ID
func (obj *_LocalAuthMgr) GetFromID(id int64) (result LocalAuth, err error) {
err = obj.DB.WithContext(obj.ctx).Model(LocalAuth{}).Where("`id` = ?", id).First(&result).Error
if err == nil && obj.isRelated {
if err = obj.NewDB().Table("users").Where("id = ?", result.ID).Find(&result.Users).Error; err != nil { //
if err != gorm.ErrRecordNotFound { // 非 没找到
return
}
}
}
return
}
// GetBatchFromID 批量查找 用户唯一ID
func (obj *_LocalAuthMgr) GetBatchFromID(ids []int64) (results []*LocalAuth, err error) {
err = obj.DB.WithContext(obj.ctx).Model(LocalAuth{}).Where("`id` IN (?)", ids).Find(&results).Error
if err == nil && obj.isRelated {
for i := 0; i < len(results); i++ {
if err = obj.NewDB().Table("users").Where("id = ?", results[i].ID).Find(&results[i].Users).Error; err != nil { //
if err != gorm.ErrRecordNotFound { // 非 没找到
return
}
}
}
}
return
}
// GetFromAccountID 通过account_id获取内容 账户标识
func (obj *_LocalAuthMgr) GetFromAccountID(accountID string) (result LocalAuth, err error) {
err = obj.DB.WithContext(obj.ctx).Model(LocalAuth{}).Where("`account_id` = ?", accountID).First(&result).Error
if err == nil && obj.isRelated {
if err = obj.NewDB().Table("users").Where("id = ?", result.ID).Find(&result.Users).Error; err != nil { //
if err != gorm.ErrRecordNotFound { // 非 没找到
return
}
}
}
return
}
// GetBatchFromAccountID 批量查找 账户标识
func (obj *_LocalAuthMgr) GetBatchFromAccountID(accountIDs []string) (results []*LocalAuth, err error) {
err = obj.DB.WithContext(obj.ctx).Model(LocalAuth{}).Where("`account_id` IN (?)", accountIDs).Find(&results).Error
if err == nil && obj.isRelated {
for i := 0; i < len(results); i++ {
if err = obj.NewDB().Table("users").Where("id = ?", results[i].ID).Find(&results[i].Users).Error; err != nil { //
if err != gorm.ErrRecordNotFound { // 非 没找到
return
}
}
}
}
return
}
//////////////////////////primary index case ////////////////////////////////////////////
// FetchByPrimaryKey primary or index 获取唯一内容
func (obj *_LocalAuthMgr) FetchByPrimaryKey(id int64) (result LocalAuth, err error) {
err = obj.DB.WithContext(obj.ctx).Model(LocalAuth{}).Where("`id` = ?", id).First(&result).Error
if err == nil && obj.isRelated {
if err = obj.NewDB().Table("users").Where("id = ?", result.ID).Find(&result.Users).Error; err != nil { //
if err != gorm.ErrRecordNotFound { // 非 没找到
return
}
}
}
return
}
// FetchUniqueByLocalAuthUnName primary or index 获取唯一内容
func (obj *_LocalAuthMgr) FetchUniqueByLocalAuthUnName(accountID string) (result LocalAuth, err error) {
err = obj.DB.WithContext(obj.ctx).Model(LocalAuth{}).Where("`account_id` = ?", accountID).First(&result).Error
if err == nil && obj.isRelated {
if err = obj.NewDB().Table("users").Where("id = ?", result.ID).Find(&result.Users).Error; err != nil { //
if err != gorm.ErrRecordNotFound { // 非 没找到
return
}
}
}
return
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
package model
import (
"context"
"fmt"
"gorm.io/gorm"
"time"
)
type _SysJobLogMgr struct {
*_BaseMgr
}
// SysJobLogMgr open func
func SysJobLogMgr(db *gorm.DB) *_SysJobLogMgr {
if db == nil {
panic(fmt.Errorf("SysJobLogMgr need init by db"))
}
ctx, cancel := context.WithCancel(context.Background())
return &_SysJobLogMgr{_BaseMgr: &_BaseMgr{DB: db.Table("sys_job_log"), isRelated: globalIsRelated, ctx: ctx, cancel: cancel, timeout: -1}}
}
// Debug open debug.打开debug模式查看sql语句
func (obj *_SysJobLogMgr) Debug() *_SysJobLogMgr {
obj._BaseMgr.DB = obj._BaseMgr.DB.Debug()
return obj
}
// GetTableName get sql table name.获取数据库名字
func (obj *_SysJobLogMgr) GetTableName() string {
return "sys_job_log"
}
// Reset 重置gorm会话
func (obj *_SysJobLogMgr) Reset() *_SysJobLogMgr {
obj.New()
return obj
}
// Get 获取
func (obj *_SysJobLogMgr) Get() (result SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).First(&result).Error
return
}
// Gets 获取批量结果
func (obj *_SysJobLogMgr) Gets() (results []*SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Find(&results).Error
return
}
// //////////////////////////////// gorm replace /////////////////////////////////
func (obj *_SysJobLogMgr) Count(count *int64) (tx *gorm.DB) {
return obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Count(count)
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////option case ////////////////////////////////////////////
// WithJobLogID job_log_id获取 任务日志ID
func (obj *_SysJobLogMgr) WithJobLogID(jobLogID int64) Option {
return optionFunc(func(o *options) { o.query["job_log_id"] = jobLogID })
}
// WithJobName job_name获取 任务名称
func (obj *_SysJobLogMgr) WithJobName(jobName string) Option {
return optionFunc(func(o *options) { o.query["job_name"] = jobName })
}
// WithJobGroup job_group获取 任务组名
func (obj *_SysJobLogMgr) WithJobGroup(jobGroup string) Option {
return optionFunc(func(o *options) { o.query["job_group"] = jobGroup })
}
// WithInvokeTarget invoke_target获取 调用目标字符串
func (obj *_SysJobLogMgr) WithInvokeTarget(invokeTarget string) Option {
return optionFunc(func(o *options) { o.query["invoke_target"] = invokeTarget })
}
// WithJobMessage job_message获取 日志信息
func (obj *_SysJobLogMgr) WithJobMessage(jobMessage string) Option {
return optionFunc(func(o *options) { o.query["job_message"] = jobMessage })
}
// WithStatus status获取 执行状态(0正常 1失败)
func (obj *_SysJobLogMgr) WithStatus(status string) Option {
return optionFunc(func(o *options) { o.query["status"] = status })
}
// WithExceptionInfo exception_info获取 异常信息
func (obj *_SysJobLogMgr) WithExceptionInfo(exceptionInfo string) Option {
return optionFunc(func(o *options) { o.query["exception_info"] = exceptionInfo })
}
// WithCreateTime create_time获取 创建时间
func (obj *_SysJobLogMgr) WithCreateTime(createTime time.Time) Option {
return optionFunc(func(o *options) { o.query["create_time"] = createTime })
}
// GetByOption 功能选项模式获取
func (obj *_SysJobLogMgr) GetByOption(opts ...Option) (result SysJobLog, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where(options.query).First(&result).Error
return
}
// GetByOptions 批量功能选项模式获取
func (obj *_SysJobLogMgr) GetByOptions(opts ...Option) (results []*SysJobLog, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where(options.query).Find(&results).Error
return
}
// SelectPage 分页查询
func (obj *_SysJobLogMgr) SelectPage(page IPage, opts ...Option) (resultPage IPage, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
resultPage = page
results := make([]SysJobLog, 0)
var count int64 // 统计总的记录数
query := obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where(options.query)
query.Count(&count)
resultPage.SetTotal(count)
if len(page.GetOrederItemsString()) > 0 {
query = query.Order(page.GetOrederItemsString())
}
err = query.Limit(int(page.GetSize())).Offset(int(page.Offset())).Find(&results).Error
resultPage.SetRecords(results)
return
}
//////////////////////////enume case ////////////////////////////////////////////
// GetFromJobLogID 通过job_log_id获取内容 任务日志ID
func (obj *_SysJobLogMgr) GetFromJobLogID(jobLogID int64) (result SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`job_log_id` = ?", jobLogID).First(&result).Error
return
}
// GetBatchFromJobLogID 批量查找 任务日志ID
func (obj *_SysJobLogMgr) GetBatchFromJobLogID(jobLogIDs []int64) (results []*SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`job_log_id` IN (?)", jobLogIDs).Find(&results).Error
return
}
// GetFromJobName 通过job_name获取内容 任务名称
func (obj *_SysJobLogMgr) GetFromJobName(jobName string) (results []*SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`job_name` = ?", jobName).Find(&results).Error
return
}
// GetBatchFromJobName 批量查找 任务名称
func (obj *_SysJobLogMgr) GetBatchFromJobName(jobNames []string) (results []*SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`job_name` IN (?)", jobNames).Find(&results).Error
return
}
// GetFromJobGroup 通过job_group获取内容 任务组名
func (obj *_SysJobLogMgr) GetFromJobGroup(jobGroup string) (results []*SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`job_group` = ?", jobGroup).Find(&results).Error
return
}
// GetBatchFromJobGroup 批量查找 任务组名
func (obj *_SysJobLogMgr) GetBatchFromJobGroup(jobGroups []string) (results []*SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`job_group` IN (?)", jobGroups).Find(&results).Error
return
}
// GetFromInvokeTarget 通过invoke_target获取内容 调用目标字符串
func (obj *_SysJobLogMgr) GetFromInvokeTarget(invokeTarget string) (results []*SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`invoke_target` = ?", invokeTarget).Find(&results).Error
return
}
// GetBatchFromInvokeTarget 批量查找 调用目标字符串
func (obj *_SysJobLogMgr) GetBatchFromInvokeTarget(invokeTargets []string) (results []*SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`invoke_target` IN (?)", invokeTargets).Find(&results).Error
return
}
// GetFromJobMessage 通过job_message获取内容 日志信息
func (obj *_SysJobLogMgr) GetFromJobMessage(jobMessage string) (results []*SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`job_message` = ?", jobMessage).Find(&results).Error
return
}
// GetBatchFromJobMessage 批量查找 日志信息
func (obj *_SysJobLogMgr) GetBatchFromJobMessage(jobMessages []string) (results []*SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`job_message` IN (?)", jobMessages).Find(&results).Error
return
}
// GetFromStatus 通过status获取内容 执行状态(0正常 1失败)
func (obj *_SysJobLogMgr) GetFromStatus(status string) (results []*SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`status` = ?", status).Find(&results).Error
return
}
// GetBatchFromStatus 批量查找 执行状态(0正常 1失败)
func (obj *_SysJobLogMgr) GetBatchFromStatus(statuss []string) (results []*SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`status` IN (?)", statuss).Find(&results).Error
return
}
// GetFromExceptionInfo 通过exception_info获取内容 异常信息
func (obj *_SysJobLogMgr) GetFromExceptionInfo(exceptionInfo string) (results []*SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`exception_info` = ?", exceptionInfo).Find(&results).Error
return
}
// GetBatchFromExceptionInfo 批量查找 异常信息
func (obj *_SysJobLogMgr) GetBatchFromExceptionInfo(exceptionInfos []string) (results []*SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`exception_info` IN (?)", exceptionInfos).Find(&results).Error
return
}
// GetFromCreateTime 通过create_time获取内容 创建时间
func (obj *_SysJobLogMgr) GetFromCreateTime(createTime time.Time) (results []*SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`create_time` = ?", createTime).Find(&results).Error
return
}
// GetBatchFromCreateTime 批量查找 创建时间
func (obj *_SysJobLogMgr) GetBatchFromCreateTime(createTimes []time.Time) (results []*SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`create_time` IN (?)", createTimes).Find(&results).Error
return
}
//////////////////////////primary index case ////////////////////////////////////////////
// FetchByPrimaryKey primary or index 获取唯一内容
func (obj *_SysJobLogMgr) FetchByPrimaryKey(jobLogID int64) (result SysJobLog, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysJobLog{}).Where("`job_log_id` = ?", jobLogID).First(&result).Error
return
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
package model
import (
"context"
"fmt"
"gorm.io/gorm"
)
type _SysRoleDeptMgr struct {
*_BaseMgr
}
// SysRoleDeptMgr open func
func SysRoleDeptMgr(db *gorm.DB) *_SysRoleDeptMgr {
if db == nil {
panic(fmt.Errorf("SysRoleDeptMgr need init by db"))
}
ctx, cancel := context.WithCancel(context.Background())
return &_SysRoleDeptMgr{_BaseMgr: &_BaseMgr{DB: db.Table("sys_role_dept"), isRelated: globalIsRelated, ctx: ctx, cancel: cancel, timeout: -1}}
}
// Debug open debug.打开debug模式查看sql语句
func (obj *_SysRoleDeptMgr) Debug() *_SysRoleDeptMgr {
obj._BaseMgr.DB = obj._BaseMgr.DB.Debug()
return obj
}
// GetTableName get sql table name.获取数据库名字
func (obj *_SysRoleDeptMgr) GetTableName() string {
return "sys_role_dept"
}
// Reset 重置gorm会话
func (obj *_SysRoleDeptMgr) Reset() *_SysRoleDeptMgr {
obj.New()
return obj
}
// Get 获取
func (obj *_SysRoleDeptMgr) Get() (result SysRoleDept, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysRoleDept{}).First(&result).Error
return
}
// Gets 获取批量结果
func (obj *_SysRoleDeptMgr) Gets() (results []*SysRoleDept, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysRoleDept{}).Find(&results).Error
return
}
// //////////////////////////////// gorm replace /////////////////////////////////
func (obj *_SysRoleDeptMgr) Count(count *int64) (tx *gorm.DB) {
return obj.DB.WithContext(obj.ctx).Model(SysRoleDept{}).Count(count)
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////option case ////////////////////////////////////////////
// WithRoleID role_id获取 角色ID
func (obj *_SysRoleDeptMgr) WithRoleID(roleID int64) Option {
return optionFunc(func(o *options) { o.query["role_id"] = roleID })
}
// WithDeptID dept_id获取 部门ID
func (obj *_SysRoleDeptMgr) WithDeptID(deptID int64) Option {
return optionFunc(func(o *options) { o.query["dept_id"] = deptID })
}
// GetByOption 功能选项模式获取
func (obj *_SysRoleDeptMgr) GetByOption(opts ...Option) (result SysRoleDept, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(SysRoleDept{}).Where(options.query).First(&result).Error
return
}
// GetByOptions 批量功能选项模式获取
func (obj *_SysRoleDeptMgr) GetByOptions(opts ...Option) (results []*SysRoleDept, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(SysRoleDept{}).Where(options.query).Find(&results).Error
return
}
// SelectPage 分页查询
func (obj *_SysRoleDeptMgr) SelectPage(page IPage, opts ...Option) (resultPage IPage, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
resultPage = page
results := make([]SysRoleDept, 0)
var count int64 // 统计总的记录数
query := obj.DB.WithContext(obj.ctx).Model(SysRoleDept{}).Where(options.query)
query.Count(&count)
resultPage.SetTotal(count)
if len(page.GetOrederItemsString()) > 0 {
query = query.Order(page.GetOrederItemsString())
}
err = query.Limit(int(page.GetSize())).Offset(int(page.Offset())).Find(&results).Error
resultPage.SetRecords(results)
return
}
//////////////////////////enume case ////////////////////////////////////////////
// GetFromRoleID 通过role_id获取内容 角色ID
func (obj *_SysRoleDeptMgr) GetFromRoleID(roleID int64) (results []*SysRoleDept, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysRoleDept{}).Where("`role_id` = ?", roleID).Find(&results).Error
return
}
// GetBatchFromRoleID 批量查找 角色ID
func (obj *_SysRoleDeptMgr) GetBatchFromRoleID(roleIDs []int64) (results []*SysRoleDept, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysRoleDept{}).Where("`role_id` IN (?)", roleIDs).Find(&results).Error
return
}
// GetFromDeptID 通过dept_id获取内容 部门ID
func (obj *_SysRoleDeptMgr) GetFromDeptID(deptID int64) (results []*SysRoleDept, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysRoleDept{}).Where("`dept_id` = ?", deptID).Find(&results).Error
return
}
// GetBatchFromDeptID 批量查找 部门ID
func (obj *_SysRoleDeptMgr) GetBatchFromDeptID(deptIDs []int64) (results []*SysRoleDept, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysRoleDept{}).Where("`dept_id` IN (?)", deptIDs).Find(&results).Error
return
}
//////////////////////////primary index case ////////////////////////////////////////////
// FetchByPrimaryKey primary or index 获取唯一内容
func (obj *_SysRoleDeptMgr) FetchByPrimaryKey(roleID int64, deptID int64) (result SysRoleDept, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysRoleDept{}).Where("`role_id` = ? AND `dept_id` = ?", roleID, deptID).First(&result).Error
return
}
package model
import (
"context"
"fmt"
"gorm.io/gorm"
)
type _SysRoleMenuMgr struct {
*_BaseMgr
}
// SysRoleMenuMgr open func
func SysRoleMenuMgr(db *gorm.DB) *_SysRoleMenuMgr {
if db == nil {
panic(fmt.Errorf("SysRoleMenuMgr need init by db"))
}
ctx, cancel := context.WithCancel(context.Background())
return &_SysRoleMenuMgr{_BaseMgr: &_BaseMgr{DB: db.Table("sys_role_menu"), isRelated: globalIsRelated, ctx: ctx, cancel: cancel, timeout: -1}}
}
// Debug open debug.打开debug模式查看sql语句
func (obj *_SysRoleMenuMgr) Debug() *_SysRoleMenuMgr {
obj._BaseMgr.DB = obj._BaseMgr.DB.Debug()
return obj
}
// GetTableName get sql table name.获取数据库名字
func (obj *_SysRoleMenuMgr) GetTableName() string {
return "sys_role_menu"
}
// Reset 重置gorm会话
func (obj *_SysRoleMenuMgr) Reset() *_SysRoleMenuMgr {
obj.New()
return obj
}
// Get 获取
func (obj *_SysRoleMenuMgr) Get() (result SysRoleMenu, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysRoleMenu{}).First(&result).Error
return
}
// Gets 获取批量结果
func (obj *_SysRoleMenuMgr) Gets() (results []*SysRoleMenu, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysRoleMenu{}).Find(&results).Error
return
}
// //////////////////////////////// gorm replace /////////////////////////////////
func (obj *_SysRoleMenuMgr) Count(count *int64) (tx *gorm.DB) {
return obj.DB.WithContext(obj.ctx).Model(SysRoleMenu{}).Count(count)
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////option case ////////////////////////////////////////////
// WithRoleID role_id获取 角色ID
func (obj *_SysRoleMenuMgr) WithRoleID(roleID int64) Option {
return optionFunc(func(o *options) { o.query["role_id"] = roleID })
}
// WithMenuID menu_id获取 菜单ID
func (obj *_SysRoleMenuMgr) WithMenuID(menuID int64) Option {
return optionFunc(func(o *options) { o.query["menu_id"] = menuID })
}
// GetByOption 功能选项模式获取
func (obj *_SysRoleMenuMgr) GetByOption(opts ...Option) (result SysRoleMenu, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(SysRoleMenu{}).Where(options.query).First(&result).Error
return
}
// GetByOptions 批量功能选项模式获取
func (obj *_SysRoleMenuMgr) GetByOptions(opts ...Option) (results []*SysRoleMenu, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(SysRoleMenu{}).Where(options.query).Find(&results).Error
return
}
// SelectPage 分页查询
func (obj *_SysRoleMenuMgr) SelectPage(page IPage, opts ...Option) (resultPage IPage, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
resultPage = page
results := make([]SysRoleMenu, 0)
var count int64 // 统计总的记录数
query := obj.DB.WithContext(obj.ctx).Model(SysRoleMenu{}).Where(options.query)
query.Count(&count)
resultPage.SetTotal(count)
if len(page.GetOrederItemsString()) > 0 {
query = query.Order(page.GetOrederItemsString())
}
err = query.Limit(int(page.GetSize())).Offset(int(page.Offset())).Find(&results).Error
resultPage.SetRecords(results)
return
}
//////////////////////////enume case ////////////////////////////////////////////
// GetFromRoleID 通过role_id获取内容 角色ID
func (obj *_SysRoleMenuMgr) GetFromRoleID(roleID int64) (results []*SysRoleMenu, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysRoleMenu{}).Where("`role_id` = ?", roleID).Find(&results).Error
return
}
// GetBatchFromRoleID 批量查找 角色ID
func (obj *_SysRoleMenuMgr) GetBatchFromRoleID(roleIDs []int64) (results []*SysRoleMenu, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysRoleMenu{}).Where("`role_id` IN (?)", roleIDs).Find(&results).Error
return
}
// GetFromMenuID 通过menu_id获取内容 菜单ID
func (obj *_SysRoleMenuMgr) GetFromMenuID(menuID int64) (results []*SysRoleMenu, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysRoleMenu{}).Where("`menu_id` = ?", menuID).Find(&results).Error
return
}
// GetBatchFromMenuID 批量查找 菜单ID
func (obj *_SysRoleMenuMgr) GetBatchFromMenuID(menuIDs []int64) (results []*SysRoleMenu, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysRoleMenu{}).Where("`menu_id` IN (?)", menuIDs).Find(&results).Error
return
}
//////////////////////////primary index case ////////////////////////////////////////////
// FetchByPrimaryKey primary or index 获取唯一内容
func (obj *_SysRoleMenuMgr) FetchByPrimaryKey(roleID int64, menuID int64) (result SysRoleMenu, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysRoleMenu{}).Where("`role_id` = ? AND `menu_id` = ?", roleID, menuID).First(&result).Error
return
}
package model
import (
"context"
"fmt"
"gorm.io/gorm"
"time"
)
type _SysTreeFaqCategoryMgr struct {
*_BaseMgr
}
// SysTreeFaqCategoryMgr open func
func SysTreeFaqCategoryMgr(db *gorm.DB) *_SysTreeFaqCategoryMgr {
if db == nil {
panic(fmt.Errorf("SysTreeFaqCategoryMgr need init by db"))
}
ctx, cancel := context.WithCancel(context.Background())
return &_SysTreeFaqCategoryMgr{_BaseMgr: &_BaseMgr{DB: db.Table("sys_tree_faq_category"), isRelated: globalIsRelated, ctx: ctx, cancel: cancel, timeout: -1}}
}
// Debug open debug.打开debug模式查看sql语句
func (obj *_SysTreeFaqCategoryMgr) Debug() *_SysTreeFaqCategoryMgr {
obj._BaseMgr.DB = obj._BaseMgr.DB.Debug()
return obj
}
// GetTableName get sql table name.获取数据库名字
func (obj *_SysTreeFaqCategoryMgr) GetTableName() string {
return "sys_tree_faq_category"
}
// Reset 重置gorm会话
func (obj *_SysTreeFaqCategoryMgr) Reset() *_SysTreeFaqCategoryMgr {
obj.New()
return obj
}
// Get 获取
func (obj *_SysTreeFaqCategoryMgr) Get() (result SysTreeFaqCategory, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).First(&result).Error
return
}
// Gets 获取批量结果
func (obj *_SysTreeFaqCategoryMgr) Gets() (results []*SysTreeFaqCategory, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).Find(&results).Error
return
}
// //////////////////////////////// gorm replace /////////////////////////////////
func (obj *_SysTreeFaqCategoryMgr) Count(count *int64) (tx *gorm.DB) {
return obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).Count(count)
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////option case ////////////////////////////////////////////
// WithID id获取 ID
func (obj *_SysTreeFaqCategoryMgr) WithID(id int64) Option {
return optionFunc(func(o *options) { o.query["id"] = id })
}
// WithTitle title获取 标题
func (obj *_SysTreeFaqCategoryMgr) WithTitle(title string) Option {
return optionFunc(func(o *options) { o.query["title"] = title })
}
// WithCreateTime create_time获取 提交时间
func (obj *_SysTreeFaqCategoryMgr) WithCreateTime(createTime time.Time) Option {
return optionFunc(func(o *options) { o.query["create_time"] = createTime })
}
// WithUpdateTime update_time获取 更新时间
func (obj *_SysTreeFaqCategoryMgr) WithUpdateTime(updateTime time.Time) Option {
return optionFunc(func(o *options) { o.query["update_time"] = updateTime })
}
// WithLang lang获取 语言
func (obj *_SysTreeFaqCategoryMgr) WithLang(lang string) Option {
return optionFunc(func(o *options) { o.query["lang"] = lang })
}
// GetByOption 功能选项模式获取
func (obj *_SysTreeFaqCategoryMgr) GetByOption(opts ...Option) (result SysTreeFaqCategory, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).Where(options.query).First(&result).Error
return
}
// GetByOptions 批量功能选项模式获取
func (obj *_SysTreeFaqCategoryMgr) GetByOptions(opts ...Option) (results []*SysTreeFaqCategory, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).Where(options.query).Find(&results).Error
return
}
// SelectPage 分页查询
func (obj *_SysTreeFaqCategoryMgr) SelectPage(page IPage, opts ...Option) (resultPage IPage, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
resultPage = page
results := make([]SysTreeFaqCategory, 0)
var count int64 // 统计总的记录数
query := obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).Where(options.query)
query.Count(&count)
resultPage.SetTotal(count)
if len(page.GetOrederItemsString()) > 0 {
query = query.Order(page.GetOrederItemsString())
}
err = query.Limit(int(page.GetSize())).Offset(int(page.Offset())).Find(&results).Error
resultPage.SetRecords(results)
return
}
//////////////////////////enume case ////////////////////////////////////////////
// GetFromID 通过id获取内容 ID
func (obj *_SysTreeFaqCategoryMgr) GetFromID(id int64) (result SysTreeFaqCategory, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).Where("`id` = ?", id).First(&result).Error
return
}
// GetBatchFromID 批量查找 ID
func (obj *_SysTreeFaqCategoryMgr) GetBatchFromID(ids []int64) (results []*SysTreeFaqCategory, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).Where("`id` IN (?)", ids).Find(&results).Error
return
}
// GetFromTitle 通过title获取内容 标题
func (obj *_SysTreeFaqCategoryMgr) GetFromTitle(title string) (results []*SysTreeFaqCategory, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).Where("`title` = ?", title).Find(&results).Error
return
}
// GetBatchFromTitle 批量查找 标题
func (obj *_SysTreeFaqCategoryMgr) GetBatchFromTitle(titles []string) (results []*SysTreeFaqCategory, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).Where("`title` IN (?)", titles).Find(&results).Error
return
}
// GetFromCreateTime 通过create_time获取内容 提交时间
func (obj *_SysTreeFaqCategoryMgr) GetFromCreateTime(createTime time.Time) (results []*SysTreeFaqCategory, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).Where("`create_time` = ?", createTime).Find(&results).Error
return
}
// GetBatchFromCreateTime 批量查找 提交时间
func (obj *_SysTreeFaqCategoryMgr) GetBatchFromCreateTime(createTimes []time.Time) (results []*SysTreeFaqCategory, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).Where("`create_time` IN (?)", createTimes).Find(&results).Error
return
}
// GetFromUpdateTime 通过update_time获取内容 更新时间
func (obj *_SysTreeFaqCategoryMgr) GetFromUpdateTime(updateTime time.Time) (results []*SysTreeFaqCategory, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).Where("`update_time` = ?", updateTime).Find(&results).Error
return
}
// GetBatchFromUpdateTime 批量查找 更新时间
func (obj *_SysTreeFaqCategoryMgr) GetBatchFromUpdateTime(updateTimes []time.Time) (results []*SysTreeFaqCategory, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).Where("`update_time` IN (?)", updateTimes).Find(&results).Error
return
}
// GetFromLang 通过lang获取内容 语言
func (obj *_SysTreeFaqCategoryMgr) GetFromLang(lang string) (results []*SysTreeFaqCategory, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).Where("`lang` = ?", lang).Find(&results).Error
return
}
// GetBatchFromLang 批量查找 语言
func (obj *_SysTreeFaqCategoryMgr) GetBatchFromLang(langs []string) (results []*SysTreeFaqCategory, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).Where("`lang` IN (?)", langs).Find(&results).Error
return
}
//////////////////////////primary index case ////////////////////////////////////////////
// FetchByPrimaryKey primary or index 获取唯一内容
func (obj *_SysTreeFaqCategoryMgr) FetchByPrimaryKey(id int64) (result SysTreeFaqCategory, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeFaqCategory{}).Where("`id` = ?", id).First(&result).Error
return
}
This diff is collapsed.
package model
import (
"context"
"fmt"
"gorm.io/gorm"
"time"
)
type _SysTreeSuggestionMgr struct {
*_BaseMgr
}
// SysTreeSuggestionMgr open func
func SysTreeSuggestionMgr(db *gorm.DB) *_SysTreeSuggestionMgr {
if db == nil {
panic(fmt.Errorf("SysTreeSuggestionMgr need init by db"))
}
ctx, cancel := context.WithCancel(context.Background())
return &_SysTreeSuggestionMgr{_BaseMgr: &_BaseMgr{DB: db.Table("sys_tree_suggestion"), isRelated: globalIsRelated, ctx: ctx, cancel: cancel, timeout: -1}}
}
// Debug open debug.打开debug模式查看sql语句
func (obj *_SysTreeSuggestionMgr) Debug() *_SysTreeSuggestionMgr {
obj._BaseMgr.DB = obj._BaseMgr.DB.Debug()
return obj
}
// GetTableName get sql table name.获取数据库名字
func (obj *_SysTreeSuggestionMgr) GetTableName() string {
return "sys_tree_suggestion"
}
// Reset 重置gorm会话
func (obj *_SysTreeSuggestionMgr) Reset() *_SysTreeSuggestionMgr {
obj.New()
return obj
}
// Get 获取
func (obj *_SysTreeSuggestionMgr) Get() (result SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).First(&result).Error
return
}
// Gets 获取批量结果
func (obj *_SysTreeSuggestionMgr) Gets() (results []*SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Find(&results).Error
return
}
// //////////////////////////////// gorm replace /////////////////////////////////
func (obj *_SysTreeSuggestionMgr) Count(count *int64) (tx *gorm.DB) {
return obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Count(count)
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////option case ////////////////////////////////////////////
// WithID id获取 ID
func (obj *_SysTreeSuggestionMgr) WithID(id int64) Option {
return optionFunc(func(o *options) { o.query["id"] = id })
}
// WithTitle title获取 标题
func (obj *_SysTreeSuggestionMgr) WithTitle(title string) Option {
return optionFunc(func(o *options) { o.query["title"] = title })
}
// WithBody body获取 内容
func (obj *_SysTreeSuggestionMgr) WithBody(body string) Option {
return optionFunc(func(o *options) { o.query["body"] = body })
}
// WithUser user获取 提交人ID
func (obj *_SysTreeSuggestionMgr) WithUser(user int64) Option {
return optionFunc(func(o *options) { o.query["user"] = user })
}
// WithStatus status获取 问题状态
func (obj *_SysTreeSuggestionMgr) WithStatus(status int16) Option {
return optionFunc(func(o *options) { o.query["status"] = status })
}
// WithCreateTime create_time获取 提交时间
func (obj *_SysTreeSuggestionMgr) WithCreateTime(createTime time.Time) Option {
return optionFunc(func(o *options) { o.query["create_time"] = createTime })
}
// WithUpdateTime update_time获取 最后更新时间
func (obj *_SysTreeSuggestionMgr) WithUpdateTime(updateTime time.Time) Option {
return optionFunc(func(o *options) { o.query["update_time"] = updateTime })
}
// WithResponse response获取 问题答复
func (obj *_SysTreeSuggestionMgr) WithResponse(response string) Option {
return optionFunc(func(o *options) { o.query["response"] = response })
}
// GetByOption 功能选项模式获取
func (obj *_SysTreeSuggestionMgr) GetByOption(opts ...Option) (result SysTreeSuggestion, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where(options.query).First(&result).Error
return
}
// GetByOptions 批量功能选项模式获取
func (obj *_SysTreeSuggestionMgr) GetByOptions(opts ...Option) (results []*SysTreeSuggestion, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where(options.query).Find(&results).Error
return
}
// SelectPage 分页查询
func (obj *_SysTreeSuggestionMgr) SelectPage(page IPage, opts ...Option) (resultPage IPage, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
resultPage = page
results := make([]SysTreeSuggestion, 0)
var count int64 // 统计总的记录数
query := obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where(options.query)
query.Count(&count)
resultPage.SetTotal(count)
if len(page.GetOrederItemsString()) > 0 {
query = query.Order(page.GetOrederItemsString())
}
err = query.Limit(int(page.GetSize())).Offset(int(page.Offset())).Find(&results).Error
resultPage.SetRecords(results)
return
}
//////////////////////////enume case ////////////////////////////////////////////
// GetFromID 通过id获取内容 ID
func (obj *_SysTreeSuggestionMgr) GetFromID(id int64) (result SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`id` = ?", id).First(&result).Error
return
}
// GetBatchFromID 批量查找 ID
func (obj *_SysTreeSuggestionMgr) GetBatchFromID(ids []int64) (results []*SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`id` IN (?)", ids).Find(&results).Error
return
}
// GetFromTitle 通过title获取内容 标题
func (obj *_SysTreeSuggestionMgr) GetFromTitle(title string) (results []*SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`title` = ?", title).Find(&results).Error
return
}
// GetBatchFromTitle 批量查找 标题
func (obj *_SysTreeSuggestionMgr) GetBatchFromTitle(titles []string) (results []*SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`title` IN (?)", titles).Find(&results).Error
return
}
// GetFromBody 通过body获取内容 内容
func (obj *_SysTreeSuggestionMgr) GetFromBody(body string) (results []*SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`body` = ?", body).Find(&results).Error
return
}
// GetBatchFromBody 批量查找 内容
func (obj *_SysTreeSuggestionMgr) GetBatchFromBody(bodys []string) (results []*SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`body` IN (?)", bodys).Find(&results).Error
return
}
// GetFromUser 通过user获取内容 提交人ID
func (obj *_SysTreeSuggestionMgr) GetFromUser(user int64) (results []*SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`user` = ?", user).Find(&results).Error
return
}
// GetBatchFromUser 批量查找 提交人ID
func (obj *_SysTreeSuggestionMgr) GetBatchFromUser(users []int64) (results []*SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`user` IN (?)", users).Find(&results).Error
return
}
// GetFromStatus 通过status获取内容 问题状态
func (obj *_SysTreeSuggestionMgr) GetFromStatus(status int16) (results []*SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`status` = ?", status).Find(&results).Error
return
}
// GetBatchFromStatus 批量查找 问题状态
func (obj *_SysTreeSuggestionMgr) GetBatchFromStatus(statuss []int16) (results []*SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`status` IN (?)", statuss).Find(&results).Error
return
}
// GetFromCreateTime 通过create_time获取内容 提交时间
func (obj *_SysTreeSuggestionMgr) GetFromCreateTime(createTime time.Time) (results []*SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`create_time` = ?", createTime).Find(&results).Error
return
}
// GetBatchFromCreateTime 批量查找 提交时间
func (obj *_SysTreeSuggestionMgr) GetBatchFromCreateTime(createTimes []time.Time) (results []*SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`create_time` IN (?)", createTimes).Find(&results).Error
return
}
// GetFromUpdateTime 通过update_time获取内容 最后更新时间
func (obj *_SysTreeSuggestionMgr) GetFromUpdateTime(updateTime time.Time) (results []*SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`update_time` = ?", updateTime).Find(&results).Error
return
}
// GetBatchFromUpdateTime 批量查找 最后更新时间
func (obj *_SysTreeSuggestionMgr) GetBatchFromUpdateTime(updateTimes []time.Time) (results []*SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`update_time` IN (?)", updateTimes).Find(&results).Error
return
}
// GetFromResponse 通过response获取内容 问题答复
func (obj *_SysTreeSuggestionMgr) GetFromResponse(response string) (results []*SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`response` = ?", response).Find(&results).Error
return
}
// GetBatchFromResponse 批量查找 问题答复
func (obj *_SysTreeSuggestionMgr) GetBatchFromResponse(responses []string) (results []*SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`response` IN (?)", responses).Find(&results).Error
return
}
//////////////////////////primary index case ////////////////////////////////////////////
// FetchByPrimaryKey primary or index 获取唯一内容
func (obj *_SysTreeSuggestionMgr) FetchByPrimaryKey(id int64) (result SysTreeSuggestion, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysTreeSuggestion{}).Where("`id` = ?", id).First(&result).Error
return
}
This diff is collapsed.
package model
import (
"context"
"fmt"
"gorm.io/gorm"
)
type _SysUserPostMgr struct {
*_BaseMgr
}
// SysUserPostMgr open func
func SysUserPostMgr(db *gorm.DB) *_SysUserPostMgr {
if db == nil {
panic(fmt.Errorf("SysUserPostMgr need init by db"))
}
ctx, cancel := context.WithCancel(context.Background())
return &_SysUserPostMgr{_BaseMgr: &_BaseMgr{DB: db.Table("sys_user_post"), isRelated: globalIsRelated, ctx: ctx, cancel: cancel, timeout: -1}}
}
// Debug open debug.打开debug模式查看sql语句
func (obj *_SysUserPostMgr) Debug() *_SysUserPostMgr {
obj._BaseMgr.DB = obj._BaseMgr.DB.Debug()
return obj
}
// GetTableName get sql table name.获取数据库名字
func (obj *_SysUserPostMgr) GetTableName() string {
return "sys_user_post"
}
// Reset 重置gorm会话
func (obj *_SysUserPostMgr) Reset() *_SysUserPostMgr {
obj.New()
return obj
}
// Get 获取
func (obj *_SysUserPostMgr) Get() (result SysUserPost, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysUserPost{}).First(&result).Error
return
}
// Gets 获取批量结果
func (obj *_SysUserPostMgr) Gets() (results []*SysUserPost, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysUserPost{}).Find(&results).Error
return
}
// //////////////////////////////// gorm replace /////////////////////////////////
func (obj *_SysUserPostMgr) Count(count *int64) (tx *gorm.DB) {
return obj.DB.WithContext(obj.ctx).Model(SysUserPost{}).Count(count)
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////option case ////////////////////////////////////////////
// WithUserID user_id获取 用户ID
func (obj *_SysUserPostMgr) WithUserID(userID int64) Option {
return optionFunc(func(o *options) { o.query["user_id"] = userID })
}
// WithPostID post_id获取 岗位ID
func (obj *_SysUserPostMgr) WithPostID(postID int64) Option {
return optionFunc(func(o *options) { o.query["post_id"] = postID })
}
// GetByOption 功能选项模式获取
func (obj *_SysUserPostMgr) GetByOption(opts ...Option) (result SysUserPost, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(SysUserPost{}).Where(options.query).First(&result).Error
return
}
// GetByOptions 批量功能选项模式获取
func (obj *_SysUserPostMgr) GetByOptions(opts ...Option) (results []*SysUserPost, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(SysUserPost{}).Where(options.query).Find(&results).Error
return
}
// SelectPage 分页查询
func (obj *_SysUserPostMgr) SelectPage(page IPage, opts ...Option) (resultPage IPage, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
resultPage = page
results := make([]SysUserPost, 0)
var count int64 // 统计总的记录数
query := obj.DB.WithContext(obj.ctx).Model(SysUserPost{}).Where(options.query)
query.Count(&count)
resultPage.SetTotal(count)
if len(page.GetOrederItemsString()) > 0 {
query = query.Order(page.GetOrederItemsString())
}
err = query.Limit(int(page.GetSize())).Offset(int(page.Offset())).Find(&results).Error
resultPage.SetRecords(results)
return
}
//////////////////////////enume case ////////////////////////////////////////////
// GetFromUserID 通过user_id获取内容 用户ID
func (obj *_SysUserPostMgr) GetFromUserID(userID int64) (results []*SysUserPost, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysUserPost{}).Where("`user_id` = ?", userID).Find(&results).Error
return
}
// GetBatchFromUserID 批量查找 用户ID
func (obj *_SysUserPostMgr) GetBatchFromUserID(userIDs []int64) (results []*SysUserPost, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysUserPost{}).Where("`user_id` IN (?)", userIDs).Find(&results).Error
return
}
// GetFromPostID 通过post_id获取内容 岗位ID
func (obj *_SysUserPostMgr) GetFromPostID(postID int64) (results []*SysUserPost, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysUserPost{}).Where("`post_id` = ?", postID).Find(&results).Error
return
}
// GetBatchFromPostID 批量查找 岗位ID
func (obj *_SysUserPostMgr) GetBatchFromPostID(postIDs []int64) (results []*SysUserPost, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysUserPost{}).Where("`post_id` IN (?)", postIDs).Find(&results).Error
return
}
//////////////////////////primary index case ////////////////////////////////////////////
// FetchByPrimaryKey primary or index 获取唯一内容
func (obj *_SysUserPostMgr) FetchByPrimaryKey(userID int64, postID int64) (result SysUserPost, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysUserPost{}).Where("`user_id` = ? AND `post_id` = ?", userID, postID).First(&result).Error
return
}
package model
import (
"context"
"fmt"
"gorm.io/gorm"
)
type _SysUserRoleMgr struct {
*_BaseMgr
}
// SysUserRoleMgr open func
func SysUserRoleMgr(db *gorm.DB) *_SysUserRoleMgr {
if db == nil {
panic(fmt.Errorf("SysUserRoleMgr need init by db"))
}
ctx, cancel := context.WithCancel(context.Background())
return &_SysUserRoleMgr{_BaseMgr: &_BaseMgr{DB: db.Table("sys_user_role"), isRelated: globalIsRelated, ctx: ctx, cancel: cancel, timeout: -1}}
}
// Debug open debug.打开debug模式查看sql语句
func (obj *_SysUserRoleMgr) Debug() *_SysUserRoleMgr {
obj._BaseMgr.DB = obj._BaseMgr.DB.Debug()
return obj
}
// GetTableName get sql table name.获取数据库名字
func (obj *_SysUserRoleMgr) GetTableName() string {
return "sys_user_role"
}
// Reset 重置gorm会话
func (obj *_SysUserRoleMgr) Reset() *_SysUserRoleMgr {
obj.New()
return obj
}
// Get 获取
func (obj *_SysUserRoleMgr) Get() (result SysUserRole, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysUserRole{}).First(&result).Error
return
}
// Gets 获取批量结果
func (obj *_SysUserRoleMgr) Gets() (results []*SysUserRole, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysUserRole{}).Find(&results).Error
return
}
// //////////////////////////////// gorm replace /////////////////////////////////
func (obj *_SysUserRoleMgr) Count(count *int64) (tx *gorm.DB) {
return obj.DB.WithContext(obj.ctx).Model(SysUserRole{}).Count(count)
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////option case ////////////////////////////////////////////
// WithUserID user_id获取 用户ID
func (obj *_SysUserRoleMgr) WithUserID(userID int64) Option {
return optionFunc(func(o *options) { o.query["user_id"] = userID })
}
// WithRoleID role_id获取 角色ID
func (obj *_SysUserRoleMgr) WithRoleID(roleID int64) Option {
return optionFunc(func(o *options) { o.query["role_id"] = roleID })
}
// GetByOption 功能选项模式获取
func (obj *_SysUserRoleMgr) GetByOption(opts ...Option) (result SysUserRole, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(SysUserRole{}).Where(options.query).First(&result).Error
return
}
// GetByOptions 批量功能选项模式获取
func (obj *_SysUserRoleMgr) GetByOptions(opts ...Option) (results []*SysUserRole, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(SysUserRole{}).Where(options.query).Find(&results).Error
return
}
// SelectPage 分页查询
func (obj *_SysUserRoleMgr) SelectPage(page IPage, opts ...Option) (resultPage IPage, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
resultPage = page
results := make([]SysUserRole, 0)
var count int64 // 统计总的记录数
query := obj.DB.WithContext(obj.ctx).Model(SysUserRole{}).Where(options.query)
query.Count(&count)
resultPage.SetTotal(count)
if len(page.GetOrederItemsString()) > 0 {
query = query.Order(page.GetOrederItemsString())
}
err = query.Limit(int(page.GetSize())).Offset(int(page.Offset())).Find(&results).Error
resultPage.SetRecords(results)
return
}
//////////////////////////enume case ////////////////////////////////////////////
// GetFromUserID 通过user_id获取内容 用户ID
func (obj *_SysUserRoleMgr) GetFromUserID(userID int64) (results []*SysUserRole, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysUserRole{}).Where("`user_id` = ?", userID).Find(&results).Error
return
}
// GetBatchFromUserID 批量查找 用户ID
func (obj *_SysUserRoleMgr) GetBatchFromUserID(userIDs []int64) (results []*SysUserRole, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysUserRole{}).Where("`user_id` IN (?)", userIDs).Find(&results).Error
return
}
// GetFromRoleID 通过role_id获取内容 角色ID
func (obj *_SysUserRoleMgr) GetFromRoleID(roleID int64) (results []*SysUserRole, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysUserRole{}).Where("`role_id` = ?", roleID).Find(&results).Error
return
}
// GetBatchFromRoleID 批量查找 角色ID
func (obj *_SysUserRoleMgr) GetBatchFromRoleID(roleIDs []int64) (results []*SysUserRole, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysUserRole{}).Where("`role_id` IN (?)", roleIDs).Find(&results).Error
return
}
//////////////////////////primary index case ////////////////////////////////////////////
// FetchByPrimaryKey primary or index 获取唯一内容
func (obj *_SysUserRoleMgr) FetchByPrimaryKey(userID int64, roleID int64) (result SysUserRole, err error) {
err = obj.DB.WithContext(obj.ctx).Model(SysUserRole{}).Where("`user_id` = ? AND `role_id` = ?", userID, roleID).First(&result).Error
return
}
This diff is collapsed.
package model
import (
"context"
"fmt"
"gorm.io/gorm"
"time"
)
type _TestMgr struct {
*_BaseMgr
}
// TestMgr open func
func TestMgr(db *gorm.DB) *_TestMgr {
if db == nil {
panic(fmt.Errorf("TestMgr need init by db"))
}
ctx, cancel := context.WithCancel(context.Background())
return &_TestMgr{_BaseMgr: &_BaseMgr{DB: db.Table("test"), isRelated: globalIsRelated, ctx: ctx, cancel: cancel, timeout: -1}}
}
// Debug open debug.打开debug模式查看sql语句
func (obj *_TestMgr) Debug() *_TestMgr {
obj._BaseMgr.DB = obj._BaseMgr.DB.Debug()
return obj
}
// GetTableName get sql table name.获取数据库名字
func (obj *_TestMgr) GetTableName() string {
return "test"
}
// Reset 重置gorm会话
func (obj *_TestMgr) Reset() *_TestMgr {
obj.New()
return obj
}
// Get 获取
func (obj *_TestMgr) Get() (result Test, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Test{}).First(&result).Error
return
}
// Gets 获取批量结果
func (obj *_TestMgr) Gets() (results []*Test, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Test{}).Find(&results).Error
return
}
// //////////////////////////////// gorm replace /////////////////////////////////
func (obj *_TestMgr) Count(count *int64) (tx *gorm.DB) {
return obj.DB.WithContext(obj.ctx).Model(Test{}).Count(count)
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////option case ////////////////////////////////////////////
// WithDddd dddd获取
func (obj *_TestMgr) WithDddd(dddd time.Time) Option {
return optionFunc(func(o *options) { o.query["dddd"] = dddd })
}
// GetByOption 功能选项模式获取
func (obj *_TestMgr) GetByOption(opts ...Option) (result Test, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(Test{}).Where(options.query).First(&result).Error
return
}
// GetByOptions 批量功能选项模式获取
func (obj *_TestMgr) GetByOptions(opts ...Option) (results []*Test, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(Test{}).Where(options.query).Find(&results).Error
return
}
// SelectPage 分页查询
func (obj *_TestMgr) SelectPage(page IPage, opts ...Option) (resultPage IPage, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
resultPage = page
results := make([]Test, 0)
var count int64 // 统计总的记录数
query := obj.DB.WithContext(obj.ctx).Model(Test{}).Where(options.query)
query.Count(&count)
resultPage.SetTotal(count)
if len(page.GetOrederItemsString()) > 0 {
query = query.Order(page.GetOrederItemsString())
}
err = query.Limit(int(page.GetSize())).Offset(int(page.Offset())).Find(&results).Error
resultPage.SetRecords(results)
return
}
//////////////////////////enume case ////////////////////////////////////////////
// GetFromDddd 通过dddd获取内容
func (obj *_TestMgr) GetFromDddd(dddd time.Time) (results []*Test, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Test{}).Where("`dddd` = ?", dddd).Find(&results).Error
return
}
// GetBatchFromDddd 批量查找
func (obj *_TestMgr) GetBatchFromDddd(dddds []time.Time) (results []*Test, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Test{}).Where("`dddd` IN (?)", dddds).Find(&results).Error
return
}
//////////////////////////primary index case ////////////////////////////////////////////
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
package model
import (
"context"
"fmt"
"gorm.io/gorm"
"time"
)
type _UsersMgr struct {
*_BaseMgr
}
// UsersMgr open func
func UsersMgr(db *gorm.DB) *_UsersMgr {
if db == nil {
panic(fmt.Errorf("UsersMgr need init by db"))
}
ctx, cancel := context.WithCancel(context.Background())
return &_UsersMgr{_BaseMgr: &_BaseMgr{DB: db.Table("users"), isRelated: globalIsRelated, ctx: ctx, cancel: cancel, timeout: -1}}
}
// Debug open debug.打开debug模式查看sql语句
func (obj *_UsersMgr) Debug() *_UsersMgr {
obj._BaseMgr.DB = obj._BaseMgr.DB.Debug()
return obj
}
// GetTableName get sql table name.获取数据库名字
func (obj *_UsersMgr) GetTableName() string {
return "users"
}
// Reset 重置gorm会话
func (obj *_UsersMgr) Reset() *_UsersMgr {
obj.New()
return obj
}
// Get 获取
func (obj *_UsersMgr) Get() (result Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).First(&result).Error
return
}
// Gets 获取批量结果
func (obj *_UsersMgr) Gets() (results []*Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Find(&results).Error
return
}
// //////////////////////////////// gorm replace /////////////////////////////////
func (obj *_UsersMgr) Count(count *int64) (tx *gorm.DB) {
return obj.DB.WithContext(obj.ctx).Model(Users{}).Count(count)
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////option case ////////////////////////////////////////////
// WithID id获取 自增主键
func (obj *_UsersMgr) WithID(id int64) Option {
return optionFunc(func(o *options) { o.query["id"] = id })
}
// WithAccountID account_id获取 账户标识
func (obj *_UsersMgr) WithAccountID(accountID string) Option {
return optionFunc(func(o *options) { o.query["account_id"] = accountID })
}
// WithEthAddress eth_address获取 ETH地址
func (obj *_UsersMgr) WithEthAddress(ethAddress string) Option {
return optionFunc(func(o *options) { o.query["eth_address"] = ethAddress })
}
// WithAvatar avatar获取 头像地址
func (obj *_UsersMgr) WithAvatar(avatar string) Option {
return optionFunc(func(o *options) { o.query["avatar"] = avatar })
}
// WithInvitor invitor获取 邀请人
func (obj *_UsersMgr) WithInvitor(invitor string) Option {
return optionFunc(func(o *options) { o.query["invitor"] = invitor })
}
// WithCreatedAt created_at获取 注册时间
func (obj *_UsersMgr) WithCreatedAt(createdAt time.Time) Option {
return optionFunc(func(o *options) { o.query["created_at"] = createdAt })
}
// WithUpdatedAt updated_at获取 更新时间
func (obj *_UsersMgr) WithUpdatedAt(updatedAt time.Time) Option {
return optionFunc(func(o *options) { o.query["updated_at"] = updatedAt })
}
// GetByOption 功能选项模式获取
func (obj *_UsersMgr) GetByOption(opts ...Option) (result Users, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where(options.query).First(&result).Error
return
}
// GetByOptions 批量功能选项模式获取
func (obj *_UsersMgr) GetByOptions(opts ...Option) (results []*Users, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where(options.query).Find(&results).Error
return
}
// SelectPage 分页查询
func (obj *_UsersMgr) SelectPage(page IPage, opts ...Option) (resultPage IPage, err error) {
options := options{
query: make(map[string]interface{}, len(opts)),
}
for _, o := range opts {
o.apply(&options)
}
resultPage = page
results := make([]Users, 0)
var count int64 // 统计总的记录数
query := obj.DB.WithContext(obj.ctx).Model(Users{}).Where(options.query)
query.Count(&count)
resultPage.SetTotal(count)
if len(page.GetOrederItemsString()) > 0 {
query = query.Order(page.GetOrederItemsString())
}
err = query.Limit(int(page.GetSize())).Offset(int(page.Offset())).Find(&results).Error
resultPage.SetRecords(results)
return
}
//////////////////////////enume case ////////////////////////////////////////////
// GetFromID 通过id获取内容 自增主键
func (obj *_UsersMgr) GetFromID(id int64) (result Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where("`id` = ?", id).First(&result).Error
return
}
// GetBatchFromID 批量查找 自增主键
func (obj *_UsersMgr) GetBatchFromID(ids []int64) (results []*Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where("`id` IN (?)", ids).Find(&results).Error
return
}
// GetFromAccountID 通过account_id获取内容 账户标识
func (obj *_UsersMgr) GetFromAccountID(accountID string) (result Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where("`account_id` = ?", accountID).First(&result).Error
return
}
// GetBatchFromAccountID 批量查找 账户标识
func (obj *_UsersMgr) GetBatchFromAccountID(accountIDs []string) (results []*Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where("`account_id` IN (?)", accountIDs).Find(&results).Error
return
}
// GetFromEthAddress 通过eth_address获取内容 ETH地址
func (obj *_UsersMgr) GetFromEthAddress(ethAddress string) (results []*Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where("`eth_address` = ?", ethAddress).Find(&results).Error
return
}
// GetBatchFromEthAddress 批量查找 ETH地址
func (obj *_UsersMgr) GetBatchFromEthAddress(ethAddresss []string) (results []*Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where("`eth_address` IN (?)", ethAddresss).Find(&results).Error
return
}
// GetFromAvatar 通过avatar获取内容 头像地址
func (obj *_UsersMgr) GetFromAvatar(avatar string) (results []*Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where("`avatar` = ?", avatar).Find(&results).Error
return
}
// GetBatchFromAvatar 批量查找 头像地址
func (obj *_UsersMgr) GetBatchFromAvatar(avatars []string) (results []*Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where("`avatar` IN (?)", avatars).Find(&results).Error
return
}
// GetFromInvitor 通过invitor获取内容 邀请人
func (obj *_UsersMgr) GetFromInvitor(invitor string) (results []*Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where("`invitor` = ?", invitor).Find(&results).Error
return
}
// GetBatchFromInvitor 批量查找 邀请人
func (obj *_UsersMgr) GetBatchFromInvitor(invitors []string) (results []*Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where("`invitor` IN (?)", invitors).Find(&results).Error
return
}
// GetFromCreatedAt 通过created_at获取内容 注册时间
func (obj *_UsersMgr) GetFromCreatedAt(createdAt time.Time) (results []*Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where("`created_at` = ?", createdAt).Find(&results).Error
return
}
// GetBatchFromCreatedAt 批量查找 注册时间
func (obj *_UsersMgr) GetBatchFromCreatedAt(createdAts []time.Time) (results []*Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where("`created_at` IN (?)", createdAts).Find(&results).Error
return
}
// GetFromUpdatedAt 通过updated_at获取内容 更新时间
func (obj *_UsersMgr) GetFromUpdatedAt(updatedAt time.Time) (results []*Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where("`updated_at` = ?", updatedAt).Find(&results).Error
return
}
// GetBatchFromUpdatedAt 批量查找 更新时间
func (obj *_UsersMgr) GetBatchFromUpdatedAt(updatedAts []time.Time) (results []*Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where("`updated_at` IN (?)", updatedAts).Find(&results).Error
return
}
//////////////////////////primary index case ////////////////////////////////////////////
// FetchByPrimaryKey primary or index 获取唯一内容
func (obj *_UsersMgr) FetchByPrimaryKey(id int64) (result Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where("`id` = ?", id).First(&result).Error
return
}
// FetchUniqueByUsersUn primary or index 获取唯一内容
func (obj *_UsersMgr) FetchUniqueByUsersUn(accountID string) (result Users, err error) {
err = obj.DB.WithContext(obj.ctx).Model(Users{}).Where("`account_id` = ?", accountID).First(&result).Error
return
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment