-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from Today-s-ramen/hyejung
- Loading branch information
Showing
24 changed files
with
287 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Request, Response } from 'express'; | ||
import { validationResult } from 'express-validator'; | ||
import { ReviewCreateDto } from '../interfaces/review/ReviewCreateDto'; | ||
import message from '../modules/responseMessage'; | ||
import statusCode from '../modules/statusCode'; | ||
import util from '../modules/util'; | ||
import { ReviewService } from '../services'; | ||
|
||
const getReviewList = async (req: Request, res: Response): Promise<Response | void> => { | ||
try { | ||
const data = await ReviewService.getReviewList(); | ||
if (!data) { | ||
res.status(statusCode.NOT_FOUND).send(util.fail(statusCode.NOT_FOUND, message.NOT_FOUND)); | ||
} | ||
res.status(statusCode.OK).send(util.success(statusCode.OK, message.READ_MAINPAGE_REVIEW_SUCCESS, data)); | ||
} catch (error) { | ||
console.log(error); | ||
res.status(statusCode.INTERNAL_SERVER_ERROR).send(util.fail(statusCode.INTERNAL_SERVER_ERROR, message.INTERNAL_SERVER_ERROR)); | ||
} | ||
}; | ||
|
||
const createReview = async (req: Request, res: Response): Promise<Response | void> => { | ||
const error = validationResult(req); | ||
if (!error.isEmpty()) { | ||
return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, message.BAD_REQUEST)); | ||
} | ||
|
||
const reviewCreateDto: ReviewCreateDto = req.body; | ||
try { | ||
const data = await ReviewService.createReview(reviewCreateDto); | ||
if (!data) { | ||
res.status(statusCode.NOT_FOUND).send(util.fail(statusCode.NOT_FOUND, message.NOT_FOUND)); | ||
} | ||
res.status(statusCode.CREATED).send(util.success(statusCode.CREATED, message.CREATE_REVIEW_SUCCESS, data)); | ||
} catch (error) { | ||
console.log(error); | ||
res.status(statusCode.INTERNAL_SERVER_ERROR).send(util.fail(statusCode.INTERNAL_SERVER_ERROR, message.INTERNAL_SERVER_ERROR)); | ||
} | ||
}; | ||
|
||
export default { | ||
getReviewList, | ||
createReview, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Request, Response } from 'express'; | ||
import message from '../modules/responseMessage'; | ||
import statusCode from '../modules/statusCode'; | ||
import util from '../modules/util'; | ||
import SubscribeService from '../services/SubscribeService'; | ||
|
||
const getSubscribeOptions = async (req: Request, res: Response) => { | ||
try { | ||
const data = await SubscribeService.getSubscribeOptions(); | ||
if (!data) { | ||
res.status(statusCode.NOT_FOUND).send(util.fail(statusCode.NOT_FOUND, message.NOT_FOUND)); | ||
} | ||
res.status(statusCode.OK).send(util.success(statusCode.OK, message.READ_SUBSCRIBE_OPTION_SUCCESS, data)); | ||
} catch (error) { | ||
console.log(error); | ||
res.status(statusCode.INTERNAL_SERVER_ERROR).send(util.fail(statusCode.INTERNAL_SERVER_ERROR, message.INTERNAL_SERVER_ERROR)); | ||
} | ||
}; | ||
|
||
export default { getSubscribeOptions }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// controller index file | ||
export { }; | ||
import ReviewController from './ReviewController'; | ||
import SubscribeController from './SubscribeController'; | ||
|
||
export { ReviewController, SubscribeController }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import mongoose from "mongoose"; | ||
import mongoose from 'mongoose'; | ||
|
||
export interface PostBaseResponseDto { | ||
_id: mongoose.Schema.Types.ObjectId; | ||
} | ||
_id: mongoose.Schema.Types.ObjectId; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export interface PeriodInfo { | ||
option: string; | ||
} | ||
option: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export interface QuantityInfo { | ||
option: string; | ||
}; | ||
option: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { ReviewInfo } from './ReviewInfo'; | ||
|
||
export interface ReviewCreateDto extends ReviewInfo {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
export interface ReviewInfo { | ||
userName: String; | ||
thumbnail?: String; | ||
description: Text; | ||
rates: Number; | ||
packageName: string; | ||
product: String; | ||
} | ||
userName: string; | ||
thumbnail?: string; | ||
description: Text; | ||
rates: number; | ||
packageName: string; | ||
product: string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import mongoose from 'mongoose'; | ||
|
||
export interface ReviewResponseDto { | ||
_id: mongoose.Types.ObjectId; | ||
userName: string; | ||
description: Text; | ||
productList: string[]; | ||
reviewDate: string; | ||
thumbnail: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { PeriodInfo } from "../period/PeriodInfo"; | ||
import { QuantityInfo } from "../quantity/QuantityInfo"; | ||
import { PeriodInfo } from '../period/PeriodInfo'; | ||
import { QuantityInfo } from '../quantity/QuantityInfo'; | ||
|
||
export interface SubscribeInfo { | ||
period: PeriodInfo; | ||
quantity: QuantityInfo; | ||
}; | ||
period: PeriodInfo; | ||
quantity: QuantityInfo; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { PeriodInfo } from '../period/PeriodInfo'; | ||
import { QuantityInfo } from '../quantity/QuantityInfo'; | ||
|
||
export interface SubscribeOptionDto { | ||
deliveryPeriodOptions: PeriodInfo[]; | ||
deliveryQuantityOptions: QuantityInfo[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import mongoose from "mongoose"; | ||
import { PeriodInfo } from "../interfaces/period/PeriodInfo"; | ||
import mongoose from 'mongoose'; | ||
import { PeriodInfo } from '../interfaces/period/PeriodInfo'; | ||
|
||
const PeriodSchema = new mongoose.Schema ({ | ||
option: { | ||
type: String, | ||
required: true | ||
} | ||
const PeriodSchema = new mongoose.Schema({ | ||
option: { | ||
type: String, | ||
required: true, | ||
}, | ||
}); | ||
|
||
export default mongoose.model<PeriodInfo & mongoose.Document>("Period", PeriodSchema) | ||
export default mongoose.model<PeriodInfo & mongoose.Document>('Period', PeriodSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import mongoose from "mongoose"; | ||
import { QuantityInfo } from "../interfaces/quantity/QuantityInfo"; | ||
import mongoose from 'mongoose'; | ||
import { QuantityInfo } from '../interfaces/quantity/QuantityInfo'; | ||
|
||
const QuantitySchema = new mongoose.Schema ({ | ||
option: { | ||
type: String, | ||
required: true | ||
} | ||
const QuantitySchema = new mongoose.Schema({ | ||
option: { | ||
type: String, | ||
required: true, | ||
}, | ||
}); | ||
|
||
export default mongoose.model<QuantityInfo & mongoose.Document>("Queantity", QuantitySchema) | ||
export default mongoose.model<QuantityInfo & mongoose.Document>('Quantity', QuantitySchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
import mongoose from "mongoose"; | ||
import { ReviewInfo } from "../interfaces/review/ReviewInfo"; | ||
import mongoose from 'mongoose'; | ||
import { ReviewInfo } from '../interfaces/review/ReviewInfo'; | ||
|
||
const ReviewSchema = new mongoose.Schema ({ | ||
const ReviewSchema = new mongoose.Schema( | ||
{ | ||
userName: { | ||
type: String, | ||
required: true | ||
type: String, | ||
required: true, | ||
}, | ||
thumbnanil: { | ||
type: String | ||
thumbnail: { | ||
type: String, | ||
}, | ||
description: { | ||
type: String, | ||
required: true | ||
type: String, | ||
required: true, | ||
}, | ||
rates: { | ||
type: Number, | ||
required: true | ||
type: Number, | ||
required: true, | ||
}, | ||
packageName: { | ||
type: String, | ||
required: true | ||
type: String, | ||
required: true, | ||
}, | ||
product: { | ||
type: String, | ||
required: true | ||
} | ||
}, | ||
{timestamps: true} | ||
type: Array, | ||
required: true, | ||
}, | ||
}, | ||
{ timestamps: true }, | ||
); | ||
|
||
export default mongoose.model<ReviewInfo & mongoose.Document>("Review", ReviewSchema) | ||
export default mongoose.model<ReviewInfo & mongoose.Document>('Review', ReviewSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import mongoose from "mongoose"; | ||
import { SubscribeInfo } from "../interfaces/subscribe/SubscribeInfo"; | ||
import mongoose from 'mongoose'; | ||
import { SubscribeInfo } from '../interfaces/subscribe/SubscribeInfo'; | ||
|
||
const SubscribeSchema = new mongoose.Schema ({ | ||
period: { | ||
option: { | ||
type: String, | ||
required: true | ||
} | ||
const SubscribeSchema = new mongoose.Schema({ | ||
period: { | ||
option: { | ||
type: String, | ||
required: true, | ||
}, | ||
quantity: { | ||
option: { | ||
type: String, | ||
required: true | ||
} | ||
} | ||
}, | ||
quantity: { | ||
option: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
}); | ||
|
||
export default mongoose.model<SubscribeInfo & mongoose.Document>("Subscribe", SubscribeSchema) | ||
export default mongoose.model<SubscribeInfo & mongoose.Document>('Subscribe', SubscribeSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Router } from 'express'; | ||
import { body } from 'express-validator'; | ||
import { ReviewController } from '../controllers'; | ||
|
||
const router: Router = Router(); | ||
|
||
router.get('/', ReviewController.getReviewList); | ||
router.post('/', [body('userName').notEmpty(), body('description').notEmpty(), body('rates').notEmpty(), body('packageName').notEmpty(), body('product').notEmpty()], ReviewController.createReview); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Router } from 'express'; | ||
import { SubscribeController } from '../controllers'; | ||
|
||
const router: Router = Router(); | ||
|
||
router.get('/', SubscribeController.getSubscribeOptions); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
// router index file | ||
import { Router } from 'express'; | ||
import ReviewRouter from './ReviewRouter'; | ||
import SubScribeRouter from './SubscribeRouter'; | ||
|
||
const router = Router(); | ||
const router: Router = Router(); | ||
|
||
router.use('/review', ReviewRouter); | ||
router.use('/subscribe', SubScribeRouter); | ||
|
||
export default router; |
Oops, something went wrong.