Commit c71167c9 authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

Merge branch 'kimpen'

parents e5b75efa 19e3ba65
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
......@@ -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
......@@ -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
defaultValue: 0.0,
}
},
{
......
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
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
......@@ -9,7 +9,7 @@ router
.get(movieCtrl.comparePopularMovie)
router
.route("/upcomming")
.get(movieCtrl.upcommingMovie)
.route("/:movieId")
.post(movieCtrl.create)
export default router;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment