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
messenger
Commits
80a6069e
Commit
80a6069e
authored
Jan 18, 2021
by
Choi Ga Young
Browse files
공개/비공개방 분류해서 가져오기
parent
7d48edd7
Changes
4
Show whitespace changes
Inline
Side-by-side
client/src/Components/ClosedList.js
View file @
80a6069e
...
...
@@ -3,6 +3,7 @@ import { ListGroup, Row, Col } from 'react-bootstrap';
import
axios
from
'
axios
'
function
ClosedList
(
props
)
{
const
[
list
,
setList
]
=
useState
([]);
useEffect
(()
=>
{
...
...
@@ -10,7 +11,9 @@ function ClosedList(props) {
},
[]);
async
function
getClosedList
()
{
let
res
=
await
axios
.
get
(
'
/room/closedlist
'
)
const
userid
=
sessionStorage
.
getItem
(
'
userId
'
)
console
.
log
(
'
id가져오기
'
,
userid
)
let
res
=
await
axios
.
get
(
'
/room/closedlist
'
,
{
params
:
{
'
_id
'
:
userid
}
})
console
.
log
(
'
가져온거
'
,
res
)
setList
(
res
.
data
)
}
...
...
client/src/Components/OpenList.js
View file @
80a6069e
import
React
,
{
useState
}
from
'
react
'
import
React
,
{
useState
,
useEffect
}
from
'
react
'
import
{
ListGroup
}
from
'
react-bootstrap
'
;
import
axios
from
'
axios
'
function
OpenList
(
props
)
{
const
[
list
,
setList
]
=
useState
([
{
room
:
'
테스트 방3
'
,
memnum
:
7
,
admin
:
'
가영2
'
},
{
room
:
'
테스트 방4
'
,
memnum
:
2
,
admin
:
'
수현2
'
}]
);
const
[
list
,
setList
]
=
useState
([]);
useEffect
(()
=>
{
getOpenList
();
},
[]);
async
function
getOpenList
()
{
let
res
=
await
axios
.
get
(
'
/room/openlist
'
)
console
.
log
(
'
가져온거
'
,
res
)
setList
(
res
.
data
)
}
function
enterChatroomCH
(
e
)
{
const
roomName
=
e
.
target
.
name
...
...
@@ -18,8 +27,8 @@ function OpenList(props) {
<
div
>
{
list
.
map
((
list
,
index
)
=>
<
ListGroup
key
=
{
index
}
>
<
ListGroup
.
Item
action
onClick
=
{
enterChatroomCH
}
name
=
{
list
.
room
}
>
<
h2
>
{
list
.
room
}
<
/h2
>
<
ListGroup
.
Item
action
onClick
=
{
enterChatroomCH
}
name
=
{
list
.
room
Name
}
>
{
list
.
room
Name
}
<
/ListGroup.Item
>
<
/ListGroup
>
)}
...
...
server/controllers/room.controller.js
View file @
80a6069e
...
...
@@ -39,12 +39,25 @@ const makeRoom = async (req, res) => {
const
getClosedList
=
async
(
req
,
res
)
=>
{
try
{
let
list
=
await
Room
.
find
({
isOpen
:
false
})
console
.
log
(
'
list가져오기
'
,
list
)
console
.
log
(
'
req확인
'
,
req
.
query
.
_id
)
let
list
=
await
Room
.
find
({
moderator
:
req
.
query
.
_id
})
console
.
log
(
'
c_list가져오기
'
,
list
)
return
res
.
json
(
list
)
}
catch
(
error
)
{
res
.
status
(
500
).
send
(
'
리스트 불러오기를 실패하였습니다!
'
)
}
}
export
default
{
makeRoom
,
getClosedList
}
const
getOpenList
=
async
(
req
,
res
)
=>
{
try
{
let
list
=
await
Room
.
find
({
isOpen
:
true
})
console
.
log
(
'
o_list가져오기
'
,
list
)
return
res
.
json
(
list
)
}
catch
(
error
)
{
res
.
status
(
500
).
send
(
'
리스트 불러오기를 실패하였습니다!
'
)
}
}
export
default
{
makeRoom
,
getClosedList
,
getOpenList
}
server/routes/room.routers.js
View file @
80a6069e
...
...
@@ -8,4 +8,7 @@ router.route('/room/makeRoom')
router
.
route
(
'
/room/closedlist
'
)
.
get
(
roomCtrl
.
getClosedList
)
router
.
route
(
'
/room/openlist
'
)
.
get
(
roomCtrl
.
getOpenList
)
export
default
router
\ No newline at end of file
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