feat:session wire
This commit is contained in:
parent
11241af84c
commit
a43c19eb48
|
@ -2,4 +2,4 @@ package biz
|
|||
|
||||
import "github.com/google/wire"
|
||||
|
||||
var ProviderSetBiz = wire.NewSet(NewAiRouterBiz)
|
||||
var ProviderSetBiz = wire.NewSet(NewAiRouterBiz, NewSessionBiz)
|
||||
|
|
|
@ -52,8 +52,6 @@ func (s *SessionBiz) SessionInit(ctx context.Context, req *entitys.SessionInitRe
|
|||
session = model.AiSession{
|
||||
SysID: sysConfig.SysID,
|
||||
SessionID: utils.UUID(),
|
||||
CreateAt: time.Now(),
|
||||
UpdateAt: time.Now(),
|
||||
}
|
||||
err = s.sessionRepo.Create(&session)
|
||||
if err != nil {
|
||||
|
|
|
@ -20,7 +20,8 @@ BaseModel 是一个泛型结构体,用于封装GORM数据库通用操作。
|
|||
|
||||
// 定义受支持的PO类型集合(可根据需要扩展), 只有包含表结构才能使用BaseModel,避免使用出现问题
|
||||
type PO interface {
|
||||
model.AiSy | model.AiSession | model.AiTask
|
||||
model.AiChatHi |
|
||||
model.AiSy | model.AiSession | model.AiTask
|
||||
}
|
||||
|
||||
type BaseModel[P PO] struct {
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const TableNameAiChatHi = "ai_chat_his"
|
||||
|
||||
// AiChatHi mapped from table <ai_chat_his>
|
||||
type AiChatHi struct {
|
||||
HisID int64 `gorm:"column:his_id;primaryKey" json:"his_id"`
|
||||
SessionID string `gorm:"column:session_id;not null" json:"session_id"`
|
||||
Role string `gorm:"column:role;not null" json:"role"`
|
||||
Content string `gorm:"column:content;not null" json:"content"`
|
||||
CreateAt *time.Time `gorm:"column:create_at;default:CURRENT_TIMESTAMP" json:"create_at"`
|
||||
}
|
||||
|
||||
// TableName AiChatHi's table name
|
||||
func (*AiChatHi) TableName() string {
|
||||
return TableNameAiChatHi
|
||||
}
|
|
@ -12,14 +12,15 @@ const TableNameAiSession = "ai_session"
|
|||
|
||||
// AiSession mapped from table <ai_session>
|
||||
type AiSession struct {
|
||||
SysID int32 `gorm:"column:sys_id;not null" json:"sys_id"`
|
||||
SessionID string `gorm:"column:session_id;primaryKey" json:"session_id"`
|
||||
KnowlegeSessionID string `gorm:"column:knowlege_session_id;not null" json:"knowlege_session_id"`
|
||||
Title string `gorm:"column:title;not null" json:"title"`
|
||||
CreateAt time.Time `gorm:"column:create_at;default:CURRENT_TIMESTAMP" json:"create_at"`
|
||||
UpdateAt time.Time `gorm:"column:update_at;default:CURRENT_TIMESTAMP" json:"update_at"`
|
||||
Status int32 `gorm:"column:status;not null" json:"status"`
|
||||
DeleteAt time.Time `gorm:"column:delete_at" json:"delete_at"`
|
||||
SessionID string `gorm:"column:session_id;primaryKey" json:"session_id"`
|
||||
SysID int32 `gorm:"column:sys_id;not null" json:"sys_id"`
|
||||
KnowlegeSessionID string `gorm:"column:knowlege_session_id;not null" json:"knowlege_session_id"`
|
||||
Title string `gorm:"column:title;not null" json:"title"`
|
||||
CreateAt *time.Time `gorm:"column:create_at;default:CURRENT_TIMESTAMP" json:"create_at"`
|
||||
UpdateAt *time.Time `gorm:"column:update_at;default:CURRENT_TIMESTAMP" json:"update_at"`
|
||||
Status int32 `gorm:"column:status;not null" json:"status"`
|
||||
DeleteAt *time.Time `gorm:"column:delete_at" json:"delete_at"`
|
||||
UserID string `gorm:"column:user_id;comment:用户id" json:"user_id"` // 用户id
|
||||
}
|
||||
|
||||
// TableName AiSession's table name
|
||||
|
|
|
@ -22,6 +22,7 @@ type AiSy struct {
|
|||
UpdateAt time.Time `gorm:"column:update_at;default:CURRENT_TIMESTAMP" json:"update_at"`
|
||||
Status int32 `gorm:"column:status;not null" json:"status"`
|
||||
DeleteAt time.Time `gorm:"column:delete_at" json:"delete_at"`
|
||||
Prologue string `gorm:"column:prologue;comment:会话开场白" json:"prologue"` // 会话开场白
|
||||
}
|
||||
|
||||
// TableName AiSy's table name
|
||||
|
|
|
@ -2,4 +2,4 @@ package services
|
|||
|
||||
import "github.com/google/wire"
|
||||
|
||||
var ProviderSetServices = wire.NewSet(NewChatService)
|
||||
var ProviderSetServices = wire.NewSet(NewChatService, NewSessionService)
|
||||
|
|
|
@ -10,7 +10,7 @@ type SessionService struct {
|
|||
sessionBiz *biz.SessionBiz
|
||||
}
|
||||
|
||||
func NewSession(sessionBiz *biz.SessionBiz) *SessionService {
|
||||
func NewSessionService(sessionBiz *biz.SessionBiz) *SessionService {
|
||||
return &SessionService{
|
||||
sessionBiz: sessionBiz,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue