티스토리 뷰
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | package texas.sbq.travel.services; import java.util.HashMap; import java.util.List; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.select.Elements; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import texas.sbq.travel.domains.Article; import texas.sbq.travel.domains.Pager; import texas.sbq.travel.domains.Tourism; import texas.sbq.travel.mappers.ArticleMapper; import texas.sbq.travel.services.ArticleService; import texas.sbq.travel.utils.Box; import texas.sbq.travel.utils.Inventory; import texas.sbq.travel.utils.Printer; @Service public class ArticleService implements IService{ @Autowired ArticleMapper articleMapper; @Autowired Box<String> box; @Autowired Article article; @Autowired Printer printer; @Autowired Inventory<HashMap<String,String>> inventory; @Override public void save(Object o) { articleMapper.insert((Article)o);} @Override public String count(Object o) { return articleMapper.count();} @Override public Article detail(Object o) { return articleMapper.selectById(String.valueOf(o));} @Override public List<?> list(Object o){ return articleMapper.select((Pager) o);} @Override public void edit(Object o) { articleMapper.update((Article)o);} @Override public void remove(Object o) { articleMapper.delete(String.valueOf(o));} public void create() { articleMapper.create();} public String favors(String articleSeq) {return articleMapper.countById(articleSeq);} public String rating(String hotelSeq) { return articleMapper.selectRatingById(hotelSeq);} @Transactional public List<?> initialize() { // String url = "https://store.naver.com/attractions/detail?entry=plt&id=38345004&query=%EB%82%A8%EC%82%B0%EC%84%9C%EC%9A%B8%ED%83%80%EC%9B%8C&tab=fsasReview"; inventory.clear(); try { Document rawData = Jsoup.connect(url).timeout(10 * 1000).get(); Elements title = rawData.select("div[class=tit] a"); Elements content = rawData.select("div[class=txt ellp2]"); Elements img = rawData.select("div[class=thumb]"); HashMap<String, String> map = null; for(int i = 0; i<title.size();i++) { map = new HashMap<String, String>(); map.put("title", title.get(i).text()); map.put("content", content.get(i).text()); map.put("img", img.get(i).select("img").attr("src")); article.setImage(img.get(i).select("img").attr("src")); article.setTitle(title.get(i).text()); article.setContent(content.get(i).text()); article.setUserid("hong"); articleMapper.insert(article); inventory.add(map); } } catch (Exception e) { e.printStackTrace(); } System.out.println(inventory+"1111"); return inventory.get(); } } | cs |
'0. 정보통신' 카테고리의 다른 글
[스프링] 메이븐 설정 프로퍼티 (0) | 2020.06.23 |
---|---|
[스프링부트] AWS CORS 이슈 ... 리액트 부분과 Controller #35 (0) | 2020.06.18 |
82537 트래블 ArticleController.java (0) | 2020.06.02 |
81540. 마이바티스 템플릿 (0) | 2020.05.29 |
82540. 인텔리제이 스프링부트(spring boot) + 마이바티스(mybatis) + 하이버네이트(JPA) 최소 설정파일들 (0) | 2020.05.27 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Django
- React
- Mlearn
- database
- terms
- ERD
- intellij
- Mongo
- Python
- FLASK
- springMVC
- docker
- Algorithm
- Git
- tensorflow
- AWS
- Java
- jQuery
- mariadb
- KAFKA
- JUnit
- JPA
- nodejs
- COLAB
- SQLAlchemy
- vscode
- Oracle
- maven
- SpringBoot
- Eclipse
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
글 보관함