代码拉取完成,页面将自动刷新
package hubLogRepo
import (
"context"
"fmt"
"gitee.com/unitedrhino/share/def"
"gitee.com/unitedrhino/share/stores"
"gitee.com/unitedrhino/things/service/dmsvr/internal/domain/deviceLog"
)
func (h *HubLogRepo) fillFilter(ctx context.Context, db *stores.DB, filter deviceLog.HubFilter) *stores.DB {
db = db.WithContext(ctx)
if len(filter.ProductID) != 0 {
db = db.Where("product_id=?", filter.ProductID)
}
if len(filter.DeviceName) != 0 {
db = db.Where("device_name=?", filter.DeviceName)
}
if len(filter.Content) != 0 {
db = db.Where("content=?", filter.Content)
}
if len(filter.RequestID) != 0 {
db = db.Where("request_id=?", filter.RequestID)
}
if len(filter.Actions) != 0 {
db = db.Where(fmt.Sprintf("action in (%v)", stores.ArrayToSql(filter.Actions)))
}
if len(filter.Topics) != 0 {
db = db.Where(fmt.Sprintf("topic in (%v)", stores.ArrayToSql(filter.Topics)))
}
return db
}
func (h *HubLogRepo) GetCountLog(ctx context.Context, filter deviceLog.HubFilter, page def.PageInfo2) (int64, error) {
db := h.fillFilter(ctx, h.db, filter)
var count int64
err := db.Model(Hub{}).Count(&count).Error
return count, stores.ErrFmt(err)
}
func (h *HubLogRepo) GetDeviceLog(ctx context.Context, filter deviceLog.HubFilter, page def.PageInfo2) (
[]*deviceLog.Hub, error) {
db := h.fillFilter(ctx, h.db, filter)
db = page.FmtSql2(db)
var list []*deviceLog.Hub
err := db.Model(Hub{}).Find(&list).Error
return list, stores.ErrFmt(err)
}
func (h *HubLogRepo) Insert(ctx context.Context, data *deviceLog.Hub) error {
h.asyncInsert.AsyncInsert(&Hub{Hub: data})
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。