Commit 976e06e2 authored by baesangjune's avatar baesangjune
Browse files

최근 검색 관광지 인기 관광지 추가

parent 3b1cee1e
[{"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":1624,"mtime":1611724576486,"results":"10","hashOfConfig":"8"},{"size":3724,"mtime":1611712847775,"results":"11","hashOfConfig":"8"},{"size":7890,"mtime":1611722257117,"results":"12","hashOfConfig":"8"},{"size":4169,"mtime":1611724518616,"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":7,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"25","messages":"26","errorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"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 <React.StrictMode>\r\n <Router>\r\n <Switch>\r\n <Route exact path=\"/\" component={App} />\r\n <Route path=\"/search\" component={Search} />\r\n <Redirect path=\"/search\" to=\"/search\" />\r\n </Switch>\r\n </Router>\r\n </React.StrictMode>,\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","36"],"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Pages\\App.js",["37"],{"ruleId":"38","severity":1,"message":"39","line":7,"column":8,"nodeType":"40","messageId":"41","endLine":7,"endColumn":13},{"ruleId":"38","severity":1,"message":"42","line":7,"column":14,"nodeType":"40","messageId":"41","endLine":7,"endColumn":19},{"ruleId":"43","severity":1,"message":"44","line":21,"column":6,"nodeType":"45","endLine":21,"endColumn":8,"suggestions":"46"},{"ruleId":"38","severity":1,"message":"47","line":2,"column":16,"nodeType":"40","messageId":"41","endLine":2,"endColumn":24},{"ruleId":"38","severity":1,"message":"48","line":16,"column":12,"nodeType":"40","messageId":"41","endLine":16,"endColumn":18},{"ruleId":"43","severity":1,"message":"49","line":44,"column":8,"nodeType":"45","endLine":44,"endColumn":10,"suggestions":"50"},{"ruleId":"43","severity":1,"message":"51","line":65,"column":8,"nodeType":"45","endLine":65,"endColumn":15,"suggestions":"52"},{"ruleId":"38","severity":1,"message":"53","line":68,"column":11,"nodeType":"40","messageId":"41","endLine":68,"endColumn":17},{"ruleId":"38","severity":1,"message":"54","line":133,"column":9,"nodeType":"40","messageId":"41","endLine":133,"endColumn":13},{"ruleId":"55","severity":1,"message":"56","line":138,"column":35,"nodeType":"57","endLine":138,"endColumn":76},{"ruleId":"58","severity":2,"message":"59","line":49,"column":5,"nodeType":"40","endLine":49,"endColumn":14},"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",["60"],"'Redirect' is defined but never used.","'mobile' is assigned a value but never used.","React Hook useEffect has a missing dependency: 'getAssociation'. Either include it or remove the dependency array.",["61"],"React Hook useEffect has missing dependencies: 'getAssociation', 'props.history', and 'search'. Either include them or remove the dependency array.",["62"],"'places' is assigned a value but never used.","'time' is assigned a value but never used.","react/jsx-no-duplicate-props","No duplicate props allowed","JSXAttribute","react-hooks/rules-of-hooks","React Hook \"useEffect\" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?",{"desc":"63","fix":"64"},{"desc":"65","fix":"66"},{"desc":"67","fix":"68"},"Update the dependencies array to be: [getReview]",{"range":"69","text":"70"},"Update the dependencies array to be: [getAssociation]",{"range":"71","text":"72"},"Update the dependencies array to be: [getAssociation, props.history, search, state]",{"range":"73","text":"74"},[605,607],"[getReview]",[1573,1575],"[getAssociation]",[2133,2140],"[getAssociation, props.history, search, state]"]
\ 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":1624,"mtime":1611724576486,"results":"10","hashOfConfig":"8"},{"size":3724,"mtime":1611712847775,"results":"11","hashOfConfig":"8"},{"size":7890,"mtime":1611730328216,"results":"12","hashOfConfig":"8"},{"size":4190,"mtime":1611732347337,"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":"21"},{"filePath":"22","messages":"23","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"24","messages":"25","errorCount":0,"warningCount":7,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"26","messages":"27","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\index.js",["28"],"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 <React.StrictMode>\r\n <Router>\r\n <Switch>\r\n <Route exact path=\"/\" component={App} />\r\n <Route path=\"/search\" component={Search} />\r\n <Redirect path=\"/search\" to=\"/search\" />\r\n </Switch>\r\n </Router>\r\n </React.StrictMode>,\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",["29","30"],"import axios from 'axios';\r\nimport React, { useEffect, useState } from 'react';\r\nimport { Modal, Container, Row, Button, } from 'react-bootstrap';\r\n\r\nfunction Place(props) {\r\n const [reviews, setReviews] = useState()\r\n const [db, setDb] = useState(false)\r\n const getReview = () => {\r\n axios({ url: `/api/review?keyword=${props.place.name}`, method: 'post', data: { db: db } })\r\n .then(res => {\r\n console.log(\"place res.data\", res.data)\r\n setReviews(res.data)\r\n })\r\n .catch(err => {\r\n console.log(err)\r\n })\r\n }\r\n\r\n useEffect(() => {\r\n getReview();\r\n }, [])\r\n\r\n return (\r\n <Modal {...props}\r\n size=\"xl\"\r\n keyboard=\"true\"\r\n variant=\"backdrop.in\"\r\n aria-labelledby=\"example-modal-sizes-title-lg\">\r\n <Modal.Header closeButton>\r\n <Modal.Title id=\"contained-modal-title-vcenter\" style={{ fontSize: '40px' }}>\r\n {props.place.name}\r\n </Modal.Title>\r\n </Modal.Header>\r\n <Modal.Body className=\"show-grid\">\r\n <Container style={{ fontSize: '40px' }}>\r\n {Array.isArray(reviews) ? reviews.map((review) => {\r\n return (\r\n <Row className=\"mt-4\">\r\n <a href={review.link}>{review.title}</a>\r\n <div>{review.summary}</div>\r\n <div>{review.content}</div>\r\n </Row>\r\n )\r\n })\r\n : \"리뷰가 없습니다.\"}\r\n </Container>\r\n\r\n </Modal.Body>\r\n <Modal.Footer>\r\n <Button block onClick={props.onHide}>Close</Button>\r\n </Modal.Footer>\r\n </Modal>\r\n );\r\n}\r\n\r\nexport default Place;\r\n","C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Components\\Paginations.js",[],"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Pages\\Search.js",["31","32","33","34","35","36","37"],"C:\\Users\\노트북펜\\Desktop\\2021YDK\\search-page\\client\\src\\Pages\\App.js",[],{"ruleId":"38","severity":1,"message":"39","line":7,"column":8,"nodeType":"40","messageId":"41","endLine":7,"endColumn":13},{"ruleId":"38","severity":1,"message":"42","line":7,"column":14,"nodeType":"40","messageId":"41","endLine":7,"endColumn":19},{"ruleId":"43","severity":1,"message":"44","line":21,"column":6,"nodeType":"45","endLine":21,"endColumn":8,"suggestions":"46"},{"ruleId":"38","severity":1,"message":"47","line":2,"column":16,"nodeType":"40","messageId":"41","endLine":2,"endColumn":24},{"ruleId":"38","severity":1,"message":"48","line":16,"column":12,"nodeType":"40","messageId":"41","endLine":16,"endColumn":18},{"ruleId":"43","severity":1,"message":"49","line":44,"column":8,"nodeType":"45","endLine":44,"endColumn":10,"suggestions":"50"},{"ruleId":"43","severity":1,"message":"51","line":65,"column":8,"nodeType":"45","endLine":65,"endColumn":15,"suggestions":"52"},{"ruleId":"38","severity":1,"message":"53","line":68,"column":11,"nodeType":"40","messageId":"41","endLine":68,"endColumn":17},{"ruleId":"38","severity":1,"message":"54","line":133,"column":9,"nodeType":"40","messageId":"41","endLine":133,"endColumn":13},{"ruleId":"55","severity":1,"message":"56","line":138,"column":35,"nodeType":"57","endLine":138,"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",["58"],"'Redirect' is defined but never used.","'mobile' is assigned a value but never used.","React Hook useEffect has a missing dependency: 'getAssociation'. Either include it or remove the dependency array.",["59"],"React Hook useEffect has missing dependencies: 'getAssociation', 'props.history', and 'search'. Either include them or remove the dependency array.",["60"],"'places' is assigned a value but never used.","'time' is assigned a value but never used.","react/jsx-no-duplicate-props","No duplicate props allowed","JSXAttribute",{"desc":"61","fix":"62"},{"desc":"63","fix":"64"},{"desc":"65","fix":"66"},"Update the dependencies array to be: [getReview]",{"range":"67","text":"68"},"Update the dependencies array to be: [getAssociation]",{"range":"69","text":"70"},"Update the dependencies array to be: [getAssociation, props.history, search, state]",{"range":"71","text":"72"},[605,607],"[getReview]",[1573,1575],"[getAssociation]",[2133,2140],"[getAssociation, props.history, search, state]"]
\ No newline at end of file
......@@ -12,11 +12,16 @@ function App() {
const [recommend, setRecommend] = useState([{ name: " ", address: " ", img: " " }]);
const [latest, setLatest] = useState([{ name: " ", address: " ", img: " " }]);
useEffect(() => {
getRecommend()
getLatest()
}, []);
if (state !== false) {
return <Redirect to={`/search?keyword=${search}`} />;
}
const handleChange = (e) => {
setSearch(e.target.value);
}
......@@ -43,74 +48,70 @@ function App() {
.catch(err => {
console.log("APP LATEST ERROR", err)
})
}
useEffect(() => {
getRecommend()
getLatest()
}, []);
}
return (
<>
<Container className="vh-100 ">
<Col md={12} >
<Row className="justify-content-center" style={{ margin: "8%" }}>
<Image src={ohuh} />
</Row>
<Row style={{ marginBottom: "10%"}}>
<Form className="vw-100" onSubmit={handleSubmit}>
<InputGroup>
<Form.Control
size="lg"
placeholder="검색어를 입력하세요."
aria-label="Large"
aria-describedby="inputGroup-sizing-sm"
onChange={handleChange}
/>
<InputGroup.Append>
<Button type='submit' variant="outline-secondary">검색</Button>
</InputGroup.Append>
</InputGroup>
</Form>
</Row>
<Row>
<Col md={6} >
<h1>인기관광지</h1>
<Card align="center" border="info" style={{ margin: "3%" }}>
<Card.Title style={{ margin: "3%", fontSize: '200%', fontWeight: 'bold' }} >{recommend.name}</Card.Title>
<Card.Img variant="top" style={{ padding: "5%", width: "100%", height: "340px" }} src={recommend.img} />
<Card.Body >
<Card.Text style={{ overflow: 'auto', fontSize: '25px', width: '100%', height: "80px" }} >
{recommend.address} </Card.Text>
<Button variant="primary" onClick={() => {
setShow(true)
}}>{recommend.name} 자세히 살펴보기</Button>
<Place place={recommend} show={show} onHide={() => setShow(false)} />
</Card.Body>
</Card>
</Col>
<Col md={6} >
<h1>최근 검색관광지</h1>
<Card align="center" border="info" style={{ margin: "3%" }}>
<Card.Title style={{ margin: "3%", fontSize: '200%', fontWeight: 'bold' }} >{latest.name}</Card.Title>
<Card.Img variant="top" style={{ padding: "5%", width: "100%", height: "340px" }} src={latest.img} />
<Card.Body >
<Card.Text style={{ overflow: 'auto', fontSize: '25px', width: '100%', height: "80px" }} >
{latest.address} </Card.Text>
<Button variant="primary" onClick={() => {
setShow(true)
}}>{latest.name} 자세히 살펴보기</Button>
<Place place={latest} show={show} onHide={() => setShow(false)} />
</Card.Body>
</Card>
</Col>
</Row>
</Col>
</Container>
</>
<Container className="vh-100 ">
<Col md={12} >
<Row className="justify-content-center" >
<Image src={ohuh} style={{ margin: "5%", marginTop : "3%" }} />
</Row>
<Row style={{ marginBottom: "5%" }}>
<Form className="vw-100" onSubmit={handleSubmit}>
<InputGroup>
<Form.Control
size="lg"
placeholder="검색어를 입력하세요."
aria-label="Large"
aria-describedby="inputGroup-sizing-sm"
onChange={handleChange}
/>
<InputGroup.Append>
<Button type='submit' variant="outline-secondary">검색</Button>
</InputGroup.Append>
</InputGroup>
</Form>
</Row>
<Row >
<Col md={6} >
<h1 className=" d-flex justify-content-center" style={{marginBottom:"7%"}}>인기관광지</h1>
<Card align="center" border="info" style={{ margin: "3%" }}>
<Card.Title style={{ margin: "3%", fontSize: '200%', fontWeight: 'bold' }} >{recommend.name}</Card.Title>
<Card.Img variant="top" style={{ padding: "5%", width: "100%", height: "340px" }} src={recommend.img} />
<Card.Body >
<Card.Text style={{ overflow: 'auto', fontSize: '25px', width: '100%', height: "80px" }} >
{recommend.address} </Card.Text>
<Button variant="primary" onClick={() => {
setShow(true)
}}>{recommend.name} 자세히 살펴보기</Button>
<Place place={recommend} show={show} onHide={() => setShow(false)} />
</Card.Body>
</Card>
</Col>
<Col md={6} >
<h1 className=" d-flex justify-content-center" style={{marginBottom:"7%"}}>최근 검색관광지</h1>
<Card align="center" border="info" style={{ margin: "3%" }}>
<Card.Title style={{ margin: "3%", fontSize: '200%', fontWeight: 'bold' }} >{latest.name}</Card.Title>
<Card.Img variant="top" style={{ padding: "5%", width: "100%", height: "340px" }} src={latest.img} />
<Card.Body >
<Card.Text style={{ overflow: 'auto', fontSize: '25px', width: '100%', height: "80px" }} >
{latest.address} </Card.Text>
<Button variant="primary" onClick={() => {
setShow(true)
}}>{latest.name} 자세히 살펴보기</Button>
<Place place={latest} show={show} onHide={() => setShow(false)} />
</Card.Body>
</Card>
</Col>
</Row>
</Col>
</Container>
);
}
......
import Places from '../models/Place.js'
import cheerio from 'cheerio'
import axios from 'axios';
const searchRecommend = async (req, res, next,) => {
let responseRecommend = await Places.find({}).sort({updatedAt:-1})
res.send(responseRecommend[0])
let responseRecommend = await Places.aggregate([
{
$project: {
name:1,
address:1,
img:1,
timeslength: { $cond: { if: { $isArray: "$times" }, then: { $size: "$times" }, else: 'NA' } }
}
}
])
let result = responseRecommend.sort((a, b) => {
return b.timeslength-a.timeslength
});
//이거는 정렬까지는 아니고 개수 세주는거 같음. 따라서 정렬은 다시해줄 필요 있는듯
// console.log("aggregate", responseRecommend.find().sort({"timeslength":1}))
console.log("ddddddddddddd", result[0])
res.send(result[0])
}
const searchLatest = async (req, res, next) => {
let responseLatest = await Places.find({})
let responseLatest = await Places.find({}).sort({ updatedAt: -1 })
res.send(responseLatest[0])
......
......@@ -8,7 +8,7 @@ const router = express.Router()
router.route('/api/app/recommend')
.get(app.searchRecommend)
router.route('/api/app/latest')
router.route('/api/app/lastest')
.get(app.searchLatest)
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