database changes
This commit is contained in:
@@ -12,19 +12,19 @@ type AiRepository struct {
|
||||
client *redis.Client
|
||||
}
|
||||
|
||||
func NewAiRepository(db *laniakea.DatabaseContext) *AiRepository {
|
||||
return &AiRepository{client: db.Redis}
|
||||
func NewAiRepository(db *laniakea.DatabaseContext) AiRepository {
|
||||
return AiRepository{client: db.Redis}
|
||||
}
|
||||
|
||||
func (rep *AiRepository) SetChatId(userId int, chatId string) error {
|
||||
func (rep AiRepository) SetChatId(userId int, chatId string) error {
|
||||
key := fmt.Sprintf("ai.chats.gpt.%d", userId)
|
||||
return rep.client.Set(ctx, key, chatId, 0).Err()
|
||||
}
|
||||
func (rep *AiRepository) GetChatId(userId int) (string, error) {
|
||||
func (rep AiRepository) GetChatId(userId int) (string, error) {
|
||||
key := fmt.Sprintf("ai.chats.gpt.%d", userId)
|
||||
return rep.client.Get(ctx, key).Result()
|
||||
}
|
||||
func (rep *AiRepository) GetOrCreateChatId(userId int) (string, error) {
|
||||
func (rep AiRepository) GetOrCreateChatId(userId int) (string, error) {
|
||||
key := fmt.Sprintf("ai.chats.gpt.%d", userId)
|
||||
res := rep.client.Get(ctx, key)
|
||||
if res.Err() != nil {
|
||||
|
||||
Reference in New Issue
Block a user