mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Enhance announcement management and database interactions
Update announcement storage to join on username instead of ID, add logging for announcement updates, and implement error handling for non-existent announcements. Also, update schema imports. Replit-Commit-Author: Agent Replit-Commit-Session-Id: cc2d271b-82f0-4d6a-9302-a0b067ffb429 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/cc2d271b-82f0-4d6a-9302-a0b067ffb429/JTP6mhE
This commit is contained in:
1 parent
95710e690b
commit
8bbbd2476c
5 files changed
+14
-5
No files matched your search
@@ -40,7 +40,7 @@ class AnnouncementDatabaseStorage implements IAnnouncementStorage {
|
||||
},
|
||||
})
|
||||
.from(dashboardMessages)
|
||||
.leftJoin(users, eq(dashboardMessages.createdBy, users.id))
|
||||
.leftJoin(users, eq(dashboardMessages.createdBy, users.username))
|
||||
.leftJoin(groups, eq(dashboardMessages.storeId, groups.id))
|
||||
.orderBy(desc(dashboardMessages.createdAt));
|
||||
|
||||
@@ -68,11 +68,20 @@ class AnnouncementDatabaseStorage implements IAnnouncementStorage {
|
||||
}
|
||||
|
||||
async updateAnnouncement(id: number, announcement: Partial<InsertAnnouncement>): Promise<DashboardMessage> {
|
||||
console.log('📝 [DB] Updating announcement with data:', announcement);
|
||||
|
||||
const [updated] = await db
|
||||
.update(dashboardMessages)
|
||||
.set(announcement)
|
||||
.where(eq(dashboardMessages.id, id))
|
||||
.returning();
|
||||
|
||||
console.log('📝 [DB] Updated announcement:', updated);
|
||||
|
||||
if (!updated) {
|
||||
throw new Error(`Announcement with id ${id} not found`);
|
||||
}
|
||||
|
||||
return updated;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ import {
|
||||
insertWeatherDataSchema,
|
||||
insertWeatherSettingsSchema,
|
||||
users, groups, userGroups, suppliers, orders, deliveries, publicities, publicityParticipations,
|
||||
customerOrders, nocodbConfigs, dlcProducts, tasks, invoiceVerifications, dashboardMessages
|
||||
customerOrders, nocodbConfig, dlcProducts, tasks, invoiceVerificationCache, dashboardMessages
|
||||
} from "@shared/schema";
|
||||
import { hasPermission } from "@shared/permissions";
|
||||
import { z } from "zod";
|
||||
@@ -3164,7 +3164,7 @@ RÉSUMÉ DU SCAN
|
||||
|
||||
// Ajouter les relations manuellement
|
||||
const announcements = await Promise.all(
|
||||
messages.map(async (message) => {
|
||||
messages.map(async (message: any) => {
|
||||
// Récupérer l'auteur
|
||||
let author = { id: message.createdBy, firstName: 'Utilisateur', lastName: 'Inconnu', username: message.createdBy };
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user