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
bora-it
Commits
6d3794cb
Commit
6d3794cb
authored
Jul 28, 2021
by
seoyeon
Browse files
Merge remote-tracking branch 'origin/woojiweon' into seoyeon2
parents
0b842128
32664664
Changes
13
Hide whitespace changes
Inline
Side-by-side
client/src/apis/room.api.js
View file @
6d3794cb
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
const
getRoom
=
async
(
payloa
d
)
=>
{
const
getRoom
=
async
(
i
d
)
=>
{
const
{
data
}
=
await
axios
.
get
(
"
/api/room/getRoom
"
,
payload
);
const
{
data
}
=
await
axios
.
get
(
`
/api/room/getRoom
/
${
id
}
`
);
return
data
;
return
data
;
};
};
...
...
client/src/apis/user.api.js
View file @
6d3794cb
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
const
getUser
=
async
(
payload
)
=>
{
const
getUser
=
async
(
id
)
=>
{
const
{
data
}
=
await
axios
.
post
(
"
/api/getUser
"
,
payload
);
// console.log('id222:',id.userID)
const
{
data
}
=
await
axios
.
get
(
`/api/getUser/
${
id
}
`
);
return
data
;
return
data
;
};
};
...
...
client/src/components/Home/CreateRoom.js
View file @
6d3794cb
...
@@ -24,7 +24,7 @@ const CreateRoom = () => {
...
@@ -24,7 +24,7 @@ const CreateRoom = () => {
},
[
room
]);
},
[
room
]);
function
handleChange
(
event
)
{
function
handleChange
(
event
)
{
console
.
log
(
room
)
//
console.log(room)
const
{
name
,
value
}
=
event
.
target
const
{
name
,
value
}
=
event
.
target
setRoom
({
...
room
,
[
name
]:
value
})
setRoom
({
...
room
,
[
name
]:
value
})
}
}
...
@@ -32,7 +32,7 @@ const CreateRoom = () => {
...
@@ -32,7 +32,7 @@ const CreateRoom = () => {
async
function
handleSubmit
(
e
)
{
async
function
handleSubmit
(
e
)
{
e
.
preventDefault
()
e
.
preventDefault
()
console
.
log
(
'
룸룸
'
,
room
)
//
console.log('룸룸', room)
try
{
try
{
const
res
=
await
roomApi
.
create
(
room
)
const
res
=
await
roomApi
.
create
(
room
)
// console.log(res)
// console.log(res)
...
...
client/src/components/Home/HomeProfile.js
View file @
6d3794cb
import
{
Link
}
from
"
react-router-dom
"
;
import
{
Link
}
from
"
react-router-dom
"
;
import
{
useState
,
useEffect
}
from
"
react
"
;
import
{
useState
,
useEffect
}
from
"
react
"
;
import
userApi
from
"
../../apis/user.api
"
;
import
userApi
from
"
../../apis/user.api
"
;
import
catchErrors
from
"
../../context/catchError
"
;
const
userprofile
=
localStorage
.
getItem
(
"
user
"
);
const
userprofile
=
localStorage
.
getItem
(
"
user
"
);
console
.
log
(
userprofile
)
console
.
log
(
userprofile
)
...
@@ -15,19 +16,17 @@ const HomeProfile = () => {
...
@@ -15,19 +16,17 @@ const HomeProfile = () => {
async
function
getSetUser
(
userID
)
{
async
function
getSetUser
(
userID
)
{
try
{
try
{
// `/users/${userId}`랑 userId랑 같은지 확인
// console.log('userID', userID)
console
.
log
(
'
userID
'
,
userID
)
const
data
=
await
userApi
.
getUser
(
userID
)
const
data
=
await
userApi
.
getUser
({
id
:
userID
})
// console.log(data)
console
.
log
(
data
)
setUser
(
data
)
setUser
(
data
)
console
.
log
(
user
)
//
console.log(user)
}
catch
(
error
)
{
}
catch
(
error
)
{
// catchErrors(error, setError)
// catchErrors(error, setError)
}
}
}
}
useEffect
(()
=>
{
useEffect
(()
=>
{
console
.
log
(
'
예에에에에ㅔ에에
'
)
getSetUser
(
userprofile
)
getSetUser
(
userprofile
)
},
[
userprofile
])
},
[
userprofile
])
...
...
client/src/components/Home/JoinRoom.js
View file @
6d3794cb
...
@@ -18,7 +18,7 @@ const JoinRoom = () => {
...
@@ -18,7 +18,7 @@ const JoinRoom = () => {
function
handleChange
(
event
)
{
function
handleChange
(
event
)
{
const
{
value
}
=
event
.
target
;
const
{
value
}
=
event
.
target
;
setRoomId
(
value
);
setRoomId
(
value
);
console
.
log
(
roomId
);
//
console.log(roomId);
}
}
async
function
handleSubmit
(
e
)
{
async
function
handleSubmit
(
e
)
{
...
@@ -26,10 +26,10 @@ const JoinRoom = () => {
...
@@ -26,10 +26,10 @@ const JoinRoom = () => {
try
{
try
{
// setLoading(true);
// setLoading(true);
// setError("");
// setError("");
console
.
log
(
'
userId:
'
,
userId
)
//
console.log('userId:', userId)
console
.
log
(
'
roomId:
'
,
roomId
)
//
console.log('roomId:', roomId)
const
data
=
await
roomApi
.
join
({
userId
:
userId
,
roomId
:
roomId
});
const
data
=
await
roomApi
.
join
({
userId
:
userId
,
roomId
:
roomId
});
console
.
log
(
data
);
//
console.log(data);
setSuccess
(
true
);
setSuccess
(
true
);
}
catch
(
error
)
{
}
catch
(
error
)
{
// catchErrors(error, setError);
// catchErrors(error, setError);
...
...
client/src/components/Home/RoomSingle.js
View file @
6d3794cb
...
@@ -4,27 +4,29 @@ import roomApi from '../../apis/room.api';
...
@@ -4,27 +4,29 @@ import roomApi from '../../apis/room.api';
import
userApi
from
'
../../apis/user.api
'
;
import
userApi
from
'
../../apis/user.api
'
;
const
RoomSingle
=
()
=>
{
const
RoomSingle
=
()
=>
{
const
[
roomNum
,
setRoomNum
]
=
useState
(
[]
)
const
[
roomNum
,
setRoomNum
]
=
useState
(
''
)
const
[
room
,
setRoom
]
=
useState
([])
const
[
room
,
setRoom
]
=
useState
([])
const
id
=
localStorage
.
getItem
(
'
user
'
);
const
id
=
localStorage
.
getItem
(
'
user
'
);
const
channelId
=
1
const
channelId
=
1
const
A
=
[]
async
function
getJoinRoom
(
Id
)
{
// async function getJoinRoom(Id) {
try
{
// try {
console
.
log
(
'
id:
'
,
id
)
// console.log('id:',id)
const
User
=
await
userApi
.
getUser
({
id
:
Id
})
// const User = await userApi.getUser({id: Id})
console
.
log
(
'
User1:
'
,
User
)
// console.log('User1:',User)
console
.
log
(
'
User2:
'
,
User
.
roomNumber
)
// console.log('User2:',User.roomNumber)
setRoomNum
(
User
.
data
.
roomNumber
)
// const RoomNumArr = User.roomNumber
const
Room
=
await
roomApi
.
getRoom
(
roomNum
)
// console.log('setRoomNum:',RoomNumArr)
}
catch
(
error
)
{
// const Room = await roomApi.getRoom(RoomNumArr)
// catchErrors(error, setError)
// } catch (error) {
}
// // catchErrors(error, setError)
}
// }
// }
useEffect
(()
=>
{
//
useEffect(() => {
getJoinRoom
(
id
)
//
getJoinRoom(id)
},
[
id
])
//
}, [id])
return
(
return
(
<
Link
<
Link
...
...
client/src/components/KakaoShareButton.js
View file @
6d3794cb
import
React
,
{
useEffect
}
from
"
react
"
;
import
React
,
{
useEffect
}
from
"
react
"
;
import
kakao_login
from
"
../kakao_login.png
"
;
const
KakaoShareButton
=
()
=>
{
const
KakaoShareButton
=
()
=>
{
useEffect
(()
=>
{
useEffect
(()
=>
{
...
...
client/src/pages/InvitePage.js
View file @
6d3794cb
...
@@ -34,7 +34,7 @@ const InvitePage = () => {
...
@@ -34,7 +34,7 @@ const InvitePage = () => {
>
>
{
/* 방 부분 */
}
{
/* 방 부분 */
}
<
p
style
=
{{
marginBottom
:
"
0px
"
,
fontSize
:
"
16px
"
}}
>
초대받은
방
<
/p
>
<
p
style
=
{{
marginBottom
:
"
0px
"
,
fontSize
:
"
16px
"
}}
>
초대받은
방
<
/p
>
<
img
style
=
{{
width
:
"
90px
"
,
height
:
"
90px
"
}}
><
/img
>
{
/* <img src={RoomImage}
style={{ width: "90px", height: "90px" }}></img>
*/
}
<
p
style
=
{{
marginBottom
:
"
0px
"
,
fontSize
:
"
16px
"
}}
>
<
p
style
=
{{
marginBottom
:
"
0px
"
,
fontSize
:
"
16px
"
}}
>
방
id
:
{
/*${roomid}*/
}
방
id
:
{
/*${roomid}*/
}
<
/p
>
<
/p
>
...
...
controllers/room.controller.js
View file @
6d3794cb
...
@@ -10,7 +10,7 @@ const joinRoom = async (req, res) => {
...
@@ -10,7 +10,7 @@ const joinRoom = async (req, res) => {
if
(
Boolean
(
room_Id
))
{
//roomId에 일치하는 방이 존재할때
if
(
Boolean
(
room_Id
))
{
//roomId에 일치하는 방이 존재할때
//roomId에 일치하는 방의 member정보에 userId 저장하기
//roomId에 일치하는 방의 member정보에 userId 저장하기
//member정보에 userId가 이미 저장되어 있는지 확인 -> 이미 참여된 방인지 확인
//member정보에 userId가 이미 저장되어 있는지 확인 -> 이미 참여된 방인지 확인
const
includeUserId
=
room_Id
.
member
.
includes
(
parseInt
(
userId
));
const
includeUserId
=
room_Id
.
member
.
includes
(
parseInt
(
userId
));
// console.log('Include확인:',includeUserId)
// console.log('Include확인:',includeUserId)
if
(
!
includeUserId
)
{
//아직 참여되지 않은 방인경우
if
(
!
includeUserId
)
{
//아직 참여되지 않은 방인경우
room_Id
.
member
.
push
(
userId
)
//member에 userId추가
room_Id
.
member
.
push
(
userId
)
//member에 userId추가
...
@@ -36,7 +36,7 @@ const joinRoom = async (req, res) => {
...
@@ -36,7 +36,7 @@ const joinRoom = async (req, res) => {
};
};
const
createRoom
=
async
(
req
,
res
)
=>
{
const
createRoom
=
async
(
req
,
res
)
=>
{
console
.
log
(
'
룸정보
'
,
req
.
body
)
//
console.log('룸정보', req.body)
const
{
name
,
owner
,
member
,
profileimg
}
=
req
.
body
;
const
{
name
,
owner
,
member
,
profileimg
}
=
req
.
body
;
const
id
=
nanoid
()
const
id
=
nanoid
()
const
Id
=
await
Room
.
findOne
({
where
:
{
id
:
id
}
});
const
Id
=
await
Room
.
findOne
({
where
:
{
id
:
id
}
});
...
@@ -77,8 +77,8 @@ const createRoom = async (req, res) => {
...
@@ -77,8 +77,8 @@ const createRoom = async (req, res) => {
}
}
}
}
const
getRoom
=
async
(
req
,
res
)
=>
{
const
getRoom
=
async
(
req
,
res
)
=>
{
console
.
log
(
'
req.body:
'
,
req
.
body
)
console
.
log
(
'
req.body:
'
,
req
.
body
)
}
}
export
default
{
export
default
{
...
...
controllers/user.controller.js
View file @
6d3794cb
...
@@ -23,7 +23,9 @@ const update = async (req, res) => {
...
@@ -23,7 +23,9 @@ const update = async (req, res) => {
}
}
};
};
const
getUser
=
async
(
req
,
res
)
=>
{
const
getUser
=
async
(
req
,
res
)
=>
{
const
user
=
await
User
.
findOne
({
where
:
{
id
:
req
.
body
.
id
}
});
// console.log('req.params:',req.params)
const
user
=
await
User
.
findOne
({
where
:
{
id
:
req
.
params
.
id
}
});
// console.log('user:',user)
res
.
json
(
user
)
res
.
json
(
user
)
};
};
...
@@ -43,9 +45,9 @@ const updateinfo = async (req, res) => {
...
@@ -43,9 +45,9 @@ const updateinfo = async (req, res) => {
};
};
const
login
=
async
(
req
,
res
)
=>
{
const
login
=
async
(
req
,
res
)
=>
{
try
{
try
{
console
.
log
(
"
login=
"
,
req
.
body
)
;
//
console.log(
'
login=
'
, req.body)
const
{
email
,
password
}
=
req
.
body
;
const
{
email
,
password
}
=
req
.
body
const
user
=
await
User
.
findOne
({
where
:
{
email
:
email
}
})
;
const
user
=
await
User
.
findOne
({
where
:
{
email
:
email
}
})
if
(
!
user
)
{
if
(
!
user
)
{
return
res
.
status
(
422
).
send
(
`
${
email
}
사용자가 존재하지 않습니다.`
);
return
res
.
status
(
422
).
send
(
`
${
email
}
사용자가 존재하지 않습니다.`
);
}
else
{
}
else
{
...
@@ -65,19 +67,19 @@ const login = async (req, res) => {
...
@@ -65,19 +67,19 @@ const login = async (req, res) => {
}
}
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
)
;
//
console.log(error)
return
res
.
status
(
500
).
send
(
"
로그인 중 에러
"
);
return
res
.
status
(
500
).
send
(
'
로그인 중 에러
'
)
}
}
};
};
const
signup
=
async
(
req
,
res
)
=>
{
const
signup
=
async
(
req
,
res
)
=>
{
try
{
try
{
console
.
log
(
"
sign up=
"
,
req
.
body
)
;
//
console.log(
'
sign up=
'
, req.body)
const
{
name
,
email
,
password
,
gender
,
phone
}
=
req
.
body
;
const
{
name
,
email
,
password
,
gender
,
phone
}
=
req
.
body
const
id
=
Math
.
floor
(
Math
.
random
()
*
(
9999
-
1000
)
+
1000
)
;
const
id
=
Math
.
floor
(
Math
.
random
()
*
(
9999
-
1000
)
+
1000
)
console
.
log
(
"
id:
"
,
id
)
;
//
console.log(
'
id:
'
, id)
const
Id
=
await
User
.
findOne
({
where
:
{
id
:
id
}
})
;
const
Id
=
await
User
.
findOne
({
where
:
{
id
:
id
}
})
console
.
log
(
"
Id 중복확인:
"
,
Id
)
;
//
console.log(
'
Id 중복확인:
'
, Id)
while
(
Id
)
{
while
(
Id
)
{
const
id
=
Math
.
floor
(
Math
.
random
()
*
(
9999
-
1000
)
+
1000
);
const
id
=
Math
.
floor
(
Math
.
random
()
*
(
9999
-
1000
)
+
1000
);
const
Id
=
await
User
.
findOne
({
where
:
{
id
:
id
}
});
const
Id
=
await
User
.
findOne
({
where
:
{
id
:
id
}
});
...
@@ -101,9 +103,7 @@ const signup = async (req, res) => {
...
@@ -101,9 +103,7 @@ const signup = async (req, res) => {
password
:
password
,
password
:
password
,
gender
:
gender
,
gender
:
gender
,
phone
:
phone
,
phone
:
phone
,
}).
then
((
_
)
=>
})
console
.
log
(
"
회원가입 정보
"
,
id
,
name
,
email
,
password
,
gender
,
phone
)
);
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
);
console
.
log
(
error
);
return
res
.
status
(
500
).
send
(
"
회원가입 중 에러
"
);
return
res
.
status
(
500
).
send
(
"
회원가입 중 에러
"
);
...
...
index.js
View file @
6d3794cb
...
@@ -20,13 +20,22 @@ sequelize
...
@@ -20,13 +20,22 @@ sequelize
email
:
"
admin
"
,
email
:
"
admin
"
,
password
:
"
admin!
"
,
password
:
"
admin!
"
,
gender
:
0
,
gender
:
0
,
roomNumber
:
[
"
1234567abc
"
,
"
abc7654321
"
],
});
});
await
Room
.
create
({
await
Room
.
create
({
id
:
"
1234567
890
"
,
id
:
"
1234567
abc
"
,
name
:
"
room
"
,
name
:
"
room
"
,
owner
:
8888
,
owner
:
8888
,
member
:
[
8888
],
member
:
[
8888
,
9999
],
profileimg
:
"
C:
\
fakepath
\
스크린샷(1).png
"
,
});
await
Room
.
create
({
id
:
"
abc7654321
"
,
name
:
"
room1
"
,
owner
:
9999
,
member
:
[
9999
],
profileimg
:
"
C:
\
fakepath
\
스크린샷(1).png
"
,
profileimg
:
"
C:
\
fakepath
\
스크린샷(1).png
"
,
});
});
...
...
routes/room.route.js
View file @
6d3794cb
...
@@ -2,7 +2,7 @@ import express from "express";
...
@@ -2,7 +2,7 @@ import express from "express";
import
roomCrtl
from
"
../controllers/room.controller.js
"
;
import
roomCrtl
from
"
../controllers/room.controller.js
"
;
const
router
=
express
.
Router
();
const
router
=
express
.
Router
();
router
.
route
(
"
/getRoom
"
).
ge
t
(
roomCrtl
.
getRoom
);
router
.
route
(
"
/getRoom
"
).
pos
t
(
roomCrtl
.
getRoom
);
router
.
route
(
"
/create
"
).
post
(
roomCrtl
.
createRoom
);
router
.
route
(
"
/create
"
).
post
(
roomCrtl
.
createRoom
);
router
.
route
(
"
/join
"
).
put
(
roomCrtl
.
joinRoom
);
router
.
route
(
"
/join
"
).
put
(
roomCrtl
.
joinRoom
);
...
...
routes/user.route.js
View file @
6d3794cb
...
@@ -3,7 +3,7 @@ import userCtrl from "../controllers/user.controller.js";
...
@@ -3,7 +3,7 @@ import userCtrl from "../controllers/user.controller.js";
const
router
=
express
.
Router
();
const
router
=
express
.
Router
();
router
.
route
(
"
/getUser
"
).
pos
t
(
userCtrl
.
getUser
);
router
.
route
(
"
/getUser
/:id
"
).
ge
t
(
userCtrl
.
getUser
);
router
.
route
(
"
/login
"
).
post
(
userCtrl
.
login
);
router
.
route
(
"
/login
"
).
post
(
userCtrl
.
login
);
router
.
route
(
"
/signup
"
).
post
(
userCtrl
.
signup
);
router
.
route
(
"
/signup
"
).
post
(
userCtrl
.
signup
);
...
...
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