ai_scheduler/internal/data/impl/session_impl.go

43 lines
950 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package impl
import (
"ai_scheduler/internal/data/model"
"ai_scheduler/tmpl/dataTemp"
"ai_scheduler/utils"
"gorm.io/gorm"
"time"
)
type SessionImpl struct {
dataTemp.DataTemp
BaseModel[model.AiSession]
}
func NewSessionImpl(db *utils.Db) *SessionImpl {
return &SessionImpl{
DataTemp: *dataTemp.NewDataTemp(db, new(model.AiSession)),
BaseModel: BaseModel[model.AiSession]{},
}
}
// WithUserId 条件用户ID
func (impl *SessionImpl) WithUserId(userId interface{}) CondFunc {
return func(db *gorm.DB) *gorm.DB {
return db.Where("user_id = ?", userId)
}
}
// WithStartTime 条件:会话开始时间
func (impl *SessionImpl) WithStartTime(startTime time.Time) CondFunc {
return func(db *gorm.DB) *gorm.DB {
return db.Where("create_at >= ?", startTime)
}
}
// WithSysId 系统id
func (s *SessionImpl) WithSysId(sysId interface{}) CondFunc {
return func(db *gorm.DB) *gorm.DB {
return db.Where("sys_id = ?", sysId)
}
}