news-cms-module 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -135,6 +135,27 @@ class NewsController {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
|
|
139
|
+
async deletePost(req, res) {
|
|
140
|
+
try {
|
|
141
|
+
const { id } = req.params;
|
|
142
|
+
|
|
143
|
+
const result = await this.newsService.deletePost(id);
|
|
144
|
+
|
|
145
|
+
if (result === 0) { // Sequelize destroy mengembalikan 0 jika tidak ada baris yang terpengaruh
|
|
146
|
+
return res.status(404).json({ success: false, message: 'News post not found for deletion.' });
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
res.status(200).json({
|
|
150
|
+
success: true,
|
|
151
|
+
message: `Post with ID ${id} deleted successfully.`
|
|
152
|
+
});
|
|
153
|
+
} catch (error) {
|
|
154
|
+
console.error(error);
|
|
155
|
+
res.status(500).json({ success: false, message: 'Failed to delete post.', error: error.message });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
138
159
|
}
|
|
139
160
|
|
|
140
161
|
module.exports = NewsController;
|