@@ -21,20 +21,26 @@ async function getNews({
21
21
this . socket . sendMessage ( { token, articles, pages } ) ;
22
22
}
23
23
24
- async function addNews ( { token, title, date, category, body } ) {
25
- const queryHandler = this . server . queryHandler ;
24
+ async function addNews ( { token, id, title, date, category, body } ) {
26
25
date = date || Math . floor ( Date . now ( ) / 1000 ) ;
27
26
27
+ const queryHandler = this . server . queryHandler ;
28
+
28
29
try {
29
- queryHandler . insertNews ( { title, category, body, date } ) ;
30
+ console . log ( id , body ) ;
31
+
32
+ if ( typeof id === 'number' ) {
33
+ queryHandler . editNews ( { id, title, category, body, date } ) ;
34
+ } else {
35
+ queryHandler . insertNews ( { title, category, body, date } ) ;
36
+ }
37
+
30
38
this . socket . sendMessage ( { token, success : true } ) ;
31
39
} catch ( e ) {
32
40
this . socket . sendMessage ( { token, success : false } ) ;
33
41
}
34
42
}
35
43
36
- async function editNews ( { token, id, title, category, body } ) { }
37
-
38
44
async function addFile ( { token, name, file } ) { }
39
45
40
46
async function getFile ( { token, name } ) {
@@ -54,7 +60,6 @@ async function getGodLetter({ token, id }) {
54
60
module . exports = {
55
61
getNews,
56
62
addNews,
57
- editNews,
58
63
addFile,
59
64
getFile,
60
65
getGodLetter
0 commit comments