diff --git a/client/.eslintcache b/client/.eslintcache index 0edf16040ce7cfd5f8b44dce9658793056c14844..8eea89876854b3c6da2ffc7d5c6b05bd6e460c01 100644 --- a/client/.eslintcache +++ b/client/.eslintcache @@ -1 +1 @@ -[{"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\index.js":"1","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\reportWebVitals.js":"2","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Components\\Place.js":"3","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Components\\Paginations.js":"4","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Pages\\Search.js":"5","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Pages\\App.js":"6"},{"size":939,"mtime":1611497444385,"results":"7","hashOfConfig":"8"},{"size":375,"mtime":1611254909401,"results":"9","hashOfConfig":"8"},{"size":1650,"mtime":1611504929008,"results":"10","hashOfConfig":"8"},{"size":2199,"mtime":1611254909395,"results":"11","hashOfConfig":"8"},{"size":7536,"mtime":1611512487907,"results":"12","hashOfConfig":"8"},{"size":1474,"mtime":1611504101870,"results":"13","hashOfConfig":"8"},{"filePath":"14","messages":"15","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"16"},"13y9yvi",{"filePath":"17","messages":"18","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"19","messages":"20","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"21","messages":"22","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"23","messages":"24","errorCount":0,"warningCount":6,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"25","messages":"26","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\index.js",["27"],"import React from 'react';\r\nimport ReactDOM from 'react-dom';\r\nimport './index.css';\r\nimport 'bootstrap/dist/css/bootstrap.min.css';\r\nimport App from './Pages/App';\r\nimport Search from './Pages/Search';\r\nimport axios from 'axios';\r\nimport reportWebVitals from './reportWebVitals';\r\nimport {\r\n BrowserRouter as Router,\r\n Switch,\r\n Route,\r\n Redirect,\r\n} from \"react-router-dom\";\r\n\r\nReactDOM.render(\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ,\r\n document.getElementById('root')\r\n);\r\n\r\n// If you want to start measuring performance in your app, pass a function\r\n// to log results (for example: reportWebVitals(console.log))\r\n// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals\r\nreportWebVitals();\r\n","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\reportWebVitals.js",[],"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Components\\Place.js",["28","29"],"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Components\\Paginations.js",[],"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Pages\\Search.js",["30","31","32","33","34","35"],"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Pages\\App.js",[],{"ruleId":"36","severity":1,"message":"37","line":7,"column":8,"nodeType":"38","messageId":"39","endLine":7,"endColumn":13},{"ruleId":"36","severity":1,"message":"40","line":7,"column":14,"nodeType":"38","messageId":"39","endLine":7,"endColumn":19},{"ruleId":"41","severity":1,"message":"42","line":21,"column":6,"nodeType":"43","endLine":21,"endColumn":8,"suggestions":"44"},{"ruleId":"36","severity":1,"message":"45","line":16,"column":12,"nodeType":"38","messageId":"39","endLine":16,"endColumn":18},{"ruleId":"36","severity":1,"message":"46","line":17,"column":12,"nodeType":"38","messageId":"39","endLine":17,"endColumn":17},{"ruleId":"36","severity":1,"message":"47","line":18,"column":12,"nodeType":"38","messageId":"39","endLine":18,"endColumn":18},{"ruleId":"41","severity":1,"message":"48","line":68,"column":8,"nodeType":"43","endLine":68,"endColumn":10,"suggestions":"49"},{"ruleId":"36","severity":1,"message":"50","line":75,"column":11,"nodeType":"38","messageId":"39","endLine":75,"endColumn":17},{"ruleId":"51","severity":1,"message":"52","line":133,"column":35,"nodeType":"53","endLine":133,"endColumn":76},"no-unused-vars","'axios' is defined but never used.","Identifier","unusedVar","'setDb' is assigned a value but never used.","react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'getReview'. Either include it or remove the dependency array.","ArrayExpression",["54"],"'mobile' is assigned a value but never used.","'place' is assigned a value but never used.","'imgUrl' is assigned a value but never used.","React Hook useEffect has missing dependencies: 'getAssociation', 'getImg', and 'getPlace'. Either include them or remove the dependency array.",["55"],"'places' is assigned a value but never used.","react/jsx-no-duplicate-props","No duplicate props allowed","JSXAttribute",{"desc":"56","fix":"57"},{"desc":"58","fix":"59"},"Update the dependencies array to be: [getReview]",{"range":"60","text":"61"},"Update the dependencies array to be: [getAssociation, getImg, getPlace]",{"range":"62","text":"63"},[605,607],"[getReview]",[2260,2262],"[getAssociation, getImg, getPlace]"] \ No newline at end of file +[{"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\index.js":"1","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\reportWebVitals.js":"2","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Components\\Place.js":"3","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Components\\Paginations.js":"4","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Pages\\Search.js":"5","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Pages\\App.js":"6"},{"size":939,"mtime":1611497444385,"results":"7","hashOfConfig":"8"},{"size":375,"mtime":1611254909401,"results":"9","hashOfConfig":"8"},{"size":1650,"mtime":1611504929008,"results":"10","hashOfConfig":"8"},{"size":2199,"mtime":1611254909395,"results":"11","hashOfConfig":"8"},{"size":8492,"mtime":1611514455100,"results":"12","hashOfConfig":"8"},{"size":1474,"mtime":1611504101870,"results":"13","hashOfConfig":"8"},{"filePath":"14","messages":"15","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"16"},"13y9yvi",{"filePath":"17","messages":"18","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"19","messages":"20","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"21","messages":"22","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"23","messages":"24","errorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"25","messages":"26","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\index.js",["27"],"import React from 'react';\r\nimport ReactDOM from 'react-dom';\r\nimport './index.css';\r\nimport 'bootstrap/dist/css/bootstrap.min.css';\r\nimport App from './Pages/App';\r\nimport Search from './Pages/Search';\r\nimport axios from 'axios';\r\nimport reportWebVitals from './reportWebVitals';\r\nimport {\r\n BrowserRouter as Router,\r\n Switch,\r\n Route,\r\n Redirect,\r\n} from \"react-router-dom\";\r\n\r\nReactDOM.render(\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ,\r\n document.getElementById('root')\r\n);\r\n\r\n// If you want to start measuring performance in your app, pass a function\r\n// to log results (for example: reportWebVitals(console.log))\r\n// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals\r\nreportWebVitals();\r\n","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\reportWebVitals.js",[],"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Components\\Place.js",["28","29"],"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Components\\Paginations.js",[],"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Pages\\Search.js",["30"],"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Pages\\App.js",[],{"ruleId":"31","severity":1,"message":"32","line":7,"column":8,"nodeType":"33","messageId":"34","endLine":7,"endColumn":13},{"ruleId":"31","severity":1,"message":"35","line":7,"column":14,"nodeType":"33","messageId":"34","endLine":7,"endColumn":19},{"ruleId":"36","severity":1,"message":"37","line":21,"column":6,"nodeType":"38","endLine":21,"endColumn":8,"suggestions":"39"},{"ruleId":null,"fatal":true,"severity":2,"message":"40","line":21,"column":4},"no-unused-vars","'axios' is defined but never used.","Identifier","unusedVar","'setDb' is assigned a value but never used.","react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'getReview'. Either include it or remove the dependency array.","ArrayExpression",["41"],"Parsing error: Unexpected token\n\n 19 | const [association, setAssociation] = useState([])\n 20 | \n> 21 | <<<<<<< HEAD\n | ^\n 22 | // console.log(\"search###############\", search)\n 23 | const getPlace = () => {\n 24 | axios.get(`/api/search/places?keyword=${search}`)",{"desc":"42","fix":"43"},"Update the dependencies array to be: [getReview]",{"range":"44","text":"45"},[605,607],"[getReview]"] \ No newline at end of file diff --git a/client/src/Pages/Search.js b/client/src/Pages/Search.js index 9e28553c2e52c57d8508b28b2ed26f485c5983af..49b847716c1eee666e347e9bfc5762c3782d9c69 100644 --- a/client/src/Pages/Search.js +++ b/client/src/Pages/Search.js @@ -65,11 +65,13 @@ function Search(props) { } else { setMobile(false) } - }, []); - - - + if (state) { + props.history.push('/search?keyword=' + search) + setState(false) + console.log("search야", search) + } + }, [search]); const places = [{ @@ -95,10 +97,14 @@ function Search(props) { }] if (state !== false) { - return ; + // console.log(queryString.parse(props.location.search)) + // = {keyword:search} + // return ; + // history.pushState(null, null, "?"+queryParams.toString()); + // return ; } const handlePage = (num) => { @@ -111,6 +117,7 @@ function Search(props) { } const handleSubmit = (e) => { + // e.preventDefault() setState(true); } diff --git a/server/controllers/place.controller.js b/server/controllers/place.controller.js index 5256c82046f3f0427dd117fb6f98302674c5008e..0db04b357337f9a0a111ce51c053bbc220438e0c 100644 --- a/server/controllers/place.controller.js +++ b/server/controllers/place.controller.js @@ -37,32 +37,34 @@ const searchImg = async (req, res) => { let DuplicateCheckImg = await Places.findOne({ name: req.query.keyword }) + if (DuplicateCheckImg) { + if (DuplicateCheckImg.img !== "https://t1.daumcdn.net/thumb/R600x0/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fqna%2Fimage%2F4b035cdf8372d67108f7e8d339660479dfb41bbd") { + res.send(DuplicateCheckImg) + console.log("333333333333333333333333333IMG@@@@@@@@@@@@@@@@@@@ 기존이미지줄력중") + } + else if (DuplicateCheckImg.img === "https://t1.daumcdn.net/thumb/R600x0/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fqna%2Fimage%2F4b035cdf8372d67108f7e8d339660479dfb41bbd") { + console.log("4444444444444444444444444444444444444444444444444") + const imgUrl = "https://www.google.com/search?q=" + encodeURI(req.query.keyword) + "+site:tistory.com/&sxsrf=ALeKk023Dv08KQDodRmpB5222lQuzw2Vaw:1610612821100&source=lnms&tbm=isch" + + axios.get(imgUrl) + .then(async (response) => { + const html = response.data + let name = req.query.keyword + let $1 = cheerio.load(html); + + let images = $1('.RAyV4b').find('img').attr('src') + + //사진만 업데이트 + let Place = await Places.findOne({ name: req.query.keyword }) + Place.times.push(new Date().toLocaleString()) + await Places.updateOne({ name: req.query.keyword }, { img: images, times: Place.times }) + + res.send(images) + }) - if (DuplicateCheckImg.img !== "https://t1.daumcdn.net/thumb/R600x0/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fqna%2Fimage%2F4b035cdf8372d67108f7e8d339660479dfb41bbd") { - res.send(DuplicateCheckImg) - console.log("333333333333333333333333333IMG@@@@@@@@@@@@@@@@@@@ 기존이미지줄력중") - } - else if (DuplicateCheckImg.img === "https://t1.daumcdn.net/thumb/R600x0/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fqna%2Fimage%2F4b035cdf8372d67108f7e8d339660479dfb41bbd") { - console.log("4444444444444444444444444444444444444444444444444") - const imgUrl = "https://www.google.com/search?q=" + encodeURI(req.query.keyword) + "+site:tistory.com/&sxsrf=ALeKk023Dv08KQDodRmpB5222lQuzw2Vaw:1610612821100&source=lnms&tbm=isch" - - axios.get(imgUrl) - .then(async (response) => { - const html = response.data - let name = req.query.keyword - let $1 = cheerio.load(html); - - let images = $1('.RAyV4b').find('img').attr('src') - - //사진만 업데이트 - let Place = await Places.findOne({ name: req.query.keyword }) - Place.times.push(new Date().toLocaleString()) - await Places.updateOne({ name: req.query.keyword }, { img: images, times: Place.times }) - res.send(images) - }) - - } else { - console.log("IMG에러") + } else { + console.log("IMG에러") + } } @@ -75,13 +77,18 @@ const searchAssociation = async (req, res) => { // if (!Place) { // res.send([]) // } - let addresse = Place.address.split(' ')[0] - - let AssociationsId = [] - let addressPlaces = new RegExp(`${addresse}`) - let responsePlaces = await Places.find({ address: addressPlaces }) - res.send(responsePlaces) + if (!Place) { + res.status(404).send({ error: "Place.address is null" }) + } + else { + let addresse = Place.address.split(' ')[0] + let AssociationsId = [] + let addressPlaces = new RegExp(`${addresse}`) + console.log("여기보세요", addressPlaces) + let responsePlaces = await Places.find({ address: addressPlaces }) + res.send(responsePlaces) + } // responsePlaces.map(Association => { // AssociationsId.push(Association._id) // })