Showing
9 changed files
with
208 additions
and
84 deletions
Database/lecture.json
0 → 100644
1 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2825"},"lecturename":"전공 기초","__v":{"$numberInt":"0"}} | ||
2 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2826"},"lecturename":"미분적분학","__v":{"$numberInt":"0"}} | ||
3 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2827"},"lecturename":"선형대수","__v":{"$numberInt":"0"}} | ||
4 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2828"},"lecturename":"확률 및 랜덤변수","__v":{"$numberInt":"0"}} | ||
5 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2829"},"lecturename":"미분방정식","__v":{"$numberInt":"0"}} | ||
6 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced282a"},"lecturename":"이산구조","__v":{"$numberInt":"0"}} | ||
7 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced282b"},"lecturename":"전공 필수","__v":{"$numberInt":"0"}} | ||
8 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced282c"},"lecturename":"웹/파이선프로그래밍","__v":{"$numberInt":"0"}} | ||
9 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced282d"},"lecturename":"객체지향프로그래밍","__v":{"$numberInt":"0"}} | ||
10 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced282e"},"lecturename":"논리회로","__v":{"$numberInt":"0"}} | ||
11 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced282f"},"lecturename":"컴퓨터구조","__v":{"$numberInt":"0"}} | ||
12 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2830"},"lecturename":"자료구조","__v":{"$numberInt":"0"}} | ||
13 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2831"},"lecturename":"운영체제","__v":{"$numberInt":"0"}} | ||
14 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2832"},"lecturename":"컴퓨터네트워크","__v":{"$numberInt":"0"}} | ||
15 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2833"},"lecturename":"소프트웨어공학","__v":{"$numberInt":"0"}} | ||
16 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2834"},"lecturename":"알고리즘분석","__v":{"$numberInt":"0"}} | ||
17 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2835"},"lecturename":"데이터베이스","__v":{"$numberInt":"0"}} | ||
18 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2836"},"lecturename":"오픈소스SW개발","__v":{"$numberInt":"0"}} | ||
19 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2837"},"lecturename":"IT기술영어 1","__v":{"$numberInt":"0"}} | ||
20 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2838"},"lecturename":"IT기술영어 2","__v":{"$numberInt":"0"}} | ||
21 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2839"},"lecturename":"IT기술영어 3","__v":{"$numberInt":"0"}} | ||
22 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced283a"},"lecturename":"캡스톤디자인 1","__v":{"$numberInt":"0"}} | ||
23 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced283b"},"lecturename":"캡스톤디자인 2","__v":{"$numberInt":"0"}} | ||
24 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced283c"},"lecturename":"졸업논문","__v":{"$numberInt":"0"}} | ||
25 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced283d"},"lecturename":"전공 선택","__v":{"$numberInt":"0"}} | ||
26 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced283e"},"lecturename":"문제해결","__v":{"$numberInt":"0"}} | ||
27 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced283f"},"lecturename":"형식언어 및컴파일러","__v":{"$numberInt":"0"}} | ||
28 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2840"},"lecturename":"파일처리","__v":{"$numberInt":"0"}} | ||
29 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2841"},"lecturename":"멀티미디어시스템","__v":{"$numberInt":"0"}} | ||
30 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2842"},"lecturename":"시스템분석 및 설계","__v":{"$numberInt":"0"}} | ||
31 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2843"},"lecturename":"프로그래밍언어구조론","__v":{"$numberInt":"0"}} | ||
32 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2844"},"lecturename":"JAVA프로그래밍","__v":{"$numberInt":"0"}} | ||
33 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2845"},"lecturename":"SW스타트업비즈니스","__v":{"$numberInt":"0"}} | ||
34 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2846"},"lecturename":"SW스타트업프로젝트","__v":{"$numberInt":"0"}} | ||
35 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2847"},"lecturename":"최신기술프로젝트 1","__v":{"$numberInt":"0"}} | ||
36 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2848"},"lecturename":"최신기술프로젝트 2","__v":{"$numberInt":"0"}} | ||
37 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2849"},"lecturename":"최신기술콜로키움 1","__v":{"$numberInt":"0"}} | ||
38 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced284a"},"lecturename":"최신기술콜로키움 2","__v":{"$numberInt":"0"}} | ||
39 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced284b"},"lecturename":"단기현장실습","__v":{"$numberInt":"0"}} | ||
40 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced284c"},"lecturename":"장기현장실습","__v":{"$numberInt":"0"}} | ||
41 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced284d"},"lecturename":"연구연수활동 1","__v":{"$numberInt":"0"}} | ||
42 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced284e"},"lecturename":"연구연수활동 2","__v":{"$numberInt":"0"}} | ||
43 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced284f"},"lecturename":"독립심화학습1 (컴퓨터공학과)","__v":{"$numberInt":"0"}} | ||
44 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2850"},"lecturename":"독립심화학습2 (컴퓨터공학과)","__v":{"$numberInt":"0"}} | ||
45 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2851"},"lecturename":"인공지능","__v":{"$numberInt":"0"}} | ||
46 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2852"},"lecturename":"머신러닝","__v":{"$numberInt":"0"}} | ||
47 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2853"},"lecturename":"빅데이터프로그래밍","__v":{"$numberInt":"0"}} | ||
48 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2854"},"lecturename":"클라우드컴퓨팅","__v":{"$numberInt":"0"}} | ||
49 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2855"},"lecturename":"데이터센터프로그래밍","__v":{"$numberInt":"0"}} | ||
50 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2856"},"lecturename":"네트워크분석및 설계","__v":{"$numberInt":"0"}} | ||
51 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2857"},"lecturename":"인터넷프로토콜및 프로그래밍","__v":{"$numberInt":"0"}} | ||
52 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2858"},"lecturename":"정보보호","__v":{"$numberInt":"0"}} | ||
53 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2859"},"lecturename":"모바일프로그래밍","__v":{"$numberInt":"0"}} | ||
54 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced285a"},"lecturename":"웹서비스프로그래밍","__v":{"$numberInt":"0"}} | ||
55 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced285b"},"lecturename":"리눅스시스템프로그래밍","__v":{"$numberInt":"0"}} | ||
56 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced285c"},"lecturename":"IoT디지털시스템","__v":{"$numberInt":"0"}} | ||
57 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced285d"},"lecturename":"IoT소프트웨어","__v":{"$numberInt":"0"}} | ||
58 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced285e"},"lecturename":"로봇소프트웨어","__v":{"$numberInt":"0"}} | ||
59 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced285f"},"lecturename":"영상처리","__v":{"$numberInt":"0"}} | ||
60 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2860"},"lecturename":"컴퓨터그래픽스","__v":{"$numberInt":"0"}} | ||
61 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2861"},"lecturename":"멀티미디어처리","__v":{"$numberInt":"0"}} | ||
62 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2862"},"lecturename":"인간-컴퓨터상호작용","__v":{"$numberInt":"0"}} | ||
63 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2863"},"lecturename":"UI/UX프로그래밍","__v":{"$numberInt":"0"}} | ||
64 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2864"},"lecturename":"컴퓨터비젼","__v":{"$numberInt":"0"}} | ||
65 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2865"},"lecturename":"디자인적사고","__v":{"$numberInt":"0"}} | ||
66 | +{"_id":{"$oid":"5cf0da0c7c7624ccbced2866"},"lecturename":"신호와시스템","__v":{"$numberInt":"0"}} |
khu.js
0 → 100644
1 | +const puppeteer = require('puppeteer'); | ||
2 | +const request = require('request'); | ||
3 | + | ||
4 | +(async () => { | ||
5 | + const browser = await puppeteer.launch(); | ||
6 | + const page = await browser.newPage(); | ||
7 | + await page.goto('http://ce.khu.ac.kr/index.php?hCode=UNIVERSITY_02_01_01'); | ||
8 | + await page.screenshot({path: 'test.png'}); | ||
9 | + var lecture = []; | ||
10 | + lecture = await page.evaluate(() => { | ||
11 | + const anchors = Array.from(document.querySelectorAll('#conTD > td > div > table > tbody > tr > td:nth-child(2)')); | ||
12 | + return anchors.map(anchor => anchor.textContent); | ||
13 | + }) | ||
14 | + | ||
15 | + lecture.push("디자인적사고") | ||
16 | + lecture.push("신호와시스템") | ||
17 | + console.log(lecture) | ||
18 | + var opts | ||
19 | + | ||
20 | + | ||
21 | + var posturl = "mongodb://localhost/facebookbot" + "/lectures" | ||
22 | + for(var i=0; i<lecture.length; i++){ | ||
23 | + console.log(lecture[i]) | ||
24 | + request.post('http://127.0.0.1:4500/lectures', { | ||
25 | + form: { | ||
26 | + lecturename: lecture[i] | ||
27 | + } | ||
28 | + }) | ||
29 | + } | ||
30 | + await browser.close(); | ||
31 | +})(); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | const mongoose = require('mongoose'); | 1 | const mongoose = require('mongoose'); |
2 | 2 | ||
3 | -// Define Schemes | ||
4 | -const lectureSchema = new mongoose.Schema({ | ||
5 | - lectureid: { type: String, unique: true }, | ||
6 | - lecturename: { type: String}, | ||
7 | - proname: { type: String }, | ||
8 | - avg_rate: { type: Number } | ||
9 | -}); | ||
10 | 3 | ||
11 | -const reviewSchema = new mongoose.Schema({ | 4 | +const LectureSchema = new mongoose.Schema({ |
12 | - lectureid: { type: String, required: true, unique: true }, | 5 | + lecturename: { type: String, required: true, unique: true } |
13 | - review: { type: String, required: true } | ||
14 | }); | 6 | }); |
15 | 7 | ||
16 | -// // Create new lecture document | 8 | +// // Create new review document |
17 | -lectureSchema.statics.create = function (payload) { | 9 | +LectureSchema.statics.create = function (payload) { |
18 | // this === Model | 10 | // this === Model |
19 | - const lecture = new this(payload); | 11 | + const review = new this(payload); |
20 | // return Promise | 12 | // return Promise |
21 | - return lecture.save(); | 13 | + return review.save(); |
22 | }; | 14 | }; |
23 | 15 | ||
24 | // Find All | 16 | // Find All |
25 | -lectureSchema.statics.findAll = function () { | 17 | +LectureSchema.statics.findAll = function () { |
26 | // return promise | 18 | // return promise |
27 | // V4부터 exec() 필요없음 | 19 | // V4부터 exec() 필요없음 |
28 | return this.find({}); | 20 | return this.find({}); |
29 | }; | 21 | }; |
30 | 22 | ||
31 | -// Find One by lectureid | 23 | +// Find One by lecturename |
32 | -lectureSchema.statics.findOneBylectureid = function (lectureid) { | 24 | +LectureSchema.statics.findOneBylecturename = function (lecturename) { |
33 | - return this.findOne({ lectureid }); | 25 | + return this.findOne({ lecturename }); |
34 | }; | 26 | }; |
35 | 27 | ||
36 | -// Update by lectureid | 28 | +// Update by lecturename |
37 | -lectureSchema.statics.updateBylectureid = function (lectureid, payload) { | 29 | +LectureSchema.statics.updateBylecturename = function (lecturename, payload) { |
38 | // { new: true }: return the modified document rather than the original. defaults to false | 30 | // { new: true }: return the modified document rather than the original. defaults to false |
39 | - return this.findOneAndUpdate({ lectureid }, payload, { new: true }); | 31 | + return this.findOneAndUpdate({ lecturename }, payload, { new: true }); |
40 | }; | 32 | }; |
41 | 33 | ||
42 | -// Delete by lectureid | 34 | +// Delete by lecturename |
43 | -lectureSchema.statics.deleteBylectureid = function (lectureid) { | 35 | +LectureSchema.statics.deleteBylecturename = function (lecturename) { |
44 | - return this.remove({ lectureid }); | 36 | + return this.remove({ lecturename }); |
45 | }; | 37 | }; |
46 | 38 | ||
47 | // Create Model & Export | 39 | // Create Model & Export |
48 | -module.exports = mongoose.model('Lecture', lectureSchema); | 40 | +module.exports = mongoose.model('Lecture', LectureSchema); |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | const mongoose = require('mongoose'); | 1 | const mongoose = require('mongoose'); |
2 | 2 | ||
3 | - | 3 | +// Define Schemes |
4 | const reviewSchema = new mongoose.Schema({ | 4 | const reviewSchema = new mongoose.Schema({ |
5 | - lectureid: { type: String, required: true, unique: true }, | 5 | + lecturename: { type: String }, |
6 | - review: { type: String, required: true } | 6 | + proname: { type: String }, |
7 | + avg_rate: { type: Number }, | ||
8 | + review: {type : String} | ||
7 | }); | 9 | }); |
8 | 10 | ||
9 | -// // Create new review document | 11 | + |
12 | +// // Create new lecture document | ||
10 | reviewSchema.statics.create = function (payload) { | 13 | reviewSchema.statics.create = function (payload) { |
11 | // this === Model | 14 | // this === Model |
12 | - const review = new this(payload); | 15 | + const lecture = new this(payload); |
13 | // return Promise | 16 | // return Promise |
14 | - return review.save(); | 17 | + return lecture.save(); |
15 | }; | 18 | }; |
16 | 19 | ||
17 | -// Find All | 20 | +// Find lecturename |
18 | -reviewSchema.statics.findAll = function () { | 21 | +reviewSchema.statics.findBylecturename = function (lecturename) { |
19 | // return promise | 22 | // return promise |
20 | // V4부터 exec() 필요없음 | 23 | // V4부터 exec() 필요없음 |
21 | - return this.find({}); | 24 | + return this.find({ lecturename }); |
22 | }; | 25 | }; |
23 | 26 | ||
24 | -// Find One by reviewid | 27 | +// Find by professor name |
25 | -reviewSchema.statics.findOneByreviewid = function (reviewid) { | 28 | +reviewSchema.statics.findByproname = function (proname) { |
26 | - return this.findOne({ reviewid }); | 29 | + return this.find({ proname }); |
27 | }; | 30 | }; |
28 | 31 | ||
29 | -// Update by reviewid | 32 | +// Update by lecturename |
30 | -reviewSchema.statics.updateByreviewid = function (reviewid, payload) { | 33 | +reviewSchema.statics.updateBylecturename = function (lecturename, payload) { |
31 | // { new: true }: return the modified document rather than the original. defaults to false | 34 | // { new: true }: return the modified document rather than the original. defaults to false |
32 | - return this.findOneAndUpdate({ reviewid }, payload, { new: true }); | 35 | + return this.findOneAndUpdate({ lecturename }, payload, { new: true }); |
33 | }; | 36 | }; |
34 | 37 | ||
35 | -// Delete by reviewid | 38 | +// Delete by lecturename |
36 | -reviewSchema.statics.deleteByreviewid = function (reviewid) { | 39 | +reviewSchema.statics.deleteBylecturename = function (lecturename) { |
37 | - return this.remove({ reviewid }); | 40 | + return this.remove({ lecturename }); |
38 | }; | 41 | }; |
39 | 42 | ||
40 | // Create Model & Export | 43 | // Create Model & Export |
41 | -module.exports = mongoose.model('Review', reviewSchema); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
44 | +module.exports = mongoose.model('Review', reviewSchema); | ... | ... |
... | @@ -617,12 +617,25 @@ | ... | @@ -617,12 +617,25 @@ |
617 | } | 617 | } |
618 | }, | 618 | }, |
619 | "mongodb": { | 619 | "mongodb": { |
620 | - "version": "3.2.5", | 620 | + "version": "3.2.6", |
621 | - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.2.5.tgz", | 621 | + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.2.6.tgz", |
622 | - "integrity": "sha512-VEu2nsfFMwWA6q6JVnlJ2kNVwjluU4op2J/YiG1LeI14t9HotLXbg8w3I794BvezC4ZCZ/wBTTdby01txalwwQ==", | 622 | + "integrity": "sha512-qnHc4tjEkHKemuzBq9R7ycYnhFE0Dlpt6+n6suoZp2DcDdqviQ+teloJU24fsOw/PLmr75yGk4mRx/YabjDQEQ==", |
623 | "requires": { | 623 | "requires": { |
624 | - "mongodb-core": "3.2.5", | 624 | + "mongodb-core": "3.2.6", |
625 | "safe-buffer": "^5.1.2" | 625 | "safe-buffer": "^5.1.2" |
626 | + }, | ||
627 | + "dependencies": { | ||
628 | + "mongodb-core": { | ||
629 | + "version": "3.2.6", | ||
630 | + "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.2.6.tgz", | ||
631 | + "integrity": "sha512-i+XRVjur9D0ywGF7cFebOUnALnbvMHajdNhhl3TQuopW6QDE655G8CpPeERbqSqfa3rOKEUo08lENDIiBIuAvQ==", | ||
632 | + "requires": { | ||
633 | + "bson": "^1.1.1", | ||
634 | + "require_optional": "^1.0.1", | ||
635 | + "safe-buffer": "^5.1.2", | ||
636 | + "saslprep": "^1.0.0" | ||
637 | + } | ||
638 | + } | ||
626 | } | 639 | } |
627 | }, | 640 | }, |
628 | "mongodb-core": { | 641 | "mongodb-core": { |
... | @@ -656,6 +669,15 @@ | ... | @@ -656,6 +669,15 @@ |
656 | "sliced": "1.0.1" | 669 | "sliced": "1.0.1" |
657 | }, | 670 | }, |
658 | "dependencies": { | 671 | "dependencies": { |
672 | + "mongodb": { | ||
673 | + "version": "3.2.5", | ||
674 | + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.2.5.tgz", | ||
675 | + "integrity": "sha512-VEu2nsfFMwWA6q6JVnlJ2kNVwjluU4op2J/YiG1LeI14t9HotLXbg8w3I794BvezC4ZCZ/wBTTdby01txalwwQ==", | ||
676 | + "requires": { | ||
677 | + "mongodb-core": "3.2.5", | ||
678 | + "safe-buffer": "^5.1.2" | ||
679 | + } | ||
680 | + }, | ||
659 | "ms": { | 681 | "ms": { |
660 | "version": "2.1.1", | 682 | "version": "2.1.1", |
661 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", | 683 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", | ... | ... |
... | @@ -13,6 +13,7 @@ | ... | @@ -13,6 +13,7 @@ |
13 | "body-parser": "^1.19.0", | 13 | "body-parser": "^1.19.0", |
14 | "dotenv": "^8.0.0", | 14 | "dotenv": "^8.0.0", |
15 | "express": "^4.17.0", | 15 | "express": "^4.17.0", |
16 | + "mongodb": "^3.2.6", | ||
16 | "mongoose": "^5.5.11", | 17 | "mongoose": "^5.5.11", |
17 | "puppeteer": "^1.17.0", | 18 | "puppeteer": "^1.17.0", |
18 | "puppeteer-core": "^1.17.0", | 19 | "puppeteer-core": "^1.17.0", | ... | ... |
... | @@ -4,41 +4,41 @@ const Lecture = require('../models/lecture'); | ... | @@ -4,41 +4,41 @@ const Lecture = require('../models/lecture'); |
4 | // Find All | 4 | // Find All |
5 | router.get('/', (req, res) => { | 5 | router.get('/', (req, res) => { |
6 | Lecture.findAll() | 6 | Lecture.findAll() |
7 | - .then((lectures) => { | 7 | + .then((Lectures) => { |
8 | - if (!lectures.length) return res.status(404).send({ err: 'Lecture not found' }); | 8 | + if (!Lectures.length) return res.status(404).send({ err: 'Lecture not found' }); |
9 | - res.send(`find successfully: ${lectures}`); | 9 | + res.send(`find successfully: ${Lectures}`); |
10 | }) | 10 | }) |
11 | .catch(err => res.status(500).send(err)); | 11 | .catch(err => res.status(500).send(err)); |
12 | }); | 12 | }); |
13 | 13 | ||
14 | -// Find One by lectureid | 14 | +// Find One by lecturename |
15 | -router.get('/lectureid/:lectureid', (req, res) => { | 15 | +router.get('/lecturename/:lecturename', (req, res) => { |
16 | - Lecture.findOneBylectureid(req.params.lectureid) | 16 | + Lecture.findOneBylecturename(req.params.lecturename) |
17 | - .then((lecture) => { | 17 | + .then((Lecture) => { |
18 | - if (!lecture) return res.status(404).send({ err: 'Lecture not found' }); | 18 | + if (!Lecture) return res.status(404).send({ err: 'Lecture not found' }); |
19 | - res.send(`findOne successfully: ${lecture}`); | 19 | + res.send(`findOne successfully: ${Lecture}`); |
20 | }) | 20 | }) |
21 | .catch(err => res.status(500).send(err)); | 21 | .catch(err => res.status(500).send(err)); |
22 | }); | 22 | }); |
23 | 23 | ||
24 | -// Create new lecture document | 24 | +// Create new Lecture document |
25 | router.post('/', (req, res) => { | 25 | router.post('/', (req, res) => { |
26 | console.log(req.body) | 26 | console.log(req.body) |
27 | Lecture.create(req.body) | 27 | Lecture.create(req.body) |
28 | - .then(lecture => res.send(lecture)) | 28 | + .then(Lecture => res.send(Lecture)) |
29 | .catch(err => res.status(500).send(err)); | 29 | .catch(err => res.status(500).send(err)); |
30 | }); | 30 | }); |
31 | 31 | ||
32 | -// Update by lectureid | 32 | +// Update by lecturename |
33 | -router.put('/lectureid/:lectureid', (req, res) => { | 33 | +router.put('/lecturename/:lecturename', (req, res) => { |
34 | - Lecture.updateBylectureid(req.params.lectureid, req.body) | 34 | + Lecture.updateBylecturename(req.params.lecturename, req.body) |
35 | - .then(lecture => res.send(lecture)) | 35 | + .then(Lecture => res.send(Lecture)) |
36 | .catch(err => res.status(500).send(err)); | 36 | .catch(err => res.status(500).send(err)); |
37 | }); | 37 | }); |
38 | 38 | ||
39 | -// Delete by lectureid | 39 | +// Delete by lecturename |
40 | -router.delete('/lectureid/:lectureid', (req, res) => { | 40 | +router.delete('/lecturename/:lecturename', (req, res) => { |
41 | - Lecture.deleteBylectureid(req.params.lectureid) | 41 | + Lecture.deleteBylecturename(req.params.lecturename) |
42 | .then(() => res.sendStatus(200)) | 42 | .then(() => res.sendStatus(200)) |
43 | .catch(err => res.status(500).send(err)); | 43 | .catch(err => res.status(500).send(err)); |
44 | }); | 44 | }); | ... | ... |
... | @@ -4,41 +4,50 @@ const Review = require('../models/review'); | ... | @@ -4,41 +4,50 @@ const Review = require('../models/review'); |
4 | // Find All | 4 | // Find All |
5 | router.get('/', (req, res) => { | 5 | router.get('/', (req, res) => { |
6 | Review.findAll() | 6 | Review.findAll() |
7 | - .then((reviews) => { | 7 | + .then((Reviews) => { |
8 | - if (!reviews.length) return res.status(404).send({ err: 'Review not found' }); | 8 | + if (!Reviews.length) return res.status(404).send({ err: 'Review not found' }); |
9 | - res.send(`find successfully: ${reviews}`); | 9 | + res.send(`find successfully: ${Reviews}`); |
10 | }) | 10 | }) |
11 | .catch(err => res.status(500).send(err)); | 11 | .catch(err => res.status(500).send(err)); |
12 | }); | 12 | }); |
13 | 13 | ||
14 | -// Find One by reviewid | 14 | +// Find One by Reviewid |
15 | -router.get('/reviewid/:reviewid', (req, res) => { | 15 | +router.get('/lecturename/:lecturename', (req, res) => { |
16 | - Review.findOneByreviewid(req.params.reviewid) | 16 | + Review.findBylecturename(req.params.lecturename) |
17 | - .then((review) => { | 17 | + .then((Review) => { |
18 | - if (!review) return res.status(404).send({ err: 'Review not found' }); | 18 | + if (!Review) return res.status(404).send({ err: 'Review not found' }); |
19 | - res.send(`findOne successfully: ${review}`); | 19 | + res.send(`findOne successfully: ${Review}`); |
20 | }) | 20 | }) |
21 | .catch(err => res.status(500).send(err)); | 21 | .catch(err => res.status(500).send(err)); |
22 | }); | 22 | }); |
23 | 23 | ||
24 | -// Create new review document | 24 | +router.get('/proname/:proname', (req, res) => { |
25 | + Review.findByproname(req.params.proname) | ||
26 | + .then((Review) => { | ||
27 | + if (!Review) return res.status(404).send({ err: 'Review not found' }); | ||
28 | + res.send(`findOne successfully: ${Review}`); | ||
29 | + }) | ||
30 | + .catch(err => res.status(500).send(err)); | ||
31 | +}); | ||
32 | + | ||
33 | +// Create new Review document | ||
25 | router.post('/', (req, res) => { | 34 | router.post('/', (req, res) => { |
26 | console.log(req.body) | 35 | console.log(req.body) |
27 | Review.create(req.body) | 36 | Review.create(req.body) |
28 | - .then(review => res.send(review)) | 37 | + .then(Review => res.send(Review)) |
29 | .catch(err => res.status(500).send(err)); | 38 | .catch(err => res.status(500).send(err)); |
30 | }); | 39 | }); |
31 | 40 | ||
32 | -// Update by reviewid | 41 | +// Update by lecturename |
33 | -router.put('/reviewid/:reviewid', (req, res) => { | 42 | +router.put('/lecturename/:lecturename', (req, res) => { |
34 | - Review.updateByreviewid(req.params.reviewid, req.body) | 43 | + Review.updateBylecturename(req.params.lecturename, req.body) |
35 | - .then(review => res.send(review)) | 44 | + .then(Review => res.send(Review)) |
36 | .catch(err => res.status(500).send(err)); | 45 | .catch(err => res.status(500).send(err)); |
37 | }); | 46 | }); |
38 | 47 | ||
39 | -// Delete by reviewid | 48 | +// Delete by lecturename |
40 | -router.delete('/reviewid/:reviewid', (req, res) => { | 49 | +router.delete('/lecturename/:lecturename', (req, res) => { |
41 | - Review.deleteByreviewid(req.params.reviewid) | 50 | + Review.deleteBylecturename(req.params.lecturename) |
42 | .then(() => res.sendStatus(200)) | 51 | .then(() => res.sendStatus(200)) |
43 | .catch(err => res.status(500).send(err)); | 52 | .catch(err => res.status(500).send(err)); |
44 | }); | 53 | }); | ... | ... |
test.png
0 → 100644
334 KB
-
Please register or login to post a comment