mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
refactor: restructure channel gateway and chat module architecture
- Refactor channel adapters (feishu, telegram, local) with enhanced descriptor and config - Restructure channel manager, service, types, and outbound messaging - Simplify chat module by removing normalize.go and chat.go, consolidating into resolver and types - Update router channel handlers and tests - Sync swagger documentation
This commit is contained in:
@@ -11,6 +11,15 @@ import (
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const deleteContainerByBotID = `-- name: DeleteContainerByBotID :exec
|
||||
DELETE FROM containers WHERE bot_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteContainerByBotID(ctx context.Context, botID pgtype.UUID) error {
|
||||
_, err := q.db.Exec(ctx, deleteContainerByBotID, botID)
|
||||
return err
|
||||
}
|
||||
|
||||
const getContainerByBotID = `-- name: GetContainerByBotID :one
|
||||
SELECT id, bot_id, container_id, container_name, image, status, namespace, auto_start, host_path, container_path, created_at, updated_at, last_started_at, last_stopped_at FROM containers WHERE bot_id = $1 ORDER BY updated_at DESC LIMIT 1
|
||||
`
|
||||
@@ -63,6 +72,44 @@ func (q *Queries) GetContainerByContainerID(ctx context.Context, containerID str
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateContainerStarted = `-- name: UpdateContainerStarted :exec
|
||||
UPDATE containers
|
||||
SET status = 'running', last_started_at = now(), updated_at = now()
|
||||
WHERE bot_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) UpdateContainerStarted(ctx context.Context, botID pgtype.UUID) error {
|
||||
_, err := q.db.Exec(ctx, updateContainerStarted, botID)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateContainerStatus = `-- name: UpdateContainerStatus :exec
|
||||
UPDATE containers
|
||||
SET status = $1, updated_at = now()
|
||||
WHERE bot_id = $2
|
||||
`
|
||||
|
||||
type UpdateContainerStatusParams struct {
|
||||
Status string `json:"status"`
|
||||
BotID pgtype.UUID `json:"bot_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateContainerStatus(ctx context.Context, arg UpdateContainerStatusParams) error {
|
||||
_, err := q.db.Exec(ctx, updateContainerStatus, arg.Status, arg.BotID)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateContainerStopped = `-- name: UpdateContainerStopped :exec
|
||||
UPDATE containers
|
||||
SET status = 'stopped', last_stopped_at = now(), updated_at = now()
|
||||
WHERE bot_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) UpdateContainerStopped(ctx context.Context, botID pgtype.UUID) error {
|
||||
_, err := q.db.Exec(ctx, updateContainerStopped, botID)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertContainer = `-- name: UpsertContainer :exec
|
||||
INSERT INTO containers (
|
||||
bot_id, container_id, container_name, image, status, namespace, auto_start,
|
||||
|
||||
Reference in New Issue
Block a user