feat(migrations): Harden task audit tracking and optimize article templates
- Added migration to harden task audit tracking by modifying audit_logs and related tables. - Introduced operator_id to several tables for better tracking of actions. - Updated article_templates with new prompt templates for various article types, enhancing content generation. - Created prompt_rules and schedule_tasks tables to manage content generation rules and scheduling. - Added foreign key constraints to articles for better data integrity.
This commit is contained in:
@@ -8,16 +8,21 @@ import (
|
||||
)
|
||||
|
||||
type AuditLogInput struct {
|
||||
OperatorID int64
|
||||
TenantID *int64
|
||||
Module string
|
||||
Action string
|
||||
BeforeJSON []byte
|
||||
AfterJSON []byte
|
||||
Result *string
|
||||
OperatorID int64
|
||||
TenantID *int64
|
||||
Module string
|
||||
Action string
|
||||
ResourceType *string
|
||||
ResourceID *int64
|
||||
RequestID *string
|
||||
BeforeJSON []byte
|
||||
AfterJSON []byte
|
||||
Result *string
|
||||
ErrorMessage *string
|
||||
}
|
||||
|
||||
type GenerationTaskInput struct {
|
||||
OperatorID int64
|
||||
TenantID int64
|
||||
ArticleID *int64
|
||||
QuotaReservationID *int64
|
||||
@@ -50,18 +55,24 @@ func NewAuditRepository(db generated.DBTX) AuditRepository {
|
||||
|
||||
func (r *auditRepository) CreateAuditLog(ctx context.Context, input AuditLogInput) error {
|
||||
return r.q.CreateAuditLog(ctx, generated.CreateAuditLogParams{
|
||||
OperatorID: input.OperatorID,
|
||||
TenantID: pgInt8(input.TenantID),
|
||||
Module: input.Module,
|
||||
Action: input.Action,
|
||||
BeforeJson: input.BeforeJSON,
|
||||
AfterJson: input.AfterJSON,
|
||||
Result: pgText(input.Result),
|
||||
OperatorID: input.OperatorID,
|
||||
TenantID: pgInt8(input.TenantID),
|
||||
Module: input.Module,
|
||||
Action: input.Action,
|
||||
ResourceType: pgText(input.ResourceType),
|
||||
ResourceID: pgInt8(input.ResourceID),
|
||||
RequestID: pgText(input.RequestID),
|
||||
BeforeJson: input.BeforeJSON,
|
||||
AfterJson: input.AfterJSON,
|
||||
Result: pgText(input.Result),
|
||||
ErrorMessage: pgText(input.ErrorMessage),
|
||||
})
|
||||
}
|
||||
|
||||
func (r *auditRepository) CreateGenerationTask(ctx context.Context, input GenerationTaskInput) (int64, error) {
|
||||
operatorID := input.OperatorID
|
||||
return r.q.CreateGenerationTask(ctx, generated.CreateGenerationTaskParams{
|
||||
OperatorID: pgInt8(&operatorID),
|
||||
TenantID: input.TenantID,
|
||||
ArticleID: pgInt8(input.ArticleID),
|
||||
QuotaReservationID: pgInt8(input.QuotaReservationID),
|
||||
|
||||
Reference in New Issue
Block a user