2026-02-28 15:29:16 +08:00
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/stores/cache"
|
|
|
|
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var _ InvStockImportLogModel = (*customInvStockImportLogModel)(nil)
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
|
InvStockImportLogModel interface {
|
|
|
|
|
invStockImportLogModel
|
2026-03-30 02:53:55 +00:00
|
|
|
FindList(ctx context.Context, tenantId string, page, pageSize int64) ([]*InvStockImportLog, int64, error)
|
2026-02-28 15:29:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
customInvStockImportLogModel struct {
|
|
|
|
|
*defaultInvStockImportLogModel
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func NewInvStockImportLogModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) InvStockImportLogModel {
|
|
|
|
|
return &customInvStockImportLogModel{
|
|
|
|
|
defaultInvStockImportLogModel: newInvStockImportLogModel(conn, c, opts...),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-30 02:53:55 +00:00
|
|
|
func (m *customInvStockImportLogModel) FindList(ctx context.Context, tenantId string, page, pageSize int64) ([]*InvStockImportLog, int64, error) {
|
2026-02-28 15:29:16 +08:00
|
|
|
var total int64
|
2026-03-30 02:53:55 +00:00
|
|
|
countQuery := fmt.Sprintf("SELECT COUNT(*) FROM %s WHERE tenant_id = ?", m.table)
|
|
|
|
|
err := m.QueryRowNoCacheCtx(ctx, &total, countQuery, tenantId)
|
2026-02-28 15:29:16 +08:00
|
|
|
if err != nil {
|
|
|
|
|
return nil, 0, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var list []*InvStockImportLog
|
2026-03-30 02:53:55 +00:00
|
|
|
query := fmt.Sprintf("SELECT %s FROM %s WHERE tenant_id = ? ORDER BY created_at DESC LIMIT ? OFFSET ?", invStockImportLogRows, m.table)
|
|
|
|
|
err = m.QueryRowsNoCacheCtx(ctx, &list, query, tenantId, pageSize, (page-1)*pageSize)
|
2026-02-28 15:29:16 +08:00
|
|
|
if err != nil {
|
|
|
|
|
return nil, 0, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list, total, nil
|
|
|
|
|
}
|