diff --git a/frontend/src/board/board.tsx b/frontend/src/board/board.tsx index 0de069972c7e24693eccb25ebf9df14b3134db44..b864008d373c8532c9fd4e6a5e7040695d1a456e 100644 --- a/frontend/src/board/board.tsx +++ b/frontend/src/board/board.tsx @@ -37,22 +37,22 @@ export default function BoardPage() { return (
-
+
`Travel Report's Board`
`여행지 후기를 남겨주세요!`
-
+
- +
{" "} {/* Link */}
-
+
Title
Date
Clicks
diff --git a/frontend/src/post/editpost.tsx b/frontend/src/post/editpost.tsx index bbff90ec0669d0022785a78297807c3565e390cf..d99ad9501ced6cbb9d49ac5c2c870ee5a46ae152 100644 --- a/frontend/src/post/editpost.tsx +++ b/frontend/src/post/editpost.tsx @@ -108,75 +108,99 @@ export function EditPost() { }; return ( -
-
-
-

Id

-

empty

- - - - +
+ +
+
+ + +
+ +
+ +
+ +
+ +
+ +
+ +
-
+
-
-
+ placeholder="제목을 입력해 주세요!" + className="flex w-96 border-2 border-sky-500 rounded" + /> +
+
+ {/* {imgSrc?.map((img, i) => ( + + ))} */} +
+
+ placeholder="여행 후기를 알려주세요!" + className="flex w-96 h-96 border-2 border-sky-500 rounded" + />
diff --git a/frontend/src/post/intopost.tsx b/frontend/src/post/intopost.tsx index e48d783bdaf6253e360d24220214efaeec66a238..c3cee0276fd665d6dce88abbd2c6e93f17e2e735 100644 --- a/frontend/src/post/intopost.tsx +++ b/frontend/src/post/intopost.tsx @@ -24,37 +24,43 @@ export function IntoPost() {
-
-
-
-
+
- +
-
-
+
+
제목: {post.title}
-
+
작성자: {post.user}
+
+ 작성일: {post.date} +
-
-
+
+
도시: {post.city}
-
+
테마: {post.theme}
-
- 작성일: {post.date} -
-
+
조회수: {post.counts}
diff --git a/frontend/src/post/posting.tsx b/frontend/src/post/posting.tsx index f86de42b4353bd597fa0dac9da442b6353a02f67..cea7a658fb45bb21c07cc73c4dd91ed502ab6e38 100644 --- a/frontend/src/post/posting.tsx +++ b/frontend/src/post/posting.tsx @@ -60,7 +60,8 @@ export default function Posting() { if (postingFormMatch(user)) { setLoading(true); if (file) { - sendImg2Db(file); + const res = sendImg2Db(file); + console.log(res); } // const res = await postApi.posting(user); // console.log("서버연결됬나요", res); @@ -153,83 +154,99 @@ export default function Posting() { }; return ( -
-
-
-

Id

-

empty

-
- +
+ +
+
+ + +
+ +
+ +
+ +
+ +
+ +
+
- - - -
-
+
-
-
-
- {imgSrc?.map((img, i) => ( - - ))} + placeholder="제목을 입력해 주세요!" + className="flex w-96 border-2 border-sky-500 rounded" + /> +
+
+ {imgSrc?.map((img, i) => ( + + ))} +
+ placeholder="여행 후기를 알려주세요!" + className="flex w-96 h-96 border-2 border-sky-500 rounded" + />
diff --git a/src/controllers/post.controller.ts b/src/controllers/post.controller.ts index 69af3821dbb27480e840bfd1dc18120123cfdf1d..49127bc8e174eb0aaeedd479cf23fff3a166dd9b 100644 --- a/src/controllers/post.controller.ts +++ b/src/controllers/post.controller.ts @@ -7,10 +7,6 @@ import { TypedRequest } from "../types"; export const createImgAndPost = asyncWrap(async (reqExp, res, next) => { const req = reqExp as TypedRequestAuth<{ userId: string }>; - // const { date, counts } = req.body as { - // date: ""; - // counts: 0; - // }; const { userId } = req.auth; @@ -20,43 +16,43 @@ export const createImgAndPost = asyncWrap(async (reqExp, res, next) => { multiples: true, }); - const fileIdArr = new Array(); - form.parse(req, (err, fields, files) => { - const title = fields.title?.[0]; - const text = fields.text?.[0]; - const theme = fields.theme?.[0]; - const city = fields.city?.[0]; - if (Array.isArray(files.picture)) { for (var i = 0; i < files.picture.length; i++) { - if (!(files.picture?.[i].originalFilename === null)) { - const originalfilename = files.picture?.[i].originalFilename; - const newfilename = files.picture?.[i].newFilename; - const filepath = files.picture?.[i].filepath; - - const filesRes = postDb.createFilesRow( - originalfilename, - newfilename, - filepath - ); + const originalfilename = files.picture?.[i].originalFilename; + const newfilename = files.picture?.[i].newFilename; + const filepath = files.picture?.[i].filepath; + + const filesRes = postDb.createFilesRow( + originalfilename, + newfilename, + filepath + ); + } + } // create fileinfos row + + if (!Array.isArray(fields.title)) { + const title = fields.title; + if (!Array.isArray(fields.text)) { + const text = fields.text; + if (!Array.isArray(fields.theme)) { + const theme = fields.theme; + if (!Array.isArray(fields.city)) { + const city = fields.city; + + const postRes = postDb.createPostRow({ + title, + text, + theme, + city, + date: Date.now(), + counts: 0, + user: userId, + }); // create posts + } } } - } else { - console.log("업로드한 사진이 없습니다."); } - - const postRes = postDb.createPostRow({ - title, - text, - theme, - city, - date: Date.now(), - counts: 0, - user: userId, - }); - - console.log("createPostRow", postRes); }); }); diff --git a/src/db/post.db.ts b/src/db/post.db.ts index 1b16277df239d1f92f6febec8880727c7d371127..9ce3319a567ba4af70ddd5034a64d2d297678dbf 100644 --- a/src/db/post.db.ts +++ b/src/db/post.db.ts @@ -28,6 +28,11 @@ export const createFilesRow = async ( return newFileRow; }; +export const findFile = async (postId: string) => { + const fileInfo = await Post.findById({ postId }).populate("file"); + return fileInfo; +}; + export const findFileByPostInfo = async (title: string, usreId: string) => { const posts = await Post.find({ title: title, userId: usreId }); return posts; diff --git a/src/db/user.db.ts b/src/db/user.db.ts index 0cb5a434c5e9bf934051ff819f413910735f3e0e..0ef20e331b2612cb954cbf00753161105e0b983b 100644 --- a/src/db/user.db.ts +++ b/src/db/user.db.ts @@ -102,7 +102,7 @@ export const postPicture = async ( } }; -export const deleteUser = async (userId: string) => { +export const deleteUser = async (userId: ObjectId) => { const user = await User.findById(userId); if (user && user.avatar) { const file = await FileInfo.findById(user.avatar._id);