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:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
type QuotaLedgerInput struct {
|
||||
TenantID int64
|
||||
OperatorID int64
|
||||
QuotaType string
|
||||
Delta int
|
||||
BalanceAfter int
|
||||
@@ -19,9 +20,10 @@ type QuotaLedgerInput struct {
|
||||
|
||||
type QuotaReservationInput struct {
|
||||
TenantID int64
|
||||
OperatorID int64
|
||||
QuotaType string
|
||||
ResourceType string
|
||||
ResourceID int64
|
||||
ResourceID *int64
|
||||
ReservedAmount int
|
||||
ExpireAt time.Time
|
||||
}
|
||||
@@ -55,8 +57,10 @@ func (r *quotaRepository) GetCurrentBalance(ctx context.Context, tenantID int64,
|
||||
}
|
||||
|
||||
func (r *quotaRepository) InsertQuotaLedger(ctx context.Context, input QuotaLedgerInput) (int64, error) {
|
||||
operatorID := input.OperatorID
|
||||
return r.q.InsertQuotaLedger(ctx, generated.InsertQuotaLedgerParams{
|
||||
TenantID: input.TenantID,
|
||||
OperatorID: pgInt8(&operatorID),
|
||||
QuotaType: input.QuotaType,
|
||||
Delta: int32(input.Delta),
|
||||
BalanceAfter: int32(input.BalanceAfter),
|
||||
@@ -68,19 +72,22 @@ func (r *quotaRepository) InsertQuotaLedger(ctx context.Context, input QuotaLedg
|
||||
|
||||
func (r *quotaRepository) CreateQuotaReservation(ctx context.Context, input QuotaReservationInput) (int64, error) {
|
||||
expireAt := input.ExpireAt
|
||||
operatorID := input.OperatorID
|
||||
return r.q.CreateQuotaReservation(ctx, generated.CreateQuotaReservationParams{
|
||||
TenantID: input.TenantID,
|
||||
OperatorID: pgInt8(&operatorID),
|
||||
QuotaType: input.QuotaType,
|
||||
ResourceType: input.ResourceType,
|
||||
ResourceID: input.ResourceID,
|
||||
ResourceID: pgInt8(input.ResourceID),
|
||||
ReservedAmount: int32(input.ReservedAmount),
|
||||
ExpireAt: pgTimestamp(&expireAt),
|
||||
})
|
||||
}
|
||||
|
||||
func (r *quotaRepository) UpdateQuotaReservationResource(ctx context.Context, reservationID, tenantID, resourceID int64) error {
|
||||
resourceIDValue := resourceID
|
||||
return r.q.UpdateQuotaReservationResource(ctx, generated.UpdateQuotaReservationResourceParams{
|
||||
ResourceID: resourceID,
|
||||
ResourceID: pgInt8(&resourceIDValue),
|
||||
ID: reservationID,
|
||||
TenantID: tenantID,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user