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
butter-studio
Commits
c71167c9
Commit
c71167c9
authored
Jul 16, 2021
by
Jiwon Yoon
Browse files
Merge branch 'kimpen'
parents
e5b75efa
19e3ba65
Changes
26
Hide whitespace changes
Inline
Side-by-side
client/src/utils/catchErrors.js
0 → 100644
View file @
c71167c9
const
catchErrors
=
(
error
,
displayError
)
=>
{
let
errorMsg
if
(
error
.
response
)
{
errorMsg
=
error
.
response
.
data
console
.
log
(
'
Error response:
'
,
errorMsg
)
}
else
if
(
error
.
request
)
{
errorMsg
=
error
.
request
console
.
log
(
'
Error request:
'
,
errorMsg
)
}
else
{
errorMsg
=
error
.
message
console
.
log
(
'
Error message:
'
,
errorMsg
)
}
displayError
(
errorMsg
)
alert
(
errorMsg
)
}
export
default
catchErrors
\ No newline at end of file
server/controllers/movie.controller.js
View file @
c71167c9
...
...
@@ -69,4 +69,21 @@ const upcommingMovie = async (req, res) => {
}
}
export
default
{
comparePopularMovie
,
upcommingMovie
}
\ No newline at end of file
<<<<<<<
HEAD
export
default
{
comparePopularMovie
,
upcommingMovie
}
=======
const
create
=
async
(
req
,
res
)
=>
{
try
{
const
{
movieId
}
=
req
.
params
const
newMovie
=
await
Movie
.
create
({
movieId
:
movieId
});
return
res
.
json
(
newMovie
);
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
영화 등록 중 에러 발생
"
);
}
}
export
default
{
comparePopularMovie
,
create
,
}
>>>>>>>
kimpen
server/models/movie.model.js
View file @
c71167c9
...
...
@@ -13,16 +13,15 @@ const MovieModel = (sequelize) => {
},
movieId
:
{
type
:
DataTypes
.
INTEGER
,
unique
:
true
unique
:
true
,
},
ticket_sales
:{
ticket_sales
:
{
type
:
DataTypes
.
FLOAT
,
default
:
0.0
defaultValue
:
0.0
,
},
vote_average
:
{
type
:
DataTypes
.
FLOAT
,
default
:
0.0
default
Value
:
0.0
,
}
},
{
...
...
server/models/role.model.js
0 → 100644
View file @
c71167c9
import
Sequelize
from
"
sequelize
"
;
const
{
DataTypes
}
=
Sequelize
;
// export const ROLE_NAME = {
// USER = "user",
// MEMBER = "member",
// ADMIN = "admin",
// ROOT = "root",
// }
const
RoleModel
=
(
sequelize
)
=>
{
const
Role
=
sequelize
.
define
(
"
role
"
,
{
id
:
{
type
:
DataTypes
.
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
name
:
{
type
:
DataTypes
.
ENUM
({
values
:
Object
.
values
(
ROLE_NAME
),
}),
defaultValue
:
ROLE_NAME
.
USER
,
set
(
value
)
{
const
lowerCaseName
=
value
.
toLowerCase
();
this
.
setDataValue
(
"
name
"
,
lowerCaseName
);
switch
(
lowerCaseName
)
{
case
ROLE_NAME
.
USER
:
this
.
priority
=
1000
;
break
;
case
ROLE_NAME
.
MEMBER
:
this
.
priority
=
500
;
break
;
case
ROLE_NAME
.
ADMIN
:
this
.
priority
=
50
;
break
;
case
ROLE_NAME
.
ROOT
:
this
.
priority
=
1
;
break
;
default
:
this
.
priority
=
1000
;
break
;
}
},
},
priority
:
{
type
:
DataTypes
.
INTEGER
,
defaultValue
:
1000
,
},
},
{
timestamps
:
true
,
}
);
return
Role
;
};
export
default
RoleModel
;
\ No newline at end of file
server/models/user.model.js
0 → 100644
View file @
c71167c9
import
bcrypt
from
"
bcryptjs
"
;
import
Sequelize
from
"
sequelize
"
;
// import { ROLE_NAME } from "./role.model.js";
const
{
DataTypes
}
=
Sequelize
;
const
UserModel
=
(
sequelize
)
=>
{
const
User
=
sequelize
.
define
(
"
user
"
,
{
id
:
{
type
:
DataTypes
.
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
userId
:
{
type
:
DataTypes
.
STRING
,
},
password
:
{
type
:
DataTypes
.
STRING
,
},
nickname
:
{
type
:
DataTypes
.
STRING
,
},
birth
:
{
type
:
DataTypes
.
INTEGER
,
},
phoneNumber
:
{
type
:
DataTypes
.
INTEGER
},
// role: {
// type: DataTypes.ENUM({
// values: Object.values(ROLE_NAME),
// }),
// }
},
{
timestamps
:
true
,
freezeTableName
:
true
,
tableName
:
"
users
"
// defaultScope: {
// attributes: { exclude: ["password"] },
// },
// scopes: {
// withPassword: {
// attributes: { include: ["password"] },
// },
// },
}
);
return
User
};
export
default
UserModel
\ No newline at end of file
server/routes/movie.route.js
View file @
c71167c9
...
...
@@ -9,7 +9,7 @@ router
.
get
(
movieCtrl
.
comparePopularMovie
)
router
.
route
(
"
/
upcomming
"
)
.
ge
t
(
movieCtrl
.
upcommingMovi
e
)
.
route
(
"
/
:movieId
"
)
.
pos
t
(
movieCtrl
.
creat
e
)
export
default
router
;
\ No newline at end of file
Prev
1
2
Next
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