Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
travel
Commits
18f1a3f8
Commit
18f1a3f8
authored
Jul 27, 2022
by
Lee Soobeom
Browse files
update debugging
parent
fbaae34c
Changes
5
Hide whitespace changes
Inline
Side-by-side
frontend/src/auth/profile.tsx
View file @
18f1a3f8
...
@@ -59,7 +59,7 @@ export default function Profile() {
...
@@ -59,7 +59,7 @@ export default function Profile() {
const
user
:
Profile
=
await
profileApi
.
profile
();
const
user
:
Profile
=
await
profileApi
.
profile
();
console
.
log
(
"
user in effect
"
,
user
);
console
.
log
(
"
user in effect
"
,
user
);
setEmail
(
user
.
email
);
setEmail
(
user
.
email
);
setAvatarUrl
(
user
.
avatar
?.
newfilename
);
setAvatarUrl
(
user
.
fileInfo
?.
newfilename
);
setProfile
({
...
profile
,
name
:
user
.
name
});
setProfile
({
...
profile
,
name
:
user
.
name
});
};
};
getProfile
();
getProfile
();
...
...
frontend/src/board/board.tsx
View file @
18f1a3f8
...
@@ -18,7 +18,7 @@ export default function BoardPage() {
...
@@ -18,7 +18,7 @@ export default function BoardPage() {
// posts
// posts
const
getDataList
=
async
()
=>
{
const
getDataList
=
async
()
=>
{
const
res
=
await
postApi
.
getData
();
const
res
=
await
postApi
.
getData
();
setPosts
(
res
);
setPosts
(
res
);
//posts = res
};
};
const
titleHandleClick
=
async
(
event
:
MouseEvent
<
HTMLButtonElement
>
)
=>
{
const
titleHandleClick
=
async
(
event
:
MouseEvent
<
HTMLButtonElement
>
)
=>
{
...
...
frontend/src/types/index.tsx
View file @
18f1a3f8
...
@@ -39,6 +39,7 @@ export interface SignupUser {
...
@@ -39,6 +39,7 @@ export interface SignupUser {
export
interface
Profile
{
export
interface
Profile
{
_id
:
string
;
_id
:
string
;
email
:
string
;
email
:
string
;
name
:
string
;
fileInfo
:
{
fileInfo
:
{
originalfilename
:
string
;
originalfilename
:
string
;
newfilename
:
string
;
newfilename
:
string
;
...
...
src/controllers/post.controller.ts
View file @
18f1a3f8
...
@@ -209,49 +209,53 @@ export const updateOnePost = asyncWrap(async (reqExp, res) => {
...
@@ -209,49 +209,53 @@ export const updateOnePost = asyncWrap(async (reqExp, res) => {
);
);
console
.
log
(
"
no files update
"
,
postRes2
);
console
.
log
(
"
no files update
"
,
postRes2
);
}
else
{
}
else
{
const
oldFilesId
=
await
postDb
.
getFilesByPostId
(
postId
);
if
(
Array
.
isArray
(
files
.
picture
))
{
if
(
!
(
oldFilesId
===
undefined
))
{
const
oldFilesId
=
await
postDb
.
getFilesByPostId
(
postId
);
for
(
var
i
=
0
;
i
<
oldFilesId
?.
length
;
i
++
)
{
if
(
!
(
oldFilesId
===
undefined
))
{
const
name
=
await
postDb
.
getOriginalFileName
(
oldFilesId
[
i
]);
for
(
var
i
=
0
;
i
<
oldFilesId
?.
length
;
i
++
)
{
if
(
!
(
name
===
undefined
))
{
const
name
=
await
postDb
.
getOriginalFileName
(
oldSet
.
add
(
name
);
oldFilesId
[
i
]
);
if
(
!
(
name
===
undefined
))
{
oldSet
.
add
(
name
);
}
}
}
}
}
}
console
.
log
(
"
OldSet
"
,
oldSet
);
console
.
log
(
"
OldSet
"
,
oldSet
);
if
(
Array
.
isArray
(
files
.
picture
))
{
if
(
Array
.
isArray
(
files
.
picture
))
{
for
(
var
i
=
0
;
i
<
files
.
picture
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
files
.
picture
.
length
;
i
++
)
{
const
newFileName
=
files
.
picture
?.[
i
].
originalFilename
;
const
newFileName
=
files
.
picture
?.[
i
].
originalFilename
;
if
(
!
(
newFileName
===
undefined
||
newFileName
===
null
))
{
if
(
!
(
newFileName
===
undefined
||
newFileName
===
null
))
{
newSet
.
add
(
newFileName
);
newSet
.
add
(
newFileName
);
}
}
}
}
}
}
console
.
log
(
"
NewSet
"
,
newSet
);
console
.
log
(
"
NewSet
"
,
newSet
);
//유지, 삭제, 추가 구분하기
//유지, 삭제, 추가 구분하기
const
trdPart
=
subTract
(
oldSet
,
newSet
);
const
trdPart
=
subTract
(
oldSet
,
newSet
);
console
.
log
(
"
keep
"
,
trdPart
.
keep
);
console
.
log
(
"
keep
"
,
trdPart
.
keep
);
console
.
log
(
"
drop
"
,
trdPart
.
drop
);
console
.
log
(
"
drop
"
,
trdPart
.
drop
);
console
.
log
(
"
add
"
,
trdPart
.
add
);
console
.
log
(
"
add
"
,
trdPart
.
add
);
// 삭제
// 삭제
for
(
var
i
=
0
;
i
<
trdPart
.
drop
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
trdPart
.
drop
.
length
;
i
++
)
{
const
dropRes
=
await
postDb
.
deleteFileByName
(
trdPart
.
drop
[
i
]);
const
dropRes
=
await
postDb
.
deleteFileByName
(
console
.
log
(
"
delete counts
"
,
dropRes
);
trdPart
.
drop
[
i
]
}
);
console
.
log
(
"
delete counts
"
,
dropRes
);
}
//유지
//유지
for
(
var
i
=
0
;
i
<
trdPart
.
keep
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
trdPart
.
keep
.
length
;
i
++
)
{
const
keepRes
=
await
postDb
.
findByName
(
trdPart
.
keep
[
i
]);
const
keepRes
=
await
postDb
.
findByName
(
trdPart
.
keep
[
i
]);
fileIdArr
.
push
(
keepRes
[
0
].
_id
);
fileIdArr
.
push
(
keepRes
[
0
].
_id
);
// console.log("keep Id", keepRes[0]._id);
// console.log("keep Id", keepRes[0]._id);
}
}
//추가
//추가
if
(
Array
.
isArray
(
files
.
picture
))
{
for
(
var
i
=
0
;
i
<
files
.
picture
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
files
.
picture
.
length
;
i
++
)
{
const
originalfilename
=
files
.
picture
?.[
i
].
originalFilename
;
const
originalfilename
=
files
.
picture
?.[
i
].
originalFilename
;
const
newfilename
=
files
.
picture
?.[
i
].
newFilename
;
const
newfilename
=
files
.
picture
?.[
i
].
newFilename
;
...
@@ -269,22 +273,69 @@ export const updateOnePost = asyncWrap(async (reqExp, res) => {
...
@@ -269,22 +273,69 @@ export const updateOnePost = asyncWrap(async (reqExp, res) => {
}
}
}
}
}
}
}
}
else
{
console
.
log
(
"
all fileId
"
,
fileIdArr
);
const
oldFilesId
=
await
postDb
.
getFilesByPostId
(
postId
);
if
(
!
(
oldFilesId
===
undefined
))
{
for
(
var
i
=
0
;
i
<
oldFilesId
?.
length
;
i
++
)
{
const
name
=
await
postDb
.
getOriginalFileName
(
oldFilesId
[
i
]
);
if
(
!
(
name
===
undefined
))
{
oldSet
.
add
(
name
);
}
}
}
console
.
log
(
"
OldSet
"
,
oldSet
);
//post정보 + file정보 update
const
newFileName
=
files
.
picture
.
originalFilename
;
const
postRes1
=
await
postDb
.
updatePostRow
(
if
(
!
(
newFileName
===
undefined
||
newFileName
===
null
))
{
{
newSet
.
add
(
newFileName
);
title
,
}
text
,
console
.
log
(
"
NewSet
"
,
newSet
);
theme
,
city
,
//유지, 삭제, 추가 구분하기
date
:
Date
.
now
(),
const
trdPart
=
subTract
(
oldSet
,
newSet
);
file
:
fileIdArr
,
},
//삭제
postId
for
(
var
i
=
0
;
i
<
trdPart
.
drop
.
length
;
i
++
)
{
);
const
dropRes
=
await
postDb
.
deleteFileByName
(
trdPart
.
drop
[
i
]
);
console
.
log
(
"
delete counts
"
,
dropRes
);
}
//추가
const
originalfilename
=
files
.
picture
.
originalFilename
;
const
newfilename
=
files
.
picture
.
newFilename
;
const
filepath
=
files
.
picture
.
filepath
;
for
(
var
j
=
0
;
j
<
trdPart
.
add
.
length
;
j
++
)
{
const
check
=
trdPart
.
add
[
j
];
if
(
originalfilename
===
check
)
{
const
addRes
=
await
postDb
.
createFilesRow
(
originalfilename
,
newfilename
,
filepath
);
fileIdArr
.
push
(
addRes
.
_id
);
}
}
}
}
}
console
.
log
(
"
all fileId
"
,
fileIdArr
);
//post정보 + file정보 update
const
postRes1
=
await
postDb
.
updatePostRow
(
{
title
,
text
,
theme
,
city
,
date
:
Date
.
now
(),
file
:
fileIdArr
,
},
postId
);
}
}
}
}
}
}
...
...
src/routes/post.route.ts
View file @
18f1a3f8
import
express
from
"
express
"
;
import
express
from
"
express
"
;
import
{
postCtrl
,
authCtrl
,
fileInfoCtrl
}
from
"
../controllers
"
;
import
{
postCtrl
,
authCtrl
}
from
"
../controllers
"
;
const
router
=
express
.
Router
();
const
router
=
express
.
Router
();
...
@@ -8,7 +8,6 @@ router.route("/").get(postCtrl.getAllPost);
...
@@ -8,7 +8,6 @@ router.route("/").get(postCtrl.getAllPost);
router
.
route
(
"
/files/:postId
"
).
get
(
authCtrl
.
requireLogin
,
postCtrl
.
getFiles
);
router
.
route
(
"
/files/:postId
"
).
get
(
authCtrl
.
requireLogin
,
postCtrl
.
getFiles
);
// router.param("postId", postCtrl.userByPostId);
router
router
.
route
(
"
/:postId
"
)
.
route
(
"
/:postId
"
)
.
post
(
authCtrl
.
requireLogin
,
postCtrl
.
addCounts
)
.
post
(
authCtrl
.
requireLogin
,
postCtrl
.
addCounts
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment