Commit d0ed12bb authored by Lee SeoYeon's avatar Lee SeoYeon
Browse files

Merge remote-tracking branch 'origin/BAE' into lsy

parents 5e8130f8 1b46e125
This diff is collapsed.
......@@ -30,12 +30,12 @@ function Place(props) {
aria-labelledby="example-modal-sizes-title-lg">
<Modal.Header closeButton>
<Modal.Title id="contained-modal-title-vcenter" style={{ fontSize: '40px' }}>
{props.index + 1}. {props.place.name}
{props.place.name}
</Modal.Title>
</Modal.Header>
<Modal.Body className="show-grid">
<Container style={{ fontSize: '40px' }}>
{Array.isArray(reviews) ? reviews.map((review, index) => {
{Array.isArray(reviews) ? reviews.map((review) => {
return (
<Row className="mt-4">
<a href={review.link}>{review.title}</a>
......
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import { Redirect } from 'react-router-dom';
import ohuh from '../ohuh.PNG'
import { Container, Row, Form, Image, InputGroup, Button, Col, Nav } from 'react-bootstrap';
import { handleLogout, isAuthenticated } from '../utils/auth.js'
import ohuh from '../ohuh.PNG';
import { Container, Row, Form, Image, InputGroup, Button, Col, Card } from 'react-bootstrap';
import axios from 'axios';
import Place from '../Components/Place';
function App() {
const [state, setState] = useState(false);
const [search, setSearch] = useState("");
const user = isAuthenticated()
const [show, setShow] = useState(false);
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}`} />;
......@@ -21,23 +30,36 @@ function App() {
setState(true);
} //submit 버튼을 누르면 state 값을 true로 바뀐다
const getRecommend = () => {
axios.get(`/api/app/recommend`)
.then(res => {
setRecommend(res.data)
})
.catch(err => {
console.log("APP RECOMMEND ERROR", err)
})
}
const getLatest = () => {
axios.get(`/api/app/lastest`)
.then(res => {
setLatest(res.data)
})
.catch(err => {
console.log("APP LATEST ERROR", err)
})
}
return (
<Container className="vh-100 d-flex justify-content-md-center align-items-center">
<Col md={6} style={{ marginTop: 140 }}>
<Nav className="justify-content-end" bg="#fff" variant="light" >
{user ? <Nav.Link onClick={() => handleLogout()}>로그아웃</Nav.Link>
: (
<>
<Nav.Link href="/signup">회원가입</Nav.Link>
<Nav.Link href="/login">로그인</Nav.Link>
</>
)}
<Nav.Link href='/bookmark'>북마크</Nav.Link>
</Nav>
<Row style={{ marginBottom: 20 }}>
<Image src={ohuh} />
<Container className="vh-100 ">
<Col md={12} >
<Row className="justify-content-center" >
<Image src={ohuh} style={{ margin: "5%", marginTop : "3%" }} />
</Row>
<Row style={{ marginBottom: 500 }}>
<Row style={{ marginBottom: "5%" }}>
<Form className="vw-100" onSubmit={handleSubmit}>
<InputGroup style={{ width: 560 }}>
<Form.Control
......@@ -53,8 +75,43 @@ function App() {
</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 React, { useState, useEffect } from 'react';
import { Link, Redirect } from 'react-router-dom';
import { Link } from 'react-router-dom';
import ohuh from '../ohuh-sm.PNG';
import Place from '../Components/Place';
import { Container, Form, Row, Col, Card, Image, InputGroup, FormControl, Button, Nav } from 'react-bootstrap';
......@@ -57,9 +57,7 @@ function Search(props) {
else {
setPagePlace(paginate(association, index, 4))
}
console.log("뿌릴 data1", pagePlace)
setEndPage(Math.floor((association.length / 4)))
console.log("7489309484839",endPage)
}, [association, index])
......
import Places from '../models/Place.js'
const searchRecommend = async (req, res, next,) => {
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
});
res.send(result[0])
}
const searchLatest = async (req, res, next) => {
let responseLatest = await Places.find({}).sort({ updatedAt: -1 })
res.send(responseLatest[0])
}
export default { searchRecommend, searchLatest }
import Places from '../models/Place.js'
import cheerio from 'cheerio'
// import fs from 'fs'
import axios from 'axios';
import { nextTick } from 'process';
const searchPlace = async (req, res, next,) => {
let DuplicateCheckPlace = await Places.findOne({ name: req.query.keyword })
req.places = DuplicateCheckPlace
if (DuplicateCheckPlace) {
console.log("11111111111111111111111Place################ 기존플레이스줄력중")
}
else {
console.log("2222222222222222222222222222222222222222222222222222222")
const url = "https://search.naver.com/search.naver?sm=tab_hty.top&where=nexearch&query=" + encodeURI(req.query.keyword)
const editUrl = /(http(s)?:\/\/)([a-z0-9\w]+\.*)+[a-z0-9]{2,4}/gi
const { data: html } = await axios.get(url)
......@@ -34,7 +30,6 @@ const searchImg = async (req, res, next) => {
if (req.places.img !== "https://t1.daumcdn.net/thumb/R600x0/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fqna%2Fimage%2F4b035cdf8372d67108f7e8d339660479dfb41bbd") {
console.log("333333333333333333333333333IMG@@@@@@@@@@@@@@@@@@@ 기존이미지줄력중")
req.places.times.push(new Date().toLocaleString())
const newPlaces = await new Places(req.places).save()
next()
......@@ -43,18 +38,12 @@ const searchImg = async (req, res, next) => {
axios.get(imgUrl)
.then(async (response) => {
console.log("4444444444444444444444444444444444444444444444444새로운 이미지 출력중")
const html = response.data
let name = req.query.keyword
let $1 = cheerio.load(html);
let images = $1('.RAyV4b').find('img').attr('src')
req.places.img = images
console.log("4141414141414141", req.places)
//사진만 업데이트
// let Place2 = await Places.findOne({ name: req.query.keyword })
req.places.times.push(new Date().toLocaleString())
// await Places.updateOne({ name: req.query.keyword }, { img: images, times: Place2.times })
// res.send(images)
const newPlaces = await new Places(req.places).save()
next()
})
......@@ -65,7 +54,6 @@ const searchImg = async (req, res, next) => {
const searchAssociation = async (req, res) => {
let Place3 = req.places.address
if (!Place3) {
console.log("asdfasdfasdf222222222222222222dsaf2222222222214123q5", Place3)
res.send({ error: "Place.address is null" })
}
else {
......@@ -73,8 +61,6 @@ const searchAssociation = async (req, res) => {
let AssociationsId = []
let addressPlaces = new RegExp(`${addresse}`)
let responsePlaces = await Places.find({ address: addressPlaces }).sort({ updatedAt: -1 })
//몽구스나 몽고디비에 있는 sort 확인해보고 나열하기.
// console.log("$$$$$$$$$$$4", responsePlaces)
res.send(responsePlaces)
}
}
......
import express from 'express'
import app from '../controllers/app.controller.js'
const router = express.Router()
router.route('/api/app/recommend')
.get(app.searchRecommend)
router.route('/api/app/lastest')
.get(app.searchLatest)
export default router
\ No newline at end of file
......@@ -4,6 +4,7 @@ import placeRouter from './routes/place.routes.js'
import reviewRouter from './routes/review.routes.js'
import userRouter from "./routes/user.routes.js"
import authRouter from "./routes/auth.routes.js"
import appRouter from './routes/app.router.js'
connectDb()
......@@ -15,6 +16,12 @@ app.use(placeRouter)
app.use(reviewRouter)
app.use(userRouter)
app.use(authRouter)
app.use(appRouter)
app.get('/', (req, res) => {
console.log("/ req.body", req.body)
res.json({ message: "http://localhost3001/ 에 연결됨" })
})
app.listen(3001, () => {
console.log('Listening on port 3001')
......
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